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