PackageManager.java revision f77a34fa17d64fad80f423aa8a86e781a7441b9e
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}: If this feature is supported, the Vulkan native API will enumerate 1577 * at least one {@code VkPhysicalDevice}, and the feature version will indicate what 1578 * level of optional hardware features limits it supports. 1579 * <p> 1580 * Level 0 includes the base Vulkan requirements as well as: 1581 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul> 1582 * <p> 1583 * Level 1 additionally includes: 1584 * <ul> 1585 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li> 1586 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li> 1587 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li> 1588 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li> 1589 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li> 1590 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li> 1591 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li> 1592 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li> 1593 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li> 1594 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li> 1595 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li> 1596 * </ul> 1597 */ 1598 @SdkConstant(SdkConstantType.FEATURE) 1599 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level"; 1600 1601 /** 1602 * Feature for {@link #getSystemAvailableFeatures} and 1603 * {@link #hasSystemFeature}: The version of this feature indicates the highest 1604 * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support 1605 * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version 1606 * uses the same encoding as Vulkan version numbers: 1607 * <ul> 1608 * <li>Major version number in bits 31-22</li> 1609 * <li>Minor version number in bits 21-12</li> 1610 * <li>Patch version number in bits 11-0</li> 1611 * </ul> 1612 */ 1613 @SdkConstant(SdkConstantType.FEATURE) 1614 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version"; 1615 1616 /** 1617 * Feature for {@link #getSystemAvailableFeatures} and 1618 * {@link #hasSystemFeature}: The device includes an accelerometer. 1619 */ 1620 @SdkConstant(SdkConstantType.FEATURE) 1621 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1622 1623 /** 1624 * Feature for {@link #getSystemAvailableFeatures} and 1625 * {@link #hasSystemFeature}: The device includes a barometer (air 1626 * pressure sensor.) 1627 */ 1628 @SdkConstant(SdkConstantType.FEATURE) 1629 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1630 1631 /** 1632 * Feature for {@link #getSystemAvailableFeatures} and 1633 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1634 */ 1635 @SdkConstant(SdkConstantType.FEATURE) 1636 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1637 1638 /** 1639 * Feature for {@link #getSystemAvailableFeatures} and 1640 * {@link #hasSystemFeature}: The device includes a gyroscope. 1641 */ 1642 @SdkConstant(SdkConstantType.FEATURE) 1643 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 1644 1645 /** 1646 * Feature for {@link #getSystemAvailableFeatures} and 1647 * {@link #hasSystemFeature}: The device includes a light sensor. 1648 */ 1649 @SdkConstant(SdkConstantType.FEATURE) 1650 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 1651 1652 /** 1653 * Feature for {@link #getSystemAvailableFeatures} and 1654 * {@link #hasSystemFeature}: The device includes a proximity sensor. 1655 */ 1656 @SdkConstant(SdkConstantType.FEATURE) 1657 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 1658 1659 /** 1660 * Feature for {@link #getSystemAvailableFeatures} and 1661 * {@link #hasSystemFeature}: The device includes a hardware step counter. 1662 */ 1663 @SdkConstant(SdkConstantType.FEATURE) 1664 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 1665 1666 /** 1667 * Feature for {@link #getSystemAvailableFeatures} and 1668 * {@link #hasSystemFeature}: The device includes a hardware step detector. 1669 */ 1670 @SdkConstant(SdkConstantType.FEATURE) 1671 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 1672 1673 /** 1674 * Feature for {@link #getSystemAvailableFeatures} and 1675 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 1676 */ 1677 @SdkConstant(SdkConstantType.FEATURE) 1678 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 1679 1680 /** 1681 * Feature for {@link #getSystemAvailableFeatures} and 1682 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram. 1683 */ 1684 @SdkConstant(SdkConstantType.FEATURE) 1685 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 1686 "android.hardware.sensor.heartrate.ecg"; 1687 1688 /** 1689 * Feature for {@link #getSystemAvailableFeatures} and 1690 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 1691 */ 1692 @SdkConstant(SdkConstantType.FEATURE) 1693 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 1694 "android.hardware.sensor.relative_humidity"; 1695 1696 /** 1697 * Feature for {@link #getSystemAvailableFeatures} and 1698 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 1699 */ 1700 @SdkConstant(SdkConstantType.FEATURE) 1701 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 1702 "android.hardware.sensor.ambient_temperature"; 1703 1704 /** 1705 * Feature for {@link #getSystemAvailableFeatures} and 1706 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 1707 * capabilities. 1708 */ 1709 @SdkConstant(SdkConstantType.FEATURE) 1710 public static final String FEATURE_HIFI_SENSORS = 1711 "android.hardware.sensor.hifi_sensors"; 1712 1713 /** 1714 * Feature for {@link #getSystemAvailableFeatures} and 1715 * {@link #hasSystemFeature}: The device has a telephony radio with data 1716 * communication support. 1717 */ 1718 @SdkConstant(SdkConstantType.FEATURE) 1719 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 1720 1721 /** 1722 * Feature for {@link #getSystemAvailableFeatures} and 1723 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 1724 */ 1725 @SdkConstant(SdkConstantType.FEATURE) 1726 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 1727 1728 /** 1729 * Feature for {@link #getSystemAvailableFeatures} and 1730 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 1731 */ 1732 @SdkConstant(SdkConstantType.FEATURE) 1733 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 1734 1735 /** 1736 * Feature for {@link #getSystemAvailableFeatures} and 1737 * {@link #hasSystemFeature}: The device supports connecting to USB devices 1738 * as the USB host. 1739 */ 1740 @SdkConstant(SdkConstantType.FEATURE) 1741 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 1742 1743 /** 1744 * Feature for {@link #getSystemAvailableFeatures} and 1745 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 1746 */ 1747 @SdkConstant(SdkConstantType.FEATURE) 1748 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 1749 1750 /** 1751 * Feature for {@link #getSystemAvailableFeatures} and 1752 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 1753 */ 1754 @SdkConstant(SdkConstantType.FEATURE) 1755 public static final String FEATURE_SIP = "android.software.sip"; 1756 1757 /** 1758 * Feature for {@link #getSystemAvailableFeatures} and 1759 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 1760 */ 1761 @SdkConstant(SdkConstantType.FEATURE) 1762 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 1763 1764 /** 1765 * Feature for {@link #getSystemAvailableFeatures} and 1766 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 1767 */ 1768 @SdkConstant(SdkConstantType.FEATURE) 1769 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 1770 1771 /** 1772 * Feature for {@link #getSystemAvailableFeatures} and 1773 * {@link #hasSystemFeature}: The device's display has a touch screen. 1774 */ 1775 @SdkConstant(SdkConstantType.FEATURE) 1776 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 1777 1778 /** 1779 * Feature for {@link #getSystemAvailableFeatures} and 1780 * {@link #hasSystemFeature}: The device's touch screen supports 1781 * multitouch sufficient for basic two-finger gesture detection. 1782 */ 1783 @SdkConstant(SdkConstantType.FEATURE) 1784 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 1785 1786 /** 1787 * Feature for {@link #getSystemAvailableFeatures} and 1788 * {@link #hasSystemFeature}: The device's touch screen is capable of 1789 * tracking two or more fingers fully independently. 1790 */ 1791 @SdkConstant(SdkConstantType.FEATURE) 1792 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1793 1794 /** 1795 * Feature for {@link #getSystemAvailableFeatures} and 1796 * {@link #hasSystemFeature}: The device's touch screen is capable of 1797 * tracking a full hand of fingers fully independently -- that is, 5 or 1798 * more simultaneous independent pointers. 1799 */ 1800 @SdkConstant(SdkConstantType.FEATURE) 1801 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1802 1803 /** 1804 * Feature for {@link #getSystemAvailableFeatures} and 1805 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1806 * does support touch emulation for basic events. For instance, the 1807 * device might use a mouse or remote control to drive a cursor, and 1808 * emulate basic touch pointer events like down, up, drag, etc. All 1809 * devices that support android.hardware.touchscreen or a sub-feature are 1810 * presumed to also support faketouch. 1811 */ 1812 @SdkConstant(SdkConstantType.FEATURE) 1813 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1814 1815 /** 1816 * Feature for {@link #getSystemAvailableFeatures} and 1817 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1818 * does support touch emulation for basic events that supports distinct 1819 * tracking of two or more fingers. This is an extension of 1820 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1821 * that unlike a distinct multitouch screen as defined by 1822 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1823 * devices will not actually provide full two-finger gestures since the 1824 * input is being transformed to cursor movement on the screen. That is, 1825 * single finger gestures will move a cursor; two-finger swipes will 1826 * result in single-finger touch events; other two-finger gestures will 1827 * result in the corresponding two-finger touch event. 1828 */ 1829 @SdkConstant(SdkConstantType.FEATURE) 1830 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1831 1832 /** 1833 * Feature for {@link #getSystemAvailableFeatures} and 1834 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1835 * does support touch emulation for basic events that supports tracking 1836 * a hand of fingers (5 or more fingers) fully independently. 1837 * This is an extension of 1838 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1839 * that unlike a multitouch screen as defined by 1840 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1841 * gestures can be detected due to the limitations described for 1842 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1843 */ 1844 @SdkConstant(SdkConstantType.FEATURE) 1845 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1846 1847 /** 1848 * Feature for {@link #getSystemAvailableFeatures} and 1849 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 1850 */ 1851 @SdkConstant(SdkConstantType.FEATURE) 1852 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 1853 1854 /** 1855 * Feature for {@link #getSystemAvailableFeatures} and 1856 * {@link #hasSystemFeature}: The device supports portrait orientation 1857 * screens. For backwards compatibility, you can assume that if neither 1858 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1859 * both portrait and landscape. 1860 */ 1861 @SdkConstant(SdkConstantType.FEATURE) 1862 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1863 1864 /** 1865 * Feature for {@link #getSystemAvailableFeatures} and 1866 * {@link #hasSystemFeature}: The device supports landscape orientation 1867 * screens. For backwards compatibility, you can assume that if neither 1868 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1869 * both portrait and landscape. 1870 */ 1871 @SdkConstant(SdkConstantType.FEATURE) 1872 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1873 1874 /** 1875 * Feature for {@link #getSystemAvailableFeatures} and 1876 * {@link #hasSystemFeature}: The device supports live wallpapers. 1877 */ 1878 @SdkConstant(SdkConstantType.FEATURE) 1879 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1880 /** 1881 * Feature for {@link #getSystemAvailableFeatures} and 1882 * {@link #hasSystemFeature}: The device supports app widgets. 1883 */ 1884 @SdkConstant(SdkConstantType.FEATURE) 1885 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 1886 1887 /** 1888 * @hide 1889 * Feature for {@link #getSystemAvailableFeatures} and 1890 * {@link #hasSystemFeature}: The device supports 1891 * {@link android.service.voice.VoiceInteractionService} and 1892 * {@link android.app.VoiceInteractor}. 1893 */ 1894 @SdkConstant(SdkConstantType.FEATURE) 1895 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 1896 1897 1898 /** 1899 * Feature for {@link #getSystemAvailableFeatures} and 1900 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 1901 * by third party applications. 1902 */ 1903 @SdkConstant(SdkConstantType.FEATURE) 1904 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 1905 1906 /** 1907 * Feature for {@link #getSystemAvailableFeatures} and 1908 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 1909 * with the {@link android.inputmethodservice.InputMethodService} API. 1910 */ 1911 @SdkConstant(SdkConstantType.FEATURE) 1912 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 1913 1914 /** 1915 * Feature for {@link #getSystemAvailableFeatures} and 1916 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 1917 */ 1918 @SdkConstant(SdkConstantType.FEATURE) 1919 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 1920 1921 /** 1922 * Feature for {@link #getSystemAvailableFeatures} and 1923 * {@link #hasSystemFeature}: The device supports leanback UI. This is 1924 * typically used in a living room television experience, but is a software 1925 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 1926 * feature will use resources associated with the "television" UI mode. 1927 */ 1928 @SdkConstant(SdkConstantType.FEATURE) 1929 public static final String FEATURE_LEANBACK = "android.software.leanback"; 1930 1931 /** 1932 * Feature for {@link #getSystemAvailableFeatures} and 1933 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 1934 * applications designed for this experience should be run, though this is 1935 * not enforced by the system. 1936 * @hide 1937 */ 1938 @SdkConstant(SdkConstantType.FEATURE) 1939 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 1940 1941 /** 1942 * Feature for {@link #getSystemAvailableFeatures} and 1943 * {@link #hasSystemFeature}: The device supports live TV and can display 1944 * contents from TV inputs implemented with the 1945 * {@link android.media.tv.TvInputService} API. 1946 */ 1947 @SdkConstant(SdkConstantType.FEATURE) 1948 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 1949 1950 /** 1951 * Feature for {@link #getSystemAvailableFeatures} and 1952 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1953 */ 1954 @SdkConstant(SdkConstantType.FEATURE) 1955 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1956 1957 /** 1958 * Feature for {@link #getSystemAvailableFeatures} and 1959 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1960 */ 1961 @SdkConstant(SdkConstantType.FEATURE) 1962 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1963 1964 /** 1965 * Feature for {@link #getSystemAvailableFeatures} and 1966 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware (NAN) 1967 * networking. 1968 * 1969 * @hide PROPOSED_NAN_API 1970 */ 1971 @SdkConstant(SdkConstantType.FEATURE) 1972 public static final String FEATURE_WIFI_NAN = "android.hardware.wifi.nan"; 1973 1974 /** 1975 * Feature for {@link #getSystemAvailableFeatures} and 1976 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1977 * on a vehicle headunit. A headunit here is defined to be inside a 1978 * vehicle that may or may not be moving. A headunit uses either a 1979 * primary display in the center console and/or additional displays in 1980 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 1981 * have limited size and resolution. The user will likely be focused on 1982 * driving so limiting driver distraction is a primary concern. User input 1983 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 1984 * like interfaces. 1985 */ 1986 @SdkConstant(SdkConstantType.FEATURE) 1987 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 1988 1989 /** 1990 * Feature for {@link #getSystemAvailableFeatures} and 1991 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1992 * on a television. Television here is defined to be a typical living 1993 * room television experience: displayed on a big screen, where the user 1994 * is sitting far away from it, and the dominant form of input will be 1995 * something like a DPAD, not through touch or mouse. 1996 * @deprecated use {@link #FEATURE_LEANBACK} instead. 1997 */ 1998 @Deprecated 1999 @SdkConstant(SdkConstantType.FEATURE) 2000 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 2001 2002 /** 2003 * Feature for {@link #getSystemAvailableFeatures} and 2004 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2005 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 2006 * the wrist. The user is very close when interacting with the device. 2007 */ 2008 @SdkConstant(SdkConstantType.FEATURE) 2009 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 2010 2011 /** 2012 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2013 * The device supports printing. 2014 */ 2015 @SdkConstant(SdkConstantType.FEATURE) 2016 public static final String FEATURE_PRINTING = "android.software.print"; 2017 2018 /** 2019 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2020 * The device can perform backup and restore operations on installed applications. 2021 */ 2022 @SdkConstant(SdkConstantType.FEATURE) 2023 public static final String FEATURE_BACKUP = "android.software.backup"; 2024 2025 /** 2026 * Feature for {@link #getSystemAvailableFeatures} and 2027 * {@link #hasSystemFeature}: The device supports freeform window management. 2028 * Windows have title bars and can be moved and resized. 2029 */ 2030 // If this feature is present, you also need to set 2031 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 2032 @SdkConstant(SdkConstantType.FEATURE) 2033 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 2034 = "android.software.freeform_window_management"; 2035 2036 /** 2037 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2038 * The device supports picture-in-picture multi-window mode. 2039 */ 2040 @SdkConstant(SdkConstantType.FEATURE) 2041 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 2042 2043 /** 2044 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2045 * The device supports creating secondary users and managed profiles via 2046 * {@link DevicePolicyManager}. 2047 */ 2048 @SdkConstant(SdkConstantType.FEATURE) 2049 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 2050 2051 /** 2052 * @hide 2053 * TODO: Remove after dependencies updated b/17392243 2054 */ 2055 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 2056 2057 /** 2058 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2059 * The device supports verified boot. 2060 */ 2061 @SdkConstant(SdkConstantType.FEATURE) 2062 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 2063 2064 /** 2065 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2066 * The device supports secure removal of users. When a user is deleted the data associated 2067 * with that user is securely deleted and no longer available. 2068 */ 2069 @SdkConstant(SdkConstantType.FEATURE) 2070 public static final String FEATURE_SECURELY_REMOVES_USERS 2071 = "android.software.securely_removes_users"; 2072 2073 /** {@hide} */ 2074 @SdkConstant(SdkConstantType.FEATURE) 2075 public static final String FEATURE_FILE_BASED_ENCRYPTION 2076 = "android.software.file_based_encryption"; 2077 2078 /** 2079 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2080 * The device has a full implementation of the android.webkit.* APIs. Devices 2081 * lacking this feature will not have a functioning WebView implementation. 2082 */ 2083 @SdkConstant(SdkConstantType.FEATURE) 2084 public static final String FEATURE_WEBVIEW = "android.software.webview"; 2085 2086 /** 2087 * Feature for {@link #getSystemAvailableFeatures} and 2088 * {@link #hasSystemFeature}: This device supports ethernet. 2089 */ 2090 @SdkConstant(SdkConstantType.FEATURE) 2091 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 2092 2093 /** 2094 * Feature for {@link #getSystemAvailableFeatures} and 2095 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 2096 * @hide 2097 */ 2098 @SdkConstant(SdkConstantType.FEATURE) 2099 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 2100 2101 /** 2102 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2103 * The device has all of the inputs necessary to be considered a compatible game controller, or 2104 * includes a compatible game controller in the box. 2105 */ 2106 @SdkConstant(SdkConstantType.FEATURE) 2107 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 2108 2109 /** 2110 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2111 * The device has a full implementation of the android.media.midi.* APIs. 2112 */ 2113 @SdkConstant(SdkConstantType.FEATURE) 2114 public static final String FEATURE_MIDI = "android.software.midi"; 2115 2116 /** 2117 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2118 * The device implements a an optimized mode for virtual reality (VR) applications that handles 2119 * stereoscopic rendering of notifications, and may potentially also include optimizations to 2120 * reduce latency in the graphics, display, and sensor stacks. 2121 */ 2122 @SdkConstant(SdkConstantType.FEATURE) 2123 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 2124 2125 /** 2126 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2127 * The device implements {@link #FEATURE_VR_MODE} but additionally meets all CTS requirements 2128 * to be certified as a "VR Ready" device, which guarantees that the device is capable of 2129 * delivering consistent performance at a high framerate over an extended period of time for 2130 * typical VR application CPU/GPU workloads with a minimal number of frame drops, implements 2131 * {@link #FEATURE_HIFI_SENSORS} with a low sensor latency, implements an optimized render path 2132 * to minimize latency to draw to the device's main display, and includes optimizations to 2133 * lower display persistence to an acceptable level. 2134 */ 2135 @SdkConstant(SdkConstantType.FEATURE) 2136 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE 2137 = "android.hardware.vr.high_performance"; 2138 2139 /** 2140 * Action to external storage service to clean out removed apps. 2141 * @hide 2142 */ 2143 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 2144 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 2145 2146 /** 2147 * Extra field name for the URI to a verification file. Passed to a package 2148 * verifier. 2149 * 2150 * @hide 2151 */ 2152 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 2153 2154 /** 2155 * Extra field name for the ID of a package pending verification. Passed to 2156 * a package verifier and is used to call back to 2157 * {@link PackageManager#verifyPendingInstall(int, int)} 2158 */ 2159 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 2160 2161 /** 2162 * Extra field name for the package identifier which is trying to install 2163 * the package. 2164 * 2165 * @hide 2166 */ 2167 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 2168 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 2169 2170 /** 2171 * Extra field name for the requested install flags for a package pending 2172 * verification. Passed to a package verifier. 2173 * 2174 * @hide 2175 */ 2176 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 2177 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 2178 2179 /** 2180 * Extra field name for the uid of who is requesting to install 2181 * the package. 2182 * 2183 * @hide 2184 */ 2185 public static final String EXTRA_VERIFICATION_INSTALLER_UID 2186 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 2187 2188 /** 2189 * Extra field name for the package name of a package pending verification. 2190 * 2191 * @hide 2192 */ 2193 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 2194 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 2195 /** 2196 * Extra field name for the result of a verification, either 2197 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 2198 * Passed to package verifiers after a package is verified. 2199 */ 2200 public static final String EXTRA_VERIFICATION_RESULT 2201 = "android.content.pm.extra.VERIFICATION_RESULT"; 2202 2203 /** 2204 * Extra field name for the version code of a package pending verification. 2205 * 2206 * @hide 2207 */ 2208 public static final String EXTRA_VERIFICATION_VERSION_CODE 2209 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 2210 2211 /** 2212 * Extra field name for the ID of a intent filter pending verification. 2213 * Passed to an intent filter verifier and is used to call back to 2214 * {@link #verifyIntentFilter} 2215 * 2216 * @hide 2217 */ 2218 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 2219 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 2220 2221 /** 2222 * Extra field name for the scheme used for an intent filter pending verification. Passed to 2223 * an intent filter verifier and is used to construct the URI to verify against. 2224 * 2225 * Usually this is "https" 2226 * 2227 * @hide 2228 */ 2229 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 2230 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 2231 2232 /** 2233 * Extra field name for the host names to be used for an intent filter pending verification. 2234 * Passed to an intent filter verifier and is used to construct the URI to verify the 2235 * intent filter. 2236 * 2237 * This is a space delimited list of hosts. 2238 * 2239 * @hide 2240 */ 2241 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 2242 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 2243 2244 /** 2245 * Extra field name for the package name to be used for an intent filter pending verification. 2246 * Passed to an intent filter verifier and is used to check the verification responses coming 2247 * from the hosts. Each host response will need to include the package name of APK containing 2248 * the intent filter. 2249 * 2250 * @hide 2251 */ 2252 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 2253 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 2254 2255 /** 2256 * The action used to request that the user approve a permission request 2257 * from the application. 2258 * 2259 * @hide 2260 */ 2261 @SystemApi 2262 public static final String ACTION_REQUEST_PERMISSIONS = 2263 "android.content.pm.action.REQUEST_PERMISSIONS"; 2264 2265 /** 2266 * The names of the requested permissions. 2267 * <p> 2268 * <strong>Type:</strong> String[] 2269 * </p> 2270 * 2271 * @hide 2272 */ 2273 @SystemApi 2274 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 2275 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 2276 2277 /** 2278 * The results from the permissions request. 2279 * <p> 2280 * <strong>Type:</strong> int[] of #PermissionResult 2281 * </p> 2282 * 2283 * @hide 2284 */ 2285 @SystemApi 2286 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 2287 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 2288 2289 /** 2290 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2291 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 2292 * the existing definition for the permission. 2293 * @hide 2294 */ 2295 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 2296 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 2297 2298 /** 2299 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2300 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 2301 * being redundantly defined by the package being installed. 2302 * @hide 2303 */ 2304 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 2305 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 2306 2307 /** 2308 * Permission flag: The permission is set in its current state 2309 * by the user and apps can still request it at runtime. 2310 * 2311 * @hide 2312 */ 2313 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 2314 2315 /** 2316 * Permission flag: The permission is set in its current state 2317 * by the user and it is fixed, i.e. apps can no longer request 2318 * this permission. 2319 * 2320 * @hide 2321 */ 2322 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 2323 2324 /** 2325 * Permission flag: The permission is set in its current state 2326 * by device policy and neither apps nor the user can change 2327 * its state. 2328 * 2329 * @hide 2330 */ 2331 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 2332 2333 /** 2334 * Permission flag: The permission is set in a granted state but 2335 * access to resources it guards is restricted by other means to 2336 * enable revoking a permission on legacy apps that do not support 2337 * runtime permissions. If this permission is upgraded to runtime 2338 * because the app was updated to support runtime permissions, the 2339 * the permission will be revoked in the upgrade process. 2340 * 2341 * @hide 2342 */ 2343 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 2344 2345 /** 2346 * Permission flag: The permission is set in its current state 2347 * because the app is a component that is a part of the system. 2348 * 2349 * @hide 2350 */ 2351 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 2352 2353 /** 2354 * Permission flag: The permission is granted by default because it 2355 * enables app functionality that is expected to work out-of-the-box 2356 * for providing a smooth user experience. For example, the phone app 2357 * is expected to have the phone permission. 2358 * 2359 * @hide 2360 */ 2361 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 2362 2363 /** 2364 * Permission flag: The permission has to be reviewed before any of 2365 * the app components can run. 2366 * 2367 * @hide 2368 */ 2369 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 2370 2371 /** 2372 * Mask for all permission flags. 2373 * 2374 * @hide 2375 */ 2376 @SystemApi 2377 public static final int MASK_PERMISSION_FLAGS = 0xFF; 2378 2379 /** 2380 * This is a library that contains components apps can invoke. For 2381 * example, a services for apps to bind to, or standard chooser UI, 2382 * etc. This library is versioned and backwards compatible. Clients 2383 * should check its version via {@link android.ext.services.Version 2384 * #getVersionCode()} and avoid calling APIs added in later versions. 2385 * 2386 * @hide 2387 */ 2388 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 2389 2390 /** 2391 * This is a library that contains components apps can dynamically 2392 * load. For example, new widgets, helper classes, etc. This library 2393 * is versioned and backwards compatible. Clients should check its 2394 * version via {@link android.ext.shared.Version#getVersionCode()} 2395 * and avoid calling APIs added in later versions. 2396 * 2397 * @hide 2398 */ 2399 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 2400 2401 /** 2402 * Retrieve overall information about an application package that is 2403 * installed on the system. 2404 * 2405 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2406 * desired package. 2407 * @param flags Additional option flags. Use any combination of 2408 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2409 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2410 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2411 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2412 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2413 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2414 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2415 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2416 * {@link #MATCH_UNINSTALLED_PACKAGES} 2417 * to modify the data returned. 2418 * 2419 * @return A PackageInfo object containing information about the 2420 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2421 * package is not found in the list of installed applications, the 2422 * package information is retrieved from the list of uninstalled 2423 * applications (which includes installed applications as well as 2424 * applications with data directory i.e. applications which had been 2425 * deleted with {@code DONT_DELETE_DATA} flag set). 2426 * @throws NameNotFoundException if a package with the given name cannot be 2427 * found on the system. 2428 * @see #GET_ACTIVITIES 2429 * @see #GET_CONFIGURATIONS 2430 * @see #GET_GIDS 2431 * @see #GET_INSTRUMENTATION 2432 * @see #GET_INTENT_FILTERS 2433 * @see #GET_META_DATA 2434 * @see #GET_PERMISSIONS 2435 * @see #GET_PROVIDERS 2436 * @see #GET_RECEIVERS 2437 * @see #GET_SERVICES 2438 * @see #GET_SHARED_LIBRARY_FILES 2439 * @see #GET_SIGNATURES 2440 * @see #GET_URI_PERMISSION_PATTERNS 2441 * @see #MATCH_DISABLED_COMPONENTS 2442 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2443 * @see #MATCH_UNINSTALLED_PACKAGES 2444 */ 2445 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) 2446 throws NameNotFoundException; 2447 2448 /** 2449 * @hide 2450 * Retrieve overall information about an application package that is 2451 * installed on the system. 2452 * 2453 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2454 * desired package. 2455 * @param flags Additional option flags. Use any combination of 2456 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2457 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2458 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2459 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2460 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2461 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2462 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2463 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2464 * {@link #MATCH_UNINSTALLED_PACKAGES} 2465 * to modify the data returned. 2466 * @param userId The user id. 2467 * 2468 * @return A PackageInfo object containing information about the 2469 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2470 * package is not found in the list of installed applications, the 2471 * package information is retrieved from the list of uninstalled 2472 * applications (which includes installed applications as well as 2473 * applications with data directory i.e. applications which had been 2474 * deleted with {@code DONT_DELETE_DATA} flag set). 2475 * @throws NameNotFoundException if a package with the given name cannot be 2476 * found on the system. 2477 * @see #GET_ACTIVITIES 2478 * @see #GET_CONFIGURATIONS 2479 * @see #GET_GIDS 2480 * @see #GET_INSTRUMENTATION 2481 * @see #GET_INTENT_FILTERS 2482 * @see #GET_META_DATA 2483 * @see #GET_PERMISSIONS 2484 * @see #GET_PROVIDERS 2485 * @see #GET_RECEIVERS 2486 * @see #GET_SERVICES 2487 * @see #GET_SHARED_LIBRARY_FILES 2488 * @see #GET_SIGNATURES 2489 * @see #GET_URI_PERMISSION_PATTERNS 2490 * @see #MATCH_DISABLED_COMPONENTS 2491 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2492 * @see #MATCH_UNINSTALLED_PACKAGES 2493 */ 2494 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 2495 public abstract PackageInfo getPackageInfoAsUser(String packageName, 2496 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 2497 2498 /** 2499 * Map from the current package names in use on the device to whatever 2500 * the current canonical name of that package is. 2501 * @param names Array of current names to be mapped. 2502 * @return Returns an array of the same size as the original, containing 2503 * the canonical name for each package. 2504 */ 2505 public abstract String[] currentToCanonicalPackageNames(String[] names); 2506 2507 /** 2508 * Map from a packages canonical name to the current name in use on the device. 2509 * @param names Array of new names to be mapped. 2510 * @return Returns an array of the same size as the original, containing 2511 * the current name for each package. 2512 */ 2513 public abstract String[] canonicalToCurrentPackageNames(String[] names); 2514 2515 /** 2516 * Returns a "good" intent to launch a front-door activity in a package. 2517 * This is used, for example, to implement an "open" button when browsing 2518 * through packages. The current implementation looks first for a main 2519 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 2520 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 2521 * <code>null</code> if neither are found. 2522 * 2523 * @param packageName The name of the package to inspect. 2524 * 2525 * @return A fully-qualified {@link Intent} that can be used to launch the 2526 * main activity in the package. Returns <code>null</code> if the package 2527 * does not contain such an activity, or if <em>packageName</em> is not 2528 * recognized. 2529 */ 2530 public abstract Intent getLaunchIntentForPackage(String packageName); 2531 2532 /** 2533 * Return a "good" intent to launch a front-door Leanback activity in a 2534 * package, for use for example to implement an "open" button when browsing 2535 * through packages. The current implementation will look for a main 2536 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 2537 * return null if no main leanback activities are found. 2538 * 2539 * @param packageName The name of the package to inspect. 2540 * @return Returns either a fully-qualified Intent that can be used to launch 2541 * the main Leanback activity in the package, or null if the package 2542 * does not contain such an activity. 2543 */ 2544 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 2545 2546 /** 2547 * Return an array of all of the secondary group-ids that have been assigned 2548 * to a package. 2549 * 2550 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2551 * desired package. 2552 * @return Returns an int array of the assigned gids, or null if there are 2553 * none. 2554 * @throws NameNotFoundException if a package with the given name cannot be 2555 * found on the system. 2556 */ 2557 public abstract int[] getPackageGids(String packageName) 2558 throws NameNotFoundException; 2559 2560 /** 2561 * Return an array of all of the secondary group-ids that have been assigned 2562 * to a package. 2563 * 2564 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2565 * desired package. 2566 * @return Returns an int array of the assigned gids, or null if there are 2567 * none. 2568 * @throws NameNotFoundException if a package with the given name cannot be 2569 * found on the system. 2570 */ 2571 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags) 2572 throws NameNotFoundException; 2573 2574 /** 2575 * Return the UID associated with the given package name. 2576 * 2577 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2578 * desired package. 2579 * @return Returns an integer UID who owns the given package name. 2580 * @throws NameNotFoundException if a package with the given name can not be 2581 * found on the system. 2582 */ 2583 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags) 2584 throws NameNotFoundException; 2585 2586 /** 2587 * Return the UID associated with the given package name. 2588 * 2589 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2590 * desired package. 2591 * @param userId The user handle identifier to look up the package under. 2592 * @return Returns an integer UID who owns the given package name. 2593 * @throws NameNotFoundException if a package with the given name can not be 2594 * found on the system. 2595 * @hide 2596 */ 2597 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId) 2598 throws NameNotFoundException; 2599 2600 /** 2601 * Return the UID associated with the given package name. 2602 * 2603 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2604 * desired package. 2605 * @param userId The user handle identifier to look up the package under. 2606 * @return Returns an integer UID who owns the given package name. 2607 * @throws NameNotFoundException if a package with the given name can not be 2608 * found on the system. 2609 * @hide 2610 */ 2611 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags, 2612 @UserIdInt int userId) throws NameNotFoundException; 2613 2614 /** 2615 * Retrieve all of the information we know about a particular permission. 2616 * 2617 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 2618 * of the permission you are interested in. 2619 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2620 * retrieve any meta-data associated with the permission. 2621 * 2622 * @return Returns a {@link PermissionInfo} containing information about the 2623 * permission. 2624 * @throws NameNotFoundException if a package with the given name cannot be 2625 * found on the system. 2626 * 2627 * @see #GET_META_DATA 2628 */ 2629 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags) 2630 throws NameNotFoundException; 2631 2632 /** 2633 * Query for all of the permissions associated with a particular group. 2634 * 2635 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 2636 * of the permission group you are interested in. Use null to 2637 * find all of the permissions not associated with a group. 2638 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2639 * retrieve any meta-data associated with the permissions. 2640 * 2641 * @return Returns a list of {@link PermissionInfo} containing information 2642 * about all of the permissions in the given group. 2643 * @throws NameNotFoundException if a package with the given name cannot be 2644 * found on the system. 2645 * 2646 * @see #GET_META_DATA 2647 */ 2648 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 2649 @PermissionInfoFlags int flags) throws NameNotFoundException; 2650 2651 /** 2652 * Retrieve all of the information we know about a particular group of 2653 * permissions. 2654 * 2655 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 2656 * of the permission you are interested in. 2657 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2658 * retrieve any meta-data associated with the permission group. 2659 * 2660 * @return Returns a {@link PermissionGroupInfo} containing information 2661 * about the permission. 2662 * @throws NameNotFoundException if a package with the given name cannot be 2663 * found on the system. 2664 * 2665 * @see #GET_META_DATA 2666 */ 2667 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 2668 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 2669 2670 /** 2671 * Retrieve all of the known permission groups in the system. 2672 * 2673 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2674 * retrieve any meta-data associated with the permission group. 2675 * 2676 * @return Returns a list of {@link PermissionGroupInfo} containing 2677 * information about all of the known permission groups. 2678 * 2679 * @see #GET_META_DATA 2680 */ 2681 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 2682 @PermissionGroupInfoFlags int flags); 2683 2684 /** 2685 * Retrieve all of the information we know about a particular 2686 * package/application. 2687 * 2688 * @param packageName The full name (i.e. com.google.apps.contacts) of an 2689 * application. 2690 * @param flags Additional option flags. Use any combination of 2691 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2692 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 2693 * to modify the data returned. 2694 * 2695 * @return An {@link ApplicationInfo} containing information about the 2696 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2697 * package is not found in the list of installed applications, the 2698 * application information is retrieved from the list of uninstalled 2699 * applications (which includes installed applications as well as 2700 * applications with data directory i.e. applications which had been 2701 * deleted with {@code DONT_DELETE_DATA} flag set). 2702 * @throws NameNotFoundException if a package with the given name cannot be 2703 * found on the system. 2704 * 2705 * @see #GET_META_DATA 2706 * @see #GET_SHARED_LIBRARY_FILES 2707 * @see #MATCH_SYSTEM_ONLY 2708 * @see #MATCH_UNINSTALLED_PACKAGES 2709 */ 2710 public abstract ApplicationInfo getApplicationInfo(String packageName, 2711 @ApplicationInfoFlags int flags) throws NameNotFoundException; 2712 2713 /** {@hide} */ 2714 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName, 2715 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 2716 2717 /** 2718 * Retrieve all of the information we know about a particular activity 2719 * class. 2720 * 2721 * @param component The full component name (i.e. 2722 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 2723 * class. 2724 * @param flags Additional option flags. Use any combination of 2725 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2726 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 2727 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2728 * {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, 2729 * {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 2730 * {@link #MATCH_UNINSTALLED_PACKAGES} 2731 * to modify the data returned. 2732 * 2733 * @return An {@link ActivityInfo} containing information about the activity. 2734 * @throws NameNotFoundException if a package with the given name cannot be 2735 * found on the system. 2736 * 2737 * @see #GET_META_DATA 2738 * @see #GET_SHARED_LIBRARY_FILES 2739 * @see #MATCH_ALL 2740 * @see #MATCH_DEBUG_TRIAGED_MISSING 2741 * @see #MATCH_DEFAULT_ONLY 2742 * @see #MATCH_DISABLED_COMPONENTS 2743 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2744 * @see #MATCH_ENCRYPTION_AWARE 2745 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 2746 * @see #MATCH_ENCRYPTION_UNAWARE 2747 * @see #MATCH_SYSTEM_ONLY 2748 * @see #MATCH_UNINSTALLED_PACKAGES 2749 */ 2750 public abstract ActivityInfo getActivityInfo(ComponentName component, 2751 @ComponentInfoFlags int flags) throws NameNotFoundException; 2752 2753 /** 2754 * Retrieve all of the information we know about a particular receiver 2755 * class. 2756 * 2757 * @param component The full component name (i.e. 2758 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 2759 * class. 2760 * @param flags Additional option flags. Use any combination of 2761 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2762 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 2763 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2764 * {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, 2765 * {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 2766 * {@link #MATCH_UNINSTALLED_PACKAGES} 2767 * to modify the data returned. 2768 * 2769 * @return An {@link ActivityInfo} containing information about the receiver. 2770 * @throws NameNotFoundException if a package with the given name cannot be 2771 * found on the system. 2772 * 2773 * @see #GET_META_DATA 2774 * @see #GET_SHARED_LIBRARY_FILES 2775 * @see #MATCH_ALL 2776 * @see #MATCH_DEBUG_TRIAGED_MISSING 2777 * @see #MATCH_DEFAULT_ONLY 2778 * @see #MATCH_DISABLED_COMPONENTS 2779 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2780 * @see #MATCH_ENCRYPTION_AWARE 2781 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 2782 * @see #MATCH_ENCRYPTION_UNAWARE 2783 * @see #MATCH_SYSTEM_ONLY 2784 * @see #MATCH_UNINSTALLED_PACKAGES 2785 */ 2786 public abstract ActivityInfo getReceiverInfo(ComponentName component, 2787 @ComponentInfoFlags int flags) throws NameNotFoundException; 2788 2789 /** 2790 * Retrieve all of the information we know about a particular service 2791 * class. 2792 * 2793 * @param component The full component name (i.e. 2794 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 2795 * class. 2796 * @param flags Additional option flags. Use any combination of 2797 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2798 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 2799 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2800 * {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, 2801 * {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 2802 * {@link #MATCH_UNINSTALLED_PACKAGES} 2803 * to modify the data returned. 2804 * 2805 * @return A {@link ServiceInfo} object containing information about the service. 2806 * @throws NameNotFoundException if a package with the given name cannot be 2807 * found on the system. 2808 * 2809 * @see #GET_META_DATA 2810 * @see #GET_SHARED_LIBRARY_FILES 2811 * @see #MATCH_ALL 2812 * @see #MATCH_DEBUG_TRIAGED_MISSING 2813 * @see #MATCH_DEFAULT_ONLY 2814 * @see #MATCH_DISABLED_COMPONENTS 2815 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2816 * @see #MATCH_ENCRYPTION_AWARE 2817 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 2818 * @see #MATCH_ENCRYPTION_UNAWARE 2819 * @see #MATCH_SYSTEM_ONLY 2820 * @see #MATCH_UNINSTALLED_PACKAGES 2821 */ 2822 public abstract ServiceInfo getServiceInfo(ComponentName component, 2823 @ComponentInfoFlags int flags) throws NameNotFoundException; 2824 2825 /** 2826 * Retrieve all of the information we know about a particular content 2827 * provider class. 2828 * 2829 * @param component The full component name (i.e. 2830 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 2831 * ContentProvider class. 2832 * @param flags Additional option flags. Use any combination of 2833 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2834 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 2835 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2836 * {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, 2837 * {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 2838 * {@link #MATCH_UNINSTALLED_PACKAGES} 2839 * to modify the data returned. 2840 * 2841 * @return A {@link ProviderInfo} object containing information about the provider. 2842 * @throws NameNotFoundException if a package with the given name cannot be 2843 * found on the system. 2844 * 2845 * @see #GET_META_DATA 2846 * @see #GET_SHARED_LIBRARY_FILES 2847 * @see #MATCH_ALL 2848 * @see #MATCH_DEBUG_TRIAGED_MISSING 2849 * @see #MATCH_DEFAULT_ONLY 2850 * @see #MATCH_DISABLED_COMPONENTS 2851 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2852 * @see #MATCH_ENCRYPTION_AWARE 2853 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 2854 * @see #MATCH_ENCRYPTION_UNAWARE 2855 * @see #MATCH_SYSTEM_ONLY 2856 * @see #MATCH_UNINSTALLED_PACKAGES 2857 */ 2858 public abstract ProviderInfo getProviderInfo(ComponentName component, 2859 @ComponentInfoFlags int flags) throws NameNotFoundException; 2860 2861 /** 2862 * Return a List of all packages that are installed 2863 * on the device. 2864 * 2865 * @param flags Additional option flags. Use any combination of 2866 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2867 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2868 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2869 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2870 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2871 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2872 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2873 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2874 * {@link #MATCH_UNINSTALLED_PACKAGES} 2875 * to modify the data returned. 2876 * 2877 * @return A List of PackageInfo objects, one for each installed package, 2878 * containing information about the package. In the unlikely case 2879 * there are no installed packages, an empty list is returned. If 2880 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 2881 * information is retrieved from the list of uninstalled 2882 * applications (which includes installed applications as well as 2883 * applications with data directory i.e. applications which had been 2884 * deleted with {@code DONT_DELETE_DATA} flag set). 2885 * 2886 * @see #GET_ACTIVITIES 2887 * @see #GET_CONFIGURATIONS 2888 * @see #GET_GIDS 2889 * @see #GET_INSTRUMENTATION 2890 * @see #GET_INTENT_FILTERS 2891 * @see #GET_META_DATA 2892 * @see #GET_PERMISSIONS 2893 * @see #GET_PROVIDERS 2894 * @see #GET_RECEIVERS 2895 * @see #GET_SERVICES 2896 * @see #GET_SHARED_LIBRARY_FILES 2897 * @see #GET_SIGNATURES 2898 * @see #GET_URI_PERMISSION_PATTERNS 2899 * @see #MATCH_DISABLED_COMPONENTS 2900 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2901 * @see #MATCH_UNINSTALLED_PACKAGES 2902 */ 2903 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags); 2904 2905 /** 2906 * Return a List of all installed packages that are currently 2907 * holding any of the given permissions. 2908 * 2909 * @param flags Additional option flags. Use any combination of 2910 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2911 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2912 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2913 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2914 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2915 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2916 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2917 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2918 * {@link #MATCH_UNINSTALLED_PACKAGES} 2919 * to modify the data returned. 2920 * 2921 * @return A List of PackageInfo objects, one for each installed package 2922 * that holds any of the permissions that were provided, containing 2923 * information about the package. If no installed packages hold any 2924 * of the permissions, an empty list is returned. If flag 2925 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package information 2926 * is retrieved from the list of uninstalled applications (which 2927 * includes installed applications as well as applications with data 2928 * directory i.e. applications which had been deleted with 2929 * {@code DONT_DELETE_DATA} flag set). 2930 * 2931 * @see #GET_ACTIVITIES 2932 * @see #GET_CONFIGURATIONS 2933 * @see #GET_GIDS 2934 * @see #GET_INSTRUMENTATION 2935 * @see #GET_INTENT_FILTERS 2936 * @see #GET_META_DATA 2937 * @see #GET_PERMISSIONS 2938 * @see #GET_PROVIDERS 2939 * @see #GET_RECEIVERS 2940 * @see #GET_SERVICES 2941 * @see #GET_SHARED_LIBRARY_FILES 2942 * @see #GET_SIGNATURES 2943 * @see #GET_URI_PERMISSION_PATTERNS 2944 * @see #MATCH_DISABLED_COMPONENTS 2945 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2946 * @see #MATCH_UNINSTALLED_PACKAGES 2947 */ 2948 public abstract List<PackageInfo> getPackagesHoldingPermissions( 2949 String[] permissions, @PackageInfoFlags int flags); 2950 2951 /** 2952 * Return a List of all packages that are installed on the device, for a specific user. 2953 * Requesting a list of installed packages for another user 2954 * will require the permission INTERACT_ACROSS_USERS_FULL. 2955 * 2956 * @param flags Additional option flags. Use any combination of 2957 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2958 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2959 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2960 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2961 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2962 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2963 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2964 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2965 * {@link #MATCH_UNINSTALLED_PACKAGES} 2966 * to modify the data returned. 2967 * @param userId The user for whom the installed packages are to be listed 2968 * 2969 * @return A List of PackageInfo objects, one for each installed package, 2970 * containing information about the package. In the unlikely case 2971 * there are no installed packages, an empty list is returned. If 2972 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 2973 * information is retrieved from the list of uninstalled 2974 * applications (which includes installed applications as well as 2975 * applications with data directory i.e. applications which had been 2976 * deleted with {@code DONT_DELETE_DATA} flag set). 2977 * 2978 * @see #GET_ACTIVITIES 2979 * @see #GET_CONFIGURATIONS 2980 * @see #GET_GIDS 2981 * @see #GET_INSTRUMENTATION 2982 * @see #GET_INTENT_FILTERS 2983 * @see #GET_META_DATA 2984 * @see #GET_PERMISSIONS 2985 * @see #GET_PROVIDERS 2986 * @see #GET_RECEIVERS 2987 * @see #GET_SERVICES 2988 * @see #GET_SHARED_LIBRARY_FILES 2989 * @see #GET_SIGNATURES 2990 * @see #GET_URI_PERMISSION_PATTERNS 2991 * @see #MATCH_DISABLED_COMPONENTS 2992 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2993 * @see #MATCH_UNINSTALLED_PACKAGES 2994 * 2995 * @hide 2996 */ 2997 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags, 2998 @UserIdInt int userId); 2999 3000 /** 3001 * Check whether a particular package has been granted a particular 3002 * permission. 3003 * 3004 * @param permName The name of the permission you are checking for. 3005 * @param pkgName The name of the package you are checking against. 3006 * 3007 * @return If the package has the permission, PERMISSION_GRANTED is 3008 * returned. If it does not have the permission, PERMISSION_DENIED 3009 * is returned. 3010 * 3011 * @see #PERMISSION_GRANTED 3012 * @see #PERMISSION_DENIED 3013 */ 3014 @CheckResult 3015 public abstract int checkPermission(String permName, String pkgName); 3016 3017 /** 3018 * Checks whether a particular permissions has been revoked for a 3019 * package by policy. Typically the device owner or the profile owner 3020 * may apply such a policy. The user cannot grant policy revoked 3021 * permissions, hence the only way for an app to get such a permission 3022 * is by a policy change. 3023 * 3024 * @param permName The name of the permission you are checking for. 3025 * @param pkgName The name of the package you are checking against. 3026 * 3027 * @return Whether the permission is restricted by policy. 3028 */ 3029 @CheckResult 3030 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 3031 @NonNull String pkgName); 3032 3033 /** 3034 * Gets the package name of the component controlling runtime permissions. 3035 * 3036 * @return The package name. 3037 * 3038 * @hide 3039 */ 3040 public abstract String getPermissionControllerPackageName(); 3041 3042 /** 3043 * Add a new dynamic permission to the system. For this to work, your 3044 * package must have defined a permission tree through the 3045 * {@link android.R.styleable#AndroidManifestPermissionTree 3046 * <permission-tree>} tag in its manifest. A package can only add 3047 * permissions to trees that were defined by either its own package or 3048 * another with the same user id; a permission is in a tree if it 3049 * matches the name of the permission tree + ".": for example, 3050 * "com.foo.bar" is a member of the permission tree "com.foo". 3051 * 3052 * <p>It is good to make your permission tree name descriptive, because you 3053 * are taking possession of that entire set of permission names. Thus, it 3054 * must be under a domain you control, with a suffix that will not match 3055 * any normal permissions that may be declared in any applications that 3056 * are part of that domain. 3057 * 3058 * <p>New permissions must be added before 3059 * any .apks are installed that use those permissions. Permissions you 3060 * add through this method are remembered across reboots of the device. 3061 * If the given permission already exists, the info you supply here 3062 * will be used to update it. 3063 * 3064 * @param info Description of the permission to be added. 3065 * 3066 * @return Returns true if a new permission was created, false if an 3067 * existing one was updated. 3068 * 3069 * @throws SecurityException if you are not allowed to add the 3070 * given permission name. 3071 * 3072 * @see #removePermission(String) 3073 */ 3074 public abstract boolean addPermission(PermissionInfo info); 3075 3076 /** 3077 * Like {@link #addPermission(PermissionInfo)} but asynchronously 3078 * persists the package manager state after returning from the call, 3079 * allowing it to return quicker and batch a series of adds at the 3080 * expense of no guarantee the added permission will be retained if 3081 * the device is rebooted before it is written. 3082 */ 3083 public abstract boolean addPermissionAsync(PermissionInfo info); 3084 3085 /** 3086 * Removes a permission that was previously added with 3087 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 3088 * -- you are only allowed to remove permissions that you are allowed 3089 * to add. 3090 * 3091 * @param name The name of the permission to remove. 3092 * 3093 * @throws SecurityException if you are not allowed to remove the 3094 * given permission name. 3095 * 3096 * @see #addPermission(PermissionInfo) 3097 */ 3098 public abstract void removePermission(String name); 3099 3100 3101 /** 3102 * Permission flags set when granting or revoking a permission. 3103 * 3104 * @hide 3105 */ 3106 @SystemApi 3107 @IntDef({FLAG_PERMISSION_USER_SET, 3108 FLAG_PERMISSION_USER_FIXED, 3109 FLAG_PERMISSION_POLICY_FIXED, 3110 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 3111 FLAG_PERMISSION_SYSTEM_FIXED, 3112 FLAG_PERMISSION_GRANTED_BY_DEFAULT}) 3113 @Retention(RetentionPolicy.SOURCE) 3114 public @interface PermissionFlags {} 3115 3116 /** 3117 * Grant a runtime permission to an application which the application does not 3118 * already have. The permission must have been requested by the application. 3119 * If the application is not allowed to hold the permission, a {@link 3120 * java.lang.SecurityException} is thrown. 3121 * <p> 3122 * <strong>Note: </strong>Using this API requires holding 3123 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 3124 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3125 * </p> 3126 * 3127 * @param packageName The package to which to grant the permission. 3128 * @param permissionName The permission name to grant. 3129 * @param user The user for which to grant the permission. 3130 * 3131 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 3132 * @see android.content.pm.PackageManager.PermissionFlags 3133 * 3134 * @hide 3135 */ 3136 @SystemApi 3137 public abstract void grantRuntimePermission(@NonNull String packageName, 3138 @NonNull String permissionName, @NonNull UserHandle user); 3139 3140 /** 3141 * Revoke a runtime permission that was previously granted by {@link 3142 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 3143 * permission must have been requested by and granted to the application. 3144 * If the application is not allowed to hold the permission, a {@link 3145 * java.lang.SecurityException} is thrown. 3146 * <p> 3147 * <strong>Note: </strong>Using this API requires holding 3148 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 3149 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3150 * </p> 3151 * 3152 * @param packageName The package from which to revoke the permission. 3153 * @param permissionName The permission name to revoke. 3154 * @param user The user for which to revoke the permission. 3155 * 3156 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 3157 * @see android.content.pm.PackageManager.PermissionFlags 3158 * 3159 * @hide 3160 */ 3161 @SystemApi 3162 public abstract void revokeRuntimePermission(@NonNull String packageName, 3163 @NonNull String permissionName, @NonNull UserHandle user); 3164 3165 /** 3166 * Gets the state flags associated with a permission. 3167 * 3168 * @param permissionName The permission for which to get the flags. 3169 * @param packageName The package name for which to get the flags. 3170 * @param user The user for which to get permission flags. 3171 * @return The permission flags. 3172 * 3173 * @hide 3174 */ 3175 @SystemApi 3176 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 3177 String packageName, @NonNull UserHandle user); 3178 3179 /** 3180 * Updates the flags associated with a permission by replacing the flags in 3181 * the specified mask with the provided flag values. 3182 * 3183 * @param permissionName The permission for which to update the flags. 3184 * @param packageName The package name for which to update the flags. 3185 * @param flagMask The flags which to replace. 3186 * @param flagValues The flags with which to replace. 3187 * @param user The user for which to update the permission flags. 3188 * 3189 * @hide 3190 */ 3191 @SystemApi 3192 public abstract void updatePermissionFlags(String permissionName, 3193 String packageName, @PermissionFlags int flagMask, int flagValues, 3194 @NonNull UserHandle user); 3195 3196 /** 3197 * Gets whether you should show UI with rationale for requesting a permission. 3198 * You should do this only if you do not have the permission and the context in 3199 * which the permission is requested does not clearly communicate to the user 3200 * what would be the benefit from grating this permission. 3201 * 3202 * @param permission A permission your app wants to request. 3203 * @return Whether you can show permission rationale UI. 3204 * 3205 * @hide 3206 */ 3207 public abstract boolean shouldShowRequestPermissionRationale(String permission); 3208 3209 /** 3210 * Returns an {@link android.content.Intent} suitable for passing to 3211 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 3212 * which prompts the user to grant permissions to this application. 3213 * 3214 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 3215 * 3216 * @hide 3217 */ 3218 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 3219 if (ArrayUtils.isEmpty(permissions)) { 3220 throw new IllegalArgumentException("permission cannot be null or empty"); 3221 } 3222 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 3223 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 3224 intent.setPackage(getPermissionControllerPackageName()); 3225 return intent; 3226 } 3227 3228 /** 3229 * Compare the signatures of two packages to determine if the same 3230 * signature appears in both of them. If they do contain the same 3231 * signature, then they are allowed special privileges when working 3232 * with each other: they can share the same user-id, run instrumentation 3233 * against each other, etc. 3234 * 3235 * @param pkg1 First package name whose signature will be compared. 3236 * @param pkg2 Second package name whose signature will be compared. 3237 * 3238 * @return Returns an integer indicating whether all signatures on the 3239 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3240 * all signatures match or < 0 if there is not a match ({@link 3241 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3242 * 3243 * @see #checkSignatures(int, int) 3244 * @see #SIGNATURE_MATCH 3245 * @see #SIGNATURE_NO_MATCH 3246 * @see #SIGNATURE_UNKNOWN_PACKAGE 3247 */ 3248 @CheckResult 3249 public abstract int checkSignatures(String pkg1, String pkg2); 3250 3251 /** 3252 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 3253 * the two packages to be checked. This can be useful, for example, 3254 * when doing the check in an IPC, where the UID is the only identity 3255 * available. It is functionally identical to determining the package 3256 * associated with the UIDs and checking their signatures. 3257 * 3258 * @param uid1 First UID whose signature will be compared. 3259 * @param uid2 Second UID whose signature will be compared. 3260 * 3261 * @return Returns an integer indicating whether all signatures on the 3262 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3263 * all signatures match or < 0 if there is not a match ({@link 3264 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3265 * 3266 * @see #checkSignatures(String, String) 3267 * @see #SIGNATURE_MATCH 3268 * @see #SIGNATURE_NO_MATCH 3269 * @see #SIGNATURE_UNKNOWN_PACKAGE 3270 */ 3271 @CheckResult 3272 public abstract int checkSignatures(int uid1, int uid2); 3273 3274 /** 3275 * Retrieve the names of all packages that are associated with a particular 3276 * user id. In most cases, this will be a single package name, the package 3277 * that has been assigned that user id. Where there are multiple packages 3278 * sharing the same user id through the "sharedUserId" mechanism, all 3279 * packages with that id will be returned. 3280 * 3281 * @param uid The user id for which you would like to retrieve the 3282 * associated packages. 3283 * 3284 * @return Returns an array of one or more packages assigned to the user 3285 * id, or null if there are no known packages with the given id. 3286 */ 3287 public abstract @Nullable String[] getPackagesForUid(int uid); 3288 3289 /** 3290 * Retrieve the official name associated with a user id. This name is 3291 * guaranteed to never change, though it is possible for the underlying 3292 * user id to be changed. That is, if you are storing information about 3293 * user ids in persistent storage, you should use the string returned 3294 * by this function instead of the raw user-id. 3295 * 3296 * @param uid The user id for which you would like to retrieve a name. 3297 * @return Returns a unique name for the given user id, or null if the 3298 * user id is not currently assigned. 3299 */ 3300 public abstract @Nullable String getNameForUid(int uid); 3301 3302 /** 3303 * Return the user id associated with a shared user name. Multiple 3304 * applications can specify a shared user name in their manifest and thus 3305 * end up using a common uid. This might be used for new applications 3306 * that use an existing shared user name and need to know the uid of the 3307 * shared user. 3308 * 3309 * @param sharedUserName The shared user name whose uid is to be retrieved. 3310 * @return Returns the UID associated with the shared user. 3311 * @throws NameNotFoundException if a package with the given name cannot be 3312 * found on the system. 3313 * @hide 3314 */ 3315 public abstract int getUidForSharedUser(String sharedUserName) 3316 throws NameNotFoundException; 3317 3318 /** 3319 * Return a List of all application packages that are installed on the 3320 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 3321 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 3322 * installed apps with data directory) will be returned. 3323 * 3324 * @param flags Additional option flags. Use any combination of 3325 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3326 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3327 * to modify the data returned. 3328 * 3329 * @return A List of ApplicationInfo objects, one for each installed application. 3330 * In the unlikely case there are no installed packages, an empty list 3331 * is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the 3332 * application information is retrieved from the list of uninstalled 3333 * applications (which includes installed applications as well as 3334 * applications with data directory i.e. applications which had been 3335 * deleted with {@code DONT_DELETE_DATA} flag set). 3336 * 3337 * @see #GET_META_DATA 3338 * @see #GET_SHARED_LIBRARY_FILES 3339 * @see #MATCH_SYSTEM_ONLY 3340 * @see #MATCH_UNINSTALLED_PACKAGES 3341 */ 3342 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 3343 3344 /** 3345 * Gets the ephemeral applications the user recently used. Requires 3346 * holding "android.permission.ACCESS_EPHEMERAL_APPS". 3347 * 3348 * @return The ephemeral app list. 3349 * 3350 * @hide 3351 */ 3352 @RequiresPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS) 3353 public abstract List<EphemeralApplicationInfo> getEphemeralApplications(); 3354 3355 /** 3356 * Gets the icon for an ephemeral application. 3357 * 3358 * @param packageName The app package name. 3359 * 3360 * @hide 3361 */ 3362 public abstract Drawable getEphemeralApplicationIcon(String packageName); 3363 3364 /** 3365 * Gets whether the caller is an ephemeral app. 3366 * 3367 * @return Whether caller is an ephemeral app. 3368 * 3369 * @see #setEphemeralCookie(byte[]) 3370 * @see #getEphemeralCookie() 3371 * @see #getEphemeralCookieMaxSizeBytes() 3372 * 3373 * @hide 3374 */ 3375 public abstract boolean isEphemeralApplication(); 3376 3377 /** 3378 * Gets the maximum size in bytes of the cookie data an ephemeral app 3379 * can store on the device. 3380 * 3381 * @return The max cookie size in bytes. 3382 * 3383 * @see #isEphemeralApplication() 3384 * @see #setEphemeralCookie(byte[]) 3385 * @see #getEphemeralCookie() 3386 * 3387 * @hide 3388 */ 3389 public abstract int getEphemeralCookieMaxSizeBytes(); 3390 3391 /** 3392 * Gets the ephemeral application cookie for this app. Non 3393 * ephemeral apps and apps that were ephemeral but were upgraded 3394 * to non-ephemeral can still access this API. For ephemeral apps 3395 * this cooke is cached for some time after uninstall while for 3396 * normal apps the cookie is deleted after the app is uninstalled. 3397 * The cookie is always present while the app is installed. 3398 * 3399 * @return The cookie. 3400 * 3401 * @see #isEphemeralApplication() 3402 * @see #setEphemeralCookie(byte[]) 3403 * @see #getEphemeralCookieMaxSizeBytes() 3404 * 3405 * @hide 3406 */ 3407 public abstract @NonNull byte[] getEphemeralCookie(); 3408 3409 /** 3410 * Sets the ephemeral application cookie for the calling app. Non 3411 * ephemeral apps and apps that were ephemeral but were upgraded 3412 * to non-ephemeral can still access this API. For ephemeral apps 3413 * this cooke is cached for some time after uninstall while for 3414 * normal apps the cookie is deleted after the app is uninstalled. 3415 * The cookie is always present while the app is installed. The 3416 * cookie size is limited by {@link #getEphemeralCookieMaxSizeBytes()}. 3417 * 3418 * @param cookie The cookie data. 3419 * @return True if the cookie was set. 3420 * 3421 * @see #isEphemeralApplication() 3422 * @see #getEphemeralCookieMaxSizeBytes() 3423 * @see #getEphemeralCookie() 3424 * 3425 * @hide 3426 */ 3427 public abstract boolean setEphemeralCookie(@NonNull byte[] cookie); 3428 3429 /** 3430 * Get a list of shared libraries that are available on the 3431 * system. 3432 * 3433 * @return An array of shared library names that are 3434 * available on the system, or null if none are installed. 3435 * 3436 */ 3437 public abstract String[] getSystemSharedLibraryNames(); 3438 3439 /** 3440 * Get the name of the package hosting the services shared library. 3441 * 3442 * @return The library host package. 3443 * 3444 * @hide 3445 */ 3446 public abstract @Nullable String getServicesSystemSharedLibraryPackageName(); 3447 3448 /** 3449 * Get a list of features that are available on the 3450 * system. 3451 * 3452 * @return An array of FeatureInfo classes describing the features 3453 * that are available on the system, or null if there are none(!!). 3454 */ 3455 public abstract FeatureInfo[] getSystemAvailableFeatures(); 3456 3457 /** 3458 * Check whether the given feature name is one of the available features as 3459 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 3460 * presence of <em>any</em> version of the given feature name; use 3461 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 3462 * 3463 * @return Returns true if the devices supports the feature, else false. 3464 */ 3465 public abstract boolean hasSystemFeature(String name); 3466 3467 /** 3468 * Check whether the given feature name and version is one of the available 3469 * features as returned by {@link #getSystemAvailableFeatures()}. Since 3470 * features are defined to always be backwards compatible, this returns true 3471 * if the available feature version is greater than or equal to the 3472 * requested version. 3473 * 3474 * @return Returns true if the devices supports the feature, else false. 3475 */ 3476 public abstract boolean hasSystemFeature(String name, int version); 3477 3478 /** 3479 * Determine the best action to perform for a given Intent. This is how 3480 * {@link Intent#resolveActivity} finds an activity if a class has not 3481 * been explicitly specified. 3482 * 3483 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 3484 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 3485 * only flag. You need to do so to resolve the activity in the same way 3486 * that {@link android.content.Context#startActivity(Intent)} and 3487 * {@link android.content.Intent#resolveActivity(PackageManager) 3488 * Intent.resolveActivity(PackageManager)} do.</p> 3489 * 3490 * @param intent An intent containing all of the desired specification 3491 * (action, data, type, category, and/or component). 3492 * @param flags Additional option flags. Use any combination of 3493 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3494 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3495 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3496 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3497 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3498 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3499 * to modify the data returned. The most important is 3500 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3501 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3502 * 3503 * @return Returns a ResolveInfo object containing the final activity intent 3504 * that was determined to be the best action. Returns null if no 3505 * matching activity was found. If multiple matching activities are 3506 * found and there is no default set, returns a ResolveInfo object 3507 * containing something else, such as the activity resolver. 3508 * 3509 * @see #GET_META_DATA 3510 * @see #GET_RESOLVED_FILTER 3511 * @see #GET_SHARED_LIBRARY_FILES 3512 * @see #MATCH_ALL 3513 * @see #MATCH_DISABLED_COMPONENTS 3514 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3515 * @see #MATCH_DEFAULT_ONLY 3516 * @see #MATCH_ENCRYPTION_AWARE 3517 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3518 * @see #MATCH_ENCRYPTION_UNAWARE 3519 * @see #MATCH_SYSTEM_ONLY 3520 * @see #MATCH_UNINSTALLED_PACKAGES 3521 */ 3522 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags); 3523 3524 /** 3525 * Determine the best action to perform for a given Intent for a given user. This 3526 * is how {@link Intent#resolveActivity} finds an activity if a class has not 3527 * been explicitly specified. 3528 * 3529 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 3530 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 3531 * only flag. You need to do so to resolve the activity in the same way 3532 * that {@link android.content.Context#startActivity(Intent)} and 3533 * {@link android.content.Intent#resolveActivity(PackageManager) 3534 * Intent.resolveActivity(PackageManager)} do.</p> 3535 * 3536 * @param intent An intent containing all of the desired specification 3537 * (action, data, type, category, and/or component). 3538 * @param flags Additional option flags. Use any combination of 3539 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3540 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3541 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3542 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3543 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3544 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3545 * to modify the data returned. The most important is 3546 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3547 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3548 * @param userId The user id. 3549 * 3550 * @return Returns a ResolveInfo object containing the final activity intent 3551 * that was determined to be the best action. Returns null if no 3552 * matching activity was found. If multiple matching activities are 3553 * found and there is no default set, returns a ResolveInfo object 3554 * containing something else, such as the activity resolver. 3555 * 3556 * @see #GET_META_DATA 3557 * @see #GET_RESOLVED_FILTER 3558 * @see #GET_SHARED_LIBRARY_FILES 3559 * @see #MATCH_ALL 3560 * @see #MATCH_DISABLED_COMPONENTS 3561 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3562 * @see #MATCH_DEFAULT_ONLY 3563 * @see #MATCH_ENCRYPTION_AWARE 3564 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3565 * @see #MATCH_ENCRYPTION_UNAWARE 3566 * @see #MATCH_SYSTEM_ONLY 3567 * @see #MATCH_UNINSTALLED_PACKAGES 3568 * 3569 * @hide 3570 */ 3571 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, 3572 @UserIdInt int userId); 3573 3574 /** 3575 * Retrieve all activities that can be performed for the given intent. 3576 * 3577 * @param intent The desired intent as per resolveActivity(). 3578 * @param flags Additional option flags. Use any combination of 3579 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3580 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3581 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3582 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3583 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3584 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3585 * to modify the data returned. The most important is 3586 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3587 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3588 * Or, set {@link #MATCH_ALL} to prevent any filtering of the results. 3589 * 3590 * @return Returns a List of ResolveInfo objects containing one entry for each 3591 * matching activity, ordered from best to worst. In other words, the 3592 * first item is what would be returned by {@link #resolveActivity}. 3593 * If there are no matching activities, an empty list is returned. 3594 * 3595 * @see #GET_META_DATA 3596 * @see #GET_RESOLVED_FILTER 3597 * @see #GET_SHARED_LIBRARY_FILES 3598 * @see #MATCH_ALL 3599 * @see #MATCH_DISABLED_COMPONENTS 3600 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3601 * @see #MATCH_DEFAULT_ONLY 3602 * @see #MATCH_ENCRYPTION_AWARE 3603 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3604 * @see #MATCH_ENCRYPTION_UNAWARE 3605 * @see #MATCH_SYSTEM_ONLY 3606 * @see #MATCH_UNINSTALLED_PACKAGES 3607 */ 3608 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 3609 @ResolveInfoFlags int flags); 3610 3611 /** 3612 * Retrieve all activities that can be performed for the given intent, for a specific user. 3613 * 3614 * @param intent The desired intent as per resolveActivity(). 3615 * @param flags Additional option flags. Use any combination of 3616 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3617 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3618 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3619 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3620 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3621 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3622 * to modify the data returned. The most important is 3623 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3624 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3625 * Or, set {@link #MATCH_ALL} to prevent any filtering of the results. 3626 * 3627 * @return Returns a List of ResolveInfo objects containing one entry for each 3628 * matching activity, ordered from best to worst. In other words, the 3629 * first item is what would be returned by {@link #resolveActivity}. 3630 * If there are no matching activities, an empty list is returned. 3631 * 3632 * @see #GET_META_DATA 3633 * @see #GET_RESOLVED_FILTER 3634 * @see #GET_SHARED_LIBRARY_FILES 3635 * @see #MATCH_ALL 3636 * @see #MATCH_DISABLED_COMPONENTS 3637 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3638 * @see #MATCH_DEFAULT_ONLY 3639 * @see #MATCH_ENCRYPTION_AWARE 3640 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3641 * @see #MATCH_ENCRYPTION_UNAWARE 3642 * @see #MATCH_SYSTEM_ONLY 3643 * @see #MATCH_UNINSTALLED_PACKAGES 3644 * 3645 * @hide 3646 */ 3647 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 3648 @ResolveInfoFlags int flags, @UserIdInt int userId); 3649 3650 /** 3651 * Retrieve a set of activities that should be presented to the user as 3652 * similar options. This is like {@link #queryIntentActivities}, except it 3653 * also allows you to supply a list of more explicit Intents that you would 3654 * like to resolve to particular options, and takes care of returning the 3655 * final ResolveInfo list in a reasonable order, with no duplicates, based 3656 * on those inputs. 3657 * 3658 * @param caller The class name of the activity that is making the 3659 * request. This activity will never appear in the output 3660 * list. Can be null. 3661 * @param specifics An array of Intents that should be resolved to the 3662 * first specific results. Can be null. 3663 * @param intent The desired intent as per resolveActivity(). 3664 * @param flags Additional option flags. Use any combination of 3665 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3666 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3667 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3668 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3669 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3670 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3671 * to modify the data returned. The most important is 3672 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 3673 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 3674 * 3675 * @return Returns a List of ResolveInfo objects containing one entry for each 3676 * matching activity. The list is ordered first by all of the intents resolved 3677 * in <var>specifics</var> and then any additional activities that 3678 * can handle <var>intent</var> but did not get included by one of 3679 * the <var>specifics</var> intents. If there are no matching 3680 * activities, an empty list is returned. 3681 * 3682 * @see #GET_META_DATA 3683 * @see #GET_RESOLVED_FILTER 3684 * @see #GET_SHARED_LIBRARY_FILES 3685 * @see #MATCH_ALL 3686 * @see #MATCH_DISABLED_COMPONENTS 3687 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3688 * @see #MATCH_DEFAULT_ONLY 3689 * @see #MATCH_ENCRYPTION_AWARE 3690 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3691 * @see #MATCH_ENCRYPTION_UNAWARE 3692 * @see #MATCH_SYSTEM_ONLY 3693 * @see #MATCH_UNINSTALLED_PACKAGES 3694 */ 3695 public abstract List<ResolveInfo> queryIntentActivityOptions( 3696 ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags); 3697 3698 /** 3699 * Retrieve all receivers that can handle a broadcast of the given intent. 3700 * 3701 * @param intent The desired intent as per resolveActivity(). 3702 * @param flags Additional option flags. Use any combination of 3703 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3704 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3705 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3706 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3707 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3708 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3709 * to modify the data returned. 3710 * 3711 * @return Returns a List of ResolveInfo objects containing one entry for each 3712 * matching receiver, ordered from best to worst. If there are no matching 3713 * receivers, an empty list or null is returned. 3714 * 3715 * @see #GET_META_DATA 3716 * @see #GET_RESOLVED_FILTER 3717 * @see #GET_SHARED_LIBRARY_FILES 3718 * @see #MATCH_ALL 3719 * @see #MATCH_DISABLED_COMPONENTS 3720 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3721 * @see #MATCH_DEFAULT_ONLY 3722 * @see #MATCH_ENCRYPTION_AWARE 3723 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3724 * @see #MATCH_ENCRYPTION_UNAWARE 3725 * @see #MATCH_SYSTEM_ONLY 3726 * @see #MATCH_UNINSTALLED_PACKAGES 3727 */ 3728 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 3729 @ResolveInfoFlags int flags); 3730 3731 /** 3732 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 3733 * user. 3734 * 3735 * @param intent The desired intent as per resolveActivity(). 3736 * @param flags Additional option flags. Use any combination of 3737 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3738 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3739 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3740 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3741 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3742 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3743 * to modify the data returned. 3744 * @param userHandle UserHandle of the user being queried. 3745 * 3746 * @return Returns a List of ResolveInfo objects containing one entry for each 3747 * matching receiver, ordered from best to worst. If there are no matching 3748 * receivers, an empty list or null is returned. 3749 * 3750 * @see #GET_META_DATA 3751 * @see #GET_RESOLVED_FILTER 3752 * @see #GET_SHARED_LIBRARY_FILES 3753 * @see #MATCH_ALL 3754 * @see #MATCH_DISABLED_COMPONENTS 3755 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3756 * @see #MATCH_DEFAULT_ONLY 3757 * @see #MATCH_ENCRYPTION_AWARE 3758 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3759 * @see #MATCH_ENCRYPTION_UNAWARE 3760 * @see #MATCH_SYSTEM_ONLY 3761 * @see #MATCH_UNINSTALLED_PACKAGES 3762 * 3763 * @hide 3764 */ 3765 @SystemApi 3766 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 3767 @ResolveInfoFlags int flags, UserHandle userHandle) { 3768 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 3769 } 3770 3771 /** 3772 * @hide 3773 */ 3774 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 3775 @ResolveInfoFlags int flags, @UserIdInt int userId); 3776 3777 3778 /** {@hide} */ 3779 @Deprecated 3780 public List<ResolveInfo> queryBroadcastReceivers(Intent intent, 3781 @ResolveInfoFlags int flags, @UserIdInt int userId) { 3782 Log.w(TAG, "STAHP USING HIDDEN APIS KTHX"); 3783 return queryBroadcastReceiversAsUser(intent, flags, userId); 3784 } 3785 3786 /** 3787 * Determine the best service to handle for a given Intent. 3788 * 3789 * @param intent An intent containing all of the desired specification 3790 * (action, data, type, category, and/or component). 3791 * @param flags Additional option flags. Use any combination of 3792 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3793 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3794 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3795 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3796 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3797 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3798 * to modify the data returned. 3799 * 3800 * @return Returns a ResolveInfo object containing the final service intent 3801 * that was determined to be the best action. Returns null if no 3802 * matching service was found. 3803 * 3804 * @see #GET_META_DATA 3805 * @see #GET_RESOLVED_FILTER 3806 * @see #GET_SHARED_LIBRARY_FILES 3807 * @see #MATCH_ALL 3808 * @see #MATCH_DISABLED_COMPONENTS 3809 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3810 * @see #MATCH_DEFAULT_ONLY 3811 * @see #MATCH_ENCRYPTION_AWARE 3812 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3813 * @see #MATCH_ENCRYPTION_UNAWARE 3814 * @see #MATCH_SYSTEM_ONLY 3815 * @see #MATCH_UNINSTALLED_PACKAGES 3816 */ 3817 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags); 3818 3819 /** 3820 * Retrieve all services that can match the given intent. 3821 * 3822 * @param intent The desired intent as per resolveService(). 3823 * @param flags Additional option flags. Use any combination of 3824 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3825 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3826 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3827 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3828 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3829 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3830 * to modify the data returned. 3831 * 3832 * @return Returns a List of ResolveInfo objects containing one entry for each 3833 * matching service, ordered from best to worst. In other words, the first 3834 * item is what would be returned by {@link #resolveService}. If there are 3835 * no matching services, an empty list or null is returned. 3836 * 3837 * @see #GET_META_DATA 3838 * @see #GET_RESOLVED_FILTER 3839 * @see #GET_SHARED_LIBRARY_FILES 3840 * @see #MATCH_ALL 3841 * @see #MATCH_DISABLED_COMPONENTS 3842 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3843 * @see #MATCH_DEFAULT_ONLY 3844 * @see #MATCH_ENCRYPTION_AWARE 3845 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3846 * @see #MATCH_ENCRYPTION_UNAWARE 3847 * @see #MATCH_SYSTEM_ONLY 3848 * @see #MATCH_UNINSTALLED_PACKAGES 3849 */ 3850 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 3851 @ResolveInfoFlags int flags); 3852 3853 /** 3854 * Retrieve all services that can match the given intent for a given user. 3855 * 3856 * @param intent The desired intent as per resolveService(). 3857 * @param flags Additional option flags. Use any combination of 3858 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3859 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3860 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3861 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3862 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3863 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3864 * to modify the data returned. 3865 * @param userId The user id. 3866 * 3867 * @return Returns a List of ResolveInfo objects containing one entry for each 3868 * matching service, ordered from best to worst. In other words, the first 3869 * item is what would be returned by {@link #resolveService}. If there are 3870 * no matching services, an empty list or null is returned. 3871 * 3872 * @see #GET_META_DATA 3873 * @see #GET_RESOLVED_FILTER 3874 * @see #GET_SHARED_LIBRARY_FILES 3875 * @see #MATCH_ALL 3876 * @see #MATCH_DISABLED_COMPONENTS 3877 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3878 * @see #MATCH_DEFAULT_ONLY 3879 * @see #MATCH_ENCRYPTION_AWARE 3880 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3881 * @see #MATCH_ENCRYPTION_UNAWARE 3882 * @see #MATCH_SYSTEM_ONLY 3883 * @see #MATCH_UNINSTALLED_PACKAGES 3884 * 3885 * @hide 3886 */ 3887 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 3888 @ResolveInfoFlags int flags, @UserIdInt int userId); 3889 3890 /** 3891 * Retrieve all providers that can match the given intent. 3892 * 3893 * @param intent An intent containing all of the desired specification 3894 * (action, data, type, category, and/or component). 3895 * @param flags Additional option flags. Use any combination of 3896 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3897 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3898 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3899 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3900 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3901 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3902 * to modify the data returned. 3903 * @param userId The user id. 3904 * 3905 * @return Returns a List of ResolveInfo objects containing one entry for each 3906 * matching provider, ordered from best to worst. If there are no 3907 * matching services, an empty list or null is returned. 3908 * 3909 * @see #GET_META_DATA 3910 * @see #GET_RESOLVED_FILTER 3911 * @see #GET_SHARED_LIBRARY_FILES 3912 * @see #MATCH_ALL 3913 * @see #MATCH_DISABLED_COMPONENTS 3914 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3915 * @see #MATCH_DEFAULT_ONLY 3916 * @see #MATCH_ENCRYPTION_AWARE 3917 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3918 * @see #MATCH_ENCRYPTION_UNAWARE 3919 * @see #MATCH_SYSTEM_ONLY 3920 * @see #MATCH_UNINSTALLED_PACKAGES 3921 * 3922 * @hide 3923 */ 3924 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 3925 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId); 3926 3927 /** 3928 * Retrieve all providers that can match the given intent. 3929 * 3930 * @param intent An intent containing all of the desired specification 3931 * (action, data, type, category, and/or component). 3932 * @param flags Additional option flags. Use any combination of 3933 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3934 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3935 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3936 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE}, 3937 * {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE}, 3938 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3939 * to modify the data returned. 3940 * 3941 * @return Returns a List of ResolveInfo objects containing one entry for each 3942 * matching provider, ordered from best to worst. If there are no 3943 * matching services, an empty list or null is returned. 3944 * 3945 * @see #GET_META_DATA 3946 * @see #GET_RESOLVED_FILTER 3947 * @see #GET_SHARED_LIBRARY_FILES 3948 * @see #MATCH_ALL 3949 * @see #MATCH_DISABLED_COMPONENTS 3950 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3951 * @see #MATCH_DEFAULT_ONLY 3952 * @see #MATCH_ENCRYPTION_AWARE 3953 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3954 * @see #MATCH_ENCRYPTION_UNAWARE 3955 * @see #MATCH_SYSTEM_ONLY 3956 * @see #MATCH_UNINSTALLED_PACKAGES 3957 */ 3958 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, 3959 @ResolveInfoFlags int flags); 3960 3961 /** 3962 * Find a single content provider by its base path name. 3963 * 3964 * @param name The name of the provider to find. 3965 * @param flags Additional option flags. Use any combination of 3966 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3967 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3968 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3969 * {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, 3970 * {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3971 * {@link #MATCH_UNINSTALLED_PACKAGES} 3972 * to modify the data returned. 3973 * 3974 * @return A {@link ProviderInfo} object containing information about the provider. 3975 * If a provider was not found, returns null. 3976 * 3977 * @see #GET_META_DATA 3978 * @see #GET_SHARED_LIBRARY_FILES 3979 * @see #MATCH_ALL 3980 * @see #MATCH_DEBUG_TRIAGED_MISSING 3981 * @see #MATCH_DEFAULT_ONLY 3982 * @see #MATCH_DISABLED_COMPONENTS 3983 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3984 * @see #MATCH_ENCRYPTION_AWARE 3985 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 3986 * @see #MATCH_ENCRYPTION_UNAWARE 3987 * @see #MATCH_SYSTEM_ONLY 3988 * @see #MATCH_UNINSTALLED_PACKAGES 3989 */ 3990 public abstract ProviderInfo resolveContentProvider(String name, 3991 @ComponentInfoFlags int flags); 3992 3993 /** 3994 * Find a single content provider by its base path name. 3995 * 3996 * @param name The name of the provider to find. 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 * @param userId The user id. 4006 * 4007 * @return A {@link ProviderInfo} object containing information about the provider. 4008 * If a provider was not found, returns null. 4009 * 4010 * @see #GET_META_DATA 4011 * @see #GET_SHARED_LIBRARY_FILES 4012 * @see #MATCH_ALL 4013 * @see #MATCH_DEBUG_TRIAGED_MISSING 4014 * @see #MATCH_DEFAULT_ONLY 4015 * @see #MATCH_DISABLED_COMPONENTS 4016 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4017 * @see #MATCH_ENCRYPTION_AWARE 4018 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 4019 * @see #MATCH_ENCRYPTION_UNAWARE 4020 * @see #MATCH_SYSTEM_ONLY 4021 * @see #MATCH_UNINSTALLED_PACKAGES 4022 * 4023 * @hide 4024 */ 4025 public abstract ProviderInfo resolveContentProviderAsUser(String name, 4026 @ComponentInfoFlags int flags, @UserIdInt int userId); 4027 4028 /** 4029 * Retrieve content provider information. 4030 * 4031 * <p><em>Note: unlike most other methods, an empty result set is indicated 4032 * by a null return instead of an empty list.</em> 4033 * 4034 * @param processName If non-null, limits the returned providers to only 4035 * those that are hosted by the given process. If null, 4036 * all content providers are returned. 4037 * @param uid If <var>processName</var> is non-null, this is the required 4038 * uid owning the requested content providers. 4039 * @param flags Additional option flags. Use any combination of 4040 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4041 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4042 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4043 * {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, 4044 * {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4045 * {@link #MATCH_UNINSTALLED_PACKAGES} 4046 * to modify the data returned. 4047 * 4048 * @return A list of {@link ProviderInfo} objects containing one entry for 4049 * each provider either matching <var>processName</var> or, if 4050 * <var>processName</var> is null, all known content providers. 4051 * <em>If there are no matching providers, null is returned.</em> 4052 * 4053 * @see #GET_META_DATA 4054 * @see #GET_SHARED_LIBRARY_FILES 4055 * @see #MATCH_ALL 4056 * @see #MATCH_DEBUG_TRIAGED_MISSING 4057 * @see #MATCH_DEFAULT_ONLY 4058 * @see #MATCH_DISABLED_COMPONENTS 4059 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4060 * @see #MATCH_ENCRYPTION_AWARE 4061 * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE 4062 * @see #MATCH_ENCRYPTION_UNAWARE 4063 * @see #MATCH_SYSTEM_ONLY 4064 * @see #MATCH_UNINSTALLED_PACKAGES 4065 */ 4066 public abstract List<ProviderInfo> queryContentProviders( 4067 String processName, int uid, @ComponentInfoFlags int flags); 4068 4069 /** 4070 * Retrieve all of the information we know about a particular 4071 * instrumentation class. 4072 * 4073 * @param className The full name (i.e. 4074 * com.google.apps.contacts.InstrumentList) of an 4075 * Instrumentation class. 4076 * @param flags Additional option flags. Use any combination of 4077 * {@link #GET_META_DATA} 4078 * to modify the data returned. 4079 * 4080 * @return An {@link InstrumentationInfo} object containing information about the 4081 * instrumentation. 4082 * @throws NameNotFoundException if a package with the given name cannot be 4083 * found on the system. 4084 * 4085 * @see #GET_META_DATA 4086 */ 4087 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className, 4088 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 4089 4090 /** 4091 * Retrieve information about available instrumentation code. May be used 4092 * to retrieve either all instrumentation code, or only the code targeting 4093 * a particular package. 4094 * 4095 * @param targetPackage If null, all instrumentation is returned; only the 4096 * instrumentation targeting this package name is 4097 * returned. 4098 * @param flags Additional option flags. Use any combination of 4099 * {@link #GET_META_DATA} 4100 * to modify the data returned. 4101 * 4102 * @return A list of {@link InstrumentationInfo} objects containing one 4103 * entry for each matching instrumentation. If there are no 4104 * instrumentation available, returns an empty list. 4105 * 4106 * @see #GET_META_DATA 4107 */ 4108 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage, 4109 @InstrumentationInfoFlags int flags); 4110 4111 /** 4112 * Retrieve an image from a package. This is a low-level API used by 4113 * the various package manager info structures (such as 4114 * {@link ComponentInfo} to implement retrieval of their associated 4115 * icon. 4116 * 4117 * @param packageName The name of the package that this icon is coming from. 4118 * Cannot be null. 4119 * @param resid The resource identifier of the desired image. Cannot be 0. 4120 * @param appInfo Overall information about <var>packageName</var>. This 4121 * may be null, in which case the application information will be retrieved 4122 * for you if needed; if you already have this information around, it can 4123 * be much more efficient to supply it here. 4124 * 4125 * @return Returns a Drawable holding the requested image. Returns null if 4126 * an image could not be found for any reason. 4127 */ 4128 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 4129 ApplicationInfo appInfo); 4130 4131 /** 4132 * Retrieve the icon associated with an activity. Given the full name of 4133 * an activity, retrieves the information about it and calls 4134 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 4135 * If the activity cannot be found, NameNotFoundException is thrown. 4136 * 4137 * @param activityName Name of the activity whose icon is to be retrieved. 4138 * 4139 * @return Returns the image of the icon, or the default activity icon if 4140 * it could not be found. Does not return null. 4141 * @throws NameNotFoundException Thrown if the resources for the given 4142 * activity could not be loaded. 4143 * 4144 * @see #getActivityIcon(Intent) 4145 */ 4146 public abstract Drawable getActivityIcon(ComponentName activityName) 4147 throws NameNotFoundException; 4148 4149 /** 4150 * Retrieve the icon associated with an Intent. If intent.getClassName() is 4151 * set, this simply returns the result of 4152 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 4153 * component and returns the icon associated with the resolved component. 4154 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4155 * to a component, NameNotFoundException is thrown. 4156 * 4157 * @param intent The intent for which you would like to retrieve an icon. 4158 * 4159 * @return Returns the image of the icon, or the default activity icon if 4160 * it could not be found. Does not return null. 4161 * @throws NameNotFoundException Thrown if the resources for application 4162 * matching the given intent could not be loaded. 4163 * 4164 * @see #getActivityIcon(ComponentName) 4165 */ 4166 public abstract Drawable getActivityIcon(Intent intent) 4167 throws NameNotFoundException; 4168 4169 /** 4170 * Retrieve the banner associated with an activity. Given the full name of 4171 * an activity, retrieves the information about it and calls 4172 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 4173 * banner. If the activity cannot be found, NameNotFoundException is thrown. 4174 * 4175 * @param activityName Name of the activity whose banner is to be retrieved. 4176 * @return Returns the image of the banner, or null if the activity has no 4177 * banner specified. 4178 * @throws NameNotFoundException Thrown if the resources for the given 4179 * activity could not be loaded. 4180 * @see #getActivityBanner(Intent) 4181 */ 4182 public abstract Drawable getActivityBanner(ComponentName activityName) 4183 throws NameNotFoundException; 4184 4185 /** 4186 * Retrieve the banner associated with an Intent. If intent.getClassName() 4187 * is set, this simply returns the result of 4188 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 4189 * intent's component and returns the banner associated with the resolved 4190 * component. If intent.getClassName() cannot be found or the Intent cannot 4191 * be resolved to a component, NameNotFoundException is thrown. 4192 * 4193 * @param intent The intent for which you would like to retrieve a banner. 4194 * @return Returns the image of the banner, or null if the activity has no 4195 * banner specified. 4196 * @throws NameNotFoundException Thrown if the resources for application 4197 * matching the given intent could not be loaded. 4198 * @see #getActivityBanner(ComponentName) 4199 */ 4200 public abstract Drawable getActivityBanner(Intent intent) 4201 throws NameNotFoundException; 4202 4203 /** 4204 * Return the generic icon for an activity that is used when no specific 4205 * icon is defined. 4206 * 4207 * @return Drawable Image of the icon. 4208 */ 4209 public abstract Drawable getDefaultActivityIcon(); 4210 4211 /** 4212 * Retrieve the icon associated with an application. If it has not defined 4213 * an icon, the default app icon is returned. Does not return null. 4214 * 4215 * @param info Information about application being queried. 4216 * 4217 * @return Returns the image of the icon, or the default application icon 4218 * if it could not be found. 4219 * 4220 * @see #getApplicationIcon(String) 4221 */ 4222 public abstract Drawable getApplicationIcon(ApplicationInfo info); 4223 4224 /** 4225 * Retrieve the icon associated with an application. Given the name of the 4226 * application's package, retrieves the information about it and calls 4227 * getApplicationIcon() to return its icon. If the application cannot be 4228 * found, NameNotFoundException is thrown. 4229 * 4230 * @param packageName Name of the package whose application icon is to be 4231 * retrieved. 4232 * 4233 * @return Returns the image of the icon, or the default application icon 4234 * if it could not be found. Does not return null. 4235 * @throws NameNotFoundException Thrown if the resources for the given 4236 * application could not be loaded. 4237 * 4238 * @see #getApplicationIcon(ApplicationInfo) 4239 */ 4240 public abstract Drawable getApplicationIcon(String packageName) 4241 throws NameNotFoundException; 4242 4243 /** 4244 * Retrieve the banner associated with an application. 4245 * 4246 * @param info Information about application being queried. 4247 * @return Returns the image of the banner or null if the application has no 4248 * banner specified. 4249 * @see #getApplicationBanner(String) 4250 */ 4251 public abstract Drawable getApplicationBanner(ApplicationInfo info); 4252 4253 /** 4254 * Retrieve the banner associated with an application. Given the name of the 4255 * application's package, retrieves the information about it and calls 4256 * getApplicationIcon() to return its banner. If the application cannot be 4257 * found, NameNotFoundException is thrown. 4258 * 4259 * @param packageName Name of the package whose application banner is to be 4260 * retrieved. 4261 * @return Returns the image of the banner or null if the application has no 4262 * banner specified. 4263 * @throws NameNotFoundException Thrown if the resources for the given 4264 * application could not be loaded. 4265 * @see #getApplicationBanner(ApplicationInfo) 4266 */ 4267 public abstract Drawable getApplicationBanner(String packageName) 4268 throws NameNotFoundException; 4269 4270 /** 4271 * Retrieve the logo associated with an activity. Given the full name of an 4272 * activity, retrieves the information about it and calls 4273 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 4274 * logo. If the activity cannot be found, NameNotFoundException is thrown. 4275 * 4276 * @param activityName Name of the activity whose logo is to be retrieved. 4277 * @return Returns the image of the logo or null if the activity has no logo 4278 * specified. 4279 * @throws NameNotFoundException Thrown if the resources for the given 4280 * activity could not be loaded. 4281 * @see #getActivityLogo(Intent) 4282 */ 4283 public abstract Drawable getActivityLogo(ComponentName activityName) 4284 throws NameNotFoundException; 4285 4286 /** 4287 * Retrieve the logo associated with an Intent. If intent.getClassName() is 4288 * set, this simply returns the result of 4289 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 4290 * component and returns the logo associated with the resolved component. 4291 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4292 * to a component, NameNotFoundException is thrown. 4293 * 4294 * @param intent The intent for which you would like to retrieve a logo. 4295 * 4296 * @return Returns the image of the logo, or null if the activity has no 4297 * logo specified. 4298 * 4299 * @throws NameNotFoundException Thrown if the resources for application 4300 * matching the given intent could not be loaded. 4301 * 4302 * @see #getActivityLogo(ComponentName) 4303 */ 4304 public abstract Drawable getActivityLogo(Intent intent) 4305 throws NameNotFoundException; 4306 4307 /** 4308 * Retrieve the logo associated with an application. If it has not specified 4309 * a logo, this method returns null. 4310 * 4311 * @param info Information about application being queried. 4312 * 4313 * @return Returns the image of the logo, or null if no logo is specified 4314 * by the application. 4315 * 4316 * @see #getApplicationLogo(String) 4317 */ 4318 public abstract Drawable getApplicationLogo(ApplicationInfo info); 4319 4320 /** 4321 * Retrieve the logo associated with an application. Given the name of the 4322 * application's package, retrieves the information about it and calls 4323 * getApplicationLogo() to return its logo. If the application cannot be 4324 * found, NameNotFoundException is thrown. 4325 * 4326 * @param packageName Name of the package whose application logo is to be 4327 * retrieved. 4328 * 4329 * @return Returns the image of the logo, or null if no application logo 4330 * has been specified. 4331 * 4332 * @throws NameNotFoundException Thrown if the resources for the given 4333 * application could not be loaded. 4334 * 4335 * @see #getApplicationLogo(ApplicationInfo) 4336 */ 4337 public abstract Drawable getApplicationLogo(String packageName) 4338 throws NameNotFoundException; 4339 4340 /** 4341 * If the target user is a managed profile of the calling user or if the 4342 * target user is the caller and is itself a managed profile, then this 4343 * returns a badged copy of the given icon to be able to distinguish it from 4344 * the original icon. For badging an arbitrary drawable use 4345 * {@link #getUserBadgedDrawableForDensity( 4346 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 4347 * <p> 4348 * If the original drawable is a BitmapDrawable and the backing bitmap is 4349 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4350 * is performed in place and the original drawable is returned. 4351 * </p> 4352 * 4353 * @param icon The icon to badge. 4354 * @param user The target user. 4355 * @return A drawable that combines the original icon and a badge as 4356 * determined by the system. 4357 */ 4358 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 4359 4360 /** 4361 * If the target user is a managed profile of the calling user or the caller 4362 * is itself a managed profile, then this returns a badged copy of the given 4363 * drawable allowing the user to distinguish it from the original drawable. 4364 * The caller can specify the location in the bounds of the drawable to be 4365 * badged where the badge should be applied as well as the density of the 4366 * badge to be used. 4367 * <p> 4368 * If the original drawable is a BitmapDrawable and the backing bitmap is 4369 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading 4370 * is performed in place and the original drawable is returned. 4371 * </p> 4372 * 4373 * @param drawable The drawable to badge. 4374 * @param user The target user. 4375 * @param badgeLocation Where in the bounds of the badged drawable to place 4376 * the badge. If not provided, the badge is applied on top of the entire 4377 * drawable being badged. 4378 * @param badgeDensity The optional desired density for the badge as per 4379 * {@link android.util.DisplayMetrics#densityDpi}. If not provided, 4380 * the density of the display is used. 4381 * @return A drawable that combines the original drawable and a badge as 4382 * determined by the system. 4383 */ 4384 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 4385 UserHandle user, Rect badgeLocation, int badgeDensity); 4386 4387 /** 4388 * If the target user is a managed profile of the calling user or the caller 4389 * is itself a managed profile, then this returns a drawable to use as a small 4390 * icon to include in a view to distinguish it from the original icon. 4391 * 4392 * @param user The target user. 4393 * @param density The optional desired density for the badge as per 4394 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4395 * the density of the current display is used. 4396 * @return the drawable or null if no drawable is required. 4397 * @hide 4398 */ 4399 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 4400 4401 /** 4402 * If the target user is a managed profile of the calling user or the caller 4403 * is itself a managed profile, then this returns a drawable to use as a small 4404 * icon to include in a view to distinguish it from the original icon. This version 4405 * doesn't have background protection and should be used over a light background instead of 4406 * a badge. 4407 * 4408 * @param user The target user. 4409 * @param density The optional desired density for the badge as per 4410 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4411 * the density of the current display is used. 4412 * @return the drawable or null if no drawable is required. 4413 * @hide 4414 */ 4415 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density); 4416 4417 /** 4418 * If the target user is a managed profile of the calling user or the caller 4419 * is itself a managed profile, then this returns a copy of the label with 4420 * badging for accessibility services like talkback. E.g. passing in "Email" 4421 * and it might return "Work Email" for Email in the work profile. 4422 * 4423 * @param label The label to change. 4424 * @param user The target user. 4425 * @return A label that combines the original label and a badge as 4426 * determined by the system. 4427 */ 4428 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 4429 4430 /** 4431 * Retrieve text from a package. This is a low-level API used by 4432 * the various package manager info structures (such as 4433 * {@link ComponentInfo} to implement retrieval of their associated 4434 * labels and other text. 4435 * 4436 * @param packageName The name of the package that this text is coming from. 4437 * Cannot be null. 4438 * @param resid The resource identifier of the desired text. Cannot be 0. 4439 * @param appInfo Overall information about <var>packageName</var>. This 4440 * may be null, in which case the application information will be retrieved 4441 * for you if needed; if you already have this information around, it can 4442 * be much more efficient to supply it here. 4443 * 4444 * @return Returns a CharSequence holding the requested text. Returns null 4445 * if the text could not be found for any reason. 4446 */ 4447 public abstract CharSequence getText(String packageName, @StringRes int resid, 4448 ApplicationInfo appInfo); 4449 4450 /** 4451 * Retrieve an XML file from a package. This is a low-level API used to 4452 * retrieve XML meta data. 4453 * 4454 * @param packageName The name of the package that this xml is coming from. 4455 * Cannot be null. 4456 * @param resid The resource identifier of the desired xml. Cannot be 0. 4457 * @param appInfo Overall information about <var>packageName</var>. This 4458 * may be null, in which case the application information will be retrieved 4459 * for you if needed; if you already have this information around, it can 4460 * be much more efficient to supply it here. 4461 * 4462 * @return Returns an XmlPullParser allowing you to parse out the XML 4463 * data. Returns null if the xml resource could not be found for any 4464 * reason. 4465 */ 4466 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 4467 ApplicationInfo appInfo); 4468 4469 /** 4470 * Return the label to use for this application. 4471 * 4472 * @return Returns the label associated with this application, or null if 4473 * it could not be found for any reason. 4474 * @param info The application to get the label of. 4475 */ 4476 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 4477 4478 /** 4479 * Retrieve the resources associated with an activity. Given the full 4480 * name of an activity, retrieves the information about it and calls 4481 * getResources() to return its application's resources. If the activity 4482 * cannot be found, NameNotFoundException is thrown. 4483 * 4484 * @param activityName Name of the activity whose resources are to be 4485 * retrieved. 4486 * 4487 * @return Returns the application's Resources. 4488 * @throws NameNotFoundException Thrown if the resources for the given 4489 * application could not be loaded. 4490 * 4491 * @see #getResourcesForApplication(ApplicationInfo) 4492 */ 4493 public abstract Resources getResourcesForActivity(ComponentName activityName) 4494 throws NameNotFoundException; 4495 4496 /** 4497 * Retrieve the resources for an application. Throws NameNotFoundException 4498 * if the package is no longer installed. 4499 * 4500 * @param app Information about the desired application. 4501 * 4502 * @return Returns the application's Resources. 4503 * @throws NameNotFoundException Thrown if the resources for the given 4504 * application could not be loaded (most likely because it was uninstalled). 4505 */ 4506 public abstract Resources getResourcesForApplication(ApplicationInfo app) 4507 throws NameNotFoundException; 4508 4509 /** 4510 * Retrieve the resources associated with an application. Given the full 4511 * package name of an application, retrieves the information about it and 4512 * calls getResources() to return its application's resources. If the 4513 * appPackageName cannot be found, NameNotFoundException is thrown. 4514 * 4515 * @param appPackageName Package name of the application whose resources 4516 * are to be retrieved. 4517 * 4518 * @return Returns the application's Resources. 4519 * @throws NameNotFoundException Thrown if the resources for the given 4520 * application could not be loaded. 4521 * 4522 * @see #getResourcesForApplication(ApplicationInfo) 4523 */ 4524 public abstract Resources getResourcesForApplication(String appPackageName) 4525 throws NameNotFoundException; 4526 4527 /** @hide */ 4528 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, 4529 @UserIdInt int userId) throws NameNotFoundException; 4530 4531 /** 4532 * Retrieve overall information about an application package defined 4533 * in a package archive file 4534 * 4535 * @param archiveFilePath The path to the archive file 4536 * @param flags Additional option flags. Use any combination of 4537 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 4538 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 4539 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 4540 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 4541 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 4542 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 4543 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 4544 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4545 * {@link #MATCH_UNINSTALLED_PACKAGES} 4546 * to modify the data returned. 4547 * 4548 * @return A PackageInfo object containing information about the 4549 * package archive. If the package could not be parsed, 4550 * returns null. 4551 * 4552 * @see #GET_ACTIVITIES 4553 * @see #GET_CONFIGURATIONS 4554 * @see #GET_GIDS 4555 * @see #GET_INSTRUMENTATION 4556 * @see #GET_INTENT_FILTERS 4557 * @see #GET_META_DATA 4558 * @see #GET_PERMISSIONS 4559 * @see #GET_PROVIDERS 4560 * @see #GET_RECEIVERS 4561 * @see #GET_SERVICES 4562 * @see #GET_SHARED_LIBRARY_FILES 4563 * @see #GET_SIGNATURES 4564 * @see #GET_URI_PERMISSION_PATTERNS 4565 * @see #MATCH_DISABLED_COMPONENTS 4566 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4567 * @see #MATCH_UNINSTALLED_PACKAGES 4568 * 4569 */ 4570 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) { 4571 final PackageParser parser = new PackageParser(); 4572 final File apkFile = new File(archiveFilePath); 4573 try { 4574 if ((flags & (MATCH_ENCRYPTION_UNAWARE | MATCH_ENCRYPTION_AWARE)) != 0) { 4575 // Caller expressed an explicit opinion about what encryption 4576 // aware/unaware components they want to see, so fall through and 4577 // give them what they want 4578 } else { 4579 // Caller expressed no opinion, so match everything 4580 flags |= MATCH_ENCRYPTION_AWARE_AND_UNAWARE; 4581 } 4582 4583 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 4584 if ((flags & GET_SIGNATURES) != 0) { 4585 PackageParser.collectCertificates(pkg, 0); 4586 } 4587 PackageUserState state = new PackageUserState(); 4588 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 4589 } catch (PackageParserException e) { 4590 return null; 4591 } 4592 } 4593 4594 /** 4595 * @deprecated replaced by {@link PackageInstaller} 4596 * @hide 4597 */ 4598 @Deprecated 4599 public abstract void installPackage( 4600 Uri packageURI, IPackageInstallObserver observer, @InstallFlags int flags, 4601 String installerPackageName); 4602 4603 /** 4604 * @deprecated replaced by {@link PackageInstaller} 4605 * @hide 4606 */ 4607 @Deprecated 4608 public abstract void installPackageWithVerification(Uri packageURI, 4609 IPackageInstallObserver observer, @InstallFlags int flags, String installerPackageName, 4610 Uri verificationURI, ContainerEncryptionParams encryptionParams); 4611 4612 /** 4613 * @deprecated replaced by {@link PackageInstaller} 4614 * @hide 4615 */ 4616 @Deprecated 4617 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 4618 IPackageInstallObserver observer, @InstallFlags int flags, String installerPackageName, 4619 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams); 4620 4621 /** 4622 * @deprecated replaced by {@link PackageInstaller} 4623 * @hide 4624 */ 4625 @Deprecated 4626 public abstract void installPackage(Uri packageURI, PackageInstallObserver observer, 4627 @InstallFlags int flags, String installerPackageName); 4628 4629 /** 4630 * @deprecated replaced by {@link PackageInstaller} 4631 * @hide 4632 */ 4633 @Deprecated 4634 public abstract void installPackageAsUser(Uri packageURI, PackageInstallObserver observer, 4635 @InstallFlags int flags, String installerPackageName, @UserIdInt int userId); 4636 4637 /** 4638 * @deprecated replaced by {@link PackageInstaller} 4639 * @hide 4640 */ 4641 @Deprecated 4642 public abstract void installPackageWithVerification(Uri packageURI, 4643 PackageInstallObserver observer, @InstallFlags int flags, String installerPackageName, 4644 Uri verificationURI, ContainerEncryptionParams encryptionParams); 4645 4646 /** 4647 * @deprecated replaced by {@link PackageInstaller} 4648 * @hide 4649 */ 4650 @Deprecated 4651 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 4652 PackageInstallObserver observer, @InstallFlags int flags, String installerPackageName, 4653 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams); 4654 4655 /** 4656 * If there is already an application with the given package name installed 4657 * on the system for other users, also install it for the calling user. 4658 * @hide 4659 */ 4660 public abstract int installExistingPackage(String packageName) throws NameNotFoundException; 4661 4662 /** 4663 * If there is already an application with the given package name installed 4664 * on the system for other users, also install it for the specified user. 4665 * @hide 4666 */ 4667 @RequiresPermission(anyOf = { 4668 Manifest.permission.INSTALL_PACKAGES, 4669 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4670 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId) 4671 throws NameNotFoundException; 4672 4673 /** 4674 * Allows a package listening to the 4675 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4676 * broadcast} to respond to the package manager. The response must include 4677 * the {@code verificationCode} which is one of 4678 * {@link PackageManager#VERIFICATION_ALLOW} or 4679 * {@link PackageManager#VERIFICATION_REJECT}. 4680 * 4681 * @param id pending package identifier as passed via the 4682 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4683 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 4684 * or {@link PackageManager#VERIFICATION_REJECT}. 4685 * @throws SecurityException if the caller does not have the 4686 * PACKAGE_VERIFICATION_AGENT permission. 4687 */ 4688 public abstract void verifyPendingInstall(int id, int verificationCode); 4689 4690 /** 4691 * Allows a package listening to the 4692 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4693 * broadcast} to extend the default timeout for a response and declare what 4694 * action to perform after the timeout occurs. The response must include 4695 * the {@code verificationCodeAtTimeout} which is one of 4696 * {@link PackageManager#VERIFICATION_ALLOW} or 4697 * {@link PackageManager#VERIFICATION_REJECT}. 4698 * 4699 * This method may only be called once per package id. Additional calls 4700 * will have no effect. 4701 * 4702 * @param id pending package identifier as passed via the 4703 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4704 * @param verificationCodeAtTimeout either 4705 * {@link PackageManager#VERIFICATION_ALLOW} or 4706 * {@link PackageManager#VERIFICATION_REJECT}. If 4707 * {@code verificationCodeAtTimeout} is neither 4708 * {@link PackageManager#VERIFICATION_ALLOW} or 4709 * {@link PackageManager#VERIFICATION_REJECT}, then 4710 * {@code verificationCodeAtTimeout} will default to 4711 * {@link PackageManager#VERIFICATION_REJECT}. 4712 * @param millisecondsToDelay the amount of time requested for the timeout. 4713 * Must be positive and less than 4714 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 4715 * {@code millisecondsToDelay} is out of bounds, 4716 * {@code millisecondsToDelay} will be set to the closest in 4717 * bounds value; namely, 0 or 4718 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 4719 * @throws SecurityException if the caller does not have the 4720 * PACKAGE_VERIFICATION_AGENT permission. 4721 */ 4722 public abstract void extendVerificationTimeout(int id, 4723 int verificationCodeAtTimeout, long millisecondsToDelay); 4724 4725 /** 4726 * Allows a package listening to the 4727 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification 4728 * broadcast} to respond to the package manager. The response must include 4729 * the {@code verificationCode} which is one of 4730 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 4731 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4732 * 4733 * @param verificationId pending package identifier as passed via the 4734 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4735 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 4736 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4737 * @param outFailedDomains a list of failed domains if the verificationCode is 4738 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 4739 * @throws SecurityException if the caller does not have the 4740 * INTENT_FILTER_VERIFICATION_AGENT permission. 4741 * 4742 * @hide 4743 */ 4744 @SystemApi 4745 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 4746 List<String> outFailedDomains); 4747 4748 /** 4749 * Get the status of a Domain Verification Result for an IntentFilter. This is 4750 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4751 * {@link android.content.IntentFilter#getAutoVerify()} 4752 * 4753 * This is used by the ResolverActivity to change the status depending on what the User select 4754 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4755 * for a domain. 4756 * 4757 * @param packageName The package name of the Activity associated with the IntentFilter. 4758 * @param userId The user id. 4759 * 4760 * @return The status to set to. This can be 4761 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4762 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4763 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 4764 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 4765 * 4766 * @hide 4767 */ 4768 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId); 4769 4770 /** 4771 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 4772 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4773 * {@link android.content.IntentFilter#getAutoVerify()} 4774 * 4775 * This is used by the ResolverActivity to change the status depending on what the User select 4776 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4777 * for a domain. 4778 * 4779 * @param packageName The package name of the Activity associated with the IntentFilter. 4780 * @param status The status to set to. This can be 4781 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4782 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4783 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 4784 * @param userId The user id. 4785 * 4786 * @return true if the status has been set. False otherwise. 4787 * 4788 * @hide 4789 */ 4790 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status, 4791 @UserIdInt int userId); 4792 4793 /** 4794 * Get the list of IntentFilterVerificationInfo for a specific package and User. 4795 * 4796 * @param packageName the package name. When this parameter is set to a non null value, 4797 * the results will be filtered by the package name provided. 4798 * Otherwise, there will be no filtering and it will return a list 4799 * corresponding for all packages 4800 * 4801 * @return a list of IntentFilterVerificationInfo for a specific package. 4802 * 4803 * @hide 4804 */ 4805 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 4806 String packageName); 4807 4808 /** 4809 * Get the list of IntentFilter for a specific package. 4810 * 4811 * @param packageName the package name. This parameter is set to a non null value, 4812 * the list will contain all the IntentFilter for that package. 4813 * Otherwise, the list will be empty. 4814 * 4815 * @return a list of IntentFilter for a specific package. 4816 * 4817 * @hide 4818 */ 4819 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 4820 4821 /** 4822 * Get the default Browser package name for a specific user. 4823 * 4824 * @param userId The user id. 4825 * 4826 * @return the package name of the default Browser for the specified user. If the user id passed 4827 * is -1 (all users) it will return a null value. 4828 * 4829 * @hide 4830 */ 4831 @TestApi 4832 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId); 4833 4834 /** 4835 * Set the default Browser package name for a specific user. 4836 * 4837 * @param packageName The package name of the default Browser. 4838 * @param userId The user id. 4839 * 4840 * @return true if the default Browser for the specified user has been set, 4841 * otherwise return false. If the user id passed is -1 (all users) this call will not 4842 * do anything and just return false. 4843 * 4844 * @hide 4845 */ 4846 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName, 4847 @UserIdInt int userId); 4848 4849 /** 4850 * Change the installer associated with a given package. There are limitations 4851 * on how the installer package can be changed; in particular: 4852 * <ul> 4853 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 4854 * is not signed with the same certificate as the calling application. 4855 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 4856 * has an installer package, and that installer package is not signed with 4857 * the same certificate as the calling application. 4858 * </ul> 4859 * 4860 * @param targetPackage The installed package whose installer will be changed. 4861 * @param installerPackageName The package name of the new installer. May be 4862 * null to clear the association. 4863 */ 4864 public abstract void setInstallerPackageName(String targetPackage, 4865 String installerPackageName); 4866 4867 /** 4868 * Attempts to delete a package. Since this may take a little while, the 4869 * result will be posted back to the given observer. A deletion will fail if 4870 * the calling context lacks the 4871 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 4872 * named package cannot be found, or if the named package is a system 4873 * package. 4874 * 4875 * @param packageName The name of the package to delete 4876 * @param observer An observer callback to get notified when the package 4877 * deletion is complete. 4878 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 4879 * will be called when that happens. observer may be null to 4880 * indicate that no callback is desired. 4881 * @hide 4882 */ 4883 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer, 4884 @DeleteFlags int flags); 4885 4886 /** 4887 * Attempts to delete a package. Since this may take a little while, the 4888 * result will be posted back to the given observer. A deletion will fail if 4889 * the named package cannot be found, or if the named package is a system 4890 * package. 4891 * 4892 * @param packageName The name of the package to delete 4893 * @param observer An observer callback to get notified when the package 4894 * deletion is complete. 4895 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 4896 * will be called when that happens. observer may be null to 4897 * indicate that no callback is desired. 4898 * @param userId The user Id 4899 * @hide 4900 */ 4901 @RequiresPermission(anyOf = { 4902 Manifest.permission.DELETE_PACKAGES, 4903 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4904 public abstract void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, 4905 @DeleteFlags int flags, @UserIdInt int userId); 4906 4907 /** 4908 * Retrieve the package name of the application that installed a package. This identifies 4909 * which market the package came from. 4910 * 4911 * @param packageName The name of the package to query 4912 */ 4913 public abstract String getInstallerPackageName(String packageName); 4914 4915 /** 4916 * Attempts to clear the user data directory of an application. 4917 * Since this may take a little while, the result will 4918 * be posted back to the given observer. A deletion will fail if the 4919 * named package cannot be found, or if the named package is a "system package". 4920 * 4921 * @param packageName The name of the package 4922 * @param observer An observer callback to get notified when the operation is finished 4923 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 4924 * will be called when that happens. observer may be null to indicate that 4925 * no callback is desired. 4926 * 4927 * @hide 4928 */ 4929 public abstract void clearApplicationUserData(String packageName, 4930 IPackageDataObserver observer); 4931 /** 4932 * Attempts to delete the cache files associated with an application. 4933 * Since this may take a little while, the result will 4934 * be posted back to the given observer. A deletion will fail if the calling context 4935 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 4936 * named package cannot be found, or if the named package is a "system package". 4937 * 4938 * @param packageName The name of the package to delete 4939 * @param observer An observer callback to get notified when the cache file deletion 4940 * is complete. 4941 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 4942 * will be called when that happens. observer may be null to indicate that 4943 * no callback is desired. 4944 * 4945 * @hide 4946 */ 4947 public abstract void deleteApplicationCacheFiles(String packageName, 4948 IPackageDataObserver observer); 4949 4950 /** 4951 * Free storage by deleting LRU sorted list of cache files across 4952 * all applications. If the currently available free storage 4953 * on the device is greater than or equal to the requested 4954 * free storage, no cache files are cleared. If the currently 4955 * available storage on the device is less than the requested 4956 * free storage, some or all of the cache files across 4957 * all applications are deleted (based on last accessed time) 4958 * to increase the free storage space on the device to 4959 * the requested value. There is no guarantee that clearing all 4960 * the cache files from all applications will clear up 4961 * enough storage to achieve the desired value. 4962 * @param freeStorageSize The number of bytes of storage to be 4963 * freed by the system. Say if freeStorageSize is XX, 4964 * and the current free storage is YY, 4965 * if XX is less than YY, just return. if not free XX-YY number 4966 * of bytes if possible. 4967 * @param observer call back used to notify when 4968 * the operation is completed 4969 * 4970 * @hide 4971 */ 4972 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 4973 freeStorageAndNotify(null, freeStorageSize, observer); 4974 } 4975 4976 /** {@hide} */ 4977 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 4978 IPackageDataObserver observer); 4979 4980 /** 4981 * Free storage by deleting LRU sorted list of cache files across 4982 * all applications. If the currently available free storage 4983 * on the device is greater than or equal to the requested 4984 * free storage, no cache files are cleared. If the currently 4985 * available storage on the device is less than the requested 4986 * free storage, some or all of the cache files across 4987 * all applications are deleted (based on last accessed time) 4988 * to increase the free storage space on the device to 4989 * the requested value. There is no guarantee that clearing all 4990 * the cache files from all applications will clear up 4991 * enough storage to achieve the desired value. 4992 * @param freeStorageSize The number of bytes of storage to be 4993 * freed by the system. Say if freeStorageSize is XX, 4994 * and the current free storage is YY, 4995 * if XX is less than YY, just return. if not free XX-YY number 4996 * of bytes if possible. 4997 * @param pi IntentSender call back used to 4998 * notify when the operation is completed.May be null 4999 * to indicate that no call back is desired. 5000 * 5001 * @hide 5002 */ 5003 public void freeStorage(long freeStorageSize, IntentSender pi) { 5004 freeStorage(null, freeStorageSize, pi); 5005 } 5006 5007 /** {@hide} */ 5008 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 5009 5010 /** 5011 * Retrieve the size information for a package. 5012 * Since this may take a little while, the result will 5013 * be posted back to the given observer. The calling context 5014 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 5015 * 5016 * @param packageName The name of the package whose size information is to be retrieved 5017 * @param userId The user whose size information should be retrieved. 5018 * @param observer An observer callback to get notified when the operation 5019 * is complete. 5020 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 5021 * The observer's callback is invoked with a PackageStats object(containing the 5022 * code, data and cache sizes of the package) and a boolean value representing 5023 * the status of the operation. observer may be null to indicate that 5024 * no callback is desired. 5025 * 5026 * @hide 5027 */ 5028 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId, 5029 IPackageStatsObserver observer); 5030 5031 /** 5032 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 5033 * returns the size for the calling user. 5034 * 5035 * @hide 5036 */ 5037 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 5038 getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer); 5039 } 5040 5041 /** 5042 * @deprecated This function no longer does anything; it was an old 5043 * approach to managing preferred activities, which has been superseded 5044 * by (and conflicts with) the modern activity-based preferences. 5045 */ 5046 @Deprecated 5047 public abstract void addPackageToPreferred(String packageName); 5048 5049 /** 5050 * @deprecated This function no longer does anything; it was an old 5051 * approach to managing preferred activities, which has been superseded 5052 * by (and conflicts with) the modern activity-based preferences. 5053 */ 5054 @Deprecated 5055 public abstract void removePackageFromPreferred(String packageName); 5056 5057 /** 5058 * Retrieve the list of all currently configured preferred packages. The 5059 * first package on the list is the most preferred, the last is the 5060 * least preferred. 5061 * 5062 * @param flags Additional option flags. Use any combination of 5063 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 5064 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 5065 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 5066 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 5067 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 5068 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 5069 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 5070 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 5071 * {@link #MATCH_UNINSTALLED_PACKAGES} 5072 * to modify the data returned. 5073 * 5074 * @return A List of PackageInfo objects, one for each preferred application, 5075 * in order of preference. 5076 * 5077 * @see #GET_ACTIVITIES 5078 * @see #GET_CONFIGURATIONS 5079 * @see #GET_GIDS 5080 * @see #GET_INSTRUMENTATION 5081 * @see #GET_INTENT_FILTERS 5082 * @see #GET_META_DATA 5083 * @see #GET_PERMISSIONS 5084 * @see #GET_PROVIDERS 5085 * @see #GET_RECEIVERS 5086 * @see #GET_SERVICES 5087 * @see #GET_SHARED_LIBRARY_FILES 5088 * @see #GET_SIGNATURES 5089 * @see #GET_URI_PERMISSION_PATTERNS 5090 * @see #MATCH_DISABLED_COMPONENTS 5091 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 5092 * @see #MATCH_UNINSTALLED_PACKAGES 5093 */ 5094 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 5095 5096 /** 5097 * @deprecated This is a protected API that should not have been available 5098 * to third party applications. It is the platform's responsibility for 5099 * assigning preferred activities and this cannot be directly modified. 5100 * 5101 * Add a new preferred activity mapping to the system. This will be used 5102 * to automatically select the given activity component when 5103 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5104 * multiple matching activities and also matches the given filter. 5105 * 5106 * @param filter The set of intents under which this activity will be 5107 * made preferred. 5108 * @param match The IntentFilter match category that this preference 5109 * applies to. 5110 * @param set The set of activities that the user was picking from when 5111 * this preference was made. 5112 * @param activity The component name of the activity that is to be 5113 * preferred. 5114 */ 5115 @Deprecated 5116 public abstract void addPreferredActivity(IntentFilter filter, int match, 5117 ComponentName[] set, ComponentName activity); 5118 5119 /** 5120 * Same as {@link #addPreferredActivity(IntentFilter, int, 5121 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 5122 to. 5123 * @hide 5124 */ 5125 public void addPreferredActivityAsUser(IntentFilter filter, int match, 5126 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5127 throw new RuntimeException("Not implemented. Must override in a subclass."); 5128 } 5129 5130 /** 5131 * @deprecated This is a protected API that should not have been available 5132 * to third party applications. It is the platform's responsibility for 5133 * assigning preferred activities and this cannot be directly modified. 5134 * 5135 * Replaces an existing preferred activity mapping to the system, and if that were not present 5136 * adds a new preferred activity. This will be used 5137 * to automatically select the given activity component when 5138 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5139 * multiple matching activities and also matches the given filter. 5140 * 5141 * @param filter The set of intents under which this activity will be 5142 * made preferred. 5143 * @param match The IntentFilter match category that this preference 5144 * applies to. 5145 * @param set The set of activities that the user was picking from when 5146 * this preference was made. 5147 * @param activity The component name of the activity that is to be 5148 * preferred. 5149 * @hide 5150 */ 5151 @Deprecated 5152 public abstract void replacePreferredActivity(IntentFilter filter, int match, 5153 ComponentName[] set, ComponentName activity); 5154 5155 /** 5156 * @hide 5157 */ 5158 @Deprecated 5159 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 5160 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5161 throw new RuntimeException("Not implemented. Must override in a subclass."); 5162 } 5163 5164 /** 5165 * Remove all preferred activity mappings, previously added with 5166 * {@link #addPreferredActivity}, from the 5167 * system whose activities are implemented in the given package name. 5168 * An application can only clear its own package(s). 5169 * 5170 * @param packageName The name of the package whose preferred activity 5171 * mappings are to be removed. 5172 */ 5173 public abstract void clearPackagePreferredActivities(String packageName); 5174 5175 /** 5176 * Retrieve all preferred activities, previously added with 5177 * {@link #addPreferredActivity}, that are 5178 * currently registered with the system. 5179 * 5180 * @param outFilters A required list in which to place the filters of all of the 5181 * preferred activities. 5182 * @param outActivities A required list in which to place the component names of 5183 * all of the preferred activities. 5184 * @param packageName An optional package in which you would like to limit 5185 * the list. If null, all activities will be returned; if non-null, only 5186 * those activities in the given package are returned. 5187 * 5188 * @return Returns the total number of registered preferred activities 5189 * (the number of distinct IntentFilter records, not the number of unique 5190 * activity components) that were found. 5191 */ 5192 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 5193 @NonNull List<ComponentName> outActivities, String packageName); 5194 5195 /** 5196 * Ask for the set of available 'home' activities and the current explicit 5197 * default, if any. 5198 * @hide 5199 */ 5200 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 5201 5202 /** 5203 * Set the enabled setting for a package component (activity, receiver, service, provider). 5204 * This setting will override any enabled state which may have been set by the component in its 5205 * manifest. 5206 * 5207 * @param componentName The component to enable 5208 * @param newState The new enabled state for the component. The legal values for this state 5209 * are: 5210 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5211 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 5212 * and 5213 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 5214 * The last one removes the setting, thereby restoring the component's state to 5215 * whatever was set in it's manifest (or enabled, by default). 5216 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 5217 */ 5218 public abstract void setComponentEnabledSetting(ComponentName componentName, 5219 int newState, int flags); 5220 5221 5222 /** 5223 * Return the enabled setting for a package component (activity, 5224 * receiver, service, provider). This returns the last value set by 5225 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 5226 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5227 * the value originally specified in the manifest has not been modified. 5228 * 5229 * @param componentName The component to retrieve. 5230 * @return Returns the current enabled state for the component. May 5231 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5232 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 5233 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 5234 * component's enabled state is based on the original information in 5235 * the manifest as found in {@link ComponentInfo}. 5236 */ 5237 public abstract int getComponentEnabledSetting(ComponentName componentName); 5238 5239 /** 5240 * Set the enabled setting for an application 5241 * This setting will override any enabled state which may have been set by the application in 5242 * its manifest. It also overrides the enabled state set in the manifest for any of the 5243 * application's components. It does not override any enabled state set by 5244 * {@link #setComponentEnabledSetting} for any of the application's components. 5245 * 5246 * @param packageName The package name of the application to enable 5247 * @param newState The new enabled state for the component. The legal values for this state 5248 * are: 5249 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5250 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 5251 * and 5252 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 5253 * The last one removes the setting, thereby restoring the applications's state to 5254 * whatever was set in its manifest (or enabled, by default). 5255 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 5256 */ 5257 public abstract void setApplicationEnabledSetting(String packageName, 5258 int newState, int flags); 5259 5260 /** 5261 * Return the enabled setting for an application. This returns 5262 * the last value set by 5263 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 5264 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5265 * the value originally specified in the manifest has not been modified. 5266 * 5267 * @param packageName The package name of the application to retrieve. 5268 * @return Returns the current enabled state for the application. May 5269 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5270 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 5271 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 5272 * application's enabled state is based on the original information in 5273 * the manifest as found in {@link ComponentInfo}. 5274 * @throws IllegalArgumentException if the named package does not exist. 5275 */ 5276 public abstract int getApplicationEnabledSetting(String packageName); 5277 5278 /** 5279 * Puts the package in a hidden state, which is almost like an uninstalled state, 5280 * making the package unavailable, but it doesn't remove the data or the actual 5281 * package file. Application can be unhidden by either resetting the hidden state 5282 * or by installing it, such as with {@link #installExistingPackage(String)} 5283 * @hide 5284 */ 5285 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 5286 UserHandle userHandle); 5287 5288 /** 5289 * Returns the hidden state of a package. 5290 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 5291 * @hide 5292 */ 5293 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 5294 UserHandle userHandle); 5295 5296 /** 5297 * Return whether the device has been booted into safe mode. 5298 */ 5299 public abstract boolean isSafeMode(); 5300 5301 /** 5302 * Adds a listener for permission changes for installed packages. 5303 * 5304 * @param listener The listener to add. 5305 * 5306 * @hide 5307 */ 5308 @SystemApi 5309 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 5310 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5311 5312 /** 5313 * Remvoes a listener for permission changes for installed packages. 5314 * 5315 * @param listener The listener to remove. 5316 * 5317 * @hide 5318 */ 5319 @SystemApi 5320 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5321 5322 /** 5323 * Return the {@link KeySet} associated with the String alias for this 5324 * application. 5325 * 5326 * @param alias The alias for a given {@link KeySet} as defined in the 5327 * application's AndroidManifest.xml. 5328 * @hide 5329 */ 5330 public abstract KeySet getKeySetByAlias(String packageName, String alias); 5331 5332 /** Return the signing {@link KeySet} for this application. 5333 * @hide 5334 */ 5335 public abstract KeySet getSigningKeySet(String packageName); 5336 5337 /** 5338 * Return whether the package denoted by packageName has been signed by all 5339 * of the keys specified by the {@link KeySet} ks. This will return true if 5340 * the package has been signed by additional keys (a superset) as well. 5341 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 5342 * @hide 5343 */ 5344 public abstract boolean isSignedBy(String packageName, KeySet ks); 5345 5346 /** 5347 * Return whether the package denoted by packageName has been signed by all 5348 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 5349 * {@link #isSignedBy(String packageName, KeySet ks)}. 5350 * @hide 5351 */ 5352 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 5353 5354 /** 5355 * Puts the package in a suspended state, where attempts at starting activities are denied. 5356 * 5357 * <p>It doesn't remove the data or the actual package file. The application notifications 5358 * will be hidden, the application will not show up in recents, will not be able to show 5359 * toasts or dialogs or ring the device. 5360 * 5361 * @param packageNames The names of the packages to set the suspended status. 5362 * @param suspended If set to {@code true} than the packages will be suspended, if set to 5363 * {@code false} the packages will be unsuspended. 5364 * @param userId The user id. 5365 * 5366 * @return an array of package names for which the suspended status is not set as requested in 5367 * this method. 5368 * 5369 * @hide 5370 */ 5371 public abstract String[] setPackagesSuspendedAsUser( 5372 String[] packageNames, boolean suspended, @UserIdInt int userId); 5373 5374 /** 5375 * @see #setPackageSuspendedAsUser(String, boolean, int) 5376 * @param packageName The name of the package to get the suspended status of. 5377 * @param userId The user id. 5378 * @return {@code true} if the package is suspended or {@code false} if the package is not 5379 * suspended or could not be found. 5380 * @hide 5381 */ 5382 public abstract boolean isPackageSuspendedForUser(String packageName, int userId); 5383 5384 /** {@hide} */ 5385 public static boolean isMoveStatusFinished(int status) { 5386 return (status < 0 || status > 100); 5387 } 5388 5389 /** {@hide} */ 5390 public static abstract class MoveCallback { 5391 public void onCreated(int moveId, Bundle extras) {} 5392 public abstract void onStatusChanged(int moveId, int status, long estMillis); 5393 } 5394 5395 /** {@hide} */ 5396 public abstract int getMoveStatus(int moveId); 5397 5398 /** {@hide} */ 5399 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 5400 /** {@hide} */ 5401 public abstract void unregisterMoveCallback(MoveCallback callback); 5402 5403 /** {@hide} */ 5404 public abstract int movePackage(String packageName, VolumeInfo vol); 5405 /** {@hide} */ 5406 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 5407 /** {@hide} */ 5408 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 5409 5410 /** {@hide} */ 5411 public abstract int movePrimaryStorage(VolumeInfo vol); 5412 /** {@hide} */ 5413 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 5414 /** {@hide} */ 5415 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 5416 5417 /** 5418 * Returns the device identity that verifiers can use to associate their scheme to a particular 5419 * device. This should not be used by anything other than a package verifier. 5420 * 5421 * @return identity that uniquely identifies current device 5422 * @hide 5423 */ 5424 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 5425 5426 /** 5427 * Returns true if the device is upgrading, such as first boot after OTA. 5428 * 5429 * @hide 5430 */ 5431 public abstract boolean isUpgrade(); 5432 5433 /** 5434 * Return interface that offers the ability to install, upgrade, and remove 5435 * applications on the device. 5436 */ 5437 public abstract @NonNull PackageInstaller getPackageInstaller(); 5438 5439 /** 5440 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 5441 * intents sent from the user with id sourceUserId can also be be resolved 5442 * by activities in the user with id targetUserId if they match the 5443 * specified intent filter. 5444 * 5445 * @param filter The {@link IntentFilter} the intent has to match 5446 * @param sourceUserId The source user id. 5447 * @param targetUserId The target user id. 5448 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 5449 * {@link #ONLY_IF_NO_MATCH_FOUND}. 5450 * @hide 5451 */ 5452 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 5453 int targetUserId, int flags); 5454 5455 /** 5456 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 5457 * as their source, and have been set by the app calling this method. 5458 * 5459 * @param sourceUserId The source user id. 5460 * @hide 5461 */ 5462 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 5463 5464 /** 5465 * @hide 5466 */ 5467 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5468 5469 /** 5470 * @hide 5471 */ 5472 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5473 5474 /** {@hide} */ 5475 public abstract boolean isPackageAvailable(String packageName); 5476 5477 /** {@hide} */ 5478 public static String installStatusToString(int status, String msg) { 5479 final String str = installStatusToString(status); 5480 if (msg != null) { 5481 return str + ": " + msg; 5482 } else { 5483 return str; 5484 } 5485 } 5486 5487 /** {@hide} */ 5488 public static String installStatusToString(int status) { 5489 switch (status) { 5490 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 5491 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 5492 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 5493 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 5494 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 5495 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 5496 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 5497 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 5498 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 5499 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 5500 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 5501 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 5502 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 5503 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 5504 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 5505 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 5506 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 5507 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 5508 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 5509 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 5510 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 5511 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 5512 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 5513 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 5514 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 5515 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 5516 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 5517 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 5518 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 5519 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 5520 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 5521 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 5522 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 5523 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 5524 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 5525 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 5526 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 5527 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 5528 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 5529 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 5530 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 5531 default: return Integer.toString(status); 5532 } 5533 } 5534 5535 /** {@hide} */ 5536 public static int installStatusToPublicStatus(int status) { 5537 switch (status) { 5538 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5539 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5540 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5541 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 5542 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5543 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5544 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5545 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5546 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5547 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5548 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5549 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 5550 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5551 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5552 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5553 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 5554 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5555 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5556 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 5557 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 5558 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5559 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 5560 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 5561 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5562 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5563 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5564 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5565 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5566 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 5567 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 5568 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5569 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5570 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 5571 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 5572 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 5573 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 5574 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 5575 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5576 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5577 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5578 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5579 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5580 default: return PackageInstaller.STATUS_FAILURE; 5581 } 5582 } 5583 5584 /** {@hide} */ 5585 public static String deleteStatusToString(int status, String msg) { 5586 final String str = deleteStatusToString(status); 5587 if (msg != null) { 5588 return str + ": " + msg; 5589 } else { 5590 return str; 5591 } 5592 } 5593 5594 /** {@hide} */ 5595 public static String deleteStatusToString(int status) { 5596 switch (status) { 5597 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 5598 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 5599 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 5600 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 5601 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 5602 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 5603 default: return Integer.toString(status); 5604 } 5605 } 5606 5607 /** {@hide} */ 5608 public static int deleteStatusToPublicStatus(int status) { 5609 switch (status) { 5610 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5611 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5612 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5613 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5614 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5615 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5616 default: return PackageInstaller.STATUS_FAILURE; 5617 } 5618 } 5619 5620 /** {@hide} */ 5621 public static String permissionFlagToString(int flag) { 5622 switch (flag) { 5623 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 5624 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 5625 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 5626 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 5627 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 5628 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 5629 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 5630 default: return Integer.toString(flag); 5631 } 5632 } 5633 5634 /** {@hide} */ 5635 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 5636 private final IPackageInstallObserver mLegacy; 5637 5638 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 5639 mLegacy = legacy; 5640 } 5641 5642 @Override 5643 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 5644 Bundle extras) { 5645 if (mLegacy == null) return; 5646 try { 5647 mLegacy.packageInstalled(basePackageName, returnCode); 5648 } catch (RemoteException ignored) { 5649 } 5650 } 5651 } 5652 5653 /** {@hide} */ 5654 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 5655 private final IPackageDeleteObserver mLegacy; 5656 5657 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 5658 mLegacy = legacy; 5659 } 5660 5661 @Override 5662 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 5663 if (mLegacy == null) return; 5664 try { 5665 mLegacy.packageDeleted(basePackageName, returnCode); 5666 } catch (RemoteException ignored) { 5667 } 5668 } 5669 } 5670} 5671