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