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