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