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