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