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