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