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