PackageManager.java revision 4efb8b4030157dd7445bed37538044949b0641af
1/* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.content.pm; 18 19import android.Manifest; 20import android.annotation.CheckResult; 21import android.annotation.DrawableRes; 22import android.annotation.IntDef; 23import android.annotation.NonNull; 24import android.annotation.Nullable; 25import android.annotation.RequiresPermission; 26import android.annotation.SdkConstant; 27import android.annotation.SdkConstant.SdkConstantType; 28import android.annotation.StringRes; 29import android.annotation.SystemApi; 30import android.annotation.XmlRes; 31import android.app.PackageDeleteObserver; 32import android.app.PackageInstallObserver; 33import android.app.admin.DevicePolicyManager; 34import android.content.ComponentName; 35import android.content.Context; 36import android.content.Intent; 37import android.content.IntentFilter; 38import android.content.IntentSender; 39import android.content.pm.PackageParser.PackageParserException; 40import android.content.res.Resources; 41import android.content.res.XmlResourceParser; 42import android.graphics.Rect; 43import android.graphics.drawable.Drawable; 44import android.net.Uri; 45import android.os.Bundle; 46import android.os.Handler; 47import android.os.RemoteException; 48import android.os.UserHandle; 49import android.os.storage.VolumeInfo; 50import android.util.AndroidException; 51 52import com.android.internal.util.ArrayUtils; 53 54import java.io.File; 55import java.lang.annotation.Retention; 56import java.lang.annotation.RetentionPolicy; 57import java.util.List; 58 59/** 60 * Class for retrieving various kinds of information related to the application 61 * packages that are currently installed on the device. 62 * 63 * You can find this class through {@link Context#getPackageManager}. 64 */ 65public abstract class PackageManager { 66 67 /** 68 * This exception is thrown when a given package, application, or component 69 * name cannot be found. 70 */ 71 public static class NameNotFoundException extends AndroidException { 72 public NameNotFoundException() { 73 } 74 75 public NameNotFoundException(String name) { 76 super(name); 77 } 78 } 79 80 /** 81 * Listener for changes in permissions granted to a UID. 82 * 83 * @hide 84 */ 85 @SystemApi 86 public interface OnPermissionsChangedListener { 87 88 /** 89 * Called when the permissions for a UID change. 90 * @param uid The UID with a change. 91 */ 92 public void onPermissionsChanged(int uid); 93 } 94 95 /** 96 * As a guiding principle: 97 * <p> 98 * {@code GET_} flags are used to request additional data that may have been 99 * elided to save wire space. 100 * <p> 101 * {@code MATCH_} flags are used to include components or packages that 102 * would have otherwise been omitted from a result set by current system 103 * state. 104 */ 105 106 /** @hide */ 107 @IntDef(flag = true, value = { 108 GET_ACTIVITIES, 109 GET_RECEIVERS, 110 GET_SERVICES, 111 GET_PROVIDERS, 112 GET_INSTRUMENTATION, 113 GET_INTENT_FILTERS, 114 GET_SIGNATURES, 115 GET_META_DATA, 116 GET_GIDS, 117 GET_SHARED_LIBRARY_FILES, 118 GET_URI_PERMISSION_PATTERNS, 119 GET_PERMISSIONS, 120 GET_CONFIGURATIONS, 121 MATCH_UNINSTALLED_PACKAGES, 122 MATCH_DISABLED_COMPONENTS, 123 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 124 MATCH_DEBUG_TRIAGED_MISSING, 125 }) 126 @Retention(RetentionPolicy.SOURCE) 127 public @interface PackageInfoFlags {} 128 129 /** @hide */ 130 @IntDef(flag = true, value = { 131 GET_META_DATA, 132 GET_SHARED_LIBRARY_FILES, 133 MATCH_UNINSTALLED_PACKAGES, 134 MATCH_SYSTEM_ONLY, 135 MATCH_DEBUG_TRIAGED_MISSING, 136 }) 137 @Retention(RetentionPolicy.SOURCE) 138 public @interface ApplicationInfoFlags {} 139 140 /** @hide */ 141 @IntDef(flag = true, value = { 142 GET_META_DATA, 143 GET_SHARED_LIBRARY_FILES, 144 MATCH_UNINSTALLED_PACKAGES, 145 MATCH_DISABLED_COMPONENTS, 146 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 147 MATCH_ALL, 148 MATCH_DEFAULT_ONLY, 149 MATCH_ENCRYPTION_AWARE, 150 MATCH_ENCRYPTION_AWARE_AND_UNAWARE, 151 MATCH_ENCRYPTION_UNAWARE, 152 MATCH_SYSTEM_ONLY, 153 MATCH_DEBUG_TRIAGED_MISSING, 154 }) 155 @Retention(RetentionPolicy.SOURCE) 156 public @interface ComponentInfoFlags {} 157 158 /** @hide */ 159 @IntDef(flag = true, value = { 160 GET_META_DATA, 161 GET_SHARED_LIBRARY_FILES, 162 GET_RESOLVED_FILTER, 163 MATCH_UNINSTALLED_PACKAGES, 164 MATCH_DISABLED_COMPONENTS, 165 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 166 MATCH_ALL, 167 MATCH_DEFAULT_ONLY, 168 MATCH_ENCRYPTION_AWARE, 169 MATCH_ENCRYPTION_AWARE_AND_UNAWARE, 170 MATCH_ENCRYPTION_UNAWARE, 171 MATCH_SYSTEM_ONLY, 172 MATCH_DEBUG_TRIAGED_MISSING, 173 }) 174 @Retention(RetentionPolicy.SOURCE) 175 public @interface ResolveInfoFlags {} 176 177 /** @hide */ 178 @IntDef(flag = true, value = { 179 GET_META_DATA, 180 }) 181 @Retention(RetentionPolicy.SOURCE) 182 public @interface PermissionInfoFlags {} 183 184 /** @hide */ 185 @IntDef(flag = true, value = { 186 GET_META_DATA, 187 }) 188 @Retention(RetentionPolicy.SOURCE) 189 public @interface PermissionGroupInfoFlags {} 190 191 /** @hide */ 192 @IntDef(flag = true, value = { 193 GET_META_DATA, 194 }) 195 @Retention(RetentionPolicy.SOURCE) 196 public @interface InstrumentationInfoFlags {} 197 198 /** 199 * {@link PackageInfo} flag: return information about 200 * activities in the package in {@link PackageInfo#activities}. 201 */ 202 public static final int GET_ACTIVITIES = 0x00000001; 203 204 /** 205 * {@link PackageInfo} flag: return information about 206 * intent receivers in the package in 207 * {@link PackageInfo#receivers}. 208 */ 209 public static final int GET_RECEIVERS = 0x00000002; 210 211 /** 212 * {@link PackageInfo} flag: return information about 213 * services in the package in {@link PackageInfo#services}. 214 */ 215 public static final int GET_SERVICES = 0x00000004; 216 217 /** 218 * {@link PackageInfo} flag: return information about 219 * content providers in the package in 220 * {@link PackageInfo#providers}. 221 */ 222 public static final int GET_PROVIDERS = 0x00000008; 223 224 /** 225 * {@link PackageInfo} flag: return information about 226 * instrumentation in the package in 227 * {@link PackageInfo#instrumentation}. 228 */ 229 public static final int GET_INSTRUMENTATION = 0x00000010; 230 231 /** 232 * {@link PackageInfo} flag: return information about the 233 * intent filters supported by the activity. 234 */ 235 public static final int GET_INTENT_FILTERS = 0x00000020; 236 237 /** 238 * {@link PackageInfo} flag: return information about the 239 * signatures included in the package. 240 */ 241 public static final int GET_SIGNATURES = 0x00000040; 242 243 /** 244 * {@link ResolveInfo} flag: return the IntentFilter that 245 * was matched for a particular ResolveInfo in 246 * {@link ResolveInfo#filter}. 247 */ 248 public static final int GET_RESOLVED_FILTER = 0x00000040; 249 250 /** 251 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData} 252 * data {@link android.os.Bundle}s that are associated with a component. 253 * This applies for any API returning a ComponentInfo subclass. 254 */ 255 public static final int GET_META_DATA = 0x00000080; 256 257 /** 258 * {@link PackageInfo} flag: return the 259 * {@link PackageInfo#gids group ids} that are associated with an 260 * application. 261 * This applies for any API returning a PackageInfo class, either 262 * directly or nested inside of another. 263 */ 264 public static final int GET_GIDS = 0x00000100; 265 266 /** 267 * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS} 268 */ 269 @Deprecated 270 public static final int GET_DISABLED_COMPONENTS = 0x00000200; 271 272 /** 273 * {@link PackageInfo} flag: include disabled components in the returned info. 274 */ 275 public static final int MATCH_DISABLED_COMPONENTS = 0x00000200; 276 277 /** 278 * {@link ApplicationInfo} flag: return the 279 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries} 280 * that are associated with an application. 281 * This applies for any API returning an ApplicationInfo class, either 282 * directly or nested inside of another. 283 */ 284 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400; 285 286 /** 287 * {@link ProviderInfo} flag: return the 288 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns} 289 * that are associated with a content provider. 290 * This applies for any API returning a ProviderInfo class, either 291 * directly or nested inside of another. 292 */ 293 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800; 294 /** 295 * {@link PackageInfo} flag: return information about 296 * permissions in the package in 297 * {@link PackageInfo#permissions}. 298 */ 299 public static final int GET_PERMISSIONS = 0x00001000; 300 301 /** 302 * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES} 303 */ 304 @Deprecated 305 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000; 306 307 /** 308 * Flag parameter to retrieve some information about all applications (even 309 * uninstalled ones) which have data directories. This state could have 310 * resulted if applications have been deleted with flag 311 * {@code DONT_DELETE_DATA} with a possibility of being replaced or 312 * reinstalled in future. 313 * <p> 314 * Note: this flag may cause less information about currently installed 315 * applications to be returned. 316 */ 317 public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000; 318 319 /** 320 * {@link PackageInfo} flag: return information about 321 * hardware preferences in 322 * {@link PackageInfo#configPreferences PackageInfo.configPreferences}, 323 * and requested features in {@link PackageInfo#reqFeatures} and 324 * {@link PackageInfo#featureGroups}. 325 */ 326 public static final int GET_CONFIGURATIONS = 0x00004000; 327 328 /** 329 * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}. 330 */ 331 @Deprecated 332 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 333 334 /** 335 * {@link PackageInfo} flag: include disabled components which are in 336 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED} 337 * in the returned info. Note that if you set this flag, applications 338 * that are in this disabled state will be reported as enabled. 339 */ 340 public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 341 342 /** 343 * Resolution and querying flag: if set, only filters that support the 344 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for 345 * matching. This is a synonym for including the CATEGORY_DEFAULT in your 346 * supplied Intent. 347 */ 348 public static final int MATCH_DEFAULT_ONLY = 0x00010000; 349 350 /** 351 * Querying flag: if set and if the platform is doing any filtering of the 352 * results, then the filtering will not happen. This is a synonym for saying 353 * that all results should be returned. 354 * <p> 355 * <em>This flag should be used with extreme care.</em> 356 */ 357 public static final int MATCH_ALL = 0x00020000; 358 359 /** 360 * Querying flag: include only components which are encryption unaware in 361 * the returned info, regardless of the current user state. 362 */ 363 public static final int MATCH_ENCRYPTION_UNAWARE = 0x00040000; 364 365 /** 366 * Querying flag: include only components which are encryption aware in the 367 * returned info, regardless of the current user state. 368 */ 369 public static final int MATCH_ENCRYPTION_AWARE = 0x00080000; 370 371 /** 372 * Querying flag: include both encryption aware and unaware components in 373 * the returned info, regardless of the current user state. 374 */ 375 public static final int MATCH_ENCRYPTION_AWARE_AND_UNAWARE = MATCH_ENCRYPTION_AWARE 376 | MATCH_ENCRYPTION_UNAWARE; 377 378 /** 379 * Querying flag: include only components from applications that are marked 380 * with {@link ApplicationInfo#FLAG_SYSTEM}. 381 */ 382 public static final int MATCH_SYSTEM_ONLY = 0x00100000; 383 384 /** 385 * Internal flag used to indicate that a system component has done their 386 * homework and verified that they correctly handle packages and components 387 * that come and go over time. In particular: 388 * <ul> 389 * <li>Apps installed on external storage, which will appear to be 390 * uninstalled while the the device is ejected. 391 * <li>Apps with encryption unaware components, which will appear to not 392 * exist while the device is locked. 393 * </ul> 394 * 395 * @see #MATCH_UNINSTALLED_PACKAGES 396 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 397 * @hide 398 */ 399 public static final int MATCH_DEBUG_TRIAGED_MISSING = 0x10000000; 400 401 /** 402 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set: 403 * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current 404 * profile will be skipped. 405 * Only activities in the target user can respond to the intent. 406 * @hide 407 */ 408 public static final int SKIP_CURRENT_PROFILE = 0x00000002; 409 410 /** 411 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set: 412 * activities in the other profiles can respond to the intent only if no activity with 413 * non-negative priority in current profile can respond to the intent. 414 * @hide 415 */ 416 public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004; 417 418 /** @hide */ 419 @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED}) 420 @Retention(RetentionPolicy.SOURCE) 421 public @interface PermissionResult {} 422 423 /** 424 * Permission check result: this is returned by {@link #checkPermission} 425 * if the permission has been granted to the given package. 426 */ 427 public static final int PERMISSION_GRANTED = 0; 428 429 /** 430 * Permission check result: this is returned by {@link #checkPermission} 431 * if the permission has not been granted to the given package. 432 */ 433 public static final int PERMISSION_DENIED = -1; 434 435 /** 436 * Signature check result: this is returned by {@link #checkSignatures} 437 * if all signatures on the two packages match. 438 */ 439 public static final int SIGNATURE_MATCH = 0; 440 441 /** 442 * Signature check result: this is returned by {@link #checkSignatures} 443 * if neither of the two packages is signed. 444 */ 445 public static final int SIGNATURE_NEITHER_SIGNED = 1; 446 447 /** 448 * Signature check result: this is returned by {@link #checkSignatures} 449 * if the first package is not signed but the second is. 450 */ 451 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1; 452 453 /** 454 * Signature check result: this is returned by {@link #checkSignatures} 455 * if the second package is not signed but the first is. 456 */ 457 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2; 458 459 /** 460 * Signature check result: this is returned by {@link #checkSignatures} 461 * if not all signatures on both packages match. 462 */ 463 public static final int SIGNATURE_NO_MATCH = -3; 464 465 /** 466 * Signature check result: this is returned by {@link #checkSignatures} 467 * if either of the packages are not valid. 468 */ 469 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; 470 471 /** 472 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 473 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 474 * component or application is in its default enabled state (as specified 475 * in its manifest). 476 */ 477 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; 478 479 /** 480 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 481 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 482 * component or application has been explictily enabled, regardless of 483 * what it has specified in its manifest. 484 */ 485 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; 486 487 /** 488 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 489 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 490 * component or application has been explicitly disabled, regardless of 491 * what it has specified in its manifest. 492 */ 493 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; 494 495 /** 496 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The 497 * user has explicitly disabled the application, regardless of what it has 498 * specified in its manifest. Because this is due to the user's request, 499 * they may re-enable it if desired through the appropriate system UI. This 500 * option currently <strong>cannot</strong> be used with 501 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 502 */ 503 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; 504 505 /** 506 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This 507 * application should be considered, until the point where the user actually 508 * wants to use it. This means that it will not normally show up to the user 509 * (such as in the launcher), but various parts of the user interface can 510 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow 511 * the user to select it (as for example an IME, device admin, etc). Such code, 512 * once the user has selected the app, should at that point also make it enabled. 513 * This option currently <strong>can not</strong> be used with 514 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 515 */ 516 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4; 517 518 /** 519 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to 520 * indicate that this package should be installed as forward locked, i.e. only the app itself 521 * should have access to its code and non-resource assets. 522 * @hide 523 */ 524 public static final int INSTALL_FORWARD_LOCK = 0x00000001; 525 526 /** 527 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already 528 * installed package, if one exists. 529 * @hide 530 */ 531 public static final int INSTALL_REPLACE_EXISTING = 0x00000002; 532 533 /** 534 * Flag parameter for {@link #installPackage} to indicate that you want to 535 * allow test packages (those that have set android:testOnly in their 536 * manifest) to be installed. 537 * @hide 538 */ 539 public static final int INSTALL_ALLOW_TEST = 0x00000004; 540 541 /** 542 * Flag parameter for {@link #installPackage} to indicate that this package 543 * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}. 544 * 545 * @hide 546 */ 547 public static final int INSTALL_EXTERNAL = 0x00000008; 548 549 /** 550 * Flag parameter for {@link #installPackage} to indicate that this package 551 * must be installed to internal storage. 552 * 553 * @hide 554 */ 555 public static final int INSTALL_INTERNAL = 0x00000010; 556 557 /** 558 * Flag parameter for {@link #installPackage} to indicate that this install 559 * was initiated via ADB. 560 * 561 * @hide 562 */ 563 public static final int INSTALL_FROM_ADB = 0x00000020; 564 565 /** 566 * Flag parameter for {@link #installPackage} to indicate that this install 567 * should immediately be visible to all users. 568 * 569 * @hide 570 */ 571 public static final int INSTALL_ALL_USERS = 0x00000040; 572 573 /** 574 * Flag parameter for {@link #installPackage} to indicate that it is okay 575 * to install an update to an app where the newly installed app has a lower 576 * version code than the currently installed app. 577 * 578 * @hide 579 */ 580 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080; 581 582 /** 583 * Flag parameter for {@link #installPackage} to indicate that all runtime 584 * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS} 585 * is set the runtime permissions will be granted to all users, otherwise 586 * only to the owner. 587 * 588 * @hide 589 */ 590 public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100; 591 592 /** {@hide} */ 593 public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200; 594 595 /** 596 * Flag parameter for {@link #installPackage} to indicate that we always want to force 597 * the prompt for permission approval. This overrides any special behaviour for internal 598 * components. 599 * 600 * @hide 601 */ 602 public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400; 603 604 /** 605 * Flag parameter for {@link #installPackage} to indicate that this package is 606 * to be installed as a lightweight "ephemeral" app. 607 * 608 * @hide 609 */ 610 public static final int INSTALL_EPHEMERAL = 0x00000800; 611 612 /** 613 * Flag parameter for 614 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 615 * that you don't want to kill the app containing the component. Be careful when you set this 616 * since changing component states can make the containing application's behavior unpredictable. 617 */ 618 public static final int DONT_KILL_APP = 0x00000001; 619 620 /** 621 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 622 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success. 623 * @hide 624 */ 625 @SystemApi 626 public static final int INSTALL_SUCCEEDED = 1; 627 628 /** 629 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 630 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is 631 * already installed. 632 * @hide 633 */ 634 @SystemApi 635 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; 636 637 /** 638 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 639 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive 640 * file is invalid. 641 * @hide 642 */ 643 @SystemApi 644 public static final int INSTALL_FAILED_INVALID_APK = -2; 645 646 /** 647 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 648 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in 649 * is invalid. 650 * @hide 651 */ 652 @SystemApi 653 public static final int INSTALL_FAILED_INVALID_URI = -3; 654 655 /** 656 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 657 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager 658 * service found that the device didn't have enough storage space to install the app. 659 * @hide 660 */ 661 @SystemApi 662 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; 663 664 /** 665 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 666 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a 667 * package is already installed with the same name. 668 * @hide 669 */ 670 @SystemApi 671 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; 672 673 /** 674 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 675 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 676 * the requested shared user does not exist. 677 * @hide 678 */ 679 @SystemApi 680 public static final int INSTALL_FAILED_NO_SHARED_USER = -6; 681 682 /** 683 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 684 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 685 * a previously installed package of the same name has a different signature 686 * than the new package (and the old package's data was not removed). 687 * @hide 688 */ 689 @SystemApi 690 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; 691 692 /** 693 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 694 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 695 * the new package is requested a shared user which is already installed on the 696 * device and does not have matching signature. 697 * @hide 698 */ 699 @SystemApi 700 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; 701 702 /** 703 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 704 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 705 * the new package uses a shared library that is not available. 706 * @hide 707 */ 708 @SystemApi 709 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; 710 711 /** 712 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 713 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 714 * the new package uses a shared library that is not available. 715 * @hide 716 */ 717 @SystemApi 718 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; 719 720 /** 721 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 722 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 723 * the new package failed while optimizing and validating its dex files, 724 * either because there was not enough storage or the validation failed. 725 * @hide 726 */ 727 @SystemApi 728 public static final int INSTALL_FAILED_DEXOPT = -11; 729 730 /** 731 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 732 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 733 * the new package failed because the current SDK version is older than 734 * that required by the package. 735 * @hide 736 */ 737 @SystemApi 738 public static final int INSTALL_FAILED_OLDER_SDK = -12; 739 740 /** 741 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 742 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 743 * the new package failed because it contains a content provider with the 744 * same authority as a provider already installed in the system. 745 * @hide 746 */ 747 @SystemApi 748 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 749 750 /** 751 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 752 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 753 * the new package failed because the current SDK version is newer than 754 * that required by the package. 755 * @hide 756 */ 757 @SystemApi 758 public static final int INSTALL_FAILED_NEWER_SDK = -14; 759 760 /** 761 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 762 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 763 * the new package failed because it has specified that it is a test-only 764 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST} 765 * flag. 766 * @hide 767 */ 768 @SystemApi 769 public static final int INSTALL_FAILED_TEST_ONLY = -15; 770 771 /** 772 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 773 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 774 * the package being installed contains native code, but none that is 775 * compatible with the device's CPU_ABI. 776 * @hide 777 */ 778 @SystemApi 779 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; 780 781 /** 782 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 783 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 784 * the new package uses a feature that is not available. 785 * @hide 786 */ 787 @SystemApi 788 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 789 790 // ------ Errors related to sdcard 791 /** 792 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 793 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 794 * a secure container mount point couldn't be accessed on external media. 795 * @hide 796 */ 797 @SystemApi 798 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; 799 800 /** 801 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 802 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 803 * the new package couldn't be installed in the specified install 804 * location. 805 * @hide 806 */ 807 @SystemApi 808 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; 809 810 /** 811 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 812 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 813 * the new package couldn't be installed in the specified install 814 * location because the media is not available. 815 * @hide 816 */ 817 @SystemApi 818 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; 819 820 /** 821 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 822 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 823 * the new package couldn't be installed because the verification timed out. 824 * @hide 825 */ 826 @SystemApi 827 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; 828 829 /** 830 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 831 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 832 * the new package couldn't be installed because the verification did not succeed. 833 * @hide 834 */ 835 @SystemApi 836 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; 837 838 /** 839 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 840 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 841 * the package changed from what the calling program expected. 842 * @hide 843 */ 844 @SystemApi 845 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; 846 847 /** 848 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 849 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 850 * the new package is assigned a different UID than it previously held. 851 * @hide 852 */ 853 public static final int INSTALL_FAILED_UID_CHANGED = -24; 854 855 /** 856 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 857 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 858 * the new package has an older version code than the currently installed package. 859 * @hide 860 */ 861 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; 862 863 /** 864 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 865 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 866 * the old package has target SDK high enough to support runtime permission and 867 * the new package has target SDK low enough to not support runtime permissions. 868 * @hide 869 */ 870 @SystemApi 871 public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26; 872 873 /** 874 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 875 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 876 * if the parser was given a path that is not a file, or does not end with the expected 877 * '.apk' extension. 878 * @hide 879 */ 880 @SystemApi 881 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; 882 883 /** 884 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 885 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 886 * if the parser was unable to retrieve the AndroidManifest.xml file. 887 * @hide 888 */ 889 @SystemApi 890 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; 891 892 /** 893 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 894 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 895 * if the parser encountered an unexpected exception. 896 * @hide 897 */ 898 @SystemApi 899 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; 900 901 /** 902 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 903 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 904 * if the parser did not find any certificates in the .apk. 905 * @hide 906 */ 907 @SystemApi 908 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; 909 910 /** 911 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 912 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 913 * if the parser found inconsistent certificates on the files in the .apk. 914 * @hide 915 */ 916 @SystemApi 917 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; 918 919 /** 920 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 921 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 922 * if the parser encountered a CertificateEncodingException in one of the 923 * files in the .apk. 924 * @hide 925 */ 926 @SystemApi 927 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; 928 929 /** 930 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 931 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 932 * if the parser encountered a bad or missing package name in the manifest. 933 * @hide 934 */ 935 @SystemApi 936 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; 937 938 /** 939 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 940 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 941 * if the parser encountered a bad shared user id name in the manifest. 942 * @hide 943 */ 944 @SystemApi 945 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; 946 947 /** 948 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 949 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 950 * if the parser encountered some structural problem in the manifest. 951 * @hide 952 */ 953 @SystemApi 954 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; 955 956 /** 957 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 958 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 959 * if the parser did not find any actionable tags (instrumentation or application) 960 * in the manifest. 961 * @hide 962 */ 963 @SystemApi 964 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 965 966 /** 967 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 968 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 969 * if the system failed to install the package because of system issues. 970 * @hide 971 */ 972 @SystemApi 973 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; 974 975 /** 976 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 977 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 978 * if the system failed to install the package because the user is restricted from installing 979 * apps. 980 * @hide 981 */ 982 public static final int INSTALL_FAILED_USER_RESTRICTED = -111; 983 984 /** 985 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 986 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 987 * if the system failed to install the package because it is attempting to define a 988 * permission that is already defined by some existing package. 989 * 990 * <p>The package name of the app which has already defined the permission is passed to 991 * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE} 992 * string extra; and the name of the permission being redefined is passed in the 993 * {@link #EXTRA_EXISTING_PERMISSION} string extra. 994 * @hide 995 */ 996 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; 997 998 /** 999 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 1000 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 1001 * if the system failed to install the package because its packaged native code did not 1002 * match any of the ABIs supported by the system. 1003 * 1004 * @hide 1005 */ 1006 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113; 1007 1008 /** 1009 * Internal return code for NativeLibraryHelper methods to indicate that the package 1010 * being processed did not contain any native code. This is placed here only so that 1011 * it can belong to the same value space as the other install failure codes. 1012 * 1013 * @hide 1014 */ 1015 public static final int NO_NATIVE_LIBRARIES = -114; 1016 1017 /** {@hide} */ 1018 public static final int INSTALL_FAILED_ABORTED = -115; 1019 1020 /** 1021 * Installation failed return code: ephemeral app installs are incompatible with some 1022 * other installation flags supplied for the operation; or other circumstances such 1023 * as trying to upgrade a system app via an ephemeral install. 1024 * @hide 1025 */ 1026 public static final int INSTALL_FAILED_EPHEMERAL_INVALID = -116; 1027 1028 /** 1029 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the 1030 * package's data directory. 1031 * 1032 * @hide 1033 */ 1034 public static final int DELETE_KEEP_DATA = 0x00000001; 1035 1036 /** 1037 * Flag parameter for {@link #deletePackage} to indicate that you want the 1038 * package deleted for all users. 1039 * 1040 * @hide 1041 */ 1042 public static final int DELETE_ALL_USERS = 0x00000002; 1043 1044 /** 1045 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling 1046 * uninstall on a system that has been updated, then don't do the normal process 1047 * of uninstalling the update and rolling back to the older system version (which 1048 * needs to happen for all users); instead, just mark the app as uninstalled for 1049 * the current user. 1050 * 1051 * @hide 1052 */ 1053 public static final int DELETE_SYSTEM_APP = 0x00000004; 1054 1055 /** 1056 * Return code for when package deletion succeeds. This is passed to the 1057 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1058 * succeeded in deleting the package. 1059 * 1060 * @hide 1061 */ 1062 public static final int DELETE_SUCCEEDED = 1; 1063 1064 /** 1065 * Deletion failed return code: this is passed to the 1066 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1067 * failed to delete the package for an unspecified reason. 1068 * 1069 * @hide 1070 */ 1071 public static final int DELETE_FAILED_INTERNAL_ERROR = -1; 1072 1073 /** 1074 * Deletion failed return code: this is passed to the 1075 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1076 * failed to delete the package because it is the active DevicePolicy 1077 * manager. 1078 * 1079 * @hide 1080 */ 1081 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; 1082 1083 /** 1084 * Deletion failed return code: this is passed to the 1085 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1086 * failed to delete the package since the user is restricted. 1087 * 1088 * @hide 1089 */ 1090 public static final int DELETE_FAILED_USER_RESTRICTED = -3; 1091 1092 /** 1093 * Deletion failed return code: this is passed to the 1094 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 1095 * failed to delete the package because a profile 1096 * or device owner has marked the package as uninstallable. 1097 * 1098 * @hide 1099 */ 1100 public static final int DELETE_FAILED_OWNER_BLOCKED = -4; 1101 1102 /** {@hide} */ 1103 public static final int DELETE_FAILED_ABORTED = -5; 1104 1105 /** 1106 * Return code that is passed to the {@link IPackageMoveObserver} by 1107 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the 1108 * package has been successfully moved by the system. 1109 * 1110 * @hide 1111 */ 1112 public static final int MOVE_SUCCEEDED = -100; 1113 1114 /** 1115 * Error code that is passed to the {@link IPackageMoveObserver} by 1116 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1117 * when the package hasn't been successfully moved by the system 1118 * because of insufficient memory on specified media. 1119 * @hide 1120 */ 1121 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1; 1122 1123 /** 1124 * Error code that is passed to the {@link IPackageMoveObserver} by 1125 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1126 * if the specified package doesn't exist. 1127 * @hide 1128 */ 1129 public static final int MOVE_FAILED_DOESNT_EXIST = -2; 1130 1131 /** 1132 * Error code that is passed to the {@link IPackageMoveObserver} by 1133 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1134 * if the specified package cannot be moved since its a system package. 1135 * @hide 1136 */ 1137 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3; 1138 1139 /** 1140 * Error code that is passed to the {@link IPackageMoveObserver} by 1141 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1142 * if the specified package cannot be moved since its forward locked. 1143 * @hide 1144 */ 1145 public static final int MOVE_FAILED_FORWARD_LOCKED = -4; 1146 1147 /** 1148 * Error code that is passed to the {@link IPackageMoveObserver} by 1149 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1150 * if the specified package cannot be moved to the specified location. 1151 * @hide 1152 */ 1153 public static final int MOVE_FAILED_INVALID_LOCATION = -5; 1154 1155 /** 1156 * Error code that is passed to the {@link IPackageMoveObserver} by 1157 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 1158 * if the specified package cannot be moved to the specified location. 1159 * @hide 1160 */ 1161 public static final int MOVE_FAILED_INTERNAL_ERROR = -6; 1162 1163 /** 1164 * Error code that is passed to the {@link IPackageMoveObserver} by 1165 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the 1166 * specified package already has an operation pending in the 1167 * {@link PackageHandler} queue. 1168 * 1169 * @hide 1170 */ 1171 public static final int MOVE_FAILED_OPERATION_PENDING = -7; 1172 1173 /** 1174 * Flag parameter for {@link #movePackage} to indicate that 1175 * the package should be moved to internal storage if its 1176 * been installed on external media. 1177 * @hide 1178 */ 1179 @Deprecated 1180 public static final int MOVE_INTERNAL = 0x00000001; 1181 1182 /** 1183 * Flag parameter for {@link #movePackage} to indicate that 1184 * the package should be moved to external media. 1185 * @hide 1186 */ 1187 @Deprecated 1188 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 1189 1190 /** {@hide} */ 1191 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID"; 1192 1193 /** 1194 * Usable by the required verifier as the {@code verificationCode} argument 1195 * for {@link PackageManager#verifyPendingInstall} to indicate that it will 1196 * allow the installation to proceed without any of the optional verifiers 1197 * needing to vote. 1198 * 1199 * @hide 1200 */ 1201 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2; 1202 1203 /** 1204 * Used as the {@code verificationCode} argument for 1205 * {@link PackageManager#verifyPendingInstall} to indicate that the calling 1206 * package verifier allows the installation to proceed. 1207 */ 1208 public static final int VERIFICATION_ALLOW = 1; 1209 1210 /** 1211 * Used as the {@code verificationCode} argument for 1212 * {@link PackageManager#verifyPendingInstall} to indicate the calling 1213 * package verifier does not vote to allow the installation to proceed. 1214 */ 1215 public static final int VERIFICATION_REJECT = -1; 1216 1217 /** 1218 * Used as the {@code verificationCode} argument for 1219 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 1220 * IntentFilter Verifier confirms that the IntentFilter is verified. 1221 * 1222 * @hide 1223 */ 1224 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1; 1225 1226 /** 1227 * Used as the {@code verificationCode} argument for 1228 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 1229 * IntentFilter Verifier confirms that the IntentFilter is NOT verified. 1230 * 1231 * @hide 1232 */ 1233 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1; 1234 1235 /** 1236 * Internal status code to indicate that an IntentFilter verification result is not specified. 1237 * 1238 * @hide 1239 */ 1240 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0; 1241 1242 /** 1243 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1244 * to indicate that the User will always be prompted the Intent Disambiguation Dialog if there 1245 * are two or more Intent resolved for the IntentFilter's domain(s). 1246 * 1247 * @hide 1248 */ 1249 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1; 1250 1251 /** 1252 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1253 * to indicate that the User will never be prompted the Intent Disambiguation Dialog if there 1254 * are two or more resolution of the Intent. The default App for the domain(s) specified in the 1255 * IntentFilter will also ALWAYS be used. 1256 * 1257 * @hide 1258 */ 1259 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2; 1260 1261 /** 1262 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1263 * to indicate that the User may be prompted the Intent Disambiguation Dialog if there 1264 * are two or more Intent resolved. The default App for the domain(s) specified in the 1265 * IntentFilter will also NEVER be presented to the User. 1266 * 1267 * @hide 1268 */ 1269 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3; 1270 1271 /** 1272 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1273 * to indicate that this app should always be considered as an ambiguous candidate for 1274 * handling the matching Intent even if there are other candidate apps in the "always" 1275 * state. Put another way: if there are any 'always ask' apps in a set of more than 1276 * one candidate app, then a disambiguation is *always* presented even if there is 1277 * another candidate app with the 'always' state. 1278 * 1279 * @hide 1280 */ 1281 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4; 1282 1283 /** 1284 * Can be used as the {@code millisecondsToDelay} argument for 1285 * {@link PackageManager#extendVerificationTimeout}. This is the 1286 * maximum time {@code PackageManager} waits for the verification 1287 * agent to return (in milliseconds). 1288 */ 1289 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000; 1290 1291 /** 1292 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's 1293 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or 1294 * lag in sound input or output. 1295 */ 1296 @SdkConstant(SdkConstantType.FEATURE) 1297 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; 1298 1299 /** 1300 * Feature for {@link #getSystemAvailableFeatures} and 1301 * {@link #hasSystemFeature}: The device includes at least one form of audio 1302 * output, such as speakers, audio jack or streaming over bluetooth 1303 */ 1304 @SdkConstant(SdkConstantType.FEATURE) 1305 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output"; 1306 1307 /** 1308 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1309 * The device has professional audio level of functionality and performance. 1310 */ 1311 @SdkConstant(SdkConstantType.FEATURE) 1312 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro"; 1313 1314 /** 1315 * Feature for {@link #getSystemAvailableFeatures} and 1316 * {@link #hasSystemFeature}: The device is capable of communicating with 1317 * other devices via Bluetooth. 1318 */ 1319 @SdkConstant(SdkConstantType.FEATURE) 1320 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 1321 1322 /** 1323 * Feature for {@link #getSystemAvailableFeatures} and 1324 * {@link #hasSystemFeature}: The device is capable of communicating with 1325 * other devices via Bluetooth Low Energy radio. 1326 */ 1327 @SdkConstant(SdkConstantType.FEATURE) 1328 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 1329 1330 /** 1331 * Feature for {@link #getSystemAvailableFeatures} and 1332 * {@link #hasSystemFeature}: The device has a camera facing away 1333 * from the screen. 1334 */ 1335 @SdkConstant(SdkConstantType.FEATURE) 1336 public static final String FEATURE_CAMERA = "android.hardware.camera"; 1337 1338 /** 1339 * Feature for {@link #getSystemAvailableFeatures} and 1340 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 1341 */ 1342 @SdkConstant(SdkConstantType.FEATURE) 1343 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 1344 1345 /** 1346 * Feature for {@link #getSystemAvailableFeatures} and 1347 * {@link #hasSystemFeature}: The device has at least one camera pointing in 1348 * some direction, or can support an external camera being connected to it. 1349 */ 1350 @SdkConstant(SdkConstantType.FEATURE) 1351 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 1352 1353 /** 1354 * Feature for {@link #getSystemAvailableFeatures} and 1355 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 1356 * The external camera may not always be connected or available to applications to use. 1357 */ 1358 @SdkConstant(SdkConstantType.FEATURE) 1359 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 1360 1361 /** 1362 * Feature for {@link #getSystemAvailableFeatures} and 1363 * {@link #hasSystemFeature}: The device's camera supports flash. 1364 */ 1365 @SdkConstant(SdkConstantType.FEATURE) 1366 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 1367 1368 /** 1369 * Feature for {@link #getSystemAvailableFeatures} and 1370 * {@link #hasSystemFeature}: The device has a front facing camera. 1371 */ 1372 @SdkConstant(SdkConstantType.FEATURE) 1373 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 1374 1375 /** 1376 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1377 * of the cameras on the device supports the 1378 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 1379 * capability level. 1380 */ 1381 @SdkConstant(SdkConstantType.FEATURE) 1382 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 1383 1384 /** 1385 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1386 * of the cameras on the device supports the 1387 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 1388 * capability level. 1389 */ 1390 @SdkConstant(SdkConstantType.FEATURE) 1391 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 1392 "android.hardware.camera.capability.manual_sensor"; 1393 1394 /** 1395 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1396 * of the cameras on the device supports the 1397 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 1398 * capability level. 1399 */ 1400 @SdkConstant(SdkConstantType.FEATURE) 1401 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 1402 "android.hardware.camera.capability.manual_post_processing"; 1403 1404 /** 1405 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1406 * of the cameras on the device supports the 1407 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 1408 * capability level. 1409 */ 1410 @SdkConstant(SdkConstantType.FEATURE) 1411 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 1412 "android.hardware.camera.capability.raw"; 1413 1414 /** 1415 * Feature for {@link #getSystemAvailableFeatures} and 1416 * {@link #hasSystemFeature}: The device is capable of communicating with 1417 * consumer IR devices. 1418 */ 1419 @SdkConstant(SdkConstantType.FEATURE) 1420 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 1421 1422 /** 1423 * Feature for {@link #getSystemAvailableFeatures} and 1424 * {@link #hasSystemFeature}: The device supports one or more methods of 1425 * reporting current location. 1426 */ 1427 @SdkConstant(SdkConstantType.FEATURE) 1428 public static final String FEATURE_LOCATION = "android.hardware.location"; 1429 1430 /** 1431 * Feature for {@link #getSystemAvailableFeatures} and 1432 * {@link #hasSystemFeature}: The device has a Global Positioning System 1433 * receiver and can report precise location. 1434 */ 1435 @SdkConstant(SdkConstantType.FEATURE) 1436 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 1437 1438 /** 1439 * Feature for {@link #getSystemAvailableFeatures} and 1440 * {@link #hasSystemFeature}: The device can report location with coarse 1441 * accuracy using a network-based geolocation system. 1442 */ 1443 @SdkConstant(SdkConstantType.FEATURE) 1444 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 1445 1446 /** 1447 * Feature for {@link #getSystemAvailableFeatures} and 1448 * {@link #hasSystemFeature}: The device can record audio via a 1449 * microphone. 1450 */ 1451 @SdkConstant(SdkConstantType.FEATURE) 1452 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 1453 1454 /** 1455 * Feature for {@link #getSystemAvailableFeatures} and 1456 * {@link #hasSystemFeature}: The device can communicate using Near-Field 1457 * Communications (NFC). 1458 */ 1459 @SdkConstant(SdkConstantType.FEATURE) 1460 public static final String FEATURE_NFC = "android.hardware.nfc"; 1461 1462 /** 1463 * Feature for {@link #getSystemAvailableFeatures} and 1464 * {@link #hasSystemFeature}: The device supports host- 1465 * based NFC card emulation. 1466 * 1467 * TODO remove when depending apps have moved to new constant. 1468 * @hide 1469 * @deprecated 1470 */ 1471 @Deprecated 1472 @SdkConstant(SdkConstantType.FEATURE) 1473 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 1474 1475 /** 1476 * Feature for {@link #getSystemAvailableFeatures} and 1477 * {@link #hasSystemFeature}: The device supports host- 1478 * based NFC card emulation. 1479 */ 1480 @SdkConstant(SdkConstantType.FEATURE) 1481 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 1482 1483 /** 1484 * Feature for {@link #getSystemAvailableFeatures} and 1485 * {@link #hasSystemFeature}: The device supports the OpenGL ES 1486 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 1487 * Android Extension Pack</a>. 1488 */ 1489 @SdkConstant(SdkConstantType.FEATURE) 1490 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 1491 1492 /** 1493 * Feature for {@link #getSystemAvailableFeatures} and 1494 * {@link #hasSystemFeature}: The device includes an accelerometer. 1495 */ 1496 @SdkConstant(SdkConstantType.FEATURE) 1497 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1498 1499 /** 1500 * Feature for {@link #getSystemAvailableFeatures} and 1501 * {@link #hasSystemFeature}: The device includes a barometer (air 1502 * pressure sensor.) 1503 */ 1504 @SdkConstant(SdkConstantType.FEATURE) 1505 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1506 1507 /** 1508 * Feature for {@link #getSystemAvailableFeatures} and 1509 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1510 */ 1511 @SdkConstant(SdkConstantType.FEATURE) 1512 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1513 1514 /** 1515 * Feature for {@link #getSystemAvailableFeatures} and 1516 * {@link #hasSystemFeature}: The device includes a gyroscope. 1517 */ 1518 @SdkConstant(SdkConstantType.FEATURE) 1519 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 1520 1521 /** 1522 * Feature for {@link #getSystemAvailableFeatures} and 1523 * {@link #hasSystemFeature}: The device includes a light sensor. 1524 */ 1525 @SdkConstant(SdkConstantType.FEATURE) 1526 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 1527 1528 /** 1529 * Feature for {@link #getSystemAvailableFeatures} and 1530 * {@link #hasSystemFeature}: The device includes a proximity sensor. 1531 */ 1532 @SdkConstant(SdkConstantType.FEATURE) 1533 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 1534 1535 /** 1536 * Feature for {@link #getSystemAvailableFeatures} and 1537 * {@link #hasSystemFeature}: The device includes a hardware step counter. 1538 */ 1539 @SdkConstant(SdkConstantType.FEATURE) 1540 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 1541 1542 /** 1543 * Feature for {@link #getSystemAvailableFeatures} and 1544 * {@link #hasSystemFeature}: The device includes a hardware step detector. 1545 */ 1546 @SdkConstant(SdkConstantType.FEATURE) 1547 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 1548 1549 /** 1550 * Feature for {@link #getSystemAvailableFeatures} and 1551 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 1552 */ 1553 @SdkConstant(SdkConstantType.FEATURE) 1554 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 1555 1556 /** 1557 * Feature for {@link #getSystemAvailableFeatures} and 1558 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram. 1559 */ 1560 @SdkConstant(SdkConstantType.FEATURE) 1561 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 1562 "android.hardware.sensor.heartrate.ecg"; 1563 1564 /** 1565 * Feature for {@link #getSystemAvailableFeatures} and 1566 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 1567 */ 1568 @SdkConstant(SdkConstantType.FEATURE) 1569 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 1570 "android.hardware.sensor.relative_humidity"; 1571 1572 /** 1573 * Feature for {@link #getSystemAvailableFeatures} and 1574 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 1575 */ 1576 @SdkConstant(SdkConstantType.FEATURE) 1577 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 1578 "android.hardware.sensor.ambient_temperature"; 1579 1580 /** 1581 * Feature for {@link #getSystemAvailableFeatures} and 1582 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 1583 * capabilities. 1584 */ 1585 @SdkConstant(SdkConstantType.FEATURE) 1586 public static final String FEATURE_HIFI_SENSORS = 1587 "android.hardware.sensor.hifi_sensors"; 1588 1589 /** 1590 * Feature for {@link #getSystemAvailableFeatures} and 1591 * {@link #hasSystemFeature}: The device has a telephony radio with data 1592 * communication support. 1593 */ 1594 @SdkConstant(SdkConstantType.FEATURE) 1595 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 1596 1597 /** 1598 * Feature for {@link #getSystemAvailableFeatures} and 1599 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 1600 */ 1601 @SdkConstant(SdkConstantType.FEATURE) 1602 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 1603 1604 /** 1605 * Feature for {@link #getSystemAvailableFeatures} and 1606 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 1607 */ 1608 @SdkConstant(SdkConstantType.FEATURE) 1609 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 1610 1611 /** 1612 * Feature for {@link #getSystemAvailableFeatures} and 1613 * {@link #hasSystemFeature}: The device supports connecting to USB devices 1614 * as the USB host. 1615 */ 1616 @SdkConstant(SdkConstantType.FEATURE) 1617 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 1618 1619 /** 1620 * Feature for {@link #getSystemAvailableFeatures} and 1621 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 1622 */ 1623 @SdkConstant(SdkConstantType.FEATURE) 1624 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 1625 1626 /** 1627 * Feature for {@link #getSystemAvailableFeatures} and 1628 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 1629 */ 1630 @SdkConstant(SdkConstantType.FEATURE) 1631 public static final String FEATURE_SIP = "android.software.sip"; 1632 1633 /** 1634 * Feature for {@link #getSystemAvailableFeatures} and 1635 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 1636 */ 1637 @SdkConstant(SdkConstantType.FEATURE) 1638 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 1639 1640 /** 1641 * Feature for {@link #getSystemAvailableFeatures} and 1642 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 1643 */ 1644 @SdkConstant(SdkConstantType.FEATURE) 1645 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 1646 1647 /** 1648 * Feature for {@link #getSystemAvailableFeatures} and 1649 * {@link #hasSystemFeature}: The device's display has a touch screen. 1650 */ 1651 @SdkConstant(SdkConstantType.FEATURE) 1652 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 1653 1654 /** 1655 * Feature for {@link #getSystemAvailableFeatures} and 1656 * {@link #hasSystemFeature}: The device's touch screen supports 1657 * multitouch sufficient for basic two-finger gesture detection. 1658 */ 1659 @SdkConstant(SdkConstantType.FEATURE) 1660 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 1661 1662 /** 1663 * Feature for {@link #getSystemAvailableFeatures} and 1664 * {@link #hasSystemFeature}: The device's touch screen is capable of 1665 * tracking two or more fingers fully independently. 1666 */ 1667 @SdkConstant(SdkConstantType.FEATURE) 1668 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1669 1670 /** 1671 * Feature for {@link #getSystemAvailableFeatures} and 1672 * {@link #hasSystemFeature}: The device's touch screen is capable of 1673 * tracking a full hand of fingers fully independently -- that is, 5 or 1674 * more simultaneous independent pointers. 1675 */ 1676 @SdkConstant(SdkConstantType.FEATURE) 1677 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1678 1679 /** 1680 * Feature for {@link #getSystemAvailableFeatures} and 1681 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1682 * does support touch emulation for basic events. For instance, the 1683 * device might use a mouse or remote control to drive a cursor, and 1684 * emulate basic touch pointer events like down, up, drag, etc. All 1685 * devices that support android.hardware.touchscreen or a sub-feature are 1686 * presumed to also support faketouch. 1687 */ 1688 @SdkConstant(SdkConstantType.FEATURE) 1689 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1690 1691 /** 1692 * Feature for {@link #getSystemAvailableFeatures} and 1693 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1694 * does support touch emulation for basic events that supports distinct 1695 * tracking of two or more fingers. This is an extension of 1696 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1697 * that unlike a distinct multitouch screen as defined by 1698 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1699 * devices will not actually provide full two-finger gestures since the 1700 * input is being transformed to cursor movement on the screen. That is, 1701 * single finger gestures will move a cursor; two-finger swipes will 1702 * result in single-finger touch events; other two-finger gestures will 1703 * result in the corresponding two-finger touch event. 1704 */ 1705 @SdkConstant(SdkConstantType.FEATURE) 1706 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1707 1708 /** 1709 * Feature for {@link #getSystemAvailableFeatures} and 1710 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1711 * does support touch emulation for basic events that supports tracking 1712 * a hand of fingers (5 or more fingers) fully independently. 1713 * This is an extension of 1714 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1715 * that unlike a multitouch screen as defined by 1716 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1717 * gestures can be detected due to the limitations described for 1718 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1719 */ 1720 @SdkConstant(SdkConstantType.FEATURE) 1721 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1722 1723 /** 1724 * Feature for {@link #getSystemAvailableFeatures} and 1725 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 1726 */ 1727 @SdkConstant(SdkConstantType.FEATURE) 1728 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 1729 1730 /** 1731 * Feature for {@link #getSystemAvailableFeatures} and 1732 * {@link #hasSystemFeature}: The device supports portrait orientation 1733 * screens. For backwards compatibility, you can assume that if neither 1734 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1735 * both portrait and landscape. 1736 */ 1737 @SdkConstant(SdkConstantType.FEATURE) 1738 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1739 1740 /** 1741 * Feature for {@link #getSystemAvailableFeatures} and 1742 * {@link #hasSystemFeature}: The device supports landscape orientation 1743 * screens. For backwards compatibility, you can assume that if neither 1744 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1745 * both portrait and landscape. 1746 */ 1747 @SdkConstant(SdkConstantType.FEATURE) 1748 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1749 1750 /** 1751 * Feature for {@link #getSystemAvailableFeatures} and 1752 * {@link #hasSystemFeature}: The device supports live wallpapers. 1753 */ 1754 @SdkConstant(SdkConstantType.FEATURE) 1755 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1756 /** 1757 * Feature for {@link #getSystemAvailableFeatures} and 1758 * {@link #hasSystemFeature}: The device supports app widgets. 1759 */ 1760 @SdkConstant(SdkConstantType.FEATURE) 1761 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 1762 1763 /** 1764 * @hide 1765 * Feature for {@link #getSystemAvailableFeatures} and 1766 * {@link #hasSystemFeature}: The device supports 1767 * {@link android.service.voice.VoiceInteractionService} and 1768 * {@link android.app.VoiceInteractor}. 1769 */ 1770 @SdkConstant(SdkConstantType.FEATURE) 1771 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 1772 1773 1774 /** 1775 * Feature for {@link #getSystemAvailableFeatures} and 1776 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 1777 * by third party applications. 1778 */ 1779 @SdkConstant(SdkConstantType.FEATURE) 1780 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 1781 1782 /** 1783 * Feature for {@link #getSystemAvailableFeatures} and 1784 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 1785 * with the {@link android.inputmethodservice.InputMethodService} API. 1786 */ 1787 @SdkConstant(SdkConstantType.FEATURE) 1788 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 1789 1790 /** 1791 * Feature for {@link #getSystemAvailableFeatures} and 1792 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 1793 */ 1794 @SdkConstant(SdkConstantType.FEATURE) 1795 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 1796 1797 /** 1798 * Feature for {@link #getSystemAvailableFeatures} and 1799 * {@link #hasSystemFeature}: The device supports leanback UI. This is 1800 * typically used in a living room television experience, but is a software 1801 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 1802 * feature will use resources associated with the "television" UI mode. 1803 */ 1804 @SdkConstant(SdkConstantType.FEATURE) 1805 public static final String FEATURE_LEANBACK = "android.software.leanback"; 1806 1807 /** 1808 * Feature for {@link #getSystemAvailableFeatures} and 1809 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 1810 * applications designed for this experience should be run, though this is 1811 * not enforced by the system. 1812 * @hide 1813 */ 1814 @SdkConstant(SdkConstantType.FEATURE) 1815 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 1816 1817 /** 1818 * Feature for {@link #getSystemAvailableFeatures} and 1819 * {@link #hasSystemFeature}: The device supports live TV and can display 1820 * contents from TV inputs implemented with the 1821 * {@link android.media.tv.TvInputService} API. 1822 */ 1823 @SdkConstant(SdkConstantType.FEATURE) 1824 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 1825 1826 /** 1827 * Feature for {@link #getSystemAvailableFeatures} and 1828 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1829 */ 1830 @SdkConstant(SdkConstantType.FEATURE) 1831 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1832 1833 /** 1834 * Feature for {@link #getSystemAvailableFeatures} and 1835 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1836 */ 1837 @SdkConstant(SdkConstantType.FEATURE) 1838 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1839 1840 /** 1841 * Feature for {@link #getSystemAvailableFeatures} and 1842 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1843 * on a vehicle headunit. A headunit here is defined to be inside a 1844 * vehicle that may or may not be moving. A headunit uses either a 1845 * primary display in the center console and/or additional displays in 1846 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 1847 * have limited size and resolution. The user will likely be focused on 1848 * driving so limiting driver distraction is a primary concern. User input 1849 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 1850 * like interfaces. 1851 */ 1852 @SdkConstant(SdkConstantType.FEATURE) 1853 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 1854 1855 /** 1856 * Feature for {@link #getSystemAvailableFeatures} and 1857 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1858 * on a television. Television here is defined to be a typical living 1859 * room television experience: displayed on a big screen, where the user 1860 * is sitting far away from it, and the dominant form of input will be 1861 * something like a DPAD, not through touch or mouse. 1862 * @deprecated use {@link #FEATURE_LEANBACK} instead. 1863 */ 1864 @Deprecated 1865 @SdkConstant(SdkConstantType.FEATURE) 1866 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 1867 1868 /** 1869 * Feature for {@link #getSystemAvailableFeatures} and 1870 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1871 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 1872 * the wrist. The user is very close when interacting with the device. 1873 */ 1874 @SdkConstant(SdkConstantType.FEATURE) 1875 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 1876 1877 /** 1878 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1879 * The device supports printing. 1880 */ 1881 @SdkConstant(SdkConstantType.FEATURE) 1882 public static final String FEATURE_PRINTING = "android.software.print"; 1883 1884 /** 1885 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1886 * The device can perform backup and restore operations on installed applications. 1887 */ 1888 @SdkConstant(SdkConstantType.FEATURE) 1889 public static final String FEATURE_BACKUP = "android.software.backup"; 1890 1891 /** 1892 * Feature for {@link #getSystemAvailableFeatures} and 1893 * {@link #hasSystemFeature}: The device supports freeform window management. 1894 * Windows have title bars and can be moved and resized. 1895 */ 1896 // If this feature is present, you also need to set 1897 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 1898 @SdkConstant(SdkConstantType.FEATURE) 1899 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 1900 = "android.software.freeform_window_management"; 1901 1902 /** 1903 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1904 * The device supports picture-in-picture multi-window mode. 1905 */ 1906 @SdkConstant(SdkConstantType.FEATURE) 1907 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 1908 1909 /** 1910 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1911 * The device supports creating secondary users and managed profiles via 1912 * {@link DevicePolicyManager}. 1913 */ 1914 @SdkConstant(SdkConstantType.FEATURE) 1915 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 1916 1917 /** 1918 * @hide 1919 * TODO: Remove after dependencies updated b/17392243 1920 */ 1921 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 1922 1923 /** 1924 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1925 * The device supports verified boot. 1926 */ 1927 @SdkConstant(SdkConstantType.FEATURE) 1928 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 1929 1930 /** 1931 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1932 * The device supports secure removal of users. When a user is deleted the data associated 1933 * with that user is securely deleted and no longer available. 1934 */ 1935 @SdkConstant(SdkConstantType.FEATURE) 1936 public static final String FEATURE_SECURELY_REMOVES_USERS 1937 = "android.software.securely_removes_users"; 1938 1939 /** 1940 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1941 * The device has a full implementation of the android.webkit.* APIs. Devices 1942 * lacking this feature will not have a functioning WebView implementation. 1943 */ 1944 @SdkConstant(SdkConstantType.FEATURE) 1945 public static final String FEATURE_WEBVIEW = "android.software.webview"; 1946 1947 /** 1948 * Feature for {@link #getSystemAvailableFeatures} and 1949 * {@link #hasSystemFeature}: This device supports ethernet. 1950 */ 1951 @SdkConstant(SdkConstantType.FEATURE) 1952 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 1953 1954 /** 1955 * Feature for {@link #getSystemAvailableFeatures} and 1956 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 1957 * @hide 1958 */ 1959 @SdkConstant(SdkConstantType.FEATURE) 1960 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 1961 1962 /** 1963 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1964 * The device has all of the inputs necessary to be considered a compatible game controller, or 1965 * includes a compatible game controller in the box. 1966 */ 1967 @SdkConstant(SdkConstantType.FEATURE) 1968 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 1969 1970 /** 1971 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1972 * The device has a full implementation of the android.media.midi.* APIs. 1973 */ 1974 @SdkConstant(SdkConstantType.FEATURE) 1975 public static final String FEATURE_MIDI = "android.software.midi"; 1976 1977 /** 1978 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1979 * The device implements a an optimized mode for virtual reality (VR) applications that handles 1980 * stereoscopic rendering of notifications, and may potentially also include optimizations to 1981 * reduce latency in the graphics, display, and sensor stacks. Presence of this feature 1982 * also indicates that the VrCore library is included on this device. 1983 */ 1984 @SdkConstant(SdkConstantType.FEATURE) 1985 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 1986 1987 /** 1988 * Action to external storage service to clean out removed apps. 1989 * @hide 1990 */ 1991 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 1992 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 1993 1994 /** 1995 * Extra field name for the URI to a verification file. Passed to a package 1996 * verifier. 1997 * 1998 * @hide 1999 */ 2000 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 2001 2002 /** 2003 * Extra field name for the ID of a package pending verification. Passed to 2004 * a package verifier and is used to call back to 2005 * {@link PackageManager#verifyPendingInstall(int, int)} 2006 */ 2007 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 2008 2009 /** 2010 * Extra field name for the package identifier which is trying to install 2011 * the package. 2012 * 2013 * @hide 2014 */ 2015 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 2016 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 2017 2018 /** 2019 * Extra field name for the requested install flags for a package pending 2020 * verification. Passed to a package verifier. 2021 * 2022 * @hide 2023 */ 2024 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 2025 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 2026 2027 /** 2028 * Extra field name for the uid of who is requesting to install 2029 * the package. 2030 * 2031 * @hide 2032 */ 2033 public static final String EXTRA_VERIFICATION_INSTALLER_UID 2034 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 2035 2036 /** 2037 * Extra field name for the package name of a package pending verification. 2038 * 2039 * @hide 2040 */ 2041 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 2042 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 2043 /** 2044 * Extra field name for the result of a verification, either 2045 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 2046 * Passed to package verifiers after a package is verified. 2047 */ 2048 public static final String EXTRA_VERIFICATION_RESULT 2049 = "android.content.pm.extra.VERIFICATION_RESULT"; 2050 2051 /** 2052 * Extra field name for the version code of a package pending verification. 2053 * 2054 * @hide 2055 */ 2056 public static final String EXTRA_VERIFICATION_VERSION_CODE 2057 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 2058 2059 /** 2060 * Extra field name for the ID of a intent filter pending verification. Passed to 2061 * an intent filter verifier and is used to call back to 2062 * {@link PackageManager#verifyIntentFilter(int, int)} 2063 * 2064 * @hide 2065 */ 2066 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 2067 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 2068 2069 /** 2070 * Extra field name for the scheme used for an intent filter pending verification. Passed to 2071 * an intent filter verifier and is used to construct the URI to verify against. 2072 * 2073 * Usually this is "https" 2074 * 2075 * @hide 2076 */ 2077 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 2078 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 2079 2080 /** 2081 * Extra field name for the host names to be used for an intent filter pending verification. 2082 * Passed to an intent filter verifier and is used to construct the URI to verify the 2083 * intent filter. 2084 * 2085 * This is a space delimited list of hosts. 2086 * 2087 * @hide 2088 */ 2089 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 2090 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 2091 2092 /** 2093 * Extra field name for the package name to be used for an intent filter pending verification. 2094 * Passed to an intent filter verifier and is used to check the verification responses coming 2095 * from the hosts. Each host response will need to include the package name of APK containing 2096 * the intent filter. 2097 * 2098 * @hide 2099 */ 2100 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 2101 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 2102 2103 /** 2104 * The action used to request that the user approve a permission request 2105 * from the application. 2106 * 2107 * @hide 2108 */ 2109 @SystemApi 2110 public static final String ACTION_REQUEST_PERMISSIONS = 2111 "android.content.pm.action.REQUEST_PERMISSIONS"; 2112 2113 /** 2114 * The names of the requested permissions. 2115 * <p> 2116 * <strong>Type:</strong> String[] 2117 * </p> 2118 * 2119 * @hide 2120 */ 2121 @SystemApi 2122 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 2123 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 2124 2125 /** 2126 * The results from the permissions request. 2127 * <p> 2128 * <strong>Type:</strong> int[] of #PermissionResult 2129 * </p> 2130 * 2131 * @hide 2132 */ 2133 @SystemApi 2134 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 2135 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 2136 2137 /** 2138 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2139 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 2140 * the existing definition for the permission. 2141 * @hide 2142 */ 2143 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 2144 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 2145 2146 /** 2147 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2148 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 2149 * being redundantly defined by the package being installed. 2150 * @hide 2151 */ 2152 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 2153 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 2154 2155 /** 2156 * Permission flag: The permission is set in its current state 2157 * by the user and apps can still request it at runtime. 2158 * 2159 * @hide 2160 */ 2161 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 2162 2163 /** 2164 * Permission flag: The permission is set in its current state 2165 * by the user and it is fixed, i.e. apps can no longer request 2166 * this permission. 2167 * 2168 * @hide 2169 */ 2170 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 2171 2172 /** 2173 * Permission flag: The permission is set in its current state 2174 * by device policy and neither apps nor the user can change 2175 * its state. 2176 * 2177 * @hide 2178 */ 2179 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 2180 2181 /** 2182 * Permission flag: The permission is set in a granted state but 2183 * access to resources it guards is restricted by other means to 2184 * enable revoking a permission on legacy apps that do not support 2185 * runtime permissions. If this permission is upgraded to runtime 2186 * because the app was updated to support runtime permissions, the 2187 * the permission will be revoked in the upgrade process. 2188 * 2189 * @hide 2190 */ 2191 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 2192 2193 /** 2194 * Permission flag: The permission is set in its current state 2195 * because the app is a component that is a part of the system. 2196 * 2197 * @hide 2198 */ 2199 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 2200 2201 /** 2202 * Permission flag: The permission is granted by default because it 2203 * enables app functionality that is expected to work out-of-the-box 2204 * for providing a smooth user experience. For example, the phone app 2205 * is expected to have the phone permission. 2206 * 2207 * @hide 2208 */ 2209 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 2210 2211 /** 2212 * Permission flag: The permission has to be reviewed before any of 2213 * the app components can run. 2214 * 2215 * @hide 2216 */ 2217 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 2218 2219 /** 2220 * Mask for all permission flags. 2221 * 2222 * @hide 2223 */ 2224 @SystemApi 2225 public static final int MASK_PERMISSION_FLAGS = 0xFF; 2226 2227 /** 2228 * Retrieve overall information about an application package that is 2229 * installed on the system. 2230 * <p> 2231 * Throws {@link NameNotFoundException} if a package with the given name can 2232 * not be found on the system. 2233 * 2234 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2235 * desired package. 2236 * @param flags Additional option flags. Use any combination of 2237 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 2238 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 2239 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2240 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2241 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 2242 * modify the data returned. 2243 * @return A PackageInfo object containing information about the 2244 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 2245 * package is not found in the list of installed applications, the 2246 * package information is retrieved from the list of uninstalled 2247 * applications (which includes installed applications as well as 2248 * applications with data directory i.e. applications which had been 2249 * deleted with {@code DONT_DELETE_DATA} flag set). 2250 * @see #GET_ACTIVITIES 2251 * @see #GET_GIDS 2252 * @see #GET_CONFIGURATIONS 2253 * @see #GET_INSTRUMENTATION 2254 * @see #GET_PERMISSIONS 2255 * @see #GET_PROVIDERS 2256 * @see #GET_RECEIVERS 2257 * @see #GET_SERVICES 2258 * @see #GET_SIGNATURES 2259 * @see #GET_UNINSTALLED_PACKAGES 2260 */ 2261 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) 2262 throws NameNotFoundException; 2263 2264 /** 2265 * @hide 2266 * Retrieve overall information about an application package that is 2267 * installed on the system. 2268 * <p> 2269 * Throws {@link NameNotFoundException} if a package with the given name can 2270 * not be found on the system. 2271 * 2272 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2273 * desired package. 2274 * @param flags Additional option flags. Use any combination of 2275 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 2276 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 2277 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2278 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2279 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 2280 * modify the data returned. 2281 * @param userId The user id. 2282 * @return A PackageInfo object containing information about the 2283 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 2284 * package is not found in the list of installed applications, the 2285 * package information is retrieved from the list of uninstalled 2286 * applications (which includes installed applications as well as 2287 * applications with data directory i.e. applications which had been 2288 * deleted with {@code DONT_DELETE_DATA} flag set). 2289 * @see #GET_ACTIVITIES 2290 * @see #GET_GIDS 2291 * @see #GET_CONFIGURATIONS 2292 * @see #GET_INSTRUMENTATION 2293 * @see #GET_PERMISSIONS 2294 * @see #GET_PROVIDERS 2295 * @see #GET_RECEIVERS 2296 * @see #GET_SERVICES 2297 * @see #GET_SIGNATURES 2298 * @see #GET_UNINSTALLED_PACKAGES 2299 */ 2300 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 2301 public abstract PackageInfo getPackageInfoAsUser(String packageName, 2302 @PackageInfoFlags int flags, int userId) throws NameNotFoundException; 2303 2304 /** 2305 * Map from the current package names in use on the device to whatever 2306 * the current canonical name of that package is. 2307 * @param names Array of current names to be mapped. 2308 * @return Returns an array of the same size as the original, containing 2309 * the canonical name for each package. 2310 */ 2311 public abstract String[] currentToCanonicalPackageNames(String[] names); 2312 2313 /** 2314 * Map from a packages canonical name to the current name in use on the device. 2315 * @param names Array of new names to be mapped. 2316 * @return Returns an array of the same size as the original, containing 2317 * the current name for each package. 2318 */ 2319 public abstract String[] canonicalToCurrentPackageNames(String[] names); 2320 2321 /** 2322 * Returns a "good" intent to launch a front-door activity in a package. 2323 * This is used, for example, to implement an "open" button when browsing 2324 * through packages. The current implementation looks first for a main 2325 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 2326 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 2327 * <code>null</code> if neither are found. 2328 * 2329 * @param packageName The name of the package to inspect. 2330 * 2331 * @return A fully-qualified {@link Intent} that can be used to launch the 2332 * main activity in the package. Returns <code>null</code> if the package 2333 * does not contain such an activity, or if <em>packageName</em> is not 2334 * recognized. 2335 */ 2336 public abstract Intent getLaunchIntentForPackage(String packageName); 2337 2338 /** 2339 * Return a "good" intent to launch a front-door Leanback activity in a 2340 * package, for use for example to implement an "open" button when browsing 2341 * through packages. The current implementation will look for a main 2342 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 2343 * return null if no main leanback activities are found. 2344 * <p> 2345 * Throws {@link NameNotFoundException} if a package with the given name 2346 * cannot be found on the system. 2347 * 2348 * @param packageName The name of the package to inspect. 2349 * @return Returns either a fully-qualified Intent that can be used to launch 2350 * the main Leanback activity in the package, or null if the package 2351 * does not contain such an activity. 2352 */ 2353 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 2354 2355 /** 2356 * Return an array of all of the secondary group-ids that have been assigned 2357 * to a package. 2358 * <p> 2359 * Throws {@link NameNotFoundException} if a package with the given name 2360 * cannot be found on the system. 2361 * 2362 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2363 * desired package. 2364 * @return Returns an int array of the assigned gids, or null if there are 2365 * none. 2366 */ 2367 public abstract int[] getPackageGids(String packageName) 2368 throws NameNotFoundException; 2369 2370 /** 2371 * @hide Return the uid associated with the given package name for the 2372 * given user. 2373 * 2374 * <p>Throws {@link NameNotFoundException} if a package with the given 2375 * name can not be found on the system. 2376 * 2377 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2378 * desired package. 2379 * @param userHandle The user handle identifier to look up the package under. 2380 * 2381 * @return Returns an integer uid who owns the given package name. 2382 */ 2383 public abstract int getPackageUid(String packageName, int userHandle) 2384 throws NameNotFoundException; 2385 2386 /** 2387 * Retrieve all of the information we know about a particular permission. 2388 * 2389 * <p>Throws {@link NameNotFoundException} if a permission with the given 2390 * name cannot be found on the system. 2391 * 2392 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 2393 * of the permission you are interested in. 2394 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2395 * retrieve any meta-data associated with the permission. 2396 * 2397 * @return Returns a {@link PermissionInfo} containing information about the 2398 * permission. 2399 */ 2400 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags) 2401 throws NameNotFoundException; 2402 2403 /** 2404 * Query for all of the permissions associated with a particular group. 2405 * 2406 * <p>Throws {@link NameNotFoundException} if the given group does not 2407 * exist. 2408 * 2409 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 2410 * of the permission group you are interested in. Use null to 2411 * find all of the permissions not associated with a group. 2412 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2413 * retrieve any meta-data associated with the permissions. 2414 * 2415 * @return Returns a list of {@link PermissionInfo} containing information 2416 * about all of the permissions in the given group. 2417 */ 2418 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 2419 @PermissionInfoFlags int flags) throws NameNotFoundException; 2420 2421 /** 2422 * Retrieve all of the information we know about a particular group of 2423 * permissions. 2424 * 2425 * <p>Throws {@link NameNotFoundException} if a permission group with the given 2426 * name cannot be found on the system. 2427 * 2428 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 2429 * of the permission you are interested in. 2430 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2431 * retrieve any meta-data associated with the permission group. 2432 * 2433 * @return Returns a {@link PermissionGroupInfo} containing information 2434 * about the permission. 2435 */ 2436 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 2437 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 2438 2439 /** 2440 * Retrieve all of the known permission groups in the system. 2441 * 2442 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2443 * retrieve any meta-data associated with the permission group. 2444 * 2445 * @return Returns a list of {@link PermissionGroupInfo} containing 2446 * information about all of the known permission groups. 2447 */ 2448 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 2449 @PermissionGroupInfoFlags int flags); 2450 2451 /** 2452 * Retrieve all of the information we know about a particular 2453 * package/application. 2454 * 2455 * <p>Throws {@link NameNotFoundException} if an application with the given 2456 * package name cannot be found on the system. 2457 * 2458 * @param packageName The full name (i.e. com.google.apps.contacts) of an 2459 * application. 2460 * @param flags Additional option flags. Use any combination of 2461 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2462 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2463 * 2464 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 2465 * information about the package. 2466 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 2467 * found in the list of installed applications, 2468 * the application information is retrieved from the 2469 * list of uninstalled applications(which includes 2470 * installed applications as well as applications 2471 * with data directory ie applications which had been 2472 * deleted with {@code DONT_DELETE_DATA} flag set). 2473 * 2474 * @see #GET_META_DATA 2475 * @see #GET_SHARED_LIBRARY_FILES 2476 * @see #GET_UNINSTALLED_PACKAGES 2477 */ 2478 public abstract ApplicationInfo getApplicationInfo(String packageName, 2479 @ApplicationInfoFlags int flags) throws NameNotFoundException; 2480 2481 /** 2482 * Retrieve all of the information we know about a particular activity 2483 * class. 2484 * 2485 * <p>Throws {@link NameNotFoundException} if an activity with the given 2486 * class name cannot be found on the system. 2487 * 2488 * @param component The full component name (i.e. 2489 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 2490 * class. 2491 * @param flags Additional option flags. Use any combination of 2492 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2493 * to modify the data (in ApplicationInfo) returned. 2494 * 2495 * @return {@link ActivityInfo} containing information about the activity. 2496 * 2497 * @see #GET_INTENT_FILTERS 2498 * @see #GET_META_DATA 2499 * @see #GET_SHARED_LIBRARY_FILES 2500 */ 2501 public abstract ActivityInfo getActivityInfo(ComponentName component, 2502 @ComponentInfoFlags int flags) throws NameNotFoundException; 2503 2504 /** 2505 * Retrieve all of the information we know about a particular receiver 2506 * class. 2507 * 2508 * <p>Throws {@link NameNotFoundException} if a receiver with the given 2509 * class name cannot be found on the system. 2510 * 2511 * @param component The full component name (i.e. 2512 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 2513 * class. 2514 * @param flags Additional option flags. Use any combination of 2515 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2516 * to modify the data returned. 2517 * 2518 * @return {@link ActivityInfo} containing information about the receiver. 2519 * 2520 * @see #GET_INTENT_FILTERS 2521 * @see #GET_META_DATA 2522 * @see #GET_SHARED_LIBRARY_FILES 2523 */ 2524 public abstract ActivityInfo getReceiverInfo(ComponentName component, 2525 @ComponentInfoFlags int flags) throws NameNotFoundException; 2526 2527 /** 2528 * Retrieve all of the information we know about a particular service 2529 * class. 2530 * 2531 * <p>Throws {@link NameNotFoundException} if a service with the given 2532 * class name cannot be found on the system. 2533 * 2534 * @param component The full component name (i.e. 2535 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 2536 * class. 2537 * @param flags Additional option flags. Use any combination of 2538 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2539 * to modify the data returned. 2540 * 2541 * @return ServiceInfo containing information about the service. 2542 * 2543 * @see #GET_META_DATA 2544 * @see #GET_SHARED_LIBRARY_FILES 2545 */ 2546 public abstract ServiceInfo getServiceInfo(ComponentName component, 2547 @ComponentInfoFlags int flags) throws NameNotFoundException; 2548 2549 /** 2550 * Retrieve all of the information we know about a particular content 2551 * provider class. 2552 * 2553 * <p>Throws {@link NameNotFoundException} if a provider with the given 2554 * class name cannot be found on the system. 2555 * 2556 * @param component The full component name (i.e. 2557 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 2558 * ContentProvider class. 2559 * @param flags Additional option flags. Use any combination of 2560 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2561 * to modify the data returned. 2562 * 2563 * @return ProviderInfo containing information about the service. 2564 * 2565 * @see #GET_META_DATA 2566 * @see #GET_SHARED_LIBRARY_FILES 2567 */ 2568 public abstract ProviderInfo getProviderInfo(ComponentName component, 2569 @ComponentInfoFlags int flags) throws NameNotFoundException; 2570 2571 /** 2572 * Return a List of all packages that are installed 2573 * on the device. 2574 * 2575 * @param flags Additional option flags. Use any combination of 2576 * {@link #GET_ACTIVITIES}, 2577 * {@link #GET_GIDS}, 2578 * {@link #GET_CONFIGURATIONS}, 2579 * {@link #GET_INSTRUMENTATION}, 2580 * {@link #GET_PERMISSIONS}, 2581 * {@link #GET_PROVIDERS}, 2582 * {@link #GET_RECEIVERS}, 2583 * {@link #GET_SERVICES}, 2584 * {@link #GET_SIGNATURES}, 2585 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2586 * 2587 * @return A List of PackageInfo objects, one for each package that is 2588 * installed on the device. In the unlikely case of there being no 2589 * installed packages, an empty list is returned. 2590 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2591 * applications including those deleted with {@code DONT_DELETE_DATA} 2592 * (partially installed apps with data directory) will be returned. 2593 * 2594 * @see #GET_ACTIVITIES 2595 * @see #GET_GIDS 2596 * @see #GET_CONFIGURATIONS 2597 * @see #GET_INSTRUMENTATION 2598 * @see #GET_PERMISSIONS 2599 * @see #GET_PROVIDERS 2600 * @see #GET_RECEIVERS 2601 * @see #GET_SERVICES 2602 * @see #GET_SIGNATURES 2603 * @see #GET_UNINSTALLED_PACKAGES 2604 */ 2605 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags); 2606 2607 /** 2608 * Return a List of all installed packages that are currently 2609 * holding any of the given permissions. 2610 * 2611 * @param flags Additional option flags. Use any combination of 2612 * {@link #GET_ACTIVITIES}, 2613 * {@link #GET_GIDS}, 2614 * {@link #GET_CONFIGURATIONS}, 2615 * {@link #GET_INSTRUMENTATION}, 2616 * {@link #GET_PERMISSIONS}, 2617 * {@link #GET_PROVIDERS}, 2618 * {@link #GET_RECEIVERS}, 2619 * {@link #GET_SERVICES}, 2620 * {@link #GET_SIGNATURES}, 2621 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2622 * 2623 * @return Returns a List of PackageInfo objects, one for each installed 2624 * application that is holding any of the permissions that were provided. 2625 * 2626 * @see #GET_ACTIVITIES 2627 * @see #GET_GIDS 2628 * @see #GET_CONFIGURATIONS 2629 * @see #GET_INSTRUMENTATION 2630 * @see #GET_PERMISSIONS 2631 * @see #GET_PROVIDERS 2632 * @see #GET_RECEIVERS 2633 * @see #GET_SERVICES 2634 * @see #GET_SIGNATURES 2635 * @see #GET_UNINSTALLED_PACKAGES 2636 */ 2637 public abstract List<PackageInfo> getPackagesHoldingPermissions( 2638 String[] permissions, @PackageInfoFlags int flags); 2639 2640 /** 2641 * Return a List of all packages that are installed on the device, for a specific user. 2642 * Requesting a list of installed packages for another user 2643 * will require the permission INTERACT_ACROSS_USERS_FULL. 2644 * @param flags Additional option flags. Use any combination of 2645 * {@link #GET_ACTIVITIES}, 2646 * {@link #GET_GIDS}, 2647 * {@link #GET_CONFIGURATIONS}, 2648 * {@link #GET_INSTRUMENTATION}, 2649 * {@link #GET_PERMISSIONS}, 2650 * {@link #GET_PROVIDERS}, 2651 * {@link #GET_RECEIVERS}, 2652 * {@link #GET_SERVICES}, 2653 * {@link #GET_SIGNATURES}, 2654 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2655 * @param userId The user for whom the installed packages are to be listed 2656 * 2657 * @return A List of PackageInfo objects, one for each package that is 2658 * installed on the device. In the unlikely case of there being no 2659 * installed packages, an empty list is returned. 2660 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2661 * applications including those deleted with {@code DONT_DELETE_DATA} 2662 * (partially installed apps with data directory) will be returned. 2663 * 2664 * @see #GET_ACTIVITIES 2665 * @see #GET_GIDS 2666 * @see #GET_CONFIGURATIONS 2667 * @see #GET_INSTRUMENTATION 2668 * @see #GET_PERMISSIONS 2669 * @see #GET_PROVIDERS 2670 * @see #GET_RECEIVERS 2671 * @see #GET_SERVICES 2672 * @see #GET_SIGNATURES 2673 * @see #GET_UNINSTALLED_PACKAGES 2674 * 2675 * @hide 2676 */ 2677 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags, int userId); 2678 2679 /** 2680 * Check whether a particular package has been granted a particular 2681 * permission. 2682 * 2683 * @param permName The name of the permission you are checking for. 2684 * @param pkgName The name of the package you are checking against. 2685 * 2686 * @return If the package has the permission, PERMISSION_GRANTED is 2687 * returned. If it does not have the permission, PERMISSION_DENIED 2688 * is returned. 2689 * 2690 * @see #PERMISSION_GRANTED 2691 * @see #PERMISSION_DENIED 2692 */ 2693 @CheckResult 2694 public abstract int checkPermission(String permName, String pkgName); 2695 2696 /** 2697 * Checks whether a particular permissions has been revoked for a 2698 * package by policy. Typically the device owner or the profile owner 2699 * may apply such a policy. The user cannot grant policy revoked 2700 * permissions, hence the only way for an app to get such a permission 2701 * is by a policy change. 2702 * 2703 * @param permName The name of the permission you are checking for. 2704 * @param pkgName The name of the package you are checking against. 2705 * 2706 * @return Whether the permission is restricted by policy. 2707 */ 2708 @CheckResult 2709 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 2710 @NonNull String pkgName); 2711 2712 /** 2713 * Gets the package name of the component controlling runtime permissions. 2714 * 2715 * @return The package name. 2716 * 2717 * @hide 2718 */ 2719 public abstract String getPermissionControllerPackageName(); 2720 2721 /** 2722 * Add a new dynamic permission to the system. For this to work, your 2723 * package must have defined a permission tree through the 2724 * {@link android.R.styleable#AndroidManifestPermissionTree 2725 * <permission-tree>} tag in its manifest. A package can only add 2726 * permissions to trees that were defined by either its own package or 2727 * another with the same user id; a permission is in a tree if it 2728 * matches the name of the permission tree + ".": for example, 2729 * "com.foo.bar" is a member of the permission tree "com.foo". 2730 * 2731 * <p>It is good to make your permission tree name descriptive, because you 2732 * are taking possession of that entire set of permission names. Thus, it 2733 * must be under a domain you control, with a suffix that will not match 2734 * any normal permissions that may be declared in any applications that 2735 * are part of that domain. 2736 * 2737 * <p>New permissions must be added before 2738 * any .apks are installed that use those permissions. Permissions you 2739 * add through this method are remembered across reboots of the device. 2740 * If the given permission already exists, the info you supply here 2741 * will be used to update it. 2742 * 2743 * @param info Description of the permission to be added. 2744 * 2745 * @return Returns true if a new permission was created, false if an 2746 * existing one was updated. 2747 * 2748 * @throws SecurityException if you are not allowed to add the 2749 * given permission name. 2750 * 2751 * @see #removePermission(String) 2752 */ 2753 public abstract boolean addPermission(PermissionInfo info); 2754 2755 /** 2756 * Like {@link #addPermission(PermissionInfo)} but asynchronously 2757 * persists the package manager state after returning from the call, 2758 * allowing it to return quicker and batch a series of adds at the 2759 * expense of no guarantee the added permission will be retained if 2760 * the device is rebooted before it is written. 2761 */ 2762 public abstract boolean addPermissionAsync(PermissionInfo info); 2763 2764 /** 2765 * Removes a permission that was previously added with 2766 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 2767 * -- you are only allowed to remove permissions that you are allowed 2768 * to add. 2769 * 2770 * @param name The name of the permission to remove. 2771 * 2772 * @throws SecurityException if you are not allowed to remove the 2773 * given permission name. 2774 * 2775 * @see #addPermission(PermissionInfo) 2776 */ 2777 public abstract void removePermission(String name); 2778 2779 2780 /** 2781 * Permission flags set when granting or revoking a permission. 2782 * 2783 * @hide 2784 */ 2785 @SystemApi 2786 @IntDef({FLAG_PERMISSION_USER_SET, 2787 FLAG_PERMISSION_USER_FIXED, 2788 FLAG_PERMISSION_POLICY_FIXED, 2789 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 2790 FLAG_PERMISSION_SYSTEM_FIXED, 2791 FLAG_PERMISSION_GRANTED_BY_DEFAULT}) 2792 @Retention(RetentionPolicy.SOURCE) 2793 public @interface PermissionFlags {} 2794 2795 /** 2796 * Grant a runtime permission to an application which the application does not 2797 * already have. The permission must have been requested by the application. 2798 * If the application is not allowed to hold the permission, a {@link 2799 * java.lang.SecurityException} is thrown. 2800 * <p> 2801 * <strong>Note: </strong>Using this API requires holding 2802 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 2803 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 2804 * </p> 2805 * 2806 * @param packageName The package to which to grant the permission. 2807 * @param permissionName The permission name to grant. 2808 * @param user The user for which to grant the permission. 2809 * 2810 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 2811 * @see android.content.pm.PackageManager.PermissionFlags 2812 * 2813 * @hide 2814 */ 2815 @SystemApi 2816 public abstract void grantRuntimePermission(@NonNull String packageName, 2817 @NonNull String permissionName, @NonNull UserHandle user); 2818 2819 /** 2820 * Revoke a runtime permission that was previously granted by {@link 2821 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 2822 * permission must have been requested by and granted to the application. 2823 * If the application is not allowed to hold the permission, a {@link 2824 * java.lang.SecurityException} is thrown. 2825 * <p> 2826 * <strong>Note: </strong>Using this API requires holding 2827 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 2828 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 2829 * </p> 2830 * 2831 * @param packageName The package from which to revoke the permission. 2832 * @param permissionName The permission name to revoke. 2833 * @param user The user for which to revoke the permission. 2834 * 2835 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 2836 * @see android.content.pm.PackageManager.PermissionFlags 2837 * 2838 * @hide 2839 */ 2840 @SystemApi 2841 public abstract void revokeRuntimePermission(@NonNull String packageName, 2842 @NonNull String permissionName, @NonNull UserHandle user); 2843 2844 /** 2845 * Gets the state flags associated with a permission. 2846 * 2847 * @param permissionName The permission for which to get the flags. 2848 * @param packageName The package name for which to get the flags. 2849 * @param user The user for which to get permission flags. 2850 * @return The permission flags. 2851 * 2852 * @hide 2853 */ 2854 @SystemApi 2855 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 2856 String packageName, @NonNull UserHandle user); 2857 2858 /** 2859 * Updates the flags associated with a permission by replacing the flags in 2860 * the specified mask with the provided flag values. 2861 * 2862 * @param permissionName The permission for which to update the flags. 2863 * @param packageName The package name for which to update the flags. 2864 * @param flagMask The flags which to replace. 2865 * @param flagValues The flags with which to replace. 2866 * @param user The user for which to update the permission flags. 2867 * 2868 * @hide 2869 */ 2870 @SystemApi 2871 public abstract void updatePermissionFlags(String permissionName, 2872 String packageName, @PermissionFlags int flagMask, int flagValues, 2873 @NonNull UserHandle user); 2874 2875 /** 2876 * Gets whether you should show UI with rationale for requesting a permission. 2877 * You should do this only if you do not have the permission and the context in 2878 * which the permission is requested does not clearly communicate to the user 2879 * what would be the benefit from grating this permission. 2880 * 2881 * @param permission A permission your app wants to request. 2882 * @return Whether you can show permission rationale UI. 2883 * 2884 * @hide 2885 */ 2886 public abstract boolean shouldShowRequestPermissionRationale(String permission); 2887 2888 /** 2889 * Returns an {@link android.content.Intent} suitable for passing to 2890 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 2891 * which prompts the user to grant permissions to this application. 2892 * 2893 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 2894 * 2895 * @hide 2896 */ 2897 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 2898 if (ArrayUtils.isEmpty(permissions)) { 2899 throw new NullPointerException("permission cannot be null or empty"); 2900 } 2901 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 2902 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 2903 intent.setPackage(getPermissionControllerPackageName()); 2904 return intent; 2905 } 2906 2907 /** 2908 * Compare the signatures of two packages to determine if the same 2909 * signature appears in both of them. If they do contain the same 2910 * signature, then they are allowed special privileges when working 2911 * with each other: they can share the same user-id, run instrumentation 2912 * against each other, etc. 2913 * 2914 * @param pkg1 First package name whose signature will be compared. 2915 * @param pkg2 Second package name whose signature will be compared. 2916 * 2917 * @return Returns an integer indicating whether all signatures on the 2918 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2919 * all signatures match or < 0 if there is not a match ({@link 2920 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2921 * 2922 * @see #checkSignatures(int, int) 2923 * @see #SIGNATURE_MATCH 2924 * @see #SIGNATURE_NO_MATCH 2925 * @see #SIGNATURE_UNKNOWN_PACKAGE 2926 */ 2927 @CheckResult 2928 public abstract int checkSignatures(String pkg1, String pkg2); 2929 2930 /** 2931 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 2932 * the two packages to be checked. This can be useful, for example, 2933 * when doing the check in an IPC, where the UID is the only identity 2934 * available. It is functionally identical to determining the package 2935 * associated with the UIDs and checking their signatures. 2936 * 2937 * @param uid1 First UID whose signature will be compared. 2938 * @param uid2 Second UID whose signature will be compared. 2939 * 2940 * @return Returns an integer indicating whether all signatures on the 2941 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2942 * all signatures match or < 0 if there is not a match ({@link 2943 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2944 * 2945 * @see #checkSignatures(String, String) 2946 * @see #SIGNATURE_MATCH 2947 * @see #SIGNATURE_NO_MATCH 2948 * @see #SIGNATURE_UNKNOWN_PACKAGE 2949 */ 2950 @CheckResult 2951 public abstract int checkSignatures(int uid1, int uid2); 2952 2953 /** 2954 * Retrieve the names of all packages that are associated with a particular 2955 * user id. In most cases, this will be a single package name, the package 2956 * that has been assigned that user id. Where there are multiple packages 2957 * sharing the same user id through the "sharedUserId" mechanism, all 2958 * packages with that id will be returned. 2959 * 2960 * @param uid The user id for which you would like to retrieve the 2961 * associated packages. 2962 * 2963 * @return Returns an array of one or more packages assigned to the user 2964 * id, or null if there are no known packages with the given id. 2965 */ 2966 public abstract String[] getPackagesForUid(int uid); 2967 2968 /** 2969 * Retrieve the official name associated with a user id. This name is 2970 * guaranteed to never change, though it is possible for the underlying 2971 * user id to be changed. That is, if you are storing information about 2972 * user ids in persistent storage, you should use the string returned 2973 * by this function instead of the raw user-id. 2974 * 2975 * @param uid The user id for which you would like to retrieve a name. 2976 * @return Returns a unique name for the given user id, or null if the 2977 * user id is not currently assigned. 2978 */ 2979 public abstract String getNameForUid(int uid); 2980 2981 /** 2982 * Return the user id associated with a shared user name. Multiple 2983 * applications can specify a shared user name in their manifest and thus 2984 * end up using a common uid. This might be used for new applications 2985 * that use an existing shared user name and need to know the uid of the 2986 * shared user. 2987 * 2988 * @param sharedUserName The shared user name whose uid is to be retrieved. 2989 * @return Returns the uid associated with the shared user, or NameNotFoundException 2990 * if the shared user name is not being used by any installed packages 2991 * @hide 2992 */ 2993 public abstract int getUidForSharedUser(String sharedUserName) 2994 throws NameNotFoundException; 2995 2996 /** 2997 * Return a List of all application packages that are installed on the 2998 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 2999 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 3000 * installed apps with data directory) will be returned. 3001 * 3002 * @param flags Additional option flags. Use any combination of 3003 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3004 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 3005 * 3006 * @return Returns a List of ApplicationInfo objects, one for each application that 3007 * is installed on the device. In the unlikely case of there being 3008 * no installed applications, an empty list is returned. 3009 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 3010 * applications including those deleted with {@code DONT_DELETE_DATA} 3011 * (partially installed apps with data directory) will be returned. 3012 * 3013 * @see #GET_META_DATA 3014 * @see #GET_SHARED_LIBRARY_FILES 3015 * @see #GET_UNINSTALLED_PACKAGES 3016 */ 3017 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 3018 3019 /** 3020 * Gets the ephemeral applications the user recently used. Requires 3021 * holding "android.permission.ACCESS_EPHEMERAL_APPS". 3022 * 3023 * @return The ephemeral app list. 3024 * 3025 * @hide 3026 */ 3027 @RequiresPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS) 3028 public abstract List<EphemeralApplicationInfo> getEphemeralApplications(); 3029 3030 /** 3031 * Gets the icon for an ephemeral application. 3032 * 3033 * @param packageName The app package name. 3034 * 3035 * @hide 3036 */ 3037 public abstract Drawable getEphemeralApplicationIcon(String packageName); 3038 3039 /** 3040 * Gets whether the caller is an ephemeral app. 3041 * 3042 * @return Whether caller is an ephemeral app. 3043 * 3044 * @see #setEphemeralCookie(byte[]) 3045 * @see #getEphemeralCookie() 3046 * @see #getEphemeralCookieMaxSizeBytes() 3047 */ 3048 public abstract boolean isEphemeralApplication(); 3049 3050 /** 3051 * Gets the maximum size in bytes of the cookie data an ephemeral app 3052 * can store on the device. 3053 * 3054 * @return The max cookie size in bytes. 3055 * 3056 * @see #isEphemeralApplication() 3057 * @see #setEphemeralCookie(byte[]) 3058 * @see #getEphemeralCookie() 3059 */ 3060 public abstract int getEphemeralCookieMaxSizeBytes(); 3061 3062 /** 3063 * Gets the ephemeral application cookie for this app. Non 3064 * ephemeral apps and apps that were ephemeral but were upgraded 3065 * to non-ephemeral can still access this API. For ephemeral apps 3066 * this cooke is cached for some time after uninstall while for 3067 * normal apps the cookie is deleted after the app is uninstalled. 3068 * The cookie is always present while the app is installed. 3069 * 3070 * @return The cookie. 3071 * 3072 * @see #isEphemeralApplication() 3073 * @see #setEphemeralCookie(byte[]) 3074 * @see #getEphemeralCookieMaxSizeBytes() 3075 */ 3076 public abstract @NonNull byte[] getEphemeralCookie(); 3077 3078 /** 3079 * Sets the ephemeral application cookie for the calling app. Non 3080 * ephemeral apps and apps that were ephemeral but were upgraded 3081 * to non-ephemeral can still access this API. For ephemeral apps 3082 * this cooke is cached for some time after uninstall while for 3083 * normal apps the cookie is deleted after the app is uninstalled. 3084 * The cookie is always present while the app is installed. The 3085 * cookie size is limited by {@link #getEphemeralCookieMaxSizeBytes()}. 3086 * 3087 * @param cookie The cookie data. 3088 * @return True if the cookie was set. 3089 * 3090 * @see #isEphemeralApplication() 3091 * @see #getEphemeralCookieMaxSizeBytes() 3092 * @see #getEphemeralCookie(); 3093 */ 3094 public abstract boolean setEphemeralCookie(@NonNull byte[] cookie); 3095 3096 /** 3097 * Get a list of shared libraries that are available on the 3098 * system. 3099 * 3100 * @return An array of shared library names that are 3101 * available on the system, or null if none are installed. 3102 * 3103 */ 3104 public abstract String[] getSystemSharedLibraryNames(); 3105 3106 /** 3107 * Get a list of features that are available on the 3108 * system. 3109 * 3110 * @return An array of FeatureInfo classes describing the features 3111 * that are available on the system, or null if there are none(!!). 3112 */ 3113 public abstract FeatureInfo[] getSystemAvailableFeatures(); 3114 3115 /** 3116 * Check whether the given feature name is one of the available 3117 * features as returned by {@link #getSystemAvailableFeatures()}. 3118 * 3119 * @return Returns true if the devices supports the feature, else 3120 * false. 3121 */ 3122 public abstract boolean hasSystemFeature(String name); 3123 3124 /** 3125 * Determine the best action to perform for a given Intent. This is how 3126 * {@link Intent#resolveActivity} finds an activity if a class has not 3127 * been explicitly specified. 3128 * 3129 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 3130 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 3131 * only flag. You need to do so to resolve the activity in the same way 3132 * that {@link android.content.Context#startActivity(Intent)} and 3133 * {@link android.content.Intent#resolveActivity(PackageManager) 3134 * Intent.resolveActivity(PackageManager)} do.</p> 3135 * 3136 * @param intent An intent containing all of the desired specification 3137 * (action, data, type, category, and/or component). 3138 * @param flags Additional option flags. The most important is 3139 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3140 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3141 * 3142 * @return Returns a ResolveInfo containing the final activity intent that 3143 * was determined to be the best action. Returns null if no 3144 * matching activity was found. If multiple matching activities are 3145 * found and there is no default set, returns a ResolveInfo 3146 * containing something else, such as the activity resolver. 3147 * 3148 * @see #MATCH_DEFAULT_ONLY 3149 * @see #GET_INTENT_FILTERS 3150 * @see #GET_RESOLVED_FILTER 3151 */ 3152 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags); 3153 3154 /** 3155 * Determine the best action to perform for a given Intent for a given user. This 3156 * is how {@link Intent#resolveActivity} finds an activity if a class has not 3157 * been explicitly specified. 3158 * 3159 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 3160 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 3161 * only flag. You need to do so to resolve the activity in the same way 3162 * that {@link android.content.Context#startActivity(Intent)} and 3163 * {@link android.content.Intent#resolveActivity(PackageManager) 3164 * Intent.resolveActivity(PackageManager)} do.</p> 3165 * 3166 * @param intent An intent containing all of the desired specification 3167 * (action, data, type, category, and/or component). 3168 * @param flags Additional option flags. The most important is 3169 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3170 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3171 * @param userId The user id. 3172 * 3173 * @return Returns a ResolveInfo containing the final activity intent that 3174 * was determined to be the best action. Returns null if no 3175 * matching activity was found. If multiple matching activities are 3176 * found and there is no default set, returns a ResolveInfo 3177 * containing something else, such as the activity resolver. 3178 * 3179 * @see #MATCH_DEFAULT_ONLY 3180 * @see #GET_INTENT_FILTERS 3181 * @see #GET_RESOLVED_FILTER 3182 * 3183 * @hide 3184 */ 3185 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, 3186 int userId); 3187 3188 /** 3189 * Retrieve all activities that can be performed for the given intent. 3190 * 3191 * @param intent The desired intent as per resolveActivity(). 3192 * @param flags Additional option flags. The most important is 3193 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3194 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3195 * 3196 * You can also set {@link #MATCH_ALL} for preventing the filtering of the results. 3197 * 3198 * @return A List<ResolveInfo> containing one entry for each matching 3199 * Activity. These are ordered from best to worst match -- that 3200 * is, the first item in the list is what is returned by 3201 * {@link #resolveActivity}. If there are no matching activities, an empty 3202 * list is returned. 3203 * 3204 * @see #MATCH_DEFAULT_ONLY 3205 * @see #GET_INTENT_FILTERS 3206 * @see #GET_RESOLVED_FILTER 3207 */ 3208 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 3209 @ResolveInfoFlags int flags); 3210 3211 /** 3212 * Retrieve all activities that can be performed for the given intent, for a specific user. 3213 * 3214 * @param intent The desired intent as per resolveActivity(). 3215 * @param flags Additional option flags. The most important is 3216 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3217 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3218 * 3219 * You can also set {@link #MATCH_ALL} for preventing the filtering of the results. 3220 * 3221 * @return A List<ResolveInfo> containing one entry for each matching 3222 * Activity. These are ordered from best to worst match -- that 3223 * is, the first item in the list is what is returned by 3224 * {@link #resolveActivity}. If there are no matching activities, an empty 3225 * list is returned. 3226 * 3227 * @see #MATCH_DEFAULT_ONLY 3228 * @see #GET_INTENT_FILTERS 3229 * @see #GET_RESOLVED_FILTER 3230 * @hide 3231 */ 3232 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 3233 @ResolveInfoFlags int flags, int userId); 3234 3235 /** 3236 * Retrieve a set of activities that should be presented to the user as 3237 * similar options. This is like {@link #queryIntentActivities}, except it 3238 * also allows you to supply a list of more explicit Intents that you would 3239 * like to resolve to particular options, and takes care of returning the 3240 * final ResolveInfo list in a reasonable order, with no duplicates, based 3241 * on those inputs. 3242 * 3243 * @param caller The class name of the activity that is making the 3244 * request. This activity will never appear in the output 3245 * list. Can be null. 3246 * @param specifics An array of Intents that should be resolved to the 3247 * first specific results. Can be null. 3248 * @param intent The desired intent as per resolveActivity(). 3249 * @param flags Additional option flags. The most important is 3250 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3251 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3252 * 3253 * @return A List<ResolveInfo> containing one entry for each matching 3254 * Activity. These are ordered first by all of the intents resolved 3255 * in <var>specifics</var> and then any additional activities that 3256 * can handle <var>intent</var> but did not get included by one of 3257 * the <var>specifics</var> intents. If there are no matching 3258 * activities, an empty list is returned. 3259 * 3260 * @see #MATCH_DEFAULT_ONLY 3261 * @see #GET_INTENT_FILTERS 3262 * @see #GET_RESOLVED_FILTER 3263 */ 3264 public abstract List<ResolveInfo> queryIntentActivityOptions( 3265 ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags); 3266 3267 /** 3268 * Retrieve all receivers that can handle a broadcast of the given intent. 3269 * 3270 * @param intent The desired intent as per resolveActivity(). 3271 * @param flags Additional option flags. 3272 * 3273 * @return A List<ResolveInfo> containing one entry for each matching 3274 * Receiver. These are ordered from first to last in priority. If 3275 * there are no matching receivers, an empty list is returned. 3276 * 3277 * @see #MATCH_DEFAULT_ONLY 3278 * @see #GET_INTENT_FILTERS 3279 * @see #GET_RESOLVED_FILTER 3280 */ 3281 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 3282 @ResolveInfoFlags int flags); 3283 3284 /** 3285 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 3286 * user. 3287 * 3288 * @param intent The desired intent as per resolveActivity(). 3289 * @param flags Additional option flags. 3290 * @param userId The userId of the user being queried. 3291 * 3292 * @return A List<ResolveInfo> containing one entry for each matching 3293 * Receiver. These are ordered from first to last in priority. If 3294 * there are no matching receivers, an empty list or {@code null} is returned. 3295 * 3296 * @see #MATCH_DEFAULT_ONLY 3297 * @see #GET_INTENT_FILTERS 3298 * @see #GET_RESOLVED_FILTER 3299 * @hide 3300 */ 3301 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 3302 @ResolveInfoFlags int flags, int userId); 3303 3304 /** 3305 * Determine the best service to handle for a given Intent. 3306 * 3307 * @param intent An intent containing all of the desired specification 3308 * (action, data, type, category, and/or component). 3309 * @param flags Additional option flags. 3310 * 3311 * @return Returns a ResolveInfo containing the final service intent that 3312 * was determined to be the best action. Returns null if no 3313 * matching service was found. 3314 * 3315 * @see #GET_INTENT_FILTERS 3316 * @see #GET_RESOLVED_FILTER 3317 */ 3318 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags); 3319 3320 /** 3321 * Retrieve all services that can match the given intent. 3322 * 3323 * @param intent The desired intent as per resolveService(). 3324 * @param flags Additional option flags. 3325 * 3326 * @return A List<ResolveInfo> containing one entry for each matching 3327 * ServiceInfo. These are ordered from best to worst match -- that 3328 * is, the first item in the list is what is returned by 3329 * resolveService(). If there are no matching services, an empty 3330 * list or {@code null} is returned. 3331 * 3332 * @see #GET_INTENT_FILTERS 3333 * @see #GET_RESOLVED_FILTER 3334 */ 3335 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 3336 @ResolveInfoFlags int flags); 3337 3338 /** 3339 * Retrieve all services that can match the given intent for a given user. 3340 * 3341 * @param intent The desired intent as per resolveService(). 3342 * @param flags Additional option flags. 3343 * @param userId The user id. 3344 * 3345 * @return A List<ResolveInfo> containing one entry for each matching 3346 * ServiceInfo. These are ordered from best to worst match -- that 3347 * is, the first item in the list is what is returned by 3348 * resolveService(). If there are no matching services, an empty 3349 * list or {@code null} is returned. 3350 * 3351 * @see #GET_INTENT_FILTERS 3352 * @see #GET_RESOLVED_FILTER 3353 * 3354 * @hide 3355 */ 3356 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 3357 @ResolveInfoFlags int flags, int userId); 3358 3359 /** {@hide} */ 3360 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 3361 Intent intent, @ResolveInfoFlags int flags, int userId); 3362 3363 /** 3364 * Retrieve all providers that can match the given intent. 3365 * 3366 * @param intent An intent containing all of the desired specification 3367 * (action, data, type, category, and/or component). 3368 * @param flags Additional option flags. 3369 * @return A List<ResolveInfo> containing one entry for each matching 3370 * ProviderInfo. These are ordered from best to worst match. If 3371 * there are no matching providers, an empty list or {@code null} is returned. 3372 * @see #GET_INTENT_FILTERS 3373 * @see #GET_RESOLVED_FILTER 3374 */ 3375 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, 3376 @ResolveInfoFlags int flags); 3377 3378 /** 3379 * Find a single content provider by its base path name. 3380 * 3381 * @param name The name of the provider to find. 3382 * @param flags Additional option flags. Currently should always be 0. 3383 * 3384 * @return ContentProviderInfo Information about the provider, if found, 3385 * else null. 3386 */ 3387 public abstract ProviderInfo resolveContentProvider(String name, 3388 @ComponentInfoFlags int flags); 3389 3390 /** 3391 * Find a single content provider by its base path name. 3392 * 3393 * @param name The name of the provider to find. 3394 * @param flags Additional option flags. Currently should always be 0. 3395 * @param userId The user id. 3396 * 3397 * @return ContentProviderInfo Information about the provider, if found, 3398 * else null. 3399 * @hide 3400 */ 3401 public abstract ProviderInfo resolveContentProviderAsUser(String name, 3402 @ComponentInfoFlags int flags, int userId); 3403 3404 /** 3405 * Retrieve content provider information. 3406 * 3407 * <p><em>Note: unlike most other methods, an empty result set is indicated 3408 * by a null return instead of an empty list.</em> 3409 * 3410 * @param processName If non-null, limits the returned providers to only 3411 * those that are hosted by the given process. If null, 3412 * all content providers are returned. 3413 * @param uid If <var>processName</var> is non-null, this is the required 3414 * uid owning the requested content providers. 3415 * @param flags Additional option flags. Currently should always be 0. 3416 * 3417 * @return A List<ContentProviderInfo> containing one entry for each 3418 * content provider either patching <var>processName</var> or, if 3419 * <var>processName</var> is null, all known content providers. 3420 * <em>If there are no matching providers, null is returned.</em> 3421 */ 3422 public abstract List<ProviderInfo> queryContentProviders( 3423 String processName, int uid, @ComponentInfoFlags int flags); 3424 3425 /** 3426 * Retrieve all of the information we know about a particular 3427 * instrumentation class. 3428 * 3429 * <p>Throws {@link NameNotFoundException} if instrumentation with the 3430 * given class name cannot be found on the system. 3431 * 3432 * @param className The full name (i.e. 3433 * com.google.apps.contacts.InstrumentList) of an 3434 * Instrumentation class. 3435 * @param flags Additional option flags. Currently should always be 0. 3436 * 3437 * @return InstrumentationInfo containing information about the 3438 * instrumentation. 3439 */ 3440 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className, 3441 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 3442 3443 /** 3444 * Retrieve information about available instrumentation code. May be used 3445 * to retrieve either all instrumentation code, or only the code targeting 3446 * a particular package. 3447 * 3448 * @param targetPackage If null, all instrumentation is returned; only the 3449 * instrumentation targeting this package name is 3450 * returned. 3451 * @param flags Additional option flags. Currently should always be 0. 3452 * 3453 * @return A List<InstrumentationInfo> containing one entry for each 3454 * matching available Instrumentation. Returns an empty list if 3455 * there is no instrumentation available for the given package. 3456 */ 3457 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage, 3458 @InstrumentationInfoFlags int flags); 3459 3460 /** 3461 * Retrieve an image from a package. This is a low-level API used by 3462 * the various package manager info structures (such as 3463 * {@link ComponentInfo} to implement retrieval of their associated 3464 * icon. 3465 * 3466 * @param packageName The name of the package that this icon is coming from. 3467 * Cannot be null. 3468 * @param resid The resource identifier of the desired image. Cannot be 0. 3469 * @param appInfo Overall information about <var>packageName</var>. This 3470 * may be null, in which case the application information will be retrieved 3471 * for you if needed; if you already have this information around, it can 3472 * be much more efficient to supply it here. 3473 * 3474 * @return Returns a Drawable holding the requested image. Returns null if 3475 * an image could not be found for any reason. 3476 */ 3477 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 3478 ApplicationInfo appInfo); 3479 3480 /** 3481 * Retrieve the icon associated with an activity. Given the full name of 3482 * an activity, retrieves the information about it and calls 3483 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 3484 * If the activity cannot be found, NameNotFoundException is thrown. 3485 * 3486 * @param activityName Name of the activity whose icon is to be retrieved. 3487 * 3488 * @return Returns the image of the icon, or the default activity icon if 3489 * it could not be found. Does not return null. 3490 * @throws NameNotFoundException Thrown if the resources for the given 3491 * activity could not be loaded. 3492 * 3493 * @see #getActivityIcon(Intent) 3494 */ 3495 public abstract Drawable getActivityIcon(ComponentName activityName) 3496 throws NameNotFoundException; 3497 3498 /** 3499 * Retrieve the icon associated with an Intent. If intent.getClassName() is 3500 * set, this simply returns the result of 3501 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 3502 * component and returns the icon associated with the resolved component. 3503 * If intent.getClassName() cannot be found or the Intent cannot be resolved 3504 * to a component, NameNotFoundException is thrown. 3505 * 3506 * @param intent The intent for which you would like to retrieve an icon. 3507 * 3508 * @return Returns the image of the icon, or the default activity icon if 3509 * it could not be found. Does not return null. 3510 * @throws NameNotFoundException Thrown if the resources for application 3511 * matching the given intent could not be loaded. 3512 * 3513 * @see #getActivityIcon(ComponentName) 3514 */ 3515 public abstract Drawable getActivityIcon(Intent intent) 3516 throws NameNotFoundException; 3517 3518 /** 3519 * Retrieve the banner associated with an activity. Given the full name of 3520 * an activity, retrieves the information about it and calls 3521 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 3522 * banner. If the activity cannot be found, NameNotFoundException is thrown. 3523 * 3524 * @param activityName Name of the activity whose banner is to be retrieved. 3525 * @return Returns the image of the banner, or null if the activity has no 3526 * banner specified. 3527 * @throws NameNotFoundException Thrown if the resources for the given 3528 * activity could not be loaded. 3529 * @see #getActivityBanner(Intent) 3530 */ 3531 public abstract Drawable getActivityBanner(ComponentName activityName) 3532 throws NameNotFoundException; 3533 3534 /** 3535 * Retrieve the banner associated with an Intent. If intent.getClassName() 3536 * is set, this simply returns the result of 3537 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 3538 * intent's component and returns the banner associated with the resolved 3539 * component. If intent.getClassName() cannot be found or the Intent cannot 3540 * be resolved to a component, NameNotFoundException is thrown. 3541 * 3542 * @param intent The intent for which you would like to retrieve a banner. 3543 * @return Returns the image of the banner, or null if the activity has no 3544 * banner specified. 3545 * @throws NameNotFoundException Thrown if the resources for application 3546 * matching the given intent could not be loaded. 3547 * @see #getActivityBanner(ComponentName) 3548 */ 3549 public abstract Drawable getActivityBanner(Intent intent) 3550 throws NameNotFoundException; 3551 3552 /** 3553 * Return the generic icon for an activity that is used when no specific 3554 * icon is defined. 3555 * 3556 * @return Drawable Image of the icon. 3557 */ 3558 public abstract Drawable getDefaultActivityIcon(); 3559 3560 /** 3561 * Retrieve the icon associated with an application. If it has not defined 3562 * an icon, the default app icon is returned. Does not return null. 3563 * 3564 * @param info Information about application being queried. 3565 * 3566 * @return Returns the image of the icon, or the default application icon 3567 * if it could not be found. 3568 * 3569 * @see #getApplicationIcon(String) 3570 */ 3571 public abstract Drawable getApplicationIcon(ApplicationInfo info); 3572 3573 /** 3574 * Retrieve the icon associated with an application. Given the name of the 3575 * application's package, retrieves the information about it and calls 3576 * getApplicationIcon() to return its icon. If the application cannot be 3577 * found, NameNotFoundException is thrown. 3578 * 3579 * @param packageName Name of the package whose application icon is to be 3580 * retrieved. 3581 * 3582 * @return Returns the image of the icon, or the default application icon 3583 * if it could not be found. Does not return null. 3584 * @throws NameNotFoundException Thrown if the resources for the given 3585 * application could not be loaded. 3586 * 3587 * @see #getApplicationIcon(ApplicationInfo) 3588 */ 3589 public abstract Drawable getApplicationIcon(String packageName) 3590 throws NameNotFoundException; 3591 3592 /** 3593 * Retrieve the banner associated with an application. 3594 * 3595 * @param info Information about application being queried. 3596 * @return Returns the image of the banner or null if the application has no 3597 * banner specified. 3598 * @see #getApplicationBanner(String) 3599 */ 3600 public abstract Drawable getApplicationBanner(ApplicationInfo info); 3601 3602 /** 3603 * Retrieve the banner associated with an application. Given the name of the 3604 * application's package, retrieves the information about it and calls 3605 * getApplicationIcon() to return its banner. If the application cannot be 3606 * found, NameNotFoundException is thrown. 3607 * 3608 * @param packageName Name of the package whose application banner is to be 3609 * retrieved. 3610 * @return Returns the image of the banner or null if the application has no 3611 * banner specified. 3612 * @throws NameNotFoundException Thrown if the resources for the given 3613 * application could not be loaded. 3614 * @see #getApplicationBanner(ApplicationInfo) 3615 */ 3616 public abstract Drawable getApplicationBanner(String packageName) 3617 throws NameNotFoundException; 3618 3619 /** 3620 * Retrieve the logo associated with an activity. Given the full name of an 3621 * activity, retrieves the information about it and calls 3622 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 3623 * logo. If the activity cannot be found, NameNotFoundException is thrown. 3624 * 3625 * @param activityName Name of the activity whose logo is to be retrieved. 3626 * @return Returns the image of the logo or null if the activity has no logo 3627 * specified. 3628 * @throws NameNotFoundException Thrown if the resources for the given 3629 * activity could not be loaded. 3630 * @see #getActivityLogo(Intent) 3631 */ 3632 public abstract Drawable getActivityLogo(ComponentName activityName) 3633 throws NameNotFoundException; 3634 3635 /** 3636 * Retrieve the logo associated with an Intent. If intent.getClassName() is 3637 * set, this simply returns the result of 3638 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 3639 * component and returns the logo associated with the resolved component. 3640 * If intent.getClassName() cannot be found or the Intent cannot be resolved 3641 * to a component, NameNotFoundException is thrown. 3642 * 3643 * @param intent The intent for which you would like to retrieve a logo. 3644 * 3645 * @return Returns the image of the logo, or null if the activity has no 3646 * logo specified. 3647 * 3648 * @throws NameNotFoundException Thrown if the resources for application 3649 * matching the given intent could not be loaded. 3650 * 3651 * @see #getActivityLogo(ComponentName) 3652 */ 3653 public abstract Drawable getActivityLogo(Intent intent) 3654 throws NameNotFoundException; 3655 3656 /** 3657 * Retrieve the logo associated with an application. If it has not specified 3658 * a logo, this method returns null. 3659 * 3660 * @param info Information about application being queried. 3661 * 3662 * @return Returns the image of the logo, or null if no logo is specified 3663 * by the application. 3664 * 3665 * @see #getApplicationLogo(String) 3666 */ 3667 public abstract Drawable getApplicationLogo(ApplicationInfo info); 3668 3669 /** 3670 * Retrieve the logo associated with an application. Given the name of the 3671 * application's package, retrieves the information about it and calls 3672 * getApplicationLogo() to return its logo. If the application cannot be 3673 * found, NameNotFoundException is thrown. 3674 * 3675 * @param packageName Name of the package whose application logo is to be 3676 * retrieved. 3677 * 3678 * @return Returns the image of the logo, or null if no application logo 3679 * has been specified. 3680 * 3681 * @throws NameNotFoundException Thrown if the resources for the given 3682 * application could not be loaded. 3683 * 3684 * @see #getApplicationLogo(ApplicationInfo) 3685 */ 3686 public abstract Drawable getApplicationLogo(String packageName) 3687 throws NameNotFoundException; 3688 3689 /** 3690 * If the target user is a managed profile of the calling user or if the 3691 * target user is the caller and is itself a managed profile, then this 3692 * returns a badged copy of the given icon to be able to distinguish it from 3693 * the original icon. For badging an arbitrary drawable use 3694 * {@link #getUserBadgedDrawableForDensity( 3695 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 3696 * <p> 3697 * If the original drawable is a BitmapDrawable and the backing bitmap is 3698 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 3699 * is performed in place and the original drawable is returned. 3700 * </p> 3701 * 3702 * @param icon The icon to badge. 3703 * @param user The target user. 3704 * @return A drawable that combines the original icon and a badge as 3705 * determined by the system. 3706 */ 3707 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 3708 3709 /** 3710 * If the target user is a managed profile of the calling user or the caller 3711 * is itself a managed profile, then this returns a badged copy of the given 3712 * drawable allowing the user to distinguish it from the original drawable. 3713 * The caller can specify the location in the bounds of the drawable to be 3714 * badged where the badge should be applied as well as the density of the 3715 * badge to be used. 3716 * <p> 3717 * If the original drawable is a BitmapDrawable and the backing bitmap is 3718 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading 3719 * is performed in place and the original drawable is returned. 3720 * </p> 3721 * 3722 * @param drawable The drawable to badge. 3723 * @param user The target user. 3724 * @param badgeLocation Where in the bounds of the badged drawable to place 3725 * the badge. If not provided, the badge is applied on top of the entire 3726 * drawable being badged. 3727 * @param badgeDensity The optional desired density for the badge as per 3728 * {@link android.util.DisplayMetrics#densityDpi}. If not provided, 3729 * the density of the display is used. 3730 * @return A drawable that combines the original drawable and a badge as 3731 * determined by the system. 3732 */ 3733 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 3734 UserHandle user, Rect badgeLocation, int badgeDensity); 3735 3736 /** 3737 * If the target user is a managed profile of the calling user or the caller 3738 * is itself a managed profile, then this returns a drawable to use as a small 3739 * icon to include in a view to distinguish it from the original icon. 3740 * 3741 * @param user The target user. 3742 * @param density The optional desired density for the badge as per 3743 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 3744 * the density of the current display is used. 3745 * @return the drawable or null if no drawable is required. 3746 * @hide 3747 */ 3748 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 3749 3750 /** 3751 * If the target user is a managed profile of the calling user or the caller 3752 * is itself a managed profile, then this returns a copy of the label with 3753 * badging for accessibility services like talkback. E.g. passing in "Email" 3754 * and it might return "Work Email" for Email in the work profile. 3755 * 3756 * @param label The label to change. 3757 * @param user The target user. 3758 * @return A label that combines the original label and a badge as 3759 * determined by the system. 3760 */ 3761 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 3762 3763 /** 3764 * Retrieve text from a package. This is a low-level API used by 3765 * the various package manager info structures (such as 3766 * {@link ComponentInfo} to implement retrieval of their associated 3767 * labels and other text. 3768 * 3769 * @param packageName The name of the package that this text is coming from. 3770 * Cannot be null. 3771 * @param resid The resource identifier of the desired text. Cannot be 0. 3772 * @param appInfo Overall information about <var>packageName</var>. This 3773 * may be null, in which case the application information will be retrieved 3774 * for you if needed; if you already have this information around, it can 3775 * be much more efficient to supply it here. 3776 * 3777 * @return Returns a CharSequence holding the requested text. Returns null 3778 * if the text could not be found for any reason. 3779 */ 3780 public abstract CharSequence getText(String packageName, @StringRes int resid, 3781 ApplicationInfo appInfo); 3782 3783 /** 3784 * Retrieve an XML file from a package. This is a low-level API used to 3785 * retrieve XML meta data. 3786 * 3787 * @param packageName The name of the package that this xml is coming from. 3788 * Cannot be null. 3789 * @param resid The resource identifier of the desired xml. Cannot be 0. 3790 * @param appInfo Overall information about <var>packageName</var>. This 3791 * may be null, in which case the application information will be retrieved 3792 * for you if needed; if you already have this information around, it can 3793 * be much more efficient to supply it here. 3794 * 3795 * @return Returns an XmlPullParser allowing you to parse out the XML 3796 * data. Returns null if the xml resource could not be found for any 3797 * reason. 3798 */ 3799 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 3800 ApplicationInfo appInfo); 3801 3802 /** 3803 * Return the label to use for this application. 3804 * 3805 * @return Returns the label associated with this application, or null if 3806 * it could not be found for any reason. 3807 * @param info The application to get the label of. 3808 */ 3809 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 3810 3811 /** 3812 * Retrieve the resources associated with an activity. Given the full 3813 * name of an activity, retrieves the information about it and calls 3814 * getResources() to return its application's resources. If the activity 3815 * cannot be found, NameNotFoundException is thrown. 3816 * 3817 * @param activityName Name of the activity whose resources are to be 3818 * retrieved. 3819 * 3820 * @return Returns the application's Resources. 3821 * @throws NameNotFoundException Thrown if the resources for the given 3822 * application could not be loaded. 3823 * 3824 * @see #getResourcesForApplication(ApplicationInfo) 3825 */ 3826 public abstract Resources getResourcesForActivity(ComponentName activityName) 3827 throws NameNotFoundException; 3828 3829 /** 3830 * Retrieve the resources for an application. Throws NameNotFoundException 3831 * if the package is no longer installed. 3832 * 3833 * @param app Information about the desired application. 3834 * 3835 * @return Returns the application's Resources. 3836 * @throws NameNotFoundException Thrown if the resources for the given 3837 * application could not be loaded (most likely because it was uninstalled). 3838 */ 3839 public abstract Resources getResourcesForApplication(ApplicationInfo app) 3840 throws NameNotFoundException; 3841 3842 /** 3843 * Retrieve the resources associated with an application. Given the full 3844 * package name of an application, retrieves the information about it and 3845 * calls getResources() to return its application's resources. If the 3846 * appPackageName cannot be found, NameNotFoundException is thrown. 3847 * 3848 * @param appPackageName Package name of the application whose resources 3849 * are to be retrieved. 3850 * 3851 * @return Returns the application's Resources. 3852 * @throws NameNotFoundException Thrown if the resources for the given 3853 * application could not be loaded. 3854 * 3855 * @see #getResourcesForApplication(ApplicationInfo) 3856 */ 3857 public abstract Resources getResourcesForApplication(String appPackageName) 3858 throws NameNotFoundException; 3859 3860 /** @hide */ 3861 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId) 3862 throws NameNotFoundException; 3863 3864 /** 3865 * Retrieve overall information about an application package defined 3866 * in a package archive file 3867 * 3868 * @param archiveFilePath The path to the archive file 3869 * @param flags Additional option flags. Use any combination of 3870 * {@link #GET_ACTIVITIES}, 3871 * {@link #GET_GIDS}, 3872 * {@link #GET_CONFIGURATIONS}, 3873 * {@link #GET_INSTRUMENTATION}, 3874 * {@link #GET_PERMISSIONS}, 3875 * {@link #GET_PROVIDERS}, 3876 * {@link #GET_RECEIVERS}, 3877 * {@link #GET_SERVICES}, 3878 * {@link #GET_SIGNATURES}, to modify the data returned. 3879 * 3880 * @return Returns the information about the package. Returns 3881 * null if the package could not be successfully parsed. 3882 * 3883 * @see #GET_ACTIVITIES 3884 * @see #GET_GIDS 3885 * @see #GET_CONFIGURATIONS 3886 * @see #GET_INSTRUMENTATION 3887 * @see #GET_PERMISSIONS 3888 * @see #GET_PROVIDERS 3889 * @see #GET_RECEIVERS 3890 * @see #GET_SERVICES 3891 * @see #GET_SIGNATURES 3892 * 3893 */ 3894 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) { 3895 final PackageParser parser = new PackageParser(); 3896 final File apkFile = new File(archiveFilePath); 3897 try { 3898 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 3899 if ((flags & GET_SIGNATURES) != 0) { 3900 parser.collectCertificates(pkg, 0); 3901 } 3902 PackageUserState state = new PackageUserState(); 3903 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 3904 } catch (PackageParserException e) { 3905 return null; 3906 } 3907 } 3908 3909 /** 3910 * @hide Install a package. Since this may take a little while, the result 3911 * will be posted back to the given observer. An installation will 3912 * fail if the calling context lacks the 3913 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if 3914 * the package named in the package file's manifest is already 3915 * installed, or if there's no space available on the device. 3916 * @param packageURI The location of the package file to install. This can 3917 * be a 'file:' or a 'content:' URI. 3918 * @param observer An observer callback to get notified when the package 3919 * installation is complete. 3920 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3921 * will be called when that happens. This parameter must not be 3922 * null. 3923 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3924 * {@link #INSTALL_REPLACE_EXISTING}, 3925 * {@link #INSTALL_ALLOW_TEST}. 3926 * @param installerPackageName Optional package name of the application that 3927 * is performing the installation. This identifies which market 3928 * the package came from. 3929 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int, 3930 * String)} instead. This method will continue to be supported 3931 * but the older observer interface will not get additional 3932 * failure details. 3933 */ 3934 // @SystemApi 3935 public abstract void installPackage( 3936 Uri packageURI, IPackageInstallObserver observer, int flags, 3937 String installerPackageName); 3938 3939 /** 3940 * Similar to 3941 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3942 * with an extra verification file provided. 3943 * 3944 * @param packageURI The location of the package file to install. This can 3945 * be a 'file:' or a 'content:' URI. 3946 * @param observer An observer callback to get notified when the package 3947 * installation is complete. 3948 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3949 * will be called when that happens. This parameter must not be 3950 * null. 3951 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3952 * {@link #INSTALL_REPLACE_EXISTING}, 3953 * {@link #INSTALL_ALLOW_TEST}. 3954 * @param installerPackageName Optional package name of the application that 3955 * is performing the installation. This identifies which market 3956 * the package came from. 3957 * @param verificationURI The location of the supplementary verification 3958 * file. This can be a 'file:' or a 'content:' URI. May be 3959 * {@code null}. 3960 * @param encryptionParams if the package to be installed is encrypted, 3961 * these parameters describing the encryption and authentication 3962 * used. May be {@code null}. 3963 * @hide 3964 * @deprecated Use {@link #installPackageWithVerification(Uri, 3965 * PackageInstallObserver, int, String, Uri, 3966 * ContainerEncryptionParams)} instead. This method will 3967 * continue to be supported but the older observer interface 3968 * will not get additional failure details. 3969 */ 3970 // @SystemApi 3971 public abstract void installPackageWithVerification(Uri packageURI, 3972 IPackageInstallObserver observer, int flags, String installerPackageName, 3973 Uri verificationURI, 3974 ContainerEncryptionParams encryptionParams); 3975 3976 /** 3977 * Similar to 3978 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3979 * with an extra verification information provided. 3980 * 3981 * @param packageURI The location of the package file to install. This can 3982 * be a 'file:' or a 'content:' URI. 3983 * @param observer An observer callback to get notified when the package 3984 * installation is complete. 3985 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3986 * will be called when that happens. This parameter must not be 3987 * null. 3988 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3989 * {@link #INSTALL_REPLACE_EXISTING}, 3990 * {@link #INSTALL_ALLOW_TEST}. 3991 * @param installerPackageName Optional package name of the application that 3992 * is performing the installation. This identifies which market 3993 * the package came from. 3994 * @param verificationParams an object that holds signal information to 3995 * assist verification. May be {@code null}. 3996 * @param encryptionParams if the package to be installed is encrypted, 3997 * these parameters describing the encryption and authentication 3998 * used. May be {@code null}. 3999 * @hide 4000 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri, 4001 * PackageInstallObserver, int, String, VerificationParams, 4002 * ContainerEncryptionParams)} instead. This method will 4003 * continue to be supported but the older observer interface 4004 * will not get additional failure details. 4005 */ 4006 @Deprecated 4007 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 4008 IPackageInstallObserver observer, int flags, String installerPackageName, 4009 VerificationParams verificationParams, 4010 ContainerEncryptionParams encryptionParams); 4011 4012 // Package-install variants that take the new, expanded form of observer interface. 4013 // Note that these *also* take the original observer type and will redundantly 4014 // report the same information to that observer if supplied; but it is not required. 4015 4016 /** 4017 * @hide 4018 * 4019 * Install a package. Since this may take a little while, the result will 4020 * be posted back to the given observer. An installation will fail if the calling context 4021 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 4022 * package named in the package file's manifest is already installed, or if there's no space 4023 * available on the device. 4024 * 4025 * @param packageURI The location of the package file to install. This can be a 'file:' or a 4026 * 'content:' URI. 4027 * @param observer An observer callback to get notified when the package installation is 4028 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 4029 * called when that happens. This parameter must not be null. 4030 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 4031 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 4032 * @param installerPackageName Optional package name of the application that is performing the 4033 * installation. This identifies which market the package came from. 4034 */ 4035 public abstract void installPackage( 4036 Uri packageURI, PackageInstallObserver observer, 4037 int flags, String installerPackageName); 4038 4039 4040 /** 4041 * @hide 4042 * Install a package. Since this may take a little while, the result will be 4043 * posted back to the given observer. An installation will fail if the package named 4044 * in the package file's manifest is already installed, or if there's no space 4045 * available on the device. 4046 * @param packageURI The location of the package file to install. This can be a 'file:' or a 4047 * 'content:' URI. 4048 * @param observer An observer callback to get notified when the package installation is 4049 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 4050 * called when that happens. This parameter must not be null. 4051 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 4052 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 4053 * @param installerPackageName Optional package name of the application that is performing the 4054 * installation. This identifies which market the package came from. 4055 * @param userId The user id. 4056 */ 4057 @RequiresPermission(anyOf = { 4058 Manifest.permission.INSTALL_PACKAGES, 4059 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4060 public abstract void installPackageAsUser( 4061 Uri packageURI, PackageInstallObserver observer, int flags, 4062 String installerPackageName, int userId); 4063 4064 /** 4065 * Similar to 4066 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 4067 * with an extra verification file provided. 4068 * 4069 * @param packageURI The location of the package file to install. This can 4070 * be a 'file:' or a 'content:' URI. 4071 * @param observer An observer callback to get notified when the package installation is 4072 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 4073 * called when that happens. This parameter must not be null. 4074 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 4075 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 4076 * @param installerPackageName Optional package name of the application that 4077 * is performing the installation. This identifies which market 4078 * the package came from. 4079 * @param verificationURI The location of the supplementary verification 4080 * file. This can be a 'file:' or a 'content:' URI. May be 4081 * {@code null}. 4082 * @param encryptionParams if the package to be installed is encrypted, 4083 * these parameters describing the encryption and authentication 4084 * used. May be {@code null}. 4085 * @hide 4086 */ 4087 public abstract void installPackageWithVerification(Uri packageURI, 4088 PackageInstallObserver observer, int flags, String installerPackageName, 4089 Uri verificationURI, 4090 ContainerEncryptionParams encryptionParams); 4091 4092 /** 4093 * Similar to 4094 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 4095 * with an extra verification information provided. 4096 * 4097 * @param packageURI The location of the package file to install. This can 4098 * be a 'file:' or a 'content:' URI. 4099 * @param observer An observer callback to get notified when the package installation is 4100 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 4101 * called when that happens. This parameter must not be null. 4102 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 4103 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 4104 * @param installerPackageName Optional package name of the application that 4105 * is performing the installation. This identifies which market 4106 * the package came from. 4107 * @param verificationParams an object that holds signal information to 4108 * assist verification. May be {@code null}. 4109 * @param encryptionParams if the package to be installed is encrypted, 4110 * these parameters describing the encryption and authentication 4111 * used. May be {@code null}. 4112 * 4113 * @hide 4114 */ 4115 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 4116 PackageInstallObserver observer, int flags, String installerPackageName, 4117 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams); 4118 4119 /** 4120 * If there is already an application with the given package name installed 4121 * on the system for other users, also install it for the calling user. 4122 * @hide 4123 */ 4124 // @SystemApi 4125 public abstract int installExistingPackage(String packageName) throws NameNotFoundException; 4126 4127 /** 4128 * If there is already an application with the given package name installed 4129 * on the system for other users, also install it for the specified user. 4130 * @hide 4131 */ 4132 @RequiresPermission(anyOf = { 4133 Manifest.permission.INSTALL_PACKAGES, 4134 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4135 public abstract int installExistingPackageAsUser(String packageName, int userId) 4136 throws NameNotFoundException; 4137 4138 /** 4139 * Allows a package listening to the 4140 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4141 * broadcast} to respond to the package manager. The response must include 4142 * the {@code verificationCode} which is one of 4143 * {@link PackageManager#VERIFICATION_ALLOW} or 4144 * {@link PackageManager#VERIFICATION_REJECT}. 4145 * 4146 * @param id pending package identifier as passed via the 4147 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4148 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 4149 * or {@link PackageManager#VERIFICATION_REJECT}. 4150 * @throws SecurityException if the caller does not have the 4151 * PACKAGE_VERIFICATION_AGENT permission. 4152 */ 4153 public abstract void verifyPendingInstall(int id, int verificationCode); 4154 4155 /** 4156 * Allows a package listening to the 4157 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4158 * broadcast} to extend the default timeout for a response and declare what 4159 * action to perform after the timeout occurs. The response must include 4160 * the {@code verificationCodeAtTimeout} which is one of 4161 * {@link PackageManager#VERIFICATION_ALLOW} or 4162 * {@link PackageManager#VERIFICATION_REJECT}. 4163 * 4164 * This method may only be called once per package id. Additional calls 4165 * will have no effect. 4166 * 4167 * @param id pending package identifier as passed via the 4168 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4169 * @param verificationCodeAtTimeout either 4170 * {@link PackageManager#VERIFICATION_ALLOW} or 4171 * {@link PackageManager#VERIFICATION_REJECT}. If 4172 * {@code verificationCodeAtTimeout} is neither 4173 * {@link PackageManager#VERIFICATION_ALLOW} or 4174 * {@link PackageManager#VERIFICATION_REJECT}, then 4175 * {@code verificationCodeAtTimeout} will default to 4176 * {@link PackageManager#VERIFICATION_REJECT}. 4177 * @param millisecondsToDelay the amount of time requested for the timeout. 4178 * Must be positive and less than 4179 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 4180 * {@code millisecondsToDelay} is out of bounds, 4181 * {@code millisecondsToDelay} will be set to the closest in 4182 * bounds value; namely, 0 or 4183 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 4184 * @throws SecurityException if the caller does not have the 4185 * PACKAGE_VERIFICATION_AGENT permission. 4186 */ 4187 public abstract void extendVerificationTimeout(int id, 4188 int verificationCodeAtTimeout, long millisecondsToDelay); 4189 4190 /** 4191 * Allows a package listening to the 4192 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification 4193 * broadcast} to respond to the package manager. The response must include 4194 * the {@code verificationCode} which is one of 4195 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 4196 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4197 * 4198 * @param verificationId pending package identifier as passed via the 4199 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4200 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 4201 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4202 * @param outFailedDomains a list of failed domains if the verificationCode is 4203 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 4204 * @throws SecurityException if the caller does not have the 4205 * INTENT_FILTER_VERIFICATION_AGENT permission. 4206 * 4207 * @hide 4208 */ 4209 @SystemApi 4210 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 4211 List<String> outFailedDomains); 4212 4213 /** 4214 * Get the status of a Domain Verification Result for an IntentFilter. This is 4215 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4216 * {@link android.content.IntentFilter#getAutoVerify()} 4217 * 4218 * This is used by the ResolverActivity to change the status depending on what the User select 4219 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4220 * for a domain. 4221 * 4222 * @param packageName The package name of the Activity associated with the IntentFilter. 4223 * @param userId The user id. 4224 * 4225 * @return The status to set to. This can be 4226 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4227 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4228 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 4229 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 4230 * 4231 * @hide 4232 */ 4233 public abstract int getIntentVerificationStatus(String packageName, int userId); 4234 4235 /** 4236 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 4237 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4238 * {@link android.content.IntentFilter#getAutoVerify()} 4239 * 4240 * This is used by the ResolverActivity to change the status depending on what the User select 4241 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4242 * for a domain. 4243 * 4244 * @param packageName The package name of the Activity associated with the IntentFilter. 4245 * @param status The status to set to. This can be 4246 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4247 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4248 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 4249 * @param userId The user id. 4250 * 4251 * @return true if the status has been set. False otherwise. 4252 * 4253 * @hide 4254 */ 4255 public abstract boolean updateIntentVerificationStatus(String packageName, int status, 4256 int userId); 4257 4258 /** 4259 * Get the list of IntentFilterVerificationInfo for a specific package and User. 4260 * 4261 * @param packageName the package name. When this parameter is set to a non null value, 4262 * the results will be filtered by the package name provided. 4263 * Otherwise, there will be no filtering and it will return a list 4264 * corresponding for all packages 4265 * 4266 * @return a list of IntentFilterVerificationInfo for a specific package. 4267 * 4268 * @hide 4269 */ 4270 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 4271 String packageName); 4272 4273 /** 4274 * Get the list of IntentFilter for a specific package. 4275 * 4276 * @param packageName the package name. This parameter is set to a non null value, 4277 * the list will contain all the IntentFilter for that package. 4278 * Otherwise, the list will be empty. 4279 * 4280 * @return a list of IntentFilter for a specific package. 4281 * 4282 * @hide 4283 */ 4284 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 4285 4286 /** 4287 * Get the default Browser package name for a specific user. 4288 * 4289 * @param userId The user id. 4290 * 4291 * @return the package name of the default Browser for the specified user. If the user id passed 4292 * is -1 (all users) it will return a null value. 4293 * 4294 * @hide 4295 */ 4296 public abstract String getDefaultBrowserPackageName(int userId); 4297 4298 /** 4299 * Set the default Browser package name for a specific user. 4300 * 4301 * @param packageName The package name of the default Browser. 4302 * @param userId The user id. 4303 * 4304 * @return true if the default Browser for the specified user has been set, 4305 * otherwise return false. If the user id passed is -1 (all users) this call will not 4306 * do anything and just return false. 4307 * 4308 * @hide 4309 */ 4310 public abstract boolean setDefaultBrowserPackageName(String packageName, int userId); 4311 4312 /** 4313 * Change the installer associated with a given package. There are limitations 4314 * on how the installer package can be changed; in particular: 4315 * <ul> 4316 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 4317 * is not signed with the same certificate as the calling application. 4318 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 4319 * has an installer package, and that installer package is not signed with 4320 * the same certificate as the calling application. 4321 * </ul> 4322 * 4323 * @param targetPackage The installed package whose installer will be changed. 4324 * @param installerPackageName The package name of the new installer. May be 4325 * null to clear the association. 4326 */ 4327 public abstract void setInstallerPackageName(String targetPackage, 4328 String installerPackageName); 4329 4330 /** 4331 * Attempts to delete a package. Since this may take a little while, the result will 4332 * be posted back to the given observer. A deletion will fail if the calling context 4333 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 4334 * named package cannot be found, or if the named package is a "system package". 4335 * (TODO: include pointer to documentation on "system packages") 4336 * 4337 * @param packageName The name of the package to delete 4338 * @param observer An observer callback to get notified when the package deletion is 4339 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 4340 * called when that happens. observer may be null to indicate that no callback is desired. 4341 * @param flags Possible values: {@link #DELETE_KEEP_DATA}, 4342 * {@link #DELETE_ALL_USERS}. 4343 * 4344 * @hide 4345 */ 4346 // @SystemApi 4347 public abstract void deletePackage( 4348 String packageName, IPackageDeleteObserver observer, int flags); 4349 4350 /** 4351 * Attempts to delete a package. Since this may take a little while, the result will 4352 * be posted back to the given observer. A deletion will fail if the named package cannot be 4353 * found, or if the named package is a "system package". 4354 * (TODO: include pointer to documentation on "system packages") 4355 * 4356 * @param packageName The name of the package to delete 4357 * @param observer An observer callback to get notified when the package deletion is 4358 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 4359 * called when that happens. observer may be null to indicate that no callback is desired. 4360 * @param flags Possible values: {@link #DELETE_KEEP_DATA}, {@link #DELETE_ALL_USERS}. 4361 * @param userId The user Id 4362 * 4363 * @hide 4364 */ 4365 @RequiresPermission(anyOf = { 4366 Manifest.permission.DELETE_PACKAGES, 4367 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4368 public abstract void deletePackageAsUser( 4369 String packageName, IPackageDeleteObserver observer, int flags, int userId); 4370 4371 /** 4372 * Retrieve the package name of the application that installed a package. This identifies 4373 * which market the package came from. 4374 * 4375 * @param packageName The name of the package to query 4376 */ 4377 public abstract String getInstallerPackageName(String packageName); 4378 4379 /** 4380 * Attempts to clear the user data directory of an application. 4381 * Since this may take a little while, the result will 4382 * be posted back to the given observer. A deletion will fail if the 4383 * named package cannot be found, or if the named package is a "system package". 4384 * 4385 * @param packageName The name of the package 4386 * @param observer An observer callback to get notified when the operation is finished 4387 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 4388 * will be called when that happens. observer may be null to indicate that 4389 * no callback is desired. 4390 * 4391 * @hide 4392 */ 4393 public abstract void clearApplicationUserData(String packageName, 4394 IPackageDataObserver observer); 4395 /** 4396 * Attempts to delete the cache files associated with an application. 4397 * Since this may take a little while, the result will 4398 * be posted back to the given observer. A deletion will fail if the calling context 4399 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 4400 * named package cannot be found, or if the named package is a "system package". 4401 * 4402 * @param packageName The name of the package to delete 4403 * @param observer An observer callback to get notified when the cache file deletion 4404 * is complete. 4405 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 4406 * will be called when that happens. observer may be null to indicate that 4407 * no callback is desired. 4408 * 4409 * @hide 4410 */ 4411 public abstract void deleteApplicationCacheFiles(String packageName, 4412 IPackageDataObserver observer); 4413 4414 /** 4415 * Free storage by deleting LRU sorted list of cache files across 4416 * all applications. If the currently available free storage 4417 * on the device is greater than or equal to the requested 4418 * free storage, no cache files are cleared. If the currently 4419 * available storage on the device is less than the requested 4420 * free storage, some or all of the cache files across 4421 * all applications are deleted (based on last accessed time) 4422 * to increase the free storage space on the device to 4423 * the requested value. There is no guarantee that clearing all 4424 * the cache files from all applications will clear up 4425 * enough storage to achieve the desired value. 4426 * @param freeStorageSize The number of bytes of storage to be 4427 * freed by the system. Say if freeStorageSize is XX, 4428 * and the current free storage is YY, 4429 * if XX is less than YY, just return. if not free XX-YY number 4430 * of bytes if possible. 4431 * @param observer call back used to notify when 4432 * the operation is completed 4433 * 4434 * @hide 4435 */ 4436 // @SystemApi 4437 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 4438 freeStorageAndNotify(null, freeStorageSize, observer); 4439 } 4440 4441 /** {@hide} */ 4442 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 4443 IPackageDataObserver observer); 4444 4445 /** 4446 * Free storage by deleting LRU sorted list of cache files across 4447 * all applications. If the currently available free storage 4448 * on the device is greater than or equal to the requested 4449 * free storage, no cache files are cleared. If the currently 4450 * available storage on the device is less than the requested 4451 * free storage, some or all of the cache files across 4452 * all applications are deleted (based on last accessed time) 4453 * to increase the free storage space on the device to 4454 * the requested value. There is no guarantee that clearing all 4455 * the cache files from all applications will clear up 4456 * enough storage to achieve the desired value. 4457 * @param freeStorageSize The number of bytes of storage to be 4458 * freed by the system. Say if freeStorageSize is XX, 4459 * and the current free storage is YY, 4460 * if XX is less than YY, just return. if not free XX-YY number 4461 * of bytes if possible. 4462 * @param pi IntentSender call back used to 4463 * notify when the operation is completed.May be null 4464 * to indicate that no call back is desired. 4465 * 4466 * @hide 4467 */ 4468 public void freeStorage(long freeStorageSize, IntentSender pi) { 4469 freeStorage(null, freeStorageSize, pi); 4470 } 4471 4472 /** {@hide} */ 4473 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 4474 4475 /** 4476 * Retrieve the size information for a package. 4477 * Since this may take a little while, the result will 4478 * be posted back to the given observer. The calling context 4479 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 4480 * 4481 * @param packageName The name of the package whose size information is to be retrieved 4482 * @param userHandle The user whose size information should be retrieved. 4483 * @param observer An observer callback to get notified when the operation 4484 * is complete. 4485 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 4486 * The observer's callback is invoked with a PackageStats object(containing the 4487 * code, data and cache sizes of the package) and a boolean value representing 4488 * the status of the operation. observer may be null to indicate that 4489 * no callback is desired. 4490 * 4491 * @hide 4492 */ 4493 public abstract void getPackageSizeInfo(String packageName, int userHandle, 4494 IPackageStatsObserver observer); 4495 4496 /** 4497 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but 4498 * returns the size for the calling user. 4499 * 4500 * @hide 4501 */ 4502 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 4503 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer); 4504 } 4505 4506 /** 4507 * @deprecated This function no longer does anything; it was an old 4508 * approach to managing preferred activities, which has been superseded 4509 * by (and conflicts with) the modern activity-based preferences. 4510 */ 4511 @Deprecated 4512 public abstract void addPackageToPreferred(String packageName); 4513 4514 /** 4515 * @deprecated This function no longer does anything; it was an old 4516 * approach to managing preferred activities, which has been superseded 4517 * by (and conflicts with) the modern activity-based preferences. 4518 */ 4519 @Deprecated 4520 public abstract void removePackageFromPreferred(String packageName); 4521 4522 /** 4523 * Retrieve the list of all currently configured preferred packages. The 4524 * first package on the list is the most preferred, the last is the 4525 * least preferred. 4526 * 4527 * @param flags Additional option flags. Use any combination of 4528 * {@link #GET_ACTIVITIES}, 4529 * {@link #GET_GIDS}, 4530 * {@link #GET_CONFIGURATIONS}, 4531 * {@link #GET_INSTRUMENTATION}, 4532 * {@link #GET_PERMISSIONS}, 4533 * {@link #GET_PROVIDERS}, 4534 * {@link #GET_RECEIVERS}, 4535 * {@link #GET_SERVICES}, 4536 * {@link #GET_SIGNATURES}, to modify the data returned. 4537 * 4538 * @return Returns a list of PackageInfo objects describing each 4539 * preferred application, in order of preference. 4540 * 4541 * @see #GET_ACTIVITIES 4542 * @see #GET_GIDS 4543 * @see #GET_CONFIGURATIONS 4544 * @see #GET_INSTRUMENTATION 4545 * @see #GET_PERMISSIONS 4546 * @see #GET_PROVIDERS 4547 * @see #GET_RECEIVERS 4548 * @see #GET_SERVICES 4549 * @see #GET_SIGNATURES 4550 */ 4551 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 4552 4553 /** 4554 * @deprecated This is a protected API that should not have been available 4555 * to third party applications. It is the platform's responsibility for 4556 * assigning preferred activities and this cannot be directly modified. 4557 * 4558 * Add a new preferred activity mapping to the system. This will be used 4559 * to automatically select the given activity component when 4560 * {@link Context#startActivity(Intent) Context.startActivity()} finds 4561 * multiple matching activities and also matches the given filter. 4562 * 4563 * @param filter The set of intents under which this activity will be 4564 * made preferred. 4565 * @param match The IntentFilter match category that this preference 4566 * applies to. 4567 * @param set The set of activities that the user was picking from when 4568 * this preference was made. 4569 * @param activity The component name of the activity that is to be 4570 * preferred. 4571 */ 4572 @Deprecated 4573 public abstract void addPreferredActivity(IntentFilter filter, int match, 4574 ComponentName[] set, ComponentName activity); 4575 4576 /** 4577 * Same as {@link #addPreferredActivity(IntentFilter, int, 4578 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 4579 to. 4580 * @hide 4581 */ 4582 public void addPreferredActivity(IntentFilter filter, int match, 4583 ComponentName[] set, ComponentName activity, int userId) { 4584 throw new RuntimeException("Not implemented. Must override in a subclass."); 4585 } 4586 4587 /** 4588 * @deprecated This is a protected API that should not have been available 4589 * to third party applications. It is the platform's responsibility for 4590 * assigning preferred activities and this cannot be directly modified. 4591 * 4592 * Replaces an existing preferred activity mapping to the system, and if that were not present 4593 * adds a new preferred activity. This will be used 4594 * to automatically select the given activity component when 4595 * {@link Context#startActivity(Intent) Context.startActivity()} finds 4596 * multiple matching activities and also matches the given filter. 4597 * 4598 * @param filter The set of intents under which this activity will be 4599 * made preferred. 4600 * @param match The IntentFilter match category that this preference 4601 * applies to. 4602 * @param set The set of activities that the user was picking from when 4603 * this preference was made. 4604 * @param activity The component name of the activity that is to be 4605 * preferred. 4606 * @hide 4607 */ 4608 @Deprecated 4609 public abstract void replacePreferredActivity(IntentFilter filter, int match, 4610 ComponentName[] set, ComponentName activity); 4611 4612 /** 4613 * @hide 4614 */ 4615 @Deprecated 4616 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 4617 ComponentName[] set, ComponentName activity, int userId) { 4618 throw new RuntimeException("Not implemented. Must override in a subclass."); 4619 } 4620 4621 /** 4622 * Remove all preferred activity mappings, previously added with 4623 * {@link #addPreferredActivity}, from the 4624 * system whose activities are implemented in the given package name. 4625 * An application can only clear its own package(s). 4626 * 4627 * @param packageName The name of the package whose preferred activity 4628 * mappings are to be removed. 4629 */ 4630 public abstract void clearPackagePreferredActivities(String packageName); 4631 4632 /** 4633 * Retrieve all preferred activities, previously added with 4634 * {@link #addPreferredActivity}, that are 4635 * currently registered with the system. 4636 * 4637 * @param outFilters A required list in which to place the filters of all of the 4638 * preferred activities. 4639 * @param outActivities A required list in which to place the component names of 4640 * all of the preferred activities. 4641 * @param packageName An optional package in which you would like to limit 4642 * the list. If null, all activities will be returned; if non-null, only 4643 * those activities in the given package are returned. 4644 * 4645 * @return Returns the total number of registered preferred activities 4646 * (the number of distinct IntentFilter records, not the number of unique 4647 * activity components) that were found. 4648 */ 4649 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 4650 @NonNull List<ComponentName> outActivities, String packageName); 4651 4652 /** 4653 * Ask for the set of available 'home' activities and the current explicit 4654 * default, if any. 4655 * @hide 4656 */ 4657 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 4658 4659 /** 4660 * Set the enabled setting for a package component (activity, receiver, service, provider). 4661 * This setting will override any enabled state which may have been set by the component in its 4662 * manifest. 4663 * 4664 * @param componentName The component to enable 4665 * @param newState The new enabled state for the component. The legal values for this state 4666 * are: 4667 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4668 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 4669 * and 4670 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 4671 * The last one removes the setting, thereby restoring the component's state to 4672 * whatever was set in it's manifest (or enabled, by default). 4673 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 4674 */ 4675 public abstract void setComponentEnabledSetting(ComponentName componentName, 4676 int newState, int flags); 4677 4678 4679 /** 4680 * Return the enabled setting for a package component (activity, 4681 * receiver, service, provider). This returns the last value set by 4682 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 4683 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 4684 * the value originally specified in the manifest has not been modified. 4685 * 4686 * @param componentName The component to retrieve. 4687 * @return Returns the current enabled state for the component. May 4688 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4689 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 4690 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 4691 * component's enabled state is based on the original information in 4692 * the manifest as found in {@link ComponentInfo}. 4693 */ 4694 public abstract int getComponentEnabledSetting(ComponentName componentName); 4695 4696 /** 4697 * Set the enabled setting for an application 4698 * This setting will override any enabled state which may have been set by the application in 4699 * its manifest. It also overrides the enabled state set in the manifest for any of the 4700 * application's components. It does not override any enabled state set by 4701 * {@link #setComponentEnabledSetting} for any of the application's components. 4702 * 4703 * @param packageName The package name of the application to enable 4704 * @param newState The new enabled state for the component. The legal values for this state 4705 * are: 4706 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4707 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 4708 * and 4709 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 4710 * The last one removes the setting, thereby restoring the applications's state to 4711 * whatever was set in its manifest (or enabled, by default). 4712 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 4713 */ 4714 public abstract void setApplicationEnabledSetting(String packageName, 4715 int newState, int flags); 4716 4717 /** 4718 * Return the enabled setting for an application. This returns 4719 * the last value set by 4720 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 4721 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 4722 * the value originally specified in the manifest has not been modified. 4723 * 4724 * @param packageName The package name of the application to retrieve. 4725 * @return Returns the current enabled state for the application. May 4726 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4727 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 4728 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 4729 * application's enabled state is based on the original information in 4730 * the manifest as found in {@link ComponentInfo}. 4731 * @throws IllegalArgumentException if the named package does not exist. 4732 */ 4733 public abstract int getApplicationEnabledSetting(String packageName); 4734 4735 /** 4736 * Puts the package in a hidden state, which is almost like an uninstalled state, 4737 * making the package unavailable, but it doesn't remove the data or the actual 4738 * package file. Application can be unhidden by either resetting the hidden state 4739 * or by installing it, such as with {@link #installExistingPackage(String)} 4740 * @hide 4741 */ 4742 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 4743 UserHandle userHandle); 4744 4745 /** 4746 * Returns the hidden state of a package. 4747 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 4748 * @hide 4749 */ 4750 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 4751 UserHandle userHandle); 4752 4753 /** 4754 * Return whether the device has been booted into safe mode. 4755 */ 4756 public abstract boolean isSafeMode(); 4757 4758 /** 4759 * Adds a listener for permission changes for installed packages. 4760 * 4761 * @param listener The listener to add. 4762 * 4763 * @hide 4764 */ 4765 @SystemApi 4766 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 4767 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 4768 4769 /** 4770 * Remvoes a listener for permission changes for installed packages. 4771 * 4772 * @param listener The listener to remove. 4773 * 4774 * @hide 4775 */ 4776 @SystemApi 4777 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 4778 4779 /** 4780 * Return the {@link KeySet} associated with the String alias for this 4781 * application. 4782 * 4783 * @param alias The alias for a given {@link KeySet} as defined in the 4784 * application's AndroidManifest.xml. 4785 * @hide 4786 */ 4787 public abstract KeySet getKeySetByAlias(String packageName, String alias); 4788 4789 /** Return the signing {@link KeySet} for this application. 4790 * @hide 4791 */ 4792 public abstract KeySet getSigningKeySet(String packageName); 4793 4794 /** 4795 * Return whether the package denoted by packageName has been signed by all 4796 * of the keys specified by the {@link KeySet} ks. This will return true if 4797 * the package has been signed by additional keys (a superset) as well. 4798 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 4799 * @hide 4800 */ 4801 public abstract boolean isSignedBy(String packageName, KeySet ks); 4802 4803 /** 4804 * Return whether the package denoted by packageName has been signed by all 4805 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 4806 * {@link #isSignedBy(String packageName, KeySet ks)}. 4807 * @hide 4808 */ 4809 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 4810 4811 /** 4812 * Attempts to move package resources from internal to external media or vice versa. 4813 * Since this may take a little while, the result will 4814 * be posted back to the given observer. This call may fail if the calling context 4815 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 4816 * named package cannot be found, or if the named package is a "system package". 4817 * 4818 * @param packageName The name of the package to delete 4819 * @param observer An observer callback to get notified when the package move is 4820 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 4821 * called when that happens. observer may be null to indicate that no callback is desired. 4822 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 4823 * {@link #MOVE_EXTERNAL_MEDIA} 4824 * 4825 * @hide 4826 */ 4827 @Deprecated 4828 public void movePackage(String packageName, IPackageMoveObserver observer, int flags) { 4829 throw new UnsupportedOperationException(); 4830 } 4831 4832 /** 4833 * Puts the package in a suspended state, making the package un-runnable, 4834 * but it doesn't remove the data or the actual package file. The application notifications 4835 * will be hidden and also the application will not show up in recents. 4836 * 4837 * @param packageName The name of the package to set the suspended status. 4838 * @param suspended If set to {@code true} than the package will be suspended, if set to 4839 * {@code false} the package will be unsuspended. 4840 * @param userId The user id. 4841 * 4842 * @hide 4843 */ 4844 public abstract boolean setPackageSuspendedAsUser( 4845 String packageName, boolean suspended, int userId); 4846 4847 /** {@hide} */ 4848 public static boolean isMoveStatusFinished(int status) { 4849 return (status < 0 || status > 100); 4850 } 4851 4852 /** {@hide} */ 4853 public static abstract class MoveCallback { 4854 public void onCreated(int moveId, Bundle extras) {} 4855 public abstract void onStatusChanged(int moveId, int status, long estMillis); 4856 } 4857 4858 /** {@hide} */ 4859 public abstract int getMoveStatus(int moveId); 4860 4861 /** {@hide} */ 4862 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 4863 /** {@hide} */ 4864 public abstract void unregisterMoveCallback(MoveCallback callback); 4865 4866 /** {@hide} */ 4867 public abstract int movePackage(String packageName, VolumeInfo vol); 4868 /** {@hide} */ 4869 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 4870 /** {@hide} */ 4871 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 4872 4873 /** {@hide} */ 4874 public abstract int movePrimaryStorage(VolumeInfo vol); 4875 /** {@hide} */ 4876 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 4877 /** {@hide} */ 4878 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 4879 4880 /** 4881 * Returns the device identity that verifiers can use to associate their scheme to a particular 4882 * device. This should not be used by anything other than a package verifier. 4883 * 4884 * @return identity that uniquely identifies current device 4885 * @hide 4886 */ 4887 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 4888 4889 /** 4890 * Returns true if the device is upgrading, such as first boot after OTA. 4891 * 4892 * @hide 4893 */ 4894 public abstract boolean isUpgrade(); 4895 4896 /** 4897 * Return interface that offers the ability to install, upgrade, and remove 4898 * applications on the device. 4899 */ 4900 public abstract @NonNull PackageInstaller getPackageInstaller(); 4901 4902 /** 4903 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the 4904 * user with id sourceUserId can also be be resolved by activities in the user with id 4905 * targetUserId if they match the specified intent filter. 4906 * @param filter The {@link IntentFilter} the intent has to match 4907 * @param sourceUserId The source user id. 4908 * @param targetUserId The target user id. 4909 * @param flags The possible values are {@link SKIP_CURRENT_PROFILE} and 4910 * {@link ONLY_IF_NO_MATCH_FOUND}. 4911 * @hide 4912 */ 4913 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 4914 int targetUserId, int flags); 4915 4916 /** 4917 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their 4918 * source, and have been set by the app calling this method. 4919 * @param sourceUserId The source user id. 4920 * @hide 4921 */ 4922 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 4923 4924 /** 4925 * @hide 4926 */ 4927 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 4928 4929 /** 4930 * @hide 4931 */ 4932 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 4933 4934 /** {@hide} */ 4935 public abstract boolean isPackageAvailable(String packageName); 4936 4937 /** {@hide} */ 4938 public static String installStatusToString(int status, String msg) { 4939 final String str = installStatusToString(status); 4940 if (msg != null) { 4941 return str + ": " + msg; 4942 } else { 4943 return str; 4944 } 4945 } 4946 4947 /** {@hide} */ 4948 public static String installStatusToString(int status) { 4949 switch (status) { 4950 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 4951 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 4952 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 4953 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 4954 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 4955 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 4956 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 4957 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 4958 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 4959 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 4960 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 4961 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 4962 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 4963 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 4964 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 4965 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 4966 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 4967 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 4968 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 4969 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 4970 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 4971 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 4972 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 4973 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 4974 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 4975 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 4976 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 4977 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 4978 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 4979 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 4980 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 4981 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 4982 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 4983 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 4984 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 4985 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 4986 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 4987 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 4988 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 4989 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 4990 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 4991 default: return Integer.toString(status); 4992 } 4993 } 4994 4995 /** {@hide} */ 4996 public static int installStatusToPublicStatus(int status) { 4997 switch (status) { 4998 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 4999 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5000 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5001 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 5002 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5003 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5004 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5005 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5006 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5007 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5008 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5009 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 5010 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5011 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5012 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5013 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 5014 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5015 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5016 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 5017 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 5018 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5019 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 5020 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 5021 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5022 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5023 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5024 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5025 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5026 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 5027 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 5028 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5029 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5030 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 5031 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 5032 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 5033 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 5034 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 5035 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5036 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5037 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5038 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5039 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5040 default: return PackageInstaller.STATUS_FAILURE; 5041 } 5042 } 5043 5044 /** {@hide} */ 5045 public static String deleteStatusToString(int status, String msg) { 5046 final String str = deleteStatusToString(status); 5047 if (msg != null) { 5048 return str + ": " + msg; 5049 } else { 5050 return str; 5051 } 5052 } 5053 5054 /** {@hide} */ 5055 public static String deleteStatusToString(int status) { 5056 switch (status) { 5057 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 5058 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 5059 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 5060 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 5061 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 5062 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 5063 default: return Integer.toString(status); 5064 } 5065 } 5066 5067 /** {@hide} */ 5068 public static int deleteStatusToPublicStatus(int status) { 5069 switch (status) { 5070 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5071 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5072 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5073 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5074 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5075 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5076 default: return PackageInstaller.STATUS_FAILURE; 5077 } 5078 } 5079 5080 /** {@hide} */ 5081 public static String permissionFlagToString(int flag) { 5082 switch (flag) { 5083 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 5084 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 5085 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 5086 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 5087 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 5088 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 5089 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 5090 default: return Integer.toString(flag); 5091 } 5092 } 5093 5094 /** {@hide} */ 5095 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 5096 private final IPackageInstallObserver mLegacy; 5097 5098 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 5099 mLegacy = legacy; 5100 } 5101 5102 @Override 5103 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 5104 Bundle extras) { 5105 if (mLegacy == null) return; 5106 try { 5107 mLegacy.packageInstalled(basePackageName, returnCode); 5108 } catch (RemoteException ignored) { 5109 } 5110 } 5111 } 5112 5113 /** {@hide} */ 5114 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 5115 private final IPackageDeleteObserver mLegacy; 5116 5117 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 5118 mLegacy = legacy; 5119 } 5120 5121 @Override 5122 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 5123 if (mLegacy == null) return; 5124 try { 5125 mLegacy.packageDeleted(basePackageName, returnCode); 5126 } catch (RemoteException ignored) { 5127 } 5128 } 5129 } 5130} 5131