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 17 package android.content.pm; 18 19 import android.Manifest; 20 import android.annotation.CallbackExecutor; 21 import android.annotation.CheckResult; 22 import android.annotation.DrawableRes; 23 import android.annotation.IntDef; 24 import android.annotation.IntRange; 25 import android.annotation.LongDef; 26 import android.annotation.NonNull; 27 import android.annotation.Nullable; 28 import android.annotation.RequiresPermission; 29 import android.annotation.SdkConstant; 30 import android.annotation.SdkConstant.SdkConstantType; 31 import android.annotation.StringRes; 32 import android.annotation.SystemApi; 33 import android.annotation.TestApi; 34 import android.annotation.UserIdInt; 35 import android.annotation.XmlRes; 36 import android.app.ActivityManager; 37 import android.app.ActivityThread; 38 import android.app.AppDetailsActivity; 39 import android.app.PackageDeleteObserver; 40 import android.app.PackageInstallObserver; 41 import android.app.PropertyInvalidatedCache; 42 import android.app.admin.DevicePolicyManager; 43 import android.app.usage.StorageStatsManager; 44 import android.compat.annotation.ChangeId; 45 import android.compat.annotation.EnabledSince; 46 import android.compat.annotation.UnsupportedAppUsage; 47 import android.content.ComponentName; 48 import android.content.Context; 49 import android.content.Intent; 50 import android.content.IntentFilter; 51 import android.content.IntentSender; 52 import android.content.pm.PackageInstaller.SessionParams; 53 import android.content.pm.dex.ArtManager; 54 import android.content.pm.pkg.FrameworkPackageUserState; 55 import android.content.pm.verify.domain.DomainVerificationManager; 56 import android.content.res.Configuration; 57 import android.content.res.Resources; 58 import android.content.res.XmlResourceParser; 59 import android.graphics.Rect; 60 import android.graphics.drawable.AdaptiveIconDrawable; 61 import android.graphics.drawable.Drawable; 62 import android.net.ConnectivityManager; 63 import android.net.wifi.WifiManager; 64 import android.os.Build; 65 import android.os.Bundle; 66 import android.os.Handler; 67 import android.os.IBinder; 68 import android.os.Parcel; 69 import android.os.Parcelable; 70 import android.os.PersistableBundle; 71 import android.os.RemoteException; 72 import android.os.UserHandle; 73 import android.os.UserManager; 74 import android.os.incremental.IncrementalManager; 75 import android.os.storage.StorageManager; 76 import android.os.storage.VolumeInfo; 77 import android.permission.PermissionManager; 78 import android.telephony.TelephonyManager; 79 import android.telephony.UiccCardInfo; 80 import android.telephony.gba.GbaService; 81 import android.telephony.ims.ImsService; 82 import android.telephony.ims.ProvisioningManager; 83 import android.telephony.ims.RcsUceAdapter; 84 import android.telephony.ims.SipDelegateManager; 85 import android.util.AndroidException; 86 import android.util.Log; 87 88 import com.android.internal.annotations.VisibleForTesting; 89 import com.android.internal.util.ArrayUtils; 90 import com.android.internal.util.DataClass; 91 92 import dalvik.system.VMRuntime; 93 94 import java.io.File; 95 import java.lang.annotation.Retention; 96 import java.lang.annotation.RetentionPolicy; 97 import java.security.cert.Certificate; 98 import java.security.cert.CertificateEncodingException; 99 import java.util.Collections; 100 import java.util.List; 101 import java.util.Locale; 102 import java.util.Objects; 103 import java.util.Set; 104 import java.util.UUID; 105 import java.util.concurrent.Executor; 106 import java.util.function.Consumer; 107 108 /** 109 * Class for retrieving various kinds of information related to the application 110 * packages that are currently installed on the device. 111 * 112 * You can find this class through {@link Context#getPackageManager}. 113 * 114 * <p class="note"><strong>Note: </strong>If your app targets Android 11 (API level 30) or 115 * higher, the methods in this class each return a filtered list of apps. Learn more about how to 116 * <a href="/training/basics/intents/package-visibility">manage package visibility</a>. 117 * </p> 118 */ 119 public abstract class PackageManager { 120 private static final String TAG = "PackageManager"; 121 122 /** {@hide} */ 123 public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true; 124 125 /** {@hide} */ 126 public static final boolean ENABLE_SHARED_UID_MIGRATION = true; 127 128 /** 129 * This exception is thrown when a given package, application, or component 130 * name cannot be found. 131 */ 132 public static class NameNotFoundException extends AndroidException { NameNotFoundException()133 public NameNotFoundException() { 134 } 135 NameNotFoundException(String name)136 public NameNotFoundException(String name) { 137 super(name); 138 } 139 } 140 141 /** 142 * <application> level {@link android.content.pm.PackageManager.Property} tag specifying 143 * the XML resource ID containing an application's media capabilities XML file 144 * 145 * For example: 146 * <application> 147 * <property android:name="android.media.PROPERTY_MEDIA_CAPABILITIES" 148 * android:resource="@xml/media_capabilities"> 149 * <application> 150 */ 151 public static final String PROPERTY_MEDIA_CAPABILITIES = 152 "android.media.PROPERTY_MEDIA_CAPABILITIES"; 153 154 /** 155 * <application> level {@link android.content.pm.PackageManager.Property} tag 156 * specifying the XML resource ID containing the declaration of the self-certified network 157 * capabilities used by the application. 158 * 159 * <p> Starting from Android 14, usage of some network capabilities in 160 * {@link android.net.ConnectivityManager#requestNetwork} require the application to 161 * declare its usage of that particular capability in this resource. Only some capabilities 162 * require a declaration. Please look up the specific capability you want to use in 163 * {@link android.net.NetworkCapabilities} to see if it needs declaration in this property. 164 * 165 * For example: 166 * <application> 167 * <property android:name="android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES" 168 * android:resource="@xml/self_certified_network_capabilities"> 169 * <application> 170 * 171 * <p> The detail format of self_certified_network_capabilities.xml is described in 172 * {@link android.net.NetworkRequest} 173 */ 174 public static final String PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES = 175 "android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES"; 176 177 /** 178 * Application level property that an app can specify to opt-out from having private data 179 * directories both on the internal and external storages. 180 * 181 * <p>Changing the value of this property during app update is not supported, and such updates 182 * will be rejected. 183 * 184 * <p>This should only be set by platform apps that know what they are doing. 185 * 186 * @hide 187 */ 188 public static final String PROPERTY_NO_APP_DATA_STORAGE = 189 "android.internal.PROPERTY_NO_APP_DATA_STORAGE"; 190 191 /** 192 * <service> level {@link android.content.pm.PackageManager.Property} tag specifying 193 * the actual use case of the service if it's foreground service with the type 194 * {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SPECIAL_USE}. 195 * 196 * <p> 197 * For example: 198 * <service> 199 * <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" 200 * android:value="foo"/> 201 * </service> 202 */ 203 public static final String PROPERTY_SPECIAL_USE_FGS_SUBTYPE = 204 "android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"; 205 206 /** 207 * Application level {@link android.content.pm.PackageManager.Property PackageManager 208 * .Property} for an app to inform the system that the app can be opted-in or opted-out 209 * from the compatibility treatment that rotates camera output by 90 degrees on landscape 210 * sensors on devices known to have compatibility issues. 211 * 212 * <p>The treatment is disabled by default but device manufacturers can enable the treatment 213 * using their discretion to improve camera compatibility. With this property set to 214 * {@code false}, the rotation will not be applied. A value of {@code true} 215 * will ensure that rotation is applied, provided it is enabled for the device. In most cases, 216 * if rotation is the desired behavior this property need not be set. However, if your app 217 * experiences stretching or incorrect rotation on these devices, explicitly setting this to 218 * {@code true} may resolve that behavior. Apps should set this to {@code false} if there 219 * is confidence that the app handles 220 * {@link android.hardware.camera2.CameraCharacteristics#SENSOR_ORIENTATION} correctly. 221 * See <a href="https://developer.android.com/training/camera2/camera-preview"> the 222 * documentation for best practice.</a> 223 * 224 * <p><b>Syntax:</b> 225 * <pre> 226 * <application> 227 * <property 228 * android:name="android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT" 229 * android:value="true|false"/> 230 * </application> 231 * </pre> 232 */ 233 public static final String PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT = 234 "android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT"; 235 236 /** 237 * Application level {@link android.content.pm.PackageManager.Property PackageManager 238 * .Property} for a privileged system installer to define a list of up to 500 packages that 239 * should not have their updates owned by any installer. The list must be provided via a default 240 * XML resource with the following format: 241 * 242 * <pre> 243 * <deny-ownership>PACKAGE_NAME</deny-ownership> 244 * <deny-ownership>PACKAGE_NAME</deny-ownership> 245 * </pre> 246 * 247 * <b>NOTE:</b> Installers that provide this property will not granted update ownership for any 248 * packages that they request update ownership of. 249 * @hide 250 */ 251 public static final String PROPERTY_LEGACY_UPDATE_OWNERSHIP_DENYLIST = 252 "android.app.PROPERTY_LEGACY_UPDATE_OWNERSHIP_DENYLIST"; 253 254 /** 255 * A property value set within the manifest. 256 * <p> 257 * The value of a property will only have a single type, as defined by 258 * the property itself. 259 */ 260 public static final class Property implements Parcelable { 261 private static final int TYPE_BOOLEAN = 1; 262 private static final int TYPE_FLOAT = 2; 263 private static final int TYPE_INTEGER = 3; 264 private static final int TYPE_RESOURCE = 4; 265 private static final int TYPE_STRING = 5; 266 private final String mName; 267 private final int mType; 268 private final String mClassName; 269 private final String mPackageName; 270 private boolean mBooleanValue; 271 private float mFloatValue; 272 private int mIntegerValue; 273 private String mStringValue; 274 275 /** @hide */ 276 @VisibleForTesting Property(@onNull String name, int type, @NonNull String packageName, @Nullable String className)277 public Property(@NonNull String name, int type, 278 @NonNull String packageName, @Nullable String className) { 279 if (type < TYPE_BOOLEAN || type > TYPE_STRING) { 280 throw new IllegalArgumentException("Invalid type"); 281 } 282 this.mName = Objects.requireNonNull(name); 283 this.mType = type; 284 this.mPackageName = Objects.requireNonNull(packageName); 285 this.mClassName = className; 286 } 287 /** @hide */ Property(@onNull String name, boolean value, String packageName, String className)288 public Property(@NonNull String name, boolean value, 289 String packageName, String className) { 290 this(name, TYPE_BOOLEAN, packageName, className); 291 mBooleanValue = value; 292 } 293 /** @hide */ Property(@onNull String name, float value, String packageName, String className)294 public Property(@NonNull String name, float value, 295 String packageName, String className) { 296 this(name, TYPE_FLOAT, packageName, className); 297 mFloatValue = value; 298 } 299 /** @hide */ Property(@onNull String name, int value, boolean isResource, String packageName, String className)300 public Property(@NonNull String name, int value, boolean isResource, 301 String packageName, String className) { 302 this(name, isResource ? TYPE_RESOURCE : TYPE_INTEGER, packageName, className); 303 mIntegerValue = value; 304 } 305 /** @hide */ Property(@onNull String name, String value, String packageName, String className)306 public Property(@NonNull String name, String value, 307 String packageName, String className) { 308 this(name, TYPE_STRING, packageName, className); 309 mStringValue = value; 310 } 311 312 /** @hide */ 313 @VisibleForTesting getType()314 public int getType() { 315 return mType; 316 } 317 318 /** 319 * Returns the name of the property. 320 */ getName()321 @NonNull public String getName() { 322 return mName; 323 } 324 325 /** 326 * Returns the name of the package where this this property was defined. 327 */ getPackageName()328 @NonNull public String getPackageName() { 329 return mPackageName; 330 } 331 332 /** 333 * Returns the classname of the component where this property was defined. 334 * <p>If the property was defined within and <application> tag, retutrns 335 * {@code null} 336 */ getClassName()337 @Nullable public String getClassName() { 338 return mClassName; 339 } 340 341 /** 342 * Returns the boolean value set for the property. 343 * <p>If the property is not of a boolean type, returns {@code false}. 344 */ getBoolean()345 public boolean getBoolean() { 346 return mBooleanValue; 347 } 348 349 /** 350 * Returns {@code true} if the property is a boolean type. Otherwise {@code false}. 351 */ isBoolean()352 public boolean isBoolean() { 353 return mType == TYPE_BOOLEAN; 354 } 355 356 /** 357 * Returns the float value set for the property. 358 * <p>If the property is not of a float type, returns {@code 0.0}. 359 */ getFloat()360 public float getFloat() { 361 return mFloatValue; 362 } 363 364 /** 365 * Returns {@code true} if the property is a float type. Otherwise {@code false}. 366 */ isFloat()367 public boolean isFloat() { 368 return mType == TYPE_FLOAT; 369 } 370 371 /** 372 * Returns the integer value set for the property. 373 * <p>If the property is not of an integer type, returns {@code 0}. 374 */ getInteger()375 public int getInteger() { 376 return mType == TYPE_INTEGER ? mIntegerValue : 0; 377 } 378 379 /** 380 * Returns {@code true} if the property is an integer type. Otherwise {@code false}. 381 */ isInteger()382 public boolean isInteger() { 383 return mType == TYPE_INTEGER; 384 } 385 386 /** 387 * Returns the a resource id set for the property. 388 * <p>If the property is not of a resource id type, returns {@code 0}. 389 */ getResourceId()390 public int getResourceId() { 391 return mType == TYPE_RESOURCE ? mIntegerValue : 0; 392 } 393 394 /** 395 * Returns {@code true} if the property is a resource id type. Otherwise {@code false}. 396 */ isResourceId()397 public boolean isResourceId() { 398 return mType == TYPE_RESOURCE; 399 } 400 401 /** 402 * Returns the a String value set for the property. 403 * <p>If the property is not a String type, returns {@code null}. 404 */ getString()405 @Nullable public String getString() { 406 return mStringValue; 407 } 408 409 /** 410 * Returns {@code true} if the property is a String type. Otherwise {@code false}. 411 */ isString()412 public boolean isString() { 413 return mType == TYPE_STRING; 414 } 415 416 /** 417 * Adds a mapping from the given key to this property's value in the provided 418 * {@link android.os.Bundle}. If the provided {@link android.os.Bundle} is 419 * {@code null}, creates a new {@link android.os.Bundle}. 420 * @hide 421 */ toBundle(Bundle outBundle)422 public Bundle toBundle(Bundle outBundle) { 423 final Bundle b = outBundle == null || outBundle == Bundle.EMPTY 424 ? new Bundle() : outBundle; 425 if (mType == TYPE_BOOLEAN) { 426 b.putBoolean(mName, mBooleanValue); 427 } else if (mType == TYPE_FLOAT) { 428 b.putFloat(mName, mFloatValue); 429 } else if (mType == TYPE_INTEGER) { 430 b.putInt(mName, mIntegerValue); 431 } else if (mType == TYPE_RESOURCE) { 432 b.putInt(mName, mIntegerValue); 433 } else if (mType == TYPE_STRING) { 434 b.putString(mName, mStringValue); 435 } 436 return b; 437 } 438 439 @Override describeContents()440 public int describeContents() { 441 return 0; 442 } 443 444 @Override writeToParcel(@onNull Parcel dest, int flags)445 public void writeToParcel(@NonNull Parcel dest, int flags) { 446 dest.writeString(mName); 447 dest.writeInt(mType); 448 dest.writeString(mPackageName); 449 dest.writeString(mClassName); 450 if (mType == TYPE_BOOLEAN) { 451 dest.writeBoolean(mBooleanValue); 452 } else if (mType == TYPE_FLOAT) { 453 dest.writeFloat(mFloatValue); 454 } else if (mType == TYPE_INTEGER) { 455 dest.writeInt(mIntegerValue); 456 } else if (mType == TYPE_RESOURCE) { 457 dest.writeInt(mIntegerValue); 458 } else if (mType == TYPE_STRING) { 459 dest.writeString(mStringValue); 460 } 461 } 462 463 @NonNull 464 public static final Creator<Property> CREATOR = new Creator<Property>() { 465 @Override 466 public Property createFromParcel(@NonNull Parcel source) { 467 final String name = source.readString(); 468 final int type = source.readInt(); 469 final String packageName = source.readString(); 470 final String className = source.readString(); 471 if (type == TYPE_BOOLEAN) { 472 return new Property(name, source.readBoolean(), packageName, className); 473 } else if (type == TYPE_FLOAT) { 474 return new Property(name, source.readFloat(), packageName, className); 475 } else if (type == TYPE_INTEGER) { 476 return new Property(name, source.readInt(), false, packageName, className); 477 } else if (type == TYPE_RESOURCE) { 478 return new Property(name, source.readInt(), true, packageName, className); 479 } else if (type == TYPE_STRING) { 480 return new Property(name, source.readString(), packageName, className); 481 } 482 return null; 483 } 484 485 @Override 486 public Property[] newArray(int size) { 487 return new Property[size]; 488 } 489 }; 490 } 491 492 /** 493 * The class containing the enabled setting of a package component. 494 * <p> 495 * This is used by the {@link #setComponentEnabledSettings(List)} to support the batch updates 496 * of the enabled settings of components. 497 * 498 * @see #setComponentEnabledSettings(List) 499 */ 500 @DataClass(genConstructor = false) 501 public static final class ComponentEnabledSetting implements Parcelable { 502 /** 503 * The package name of the application to enable the setting. 504 */ 505 private final @Nullable String mPackageName; 506 507 /** 508 * The component name of the application to enable the setting. 509 */ 510 private final @Nullable ComponentName mComponentName; 511 512 /** 513 * The new enabled state 514 */ 515 private final @EnabledState int mEnabledState; 516 517 /** 518 * The optional behavior flag 519 */ 520 private final @EnabledFlags int mEnabledFlags; 521 522 /** 523 * Create an instance of the ComponentEnabledSetting for the component level's enabled 524 * setting update. 525 * 526 * @param componentName The component name to update the enabled setting. 527 * @param newState The new enabled state. 528 * @param flags The optional behavior flags. 529 */ ComponentEnabledSetting(@onNull ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags)530 public ComponentEnabledSetting(@NonNull ComponentName componentName, 531 @EnabledState int newState, @EnabledFlags int flags) { 532 mPackageName = null; 533 mComponentName = Objects.requireNonNull(componentName); 534 mEnabledState = newState; 535 mEnabledFlags = flags; 536 } 537 538 /** 539 * Create an instance of the ComponentEnabledSetting for the application level's enabled 540 * setting update. 541 * 542 * @param packageName The package name to update the enabled setting. 543 * @param newState The new enabled state. 544 * @param flags The optional behavior flags. 545 * @hide 546 */ ComponentEnabledSetting(@onNull String packageName, @EnabledState int newState, @EnabledFlags int flags)547 public ComponentEnabledSetting(@NonNull String packageName, 548 @EnabledState int newState, @EnabledFlags int flags) { 549 mPackageName = Objects.requireNonNull(packageName); 550 mComponentName = null; 551 mEnabledState = newState; 552 mEnabledFlags = flags; 553 } 554 555 /** 556 * Returns the package name of the setting. 557 * 558 * @return the package name. 559 * @hide 560 */ getPackageName()561 public @NonNull String getPackageName() { 562 if (isComponent()) { 563 return mComponentName.getPackageName(); 564 } 565 return mPackageName; 566 } 567 568 /** 569 * Returns the component class name of the setting. 570 * 571 * @return the class name. 572 * @hide 573 */ getClassName()574 public @Nullable String getClassName() { 575 if (isComponent()) { 576 return mComponentName.getClassName(); 577 } 578 return null; 579 } 580 581 /** 582 * Whether or not this is for the component level's enabled setting update. 583 * 584 * @return {@code true} if it's the component level enabled setting update. 585 * @hide 586 */ isComponent()587 public boolean isComponent() { 588 return mComponentName != null; 589 } 590 591 592 593 // Code below generated by codegen v1.0.23. 594 // 595 // DO NOT MODIFY! 596 // CHECKSTYLE:OFF Generated code 597 // 598 // To regenerate run: 599 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/PackageManager.java 600 // 601 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 602 // Settings > Editor > Code Style > Formatter Control 603 //@formatter:off 604 605 606 /** 607 * The component name of the application to enable the setting. 608 */ 609 @DataClass.Generated.Member getComponentName()610 public @Nullable ComponentName getComponentName() { 611 return mComponentName; 612 } 613 614 /** 615 * The new enabled state 616 */ 617 @DataClass.Generated.Member getEnabledState()618 public @EnabledState int getEnabledState() { 619 return mEnabledState; 620 } 621 622 /** 623 * The optional behavior flag 624 */ 625 @DataClass.Generated.Member getEnabledFlags()626 public @EnabledFlags int getEnabledFlags() { 627 return mEnabledFlags; 628 } 629 630 @Override 631 @DataClass.Generated.Member writeToParcel(@onNull Parcel dest, int flags)632 public void writeToParcel(@NonNull Parcel dest, int flags) { 633 // You can override field parcelling by defining methods like: 634 // void parcelFieldName(Parcel dest, int flags) { ... } 635 636 byte flg = 0; 637 if (mPackageName != null) flg |= 0x1; 638 if (mComponentName != null) flg |= 0x2; 639 dest.writeByte(flg); 640 if (mPackageName != null) dest.writeString(mPackageName); 641 if (mComponentName != null) dest.writeTypedObject(mComponentName, flags); 642 dest.writeInt(mEnabledState); 643 dest.writeInt(mEnabledFlags); 644 } 645 646 @Override 647 @DataClass.Generated.Member describeContents()648 public int describeContents() { return 0; } 649 650 /** @hide */ 651 @SuppressWarnings({"unchecked", "RedundantCast"}) 652 @DataClass.Generated.Member ComponentEnabledSetting(@onNull Parcel in)653 /* package-private */ ComponentEnabledSetting(@NonNull Parcel in) { 654 // You can override field unparcelling by defining methods like: 655 // static FieldType unparcelFieldName(Parcel in) { ... } 656 657 byte flg = in.readByte(); 658 String packageName = (flg & 0x1) == 0 ? null : in.readString(); 659 ComponentName componentName = (flg & 0x2) == 0 ? null : (ComponentName) in.readTypedObject(ComponentName.CREATOR); 660 int enabledState = in.readInt(); 661 int enabledFlags = in.readInt(); 662 663 this.mPackageName = packageName; 664 this.mComponentName = componentName; 665 this.mEnabledState = enabledState; 666 com.android.internal.util.AnnotationValidations.validate( 667 EnabledState.class, null, mEnabledState); 668 this.mEnabledFlags = enabledFlags; 669 com.android.internal.util.AnnotationValidations.validate( 670 EnabledFlags.class, null, mEnabledFlags); 671 672 // onConstructed(); // You can define this method to get a callback 673 } 674 675 @DataClass.Generated.Member 676 public static final @NonNull Parcelable.Creator<ComponentEnabledSetting> CREATOR 677 = new Parcelable.Creator<ComponentEnabledSetting>() { 678 @Override 679 public ComponentEnabledSetting[] newArray(int size) { 680 return new ComponentEnabledSetting[size]; 681 } 682 683 @Override 684 public ComponentEnabledSetting createFromParcel(@NonNull Parcel in) { 685 return new ComponentEnabledSetting(in); 686 } 687 }; 688 689 @DataClass.Generated( 690 time = 1628668290863L, 691 codegenVersion = "1.0.23", 692 sourceFile = "frameworks/base/core/java/android/content/pm/PackageManager.java", 693 inputSignatures = "private final @android.annotation.Nullable java.lang.String mPackageName\nprivate final @android.annotation.Nullable android.content.ComponentName mComponentName\nprivate final @android.content.pm.PackageManager.EnabledState int mEnabledState\nprivate final @android.content.pm.PackageManager.EnabledFlags int mEnabledFlags\npublic @android.annotation.NonNull java.lang.String getPackageName()\npublic @android.annotation.Nullable java.lang.String getClassName()\npublic boolean isComponent()\nclass ComponentEnabledSetting extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false)") 694 @Deprecated __metadata()695 private void __metadata() {} 696 697 698 //@formatter:on 699 // End of generated code 700 701 } 702 703 /** 704 * Listener for changes in permissions granted to a UID. 705 * 706 * @hide 707 */ 708 @SystemApi 709 public interface OnPermissionsChangedListener { 710 711 /** 712 * Called when the permissions for a UID change. 713 * @param uid The UID with a change. 714 */ onPermissionsChanged(int uid)715 public void onPermissionsChanged(int uid); 716 } 717 718 /** @hide */ 719 public static final int TYPE_UNKNOWN = 0; 720 /** @hide */ 721 public static final int TYPE_ACTIVITY = 1; 722 /** @hide */ 723 public static final int TYPE_RECEIVER = 2; 724 /** @hide */ 725 public static final int TYPE_SERVICE = 3; 726 /** @hide */ 727 public static final int TYPE_PROVIDER = 4; 728 /** @hide */ 729 public static final int TYPE_APPLICATION = 5; 730 /** @hide */ 731 @IntDef(prefix = { "TYPE_" }, value = { 732 TYPE_UNKNOWN, 733 TYPE_ACTIVITY, 734 TYPE_RECEIVER, 735 TYPE_SERVICE, 736 TYPE_PROVIDER, 737 }) 738 @Retention(RetentionPolicy.SOURCE) 739 public @interface ComponentType {} 740 741 /** @hide */ 742 @IntDef(prefix = { "TYPE_" }, value = { 743 TYPE_UNKNOWN, 744 TYPE_ACTIVITY, 745 TYPE_RECEIVER, 746 TYPE_SERVICE, 747 TYPE_PROVIDER, 748 TYPE_APPLICATION, 749 }) 750 @Retention(RetentionPolicy.SOURCE) 751 public @interface PropertyLocation {} 752 753 /** 754 * As a guiding principle: 755 * <p> 756 * {@code GET_} flags are used to request additional data that may have been 757 * elided to save wire space. 758 * <p> 759 * {@code MATCH_} flags are used to include components or packages that 760 * would have otherwise been omitted from a result set by current system 761 * state. 762 */ 763 764 /** @hide */ 765 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 766 GET_ACTIVITIES, 767 GET_CONFIGURATIONS, 768 GET_GIDS, 769 GET_INSTRUMENTATION, 770 GET_INTENT_FILTERS, 771 GET_META_DATA, 772 GET_PERMISSIONS, 773 GET_PROVIDERS, 774 GET_RECEIVERS, 775 GET_SERVICES, 776 GET_SHARED_LIBRARY_FILES, 777 GET_SIGNATURES, 778 GET_SIGNING_CERTIFICATES, 779 GET_URI_PERMISSION_PATTERNS, 780 MATCH_UNINSTALLED_PACKAGES, 781 MATCH_DISABLED_COMPONENTS, 782 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 783 MATCH_SYSTEM_ONLY, 784 MATCH_FACTORY_ONLY, 785 MATCH_ANY_USER, 786 MATCH_DEBUG_TRIAGED_MISSING, 787 MATCH_INSTANT, 788 MATCH_APEX, 789 GET_DISABLED_COMPONENTS, 790 GET_DISABLED_UNTIL_USED_COMPONENTS, 791 GET_UNINSTALLED_PACKAGES, 792 MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS, 793 GET_ATTRIBUTIONS_LONG, 794 }) 795 @Retention(RetentionPolicy.SOURCE) 796 public @interface PackageInfoFlagsBits {} 797 798 /** @hide */ 799 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 800 GET_META_DATA, 801 GET_SHARED_LIBRARY_FILES, 802 MATCH_UNINSTALLED_PACKAGES, 803 MATCH_SYSTEM_ONLY, 804 MATCH_DEBUG_TRIAGED_MISSING, 805 MATCH_DISABLED_COMPONENTS, 806 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 807 MATCH_INSTANT, 808 MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, 809 GET_DISABLED_UNTIL_USED_COMPONENTS, 810 GET_UNINSTALLED_PACKAGES, 811 MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS, 812 MATCH_APEX, 813 }) 814 @Retention(RetentionPolicy.SOURCE) 815 public @interface ApplicationInfoFlagsBits {} 816 817 /** @hide */ 818 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 819 GET_META_DATA, 820 GET_SHARED_LIBRARY_FILES, 821 MATCH_ALL, 822 MATCH_DEBUG_TRIAGED_MISSING, 823 MATCH_DEFAULT_ONLY, 824 MATCH_DISABLED_COMPONENTS, 825 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 826 MATCH_DIRECT_BOOT_AUTO, 827 MATCH_DIRECT_BOOT_AWARE, 828 MATCH_DIRECT_BOOT_UNAWARE, 829 MATCH_SYSTEM_ONLY, 830 MATCH_UNINSTALLED_PACKAGES, 831 MATCH_INSTANT, 832 MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, 833 GET_DISABLED_COMPONENTS, 834 GET_DISABLED_UNTIL_USED_COMPONENTS, 835 GET_UNINSTALLED_PACKAGES, 836 }) 837 @Retention(RetentionPolicy.SOURCE) 838 public @interface ComponentInfoFlagsBits {} 839 840 /** @hide */ 841 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 842 GET_META_DATA, 843 GET_RESOLVED_FILTER, 844 GET_SHARED_LIBRARY_FILES, 845 MATCH_ALL, 846 MATCH_DEBUG_TRIAGED_MISSING, 847 MATCH_DISABLED_COMPONENTS, 848 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 849 MATCH_DEFAULT_ONLY, 850 MATCH_DIRECT_BOOT_AUTO, 851 MATCH_DIRECT_BOOT_AWARE, 852 MATCH_DIRECT_BOOT_UNAWARE, 853 MATCH_SYSTEM_ONLY, 854 MATCH_UNINSTALLED_PACKAGES, 855 MATCH_INSTANT, 856 GET_DISABLED_COMPONENTS, 857 GET_DISABLED_UNTIL_USED_COMPONENTS, 858 GET_UNINSTALLED_PACKAGES, 859 MATCH_CLONE_PROFILE 860 }) 861 @Retention(RetentionPolicy.SOURCE) 862 public @interface ResolveInfoFlagsBits {} 863 864 /** @hide */ 865 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 866 MATCH_ALL, 867 }) 868 @Retention(RetentionPolicy.SOURCE) 869 public @interface InstalledModulesFlags {} 870 871 /** @hide */ 872 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 873 GET_META_DATA, 874 }) 875 @Retention(RetentionPolicy.SOURCE) 876 public @interface PermissionInfoFlags {} 877 878 /** @hide */ 879 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 880 GET_META_DATA, 881 }) 882 @Retention(RetentionPolicy.SOURCE) 883 public @interface PermissionGroupInfoFlags {} 884 885 /** @hide */ 886 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 887 GET_META_DATA, 888 }) 889 @Retention(RetentionPolicy.SOURCE) 890 public @interface InstrumentationInfoFlags {} 891 892 /** 893 * {@link PackageInfo} flag: return information about 894 * activities in the package in {@link PackageInfo#activities}. 895 */ 896 public static final int GET_ACTIVITIES = 0x00000001; 897 898 /** 899 * {@link PackageInfo} flag: return information about 900 * intent receivers in the package in 901 * {@link PackageInfo#receivers}. 902 */ 903 public static final int GET_RECEIVERS = 0x00000002; 904 905 /** 906 * {@link PackageInfo} flag: return information about 907 * services in the package in {@link PackageInfo#services}. 908 */ 909 public static final int GET_SERVICES = 0x00000004; 910 911 /** 912 * {@link PackageInfo} flag: return information about 913 * content providers in the package in 914 * {@link PackageInfo#providers}. 915 */ 916 public static final int GET_PROVIDERS = 0x00000008; 917 918 /** 919 * {@link PackageInfo} flag: return information about 920 * instrumentation in the package in 921 * {@link PackageInfo#instrumentation}. 922 */ 923 public static final int GET_INSTRUMENTATION = 0x00000010; 924 925 /** 926 * {@link PackageInfo} flag: return information about the 927 * intent filters supported by the activity. 928 * 929 * @deprecated The platform does not support getting {@link IntentFilter}s for the package. 930 */ 931 @Deprecated 932 public static final int GET_INTENT_FILTERS = 0x00000020; 933 934 /** 935 * {@link PackageInfo} flag: return information about the 936 * signatures included in the package. 937 * 938 * @deprecated use {@code GET_SIGNING_CERTIFICATES} instead 939 */ 940 @Deprecated 941 public static final int GET_SIGNATURES = 0x00000040; 942 943 /** 944 * {@link ResolveInfo} flag: return the IntentFilter that 945 * was matched for a particular ResolveInfo in 946 * {@link ResolveInfo#filter}. 947 */ 948 public static final int GET_RESOLVED_FILTER = 0x00000040; 949 950 /** 951 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData} 952 * data {@link android.os.Bundle}s that are associated with a component. 953 * This applies for any API returning a ComponentInfo subclass. 954 */ 955 public static final int GET_META_DATA = 0x00000080; 956 957 /** 958 * {@link PackageInfo} flag: return the 959 * {@link PackageInfo#gids group ids} that are associated with an 960 * application. 961 * This applies for any API returning a PackageInfo class, either 962 * directly or nested inside of another. 963 */ 964 public static final int GET_GIDS = 0x00000100; 965 966 /** 967 * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS} 968 */ 969 @Deprecated 970 public static final int GET_DISABLED_COMPONENTS = 0x00000200; 971 972 /** 973 * {@link PackageInfo} flag: include disabled components in the returned info. 974 */ 975 public static final int MATCH_DISABLED_COMPONENTS = 0x00000200; 976 977 /** 978 * {@link ApplicationInfo} flag: return the 979 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries} 980 * that are associated with an application. 981 * This applies for any API returning an ApplicationInfo class, either 982 * directly or nested inside of another. 983 */ 984 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400; 985 986 /** 987 * {@link ProviderInfo} flag: return the 988 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns} 989 * that are associated with a content provider. 990 * This applies for any API returning a ProviderInfo class, either 991 * directly or nested inside of another. 992 */ 993 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800; 994 /** 995 * {@link PackageInfo} flag: return information about 996 * permissions in the package in 997 * {@link PackageInfo#permissions}. 998 */ 999 public static final int GET_PERMISSIONS = 0x00001000; 1000 1001 /** 1002 * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES} 1003 */ 1004 @Deprecated 1005 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000; 1006 1007 /** 1008 * Flag parameter to retrieve some information about all applications (even 1009 * uninstalled ones) which have data directories. This state could have 1010 * resulted if applications have been deleted with flag 1011 * {@code DELETE_KEEP_DATA} with a possibility of being replaced or 1012 * reinstalled in future. 1013 * <p> 1014 * Note: this flag may cause less information about currently installed 1015 * applications to be returned. 1016 * <p> 1017 * Note: use of this flag requires the android.permission.QUERY_ALL_PACKAGES 1018 * permission to see uninstalled packages. 1019 */ 1020 public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000; 1021 1022 /** 1023 * {@link PackageInfo} flag: return information about 1024 * hardware preferences in 1025 * {@link PackageInfo#configPreferences PackageInfo.configPreferences}, 1026 * and requested features in {@link PackageInfo#reqFeatures} and 1027 * {@link PackageInfo#featureGroups}. 1028 */ 1029 public static final int GET_CONFIGURATIONS = 0x00004000; 1030 1031 /** 1032 * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}. 1033 */ 1034 @Deprecated 1035 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 1036 1037 /** 1038 * {@link PackageInfo} flag: include disabled components which are in 1039 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED} 1040 * in the returned info. Note that if you set this flag, applications 1041 * that are in this disabled state will be reported as enabled. 1042 */ 1043 public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 1044 1045 /** 1046 * Resolution and querying flag: if set, only filters that support the 1047 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for 1048 * matching. This is a synonym for including the CATEGORY_DEFAULT in your 1049 * supplied Intent. 1050 */ 1051 public static final int MATCH_DEFAULT_ONLY = 0x00010000; 1052 1053 /** 1054 * Querying flag: if set and if the platform is doing any filtering of the 1055 * results, then the filtering will not happen. This is a synonym for saying 1056 * that all results should be returned. 1057 * <p> 1058 * <em>This flag should be used with extreme care.</em> 1059 */ 1060 public static final int MATCH_ALL = 0x00020000; 1061 1062 /** 1063 * Querying flag: match components which are direct boot <em>unaware</em> in 1064 * the returned info, regardless of the current user state. 1065 * <p> 1066 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor 1067 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is 1068 * to match only runnable components based on the user state. For example, 1069 * when a user is started but credentials have not been presented yet, the 1070 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE} 1071 * components are returned. Once the user credentials have been presented, 1072 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE} 1073 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned. 1074 * 1075 * @see UserManager#isUserUnlocked() 1076 */ 1077 public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000; 1078 1079 /** 1080 * Querying flag: match components which are direct boot <em>aware</em> in 1081 * the returned info, regardless of the current user state. 1082 * <p> 1083 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor 1084 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is 1085 * to match only runnable components based on the user state. For example, 1086 * when a user is started but credentials have not been presented yet, the 1087 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE} 1088 * components are returned. Once the user credentials have been presented, 1089 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE} 1090 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned. 1091 * 1092 * @see UserManager#isUserUnlocked() 1093 */ 1094 public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000; 1095 1096 /** 1097 * Querying flag: include only components from applications that are marked 1098 * with {@link ApplicationInfo#FLAG_SYSTEM}. 1099 */ 1100 public static final int MATCH_SYSTEM_ONLY = 0x00100000; 1101 1102 /** 1103 * Internal {@link PackageInfo} flag: include only components on the system image. 1104 * This will not return information on any unbundled update to system components. 1105 * @hide 1106 */ 1107 @SystemApi 1108 public static final int MATCH_FACTORY_ONLY = 0x00200000; 1109 1110 /** 1111 * Allows querying of packages installed for any user, not just the specific one. This flag 1112 * is only meant for use by apps that have INTERACT_ACROSS_USERS permission. 1113 * @hide 1114 */ 1115 @SystemApi 1116 public static final int MATCH_ANY_USER = 0x00400000; 1117 1118 /** 1119 * Combination of MATCH_ANY_USER and MATCH_UNINSTALLED_PACKAGES to mean any known 1120 * package. 1121 * @hide 1122 */ 1123 @TestApi 1124 public static final int MATCH_KNOWN_PACKAGES = MATCH_UNINSTALLED_PACKAGES | MATCH_ANY_USER; 1125 1126 /** 1127 * Internal {@link PackageInfo} flag: include components that are part of an 1128 * instant app. By default, instant app components are not matched. 1129 * @hide 1130 */ 1131 @SystemApi 1132 public static final int MATCH_INSTANT = 0x00800000; 1133 1134 /** 1135 * Internal {@link PackageInfo} flag: include only components that are exposed to 1136 * instant apps. Matched components may have been either explicitly or implicitly 1137 * exposed. 1138 * @hide 1139 */ 1140 public static final int MATCH_VISIBLE_TO_INSTANT_APP_ONLY = 0x01000000; 1141 1142 /** 1143 * Internal {@link PackageInfo} flag: include only components that have been 1144 * explicitly exposed to instant apps. 1145 * @hide 1146 */ 1147 public static final int MATCH_EXPLICITLY_VISIBLE_ONLY = 0x02000000; 1148 1149 /** 1150 * Internal {@link PackageInfo} flag: include static shared and SDK libraries. 1151 * Apps that depend on static shared/SDK libs can always access the version 1152 * of the lib they depend on. System/shell/root can access all shared 1153 * libs regardless of dependency but need to explicitly ask for them 1154 * via this flag. 1155 * @hide 1156 */ 1157 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 1158 public static final int MATCH_STATIC_SHARED_AND_SDK_LIBRARIES = 0x04000000; 1159 1160 /** 1161 * {@link PackageInfo} flag: return the signing certificates associated with 1162 * this package. Each entry is a signing certificate that the package 1163 * has proven it is authorized to use, usually a past signing certificate from 1164 * which it has rotated. 1165 */ 1166 public static final int GET_SIGNING_CERTIFICATES = 0x08000000; 1167 1168 /** 1169 * Querying flag: automatically match components based on their Direct Boot 1170 * awareness and the current user state. 1171 * <p> 1172 * Since the default behavior is to automatically apply the current user 1173 * state, this is effectively a sentinel value that doesn't change the 1174 * output of any queries based on its presence or absence. 1175 * <p> 1176 * Instead, this value can be useful in conjunction with 1177 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()} 1178 * to detect when a caller is relying on implicit automatic matching, 1179 * instead of confirming the explicit behavior they want, using a 1180 * combination of these flags: 1181 * <ul> 1182 * <li>{@link #MATCH_DIRECT_BOOT_AWARE} 1183 * <li>{@link #MATCH_DIRECT_BOOT_UNAWARE} 1184 * <li>{@link #MATCH_DIRECT_BOOT_AUTO} 1185 * </ul> 1186 */ 1187 public static final int MATCH_DIRECT_BOOT_AUTO = 0x10000000; 1188 1189 /** 1190 * {@link ResolveInfo} flag: allow matching components across clone profile 1191 * <p> 1192 * This flag is used only for query and not resolution, the default behaviour would be to 1193 * restrict querying across clone profile. This flag would be honored only if caller have 1194 * permission {@link Manifest.permission.QUERY_CLONED_APPS}. 1195 * 1196 * @hide 1197 * <p> 1198 */ 1199 @SystemApi 1200 public static final int MATCH_CLONE_PROFILE = 0x20000000; 1201 1202 /** 1203 * @deprecated Use {@link #GET_ATTRIBUTIONS_LONG} to avoid unintended sign extension. 1204 */ 1205 @Deprecated 1206 public static final int GET_ATTRIBUTIONS = 0x80000000; 1207 1208 /** @hide */ 1209 @Deprecated 1210 public static final int MATCH_DEBUG_TRIAGED_MISSING = MATCH_DIRECT_BOOT_AUTO; 1211 1212 /** 1213 * {@link PackageInfo} flag: include system apps that are in the uninstalled state and have 1214 * been set to be hidden until installed via {@link #setSystemAppState}. 1215 * @hide 1216 */ 1217 @SystemApi 1218 public static final int MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS = 0x20000000; 1219 1220 /** 1221 * {@link PackageInfo} flag: include APEX packages that are currently 1222 * installed. In APEX terminology, this corresponds to packages that are 1223 * currently active, i.e. mounted and available to other processes of the OS. 1224 * In particular, this flag alone will not match APEX files that are staged 1225 * for activation at next reboot. 1226 */ 1227 public static final int MATCH_APEX = 0x40000000; 1228 1229 /** 1230 * {@link PackageInfo} flag: return all attributions declared in the package manifest 1231 */ 1232 public static final long GET_ATTRIBUTIONS_LONG = 0x80000000L; 1233 1234 /** 1235 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when 1236 * resolving an intent that matches the {@code CrossProfileIntentFilter}, 1237 * the current profile will be skipped. Only activities in the target user 1238 * can respond to the intent. 1239 * 1240 * @hide 1241 */ 1242 public static final int SKIP_CURRENT_PROFILE = 0x00000002; 1243 1244 /** 1245 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: 1246 * activities in the other profiles can respond to the intent only if no activity with 1247 * non-negative priority in current profile can respond to the intent. 1248 * @hide 1249 */ 1250 public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004; 1251 1252 /** @hide */ 1253 @IntDef(flag = true, prefix = { "MODULE_" }, value = { 1254 MODULE_APEX_NAME, 1255 }) 1256 @Retention(RetentionPolicy.SOURCE) 1257 public @interface ModuleInfoFlags {} 1258 1259 /** 1260 * Flag for {@link #getModuleInfo}: allow ModuleInfo to be retrieved using the apex module 1261 * name, rather than the package name. 1262 * 1263 * @hide 1264 */ 1265 @SystemApi 1266 public static final int MODULE_APEX_NAME = 0x00000001; 1267 1268 /** @hide */ 1269 @IntDef(prefix = { "PERMISSION_" }, value = { 1270 PERMISSION_GRANTED, 1271 PERMISSION_DENIED 1272 }) 1273 @Retention(RetentionPolicy.SOURCE) 1274 public @interface PermissionResult {} 1275 1276 /** 1277 * Permission check result: this is returned by {@link #checkPermission} 1278 * if the permission has been granted to the given package. 1279 */ 1280 public static final int PERMISSION_GRANTED = 0; 1281 1282 /** 1283 * Permission check result: this is returned by {@link #checkPermission} 1284 * if the permission has not been granted to the given package. 1285 */ 1286 public static final int PERMISSION_DENIED = -1; 1287 1288 /** @hide */ 1289 @IntDef(prefix = { "SIGNATURE_" }, value = { 1290 SIGNATURE_MATCH, 1291 SIGNATURE_NEITHER_SIGNED, 1292 SIGNATURE_FIRST_NOT_SIGNED, 1293 SIGNATURE_SECOND_NOT_SIGNED, 1294 SIGNATURE_NO_MATCH, 1295 SIGNATURE_UNKNOWN_PACKAGE, 1296 }) 1297 @Retention(RetentionPolicy.SOURCE) 1298 public @interface SignatureResult {} 1299 1300 /** 1301 * Signature check result: this is returned by {@link #checkSignatures} 1302 * if all signatures on the two packages match. 1303 */ 1304 public static final int SIGNATURE_MATCH = 0; 1305 1306 /** 1307 * Signature check result: this is returned by {@link #checkSignatures} 1308 * if neither of the two packages is signed. 1309 */ 1310 public static final int SIGNATURE_NEITHER_SIGNED = 1; 1311 1312 /** 1313 * Signature check result: this is returned by {@link #checkSignatures} 1314 * if the first package is not signed but the second is. 1315 */ 1316 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1; 1317 1318 /** 1319 * Signature check result: this is returned by {@link #checkSignatures} 1320 * if the second package is not signed but the first is. 1321 */ 1322 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2; 1323 1324 /** 1325 * Signature check result: this is returned by {@link #checkSignatures} 1326 * if not all signatures on both packages match. 1327 */ 1328 public static final int SIGNATURE_NO_MATCH = -3; 1329 1330 /** 1331 * Signature check result: this is returned by {@link #checkSignatures} 1332 * if either of the packages are not valid. 1333 */ 1334 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; 1335 1336 /** @hide */ 1337 @IntDef(prefix = { "COMPONENT_ENABLED_STATE_" }, value = { 1338 COMPONENT_ENABLED_STATE_DEFAULT, 1339 COMPONENT_ENABLED_STATE_ENABLED, 1340 COMPONENT_ENABLED_STATE_DISABLED, 1341 COMPONENT_ENABLED_STATE_DISABLED_USER, 1342 COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED, 1343 }) 1344 @Retention(RetentionPolicy.SOURCE) 1345 public @interface EnabledState {} 1346 1347 /** 1348 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and 1349 * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 1350 * component or application is in its default enabled state (as specified in 1351 * its manifest). 1352 * <p> 1353 * Explicitly setting the component state to this value restores it's 1354 * enabled state to whatever is set in the manifest. 1355 */ 1356 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; 1357 1358 /** 1359 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 1360 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 1361 * component or application has been explictily enabled, regardless of 1362 * what it has specified in its manifest. 1363 */ 1364 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; 1365 1366 /** 1367 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 1368 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 1369 * component or application has been explicitly disabled, regardless of 1370 * what it has specified in its manifest. 1371 */ 1372 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; 1373 1374 /** 1375 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The 1376 * user has explicitly disabled the application, regardless of what it has 1377 * specified in its manifest. Because this is due to the user's request, 1378 * they may re-enable it if desired through the appropriate system UI. This 1379 * option currently <strong>cannot</strong> be used with 1380 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 1381 */ 1382 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; 1383 1384 /** 1385 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This 1386 * application should be considered, until the point where the user actually 1387 * wants to use it. This means that it will not normally show up to the user 1388 * (such as in the launcher), but various parts of the user interface can 1389 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow 1390 * the user to select it (as for example an IME, device admin, etc). Such code, 1391 * once the user has selected the app, should at that point also make it enabled. 1392 * This option currently <strong>can not</strong> be used with 1393 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 1394 */ 1395 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4; 1396 1397 /** @hide */ 1398 @Retention(RetentionPolicy.SOURCE) 1399 @IntDef(prefix = { "ROLLBACK_DATA_POLICY_" }, value = { 1400 ROLLBACK_DATA_POLICY_RESTORE, 1401 ROLLBACK_DATA_POLICY_WIPE, 1402 ROLLBACK_DATA_POLICY_RETAIN 1403 }) 1404 public @interface RollbackDataPolicy {} 1405 1406 /** 1407 * User data will be backed up during install and restored during rollback. 1408 * 1409 * @hide 1410 */ 1411 @SystemApi 1412 public static final int ROLLBACK_DATA_POLICY_RESTORE = 0; 1413 1414 /** 1415 * User data won't be backed up during install but will be wiped out during rollback. 1416 * 1417 * @hide 1418 */ 1419 @SystemApi 1420 public static final int ROLLBACK_DATA_POLICY_WIPE = 1; 1421 1422 /** 1423 * User data won't be backed up during install and will remain unchanged during rollback. 1424 * 1425 * @hide 1426 */ 1427 @SystemApi 1428 public static final int ROLLBACK_DATA_POLICY_RETAIN = 2; 1429 1430 /** @hide */ 1431 @IntDef(flag = true, prefix = { "INSTALL_" }, value = { 1432 INSTALL_REPLACE_EXISTING, 1433 INSTALL_ALLOW_TEST, 1434 INSTALL_INTERNAL, 1435 INSTALL_FROM_ADB, 1436 INSTALL_ALL_USERS, 1437 INSTALL_REQUEST_DOWNGRADE, 1438 INSTALL_GRANT_ALL_REQUESTED_PERMISSIONS, 1439 INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS, 1440 INSTALL_FORCE_VOLUME_UUID, 1441 INSTALL_FORCE_PERMISSION_PROMPT, 1442 INSTALL_INSTANT_APP, 1443 INSTALL_DONT_KILL_APP, 1444 INSTALL_FULL_APP, 1445 INSTALL_ALLOCATE_AGGRESSIVE, 1446 INSTALL_VIRTUAL_PRELOAD, 1447 INSTALL_APEX, 1448 INSTALL_ENABLE_ROLLBACK, 1449 INSTALL_ALLOW_DOWNGRADE, 1450 INSTALL_STAGED, 1451 INSTALL_REQUEST_UPDATE_OWNERSHIP, 1452 }) 1453 @Retention(RetentionPolicy.SOURCE) 1454 public @interface InstallFlags {} 1455 1456 /** 1457 * Flag parameter for {@link #installPackage} to indicate that you want to 1458 * replace an already installed package, if one exists. 1459 * 1460 * @hide 1461 */ 1462 @UnsupportedAppUsage 1463 public static final int INSTALL_REPLACE_EXISTING = 0x00000002; 1464 1465 /** 1466 * Flag parameter for {@link #installPackage} to indicate that you want to 1467 * allow test packages (those that have set android:testOnly in their 1468 * manifest) to be installed. 1469 * @hide 1470 */ 1471 public static final int INSTALL_ALLOW_TEST = 0x00000004; 1472 1473 /** 1474 * Flag parameter for {@link #installPackage} to indicate that this package 1475 * must be installed to internal storage. 1476 * 1477 * @hide 1478 */ 1479 public static final int INSTALL_INTERNAL = 0x00000010; 1480 1481 /** 1482 * Flag parameter for {@link #installPackage} to indicate that this install 1483 * was initiated via ADB. 1484 * 1485 * @hide 1486 */ 1487 public static final int INSTALL_FROM_ADB = 0x00000020; 1488 1489 /** 1490 * Flag parameter for {@link #installPackage} to indicate that this install 1491 * should immediately be visible to all users. 1492 * 1493 * @hide 1494 */ 1495 public static final int INSTALL_ALL_USERS = 0x00000040; 1496 1497 /** 1498 * Flag parameter for {@link #installPackage} to indicate that an upgrade to a lower version 1499 * of a package than currently installed has been requested. 1500 * 1501 * <p>Note that this flag doesn't guarantee that downgrade will be performed. That decision 1502 * depends 1503 * on whenever: 1504 * <ul> 1505 * <li>An app is debuggable. 1506 * <li>Or a build is debuggable. 1507 * <li>Or {@link #INSTALL_ALLOW_DOWNGRADE} is set. 1508 * </ul> 1509 * 1510 * @hide 1511 */ 1512 public static final int INSTALL_REQUEST_DOWNGRADE = 0x00000080; 1513 1514 /** 1515 * Flag parameter for package install to indicate that all requested permissions should be 1516 * granted to the package. If {@link #INSTALL_ALL_USERS} is set the runtime permissions will 1517 * be granted to all users, otherwise only to the owner. 1518 * <p/> 1519 * If this flag is set, {@link SessionParams#setPermissionState(String, int)} should not be 1520 * called. 1521 * 1522 * @hide 1523 */ 1524 public static final int INSTALL_GRANT_ALL_REQUESTED_PERMISSIONS = 0x00000100; 1525 1526 /** {@hide} */ 1527 public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200; 1528 1529 /** 1530 * Flag parameter for {@link #installPackage} to indicate that we always want to force 1531 * the prompt for permission approval. This overrides any special behaviour for internal 1532 * components. 1533 * 1534 * @hide 1535 */ 1536 public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400; 1537 1538 /** 1539 * Flag parameter for {@link #installPackage} to indicate that this package is 1540 * to be installed as a lightweight "ephemeral" app. 1541 * 1542 * @hide 1543 */ 1544 public static final int INSTALL_INSTANT_APP = 0x00000800; 1545 1546 /** 1547 * Flag parameter for {@link #installPackage} to indicate that this package contains 1548 * a feature split to an existing application and the existing application should not 1549 * be killed during the installation process. 1550 * 1551 * @hide 1552 */ 1553 public static final int INSTALL_DONT_KILL_APP = 0x00001000; 1554 1555 /** 1556 * Flag parameter for {@link #installPackage} to indicate that this package is 1557 * to be installed as a heavy weight app. This is fundamentally the opposite of 1558 * {@link #INSTALL_INSTANT_APP}. 1559 * 1560 * @hide 1561 */ 1562 public static final int INSTALL_FULL_APP = 0x00004000; 1563 1564 /** 1565 * Flag parameter for {@link #installPackage} to indicate that this package 1566 * is critical to system health or security, meaning the system should use 1567 * {@link StorageManager#FLAG_ALLOCATE_AGGRESSIVE} internally. 1568 * 1569 * @hide 1570 */ 1571 public static final int INSTALL_ALLOCATE_AGGRESSIVE = 0x00008000; 1572 1573 /** 1574 * Flag parameter for {@link #installPackage} to indicate that this package 1575 * is a virtual preload. 1576 * 1577 * @hide 1578 */ 1579 public static final int INSTALL_VIRTUAL_PRELOAD = 0x00010000; 1580 1581 /** 1582 * Flag parameter for {@link #installPackage} to indicate that this package 1583 * is an APEX package 1584 * 1585 * @hide 1586 */ 1587 public static final int INSTALL_APEX = 0x00020000; 1588 1589 /** 1590 * Flag parameter for {@link #installPackage} to indicate that rollback 1591 * should be enabled for this install. 1592 * 1593 * @hide 1594 */ 1595 public static final int INSTALL_ENABLE_ROLLBACK = 0x00040000; 1596 1597 /** 1598 * Flag parameter for {@link #installPackage} to indicate that package verification should be 1599 * disabled for this package. 1600 * 1601 * @hide 1602 */ 1603 public static final int INSTALL_DISABLE_VERIFICATION = 0x00080000; 1604 1605 /** 1606 * Flag parameter for {@link #installPackage} to indicate that 1607 * {@link #INSTALL_REQUEST_DOWNGRADE} should be allowed. 1608 * 1609 * @hide 1610 */ 1611 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00100000; 1612 1613 /** 1614 * Flag parameter for {@link #installPackage} to indicate that this package 1615 * is being installed as part of a staged install. 1616 * 1617 * @hide 1618 */ 1619 public static final int INSTALL_STAGED = 0x00200000; 1620 1621 /** 1622 * Flag parameter for {@link #installPackage} to indicate that all restricted 1623 * permissions should be allowlisted. If {@link #INSTALL_ALL_USERS} 1624 * is set the restricted permissions will be allowlisted for all users, otherwise 1625 * only to the owner. 1626 * 1627 * <p> 1628 * <strong>Note: </strong>In retrospect it would have been preferred to use 1629 * more inclusive terminology when naming this API. Similar APIs added will 1630 * refrain from using the term "whitelist". 1631 * </p> 1632 * 1633 * @hide 1634 */ 1635 public static final int INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS = 0x00400000; 1636 1637 /** 1638 * Flag parameter for {@link #installPackage} to indicate that check whether given APEX can be 1639 * updated should be disabled for this install. 1640 * @hide 1641 */ 1642 public static final int INSTALL_DISABLE_ALLOWED_APEX_UPDATE_CHECK = 0x00800000; 1643 1644 /** 1645 * Flag parameter for {@link #installPackage} to bypass the low targer sdk version block 1646 * for this install. 1647 * 1648 * @hide 1649 */ 1650 public static final int INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK = 0x01000000; 1651 1652 /** 1653 * Flag parameter for {@link SessionParams} to indicate that the 1654 * update ownership enforcement is requested. 1655 * @hide 1656 */ 1657 public static final int INSTALL_REQUEST_UPDATE_OWNERSHIP = 1 << 25; 1658 1659 /** 1660 * Flag parameter for {@link PackageInstaller.SessionParams} to indicate that this 1661 * session is from a managed user or profile. 1662 * @hide 1663 */ 1664 public static final int INSTALL_FROM_MANAGED_USER_OR_PROFILE = 1 << 26; 1665 1666 /** @hide */ 1667 @IntDef(flag = true, value = { 1668 DONT_KILL_APP, 1669 SYNCHRONOUS 1670 }) 1671 @Retention(RetentionPolicy.SOURCE) 1672 public @interface EnabledFlags {} 1673 1674 /** 1675 * Flag parameter for 1676 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 1677 * that you don't want to kill the app containing the component. Be careful when you set this 1678 * since changing component states can make the containing application's behavior unpredictable. 1679 */ 1680 public static final int DONT_KILL_APP = 0x00000001; 1681 1682 /** 1683 * Flag parameter for 1684 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 1685 * that the given user's package restrictions state will be serialised to disk after the 1686 * component state has been updated. Note that this is synchronous disk access, so calls using 1687 * this flag should be run on a background thread. 1688 */ 1689 public static final int SYNCHRONOUS = 0x00000002; 1690 1691 /** @hide */ 1692 @IntDef(prefix = { "INSTALL_REASON_" }, value = { 1693 INSTALL_REASON_UNKNOWN, 1694 INSTALL_REASON_POLICY, 1695 INSTALL_REASON_DEVICE_RESTORE, 1696 INSTALL_REASON_DEVICE_SETUP, 1697 INSTALL_REASON_USER, 1698 INSTALL_REASON_ROLLBACK 1699 }) 1700 @Retention(RetentionPolicy.SOURCE) 1701 public @interface InstallReason {} 1702 1703 /** 1704 * Code indicating that the reason for installing this package is unknown. 1705 */ 1706 public static final int INSTALL_REASON_UNKNOWN = 0; 1707 1708 /** 1709 * Code indicating that this package was installed due to enterprise policy. 1710 */ 1711 public static final int INSTALL_REASON_POLICY = 1; 1712 1713 /** 1714 * Code indicating that this package was installed as part of restoring from another device. 1715 */ 1716 public static final int INSTALL_REASON_DEVICE_RESTORE = 2; 1717 1718 /** 1719 * Code indicating that this package was installed as part of device setup. 1720 */ 1721 public static final int INSTALL_REASON_DEVICE_SETUP = 3; 1722 1723 /** 1724 * Code indicating that the package installation was initiated by the user. 1725 */ 1726 public static final int INSTALL_REASON_USER = 4; 1727 1728 /** 1729 * Code indicating that the package installation was a rollback initiated by RollbackManager. 1730 * 1731 * @hide 1732 */ 1733 public static final int INSTALL_REASON_ROLLBACK = 5; 1734 1735 /** @hide */ 1736 @IntDef(prefix = { "INSTALL_SCENARIO_" }, value = { 1737 INSTALL_SCENARIO_DEFAULT, 1738 INSTALL_SCENARIO_FAST, 1739 INSTALL_SCENARIO_BULK, 1740 INSTALL_SCENARIO_BULK_SECONDARY, 1741 }) 1742 @Retention(RetentionPolicy.SOURCE) 1743 public @interface InstallScenario {} 1744 1745 /** 1746 * A value to indicate the lack of CUJ information, disabling all installation scenario logic. 1747 */ 1748 public static final int INSTALL_SCENARIO_DEFAULT = 0; 1749 1750 /** 1751 * Installation scenario providing the fastest “install button to launch" experience possible. 1752 */ 1753 public static final int INSTALL_SCENARIO_FAST = 1; 1754 1755 /** 1756 * Installation scenario indicating a bulk operation with the desired result of a fully 1757 * optimized application. If the system is busy or resources are scarce the system will 1758 * perform less work to avoid impacting system health. 1759 * 1760 * Examples of bulk installation scenarios might include device restore, background updates of 1761 * multiple applications, or user-triggered updates for all applications. 1762 * 1763 * The decision to use BULK or BULK_SECONDARY should be based on the desired user experience. 1764 * BULK_SECONDARY operations may take less time to complete but, when they do, will produce 1765 * less optimized applications. The device state (e.g. memory usage or battery status) should 1766 * not be considered when making this decision as those factors are taken into account by the 1767 * Package Manager when acting on the installation scenario. 1768 */ 1769 public static final int INSTALL_SCENARIO_BULK = 2; 1770 1771 /** 1772 * Installation scenario indicating a bulk operation that prioritizes minimal system health 1773 * impact over application optimization. The application may undergo additional optimization 1774 * if the system is idle and system resources are abundant. The more elements of a bulk 1775 * operation that are marked BULK_SECONDARY, the faster the entire bulk operation will be. 1776 * 1777 * See the comments for INSTALL_SCENARIO_BULK for more information. 1778 */ 1779 public static final int INSTALL_SCENARIO_BULK_SECONDARY = 3; 1780 1781 /** @hide */ 1782 @IntDef(prefix = { "UNINSTALL_REASON_" }, value = { 1783 UNINSTALL_REASON_UNKNOWN, 1784 UNINSTALL_REASON_USER_TYPE, 1785 }) 1786 @Retention(RetentionPolicy.SOURCE) 1787 public @interface UninstallReason {} 1788 1789 /** 1790 * Code indicating that the reason for uninstalling this package is unknown. 1791 * @hide 1792 */ 1793 public static final int UNINSTALL_REASON_UNKNOWN = 0; 1794 1795 /** 1796 * Code indicating that this package was uninstalled due to the type of user. 1797 * See UserSystemPackageInstaller 1798 * @hide 1799 */ 1800 public static final int UNINSTALL_REASON_USER_TYPE = 1; 1801 1802 /** 1803 * @hide 1804 */ 1805 public static final int INSTALL_UNKNOWN = 0; 1806 1807 /** 1808 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1809 * on success. 1810 * 1811 * @hide 1812 */ 1813 @SystemApi 1814 public static final int INSTALL_SUCCEEDED = 1; 1815 1816 /** 1817 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1818 * if the package is already installed. 1819 * 1820 * @hide 1821 */ 1822 @SystemApi 1823 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; 1824 1825 /** 1826 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1827 * if the package archive file is invalid. 1828 * 1829 * @hide 1830 */ 1831 @SystemApi 1832 public static final int INSTALL_FAILED_INVALID_APK = -2; 1833 1834 /** 1835 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1836 * if the URI passed in is invalid. 1837 * 1838 * @hide 1839 */ 1840 @SystemApi 1841 public static final int INSTALL_FAILED_INVALID_URI = -3; 1842 1843 /** 1844 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1845 * if the package manager service found that the device didn't have enough storage space to 1846 * install the app. 1847 * 1848 * @hide 1849 */ 1850 @SystemApi 1851 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; 1852 1853 /** 1854 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1855 * if a package is already installed with the same name. 1856 * 1857 * @hide 1858 */ 1859 @SystemApi 1860 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; 1861 1862 /** 1863 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1864 * if the requested shared user does not exist. 1865 * 1866 * @hide 1867 */ 1868 @SystemApi 1869 public static final int INSTALL_FAILED_NO_SHARED_USER = -6; 1870 1871 /** 1872 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1873 * if a previously installed package of the same name has a different signature than the new 1874 * package (and the old package's data was not removed). 1875 * 1876 * @hide 1877 */ 1878 @SystemApi 1879 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; 1880 1881 /** 1882 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1883 * if the new package is requested a shared user which is already installed on the device and 1884 * does not have matching signature. 1885 * 1886 * @hide 1887 */ 1888 @SystemApi 1889 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; 1890 1891 /** 1892 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1893 * if the new package uses a shared library that is not available. 1894 * 1895 * @hide 1896 */ 1897 @SystemApi 1898 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; 1899 1900 /** 1901 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1902 * when the package being replaced is a system app and the caller didn't provide the 1903 * {@link #DELETE_SYSTEM_APP} flag. 1904 * 1905 * @hide 1906 */ 1907 @SystemApi 1908 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; 1909 1910 /** 1911 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1912 * if the new package failed while optimizing and validating its dex files, either because there 1913 * was not enough storage or the validation failed. 1914 * 1915 * @hide 1916 */ 1917 @SystemApi 1918 public static final int INSTALL_FAILED_DEXOPT = -11; 1919 1920 /** 1921 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1922 * if the new package failed because the current SDK version is older than that required by the 1923 * package. 1924 * 1925 * @hide 1926 */ 1927 @SystemApi 1928 public static final int INSTALL_FAILED_OLDER_SDK = -12; 1929 1930 /** 1931 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1932 * if the new package failed because it contains a content provider with the same authority as a 1933 * provider already installed in the system. 1934 * 1935 * @hide 1936 */ 1937 @SystemApi 1938 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 1939 1940 /** 1941 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1942 * if the new package failed because the current SDK version is newer than that required by the 1943 * package. 1944 * 1945 * @hide 1946 */ 1947 @SystemApi 1948 public static final int INSTALL_FAILED_NEWER_SDK = -14; 1949 1950 /** 1951 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1952 * if the new package failed because it has specified that it is a test-only package and the 1953 * caller has not supplied the {@link #INSTALL_ALLOW_TEST} flag. 1954 * 1955 * @hide 1956 */ 1957 @SystemApi 1958 public static final int INSTALL_FAILED_TEST_ONLY = -15; 1959 1960 /** 1961 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1962 * if the package being installed contains native code, but none that is compatible with the 1963 * device's CPU_ABI. 1964 * 1965 * @hide 1966 */ 1967 @SystemApi 1968 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; 1969 1970 /** 1971 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1972 * if the new package uses a feature that is not available. 1973 * 1974 * @hide 1975 */ 1976 @SystemApi 1977 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 1978 1979 // ------ Errors related to sdcard 1980 /** 1981 * Installation return code: this is passed in the 1982 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if a secure container mount point couldn't be 1983 * accessed on external media. 1984 * 1985 * @hide 1986 */ 1987 @SystemApi 1988 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; 1989 1990 /** 1991 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 1992 * if the new package couldn't be installed in the specified install location. 1993 * 1994 * @hide 1995 */ 1996 @SystemApi 1997 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; 1998 1999 /** 2000 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2001 * if the new package couldn't be installed in the specified install location because the media 2002 * is not available. 2003 * 2004 * @hide 2005 */ 2006 @SystemApi 2007 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; 2008 2009 /** 2010 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2011 * if the new package couldn't be installed because the verification timed out. 2012 * 2013 * @hide 2014 */ 2015 @SystemApi 2016 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; 2017 2018 /** 2019 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2020 * if the new package couldn't be installed because the verification did not succeed. 2021 * 2022 * @hide 2023 */ 2024 @SystemApi 2025 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; 2026 2027 /** 2028 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2029 * if the package changed from what the calling program expected. 2030 * 2031 * @hide 2032 */ 2033 @SystemApi 2034 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; 2035 2036 /** 2037 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2038 * if the new package is assigned a different UID than it previously held. 2039 * 2040 * @hide 2041 */ 2042 public static final int INSTALL_FAILED_UID_CHANGED = -24; 2043 2044 /** 2045 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2046 * if the new package has an older version code than the currently installed package. 2047 * 2048 * @hide 2049 */ 2050 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; 2051 2052 /** 2053 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2054 * if the old package has target SDK high enough to support runtime permission and the new 2055 * package has target SDK low enough to not support runtime permissions. 2056 * 2057 * @hide 2058 */ 2059 @SystemApi 2060 public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26; 2061 2062 /** 2063 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2064 * if the new package attempts to downgrade the target sandbox version of the app. 2065 * 2066 * @hide 2067 */ 2068 @SystemApi 2069 public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27; 2070 2071 /** 2072 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2073 * if the new package requires at least one split and it was not provided. 2074 * 2075 * @hide 2076 */ 2077 public static final int INSTALL_FAILED_MISSING_SPLIT = -28; 2078 2079 /** 2080 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2081 * if the new package targets a deprecated SDK version. 2082 * 2083 * @hide 2084 */ 2085 public static final int INSTALL_FAILED_DEPRECATED_SDK_VERSION = -29; 2086 2087 /** 2088 * Installation parse return code: this is passed in the 2089 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was given a path that is not a 2090 * file, or does not end with the expected '.apk' extension. 2091 * 2092 * @hide 2093 */ 2094 @SystemApi 2095 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; 2096 2097 /** 2098 * Installation parse return code: this is passed in the 2099 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was unable to retrieve the 2100 * AndroidManifest.xml file. 2101 * 2102 * @hide 2103 */ 2104 @SystemApi 2105 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; 2106 2107 /** 2108 * Installation parse return code: this is passed in the 2109 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered an unexpected 2110 * exception. 2111 * 2112 * @hide 2113 */ 2114 @SystemApi 2115 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; 2116 2117 /** 2118 * Installation parse return code: this is passed in the 2119 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any certificates in 2120 * the .apk. 2121 * 2122 * @hide 2123 */ 2124 @SystemApi 2125 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; 2126 2127 /** 2128 * Installation parse return code: this is passed in the 2129 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser found inconsistent certificates on 2130 * the files in the .apk. 2131 * 2132 * @hide 2133 */ 2134 @SystemApi 2135 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; 2136 2137 /** 2138 * Installation parse return code: this is passed in the 2139 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a 2140 * CertificateEncodingException in one of the files in the .apk. 2141 * 2142 * @hide 2143 */ 2144 @SystemApi 2145 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; 2146 2147 /** 2148 * Installation parse return code: this is passed in the 2149 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad or missing 2150 * package name in the manifest. 2151 * 2152 * @hide 2153 */ 2154 @SystemApi 2155 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; 2156 2157 /** 2158 * Installation parse return code: tthis is passed in the 2159 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad shared user id 2160 * name in the manifest. 2161 * 2162 * @hide 2163 */ 2164 @SystemApi 2165 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; 2166 2167 /** 2168 * Installation parse return code: this is passed in the 2169 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered some structural 2170 * problem in the manifest. 2171 * 2172 * @hide 2173 */ 2174 @SystemApi 2175 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; 2176 2177 /** 2178 * Installation parse return code: this is passed in the 2179 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any actionable tags 2180 * (instrumentation or application) in the manifest. 2181 * 2182 * @hide 2183 */ 2184 @SystemApi 2185 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 2186 2187 /** 2188 * Installation failed return code: this is passed in the 2189 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2190 * because of system issues. 2191 * 2192 * @hide 2193 */ 2194 @SystemApi 2195 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; 2196 2197 /** 2198 * Installation failed return code: this is passed in the 2199 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2200 * because the user is restricted from installing apps. 2201 * 2202 * @hide 2203 */ 2204 public static final int INSTALL_FAILED_USER_RESTRICTED = -111; 2205 2206 /** 2207 * Installation failed return code: this is passed in the 2208 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2209 * because it is attempting to define a permission that is already defined by some existing 2210 * package. 2211 * <p> 2212 * The package name of the app which has already defined the permission is passed to a 2213 * {@link PackageInstallObserver}, if any, as the {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string 2214 * extra; and the name of the permission being redefined is passed in the 2215 * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra. 2216 * 2217 * @hide 2218 */ 2219 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; 2220 2221 /** 2222 * Installation failed return code: this is passed in the 2223 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2224 * because its packaged native code did not match any of the ABIs supported by the system. 2225 * 2226 * @hide 2227 */ 2228 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113; 2229 2230 /** 2231 * Internal return code for NativeLibraryHelper methods to indicate that the package 2232 * being processed did not contain any native code. This is placed here only so that 2233 * it can belong to the same value space as the other install failure codes. 2234 * 2235 * @hide 2236 */ 2237 @UnsupportedAppUsage 2238 public static final int NO_NATIVE_LIBRARIES = -114; 2239 2240 /** {@hide} */ 2241 public static final int INSTALL_FAILED_ABORTED = -115; 2242 2243 /** 2244 * Installation failed return code: install type is incompatible with some other 2245 * installation flags supplied for the operation; or other circumstances such as trying 2246 * to upgrade a system app via an Incremental or instant app install. 2247 * @hide 2248 */ 2249 public static final int INSTALL_FAILED_SESSION_INVALID = -116; 2250 2251 /** 2252 * Installation parse return code: this is passed in the 2253 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the dex metadata file is invalid or 2254 * if there was no matching apk file for a dex metadata file. 2255 * 2256 * @hide 2257 */ 2258 public static final int INSTALL_FAILED_BAD_DEX_METADATA = -117; 2259 2260 /** 2261 * Installation parse return code: this is passed in the 2262 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if there is any signature problem. 2263 * 2264 * @hide 2265 */ 2266 public static final int INSTALL_FAILED_BAD_SIGNATURE = -118; 2267 2268 /** 2269 * Installation failed return code: a new staged session was attempted to be committed while 2270 * there is already one in-progress or new session has package that is already staged. 2271 * 2272 * @hide 2273 */ 2274 public static final int INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS = -119; 2275 2276 /** 2277 * Installation failed return code: one of the child sessions does not match the parent session 2278 * in respect to staged or rollback enabled parameters. 2279 * 2280 * @hide 2281 */ 2282 public static final int INSTALL_FAILED_MULTIPACKAGE_INCONSISTENCY = -120; 2283 2284 /** 2285 * Installation failed return code: the required installed version code 2286 * does not match the currently installed package version code. 2287 * 2288 * @hide 2289 */ 2290 public static final int INSTALL_FAILED_WRONG_INSTALLED_VERSION = -121; 2291 2292 /** 2293 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2294 * if the new package failed because it contains a request to use a process that was not 2295 * explicitly defined as part of its <processes> tag. 2296 * 2297 * @hide 2298 */ 2299 public static final int INSTALL_FAILED_PROCESS_NOT_DEFINED = -122; 2300 2301 /** 2302 * Installation failed return code: the {@code resources.arsc} of one of the APKs being 2303 * installed is compressed or not aligned on a 4-byte boundary. Resource tables that cannot be 2304 * memory mapped exert excess memory pressure on the system and drastically slow down 2305 * construction of {@link Resources} objects. 2306 * 2307 * @hide 2308 */ 2309 public static final int INSTALL_PARSE_FAILED_RESOURCES_ARSC_COMPRESSED = -124; 2310 2311 /** 2312 * Installation failed return code: the package was skipped and should be ignored. 2313 * 2314 * The reason for the skip is undefined. 2315 * @hide 2316 */ 2317 public static final int INSTALL_PARSE_FAILED_SKIPPED = -125; 2318 2319 /** 2320 * Installation failed return code: this is passed in the 2321 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2322 * because it is attempting to define a permission group that is already defined by some 2323 * existing package. 2324 * 2325 * @hide 2326 */ 2327 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION_GROUP = -126; 2328 2329 /** 2330 * Installation failed return code: this is passed in the 2331 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2332 * because it is attempting to define a permission in a group that does not exists or that is 2333 * defined by an packages with an incompatible certificate. 2334 * 2335 * @hide 2336 */ 2337 public static final int INSTALL_FAILED_BAD_PERMISSION_GROUP = -127; 2338 2339 /** 2340 * Installation failed return code: an error occurred during the activation phase of this 2341 * session. 2342 * 2343 * @hide 2344 */ 2345 public static final int INSTALL_ACTIVATION_FAILED = -128; 2346 2347 /** 2348 * Installation failed return code: requesting user pre-approval is currently unavailable. 2349 * 2350 * @hide 2351 */ 2352 public static final int INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE = -129; 2353 2354 /** 2355 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2356 * if the new package declares bad certificate digest for a shared library in the package 2357 * manifest. 2358 * 2359 * @hide 2360 */ 2361 public static final int INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST = -130; 2362 2363 /** 2364 * App minimum aspect ratio set by the user which will override app-defined aspect ratio. 2365 * 2366 * @hide 2367 */ 2368 @IntDef(prefix = { "USER_MIN_ASPECT_RATIO_" }, value = { 2369 USER_MIN_ASPECT_RATIO_UNSET, 2370 USER_MIN_ASPECT_RATIO_SPLIT_SCREEN, 2371 USER_MIN_ASPECT_RATIO_DISPLAY_SIZE, 2372 USER_MIN_ASPECT_RATIO_4_3, 2373 USER_MIN_ASPECT_RATIO_16_9, 2374 USER_MIN_ASPECT_RATIO_3_2, 2375 USER_MIN_ASPECT_RATIO_FULLSCREEN, 2376 }) 2377 @Retention(RetentionPolicy.SOURCE) 2378 public @interface UserMinAspectRatio {} 2379 2380 /** 2381 * No aspect ratio override has been set by user. 2382 * 2383 * @hide 2384 */ 2385 public static final int USER_MIN_ASPECT_RATIO_UNSET = 0; 2386 2387 /** 2388 * Aspect ratio override code: user forces app to split screen aspect ratio. This is adjusted to 2389 * half of the screen without the split screen divider. 2390 * 2391 * @hide 2392 */ 2393 public static final int USER_MIN_ASPECT_RATIO_SPLIT_SCREEN = 1; 2394 2395 /** 2396 * Aspect ratio override code: user forces app to the aspect ratio of the device display size. 2397 * This will be the portrait aspect ratio of the device if the app has fixed portrait 2398 * orientation or the landscape aspect ratio of the device if the app has fixed landscape 2399 * orientation. 2400 * 2401 * @hide 2402 */ 2403 public static final int USER_MIN_ASPECT_RATIO_DISPLAY_SIZE = 2; 2404 2405 /** 2406 * Aspect ratio override code: user forces app to 4:3 min aspect ratio 2407 * @hide 2408 */ 2409 public static final int USER_MIN_ASPECT_RATIO_4_3 = 3; 2410 2411 /** 2412 * Aspect ratio override code: user forces app to 16:9 min aspect ratio 2413 * @hide 2414 */ 2415 public static final int USER_MIN_ASPECT_RATIO_16_9 = 4; 2416 2417 /** 2418 * Aspect ratio override code: user forces app to 3:2 min aspect ratio 2419 * @hide 2420 */ 2421 public static final int USER_MIN_ASPECT_RATIO_3_2 = 5; 2422 2423 /** 2424 * Aspect ratio override code: user forces app to fullscreen 2425 * @hide 2426 */ 2427 public static final int USER_MIN_ASPECT_RATIO_FULLSCREEN = 6; 2428 2429 /** @hide */ 2430 @IntDef(flag = true, prefix = { "DELETE_" }, value = { 2431 DELETE_KEEP_DATA, 2432 DELETE_ALL_USERS, 2433 DELETE_SYSTEM_APP, 2434 DELETE_DONT_KILL_APP, 2435 DELETE_CHATTY, 2436 }) 2437 @Retention(RetentionPolicy.SOURCE) 2438 public @interface DeleteFlags {} 2439 2440 /** 2441 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the 2442 * package's data directory. 2443 * 2444 * @hide 2445 */ 2446 @SystemApi 2447 public static final int DELETE_KEEP_DATA = 0x00000001; 2448 2449 /** 2450 * Flag parameter for {@link #deletePackage} to indicate that you want the 2451 * package deleted for all users. 2452 * 2453 * @hide 2454 */ 2455 @SystemApi 2456 public static final int DELETE_ALL_USERS = 0x00000002; 2457 2458 /** 2459 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling 2460 * uninstall on a system that has been updated, then don't do the normal process 2461 * of uninstalling the update and rolling back to the older system version (which 2462 * needs to happen for all users); instead, just mark the app as uninstalled for 2463 * the current user. 2464 * 2465 * @hide 2466 */ 2467 public static final int DELETE_SYSTEM_APP = 0x00000004; 2468 2469 /** 2470 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling 2471 * uninstall on a package that is replaced to provide new feature splits, the 2472 * existing application should not be killed during the removal process. 2473 * 2474 * @hide 2475 */ 2476 public static final int DELETE_DONT_KILL_APP = 0x00000008; 2477 2478 /** 2479 * Flag parameter for {@link #deletePackage} to indicate that package deletion 2480 * should be chatty. 2481 * 2482 * @hide 2483 */ 2484 public static final int DELETE_CHATTY = 0x80000000; 2485 2486 /** 2487 * Return code for when package deletion succeeds. This is passed to the 2488 * {@link IPackageDeleteObserver} if the system succeeded in deleting the 2489 * package. 2490 * 2491 * @hide 2492 */ 2493 @SystemApi 2494 public static final int DELETE_SUCCEEDED = 1; 2495 2496 /** 2497 * Deletion failed return code: this is passed to the 2498 * {@link IPackageDeleteObserver} if the system failed to delete the package 2499 * for an unspecified reason. 2500 * 2501 * @hide 2502 */ 2503 @SystemApi 2504 public static final int DELETE_FAILED_INTERNAL_ERROR = -1; 2505 2506 /** 2507 * Deletion failed return code: this is passed to the 2508 * {@link IPackageDeleteObserver} if the system failed to delete the package 2509 * because it is the active DevicePolicy manager. 2510 * 2511 * @hide 2512 */ 2513 @SystemApi 2514 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; 2515 2516 /** 2517 * Deletion failed return code: this is passed to the 2518 * {@link IPackageDeleteObserver} if the system failed to delete the package 2519 * since the user is restricted. 2520 * 2521 * @hide 2522 */ 2523 public static final int DELETE_FAILED_USER_RESTRICTED = -3; 2524 2525 /** 2526 * Deletion failed return code: this is passed to the 2527 * {@link IPackageDeleteObserver} if the system failed to delete the package 2528 * because a profile or device owner has marked the package as 2529 * uninstallable. 2530 * 2531 * @hide 2532 */ 2533 @SystemApi 2534 public static final int DELETE_FAILED_OWNER_BLOCKED = -4; 2535 2536 /** {@hide} */ 2537 @SystemApi 2538 public static final int DELETE_FAILED_ABORTED = -5; 2539 2540 /** 2541 * Deletion failed return code: this is passed to the 2542 * {@link IPackageDeleteObserver} if the system failed to delete the package 2543 * because the packge is a shared library used by other installed packages. 2544 * {@hide} */ 2545 public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6; 2546 2547 /** 2548 * Deletion failed return code: this is passed to the 2549 * {@link IPackageDeleteObserver} if the system failed to delete the package 2550 * because there is an app pinned. 2551 * 2552 * @hide 2553 */ 2554 public static final int DELETE_FAILED_APP_PINNED = -7; 2555 2556 /** 2557 * Deletion failed return code: this is passed to the 2558 * {@link IPackageDeleteObserver} if the system failed to delete the package 2559 * for any child profile with {@link UserProperties#getDeleteAppWithParent()} as true. 2560 * @hide 2561 */ 2562 public static final int DELETE_FAILED_FOR_CHILD_PROFILE = -8; 2563 2564 /** 2565 * Return code that is passed to the {@link IPackageMoveObserver} when the 2566 * package has been successfully moved by the system. 2567 * 2568 * @hide 2569 */ 2570 public static final int MOVE_SUCCEEDED = -100; 2571 2572 /** 2573 * Error code that is passed to the {@link IPackageMoveObserver} when the 2574 * package hasn't been successfully moved by the system because of 2575 * insufficient memory on specified media. 2576 * 2577 * @hide 2578 */ 2579 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1; 2580 2581 /** 2582 * Error code that is passed to the {@link IPackageMoveObserver} if the 2583 * specified package doesn't exist. 2584 * 2585 * @hide 2586 */ 2587 public static final int MOVE_FAILED_DOESNT_EXIST = -2; 2588 2589 /** 2590 * Error code that is passed to the {@link IPackageMoveObserver} if the 2591 * specified package cannot be moved since its a system package. 2592 * 2593 * @hide 2594 */ 2595 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3; 2596 2597 /** 2598 * Error code that is passed to the {@link IPackageMoveObserver} if the 2599 * specified package cannot be moved to the specified location. 2600 * 2601 * @hide 2602 */ 2603 public static final int MOVE_FAILED_INVALID_LOCATION = -5; 2604 2605 /** 2606 * Error code that is passed to the {@link IPackageMoveObserver} if the 2607 * specified package cannot be moved to the specified location. 2608 * 2609 * @hide 2610 */ 2611 public static final int MOVE_FAILED_INTERNAL_ERROR = -6; 2612 2613 /** 2614 * Error code that is passed to the {@link IPackageMoveObserver} if the 2615 * specified package already has an operation pending in the queue. 2616 * 2617 * @hide 2618 */ 2619 public static final int MOVE_FAILED_OPERATION_PENDING = -7; 2620 2621 /** 2622 * Error code that is passed to the {@link IPackageMoveObserver} if the 2623 * specified package cannot be moved since it contains a device admin. 2624 * 2625 * @hide 2626 */ 2627 public static final int MOVE_FAILED_DEVICE_ADMIN = -8; 2628 2629 /** 2630 * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow 2631 * non-system apps to be moved to internal storage. 2632 * 2633 * @hide 2634 */ 2635 public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9; 2636 2637 /** @hide */ 2638 public static final int MOVE_FAILED_LOCKED_USER = -10; 2639 2640 /** 2641 * Flag parameter for {@link #movePackage} to indicate that 2642 * the package should be moved to internal storage if its 2643 * been installed on external media. 2644 * @hide 2645 */ 2646 @Deprecated 2647 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2648 public static final int MOVE_INTERNAL = 0x00000001; 2649 2650 /** 2651 * Flag parameter for {@link #movePackage} to indicate that 2652 * the package should be moved to external media. 2653 * @hide 2654 */ 2655 @Deprecated 2656 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2657 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 2658 2659 /** {@hide} */ 2660 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID"; 2661 2662 /** 2663 * Usable by the required verifier as the {@code verificationCode} argument 2664 * for {@link PackageManager#verifyPendingInstall} to indicate that it will 2665 * allow the installation to proceed without any of the optional verifiers 2666 * needing to vote. 2667 * 2668 * @hide 2669 */ 2670 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2; 2671 2672 /** 2673 * Used as the {@code verificationCode} argument for 2674 * {@link PackageManager#verifyPendingInstall} to indicate that the calling 2675 * package verifier allows the installation to proceed. 2676 */ 2677 public static final int VERIFICATION_ALLOW = 1; 2678 2679 /** 2680 * Used as the {@code verificationCode} argument for 2681 * {@link PackageManager#verifyPendingInstall} to indicate the calling 2682 * package verifier does not vote to allow the installation to proceed. 2683 */ 2684 public static final int VERIFICATION_REJECT = -1; 2685 2686 /** 2687 * Used as the {@code verificationCode} argument for 2688 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 2689 * IntentFilter Verifier confirms that the IntentFilter is verified. 2690 * 2691 * @deprecated Use {@link DomainVerificationManager} APIs. 2692 * @hide 2693 */ 2694 @Deprecated 2695 @SystemApi 2696 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1; 2697 2698 /** 2699 * Used as the {@code verificationCode} argument for 2700 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 2701 * IntentFilter Verifier confirms that the IntentFilter is NOT verified. 2702 * 2703 * @deprecated Use {@link DomainVerificationManager} APIs. 2704 * @hide 2705 */ 2706 @Deprecated 2707 @SystemApi 2708 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1; 2709 2710 /** 2711 * Internal status code to indicate that an IntentFilter verification result is not specified. 2712 * 2713 * @deprecated Use {@link DomainVerificationManager} APIs. 2714 * @hide 2715 */ 2716 @Deprecated 2717 @SystemApi 2718 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0; 2719 2720 /** 2721 * Used as the {@code status} argument for 2722 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 2723 * will always be prompted the Intent Disambiguation Dialog if there are two 2724 * or more Intent resolved for the IntentFilter's domain(s). 2725 * 2726 * @deprecated Use {@link DomainVerificationManager} APIs. 2727 * @hide 2728 */ 2729 @Deprecated 2730 @SystemApi 2731 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1; 2732 2733 /** 2734 * Used as the {@code status} argument for 2735 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 2736 * will never be prompted the Intent Disambiguation Dialog if there are two 2737 * or more resolution of the Intent. The default App for the domain(s) 2738 * specified in the IntentFilter will also ALWAYS be used. 2739 * 2740 * @deprecated Use {@link DomainVerificationManager} APIs. 2741 * @hide 2742 */ 2743 @Deprecated 2744 @SystemApi 2745 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2; 2746 2747 /** 2748 * Used as the {@code status} argument for 2749 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 2750 * may be prompted the Intent Disambiguation Dialog if there are two or more 2751 * Intent resolved. The default App for the domain(s) specified in the 2752 * IntentFilter will also NEVER be presented to the User. 2753 * 2754 * @deprecated Use {@link DomainVerificationManager} APIs. 2755 * @hide 2756 */ 2757 @Deprecated 2758 @SystemApi 2759 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3; 2760 2761 /** 2762 * Used as the {@code status} argument for 2763 * {@link #updateIntentVerificationStatusAsUser} to indicate that this app 2764 * should always be considered as an ambiguous candidate for handling the 2765 * matching Intent even if there are other candidate apps in the "always" 2766 * state. Put another way: if there are any 'always ask' apps in a set of 2767 * more than one candidate app, then a disambiguation is *always* presented 2768 * even if there is another candidate app with the 'always' state. 2769 * 2770 * @deprecated Use {@link DomainVerificationManager} APIs. 2771 * @hide 2772 */ 2773 @Deprecated 2774 @SystemApi 2775 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4; 2776 2777 /** 2778 * Can be used as the {@code millisecondsToDelay} argument for 2779 * {@link PackageManager#extendVerificationTimeout}. This is the 2780 * maximum time {@code PackageManager} waits for the verification 2781 * agent to return (in milliseconds). 2782 */ 2783 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000; 2784 2785 /** 2786 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's 2787 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or 2788 * lag in sound input or output. 2789 */ 2790 @SdkConstant(SdkConstantType.FEATURE) 2791 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; 2792 2793 /** 2794 * Feature for {@link #getSystemAvailableFeatures} and 2795 * {@link #hasSystemFeature}: The device includes at least one form of audio 2796 * output, as defined in the Android Compatibility Definition Document (CDD) 2797 * <a href="https://source.android.com/compatibility/android-cdd#7_8_audio">section 7.8 Audio</a>. 2798 */ 2799 @SdkConstant(SdkConstantType.FEATURE) 2800 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output"; 2801 2802 /** 2803 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2804 * The device has professional audio level of functionality and performance. 2805 */ 2806 @SdkConstant(SdkConstantType.FEATURE) 2807 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro"; 2808 2809 /** 2810 * Feature for {@link #getSystemAvailableFeatures} and 2811 * {@link #hasSystemFeature}: The device is capable of communicating with 2812 * other devices via Bluetooth. 2813 */ 2814 @SdkConstant(SdkConstantType.FEATURE) 2815 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 2816 2817 /** 2818 * Feature for {@link #getSystemAvailableFeatures} and 2819 * {@link #hasSystemFeature}: The device is capable of communicating with 2820 * other devices via Bluetooth Low Energy radio. 2821 */ 2822 @SdkConstant(SdkConstantType.FEATURE) 2823 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 2824 2825 /** 2826 * Feature for {@link #getSystemAvailableFeatures} and 2827 * {@link #hasSystemFeature}: The device has a camera facing away 2828 * from the screen. 2829 */ 2830 @SdkConstant(SdkConstantType.FEATURE) 2831 public static final String FEATURE_CAMERA = "android.hardware.camera"; 2832 2833 /** 2834 * Feature for {@link #getSystemAvailableFeatures} and 2835 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 2836 */ 2837 @SdkConstant(SdkConstantType.FEATURE) 2838 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 2839 2840 /** 2841 * Feature for {@link #getSystemAvailableFeatures} and 2842 * {@link #hasSystemFeature}: The device has at least one camera pointing in 2843 * some direction, or can support an external camera being connected to it. 2844 */ 2845 @SdkConstant(SdkConstantType.FEATURE) 2846 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 2847 2848 /** 2849 * Feature for {@link #getSystemAvailableFeatures} and 2850 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 2851 * The external camera may not always be connected or available to applications to use. 2852 */ 2853 @SdkConstant(SdkConstantType.FEATURE) 2854 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 2855 2856 /** 2857 * Feature for {@link #getSystemAvailableFeatures} and 2858 * {@link #hasSystemFeature}: The device's camera supports flash. 2859 */ 2860 @SdkConstant(SdkConstantType.FEATURE) 2861 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 2862 2863 /** 2864 * Feature for {@link #getSystemAvailableFeatures} and 2865 * {@link #hasSystemFeature}: The device has a front facing camera. 2866 */ 2867 @SdkConstant(SdkConstantType.FEATURE) 2868 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 2869 2870 /** 2871 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 2872 * of the cameras on the device supports the 2873 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 2874 * capability level. 2875 */ 2876 @SdkConstant(SdkConstantType.FEATURE) 2877 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 2878 2879 /** 2880 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 2881 * of the cameras on the device supports the 2882 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 2883 * capability level. 2884 */ 2885 @SdkConstant(SdkConstantType.FEATURE) 2886 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 2887 "android.hardware.camera.capability.manual_sensor"; 2888 2889 /** 2890 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 2891 * of the cameras on the device supports the 2892 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 2893 * capability level. 2894 */ 2895 @SdkConstant(SdkConstantType.FEATURE) 2896 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 2897 "android.hardware.camera.capability.manual_post_processing"; 2898 2899 /** 2900 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 2901 * of the cameras on the device supports the 2902 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 2903 * capability level. 2904 */ 2905 @SdkConstant(SdkConstantType.FEATURE) 2906 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 2907 "android.hardware.camera.capability.raw"; 2908 2909 /** 2910 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 2911 * of the cameras on the device supports the 2912 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING 2913 * MOTION_TRACKING} capability level. 2914 */ 2915 @SdkConstant(SdkConstantType.FEATURE) 2916 public static final String FEATURE_CAMERA_AR = 2917 "android.hardware.camera.ar"; 2918 2919 /** 2920 * Feature for {@link #getSystemAvailableFeatures} and 2921 * {@link #hasSystemFeature}: The device's main front and back cameras can stream 2922 * concurrently as described in {@link 2923 * android.hardware.camera2.CameraManager#getConcurrentCameraIds()}. 2924 * </p> 2925 * <p>While {@link android.hardware.camera2.CameraManager#getConcurrentCameraIds()} and 2926 * associated APIs are only available on API level 30 or newer, this feature flag may be 2927 * advertised by devices on API levels below 30. If present on such a device, the same 2928 * guarantees hold: The main front and main back camera can be used at the same time, with 2929 * guaranteed stream configurations as defined in the table for concurrent streaming at 2930 * {@link android.hardware.camera2.CameraDevice#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)}. 2931 * </p> 2932 */ 2933 @SdkConstant(SdkConstantType.FEATURE) 2934 public static final String FEATURE_CAMERA_CONCURRENT = "android.hardware.camera.concurrent"; 2935 2936 /** 2937 * Feature for {@link #getSystemAvailableFeatures} and 2938 * {@link #hasSystemFeature}: The device is capable of communicating with 2939 * consumer IR devices. 2940 */ 2941 @SdkConstant(SdkConstantType.FEATURE) 2942 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 2943 2944 /** 2945 * Feature for {@link #getSystemAvailableFeatures} and 2946 * {@link #hasSystemFeature}: The device supports a Context Hub, used to expose the 2947 * functionalities in {@link android.hardware.location.ContextHubManager}. 2948 * 2949 * @hide 2950 */ 2951 @SystemApi 2952 @SdkConstant(SdkConstantType.FEATURE) 2953 public static final String FEATURE_CONTEXT_HUB = "android.hardware.context_hub"; 2954 2955 /** {@hide} */ 2956 @SdkConstant(SdkConstantType.FEATURE) 2957 public static final String FEATURE_CTS = "android.software.cts"; 2958 2959 /** 2960 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 2961 * is opted-in to render the application using Automotive App Host 2962 * 2963 * @hide 2964 */ 2965 @SdkConstant(SdkConstantType.FEATURE) 2966 public static final String FEATURE_CAR_TEMPLATES_HOST = 2967 "android.software.car.templates_host"; 2968 2969 /** 2970 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:If this 2971 * feature is supported, the device should also declare {@link #FEATURE_AUTOMOTIVE} and show 2972 * a UI that can display multiple tasks at the same time on a single display. The user can 2973 * perform multiple actions on different tasks simultaneously. Apps open in split screen mode 2974 * by default, instead of full screen. Unlike Android's multi-window mode, where users can 2975 * choose how to display apps, the device determines how apps are shown. 2976 * 2977 * @hide 2978 */ 2979 @SdkConstant(SdkConstantType.FEATURE) 2980 public static final String FEATURE_CAR_SPLITSCREEN_MULTITASKING = 2981 "android.software.car.splitscreen_multitasking"; 2982 2983 /** 2984 * Feature for {@link #getSystemAvailableFeatures} and 2985 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports 2986 * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware 2987 * at the given feature version. 2988 * 2989 * <p>Known feature versions include: 2990 * <ul> 2991 * <li><code>202009</code>: corresponds to the features included in the Identity Credential 2992 * API shipped in Android 11. 2993 * <li><code>202101</code>: corresponds to the features included in the Identity Credential 2994 * API shipped in Android 12. 2995 * <li><code>202201</code>: corresponds to the features included in the Identity Credential 2996 * API shipped in Android 13. 2997 * </ul> 2998 */ 2999 @SdkConstant(SdkConstantType.FEATURE) 3000 public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE = 3001 "android.hardware.identity_credential"; 3002 3003 /** 3004 * Feature for {@link #getSystemAvailableFeatures} and 3005 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports 3006 * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware 3007 * with direct access at the given feature version. 3008 * See {@link #FEATURE_IDENTITY_CREDENTIAL_HARDWARE} for known feature versions. 3009 */ 3010 @SdkConstant(SdkConstantType.FEATURE) 3011 public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE_DIRECT_ACCESS = 3012 "android.hardware.identity_credential_direct_access"; 3013 3014 /** 3015 * Feature for {@link #getSystemAvailableFeatures} and 3016 * {@link #hasSystemFeature}: The device supports one or more methods of 3017 * reporting current location. 3018 */ 3019 @SdkConstant(SdkConstantType.FEATURE) 3020 public static final String FEATURE_LOCATION = "android.hardware.location"; 3021 3022 /** 3023 * Feature for {@link #getSystemAvailableFeatures} and 3024 * {@link #hasSystemFeature}: The device has a Global Positioning System 3025 * receiver and can report precise location. 3026 */ 3027 @SdkConstant(SdkConstantType.FEATURE) 3028 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 3029 3030 /** 3031 * Feature for {@link #getSystemAvailableFeatures} and 3032 * {@link #hasSystemFeature}: The device can report location with coarse 3033 * accuracy using a network-based geolocation system. 3034 */ 3035 @SdkConstant(SdkConstantType.FEATURE) 3036 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 3037 3038 /** 3039 * Feature for {@link #getSystemAvailableFeatures} and 3040 * {@link #hasSystemFeature}: The device supports FeliCa communication, which is based on 3041 * ISO/IEC 18092 and JIS X 6319-4. 3042 * 3043 * @hide 3044 */ 3045 @SdkConstant(SdkConstantType.FEATURE) 3046 public static final String FEATURE_FELICA = "android.hardware.felica"; 3047 3048 /** 3049 * Feature for {@link #getSystemAvailableFeatures} and 3050 * {@link #hasSystemFeature}: The device's 3051 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns 3052 * true. 3053 */ 3054 @SdkConstant(SdkConstantType.FEATURE) 3055 public static final String FEATURE_RAM_LOW = "android.hardware.ram.low"; 3056 3057 /** 3058 * Feature for {@link #getSystemAvailableFeatures} and 3059 * {@link #hasSystemFeature}: The device's 3060 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns 3061 * false. 3062 */ 3063 @SdkConstant(SdkConstantType.FEATURE) 3064 public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal"; 3065 3066 /** 3067 * Feature for {@link #getSystemAvailableFeatures} and 3068 * {@link #hasSystemFeature}: The device can record audio via a 3069 * microphone. 3070 */ 3071 @SdkConstant(SdkConstantType.FEATURE) 3072 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 3073 3074 /** 3075 * Feature for {@link #getSystemAvailableFeatures} and 3076 * {@link #hasSystemFeature}: The device can communicate using Near-Field 3077 * Communications (NFC). 3078 */ 3079 @SdkConstant(SdkConstantType.FEATURE) 3080 public static final String FEATURE_NFC = "android.hardware.nfc"; 3081 3082 /** 3083 * Feature for {@link #getSystemAvailableFeatures} and 3084 * {@link #hasSystemFeature}: The device supports host- 3085 * based NFC card emulation. 3086 * 3087 * TODO remove when depending apps have moved to new constant. 3088 * @hide 3089 * @deprecated 3090 */ 3091 @Deprecated 3092 @SdkConstant(SdkConstantType.FEATURE) 3093 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 3094 3095 /** 3096 * Feature for {@link #getSystemAvailableFeatures} and 3097 * {@link #hasSystemFeature}: The device supports host- 3098 * based NFC card emulation. 3099 */ 3100 @SdkConstant(SdkConstantType.FEATURE) 3101 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 3102 3103 /** 3104 * Feature for {@link #getSystemAvailableFeatures} and 3105 * {@link #hasSystemFeature}: The device supports host- 3106 * based NFC-F card emulation. 3107 */ 3108 @SdkConstant(SdkConstantType.FEATURE) 3109 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef"; 3110 3111 /** 3112 * Feature for {@link #getSystemAvailableFeatures} and 3113 * {@link #hasSystemFeature}: The device supports uicc- 3114 * based NFC card emulation. 3115 */ 3116 @SdkConstant(SdkConstantType.FEATURE) 3117 public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC = 3118 "android.hardware.nfc.uicc"; 3119 3120 /** 3121 * Feature for {@link #getSystemAvailableFeatures} and 3122 * {@link #hasSystemFeature}: The device supports eSE- 3123 * based NFC card emulation. 3124 */ 3125 @SdkConstant(SdkConstantType.FEATURE) 3126 public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE = "android.hardware.nfc.ese"; 3127 3128 /** 3129 * Feature for {@link #getSystemAvailableFeatures} and 3130 * {@link #hasSystemFeature}: The Beam API is enabled on the device. 3131 */ 3132 @SdkConstant(SdkConstantType.FEATURE) 3133 public static final String FEATURE_NFC_BEAM = "android.sofware.nfc.beam"; 3134 3135 /** 3136 * Feature for {@link #getSystemAvailableFeatures} and 3137 * {@link #hasSystemFeature}: The device supports any 3138 * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION}, 3139 * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features. 3140 * 3141 * @hide 3142 */ 3143 @SdkConstant(SdkConstantType.FEATURE) 3144 public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any"; 3145 3146 /** 3147 * Feature for {@link #getSystemAvailableFeatures} and 3148 * {@link #hasSystemFeature}: The device contains support for installing SDKs to a work 3149 * profile. 3150 * 3151 * @hide 3152 */ 3153 @SdkConstant(SdkConstantType.FEATURE) 3154 public static final String FEATURE_SDK_SANDBOX_WORK_PROFILE_INSTALL = 3155 "android.software.sdksandbox.sdk_install_work_profile"; 3156 3157 /** 3158 * Feature for {@link #getSystemAvailableFeatures} and 3159 * {@link #hasSystemFeature}: The device supports Open Mobile API capable UICC-based secure 3160 * elements. 3161 */ 3162 @SdkConstant(SdkConstantType.FEATURE) 3163 public static final String FEATURE_SE_OMAPI_UICC = "android.hardware.se.omapi.uicc"; 3164 3165 /** 3166 * Feature for {@link #getSystemAvailableFeatures} and 3167 * {@link #hasSystemFeature}: The device supports Open Mobile API capable eSE-based secure 3168 * elements. 3169 */ 3170 @SdkConstant(SdkConstantType.FEATURE) 3171 public static final String FEATURE_SE_OMAPI_ESE = "android.hardware.se.omapi.ese"; 3172 3173 /** 3174 * Feature for {@link #getSystemAvailableFeatures} and 3175 * {@link #hasSystemFeature}: The device supports Open Mobile API capable SD-based secure 3176 * elements. 3177 */ 3178 @SdkConstant(SdkConstantType.FEATURE) 3179 public static final String FEATURE_SE_OMAPI_SD = "android.hardware.se.omapi.sd"; 3180 3181 /** 3182 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device is 3183 * compatible with Android’s security model. 3184 * 3185 * <p>See sections 2 and 9 in the 3186 * <a href="https://source.android.com/compatibility/android-cdd">Android CDD</a> for more 3187 * details. 3188 */ 3189 @SdkConstant(SdkConstantType.FEATURE) 3190 public static final String FEATURE_SECURITY_MODEL_COMPATIBLE = 3191 "android.hardware.security.model.compatible"; 3192 3193 /** 3194 * Feature for {@link #getSystemAvailableFeatures} and 3195 * {@link #hasSystemFeature}: The device supports the OpenGL ES 3196 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 3197 * Android Extension Pack</a>. 3198 */ 3199 @SdkConstant(SdkConstantType.FEATURE) 3200 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 3201 3202 /** 3203 * Feature for {@link #getSystemAvailableFeatures()} and {@link #hasSystemFeature(String)}. 3204 * This feature indicates whether device supports 3205 * <a href="https://source.android.com/docs/core/virtualization">Android Virtualization Framework</a>. 3206 * 3207 * @hide 3208 */ 3209 @SystemApi 3210 @SdkConstant(SdkConstantType.FEATURE) 3211 public static final String FEATURE_VIRTUALIZATION_FRAMEWORK = 3212 "android.software.virtualization_framework"; 3213 3214 /** 3215 * Feature for {@link #getSystemAvailableFeatures} and 3216 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 3217 * implementation on this device is hardware accelerated, and the Vulkan native API will 3218 * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what 3219 * level of optional hardware features limits it supports. 3220 * <p> 3221 * Level 0 includes the base Vulkan requirements as well as: 3222 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul> 3223 * <p> 3224 * Level 1 additionally includes: 3225 * <ul> 3226 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li> 3227 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li> 3228 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li> 3229 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li> 3230 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li> 3231 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li> 3232 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li> 3233 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li> 3234 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li> 3235 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li> 3236 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li> 3237 * </ul> 3238 */ 3239 @SdkConstant(SdkConstantType.FEATURE) 3240 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level"; 3241 3242 /** 3243 * Feature for {@link #getSystemAvailableFeatures} and 3244 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 3245 * implementation on this device is hardware accelerated, and the Vulkan native API will 3246 * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what 3247 * level of optional compute features that device supports beyond the Vulkan 1.0 requirements. 3248 * <p> 3249 * Compute level 0 indicates: 3250 * <ul> 3251 * <li>The {@code VK_KHR_variable_pointers} extension and 3252 * {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are 3253 supported.</li> 3254 * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li> 3255 * </ul> 3256 */ 3257 @SdkConstant(SdkConstantType.FEATURE) 3258 public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute"; 3259 3260 /** 3261 * Feature for {@link #getSystemAvailableFeatures} and 3262 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 3263 * implementation on this device is hardware accelerated, and the feature version will indicate 3264 * the highest {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices 3265 * that support the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The 3266 * feature version uses the same encoding as Vulkan version numbers: 3267 * <ul> 3268 * <li>Major version number in bits 31-22</li> 3269 * <li>Minor version number in bits 21-12</li> 3270 * <li>Patch version number in bits 11-0</li> 3271 * </ul> 3272 * A version of 1.1.0 or higher also indicates: 3273 * <ul> 3274 * <li>The {@code VK_ANDROID_external_memory_android_hardware_buffer} extension is 3275 * supported.</li> 3276 * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li> 3277 * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is 3278 * supported.</li> 3279 * </ul> 3280 * A subset of devices that support Vulkan 1.1 do so via software emulation. For more 3281 * information, see 3282 * <a href="{@docRoot}ndk/guides/graphics/design-notes">Vulkan Design Guidelines</a>. 3283 */ 3284 @SdkConstant(SdkConstantType.FEATURE) 3285 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version"; 3286 3287 /** 3288 * Feature for {@link #getSystemAvailableFeatures} and 3289 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version 3290 * specifies a date such that the device is known to pass the Vulkan dEQP test suite associated 3291 * with that date. The date is encoded as follows: 3292 * <ul> 3293 * <li>Year in bits 31-16</li> 3294 * <li>Month in bits 15-8</li> 3295 * <li>Day in bits 7-0</li> 3296 * </ul> 3297 * <p> 3298 * Example: 2019-03-01 is encoded as 0x07E30301, and would indicate that the device passes the 3299 * Vulkan dEQP test suite version that was current on 2019-03-01. 3300 */ 3301 @SdkConstant(SdkConstantType.FEATURE) 3302 public static final String FEATURE_VULKAN_DEQP_LEVEL = "android.software.vulkan.deqp.level"; 3303 3304 /** 3305 * Feature for {@link #getSystemAvailableFeatures} and 3306 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version 3307 * specifies a date such that the device is known to pass the OpenGLES dEQP test suite 3308 * associated with that date. The date is encoded as follows: 3309 * <ul> 3310 * <li>Year in bits 31-16</li> 3311 * <li>Month in bits 15-8</li> 3312 * <li>Day in bits 7-0</li> 3313 * </ul> 3314 * <p> 3315 * Example: 2021-03-01 is encoded as 0x07E50301, and would indicate that the device passes the 3316 * OpenGL ES dEQP test suite version that was current on 2021-03-01. 3317 */ 3318 @SdkConstant(SdkConstantType.FEATURE) 3319 public static final String FEATURE_OPENGLES_DEQP_LEVEL = "android.software.opengles.deqp.level"; 3320 3321 /** 3322 * Feature for {@link #getSystemAvailableFeatures} and 3323 * {@link #hasSystemFeature}: The device includes broadcast radio tuner. 3324 * @hide 3325 */ 3326 @SystemApi 3327 @SdkConstant(SdkConstantType.FEATURE) 3328 public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio"; 3329 3330 /** 3331 * Feature for {@link #getSystemAvailableFeatures} and 3332 * {@link #hasSystemFeature}: The device has a secure implementation of keyguard, meaning the 3333 * device supports PIN, pattern and password as defined in Android CDD 3334 */ 3335 @SdkConstant(SdkConstantType.FEATURE) 3336 public static final String FEATURE_SECURE_LOCK_SCREEN = "android.software.secure_lock_screen"; 3337 3338 /** 3339 * Feature for {@link #getSystemAvailableFeatures} and 3340 * {@link #hasSystemFeature}: The device includes an accelerometer. 3341 */ 3342 @SdkConstant(SdkConstantType.FEATURE) 3343 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 3344 3345 /** 3346 * Feature for {@link #getSystemAvailableFeatures} and 3347 * {@link #hasSystemFeature}: The device includes a barometer (air 3348 * pressure sensor.) 3349 */ 3350 @SdkConstant(SdkConstantType.FEATURE) 3351 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 3352 3353 /** 3354 * Feature for {@link #getSystemAvailableFeatures} and 3355 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 3356 */ 3357 @SdkConstant(SdkConstantType.FEATURE) 3358 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 3359 3360 /** 3361 * Feature for {@link #getSystemAvailableFeatures} and 3362 * {@link #hasSystemFeature}: The device includes a gyroscope. 3363 */ 3364 @SdkConstant(SdkConstantType.FEATURE) 3365 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 3366 3367 /** 3368 * Feature for {@link #getSystemAvailableFeatures} and 3369 * {@link #hasSystemFeature}: The device includes a limited axes accelerometer. 3370 */ 3371 @SdkConstant(SdkConstantType.FEATURE) 3372 public static final String FEATURE_SENSOR_ACCELEROMETER_LIMITED_AXES = 3373 "android.hardware.sensor.accelerometer_limited_axes"; 3374 3375 /** 3376 * Feature for {@link #getSystemAvailableFeatures} and 3377 * {@link #hasSystemFeature}: The device includes a limited axes gyroscope. 3378 */ 3379 @SdkConstant(SdkConstantType.FEATURE) 3380 public static final String FEATURE_SENSOR_GYROSCOPE_LIMITED_AXES = 3381 "android.hardware.sensor.gyroscope_limited_axes"; 3382 3383 /** 3384 * Feature for {@link #getSystemAvailableFeatures} and 3385 * {@link #hasSystemFeature}: The device includes an uncalibrated limited axes accelerometer. 3386 */ 3387 @SdkConstant(SdkConstantType.FEATURE) 3388 public static final String FEATURE_SENSOR_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED = 3389 "android.hardware.sensor.accelerometer_limited_axes_uncalibrated"; 3390 3391 /** 3392 * Feature for {@link #getSystemAvailableFeatures} and 3393 * {@link #hasSystemFeature}: The device includes an uncalibrated limited axes gyroscope. 3394 */ 3395 @SdkConstant(SdkConstantType.FEATURE) 3396 public static final String FEATURE_SENSOR_GYROSCOPE_LIMITED_AXES_UNCALIBRATED = 3397 "android.hardware.sensor.gyroscope_limited_axes_uncalibrated"; 3398 3399 /** 3400 * Feature for {@link #getSystemAvailableFeatures} and 3401 * {@link #hasSystemFeature}: The device includes a light sensor. 3402 */ 3403 @SdkConstant(SdkConstantType.FEATURE) 3404 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 3405 3406 /** 3407 * Feature for {@link #getSystemAvailableFeatures} and 3408 * {@link #hasSystemFeature}: The device includes a proximity sensor. 3409 */ 3410 @SdkConstant(SdkConstantType.FEATURE) 3411 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 3412 3413 /** 3414 * Feature for {@link #getSystemAvailableFeatures} and 3415 * {@link #hasSystemFeature}: The device includes a hardware step counter. 3416 */ 3417 @SdkConstant(SdkConstantType.FEATURE) 3418 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 3419 3420 /** 3421 * Feature for {@link #getSystemAvailableFeatures} and 3422 * {@link #hasSystemFeature}: The device includes a hardware step detector. 3423 */ 3424 @SdkConstant(SdkConstantType.FEATURE) 3425 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 3426 3427 /** 3428 * Feature for {@link #getSystemAvailableFeatures} and 3429 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 3430 */ 3431 @SdkConstant(SdkConstantType.FEATURE) 3432 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 3433 3434 /** 3435 * Feature for {@link #getSystemAvailableFeatures} and 3436 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram. 3437 */ 3438 @SdkConstant(SdkConstantType.FEATURE) 3439 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 3440 "android.hardware.sensor.heartrate.ecg"; 3441 3442 /** 3443 * Feature for {@link #getSystemAvailableFeatures} and 3444 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 3445 */ 3446 @SdkConstant(SdkConstantType.FEATURE) 3447 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 3448 "android.hardware.sensor.relative_humidity"; 3449 3450 /** 3451 * Feature for {@link #getSystemAvailableFeatures} and 3452 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 3453 */ 3454 @SdkConstant(SdkConstantType.FEATURE) 3455 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 3456 "android.hardware.sensor.ambient_temperature"; 3457 3458 /** 3459 * Feature for {@link #getSystemAvailableFeatures} and 3460 * {@link #hasSystemFeature}: The device includes a hinge angle sensor. 3461 */ 3462 @SdkConstant(SdkConstantType.FEATURE) 3463 public static final String FEATURE_SENSOR_HINGE_ANGLE = "android.hardware.sensor.hinge_angle"; 3464 3465 /** 3466 * Feature for {@link #getSystemAvailableFeatures} and 3467 * {@link #hasSystemFeature}: The device includes a heading sensor. 3468 */ 3469 @SdkConstant(SdkConstantType.FEATURE) 3470 public static final String FEATURE_SENSOR_HEADING = "android.hardware.sensor.heading"; 3471 3472 /** 3473 * Feature for {@link #getSystemAvailableFeatures} and 3474 * {@link #hasSystemFeature}: The device supports exposing head tracker sensors from peripheral 3475 * devices via the dynamic sensors API. 3476 */ 3477 @SdkConstant(SdkConstantType.FEATURE) 3478 public static final String FEATURE_SENSOR_DYNAMIC_HEAD_TRACKER = "android.hardware.sensor.dynamic.head_tracker"; 3479 3480 /** 3481 * Feature for {@link #getSystemAvailableFeatures} and 3482 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 3483 * capabilities. 3484 */ 3485 @SdkConstant(SdkConstantType.FEATURE) 3486 public static final String FEATURE_HIFI_SENSORS = 3487 "android.hardware.sensor.hifi_sensors"; 3488 3489 /** 3490 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3491 * The device supports a hardware mechanism for invoking an assist gesture. 3492 * @see android.provider.Settings.Secure#ASSIST_GESTURE_ENABLED 3493 * @hide 3494 */ 3495 @SdkConstant(SdkConstantType.FEATURE) 3496 public static final String FEATURE_ASSIST_GESTURE = "android.hardware.sensor.assist"; 3497 3498 /** 3499 * Feature for {@link #getSystemAvailableFeatures} and 3500 * {@link #hasSystemFeature}: The device has a telephony radio with data 3501 * communication support. 3502 */ 3503 @SdkConstant(SdkConstantType.FEATURE) 3504 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 3505 3506 /** 3507 * Feature for {@link #getSystemAvailableFeatures} and 3508 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 3509 * 3510 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined. 3511 */ 3512 @SdkConstant(SdkConstantType.FEATURE) 3513 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 3514 3515 /** 3516 * Feature for {@link #getSystemAvailableFeatures} and 3517 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 3518 * 3519 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined. 3520 */ 3521 @SdkConstant(SdkConstantType.FEATURE) 3522 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 3523 3524 /** 3525 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3526 * The device supports telephony carrier restriction mechanism. 3527 * 3528 * <p>Devices declaring this feature must have an implementation of the 3529 * {@link android.telephony.TelephonyManager#getAllowedCarriers} and 3530 * {@link android.telephony.TelephonyManager#setAllowedCarriers}. 3531 * 3532 * This feature should only be defined if {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 3533 * has been defined. 3534 * @hide 3535 */ 3536 @SystemApi 3537 @SdkConstant(SdkConstantType.FEATURE) 3538 public static final String FEATURE_TELEPHONY_CARRIERLOCK = 3539 "android.hardware.telephony.carrierlock"; 3540 3541 /** 3542 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3543 * supports embedded subscriptions on eUICCs. 3544 * 3545 * This feature should only be defined if {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 3546 * has been defined. 3547 */ 3548 @SdkConstant(SdkConstantType.FEATURE) 3549 public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc"; 3550 3551 /** 3552 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3553 * supports multiple enabled profiles on eUICCs. 3554 * 3555 * <p>Devices declaring this feature must have an implementation of the 3556 * {@link UiccCardInfo#getPorts}, 3557 * {@link UiccCardInfo#isMultipleEnabledProfilesSupported} and 3558 * {@link android.telephony.euicc.EuiccManager#switchToSubscription (with portIndex)}. 3559 * 3560 * This feature should only be defined if {@link #FEATURE_TELEPHONY_EUICC} have been defined. 3561 */ 3562 @SdkConstant(SdkConstantType.FEATURE) 3563 public static final String FEATURE_TELEPHONY_EUICC_MEP = "android.hardware.telephony.euicc.mep"; 3564 3565 /** 3566 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3567 * supports cell-broadcast reception using the MBMS APIs. 3568 * 3569 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 3570 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined. 3571 */ 3572 @SdkConstant(SdkConstantType.FEATURE) 3573 public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms"; 3574 3575 /** 3576 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3577 * supports attaching to IMS implementations using the ImsService API in telephony. 3578 * 3579 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_DATA} has been defined. 3580 */ 3581 @SdkConstant(SdkConstantType.FEATURE) 3582 public static final String FEATURE_TELEPHONY_IMS = "android.hardware.telephony.ims"; 3583 3584 /** 3585 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3586 * supports a single IMS registration as defined by carrier networks in the IMS service 3587 * implementation using the {@link ImsService} API, {@link GbaService} API, and IRadio 1.6 HAL. 3588 * <p> 3589 * When set, the device must fully support the following APIs for an application to implement 3590 * IMS single registration: 3591 * <ul> 3592 * <li> Updating RCS provisioning status using the {@link ProvisioningManager} API to supply an 3593 * RCC.14 defined XML and notify IMS applications of Auto Configuration Server (ACS) or 3594 * proprietary server provisioning updates.</li> 3595 * <li>Opening a delegate in the device IMS service to forward SIP traffic to the carrier's 3596 * network using the {@link SipDelegateManager} API</li> 3597 * <li>Listening to EPS dedicated bearer establishment via the 3598 * {@link ConnectivityManager#registerQosCallback} 3599 * API to indicate to the application when to start/stop media traffic.</li> 3600 * <li>Implementing Generic Bootstrapping Architecture (GBA) and providing the associated 3601 * authentication keys to applications 3602 * requesting this information via the {@link TelephonyManager#bootstrapAuthenticationRequest} 3603 * API</li> 3604 * <li>Implementing RCS User Capability Exchange using the {@link RcsUceAdapter} API</li> 3605 * </ul> 3606 * <p> 3607 * This feature should only be defined if {@link #FEATURE_TELEPHONY_IMS} is also defined. 3608 * @hide 3609 */ 3610 @SystemApi 3611 @SdkConstant(SdkConstantType.FEATURE) 3612 public static final String FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION = 3613 "android.hardware.telephony.ims.singlereg"; 3614 3615 /** 3616 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3617 * The device supports Telecom Service APIs. 3618 */ 3619 @SdkConstant(SdkConstantType.FEATURE) 3620 public static final String FEATURE_TELECOM = "android.software.telecom"; 3621 3622 /** 3623 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3624 * The device supports Telephony APIs for calling service. 3625 * 3626 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_RADIO_ACCESS}, 3627 * {@link #FEATURE_TELEPHONY_SUBSCRIPTION}, and {@link #FEATURE_TELECOM} have been defined. 3628 */ 3629 @SdkConstant(SdkConstantType.FEATURE) 3630 public static final String FEATURE_TELEPHONY_CALLING = "android.hardware.telephony.calling"; 3631 3632 /** 3633 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3634 * The device supports Telephony APIs for data service. 3635 * 3636 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 3637 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined. 3638 */ 3639 @SdkConstant(SdkConstantType.FEATURE) 3640 public static final String FEATURE_TELEPHONY_DATA = "android.hardware.telephony.data"; 3641 3642 /** 3643 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3644 * The device supports Telephony APIs for SMS and MMS. 3645 * 3646 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 3647 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined. 3648 */ 3649 @SdkConstant(SdkConstantType.FEATURE) 3650 public static final String FEATURE_TELEPHONY_MESSAGING = "android.hardware.telephony.messaging"; 3651 3652 /** 3653 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3654 * The device supports Telephony APIs for the radio access. 3655 * 3656 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined. 3657 */ 3658 @SdkConstant(SdkConstantType.FEATURE) 3659 public static final String FEATURE_TELEPHONY_RADIO_ACCESS = 3660 "android.hardware.telephony.radio.access"; 3661 3662 /** 3663 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3664 * The device supports Telephony APIs for Satellite communication. 3665 * 3666 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_MESSAGING} 3667 * has been defined. 3668 * 3669 * @hide 3670 */ 3671 @SdkConstant(SdkConstantType.FEATURE) 3672 public static final String FEATURE_TELEPHONY_SATELLITE = "android.hardware.telephony.satellite"; 3673 3674 /** 3675 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3676 * The device supports Telephony APIs for the subscription. 3677 * 3678 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined. 3679 */ 3680 @SdkConstant(SdkConstantType.FEATURE) 3681 public static final String FEATURE_TELEPHONY_SUBSCRIPTION = 3682 "android.hardware.telephony.subscription"; 3683 3684 /** 3685 * Feature for {@link #getSystemAvailableFeatures} and 3686 * {@link #hasSystemFeature}: The device is capable of communicating with 3687 * other devices via ultra wideband. 3688 */ 3689 @SdkConstant(SdkConstantType.FEATURE) 3690 public static final String FEATURE_UWB = "android.hardware.uwb"; 3691 3692 /** 3693 * Feature for {@link #getSystemAvailableFeatures} and 3694 * {@link #hasSystemFeature}: The device supports connecting to USB devices 3695 * as the USB host. 3696 */ 3697 @SdkConstant(SdkConstantType.FEATURE) 3698 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 3699 3700 /** 3701 * Feature for {@link #getSystemAvailableFeatures} and 3702 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 3703 */ 3704 @SdkConstant(SdkConstantType.FEATURE) 3705 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 3706 3707 /** 3708 * Feature for {@link #getSystemAvailableFeatures} and 3709 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 3710 */ 3711 @SdkConstant(SdkConstantType.FEATURE) 3712 public static final String FEATURE_SIP = "android.software.sip"; 3713 3714 /** 3715 * Feature for {@link #getSystemAvailableFeatures} and 3716 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 3717 */ 3718 @SdkConstant(SdkConstantType.FEATURE) 3719 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 3720 3721 /** 3722 * Feature for {@link #getSystemAvailableFeatures} and 3723 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 3724 * @deprecated use {@link #FEATURE_TELECOM} instead. 3725 */ 3726 @Deprecated 3727 @SdkConstant(SdkConstantType.FEATURE) 3728 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 3729 3730 /** 3731 * Feature for {@link #getSystemAvailableFeatures} and 3732 * {@link #hasSystemFeature}: The device's display has a touch screen. 3733 */ 3734 @SdkConstant(SdkConstantType.FEATURE) 3735 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 3736 3737 /** 3738 * Feature for {@link #getSystemAvailableFeatures} and 3739 * {@link #hasSystemFeature}: The device's touch screen supports 3740 * multitouch sufficient for basic two-finger gesture detection. 3741 */ 3742 @SdkConstant(SdkConstantType.FEATURE) 3743 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 3744 3745 /** 3746 * Feature for {@link #getSystemAvailableFeatures} and 3747 * {@link #hasSystemFeature}: The device's touch screen is capable of 3748 * tracking two or more fingers fully independently. 3749 */ 3750 @SdkConstant(SdkConstantType.FEATURE) 3751 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 3752 3753 /** 3754 * Feature for {@link #getSystemAvailableFeatures} and 3755 * {@link #hasSystemFeature}: The device's touch screen is capable of 3756 * tracking a full hand of fingers fully independently -- that is, 5 or 3757 * more simultaneous independent pointers. 3758 */ 3759 @SdkConstant(SdkConstantType.FEATURE) 3760 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 3761 3762 /** 3763 * Feature for {@link #getSystemAvailableFeatures} and 3764 * {@link #hasSystemFeature}: The device does not have a touch screen, but 3765 * does support touch emulation for basic events. For instance, the 3766 * device might use a mouse or remote control to drive a cursor, and 3767 * emulate basic touch pointer events like down, up, drag, etc. All 3768 * devices that support android.hardware.touchscreen or a sub-feature are 3769 * presumed to also support faketouch. 3770 */ 3771 @SdkConstant(SdkConstantType.FEATURE) 3772 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 3773 3774 /** 3775 * Feature for {@link #getSystemAvailableFeatures} and 3776 * {@link #hasSystemFeature}: The device does not have a touch screen, but 3777 * does support touch emulation for basic events that supports distinct 3778 * tracking of two or more fingers. This is an extension of 3779 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 3780 * that unlike a distinct multitouch screen as defined by 3781 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 3782 * devices will not actually provide full two-finger gestures since the 3783 * input is being transformed to cursor movement on the screen. That is, 3784 * single finger gestures will move a cursor; two-finger swipes will 3785 * result in single-finger touch events; other two-finger gestures will 3786 * result in the corresponding two-finger touch event. 3787 */ 3788 @SdkConstant(SdkConstantType.FEATURE) 3789 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 3790 3791 /** 3792 * Feature for {@link #getSystemAvailableFeatures} and 3793 * {@link #hasSystemFeature}: The device does not have a touch screen, but 3794 * does support touch emulation for basic events that supports tracking 3795 * a hand of fingers (5 or more fingers) fully independently. 3796 * This is an extension of 3797 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 3798 * that unlike a multitouch screen as defined by 3799 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 3800 * gestures can be detected due to the limitations described for 3801 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 3802 */ 3803 @SdkConstant(SdkConstantType.FEATURE) 3804 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 3805 3806 /** 3807 * Feature for {@link #getSystemAvailableFeatures} and 3808 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 3809 */ 3810 @SdkConstant(SdkConstantType.FEATURE) 3811 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 3812 3813 /** 3814 * Feature for {@link #getSystemAvailableFeatures} and 3815 * {@link #hasSystemFeature}: The device has biometric hardware to perform face authentication. 3816 */ 3817 @SdkConstant(SdkConstantType.FEATURE) 3818 public static final String FEATURE_FACE = "android.hardware.biometrics.face"; 3819 3820 /** 3821 * Feature for {@link #getSystemAvailableFeatures} and 3822 * {@link #hasSystemFeature}: The device has biometric hardware to perform iris authentication. 3823 */ 3824 @SdkConstant(SdkConstantType.FEATURE) 3825 public static final String FEATURE_IRIS = "android.hardware.biometrics.iris"; 3826 3827 /** 3828 * Feature for {@link #getSystemAvailableFeatures} and 3829 * {@link #hasSystemFeature}: The device supports portrait orientation 3830 * screens. For backwards compatibility, you can assume that if neither 3831 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 3832 * both portrait and landscape. 3833 */ 3834 @SdkConstant(SdkConstantType.FEATURE) 3835 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 3836 3837 /** 3838 * Feature for {@link #getSystemAvailableFeatures} and 3839 * {@link #hasSystemFeature}: The device supports landscape orientation 3840 * screens. For backwards compatibility, you can assume that if neither 3841 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 3842 * both portrait and landscape. 3843 */ 3844 @SdkConstant(SdkConstantType.FEATURE) 3845 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 3846 3847 /** 3848 * Feature for {@link #getSystemAvailableFeatures} and 3849 * {@link #hasSystemFeature}: The device supports live wallpapers. 3850 */ 3851 @SdkConstant(SdkConstantType.FEATURE) 3852 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 3853 /** 3854 * Feature for {@link #getSystemAvailableFeatures} and 3855 * {@link #hasSystemFeature}: The device supports app widgets. 3856 */ 3857 @SdkConstant(SdkConstantType.FEATURE) 3858 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 3859 /** 3860 * Feature for {@link #getSystemAvailableFeatures} and 3861 * {@link #hasSystemFeature}: The device supports the 3862 * {@link android.R.attr#cantSaveState} API. 3863 */ 3864 @SdkConstant(SdkConstantType.FEATURE) 3865 public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state"; 3866 3867 /** 3868 * @hide 3869 * Feature for {@link #getSystemAvailableFeatures} and 3870 * {@link #hasSystemFeature}: The device supports 3871 * {@link android.service.games.GameService}. 3872 * 3873 * @hide 3874 */ 3875 @SdkConstant(SdkConstantType.FEATURE) 3876 @SystemApi 3877 public static final String FEATURE_GAME_SERVICE = "android.software.game_service"; 3878 3879 /** 3880 * @hide 3881 * Feature for {@link #getSystemAvailableFeatures} and 3882 * {@link #hasSystemFeature}: The device supports 3883 * {@link android.service.voice.VoiceInteractionService} and 3884 * {@link android.app.VoiceInteractor}. 3885 */ 3886 @SdkConstant(SdkConstantType.FEATURE) 3887 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 3888 3889 3890 /** 3891 * Feature for {@link #getSystemAvailableFeatures} and 3892 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 3893 * by third party applications. 3894 */ 3895 @SdkConstant(SdkConstantType.FEATURE) 3896 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 3897 3898 /** 3899 * Feature for {@link #getSystemAvailableFeatures} and 3900 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 3901 * with the {@link android.inputmethodservice.InputMethodService} API. 3902 */ 3903 @SdkConstant(SdkConstantType.FEATURE) 3904 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 3905 3906 /** 3907 * Feature for {@link #getSystemAvailableFeatures} and 3908 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 3909 */ 3910 @SdkConstant(SdkConstantType.FEATURE) 3911 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 3912 3913 /** 3914 * Feature for {@link #getSystemAvailableFeatures} and 3915 * {@link #hasSystemFeature}: The device supports leanback UI. This is 3916 * typically used in a living room television experience, but is a software 3917 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 3918 * feature will use resources associated with the "television" UI mode. 3919 */ 3920 @SdkConstant(SdkConstantType.FEATURE) 3921 public static final String FEATURE_LEANBACK = "android.software.leanback"; 3922 3923 /** 3924 * Feature for {@link #getSystemAvailableFeatures} and 3925 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 3926 * applications designed for this experience should be run, though this is 3927 * not enforced by the system. 3928 */ 3929 @SdkConstant(SdkConstantType.FEATURE) 3930 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 3931 3932 /** 3933 * Feature for {@link #getSystemAvailableFeatures} and 3934 * {@link #hasSystemFeature}: The device supports live TV and can display 3935 * contents from TV inputs implemented with the 3936 * {@link android.media.tv.TvInputService} API. 3937 */ 3938 @SdkConstant(SdkConstantType.FEATURE) 3939 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 3940 3941 /** 3942 * Feature for {@link #getSystemAvailableFeatures} and 3943 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 3944 */ 3945 @SdkConstant(SdkConstantType.FEATURE) 3946 public static final String FEATURE_WIFI = "android.hardware.wifi"; 3947 3948 /** 3949 * Feature for {@link #getSystemAvailableFeatures} and 3950 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 3951 */ 3952 @SdkConstant(SdkConstantType.FEATURE) 3953 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 3954 3955 /** 3956 * Feature for {@link #getSystemAvailableFeatures} and 3957 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware. 3958 */ 3959 @SdkConstant(SdkConstantType.FEATURE) 3960 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware"; 3961 3962 /** 3963 * Feature for {@link #getSystemAvailableFeatures} and 3964 * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all 3965 * Passpoint related APIs in {@link WifiManager} are supported. Refer to 3966 * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info. 3967 */ 3968 @SdkConstant(SdkConstantType.FEATURE) 3969 public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint"; 3970 3971 /** 3972 * Feature for {@link #getSystemAvailableFeatures} and 3973 * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc). 3974 */ 3975 @SdkConstant(SdkConstantType.FEATURE) 3976 public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt"; 3977 3978 3979 /** 3980 * Feature for {@link #getSystemAvailableFeatures} and 3981 * {@link #hasSystemFeature}: The device supports LoWPAN networking. 3982 * @hide 3983 */ 3984 @SdkConstant(SdkConstantType.FEATURE) 3985 public static final String FEATURE_LOWPAN = "android.hardware.lowpan"; 3986 3987 /** 3988 * Feature for {@link #getSystemAvailableFeatures} and 3989 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 3990 * on a vehicle headunit. A headunit here is defined to be inside a 3991 * vehicle that may or may not be moving. A headunit uses either a 3992 * primary display in the center console and/or additional displays in 3993 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 3994 * have limited size and resolution. The user will likely be focused on 3995 * driving so limiting driver distraction is a primary concern. User input 3996 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 3997 * like interfaces. 3998 */ 3999 @SdkConstant(SdkConstantType.FEATURE) 4000 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 4001 4002 /** 4003 * Feature for {@link #getSystemAvailableFeatures} and 4004 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 4005 * on a television. Television here is defined to be a typical living 4006 * room television experience: displayed on a big screen, where the user 4007 * is sitting far away from it, and the dominant form of input will be 4008 * something like a DPAD, not through touch or mouse. 4009 * @deprecated use {@link #FEATURE_LEANBACK} instead. 4010 */ 4011 @Deprecated 4012 @SdkConstant(SdkConstantType.FEATURE) 4013 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 4014 4015 /** 4016 * Feature for {@link #getSystemAvailableFeatures} and 4017 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 4018 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 4019 * the wrist. The user is very close when interacting with the device. 4020 */ 4021 @SdkConstant(SdkConstantType.FEATURE) 4022 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 4023 4024 /** 4025 * Feature for {@link #getSystemAvailableFeatures} and 4026 * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded 4027 * device is defined as a full stack Android device with or without a display and no 4028 * user-installable apps. 4029 */ 4030 @SdkConstant(SdkConstantType.FEATURE) 4031 public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded"; 4032 4033 /** 4034 * Feature for {@link #getSystemAvailableFeatures} and 4035 * {@link #hasSystemFeature}: This is a device dedicated to be primarily used 4036 * with keyboard, mouse or touchpad. This includes traditional desktop 4037 * computers, laptops and variants such as convertibles or detachables. 4038 * Due to the larger screen, the device will most likely use the 4039 * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well. 4040 */ 4041 @SdkConstant(SdkConstantType.FEATURE) 4042 public static final String FEATURE_PC = "android.hardware.type.pc"; 4043 4044 /** 4045 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4046 * The device supports printing. 4047 */ 4048 @SdkConstant(SdkConstantType.FEATURE) 4049 public static final String FEATURE_PRINTING = "android.software.print"; 4050 4051 /** 4052 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4053 * The device supports {@link android.companion.CompanionDeviceManager#associate associating} 4054 * with devices via {@link android.companion.CompanionDeviceManager}. 4055 */ 4056 @SdkConstant(SdkConstantType.FEATURE) 4057 public static final String FEATURE_COMPANION_DEVICE_SETUP 4058 = "android.software.companion_device_setup"; 4059 4060 /** 4061 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4062 * The device can perform backup and restore operations on installed applications. 4063 */ 4064 @SdkConstant(SdkConstantType.FEATURE) 4065 public static final String FEATURE_BACKUP = "android.software.backup"; 4066 4067 /** 4068 * Feature for {@link #getSystemAvailableFeatures} and 4069 * {@link #hasSystemFeature}: The device supports freeform window management. 4070 * Windows have title bars and can be moved and resized. 4071 */ 4072 // If this feature is present, you also need to set 4073 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 4074 @SdkConstant(SdkConstantType.FEATURE) 4075 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 4076 = "android.software.freeform_window_management"; 4077 4078 /** 4079 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4080 * The device supports picture-in-picture multi-window mode. 4081 */ 4082 @SdkConstant(SdkConstantType.FEATURE) 4083 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 4084 4085 /** 4086 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4087 * The device supports expanded picture-in-picture multi-window mode. 4088 * 4089 * @see android.app.PictureInPictureParams.Builder#setExpandedAspectRatio 4090 */ 4091 @SdkConstant(SdkConstantType.FEATURE) 4092 public static final String FEATURE_EXPANDED_PICTURE_IN_PICTURE 4093 = "android.software.expanded_picture_in_picture"; 4094 4095 /** 4096 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4097 * The device supports running activities on secondary displays. Displays here 4098 * refers to both physical and virtual displays. Disabling this feature can impact 4099 * support for application projection use-cases and support for virtual devices 4100 * on the device. 4101 */ 4102 @SdkConstant(SdkConstantType.FEATURE) 4103 public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS 4104 = "android.software.activities_on_secondary_displays"; 4105 4106 /** 4107 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4108 * The device supports creating secondary users and managed profiles via 4109 * {@link DevicePolicyManager}. 4110 */ 4111 @SdkConstant(SdkConstantType.FEATURE) 4112 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 4113 4114 /** 4115 * @hide 4116 * TODO: Remove after dependencies updated b/17392243 4117 */ 4118 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 4119 4120 /** 4121 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4122 * The device supports verified boot. 4123 */ 4124 @SdkConstant(SdkConstantType.FEATURE) 4125 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 4126 4127 /** 4128 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4129 * The device supports secure removal of users. When a user is deleted the data associated 4130 * with that user is securely deleted and no longer available. 4131 */ 4132 @SdkConstant(SdkConstantType.FEATURE) 4133 public static final String FEATURE_SECURELY_REMOVES_USERS 4134 = "android.software.securely_removes_users"; 4135 4136 /** {@hide} */ 4137 @TestApi 4138 @SdkConstant(SdkConstantType.FEATURE) 4139 public static final String FEATURE_FILE_BASED_ENCRYPTION 4140 = "android.software.file_based_encryption"; 4141 4142 /** {@hide} */ 4143 @TestApi 4144 @SdkConstant(SdkConstantType.FEATURE) 4145 public static final String FEATURE_ADOPTABLE_STORAGE 4146 = "android.software.adoptable_storage"; 4147 4148 /** 4149 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4150 * The device has a full implementation of the android.webkit.* APIs. Devices 4151 * lacking this feature will not have a functioning WebView implementation. 4152 */ 4153 @SdkConstant(SdkConstantType.FEATURE) 4154 public static final String FEATURE_WEBVIEW = "android.software.webview"; 4155 4156 /** 4157 * Feature for {@link #getSystemAvailableFeatures} and 4158 * {@link #hasSystemFeature}: This device supports ethernet. 4159 */ 4160 @SdkConstant(SdkConstantType.FEATURE) 4161 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 4162 4163 /** 4164 * Feature for {@link #getSystemAvailableFeatures} and 4165 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 4166 * @hide 4167 */ 4168 @TestApi 4169 @SdkConstant(SdkConstantType.FEATURE) 4170 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 4171 4172 /** 4173 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4174 * The device has all of the inputs necessary to be considered a compatible game controller, or 4175 * includes a compatible game controller in the box. 4176 */ 4177 @SdkConstant(SdkConstantType.FEATURE) 4178 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 4179 4180 /** 4181 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4182 * The device has a full implementation of the android.media.midi.* APIs. 4183 */ 4184 @SdkConstant(SdkConstantType.FEATURE) 4185 public static final String FEATURE_MIDI = "android.software.midi"; 4186 4187 /** 4188 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4189 * The device implements an optimized mode for virtual reality (VR) applications that handles 4190 * stereoscopic rendering of notifications, and disables most monocular system UI components 4191 * while a VR application has user focus. 4192 * Devices declaring this feature must include an application implementing a 4193 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 4194 * {@link android.app.Activity#setVrModeEnabled}. 4195 * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead. 4196 */ 4197 @Deprecated 4198 @SdkConstant(SdkConstantType.FEATURE) 4199 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 4200 4201 /** 4202 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4203 * The device implements an optimized mode for virtual reality (VR) applications that handles 4204 * stereoscopic rendering of notifications, disables most monocular system UI components 4205 * while a VR application has user focus and meets extra CDD requirements to provide a 4206 * high-quality VR experience. 4207 * Devices declaring this feature must include an application implementing a 4208 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 4209 * {@link android.app.Activity#setVrModeEnabled}. 4210 * and must meet CDD requirements to provide a high-quality VR experience. 4211 */ 4212 @SdkConstant(SdkConstantType.FEATURE) 4213 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE 4214 = "android.hardware.vr.high_performance"; 4215 4216 /** 4217 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4218 * The device supports autofill of user credentials, addresses, credit cards, etc 4219 * via integration with {@link android.service.autofill.AutofillService autofill 4220 * providers}. 4221 */ 4222 @SdkConstant(SdkConstantType.FEATURE) 4223 public static final String FEATURE_AUTOFILL = "android.software.autofill"; 4224 4225 /** 4226 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4227 * The device implements headtracking suitable for a VR device. 4228 */ 4229 @SdkConstant(SdkConstantType.FEATURE) 4230 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking"; 4231 4232 /** 4233 * Feature for {@link #getSystemAvailableFeatures} and 4234 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements 4235 * the Android Keystore backed by an isolated execution environment. The version indicates 4236 * which features are implemented in the isolated execution environment: 4237 * <ul> 4238 * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support 4239 * for app-generated attestation keys (see {@link 4240 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}). 4241 * <li>41: Hardware enforcement of device-unlocked keys (see {@link 4242 * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}). 4243 * <li>40: Support for wrapped key import (see {@link 4244 * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link 4245 * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}), 4246 * attestation (see {@link 4247 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}), 4248 * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure 4249 * hardware, and support for requiring user authentication before a key can be used. 4250 * </ul> 4251 * This feature version is guaranteed to be set for all devices launching with Android 12 and 4252 * may be set on devices launching with an earlier version. If the feature version is set, it 4253 * will at least have the value 40. If it's not set the device may have a version of 4254 * hardware-backed keystore but it may not support all features listed above. 4255 */ 4256 @SdkConstant(SdkConstantType.FEATURE) 4257 public static final String FEATURE_HARDWARE_KEYSTORE = "android.hardware.hardware_keystore"; 4258 4259 /** 4260 * Feature for {@link #getSystemAvailableFeatures}, {@link #hasSystemFeature(String)}, and 4261 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements 4262 * the Android Keystore backed by a dedicated secure processor referred to as 4263 * <a href="https://source.android.com/security/best-practices/hardware#strongbox-keymaster"> 4264 * StrongBox</a>. If this feature has a version, the version number indicates which features are 4265 * implemented in StrongBox: 4266 * <ul> 4267 * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support 4268 * for app-generated attestation keys (see {@link 4269 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}). 4270 * <li>41: Hardware enforcement of device-unlocked keys (see {@link 4271 * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}). 4272 * <li>40: Support for wrapped key import (see {@link 4273 * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link 4274 * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}), 4275 * attestation (see {@link 4276 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}), 4277 * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure 4278 * hardware, and support for requiring user authentication before a key can be used. 4279 * </ul> 4280 * If a device has StrongBox, this feature version number is guaranteed to be set for all 4281 * devices launching with Android 12 and may be set on devices launching with an earlier 4282 * version. If the feature version is set, it will at least have the value 40. If it's not 4283 * set the device may have StrongBox but it may not support all features listed above. 4284 */ 4285 @SdkConstant(SdkConstantType.FEATURE) 4286 public static final String FEATURE_STRONGBOX_KEYSTORE = 4287 "android.hardware.strongbox_keystore"; 4288 4289 /** 4290 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4291 * The device does not have slices implementation. 4292 * @hide 4293 */ 4294 @SdkConstant(SdkConstantType.FEATURE) 4295 public static final String FEATURE_SLICES_DISABLED = "android.software.slices_disabled"; 4296 4297 /** 4298 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4299 * The device supports device-unique Keystore attestations. Only available on devices that 4300 * also support {@link #FEATURE_STRONGBOX_KEYSTORE}, and can only be used by device owner 4301 * apps (see {@link android.app.admin.DevicePolicyManager#generateKeyPair}). 4302 * @hide 4303 */ 4304 @SdkConstant(SdkConstantType.FEATURE) 4305 public static final String FEATURE_DEVICE_UNIQUE_ATTESTATION = 4306 "android.hardware.device_unique_attestation"; 4307 4308 /** 4309 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4310 * The device has a Keymaster implementation that supports Device ID attestation. 4311 * 4312 * @see DevicePolicyManager#isDeviceIdAttestationSupported 4313 * @hide 4314 */ 4315 @SdkConstant(SdkConstantType.FEATURE) 4316 public static final String FEATURE_DEVICE_ID_ATTESTATION = 4317 "android.software.device_id_attestation"; 4318 4319 /** 4320 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4321 * the requisite kernel support for multinetworking-capable IPsec tunnels. 4322 * 4323 * <p>This feature implies that the device supports XFRM Interfaces (CONFIG_XFRM_INTERFACE), or 4324 * VTIs with kernel patches allowing updates of output/set mark via UPDSA. 4325 */ 4326 @SdkConstant(SdkConstantType.FEATURE) 4327 public static final String FEATURE_IPSEC_TUNNELS = "android.software.ipsec_tunnels"; 4328 4329 /** 4330 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4331 * the requisite kernel support for migrating IPsec tunnels to new source/destination addresses. 4332 * 4333 * <p>This feature implies that the device supports XFRM Migration (CONFIG_XFRM_MIGRATE) and has 4334 * the kernel fixes to support cross-address-family IPsec tunnel migration 4335 */ 4336 @SdkConstant(SdkConstantType.FEATURE) 4337 public static final String FEATURE_IPSEC_TUNNEL_MIGRATION = 4338 "android.software.ipsec_tunnel_migration"; 4339 4340 /** 4341 * Feature for {@link #getSystemAvailableFeatures} and 4342 * {@link #hasSystemFeature}: The device supports a system interface for the user to select 4343 * and bind device control services provided by applications. 4344 * 4345 * @see android.service.controls.ControlsProviderService 4346 */ 4347 @SdkConstant(SdkConstantType.FEATURE) 4348 public static final String FEATURE_CONTROLS = "android.software.controls"; 4349 4350 /** 4351 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4352 * the requisite hardware support to support reboot escrow of synthetic password for updates. 4353 * 4354 * <p>This feature implies that the device has the RebootEscrow HAL implementation. 4355 * 4356 * @hide 4357 */ 4358 @SystemApi 4359 @SdkConstant(SdkConstantType.FEATURE) 4360 public static final String FEATURE_REBOOT_ESCROW = "android.hardware.reboot_escrow"; 4361 4362 /** 4363 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4364 * the requisite kernel support to support incremental delivery aka Incremental FileSystem. 4365 * 4366 * feature not present - IncFs is not present on the device. 4367 * 1 - IncFs v1, core features, no PerUid support. Optional in R. 4368 * 2 - IncFs v2, PerUid support, fs-verity support. Required in S. 4369 * 4370 * @see IncrementalManager#isFeatureEnabled 4371 * @see IncrementalManager#getVersion() 4372 * @hide 4373 */ 4374 @SystemApi 4375 @SdkConstant(SdkConstantType.FEATURE) 4376 public static final String FEATURE_INCREMENTAL_DELIVERY = 4377 "android.software.incremental_delivery"; 4378 4379 /** 4380 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4381 * has the requisite kernel support for the EROFS filesystem present in 4.19 kernels as a 4382 * staging driver, which lacks 0padding and big pcluster support. 4383 * 4384 * @hide 4385 */ 4386 @SystemApi 4387 @SdkConstant(SdkConstantType.FEATURE) 4388 public static final String FEATURE_EROFS_LEGACY = "android.software.erofs_legacy"; 4389 4390 /** 4391 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4392 * has the requisite kernel support for the EROFS filesystem present in 5.10 kernels, which 4393 * has 0padding, big pcluster, and chunked index support. 4394 * 4395 * @hide 4396 */ 4397 @SystemApi 4398 @SdkConstant(SdkConstantType.FEATURE) 4399 public static final String FEATURE_EROFS = "android.software.erofs"; 4400 4401 /** 4402 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4403 * The device has tuner hardware to support tuner operations. 4404 * 4405 * <p>This feature implies that the device has the tuner HAL implementation. 4406 * 4407 * @hide 4408 */ 4409 @SdkConstant(SdkConstantType.FEATURE) 4410 public static final String FEATURE_TUNER = "android.hardware.tv.tuner"; 4411 4412 /** 4413 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4414 * the necessary changes to support app enumeration. 4415 * 4416 * @hide 4417 */ 4418 @SdkConstant(SdkConstantType.FEATURE) 4419 public static final String FEATURE_APP_ENUMERATION = "android.software.app_enumeration"; 4420 4421 /** 4422 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4423 * a Keystore implementation that can only enforce limited use key in hardware with max usage 4424 * count equals to 1. 4425 */ 4426 @SdkConstant(SdkConstantType.FEATURE) 4427 public static final String FEATURE_KEYSTORE_SINGLE_USE_KEY = 4428 "android.hardware.keystore.single_use_key"; 4429 4430 /** 4431 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4432 * a Keystore implementation that can enforce limited use key in hardware with any max usage 4433 * count (including count equals to 1). 4434 */ 4435 @SdkConstant(SdkConstantType.FEATURE) 4436 public static final String FEATURE_KEYSTORE_LIMITED_USE_KEY = 4437 "android.hardware.keystore.limited_use_key"; 4438 4439 /** 4440 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4441 * a Keystore implementation that can create application-specific attestation keys. 4442 * See {@link android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias}. 4443 */ 4444 @SdkConstant(SdkConstantType.FEATURE) 4445 public static final String FEATURE_KEYSTORE_APP_ATTEST_KEY = 4446 "android.hardware.keystore.app_attest_key"; 4447 4448 /** 4449 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4450 * is opted-in to receive per-app compatibility overrides that are applied in 4451 * {@link com.android.server.compat.overrides.AppCompatOverridesService}. 4452 * 4453 * @hide 4454 */ 4455 @SdkConstant(SdkConstantType.FEATURE) 4456 public static final String FEATURE_APP_COMPAT_OVERRIDES = 4457 "android.software.app_compat_overrides"; 4458 4459 /** 4460 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4461 * supports communal mode, 4462 * 4463 * @hide 4464 */ 4465 @SdkConstant(SdkConstantType.FEATURE) 4466 @TestApi 4467 public static final String FEATURE_COMMUNAL_MODE = "android.software.communal_mode"; 4468 4469 /** 4470 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4471 * supports dream overlay feature, which is an informational layer shown on top of dreams. 4472 * 4473 * @hide 4474 */ 4475 @SdkConstant(SdkConstantType.FEATURE) 4476 public static final String FEATURE_DREAM_OVERLAY = "android.software.dream_overlay"; 4477 4478 /** 4479 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4480 * supports window magnification. 4481 * 4482 * @see android.accessibilityservice.MagnificationConfig#MAGNIFICATION_MODE_WINDOW 4483 */ 4484 @SdkConstant(SdkConstantType.FEATURE) 4485 public static final String FEATURE_WINDOW_MAGNIFICATION = 4486 "android.software.window_magnification"; 4487 4488 /** 4489 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4490 * supports retrieval of user credentials, via integration with credential providers. 4491 */ 4492 @SdkConstant(SdkConstantType.FEATURE) 4493 public static final String FEATURE_CREDENTIALS = "android.software.credentials"; 4494 4495 /** 4496 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4497 * supports locking (for example, by a financing provider in case of a missed payment). 4498 */ 4499 @SdkConstant(SdkConstantType.FEATURE) 4500 public static final String FEATURE_DEVICE_LOCK = "android.software.device_lock"; 4501 4502 /** 4503 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4504 * supports showing location-based suggestions for wallet cards provided by the default payment 4505 * app. 4506 */ 4507 @SdkConstant(SdkConstantType.FEATURE) 4508 public static final String FEATURE_WALLET_LOCATION_BASED_SUGGESTIONS = 4509 "android.software.wallet_location_based_suggestions"; 4510 4511 /** @hide */ 4512 public static final boolean APP_ENUMERATION_ENABLED_BY_DEFAULT = true; 4513 4514 /** 4515 * Extra field name for the URI to a verification file. Passed to a package verifier. 4516 * 4517 * @hide 4518 */ 4519 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 4520 4521 /** 4522 * Extra field name for the ID of a package pending verification. Passed to 4523 * a package verifier and is used to call back to 4524 * {@link PackageManager#verifyPendingInstall(int, int)} 4525 */ 4526 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 4527 4528 /** 4529 * Extra field name for the package identifier which is trying to install 4530 * the package. 4531 * 4532 * @hide 4533 */ 4534 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 4535 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 4536 4537 /** 4538 * Extra field name for the requested install flags for a package pending 4539 * verification. Passed to a package verifier. 4540 * 4541 * @hide 4542 */ 4543 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 4544 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 4545 4546 /** 4547 * Extra field name for the uid of who is requesting to install 4548 * the package. 4549 * 4550 * @hide 4551 */ 4552 public static final String EXTRA_VERIFICATION_INSTALLER_UID 4553 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 4554 4555 /** 4556 * Extra field name for the package name of a package pending verification. 4557 * 4558 * @hide 4559 */ 4560 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 4561 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 4562 4563 /** 4564 * Extra field name for the result of a verification, either 4565 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 4566 * Passed to package verifiers after a package is verified. 4567 */ 4568 public static final String EXTRA_VERIFICATION_RESULT 4569 = "android.content.pm.extra.VERIFICATION_RESULT"; 4570 4571 /** 4572 * Extra field name for tracking whether user action 4573 * was requested for a particular install, either {@code true} or {@code false}. 4574 * @hide 4575 */ 4576 public static final String EXTRA_USER_ACTION_REQUIRED 4577 = "android.content.pm.extra.USER_ACTION_REQUIRED"; 4578 4579 /** 4580 * Extra field name for the version code of a package pending verification. 4581 * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead. 4582 * @hide 4583 */ 4584 @Deprecated 4585 public static final String EXTRA_VERIFICATION_VERSION_CODE 4586 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 4587 4588 /** 4589 * Extra field name for the long version code of a package pending verification 4590 * @hide 4591 */ 4592 public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE = 4593 "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE"; 4594 4595 /** 4596 * Extra field name for the Merkle tree root hash of a package. 4597 * <p>Passed to a package verifier both prior to verification and as a result 4598 * of verification. 4599 * <p>The value of the extra is a specially formatted list: 4600 * {@code filename1:HASH_1;filename2:HASH_2;...;filenameN:HASH_N} 4601 * <p>The extra must include an entry for every APK within an installation. If 4602 * a hash is not physically present, a hash value of {@code 0} will be used. 4603 * <p>The root hash is generated using SHA-256, no salt with a 4096 byte block 4604 * size. See the description of the 4605 * <a href="https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#merkle-tree">fs-verity merkle-tree</a> 4606 * for more details. 4607 * @hide 4608 */ 4609 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4610 public static final String EXTRA_VERIFICATION_ROOT_HASH = 4611 "android.content.pm.extra.VERIFICATION_ROOT_HASH"; 4612 4613 /** 4614 * Extra field name for the ID of a intent filter pending verification. 4615 * Passed to an intent filter verifier and is used to call back to 4616 * {@link #verifyIntentFilter} 4617 * 4618 * @deprecated Use DomainVerificationManager APIs. 4619 * @hide 4620 */ 4621 @Deprecated 4622 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 4623 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 4624 4625 /** 4626 * Extra field name for the scheme used for an intent filter pending verification. Passed to 4627 * an intent filter verifier and is used to construct the URI to verify against. 4628 * 4629 * Usually this is "https" 4630 * 4631 * @deprecated Use DomainVerificationManager APIs. 4632 * @hide 4633 */ 4634 @Deprecated 4635 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 4636 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 4637 4638 /** 4639 * Extra field name for the host names to be used for an intent filter pending verification. 4640 * Passed to an intent filter verifier and is used to construct the URI to verify the 4641 * intent filter. 4642 * 4643 * This is a space delimited list of hosts. 4644 * 4645 * @deprecated Use DomainVerificationManager APIs. 4646 * @hide 4647 */ 4648 @Deprecated 4649 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 4650 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 4651 4652 /** 4653 * Extra field name for the package name to be used for an intent filter pending verification. 4654 * Passed to an intent filter verifier and is used to check the verification responses coming 4655 * from the hosts. Each host response will need to include the package name of APK containing 4656 * the intent filter. 4657 * 4658 * @deprecated Use DomainVerificationManager APIs. 4659 * @hide 4660 */ 4661 @Deprecated 4662 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 4663 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 4664 4665 /** 4666 * The action used to request that the user approve a permission request 4667 * from the application. 4668 * 4669 * @hide 4670 */ 4671 @SystemApi 4672 public static final String ACTION_REQUEST_PERMISSIONS = 4673 "android.content.pm.action.REQUEST_PERMISSIONS"; 4674 4675 /** 4676 * The action used to request that the user approve a permission request 4677 * from the application. Sent from an application other than the one whose permissions 4678 * will be granted. Can only be used by the system server. 4679 * 4680 * @hide 4681 */ 4682 @SystemApi 4683 public static final String ACTION_REQUEST_PERMISSIONS_FOR_OTHER = 4684 "android.content.pm.action.REQUEST_PERMISSIONS_FOR_OTHER"; 4685 4686 /** 4687 * The names of the requested permissions. 4688 * <p> 4689 * <strong>Type:</strong> String[] 4690 * </p> 4691 * 4692 * @hide 4693 */ 4694 @SystemApi 4695 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 4696 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 4697 4698 /** 4699 * The results from the permissions request. 4700 * <p> 4701 * <strong>Type:</strong> int[] of #PermissionResult 4702 * </p> 4703 * 4704 * @hide 4705 */ 4706 @SystemApi 4707 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 4708 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 4709 4710 /** 4711 * Indicates that the package requesting permissions has legacy access for some permissions, 4712 * or had it, but it was recently revoked. These request dialogs may show different text, 4713 * indicating that the app is requesting continued access to a permission. Will be cleared 4714 * from any permission request intent, if set by a non-system server app. 4715 * <p> 4716 * <strong>Type:</strong> String[] 4717 * </p> 4718 * 4719 * @hide 4720 */ 4721 @SystemApi 4722 public static final String EXTRA_REQUEST_PERMISSIONS_LEGACY_ACCESS_PERMISSION_NAMES 4723 = "android.content.pm.extra.REQUEST_PERMISSIONS_LEGACY_ACCESS_PERMISSION_NAMES"; 4724 4725 /** 4726 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 4727 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 4728 * the existing definition for the permission. 4729 * @hide 4730 */ 4731 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 4732 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 4733 4734 /** 4735 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 4736 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 4737 * being redundantly defined by the package being installed. 4738 * @hide 4739 */ 4740 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 4741 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 4742 4743 /** 4744 * Permission flag: The permission is set in its current state 4745 * by the user and apps can still request it at runtime. 4746 * 4747 * @hide 4748 */ 4749 @SystemApi 4750 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 4751 4752 /** 4753 * Permission flag: The permission is set in its current state 4754 * by the user and it is fixed, i.e. apps can no longer request 4755 * this permission. 4756 * 4757 * @hide 4758 */ 4759 @SystemApi 4760 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 4761 4762 /** 4763 * Permission flag: The permission is set in its current state 4764 * by device policy and neither apps nor the user can change 4765 * its state. 4766 * 4767 * @hide 4768 */ 4769 @SystemApi 4770 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 4771 4772 /** 4773 * Permission flag: The permission is set in a granted state but 4774 * access to resources it guards is restricted by other means to 4775 * enable revoking a permission on legacy apps that do not support 4776 * runtime permissions. If this permission is upgraded to runtime 4777 * because the app was updated to support runtime permissions, the 4778 * the permission will be revoked in the upgrade process. 4779 * 4780 * @deprecated Renamed to {@link #FLAG_PERMISSION_REVOKED_COMPAT}. 4781 * 4782 * @hide 4783 */ 4784 @Deprecated 4785 @SystemApi 4786 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 4787 4788 /** 4789 * Permission flag: The permission is set in its current state 4790 * because the app is a component that is a part of the system. 4791 * 4792 * @hide 4793 */ 4794 @SystemApi 4795 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 4796 4797 /** 4798 * Permission flag: The permission is granted by default because it 4799 * enables app functionality that is expected to work out-of-the-box 4800 * for providing a smooth user experience. For example, the phone app 4801 * is expected to have the phone permission. 4802 * 4803 * @hide 4804 */ 4805 @SystemApi 4806 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 4807 4808 /** 4809 * Permission flag: If app targetSDK < M, then the permission has to be reviewed before any of 4810 * the app components can run. If app targetSDK >= M, then the system might need to show a 4811 * request dialog for this permission on behalf of an app. 4812 * 4813 * @hide 4814 */ 4815 @SystemApi 4816 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 4817 4818 /** 4819 * Permission flag: The permission has not been explicitly requested by 4820 * the app but has been added automatically by the system. Revoke once 4821 * the app does explicitly request it. 4822 * 4823 * @hide 4824 */ 4825 @TestApi 4826 @SystemApi 4827 public static final int FLAG_PERMISSION_REVOKE_WHEN_REQUESTED = 1 << 7; 4828 4829 /** 4830 * Permission flag: The permission's usage should be made highly visible to the user 4831 * when granted. 4832 * 4833 * @hide 4834 */ 4835 @SystemApi 4836 public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED = 1 << 8; 4837 4838 /** 4839 * Permission flag: The permission's usage should be made highly visible to the user 4840 * when denied. 4841 * 4842 * @hide 4843 */ 4844 @SystemApi 4845 public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED = 1 << 9; 4846 4847 /** 4848 * Permission flag: The permission is restricted but the app is exempt 4849 * from the restriction and is allowed to hold this permission in its 4850 * full form and the exemption is provided by the installer on record. 4851 * 4852 * @hide 4853 */ 4854 @SystemApi 4855 public static final int FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT = 1 << 11; 4856 4857 /** 4858 * Permission flag: The permission is restricted but the app is exempt 4859 * from the restriction and is allowed to hold this permission in its 4860 * full form and the exemption is provided by the system due to its 4861 * permission policy. 4862 * 4863 * @hide 4864 */ 4865 @SystemApi 4866 public static final int FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT = 1 << 12; 4867 4868 /** 4869 * Permission flag: The permission is restricted but the app is exempt 4870 * from the restriction and is allowed to hold this permission and the 4871 * exemption is provided by the system when upgrading from an OS version 4872 * where the permission was not restricted to an OS version where the 4873 * permission is restricted. 4874 * 4875 * @hide 4876 */ 4877 @SystemApi 4878 public static final int FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT = 1 << 13; 4879 4880 4881 /** 4882 * Permission flag: The permission is disabled but may be granted. If 4883 * disabled the data protected by the permission should be protected 4884 * by a no-op (empty list, default error, etc) instead of crashing the 4885 * client. 4886 * 4887 * @hide 4888 */ 4889 @SystemApi 4890 public static final int FLAG_PERMISSION_APPLY_RESTRICTION = 1 << 14; 4891 4892 /** 4893 * Permission flag: The permission is granted because the application holds a role. 4894 * 4895 * @hide 4896 */ 4897 @SystemApi 4898 public static final int FLAG_PERMISSION_GRANTED_BY_ROLE = 1 << 15; 4899 4900 /** 4901 * Permission flag: The permission should have been revoked but is kept granted for 4902 * compatibility. The data protected by the permission should be protected by a no-op (empty 4903 * list, default error, etc) instead of crashing the client. The permission will be revoked if 4904 * the app is upgraded to supports it. 4905 * 4906 * @hide 4907 */ 4908 @SystemApi 4909 public static final int FLAG_PERMISSION_REVOKED_COMPAT = FLAG_PERMISSION_REVOKE_ON_UPGRADE; 4910 4911 /** 4912 * Permission flag: The permission is one-time and should be revoked automatically on app 4913 * inactivity 4914 * 4915 * @hide 4916 */ 4917 @SystemApi 4918 public static final int FLAG_PERMISSION_ONE_TIME = 1 << 16; 4919 4920 /** 4921 * Permission flag: Whether permission was revoked by auto-revoke. 4922 * 4923 * @hide 4924 */ 4925 @SystemApi 4926 public static final int FLAG_PERMISSION_AUTO_REVOKED = 1 << 17; 4927 4928 /** 4929 * Permission flag: This location permission is selected as the level of granularity of 4930 * location accuracy. 4931 * Example: If this flag is set for ACCESS_FINE_LOCATION, FINE location is the selected location 4932 * accuracy for location permissions. 4933 * 4934 * @hide 4935 */ 4936 @SystemApi 4937 public static final int FLAG_PERMISSION_SELECTED_LOCATION_ACCURACY = 1 << 19; 4938 4939 /** 4940 * Permission flags: Reserved for use by the permission controller. The platform and any 4941 * packages besides the permission controller should not assume any definition about these 4942 * flags. 4943 * @hide 4944 */ 4945 @SystemApi 4946 public static final int FLAGS_PERMISSION_RESERVED_PERMISSION_CONTROLLER = 1 << 28 | 1 << 29 4947 | 1 << 30 | 1 << 31; 4948 4949 /** 4950 * Permission flags: Bitwise or of all permission flags allowing an 4951 * exemption for a restricted permission. 4952 * @hide 4953 */ 4954 public static final int FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT = 4955 FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT 4956 | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT 4957 | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT; 4958 4959 /** 4960 * Mask for all permission flags. 4961 * 4962 * @hide 4963 * 4964 * @deprecated Don't use - does not capture all flags. 4965 */ 4966 @Deprecated 4967 @SystemApi 4968 public static final int MASK_PERMISSION_FLAGS = 0xFF; 4969 4970 /** 4971 * Mask for all permission flags. 4972 * 4973 * @hide 4974 */ 4975 public static final int MASK_PERMISSION_FLAGS_ALL = FLAG_PERMISSION_USER_SET 4976 | FLAG_PERMISSION_USER_FIXED 4977 | FLAG_PERMISSION_POLICY_FIXED 4978 | FLAG_PERMISSION_REVOKE_ON_UPGRADE 4979 | FLAG_PERMISSION_SYSTEM_FIXED 4980 | FLAG_PERMISSION_GRANTED_BY_DEFAULT 4981 | FLAG_PERMISSION_REVIEW_REQUIRED 4982 | FLAG_PERMISSION_REVOKE_WHEN_REQUESTED 4983 | FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED 4984 | FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED 4985 | FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT 4986 | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT 4987 | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT 4988 | FLAG_PERMISSION_APPLY_RESTRICTION 4989 | FLAG_PERMISSION_GRANTED_BY_ROLE 4990 | FLAG_PERMISSION_REVOKED_COMPAT 4991 | FLAG_PERMISSION_ONE_TIME 4992 | FLAG_PERMISSION_AUTO_REVOKED; 4993 4994 /** 4995 * Injected activity in app that forwards user to setting activity of that app. 4996 * 4997 * @hide 4998 */ 4999 public static final String APP_DETAILS_ACTIVITY_CLASS_NAME = AppDetailsActivity.class.getName(); 5000 5001 /** 5002 * Permission whitelist flag: permissions whitelisted by the system. 5003 * Permissions can also be whitelisted by the installer, on upgrade, or on 5004 * role grant. 5005 * 5006 * <p> 5007 * <strong>Note: </strong>In retrospect it would have been preferred to use 5008 * more inclusive terminology when naming this API. Similar APIs added will 5009 * refrain from using the term "whitelist". 5010 * </p> 5011 */ 5012 public static final int FLAG_PERMISSION_WHITELIST_SYSTEM = 1 << 0; 5013 5014 /** 5015 * Permission whitelist flag: permissions whitelisted by the installer. 5016 * Permissions can also be whitelisted by the system, on upgrade, or on role 5017 * grant. 5018 * 5019 * <p> 5020 * <strong>Note: </strong>In retrospect it would have been preferred to use 5021 * more inclusive terminology when naming this API. Similar APIs added will 5022 * refrain from using the term "whitelist". 5023 * </p> 5024 */ 5025 public static final int FLAG_PERMISSION_WHITELIST_INSTALLER = 1 << 1; 5026 5027 /** 5028 * Permission whitelist flag: permissions whitelisted by the system 5029 * when upgrading from an OS version where the permission was not 5030 * restricted to an OS version where the permission is restricted. 5031 * Permissions can also be whitelisted by the installer, the system, or on 5032 * role grant. 5033 * 5034 * <p> 5035 * <strong>Note: </strong>In retrospect it would have been preferred to use 5036 * more inclusive terminology when naming this API. Similar APIs added will 5037 * refrain from using the term "whitelist". 5038 * </p> 5039 */ 5040 public static final int FLAG_PERMISSION_WHITELIST_UPGRADE = 1 << 2; 5041 5042 /** @hide */ 5043 @IntDef(flag = true, prefix = {"FLAG_PERMISSION_WHITELIST_"}, value = { 5044 FLAG_PERMISSION_WHITELIST_SYSTEM, 5045 FLAG_PERMISSION_WHITELIST_INSTALLER, 5046 FLAG_PERMISSION_WHITELIST_UPGRADE 5047 }) 5048 @Retention(RetentionPolicy.SOURCE) 5049 public @interface PermissionWhitelistFlags {} 5050 5051 /** 5052 * This is a library that contains components apps can invoke. For 5053 * example, a services for apps to bind to, or standard chooser UI, 5054 * etc. This library is versioned and backwards compatible. Clients 5055 * should check its version via {@link android.ext.services.Version 5056 * #getVersionCode()} and avoid calling APIs added in later versions. 5057 * <p> 5058 * This shared library no longer exists since Android R. 5059 * 5060 * @see #getServicesSystemSharedLibraryPackageName() 5061 * 5062 * @hide 5063 */ 5064 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 5065 @TestApi 5066 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 5067 5068 /** 5069 * This is a library that contains components apps can dynamically 5070 * load. For example, new widgets, helper classes, etc. This library 5071 * is versioned and backwards compatible. Clients should check its 5072 * version via {@link android.ext.shared.Version#getVersionCode()} 5073 * and avoid calling APIs added in later versions. 5074 * 5075 * @hide 5076 */ 5077 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 5078 @TestApi 5079 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 5080 5081 /** @hide */ 5082 @IntDef({ 5083 NOTIFY_PACKAGE_USE_ACTIVITY, 5084 NOTIFY_PACKAGE_USE_SERVICE, 5085 NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE, 5086 NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER, 5087 NOTIFY_PACKAGE_USE_CONTENT_PROVIDER, 5088 NOTIFY_PACKAGE_USE_BACKUP, 5089 NOTIFY_PACKAGE_USE_CROSS_PACKAGE, 5090 NOTIFY_PACKAGE_USE_INSTRUMENTATION, 5091 }) 5092 public @interface NotifyReason { 5093 } 5094 5095 /** 5096 * Used when starting a process for an Activity. 5097 * 5098 * @hide 5099 */ 5100 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0; 5101 5102 /** 5103 * Used when starting a process for a Service. 5104 * 5105 * @hide 5106 */ 5107 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1; 5108 5109 /** 5110 * Used when moving a Service to the foreground. 5111 * 5112 * @hide 5113 */ 5114 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2; 5115 5116 /** 5117 * Used when starting a process for a BroadcastReceiver. 5118 * 5119 * @hide 5120 */ 5121 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3; 5122 5123 /** 5124 * Used when starting a process for a ContentProvider. 5125 * 5126 * @hide 5127 */ 5128 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4; 5129 5130 /** 5131 * Used when starting a process for a BroadcastReceiver. 5132 * 5133 * @hide 5134 */ 5135 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5; 5136 5137 /** 5138 * Used with Context.getClassLoader() across Android packages. 5139 * 5140 * @hide 5141 */ 5142 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6; 5143 5144 /** 5145 * Used when starting a package within a process for Instrumentation. 5146 * 5147 * @hide 5148 */ 5149 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7; 5150 5151 /** 5152 * Total number of usage reasons. 5153 * 5154 * @hide 5155 */ 5156 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8; 5157 5158 /** 5159 * Constant for specifying the highest installed package version code. 5160 */ 5161 public static final int VERSION_CODE_HIGHEST = -1; 5162 5163 /** 5164 * Apps targeting Android R and above will need to declare the packages and intents they intend 5165 * to use to get details about other apps on a device. Such declarations must be made via the 5166 * {@code <queries>} tag in the manifest. 5167 * 5168 * @hide 5169 */ 5170 @ChangeId 5171 @EnabledSince(targetSdkVersion = Build.VERSION_CODES.R) 5172 public static final long FILTER_APPLICATION_QUERY = 135549675L; 5173 5174 /** {@hide} */ 5175 @IntDef(prefix = {"SYSTEM_APP_STATE_"}, value = { 5176 SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN, 5177 SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE, 5178 SYSTEM_APP_STATE_INSTALLED, 5179 SYSTEM_APP_STATE_UNINSTALLED 5180 }) 5181 @Retention(RetentionPolicy.SOURCE) 5182 public @interface SystemAppState {} 5183 5184 /** 5185 * Constant for use with {@link #setSystemAppState} to mark a system app as hidden until 5186 * installation. 5187 * @hide 5188 */ 5189 @SystemApi 5190 public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN = 0; 5191 5192 /** 5193 * Constant for use with {@link #setSystemAppState} to mark a system app as not hidden until 5194 * installation. 5195 * @hide 5196 */ 5197 @SystemApi 5198 public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE = 1; 5199 5200 /** 5201 * Constant for use with {@link #setSystemAppState} to change a system app's state to installed. 5202 * @hide 5203 */ 5204 @SystemApi 5205 public static final int SYSTEM_APP_STATE_INSTALLED = 2; 5206 5207 /** 5208 * Constant for use with {@link #setSystemAppState} to change a system app's state to 5209 * uninstalled. 5210 * @hide 5211 */ 5212 @SystemApi 5213 public static final int SYSTEM_APP_STATE_UNINSTALLED = 3; 5214 5215 /** 5216 * A manifest property to control app's participation in {@code adb backup}. Should only 5217 * be used by system / privileged apps. 5218 * 5219 * @hide 5220 */ 5221 public static final String PROPERTY_ALLOW_ADB_BACKUP = "android.backup.ALLOW_ADB_BACKUP"; 5222 5223 /** 5224 * Flags class that wraps around the bitmask flags used in methods that retrieve package or 5225 * application info. 5226 * @hide 5227 */ 5228 public static class Flags { 5229 final long mValue; Flags(long value)5230 protected Flags(long value) { 5231 mValue = value; 5232 } getValue()5233 public long getValue() { 5234 return mValue; 5235 } 5236 } 5237 5238 /** 5239 * Specific flags used for retrieving package info. Example: 5240 * {@code PackageManager.getPackageInfo(packageName, PackageInfoFlags.of(0)} 5241 */ 5242 public final static class PackageInfoFlags extends Flags { PackageInfoFlags(@ackageInfoFlagsBits long value)5243 private PackageInfoFlags(@PackageInfoFlagsBits long value) { 5244 super(value); 5245 } 5246 @NonNull of(@ackageInfoFlagsBits long value)5247 public static PackageInfoFlags of(@PackageInfoFlagsBits long value) { 5248 return new PackageInfoFlags(value); 5249 } 5250 } 5251 5252 /** 5253 * Specific flags used for retrieving application info. 5254 */ 5255 public final static class ApplicationInfoFlags extends Flags { ApplicationInfoFlags(@pplicationInfoFlagsBits long value)5256 private ApplicationInfoFlags(@ApplicationInfoFlagsBits long value) { 5257 super(value); 5258 } 5259 @NonNull of(@pplicationInfoFlagsBits long value)5260 public static ApplicationInfoFlags of(@ApplicationInfoFlagsBits long value) { 5261 return new ApplicationInfoFlags(value); 5262 } 5263 } 5264 5265 /** 5266 * Specific flags used for retrieving component info. 5267 */ 5268 public final static class ComponentInfoFlags extends Flags { ComponentInfoFlags(@omponentInfoFlagsBits long value)5269 private ComponentInfoFlags(@ComponentInfoFlagsBits long value) { 5270 super(value); 5271 } 5272 @NonNull of(@omponentInfoFlagsBits long value)5273 public static ComponentInfoFlags of(@ComponentInfoFlagsBits long value) { 5274 return new ComponentInfoFlags(value); 5275 } 5276 } 5277 5278 /** 5279 * Specific flags used for retrieving resolve info. 5280 */ 5281 public final static class ResolveInfoFlags extends Flags { ResolveInfoFlags(@esolveInfoFlagsBits long value)5282 private ResolveInfoFlags(@ResolveInfoFlagsBits long value) { 5283 super(value); 5284 } 5285 @NonNull of(@esolveInfoFlagsBits long value)5286 public static ResolveInfoFlags of(@ResolveInfoFlagsBits long value) { 5287 return new ResolveInfoFlags(value); 5288 } 5289 } 5290 5291 /** {@hide} */ getUserId()5292 public int getUserId() { 5293 return UserHandle.myUserId(); 5294 } 5295 5296 /** 5297 * @deprecated Do not instantiate or subclass - obtain an instance from 5298 * {@link Context#getPackageManager} 5299 */ 5300 @Deprecated PackageManager()5301 public PackageManager() {} 5302 5303 /** 5304 * Retrieve overall information about an application package that is 5305 * installed on the system. 5306 * 5307 * Use {@link #getPackageInfo(String, PackageInfoFlags)} when long flags are needed. 5308 * 5309 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5310 * desired package. 5311 * @param flags Additional option flags to modify the data returned. 5312 * @return A PackageInfo object containing information about the package. If 5313 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 5314 * is not found in the list of installed applications, the package 5315 * information is retrieved from the list of uninstalled 5316 * applications (which includes installed applications as well as 5317 * applications with data directory i.e. applications which had been 5318 * deleted with {@code DELETE_KEEP_DATA} flag set). 5319 * @throws NameNotFoundException if no such package is available to the 5320 * caller. 5321 */ getPackageInfo(@onNull String packageName, int flags)5322 public abstract PackageInfo getPackageInfo(@NonNull String packageName, int flags) 5323 throws NameNotFoundException; 5324 5325 /** 5326 * See {@link #getPackageInfo(String, int)} 5327 */ 5328 @NonNull getPackageInfo(@onNull String packageName, @NonNull PackageInfoFlags flags)5329 public PackageInfo getPackageInfo(@NonNull String packageName, @NonNull PackageInfoFlags flags) 5330 throws NameNotFoundException { 5331 throw new UnsupportedOperationException( 5332 "getPackageInfo not implemented in subclass"); 5333 } 5334 5335 /** 5336 * Retrieve overall information about an application package that is 5337 * installed on the system. This method can be used for retrieving 5338 * information about packages for which multiple versions can be installed 5339 * at the time. Currently only packages hosting static shared libraries can 5340 * have multiple installed versions. The method can also be used to get info 5341 * for a package that has a single version installed by passing 5342 * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage} 5343 * constructor. 5344 * 5345 * Use {@link #getPackageInfo(VersionedPackage, PackageInfoFlags)} when long flags are needed. 5346 * 5347 * @param versionedPackage The versioned package for which to query. 5348 * @param flags Additional option flags to modify the data returned. 5349 * @return A PackageInfo object containing information about the package. If 5350 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 5351 * is not found in the list of installed applications, the package 5352 * information is retrieved from the list of uninstalled 5353 * applications (which includes installed applications as well as 5354 * applications with data directory i.e. applications which had been 5355 * deleted with {@code DELETE_KEEP_DATA} flag set). 5356 * @throws NameNotFoundException if no such package is available to the 5357 * caller. 5358 */ getPackageInfo(@onNull VersionedPackage versionedPackage, int flags)5359 public abstract PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage, 5360 int flags) throws NameNotFoundException; 5361 5362 /** 5363 * See {@link #getPackageInfo(VersionedPackage, int)} 5364 */ 5365 @NonNull getPackageInfo(@onNull VersionedPackage versionedPackage, @NonNull PackageInfoFlags flags)5366 public PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage, 5367 @NonNull PackageInfoFlags flags) throws NameNotFoundException { 5368 throw new UnsupportedOperationException( 5369 "getPackageInfo not implemented in subclass"); 5370 } 5371 5372 /** 5373 * Retrieve overall information about an application package that is 5374 * installed on the system. 5375 * 5376 * Use {@link #getPackageInfoAsUser(String, PackageInfoFlags, int)} when long flags are needed. 5377 * 5378 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5379 * desired package. 5380 * @param flags Additional option flags to modify the data returned. 5381 * @param userId The user id. 5382 * @return A PackageInfo object containing information about the package. If 5383 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 5384 * is not found in the list of installed applications, the package 5385 * information is retrieved from the list of uninstalled 5386 * applications (which includes installed applications as well as 5387 * applications with data directory i.e. applications which had been 5388 * deleted with {@code DELETE_KEEP_DATA} flag set). 5389 * @throws NameNotFoundException if no such package is available to the 5390 * caller. 5391 * @hide 5392 */ 5393 @SuppressWarnings("HiddenAbstractMethod") 5394 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 5395 @UnsupportedAppUsage getPackageInfoAsUser(@onNull String packageName, int flags, @UserIdInt int userId)5396 public abstract PackageInfo getPackageInfoAsUser(@NonNull String packageName, 5397 int flags, @UserIdInt int userId) throws NameNotFoundException; 5398 5399 /** 5400 * See {@link #getPackageInfoAsUser(String, int, int)} 5401 * @hide 5402 */ 5403 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 5404 @NonNull getPackageInfoAsUser(@onNull String packageName, @NonNull PackageInfoFlags flags, @UserIdInt int userId)5405 public PackageInfo getPackageInfoAsUser(@NonNull String packageName, 5406 @NonNull PackageInfoFlags flags, @UserIdInt int userId) throws NameNotFoundException { 5407 throw new UnsupportedOperationException( 5408 "getPackageInfoAsUser not implemented in subclass"); 5409 } 5410 5411 /** 5412 * Map from the current package names in use on the device to whatever 5413 * the current canonical name of that package is. 5414 * @param packageNames Array of current names to be mapped. 5415 * @return Returns an array of the same size as the original, containing 5416 * the canonical name for each package. 5417 */ currentToCanonicalPackageNames(@onNull String[] packageNames)5418 public abstract String[] currentToCanonicalPackageNames(@NonNull String[] packageNames); 5419 5420 /** 5421 * Map from a packages canonical name to the current name in use on the device. 5422 * @param packageNames Array of new names to be mapped. 5423 * @return Returns an array of the same size as the original, containing 5424 * the current name for each package. 5425 */ canonicalToCurrentPackageNames(@onNull String[] packageNames)5426 public abstract String[] canonicalToCurrentPackageNames(@NonNull String[] packageNames); 5427 5428 /** 5429 * Returns a "good" intent to launch a front-door activity in a package. 5430 * This is used, for example, to implement an "open" button when browsing 5431 * through packages. The current implementation looks first for a main 5432 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 5433 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 5434 * <code>null</code> if neither are found. 5435 * 5436 * <p>Consider using {@link #getLaunchIntentSenderForPackage(String)} if 5437 * the caller is not allowed to query for the <code>packageName</code>. 5438 * 5439 * @param packageName The name of the package to inspect. 5440 * 5441 * @return A fully-qualified {@link Intent} that can be used to launch the 5442 * main activity in the package. Returns <code>null</code> if the package 5443 * does not contain such an activity, or if <em>packageName</em> is not 5444 * recognized. 5445 * 5446 * @see #getLaunchIntentSenderForPackage(String) 5447 */ getLaunchIntentForPackage(@onNull String packageName)5448 public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName); 5449 5450 /** 5451 * Return a "good" intent to launch a front-door Leanback activity in a 5452 * package, for use for example to implement an "open" button when browsing 5453 * through packages. The current implementation will look for a main 5454 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 5455 * return null if no main leanback activities are found. 5456 * 5457 * @param packageName The name of the package to inspect. 5458 * @return Returns either a fully-qualified Intent that can be used to launch 5459 * the main Leanback activity in the package, or null if the package 5460 * does not contain such an activity. 5461 */ getLeanbackLaunchIntentForPackage(@onNull String packageName)5462 public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName); 5463 5464 /** 5465 * Return a "good" intent to launch a front-door Car activity in a 5466 * package, for use for example to implement an "open" button when browsing 5467 * through packages. The current implementation will look for a main 5468 * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or 5469 * return null if no main car activities are found. 5470 * 5471 * @param packageName The name of the package to inspect. 5472 * @return Returns either a fully-qualified Intent that can be used to launch 5473 * the main Car activity in the package, or null if the package 5474 * does not contain such an activity. 5475 * @hide 5476 */ 5477 @SuppressWarnings("HiddenAbstractMethod") getCarLaunchIntentForPackage(@onNull String packageName)5478 public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName); 5479 5480 /** 5481 * Returns an {@link IntentSender} that can be used to launch a front-door activity in a 5482 * package. This is used, for example, to implement an "open" button when browsing through 5483 * packages. The current implementation is the same with 5484 * {@link #getLaunchIntentForPackage(String)}. Instead of returning the {@link Intent}, it 5485 * returns the {@link IntentSender} which is not restricted by the package visibility. 5486 * 5487 * <p>The caller can invoke 5488 * {@link IntentSender#sendIntent(Context, int, Intent, IntentSender.OnFinished, Handler)} 5489 * to launch the activity. An {@link IntentSender.SendIntentException} is thrown if the 5490 * package does not contain such an activity, or if <em>packageName</em> is not recognized. 5491 * 5492 * @param packageName The name of the package to inspect. 5493 * @return Returns a {@link IntentSender} to launch the activity. 5494 * 5495 * @see #getLaunchIntentForPackage(String) 5496 */ getLaunchIntentSenderForPackage(@onNull String packageName)5497 public @NonNull IntentSender getLaunchIntentSenderForPackage(@NonNull String packageName) { 5498 throw new UnsupportedOperationException("getLaunchIntentSenderForPackage not implemented" 5499 + "in subclass"); 5500 } 5501 5502 /** 5503 * Return an array of all of the POSIX secondary group IDs that have been 5504 * assigned to the given package. 5505 * <p> 5506 * Note that the same package may have different GIDs under different 5507 * {@link UserHandle} on the same device. 5508 * 5509 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5510 * desired package. 5511 * @return Returns an int array of the assigned GIDs, or null if there are 5512 * none. 5513 * @throws NameNotFoundException if no such package is available to the 5514 * caller. 5515 */ getPackageGids(@onNull String packageName)5516 public abstract int[] getPackageGids(@NonNull String packageName) 5517 throws NameNotFoundException; 5518 5519 /** 5520 * Return an array of all of the POSIX secondary group IDs that have been 5521 * assigned to the given package. 5522 * <p> 5523 * Note that the same package may have different GIDs under different 5524 * {@link UserHandle} on the same device. 5525 * 5526 * Use {@link #getPackageGids(String, PackageInfoFlags)} when long flags are needed. 5527 * 5528 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5529 * desired package. 5530 * @return Returns an int array of the assigned gids, or null if there are 5531 * none. 5532 * @throws NameNotFoundException if no such package is available to the 5533 * caller. 5534 */ 5535 getPackageGids(@onNull String packageName, int flags)5536 public abstract int[] getPackageGids(@NonNull String packageName, int flags) 5537 throws NameNotFoundException; 5538 5539 /** 5540 * See {@link #getPackageGids(String, int)}. 5541 */ 5542 @Nullable getPackageGids(@onNull String packageName, @NonNull PackageInfoFlags flags)5543 public int[] getPackageGids(@NonNull String packageName, @NonNull PackageInfoFlags flags) 5544 throws NameNotFoundException { 5545 throw new UnsupportedOperationException( 5546 "getPackageGids not implemented in subclass"); 5547 } 5548 5549 /** 5550 * Return the UID associated with the given package name. 5551 * <p> 5552 * Note that the same package will have different UIDs under different 5553 * {@link UserHandle} on the same device. 5554 * 5555 * Use {@link #getPackageUid(String, PackageInfoFlags)} when long flags are needed. 5556 * 5557 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5558 * desired package. 5559 * @return Returns an integer UID who owns the given package name. 5560 * @throws NameNotFoundException if no such package is available to the 5561 * caller. 5562 */ getPackageUid(@onNull String packageName, int flags)5563 public abstract int getPackageUid(@NonNull String packageName, int flags) 5564 throws NameNotFoundException; 5565 5566 /** 5567 * See {@link #getPackageUid(String, int)}. 5568 */ getPackageUid(@onNull String packageName, @NonNull PackageInfoFlags flags)5569 public int getPackageUid(@NonNull String packageName, @NonNull PackageInfoFlags flags) 5570 throws NameNotFoundException { 5571 throw new UnsupportedOperationException( 5572 "getPackageUid not implemented in subclass"); 5573 } 5574 5575 /** 5576 * Return the UID associated with the given package name. 5577 * <p> 5578 * Note that the same package will have different UIDs under different 5579 * {@link UserHandle} on the same device. 5580 * 5581 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5582 * desired package. 5583 * @param userId The user handle identifier to look up the package under. 5584 * @return Returns an integer UID who owns the given package name. 5585 * @throws NameNotFoundException if no such package is available to the 5586 * caller. 5587 * @hide 5588 */ 5589 @SuppressWarnings("HiddenAbstractMethod") 5590 @UnsupportedAppUsage getPackageUidAsUser(@onNull String packageName, @UserIdInt int userId)5591 public abstract int getPackageUidAsUser(@NonNull String packageName, @UserIdInt int userId) 5592 throws NameNotFoundException; 5593 5594 /** 5595 * See {@link #getPackageUidAsUser(String, PackageInfoFlags, int)}. 5596 * Use {@link #getPackageUidAsUser(String, PackageInfoFlags, int)} when long flags are needed. 5597 * @hide 5598 */ 5599 @SuppressWarnings("HiddenAbstractMethod") 5600 @UnsupportedAppUsage getPackageUidAsUser(@onNull String packageName, int flags, @UserIdInt int userId)5601 public abstract int getPackageUidAsUser(@NonNull String packageName, 5602 int flags, @UserIdInt int userId) throws NameNotFoundException; 5603 5604 /** 5605 * Return the UID associated with the given package name. 5606 * <p> 5607 * Note that the same package will have different UIDs under different 5608 * {@link UserHandle} on the same device. 5609 * 5610 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5611 * desired package. 5612 * @param flags Additional option flags to modify the data returned. 5613 * @param userId The user handle identifier to look up the package under. 5614 * @return Returns an integer UID who owns the given package name. 5615 * @throws NameNotFoundException if no such package is available to the 5616 * caller. 5617 * @hide 5618 */ 5619 @SystemApi 5620 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) getPackageUidAsUser(@onNull String packageName, @NonNull PackageInfoFlags flags, @UserIdInt int userId)5621 public int getPackageUidAsUser(@NonNull String packageName, @NonNull PackageInfoFlags flags, 5622 @UserIdInt int userId) throws NameNotFoundException { 5623 throw new UnsupportedOperationException( 5624 "getPackageUidAsUser not implemented in subclass"); 5625 } 5626 5627 /** 5628 * Retrieve all of the information we know about a particular permission. 5629 * 5630 * @param permName The fully qualified name (i.e. com.google.permission.LOGIN) 5631 * of the permission you are interested in. 5632 * @param flags Additional option flags to modify the data returned. 5633 * @return Returns a {@link PermissionInfo} containing information about the 5634 * permission. 5635 * @throws NameNotFoundException if a package with the given name cannot be 5636 * found on the system. 5637 */ 5638 //@Deprecated getPermissionInfo(@onNull String permName, @PermissionInfoFlags int flags)5639 public abstract PermissionInfo getPermissionInfo(@NonNull String permName, 5640 @PermissionInfoFlags int flags) throws NameNotFoundException; 5641 5642 /** 5643 * Query for all of the permissions associated with a particular group. 5644 * 5645 * @param permissionGroup The fully qualified name (i.e. com.google.permission.LOGIN) 5646 * of the permission group you are interested in. Use {@code null} to 5647 * find all of the permissions not associated with a group. 5648 * @param flags Additional option flags to modify the data returned. 5649 * @return Returns a list of {@link PermissionInfo} containing information 5650 * about all of the permissions in the given group. 5651 * @throws NameNotFoundException if a group with the given name cannot be 5652 * found on the system. 5653 */ 5654 //@Deprecated 5655 @NonNull queryPermissionsByGroup(@ullable String permissionGroup, @PermissionInfoFlags int flags)5656 public abstract List<PermissionInfo> queryPermissionsByGroup(@Nullable String permissionGroup, 5657 @PermissionInfoFlags int flags) throws NameNotFoundException; 5658 5659 /** 5660 * Returns true if some permissions are individually controlled. 5661 * 5662 * <p>The user usually grants and revokes permission-groups. If this option is set some 5663 * dangerous system permissions can be revoked/granted by the user separately from their group. 5664 * 5665 * @hide 5666 */ 5667 @SuppressWarnings("HiddenAbstractMethod") 5668 @SystemApi arePermissionsIndividuallyControlled()5669 public abstract boolean arePermissionsIndividuallyControlled(); 5670 5671 /** 5672 * Returns true if wireless consent mode is enabled 5673 * 5674 * @hide 5675 */ 5676 @SuppressWarnings("HiddenAbstractMethod") isWirelessConsentModeEnabled()5677 public abstract boolean isWirelessConsentModeEnabled(); 5678 5679 /** 5680 * Retrieve all of the information we know about a particular group of 5681 * permissions. 5682 * 5683 * @param groupName The fully qualified name (i.e. 5684 * com.google.permission_group.APPS) of the permission you are 5685 * interested in. 5686 * @param flags Additional option flags to modify the data returned. 5687 * @return Returns a {@link PermissionGroupInfo} containing information 5688 * about the permission. 5689 * @throws NameNotFoundException if a package with the given name cannot be 5690 * found on the system. 5691 */ 5692 //@Deprecated 5693 @NonNull getPermissionGroupInfo(@onNull String groupName, @PermissionGroupInfoFlags int flags)5694 public abstract PermissionGroupInfo getPermissionGroupInfo(@NonNull String groupName, 5695 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 5696 5697 /** 5698 * Retrieve all of the known permission groups in the system. 5699 * 5700 * @param flags Additional option flags to modify the data returned. 5701 * @return Returns a list of {@link PermissionGroupInfo} containing 5702 * information about all of the known permission groups. 5703 */ 5704 //@Deprecated 5705 @NonNull getAllPermissionGroups( @ermissionGroupInfoFlags int flags)5706 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 5707 @PermissionGroupInfoFlags int flags); 5708 5709 /** 5710 * Get the platform-defined permissions which belong to a particular permission group. 5711 * 5712 * @param permissionGroupName the permission group whose permissions are desired 5713 * @param executor the {@link Executor} on which to invoke the callback 5714 * @param callback the callback which will receive a list of the platform-defined permissions in 5715 * the group, or empty if the group is not a valid platform-defined permission 5716 * group, or there was an exception 5717 */ getPlatformPermissionsForGroup(@onNull String permissionGroupName, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<List<String>> callback)5718 public void getPlatformPermissionsForGroup(@NonNull String permissionGroupName, 5719 @NonNull @CallbackExecutor Executor executor, 5720 @NonNull Consumer<List<String>> callback) {} 5721 5722 /** 5723 * Get the platform-defined permission group of a particular permission, if the permission is a 5724 * platform-defined permission. 5725 * 5726 * @param permissionName the permission whose group is desired 5727 * @param executor the {@link Executor} on which to invoke the callback 5728 * @param callback the callback which will receive the name of the permission group this 5729 * permission belongs to, or {@code null} if it has no group, is not a 5730 * platform-defined permission, or there was an exception 5731 */ getGroupOfPlatformPermission(@onNull String permissionName, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback)5732 public void getGroupOfPlatformPermission(@NonNull String permissionName, 5733 @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback) {} 5734 5735 /** 5736 * Retrieve all of the information we know about a particular 5737 * package/application. 5738 * 5739 * Use {@link #getApplicationInfo(String, ApplicationInfoFlags)} when long flags are needed. 5740 * 5741 * @param packageName The full name (i.e. com.google.apps.contacts) of an 5742 * application. 5743 * @param flags Additional option flags to modify the data returned. 5744 * @return An {@link ApplicationInfo} containing information about the 5745 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if 5746 * the package is not found in the list of installed applications, 5747 * the application information is retrieved from the list of 5748 * uninstalled applications (which includes installed applications 5749 * as well as applications with data directory i.e. applications 5750 * which had been deleted with {@code DELETE_KEEP_DATA} flag set). 5751 * @throws NameNotFoundException if a package with the given name cannot be 5752 * found on the system. 5753 */ 5754 @NonNull getApplicationInfo(@onNull String packageName, int flags)5755 public abstract ApplicationInfo getApplicationInfo(@NonNull String packageName, 5756 int flags) throws NameNotFoundException; 5757 5758 /** 5759 * See {@link #getApplicationInfo(String, int)}. 5760 */ 5761 @NonNull getApplicationInfo(@onNull String packageName, @NonNull ApplicationInfoFlags flags)5762 public ApplicationInfo getApplicationInfo(@NonNull String packageName, 5763 @NonNull ApplicationInfoFlags flags) throws NameNotFoundException { 5764 throw new UnsupportedOperationException( 5765 "getApplicationInfo not implemented in subclass"); 5766 } 5767 5768 /** 5769 * Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, int)} when long flags are 5770 * needed. 5771 * {@hide} 5772 */ 5773 @SuppressWarnings("HiddenAbstractMethod") 5774 @NonNull 5775 @UnsupportedAppUsage getApplicationInfoAsUser(@onNull String packageName, int flags, @UserIdInt int userId)5776 public abstract ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 5777 int flags, @UserIdInt int userId) throws NameNotFoundException; 5778 5779 /** {@hide} */ 5780 @NonNull getApplicationInfoAsUser(@onNull String packageName, @NonNull ApplicationInfoFlags flags, @UserIdInt int userId)5781 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 5782 @NonNull ApplicationInfoFlags flags, @UserIdInt int userId) 5783 throws NameNotFoundException { 5784 throw new UnsupportedOperationException( 5785 "getApplicationInfoAsUser not implemented in subclass"); 5786 } 5787 5788 /** 5789 * Retrieve all of the information we know about a particular 5790 * package/application, for a specific user. 5791 * 5792 * Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, UserHandle)} when long 5793 * flags are needed. 5794 * 5795 * @param packageName The full name (i.e. com.google.apps.contacts) of an 5796 * application. 5797 * @param flags Additional option flags to modify the data returned. 5798 * @return An {@link ApplicationInfo} containing information about the 5799 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if 5800 * the package is not found in the list of installed applications, 5801 * the application information is retrieved from the list of 5802 * uninstalled applications (which includes installed applications 5803 * as well as applications with data directory i.e. applications 5804 * which had been deleted with {@code DELETE_KEEP_DATA} flag set). 5805 * @throws NameNotFoundException if a package with the given name cannot be 5806 * found on the system. 5807 * @hide 5808 */ 5809 @NonNull 5810 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 5811 @SystemApi getApplicationInfoAsUser(@onNull String packageName, int flags, @NonNull UserHandle user)5812 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 5813 int flags, @NonNull UserHandle user) 5814 throws NameNotFoundException { 5815 return getApplicationInfoAsUser(packageName, flags, user.getIdentifier()); 5816 } 5817 5818 /** 5819 * See {@link #getApplicationInfoAsUser(String, int, UserHandle)}. 5820 * @hide 5821 */ 5822 @NonNull 5823 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 5824 @SystemApi getApplicationInfoAsUser(@onNull String packageName, @NonNull ApplicationInfoFlags flags, @NonNull UserHandle user)5825 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 5826 @NonNull ApplicationInfoFlags flags, @NonNull UserHandle user) 5827 throws NameNotFoundException { 5828 return getApplicationInfoAsUser(packageName, flags, user.getIdentifier()); 5829 } 5830 5831 /** 5832 * @return The target SDK version for the given package name. 5833 * @throws NameNotFoundException if a package with the given name cannot be found on the system. 5834 */ 5835 @IntRange(from = 0) getTargetSdkVersion(@onNull String packageName)5836 public int getTargetSdkVersion(@NonNull String packageName) throws NameNotFoundException { 5837 throw new UnsupportedOperationException(); 5838 } 5839 5840 /** 5841 * Retrieve all of the information we know about a particular activity 5842 * class. 5843 * 5844 * Use {@link #getActivityInfo(ComponentName, ComponentInfoFlags)} when long flags are needed. 5845 * 5846 * @param component The full component name (i.e. 5847 * com.google.apps.contacts/com.google.apps.contacts. 5848 * ContactsList) of an Activity class. 5849 * @param flags Additional option flags to modify the data returned. 5850 * @return An {@link ActivityInfo} containing information about the 5851 * activity. 5852 * @throws NameNotFoundException if a package with the given name cannot be 5853 * found on the system. 5854 */ 5855 @NonNull getActivityInfo(@onNull ComponentName component, int flags)5856 public abstract ActivityInfo getActivityInfo(@NonNull ComponentName component, 5857 int flags) throws NameNotFoundException; 5858 5859 /** 5860 * See {@link #getActivityInfo(ComponentName, int)}. 5861 */ 5862 @NonNull getActivityInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)5863 public ActivityInfo getActivityInfo(@NonNull ComponentName component, 5864 @NonNull ComponentInfoFlags flags) throws NameNotFoundException { 5865 throw new UnsupportedOperationException( 5866 "getActivityInfo not implemented in subclass"); 5867 } 5868 5869 /** 5870 * Retrieve all of the information we know about a particular receiver 5871 * class. 5872 * 5873 * Use {@link #getReceiverInfo(ComponentName, ComponentInfoFlags)} when long flags are needed. 5874 * 5875 * @param component The full component name (i.e. 5876 * com.google.apps.calendar/com.google.apps.calendar. 5877 * CalendarAlarm) of a Receiver class. 5878 * @param flags Additional option flags to modify the data returned. 5879 * @return An {@link ActivityInfo} containing information about the 5880 * receiver. 5881 * @throws NameNotFoundException if a package with the given name cannot be 5882 * found on the system. 5883 */ 5884 @NonNull getReceiverInfo(@onNull ComponentName component, int flags)5885 public abstract ActivityInfo getReceiverInfo(@NonNull ComponentName component, 5886 int flags) throws NameNotFoundException; 5887 5888 /** 5889 * See {@link #getReceiverInfo(ComponentName, int)}. 5890 */ 5891 @NonNull getReceiverInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)5892 public ActivityInfo getReceiverInfo(@NonNull ComponentName component, 5893 @NonNull ComponentInfoFlags flags) throws NameNotFoundException { 5894 throw new UnsupportedOperationException( 5895 "getReceiverInfo not implemented in subclass"); 5896 } 5897 5898 /** 5899 * Retrieve all of the information we know about a particular service class. 5900 * 5901 * Use {@link #getServiceInfo(ComponentName, ComponentInfoFlags)} when long flags are needed. 5902 * 5903 * @param component The full component name (i.e. 5904 * com.google.apps.media/com.google.apps.media. 5905 * BackgroundPlayback) of a Service class. 5906 * @param flags Additional option flags to modify the data returned. 5907 * @return A {@link ServiceInfo} object containing information about the 5908 * service. 5909 * @throws NameNotFoundException if the component cannot be found on the system. 5910 */ 5911 @NonNull getServiceInfo(@onNull ComponentName component, int flags)5912 public abstract ServiceInfo getServiceInfo(@NonNull ComponentName component, 5913 int flags) throws NameNotFoundException; 5914 5915 /** 5916 * See {@link #getServiceInfo(ComponentName, int)}. 5917 */ 5918 @NonNull getServiceInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)5919 public ServiceInfo getServiceInfo(@NonNull ComponentName component, 5920 @NonNull ComponentInfoFlags flags) throws NameNotFoundException { 5921 throw new UnsupportedOperationException( 5922 "getServiceInfo not implemented in subclass"); 5923 } 5924 5925 /** 5926 * Retrieve all of the information we know about a particular content 5927 * provider class. 5928 * 5929 * Use {@link #getProviderInfo(ComponentName, ComponentInfoFlags)} when long flags are needed. 5930 * 5931 * @param component The full component name (i.e. 5932 * com.google.providers.media/com.google.providers.media. 5933 * MediaProvider) of a ContentProvider class. 5934 * @param flags Additional option flags to modify the data returned. 5935 * @return A {@link ProviderInfo} object containing information about the 5936 * provider. 5937 * @throws NameNotFoundException if a package with the given name cannot be 5938 * found on the system. 5939 */ 5940 @NonNull getProviderInfo(@onNull ComponentName component, int flags)5941 public abstract ProviderInfo getProviderInfo(@NonNull ComponentName component, 5942 int flags) throws NameNotFoundException; 5943 5944 /** 5945 * See {@link #getProviderInfo(ComponentName, int)}. 5946 */ 5947 @NonNull getProviderInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)5948 public ProviderInfo getProviderInfo(@NonNull ComponentName component, 5949 @NonNull ComponentInfoFlags flags) throws NameNotFoundException { 5950 throw new UnsupportedOperationException( 5951 "getProviderInfo not implemented in subclass"); 5952 } 5953 5954 /** 5955 * Retrieve information for a particular module. 5956 * 5957 * @param packageName The name of the module. 5958 * @param flags Additional option flags to modify the data returned. 5959 * @return A {@link ModuleInfo} object containing information about the 5960 * module. 5961 * @throws NameNotFoundException if a module with the given name cannot be 5962 * found on the system. 5963 */ 5964 @NonNull getModuleInfo(@onNull String packageName, @ModuleInfoFlags int flags)5965 public ModuleInfo getModuleInfo(@NonNull String packageName, @ModuleInfoFlags int flags) 5966 throws NameNotFoundException { 5967 throw new UnsupportedOperationException( 5968 "getModuleInfo not implemented in subclass"); 5969 } 5970 5971 /** 5972 * Return a List of all modules that are installed. 5973 * 5974 * @param flags Additional option flags to modify the data returned. 5975 * @return A {@link List} of {@link ModuleInfo} objects, one for each installed 5976 * module, containing information about the module. In the unlikely case 5977 * there are no installed modules, an empty list is returned. 5978 */ 5979 @NonNull getInstalledModules(@nstalledModulesFlags int flags)5980 public List<ModuleInfo> getInstalledModules(@InstalledModulesFlags int flags) { 5981 throw new UnsupportedOperationException( 5982 "getInstalledModules not implemented in subclass"); 5983 } 5984 5985 /** 5986 * Return a List of all packages that are installed for the current user. 5987 * 5988 * Use {@link #getInstalledPackages(PackageInfoFlags)} when long flags are needed. 5989 * 5990 * @param flags Additional option flags to modify the data returned. 5991 * @return A List of PackageInfo objects, one for each installed package, 5992 * containing information about the package. In the unlikely case 5993 * there are no installed packages, an empty list is returned. If 5994 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 5995 * information is retrieved from the list of uninstalled 5996 * applications (which includes installed applications as well as 5997 * applications with data directory i.e. applications which had been 5998 * deleted with {@code DELETE_KEEP_DATA} flag set). 5999 */ 6000 @NonNull getInstalledPackages(int flags)6001 public abstract List<PackageInfo> getInstalledPackages(int flags); 6002 6003 /** 6004 * See {@link #getInstalledPackages(int)}. 6005 */ 6006 @NonNull getInstalledPackages(@onNull PackageInfoFlags flags)6007 public List<PackageInfo> getInstalledPackages(@NonNull PackageInfoFlags flags) { 6008 throw new UnsupportedOperationException( 6009 "getInstalledPackages not implemented in subclass"); 6010 } 6011 6012 /** 6013 * Returns the app metadata for a package. 6014 * 6015 * @param packageName The package name for which to get the app metadata. 6016 * @return A PersistableBundle containing the app metadata that was provided by the installer. 6017 * In the case where a package does not have any metadata, an empty PersistableBundle is 6018 * returned. 6019 * @throws NameNotFoundException if no such package is available to the caller. 6020 * @hide 6021 */ 6022 @NonNull 6023 @SystemApi 6024 @RequiresPermission(Manifest.permission.GET_APP_METADATA) getAppMetadata(@onNull String packageName)6025 public PersistableBundle getAppMetadata(@NonNull String packageName) 6026 throws NameNotFoundException { 6027 throw new UnsupportedOperationException("getAppMetadata not implemented in subclass"); 6028 } 6029 6030 /** 6031 * Return a List of all installed packages that are currently holding any of 6032 * the given permissions. 6033 * 6034 * Use {@link #getPackagesHoldingPermissions(String[], PackageInfoFlags)} when long flags are 6035 * needed. 6036 * 6037 * @param flags Additional option flags to modify the data returned. 6038 * @return A List of PackageInfo objects, one for each installed package 6039 * that holds any of the permissions that were provided, containing 6040 * information about the package. If no installed packages hold any 6041 * of the permissions, an empty list is returned. If flag 6042 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 6043 * information is retrieved from the list of uninstalled 6044 * applications (which includes installed applications as well as 6045 * applications with data directory i.e. applications which had been 6046 * deleted with {@code DELETE_KEEP_DATA} flag set). 6047 */ 6048 @NonNull getPackagesHoldingPermissions( @onNull String[] permissions, int flags)6049 public abstract List<PackageInfo> getPackagesHoldingPermissions( 6050 @NonNull String[] permissions, int flags); 6051 6052 /** 6053 * See {@link #getPackagesHoldingPermissions(String[], int)}. 6054 */ 6055 @NonNull getPackagesHoldingPermissions( @onNull String[] permissions, @NonNull PackageInfoFlags flags)6056 public List<PackageInfo> getPackagesHoldingPermissions( 6057 @NonNull String[] permissions, @NonNull PackageInfoFlags flags) { 6058 throw new UnsupportedOperationException( 6059 "getPackagesHoldingPermissions not implemented in subclass"); 6060 } 6061 6062 /** 6063 * Return a List of all packages that are installed on the device, for a 6064 * specific user. 6065 * 6066 * Use {@link #getInstalledPackagesAsUser(PackageInfoFlags, int)} when long flags are needed. 6067 * 6068 * @param flags Additional option flags to modify the data returned. 6069 * @param userId The user for whom the installed packages are to be listed 6070 * @return A List of PackageInfo objects, one for each installed package, 6071 * containing information about the package. In the unlikely case 6072 * there are no installed packages, an empty list is returned. If 6073 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 6074 * information is retrieved from the list of uninstalled 6075 * applications (which includes installed applications as well as 6076 * applications with data directory i.e. applications which had been 6077 * deleted with {@code DELETE_KEEP_DATA} flag set). 6078 * @hide 6079 */ 6080 @SuppressWarnings("HiddenAbstractMethod") 6081 @NonNull 6082 @SystemApi 6083 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) getInstalledPackagesAsUser(int flags, @UserIdInt int userId)6084 public abstract List<PackageInfo> getInstalledPackagesAsUser(int flags, 6085 @UserIdInt int userId); 6086 6087 /** 6088 * See {@link #getInstalledPackagesAsUser(int, int)}. 6089 * @hide 6090 */ 6091 @NonNull 6092 @SystemApi 6093 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) getInstalledPackagesAsUser(@onNull PackageInfoFlags flags, @UserIdInt int userId)6094 public List<PackageInfo> getInstalledPackagesAsUser(@NonNull PackageInfoFlags flags, 6095 @UserIdInt int userId) { 6096 throw new UnsupportedOperationException( 6097 "getApplicationInfoAsUser not implemented in subclass"); 6098 } 6099 6100 /** 6101 * Check whether a particular package has been granted a particular 6102 * permission. 6103 * 6104 * @param permName The name of the permission you are checking for. 6105 * @param packageName The name of the package you are checking against. 6106 * 6107 * @return If the package has the permission, PERMISSION_GRANTED is 6108 * returned. If it does not have the permission, PERMISSION_DENIED 6109 * is returned. 6110 * 6111 * @see #PERMISSION_GRANTED 6112 * @see #PERMISSION_DENIED 6113 */ 6114 @CheckResult 6115 @PermissionResult checkPermission(@onNull String permName, @NonNull String packageName)6116 public abstract int checkPermission(@NonNull String permName, 6117 @NonNull String packageName); 6118 6119 /** 6120 * Checks whether a particular permissions has been revoked for a 6121 * package by policy. Typically the device owner or the profile owner 6122 * may apply such a policy. The user cannot grant policy revoked 6123 * permissions, hence the only way for an app to get such a permission 6124 * is by a policy change. 6125 * 6126 * @param permName The name of the permission you are checking for. 6127 * @param packageName The name of the package you are checking against. 6128 * 6129 * @return Whether the permission is restricted by policy. 6130 */ 6131 @CheckResult 6132 //@Deprecated isPermissionRevokedByPolicy(@onNull String permName, @NonNull String packageName)6133 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 6134 @NonNull String packageName); 6135 6136 /** 6137 * Gets the package name of the component controlling runtime permissions. 6138 * 6139 * @return the package name of the component controlling runtime permissions 6140 * 6141 * @hide 6142 */ 6143 @NonNull 6144 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 6145 @TestApi 6146 @UnsupportedAppUsage getPermissionControllerPackageName()6147 public String getPermissionControllerPackageName() { 6148 throw new RuntimeException("Not implemented. Must override in a subclass."); 6149 } 6150 6151 /** 6152 * Returns the package name of the component implementing sdk sandbox service. 6153 * 6154 * @return the package name of the component implementing sdk sandbox service 6155 * 6156 * @hide 6157 */ 6158 @NonNull 6159 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 6160 @TestApi getSdkSandboxPackageName()6161 public String getSdkSandboxPackageName() { 6162 throw new RuntimeException("Not implemented. Must override in a subclass."); 6163 } 6164 6165 /** 6166 * Add a new dynamic permission to the system. For this to work, your 6167 * package must have defined a permission tree through the 6168 * {@link android.R.styleable#AndroidManifestPermissionTree 6169 * <permission-tree>} tag in its manifest. A package can only add 6170 * permissions to trees that were defined by either its own package or 6171 * another with the same user id; a permission is in a tree if it 6172 * matches the name of the permission tree + ".": for example, 6173 * "com.foo.bar" is a member of the permission tree "com.foo". 6174 * 6175 * <p>It is good to make your permission tree name descriptive, because you 6176 * are taking possession of that entire set of permission names. Thus, it 6177 * must be under a domain you control, with a suffix that will not match 6178 * any normal permissions that may be declared in any applications that 6179 * are part of that domain. 6180 * 6181 * <p>New permissions must be added before 6182 * any .apks are installed that use those permissions. Permissions you 6183 * add through this method are remembered across reboots of the device. 6184 * If the given permission already exists, the info you supply here 6185 * will be used to update it. 6186 * 6187 * @param info Description of the permission to be added. 6188 * 6189 * @return Returns true if a new permission was created, false if an 6190 * existing one was updated. 6191 * 6192 * @throws SecurityException if you are not allowed to add the 6193 * given permission name. 6194 * 6195 * @see #removePermission(String) 6196 */ 6197 //@Deprecated addPermission(@onNull PermissionInfo info)6198 public abstract boolean addPermission(@NonNull PermissionInfo info); 6199 6200 /** 6201 * Like {@link #addPermission(PermissionInfo)} but asynchronously 6202 * persists the package manager state after returning from the call, 6203 * allowing it to return quicker and batch a series of adds at the 6204 * expense of no guarantee the added permission will be retained if 6205 * the device is rebooted before it is written. 6206 */ 6207 //@Deprecated addPermissionAsync(@onNull PermissionInfo info)6208 public abstract boolean addPermissionAsync(@NonNull PermissionInfo info); 6209 6210 /** 6211 * Removes a permission that was previously added with 6212 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 6213 * -- you are only allowed to remove permissions that you are allowed 6214 * to add. 6215 * 6216 * @param permName The name of the permission to remove. 6217 * 6218 * @throws SecurityException if you are not allowed to remove the 6219 * given permission name. 6220 * 6221 * @see #addPermission(PermissionInfo) 6222 */ 6223 //@Deprecated removePermission(@onNull String permName)6224 public abstract void removePermission(@NonNull String permName); 6225 6226 /** 6227 * Permission flags set when granting or revoking a permission. 6228 * 6229 * @hide 6230 */ 6231 @SystemApi 6232 @IntDef(prefix = { "FLAG_PERMISSION_" }, value = { 6233 FLAG_PERMISSION_USER_SET, 6234 FLAG_PERMISSION_USER_FIXED, 6235 FLAG_PERMISSION_POLICY_FIXED, 6236 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 6237 FLAG_PERMISSION_SYSTEM_FIXED, 6238 FLAG_PERMISSION_GRANTED_BY_DEFAULT, 6239 FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED, 6240 FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED, 6241 /* 6242 FLAG_PERMISSION_REVOKE_WHEN_REQUESED 6243 */ 6244 FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT, 6245 FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT, 6246 FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT, 6247 FLAG_PERMISSION_APPLY_RESTRICTION, 6248 FLAG_PERMISSION_GRANTED_BY_ROLE, 6249 FLAG_PERMISSION_REVOKED_COMPAT, 6250 FLAG_PERMISSION_ONE_TIME, 6251 FLAG_PERMISSION_AUTO_REVOKED 6252 }) 6253 @Retention(RetentionPolicy.SOURCE) 6254 public @interface PermissionFlags {} 6255 6256 /** 6257 * Grant a runtime permission to an application which the application does not 6258 * already have. The permission must have been requested by the application. 6259 * If the application is not allowed to hold the permission, a {@link 6260 * java.lang.SecurityException} is thrown. If the package or permission is 6261 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 6262 * <p> 6263 * <strong>Note: </strong>Using this API requires holding 6264 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is 6265 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 6266 * </p> 6267 * 6268 * @param packageName The package to which to grant the permission. 6269 * @param permName The permission name to grant. 6270 * @param user The user for which to grant the permission. 6271 * 6272 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 6273 * 6274 * @hide 6275 */ 6276 //@Deprecated 6277 @SuppressWarnings("HiddenAbstractMethod") 6278 @SystemApi 6279 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) grantRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user)6280 public abstract void grantRuntimePermission(@NonNull String packageName, 6281 @NonNull String permName, @NonNull UserHandle user); 6282 6283 /** 6284 * Revoke a runtime permission that was previously granted by {@link 6285 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 6286 * permission must have been requested by and granted to the application. 6287 * If the application is not allowed to hold the permission, a {@link 6288 * java.lang.SecurityException} is thrown. If the package or permission is 6289 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 6290 * <p> 6291 * <strong>Note: </strong>Using this API requires holding 6292 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 6293 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 6294 * </p> 6295 * 6296 * @param packageName The package from which to revoke the permission. 6297 * @param permName The permission name to revoke. 6298 * @param user The user for which to revoke the permission. 6299 * 6300 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 6301 * 6302 * @hide 6303 */ 6304 //@Deprecated 6305 @SuppressWarnings("HiddenAbstractMethod") 6306 @SystemApi 6307 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) revokeRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user)6308 public abstract void revokeRuntimePermission(@NonNull String packageName, 6309 @NonNull String permName, @NonNull UserHandle user); 6310 6311 /** 6312 * Revoke a runtime permission that was previously granted by {@link 6313 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 6314 * permission must have been requested by and granted to the application. 6315 * If the application is not allowed to hold the permission, a {@link 6316 * java.lang.SecurityException} is thrown. If the package or permission is 6317 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 6318 * <p> 6319 * <strong>Note: </strong>Using this API requires holding 6320 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 6321 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 6322 * </p> 6323 * 6324 * @param packageName The package from which to revoke the permission. 6325 * @param permName The permission name to revoke. 6326 * @param user The user for which to revoke the permission. 6327 * @param reason The reason for the revoke. 6328 * 6329 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 6330 * 6331 * @hide 6332 */ 6333 //@Deprecated 6334 @SystemApi 6335 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) revokeRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user, @NonNull String reason)6336 public void revokeRuntimePermission(@NonNull String packageName, 6337 @NonNull String permName, @NonNull UserHandle user, @NonNull String reason) { 6338 revokeRuntimePermission(packageName, permName, user); 6339 } 6340 6341 /** 6342 * Gets the state flags associated with a permission. 6343 * 6344 * @param permName The permission for which to get the flags. 6345 * @param packageName The package name for which to get the flags. 6346 * @param user The user for which to get permission flags. 6347 * @return The permission flags. 6348 * 6349 * @hide 6350 */ 6351 //@Deprecated 6352 @SuppressWarnings("HiddenAbstractMethod") 6353 @SystemApi 6354 @RequiresPermission(anyOf = { 6355 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 6356 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS, 6357 android.Manifest.permission.GET_RUNTIME_PERMISSIONS 6358 }) 6359 @PermissionFlags getPermissionFlags(@onNull String permName, @NonNull String packageName, @NonNull UserHandle user)6360 public abstract int getPermissionFlags(@NonNull String permName, 6361 @NonNull String packageName, @NonNull UserHandle user); 6362 6363 /** 6364 * Updates the flags associated with a permission by replacing the flags in 6365 * the specified mask with the provided flag values. 6366 * 6367 * @param permName The permission for which to update the flags. 6368 * @param packageName The package name for which to update the flags. 6369 * @param flagMask The flags which to replace. 6370 * @param flagValues The flags with which to replace. 6371 * @param user The user for which to update the permission flags. 6372 * 6373 * @hide 6374 */ 6375 //@Deprecated 6376 @SuppressWarnings("HiddenAbstractMethod") 6377 @SystemApi 6378 @RequiresPermission(anyOf = { 6379 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 6380 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS 6381 }) updatePermissionFlags(@onNull String permName, @NonNull String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues, @NonNull UserHandle user)6382 public abstract void updatePermissionFlags(@NonNull String permName, 6383 @NonNull String packageName, @PermissionFlags int flagMask, 6384 @PermissionFlags int flagValues, @NonNull UserHandle user); 6385 6386 /** 6387 * Gets the restricted permissions that have been whitelisted and the app 6388 * is allowed to have them granted in their full form. 6389 * 6390 * <p> Permissions can be hard restricted which means that the app cannot hold 6391 * them or soft restricted where the app can hold the permission but in a weaker 6392 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 6393 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 6394 * depends on the permission declaration. Whitelisting a hard restricted permission 6395 * allows for the to hold that permission and whitelisting a soft restricted 6396 * permission allows the app to hold the permission in its full, unrestricted form. 6397 * 6398 * <p><ol>There are four allowlists: 6399 * 6400 * <li>one for cases where the system permission policy whitelists a permission 6401 * This list corresponds to the{@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 6402 * Can only be accessed by pre-installed holders of a dedicated permission. 6403 * 6404 * <li>one for cases where the system whitelists the permission when upgrading 6405 * from an OS version in which the permission was not restricted to an OS version 6406 * in which the permission is restricted. This list corresponds to the {@link 6407 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be accessed by pre-installed 6408 * holders of a dedicated permission or the installer on record. 6409 * 6410 * <li>one for cases where the installer of the package whitelists a permission. 6411 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 6412 * Can be accessed by pre-installed holders of a dedicated permission or the 6413 * installer on record. 6414 * </ol> 6415 * 6416 * <p> 6417 * <strong>Note: </strong>In retrospect it would have been preferred to use 6418 * more inclusive terminology when naming this API. Similar APIs added will 6419 * refrain from using the term "whitelist". 6420 * </p> 6421 * 6422 * @param packageName The app for which to get whitelisted permissions. 6423 * @param whitelistFlag The flag to determine which whitelist to query. Only one flag 6424 * can be passed.s 6425 * @return The whitelisted permissions that are on any of the whitelists you query for. 6426 * 6427 * @see #addWhitelistedRestrictedPermission(String, String, int) 6428 * @see #removeWhitelistedRestrictedPermission(String, String, int) 6429 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 6430 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 6431 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 6432 * 6433 * @throws SecurityException if you try to access a whitelist that you have no access to. 6434 */ 6435 //@Deprecated 6436 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 6437 conditional = true) getWhitelistedRestrictedPermissions( @onNull String packageName, @PermissionWhitelistFlags int whitelistFlag)6438 public @NonNull Set<String> getWhitelistedRestrictedPermissions( 6439 @NonNull String packageName, @PermissionWhitelistFlags int whitelistFlag) { 6440 return Collections.emptySet(); 6441 } 6442 6443 /** 6444 * Adds a whitelisted restricted permission for an app. 6445 * 6446 * <p> Permissions can be hard restricted which means that the app cannot hold 6447 * them or soft restricted where the app can hold the permission but in a weaker 6448 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 6449 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 6450 * depends on the permission declaration. Whitelisting a hard restricted permission 6451 * allows for the to hold that permission and whitelisting a soft restricted 6452 * permission allows the app to hold the permission in its full, unrestricted form. 6453 * 6454 * <p><ol>There are four whitelists: 6455 * 6456 * <li>one for cases where the system permission policy whitelists a permission 6457 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 6458 * Can only be modified by pre-installed holders of a dedicated permission. 6459 * 6460 * <li>one for cases where the system whitelists the permission when upgrading 6461 * from an OS version in which the permission was not restricted to an OS version 6462 * in which the permission is restricted. This list corresponds to the {@link 6463 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 6464 * holders of a dedicated permission. The installer on record can only remove 6465 * permissions from this whitelist. 6466 * 6467 * <li>one for cases where the installer of the package whitelists a permission. 6468 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 6469 * Can be modified by pre-installed holders of a dedicated permission or the installer 6470 * on record. 6471 * </ol> 6472 * 6473 * <p>You need to specify the whitelists for which to set the whitelisted permissions 6474 * which will clear the previous whitelisted permissions and replace them with the 6475 * provided ones. 6476 * 6477 * <p> 6478 * <strong>Note: </strong>In retrospect it would have been preferred to use 6479 * more inclusive terminology when naming this API. Similar APIs added will 6480 * refrain from using the term "whitelist". 6481 * </p> 6482 * 6483 * @param packageName The app for which to get whitelisted permissions. 6484 * @param permName The whitelisted permission to add. 6485 * @param whitelistFlags The whitelists to which to add. Passing multiple flags 6486 * updates all specified whitelists. 6487 * @return Whether the permission was added to the whitelist. 6488 * 6489 * @see #getWhitelistedRestrictedPermissions(String, int) 6490 * @see #removeWhitelistedRestrictedPermission(String, String, int) 6491 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 6492 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 6493 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 6494 * 6495 * @throws SecurityException if you try to modify a whitelist that you have no access to. 6496 */ 6497 //@Deprecated 6498 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 6499 conditional = true) addWhitelistedRestrictedPermission(@onNull String packageName, @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags)6500 public boolean addWhitelistedRestrictedPermission(@NonNull String packageName, 6501 @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) { 6502 return false; 6503 } 6504 6505 /** 6506 * Removes a whitelisted restricted permission for an app. 6507 * 6508 * <p> Permissions can be hard restricted which means that the app cannot hold 6509 * them or soft restricted where the app can hold the permission but in a weaker 6510 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 6511 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 6512 * depends on the permission declaration. Whitelisting a hard restricted permission 6513 * allows for the to hold that permission and whitelisting a soft restricted 6514 * permission allows the app to hold the permission in its full, unrestricted form. 6515 * 6516 * <p><ol>There are four whitelists: 6517 * 6518 * <li>one for cases where the system permission policy whitelists a permission 6519 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 6520 * Can only be modified by pre-installed holders of a dedicated permission. 6521 * 6522 * <li>one for cases where the system whitelists the permission when upgrading 6523 * from an OS version in which the permission was not restricted to an OS version 6524 * in which the permission is restricted. This list corresponds to the {@link 6525 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 6526 * holders of a dedicated permission. The installer on record can only remove 6527 * permissions from this whitelist. 6528 * 6529 * <li>one for cases where the installer of the package whitelists a permission. 6530 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 6531 * Can be modified by pre-installed holders of a dedicated permission or the installer 6532 * on record. 6533 * 6534 * <li>one for cases where the system exempts the permission when upgrading 6535 * from an OS version in which the permission was not restricted to an OS version 6536 * in which the permission is restricted. This list corresponds to the {@link 6537 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 6538 * holders of a dedicated permission. The installer on record can only remove 6539 * permissions from this allowlist. 6540 * </ol> 6541 * 6542 * <p>You need to specify the whitelists for which to set the whitelisted permissions 6543 * which will clear the previous whitelisted permissions and replace them with the 6544 * provided ones. 6545 * 6546 * <p> 6547 * <strong>Note: </strong>In retrospect it would have been preferred to use 6548 * more inclusive terminology when naming this API. Similar APIs added will 6549 * refrain from using the term "whitelist". 6550 * </p> 6551 * 6552 * @param packageName The app for which to get whitelisted permissions. 6553 * @param permName The whitelisted permission to remove. 6554 * @param whitelistFlags The whitelists from which to remove. Passing multiple flags 6555 * updates all specified whitelists. 6556 * @return Whether the permission was removed from the whitelist. 6557 * 6558 * @see #getWhitelistedRestrictedPermissions(String, int) 6559 * @see #addWhitelistedRestrictedPermission(String, String, int) 6560 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 6561 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 6562 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 6563 * 6564 * @throws SecurityException if you try to modify a whitelist that you have no access to. 6565 */ 6566 //@Deprecated 6567 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 6568 conditional = true) removeWhitelistedRestrictedPermission(@onNull String packageName, @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags)6569 public boolean removeWhitelistedRestrictedPermission(@NonNull String packageName, 6570 @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) { 6571 return false; 6572 } 6573 6574 /** 6575 * Marks an application exempt from having its permissions be automatically revoked when 6576 * the app is unused for an extended period of time. 6577 * 6578 * Only the installer on record that installed the given package is allowed to call this. 6579 * 6580 * Packages start in whitelisted state, and it is the installer's responsibility to 6581 * un-whitelist the packages it installs, unless auto-revoking permissions from that package 6582 * would cause breakages beyond having to re-request the permission(s). 6583 * 6584 * <p> 6585 * <strong>Note: </strong>In retrospect it would have been preferred to use 6586 * more inclusive terminology when naming this API. Similar APIs added will 6587 * refrain from using the term "whitelist". 6588 * </p> 6589 * 6590 * @param packageName The app for which to set exemption. 6591 * @param whitelisted Whether the app should be whitelisted. 6592 * 6593 * @return whether any change took effect. 6594 * 6595 * @see #isAutoRevokeWhitelisted 6596 * 6597 * @throws SecurityException if you you have no access to modify this. 6598 */ 6599 //@Deprecated 6600 @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS, 6601 conditional = true) setAutoRevokeWhitelisted(@onNull String packageName, boolean whitelisted)6602 public boolean setAutoRevokeWhitelisted(@NonNull String packageName, boolean whitelisted) { 6603 return false; 6604 } 6605 6606 /** 6607 * Checks whether an application is exempt from having its permissions be automatically revoked 6608 * when the app is unused for an extended period of time. 6609 * 6610 * Only the installer on record that installed the given package, or a holder of 6611 * {@code WHITELIST_AUTO_REVOKE_PERMISSIONS} is allowed to call this. 6612 * 6613 * <p> 6614 * <strong>Note: </strong>In retrospect it would have been preferred to use 6615 * more inclusive terminology when naming this API. Similar APIs added will 6616 * refrain from using the term "whitelist". 6617 * </p> 6618 * 6619 * @param packageName The app for which to set exemption. 6620 * 6621 * @return Whether the app is whitelisted. 6622 * 6623 * @see #setAutoRevokeWhitelisted 6624 * 6625 * @throws SecurityException if you you have no access to this. 6626 */ 6627 //@Deprecated 6628 @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS, 6629 conditional = true) isAutoRevokeWhitelisted(@onNull String packageName)6630 public boolean isAutoRevokeWhitelisted(@NonNull String packageName) { 6631 return false; 6632 } 6633 6634 6635 /** 6636 * Gets whether you should show UI with rationale for requesting a permission. 6637 * You should do this only if you do not have the permission and the context in 6638 * which the permission is requested does not clearly communicate to the user 6639 * what would be the benefit from grating this permission. 6640 * 6641 * @param permName A permission your app wants to request. 6642 * @return Whether you can show permission rationale UI. 6643 * 6644 * @hide 6645 */ 6646 //@Deprecated 6647 @SuppressWarnings("HiddenAbstractMethod") 6648 @UnsupportedAppUsage shouldShowRequestPermissionRationale(@onNull String permName)6649 public abstract boolean shouldShowRequestPermissionRationale(@NonNull String permName); 6650 6651 /** 6652 * Gets the localized label that corresponds to the option in settings for granting 6653 * background access. 6654 * 6655 * <p>The intended use is for apps to reference this label in its instruction for users to grant 6656 * a background permission. 6657 * 6658 * @return the localized label that corresponds to the settings option for granting 6659 * background access 6660 */ 6661 @NonNull getBackgroundPermissionOptionLabel()6662 public CharSequence getBackgroundPermissionOptionLabel() { 6663 return ""; 6664 } 6665 6666 /** 6667 * Returns an {@link android.content.Intent} suitable for passing to 6668 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 6669 * which prompts the user to grant permissions to this application. 6670 * 6671 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 6672 * 6673 * @hide 6674 */ 6675 @NonNull 6676 @UnsupportedAppUsage buildRequestPermissionsIntent(@onNull String[] permissions)6677 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 6678 if (ArrayUtils.isEmpty(permissions)) { 6679 throw new IllegalArgumentException("permission cannot be null or empty"); 6680 } 6681 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 6682 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 6683 intent.setPackage(getPermissionControllerPackageName()); 6684 return intent; 6685 } 6686 6687 /** 6688 * Compare the signatures of two packages to determine if the same 6689 * signature appears in both of them. If they do contain the same 6690 * signature, then they are allowed special privileges when working 6691 * with each other: they can share the same user-id, run instrumentation 6692 * against each other, etc. 6693 * 6694 * @param packageName1 First package name whose signature will be compared. 6695 * @param packageName2 Second package name whose signature will be compared. 6696 * 6697 * @return Returns an integer indicating whether all signatures on the 6698 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 6699 * all signatures match or < 0 if there is not a match ({@link 6700 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 6701 * 6702 * @see #checkSignatures(int, int) 6703 */ 6704 @CheckResult 6705 @SignatureResult checkSignatures(@onNull String packageName1, @NonNull String packageName2)6706 public abstract int checkSignatures(@NonNull String packageName1, 6707 @NonNull String packageName2); 6708 6709 /** 6710 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 6711 * the two packages to be checked. This can be useful, for example, 6712 * when doing the check in an IPC, where the UID is the only identity 6713 * available. It is functionally identical to determining the package 6714 * associated with the UIDs and checking their signatures. 6715 * 6716 * @param uid1 First UID whose signature will be compared. 6717 * @param uid2 Second UID whose signature will be compared. 6718 * 6719 * @return Returns an integer indicating whether all signatures on the 6720 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 6721 * all signatures match or < 0 if there is not a match ({@link 6722 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 6723 * 6724 * @see #checkSignatures(String, String) 6725 */ 6726 @CheckResult checkSignatures(int uid1, int uid2)6727 public abstract @SignatureResult int checkSignatures(int uid1, int uid2); 6728 6729 /** 6730 * Retrieve the names of all packages that are associated with a particular 6731 * user id. In most cases, this will be a single package name, the package 6732 * that has been assigned that user id. Where there are multiple packages 6733 * sharing the same user id through the "sharedUserId" mechanism, all 6734 * packages with that id will be returned. 6735 * 6736 * @param uid The user id for which you would like to retrieve the 6737 * associated packages. 6738 * 6739 * @return Returns an array of one or more packages assigned to the user 6740 * id, or null if there are no known packages with the given id. 6741 */ getPackagesForUid(int uid)6742 public abstract @Nullable String[] getPackagesForUid(int uid); 6743 6744 /** 6745 * Retrieve the official name associated with a uid. This name is 6746 * guaranteed to never change, though it is possible for the underlying 6747 * uid to be changed. That is, if you are storing information about 6748 * uids in persistent storage, you should use the string returned 6749 * by this function instead of the raw uid. 6750 * 6751 * @param uid The uid for which you would like to retrieve a name. 6752 * @return Returns a unique name for the given uid, or null if the 6753 * uid is not currently assigned. 6754 */ getNameForUid(int uid)6755 public abstract @Nullable String getNameForUid(int uid); 6756 6757 /** 6758 * Retrieves the official names associated with each given uid. 6759 * @see #getNameForUid(int) 6760 * 6761 * @hide 6762 */ 6763 @SuppressWarnings({"HiddenAbstractMethod", "NullableCollection"}) 6764 @TestApi getNamesForUids(int[] uids)6765 public abstract @Nullable String[] getNamesForUids(int[] uids); 6766 6767 /** 6768 * Return the user id associated with a shared user name. Multiple 6769 * applications can specify a shared user name in their manifest and thus 6770 * end up using a common uid. This might be used for new applications 6771 * that use an existing shared user name and need to know the uid of the 6772 * shared user. 6773 * 6774 * @param sharedUserName The shared user name whose uid is to be retrieved. 6775 * @return Returns the UID associated with the shared user. 6776 * @throws NameNotFoundException if a package with the given name cannot be 6777 * found on the system. 6778 * @hide 6779 */ 6780 @SuppressWarnings("HiddenAbstractMethod") 6781 @UnsupportedAppUsage getUidForSharedUser(@onNull String sharedUserName)6782 public abstract int getUidForSharedUser(@NonNull String sharedUserName) 6783 throws NameNotFoundException; 6784 6785 /** 6786 * Return a List of all application packages that are installed for the 6787 * current user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 6788 * applications including those deleted with {@code DELETE_KEEP_DATA} 6789 * (partially installed apps with data directory) will be returned. 6790 * 6791 * Use {@link #getInstalledApplications(ApplicationInfoFlags)} when long flags are needed. 6792 * 6793 * @param flags Additional option flags to modify the data returned. 6794 * @return A List of ApplicationInfo objects, one for each installed 6795 * application. In the unlikely case there are no installed 6796 * packages, an empty list is returned. If flag 6797 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 6798 * information is retrieved from the list of uninstalled 6799 * applications (which includes installed applications as well as 6800 * applications with data directory i.e. applications which had been 6801 * deleted with {@code DELETE_KEEP_DATA} flag set). 6802 */ 6803 @NonNull getInstalledApplications(int flags)6804 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 6805 6806 /** 6807 * See {@link #getInstalledApplications(int)} 6808 * @param flags 6809 */ 6810 @NonNull getInstalledApplications(@onNull ApplicationInfoFlags flags)6811 public List<ApplicationInfo> getInstalledApplications(@NonNull ApplicationInfoFlags flags) { 6812 throw new UnsupportedOperationException( 6813 "getInstalledApplications not implemented in subclass"); 6814 } 6815 /** 6816 * Return a List of all application packages that are installed on the 6817 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been 6818 * set, a list of all applications including those deleted with 6819 * {@code DELETE_KEEP_DATA} (partially installed apps with data directory) 6820 * will be returned. 6821 * 6822 * Use {@link #getInstalledApplicationsAsUser(ApplicationInfoFlags, int)} when long flags are 6823 * needed. 6824 * 6825 * @param flags Additional option flags to modify the data returned. 6826 * @param userId The user for whom the installed applications are to be 6827 * listed 6828 * @return A List of ApplicationInfo objects, one for each installed 6829 * application. In the unlikely case there are no installed 6830 * packages, an empty list is returned. If flag 6831 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 6832 * information is retrieved from the list of uninstalled 6833 * applications (which includes installed applications as well as 6834 * applications with data directory i.e. applications which had been 6835 * deleted with {@code DELETE_KEEP_DATA} flag set). 6836 * @hide 6837 */ 6838 @SuppressWarnings("HiddenAbstractMethod") 6839 @NonNull 6840 @TestApi getInstalledApplicationsAsUser( int flags, @UserIdInt int userId)6841 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser( 6842 int flags, @UserIdInt int userId); 6843 6844 /** 6845 * See {@link #getInstalledApplicationsAsUser(int, int}. 6846 * @hide 6847 */ 6848 @NonNull 6849 @TestApi getInstalledApplicationsAsUser( @onNull ApplicationInfoFlags flags, @UserIdInt int userId)6850 public List<ApplicationInfo> getInstalledApplicationsAsUser( 6851 @NonNull ApplicationInfoFlags flags, @UserIdInt int userId) { 6852 throw new UnsupportedOperationException( 6853 "getInstalledApplicationsAsUser not implemented in subclass"); 6854 } 6855 6856 /** 6857 * Gets the instant applications the user recently used. 6858 * 6859 * @return The instant app list. 6860 * 6861 * @hide 6862 */ 6863 @SuppressWarnings("HiddenAbstractMethod") 6864 @SystemApi 6865 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) getInstantApps()6866 public abstract @NonNull List<InstantAppInfo> getInstantApps(); 6867 6868 /** 6869 * Gets the icon for an instant application. 6870 * 6871 * @param packageName The app package name. 6872 * 6873 * @hide 6874 */ 6875 @SuppressWarnings("HiddenAbstractMethod") 6876 @SystemApi 6877 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) getInstantAppIcon(String packageName)6878 public abstract @Nullable Drawable getInstantAppIcon(String packageName); 6879 6880 /** 6881 * Gets whether this application is an instant app. 6882 * 6883 * @return Whether caller is an instant app. 6884 * 6885 * @see #isInstantApp(String) 6886 * @see #updateInstantAppCookie(byte[]) 6887 * @see #getInstantAppCookie() 6888 * @see #getInstantAppCookieMaxBytes() 6889 */ isInstantApp()6890 public abstract boolean isInstantApp(); 6891 6892 /** 6893 * Gets whether the given package is an instant app. 6894 * 6895 * @param packageName The package to check 6896 * @return Whether the given package is an instant app. 6897 * 6898 * @see #isInstantApp() 6899 * @see #updateInstantAppCookie(byte[]) 6900 * @see #getInstantAppCookie() 6901 * @see #getInstantAppCookieMaxBytes() 6902 * @see #clearInstantAppCookie() 6903 */ isInstantApp(@onNull String packageName)6904 public abstract boolean isInstantApp(@NonNull String packageName); 6905 6906 /** 6907 * Gets the maximum size in bytes of the cookie data an instant app 6908 * can store on the device. 6909 * 6910 * @return The max cookie size in bytes. 6911 * 6912 * @see #isInstantApp() 6913 * @see #isInstantApp(String) 6914 * @see #updateInstantAppCookie(byte[]) 6915 * @see #getInstantAppCookie() 6916 * @see #clearInstantAppCookie() 6917 */ getInstantAppCookieMaxBytes()6918 public abstract int getInstantAppCookieMaxBytes(); 6919 6920 /** 6921 * deprecated 6922 * @hide 6923 */ 6924 @SuppressWarnings("HiddenAbstractMethod") getInstantAppCookieMaxSize()6925 public abstract int getInstantAppCookieMaxSize(); 6926 6927 /** 6928 * Gets the instant application cookie for this app. Non 6929 * instant apps and apps that were instant but were upgraded 6930 * to normal apps can still access this API. For instant apps 6931 * this cookie is cached for some time after uninstall while for 6932 * normal apps the cookie is deleted after the app is uninstalled. 6933 * The cookie is always present while the app is installed. 6934 * 6935 * @return The cookie. 6936 * 6937 * @see #isInstantApp() 6938 * @see #isInstantApp(String) 6939 * @see #updateInstantAppCookie(byte[]) 6940 * @see #getInstantAppCookieMaxBytes() 6941 * @see #clearInstantAppCookie() 6942 */ getInstantAppCookie()6943 public abstract @NonNull byte[] getInstantAppCookie(); 6944 6945 /** 6946 * Clears the instant application cookie for the calling app. 6947 * 6948 * @see #isInstantApp() 6949 * @see #isInstantApp(String) 6950 * @see #getInstantAppCookieMaxBytes() 6951 * @see #getInstantAppCookie() 6952 * @see #clearInstantAppCookie() 6953 */ clearInstantAppCookie()6954 public abstract void clearInstantAppCookie(); 6955 6956 /** 6957 * Updates the instant application cookie for the calling app. Non 6958 * instant apps and apps that were instant but were upgraded 6959 * to normal apps can still access this API. For instant apps 6960 * this cookie is cached for some time after uninstall while for 6961 * normal apps the cookie is deleted after the app is uninstalled. 6962 * The cookie is always present while the app is installed. The 6963 * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}. 6964 * Passing <code>null</code> or an empty array clears the cookie. 6965 * </p> 6966 * 6967 * @param cookie The cookie data. 6968 * 6969 * @see #isInstantApp() 6970 * @see #isInstantApp(String) 6971 * @see #getInstantAppCookieMaxBytes() 6972 * @see #getInstantAppCookie() 6973 * @see #clearInstantAppCookie() 6974 * 6975 * @throws IllegalArgumentException if the array exceeds max cookie size. 6976 */ updateInstantAppCookie(@ullable byte[] cookie)6977 public abstract void updateInstantAppCookie(@Nullable byte[] cookie); 6978 6979 /** 6980 * @removed 6981 */ 6982 @SuppressWarnings("HiddenAbstractMethod") setInstantAppCookie(@ullable byte[] cookie)6983 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie); 6984 6985 /** 6986 * Get a list of shared libraries that are available on the 6987 * system. 6988 * 6989 * @return An array of shared library names that are 6990 * available on the system, or null if none are installed. 6991 * 6992 */ 6993 @Nullable getSystemSharedLibraryNames()6994 public abstract String[] getSystemSharedLibraryNames(); 6995 6996 /** 6997 * Get a list of shared libraries on the device. 6998 * 6999 * Use {@link #getSharedLibraries(PackageInfoFlags)} when long flags are needed. 7000 * 7001 * @param flags To filter the libraries to return. 7002 * @return The shared library list. 7003 * 7004 * @see #MATCH_UNINSTALLED_PACKAGES 7005 */ getSharedLibraries(int flags)7006 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(int flags); 7007 7008 /** 7009 * See {@link #getSharedLibraries(int)}. 7010 * @param flags 7011 */ getSharedLibraries(@onNull PackageInfoFlags flags)7012 public @NonNull List<SharedLibraryInfo> getSharedLibraries(@NonNull PackageInfoFlags flags) { 7013 throw new UnsupportedOperationException( 7014 "getSharedLibraries() not implemented in subclass"); 7015 } 7016 7017 /** 7018 * Get a list of shared libraries on the device. 7019 * 7020 * Use {@link #getSharedLibrariesAsUser(PackageInfoFlags, int)} when long flags are needed. 7021 * 7022 * @param flags To filter the libraries to return. 7023 * @param userId The user to query for. 7024 * @return The shared library list. 7025 * 7026 * @see #MATCH_FACTORY_ONLY 7027 * @see #MATCH_KNOWN_PACKAGES 7028 * @see #MATCH_ANY_USER 7029 * @see #MATCH_UNINSTALLED_PACKAGES 7030 * 7031 * @hide 7032 */ 7033 @SuppressWarnings("HiddenAbstractMethod") getSharedLibrariesAsUser(int flags, @UserIdInt int userId)7034 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(int flags, 7035 @UserIdInt int userId); 7036 7037 /** 7038 * See {@link #getSharedLibrariesAsUser(int, int)}. 7039 * @hide 7040 */ getSharedLibrariesAsUser( @onNull PackageInfoFlags flags, @UserIdInt int userId)7041 public @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser( 7042 @NonNull PackageInfoFlags flags, @UserIdInt int userId) { 7043 throw new UnsupportedOperationException( 7044 "getSharedLibrariesAsUser() not implemented in subclass"); 7045 } 7046 7047 /** 7048 * Get the list of shared libraries declared by a package. 7049 * 7050 * Use {@link #getDeclaredSharedLibraries(String, PackageInfoFlags)} when long flags are needed. 7051 * 7052 * @param packageName the package name to query 7053 * @param flags the flags to filter packages 7054 * @return the shared library list 7055 * 7056 * @hide 7057 */ 7058 @SuppressWarnings("HiddenAbstractMethod") 7059 @NonNull 7060 @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES) 7061 @SystemApi getDeclaredSharedLibraries(@onNull String packageName, int flags)7062 public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName, 7063 int flags) { 7064 throw new UnsupportedOperationException( 7065 "getDeclaredSharedLibraries() not implemented in subclass"); 7066 } 7067 7068 /** 7069 * See {@link #getDeclaredSharedLibraries(String, int)}. 7070 * @hide 7071 */ 7072 @NonNull 7073 @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES) 7074 @SystemApi getDeclaredSharedLibraries(@onNull String packageName, @NonNull PackageInfoFlags flags)7075 public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName, 7076 @NonNull PackageInfoFlags flags) { 7077 throw new UnsupportedOperationException( 7078 "getDeclaredSharedLibraries() not implemented in subclass"); 7079 } 7080 7081 /** 7082 * Get the name of the package hosting the services shared library. 7083 * <p> 7084 * Note that this package is no longer a shared library since Android R. It is now a package 7085 * that hosts for a bunch of updatable services that the system binds to. 7086 * 7087 * @return The library host package. 7088 * 7089 * @hide 7090 */ 7091 @SuppressWarnings("HiddenAbstractMethod") 7092 @UnsupportedAppUsage 7093 @TestApi getServicesSystemSharedLibraryPackageName()7094 public abstract @NonNull String getServicesSystemSharedLibraryPackageName(); 7095 7096 /** 7097 * Get the name of the package hosting the shared components shared library. 7098 * 7099 * @return The library host package. 7100 * 7101 * @hide 7102 */ 7103 @SuppressWarnings("HiddenAbstractMethod") 7104 @UnsupportedAppUsage 7105 @TestApi getSharedSystemSharedLibraryPackageName()7106 public abstract @NonNull String getSharedSystemSharedLibraryPackageName(); 7107 7108 /** 7109 * Returns the names of the packages that have been changed 7110 * [eg. added, removed or updated] since the given sequence 7111 * number. 7112 * <p>If no packages have been changed, returns <code>null</code>. 7113 * <p>The sequence number starts at <code>0</code> and is 7114 * reset every boot. 7115 * @param sequenceNumber The first sequence number for which to retrieve package changes. 7116 * @see android.provider.Settings.Global#BOOT_COUNT 7117 */ getChangedPackages( @ntRangefrom=0) int sequenceNumber)7118 public abstract @Nullable ChangedPackages getChangedPackages( 7119 @IntRange(from=0) int sequenceNumber); 7120 7121 /** 7122 * Get a list of features that are available on the 7123 * system. 7124 * 7125 * @return An array of FeatureInfo classes describing the features 7126 * that are available on the system, or null if there are none(!!). 7127 */ 7128 @NonNull getSystemAvailableFeatures()7129 public abstract FeatureInfo[] getSystemAvailableFeatures(); 7130 7131 /** 7132 * Check whether the given feature name is one of the available features as 7133 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 7134 * presence of <em>any</em> version of the given feature name; use 7135 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 7136 * 7137 * @return Returns true if the devices supports the feature, else false. 7138 */ hasSystemFeature(@onNull String featureName)7139 public abstract boolean hasSystemFeature(@NonNull String featureName); 7140 7141 /** 7142 * Check whether the given feature name and version is one of the available 7143 * features as returned by {@link #getSystemAvailableFeatures()}. Since 7144 * features are defined to always be backwards compatible, this returns true 7145 * if the available feature version is greater than or equal to the 7146 * requested version. 7147 * 7148 * @return Returns true if the devices supports the feature, else false. 7149 */ hasSystemFeature(@onNull String featureName, int version)7150 public abstract boolean hasSystemFeature(@NonNull String featureName, int version); 7151 7152 /** 7153 * Determine the best action to perform for a given Intent. This is how 7154 * {@link Intent#resolveActivity} finds an activity if a class has not been 7155 * explicitly specified. 7156 * <p> 7157 * <em>Note:</em> if using an implicit Intent (without an explicit 7158 * ComponentName specified), be sure to consider whether to set the 7159 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 7160 * activity in the same way that 7161 * {@link android.content.Context#startActivity(Intent)} and 7162 * {@link android.content.Intent#resolveActivity(PackageManager) 7163 * Intent.resolveActivity(PackageManager)} do. 7164 * </p> 7165 * 7166 * Use {@link #resolveActivity(Intent, ResolveInfoFlags)} when long flags are needed. 7167 * 7168 * @param intent An intent containing all of the desired specification 7169 * (action, data, type, category, and/or component). 7170 * @param flags Additional option flags to modify the data returned. The 7171 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7172 * resolution to only those activities that support the 7173 * {@link android.content.Intent#CATEGORY_DEFAULT}. 7174 * @return Returns a ResolveInfo object containing the final activity intent 7175 * that was determined to be the best action. Returns null if no 7176 * matching activity was found. If multiple matching activities are 7177 * found and there is no default set, returns a ResolveInfo object 7178 * containing something else, such as the activity resolver. 7179 */ 7180 @Nullable resolveActivity(@onNull Intent intent, int flags)7181 public abstract ResolveInfo resolveActivity(@NonNull Intent intent, int flags); 7182 7183 /** 7184 * See {@link #resolveActivity(Intent, int)}. 7185 */ 7186 @Nullable resolveActivity(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7187 public ResolveInfo resolveActivity(@NonNull Intent intent, @NonNull ResolveInfoFlags flags) { 7188 throw new UnsupportedOperationException( 7189 "resolveActivity not implemented in subclass"); 7190 } 7191 7192 /** 7193 * Determine the best action to perform for a given Intent for a given user. 7194 * This is how {@link Intent#resolveActivity} finds an activity if a class 7195 * has not been explicitly specified. 7196 * <p> 7197 * <em>Note:</em> if using an implicit Intent (without an explicit 7198 * ComponentName specified), be sure to consider whether to set the 7199 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 7200 * activity in the same way that 7201 * {@link android.content.Context#startActivity(Intent)} and 7202 * {@link android.content.Intent#resolveActivity(PackageManager) 7203 * Intent.resolveActivity(PackageManager)} do. 7204 * </p> 7205 * 7206 * Use {@link #resolveActivityAsUser(Intent, ResolveInfoFlags, int)} when long flags are needed. 7207 * 7208 * @param intent An intent containing all of the desired specification 7209 * (action, data, type, category, and/or component). 7210 * @param flags Additional option flags to modify the data returned. The 7211 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7212 * resolution to only those activities that support the 7213 * {@link android.content.Intent#CATEGORY_DEFAULT}. 7214 * @param userId The user id. 7215 * @return Returns a ResolveInfo object containing the final activity intent 7216 * that was determined to be the best action. Returns null if no 7217 * matching activity was found. If multiple matching activities are 7218 * found and there is no default set, returns a ResolveInfo object 7219 * containing something else, such as the activity resolver. 7220 * @hide 7221 */ 7222 @SuppressWarnings("HiddenAbstractMethod") 7223 @Nullable 7224 @UnsupportedAppUsage resolveActivityAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7225 public abstract ResolveInfo resolveActivityAsUser(@NonNull Intent intent, 7226 int flags, @UserIdInt int userId); 7227 7228 /** 7229 * See {@link #resolveActivityAsUser(Intent, int, int)}. 7230 * @hide 7231 */ 7232 @Nullable resolveActivityAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7233 public ResolveInfo resolveActivityAsUser(@NonNull Intent intent, 7234 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 7235 throw new UnsupportedOperationException( 7236 "resolveActivityAsUser not implemented in subclass"); 7237 } 7238 7239 /** 7240 * Retrieve all activities that can be performed for the given intent. 7241 * 7242 * Use {@link #queryIntentActivities(Intent, ResolveInfoFlags)} when long flags are needed. 7243 * 7244 * @param intent The desired intent as per resolveActivity(). 7245 * @param flags Additional option flags to modify the data returned. The 7246 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7247 * resolution to only those activities that support the 7248 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 7249 * {@link #MATCH_ALL} to prevent any filtering of the results. 7250 * @return Returns a List of ResolveInfo objects containing one entry for 7251 * each matching activity, ordered from best to worst. In other 7252 * words, the first item is what would be returned by 7253 * {@link #resolveActivity}. If there are no matching activities, an 7254 * empty list is returned. 7255 */ 7256 @NonNull queryIntentActivities(@onNull Intent intent, int flags)7257 public abstract List<ResolveInfo> queryIntentActivities(@NonNull Intent intent, int flags); 7258 7259 /** 7260 * See {@link #queryIntentActivities(Intent, int)}. 7261 */ 7262 @NonNull queryIntentActivities(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7263 public List<ResolveInfo> queryIntentActivities(@NonNull Intent intent, 7264 @NonNull ResolveInfoFlags flags) { 7265 throw new UnsupportedOperationException( 7266 "queryIntentActivities not implemented in subclass"); 7267 } 7268 7269 /** 7270 * Retrieve all activities that can be performed for the given intent, for a 7271 * specific user. 7272 * 7273 * Use {@link #queryIntentActivitiesAsUser(Intent, ResolveInfoFlags, int)} when long flags are 7274 * needed. 7275 * 7276 * @param intent The desired intent as per resolveActivity(). 7277 * @param flags Additional option flags to modify the data returned. The 7278 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7279 * resolution to only those activities that support the 7280 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 7281 * {@link #MATCH_ALL} to prevent any filtering of the results. 7282 * @return Returns a List of ResolveInfo objects containing one entry for 7283 * each matching activity, ordered from best to worst. In other 7284 * words, the first item is what would be returned by 7285 * {@link #resolveActivity}. If there are no matching activities, an 7286 * empty list is returned. 7287 * @hide 7288 */ 7289 @SuppressWarnings("HiddenAbstractMethod") 7290 @NonNull 7291 @UnsupportedAppUsage queryIntentActivitiesAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7292 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 7293 int flags, @UserIdInt int userId); 7294 7295 /** 7296 * See {@link #queryIntentActivitiesAsUser(Intent, int, int)}. 7297 * @hide 7298 */ 7299 @NonNull queryIntentActivitiesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7300 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 7301 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 7302 throw new UnsupportedOperationException( 7303 "queryIntentActivitiesAsUser not implemented in subclass"); 7304 } 7305 7306 /** 7307 * Retrieve all activities that can be performed for the given intent, for a 7308 * specific user. 7309 * 7310 * Use {@link #queryIntentActivitiesAsUser(Intent, ResolveInfoFlags, UserHandle)} when long 7311 * flags are needed. 7312 * 7313 * @param intent The desired intent as per resolveActivity(). 7314 * @param flags Additional option flags to modify the data returned. The 7315 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7316 * resolution to only those activities that support the 7317 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 7318 * {@link #MATCH_ALL} to prevent any filtering of the results. 7319 * @param user The user being queried. 7320 * @return Returns a List of ResolveInfo objects containing one entry for 7321 * each matching activity, ordered from best to worst. In other 7322 * words, the first item is what would be returned by 7323 * {@link #resolveActivity}. If there are no matching activities, an 7324 * empty list is returned. 7325 * @hide 7326 */ 7327 @SuppressWarnings("HiddenAbstractMethod") 7328 @NonNull 7329 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 7330 @SystemApi queryIntentActivitiesAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)7331 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 7332 int flags, @NonNull UserHandle user) { 7333 return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier()); 7334 } 7335 7336 /** 7337 * See {@link #queryIntentActivitiesAsUser(Intent, int, UserHandle)}. 7338 * @hide 7339 */ 7340 @NonNull 7341 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 7342 @SystemApi queryIntentActivitiesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)7343 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 7344 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) { 7345 return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier()); 7346 } 7347 7348 /** 7349 * Retrieve a set of activities that should be presented to the user as 7350 * similar options. This is like {@link #queryIntentActivities}, except it 7351 * also allows you to supply a list of more explicit Intents that you would 7352 * like to resolve to particular options, and takes care of returning the 7353 * final ResolveInfo list in a reasonable order, with no duplicates, based 7354 * on those inputs. 7355 * 7356 * Use {@link #queryIntentActivityOptions(ComponentName, List, Intent, ResolveInfoFlags)} when 7357 * long flags are needed. 7358 * 7359 * @param caller The class name of the activity that is making the request. 7360 * This activity will never appear in the output list. Can be 7361 * null. 7362 * @param specifics An array of Intents that should be resolved to the first 7363 * specific results. Can be null. 7364 * @param intent The desired intent as per resolveActivity(). 7365 * @param flags Additional option flags to modify the data returned. The 7366 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7367 * resolution to only those activities that support the 7368 * {@link android.content.Intent#CATEGORY_DEFAULT}. 7369 * @return Returns a List of ResolveInfo objects containing one entry for 7370 * each matching activity. The list is ordered first by all of the 7371 * intents resolved in <var>specifics</var> and then any additional 7372 * activities that can handle <var>intent</var> but did not get 7373 * included by one of the <var>specifics</var> intents. If there are 7374 * no matching activities, an empty list is returned. 7375 */ 7376 @NonNull queryIntentActivityOptions(@ullable ComponentName caller, @Nullable Intent[] specifics, @NonNull Intent intent, int flags)7377 public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller, 7378 @Nullable Intent[] specifics, @NonNull Intent intent, int flags); 7379 7380 /** 7381 * See {@link #queryIntentActivityOptions(ComponentName, Intent[], Intent, int)}. 7382 */ 7383 @NonNull queryIntentActivityOptions(@ullable ComponentName caller, @Nullable List<Intent> specifics, @NonNull Intent intent, @NonNull ResolveInfoFlags flags)7384 public List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller, 7385 @Nullable List<Intent> specifics, @NonNull Intent intent, 7386 @NonNull ResolveInfoFlags flags) { 7387 throw new UnsupportedOperationException( 7388 "queryIntentActivityOptions not implemented in subclass"); 7389 } 7390 7391 /** 7392 * Retrieve all receivers that can handle a broadcast of the given intent. 7393 * 7394 * Use {@link #queryBroadcastReceivers(Intent, ResolveInfoFlags)} when long flags are needed. 7395 * 7396 * @param intent The desired intent as per resolveActivity(). 7397 * @param flags Additional option flags to modify the data returned. 7398 * @return Returns a List of ResolveInfo objects containing one entry for 7399 * each matching receiver, ordered from best to worst. If there are 7400 * no matching receivers, an empty list or null is returned. 7401 */ 7402 @NonNull queryBroadcastReceivers(@onNull Intent intent, int flags)7403 public abstract List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, int flags); 7404 7405 /** 7406 * See {@link #queryBroadcastReceivers(Intent, int)}. 7407 */ 7408 @NonNull queryBroadcastReceivers(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7409 public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, 7410 @NonNull ResolveInfoFlags flags) { 7411 throw new UnsupportedOperationException( 7412 "queryBroadcastReceivers not implemented in subclass"); 7413 } 7414 7415 /** 7416 * Retrieve all receivers that can handle a broadcast of the given intent, 7417 * for a specific user. 7418 * 7419 * Use {@link #queryBroadcastReceiversAsUser(Intent, ResolveInfoFlags, UserHandle)} when long 7420 * flags are needed. 7421 * 7422 * @param intent The desired intent as per resolveActivity(). 7423 * @param flags Additional option flags to modify the data returned. 7424 * @param userHandle UserHandle of the user being queried. 7425 * @return Returns a List of ResolveInfo objects containing one entry for 7426 * each matching receiver, ordered from best to worst. If there are 7427 * no matching receivers, an empty list or null is returned. 7428 * @hide 7429 */ 7430 @SuppressWarnings("HiddenAbstractMethod") 7431 @NonNull 7432 @SystemApi 7433 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) queryBroadcastReceiversAsUser(@onNull Intent intent, int flags, UserHandle userHandle)7434 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 7435 int flags, UserHandle userHandle) { 7436 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 7437 } 7438 7439 /** 7440 * See {@link #queryBroadcastReceiversAsUser(Intent, int, UserHandle)}. 7441 * @hide 7442 */ 7443 @NonNull 7444 @SystemApi 7445 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) queryBroadcastReceiversAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle userHandle)7446 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 7447 @NonNull ResolveInfoFlags flags, @NonNull UserHandle userHandle) { 7448 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 7449 } 7450 7451 /** 7452 * @hide 7453 * Use {@link #queryBroadcastReceiversAsUser(Intent, ResolveInfoFlags, int)} when long flags are 7454 * needed. 7455 */ 7456 @SuppressWarnings("HiddenAbstractMethod") 7457 @NonNull 7458 @UnsupportedAppUsage queryBroadcastReceiversAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7459 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 7460 int flags, @UserIdInt int userId); 7461 7462 /** 7463 * See {@link #queryBroadcastReceiversAsUser(Intent, int, int)}. 7464 * @hide 7465 */ 7466 @NonNull queryBroadcastReceiversAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7467 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 7468 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 7469 throw new UnsupportedOperationException( 7470 "queryBroadcastReceiversAsUser not implemented in subclass"); 7471 } 7472 7473 7474 /** @deprecated @hide */ 7475 @NonNull 7476 @Deprecated 7477 @UnsupportedAppUsage queryBroadcastReceivers(@onNull Intent intent, int flags, @UserIdInt int userId)7478 public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, 7479 int flags, @UserIdInt int userId) { 7480 final String msg = "Shame on you for calling the hidden API " 7481 + "queryBroadcastReceivers(). Shame!"; 7482 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) { 7483 throw new UnsupportedOperationException(msg); 7484 } else { 7485 Log.d(TAG, msg); 7486 return queryBroadcastReceiversAsUser(intent, flags, userId); 7487 } 7488 } 7489 7490 /** 7491 * Determine the best service to handle for a given Intent. 7492 * 7493 * Use {@link #resolveService(Intent, ResolveInfoFlags)} when long flags are needed. 7494 * 7495 * @param intent An intent containing all of the desired specification 7496 * (action, data, type, category, and/or component). 7497 * @param flags Additional option flags to modify the data returned. 7498 * @return Returns a ResolveInfo object containing the final service intent 7499 * that was determined to be the best action. Returns null if no 7500 * matching service was found. 7501 */ 7502 @Nullable resolveService(@onNull Intent intent, int flags)7503 public abstract ResolveInfo resolveService(@NonNull Intent intent, int flags); 7504 7505 /** 7506 * See {@link #resolveService(Intent, int)}. 7507 */ 7508 @Nullable resolveService(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7509 public ResolveInfo resolveService(@NonNull Intent intent, @NonNull ResolveInfoFlags flags) { 7510 throw new UnsupportedOperationException( 7511 "resolveService not implemented in subclass"); 7512 } 7513 7514 /** 7515 * @hide 7516 * Use {@link #resolveServiceAsUser(Intent, ResolveInfoFlags, int)} when long flags are needed. 7517 */ 7518 @SuppressWarnings("HiddenAbstractMethod") 7519 @Nullable resolveServiceAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7520 public abstract ResolveInfo resolveServiceAsUser(@NonNull Intent intent, 7521 int flags, @UserIdInt int userId); 7522 7523 /** 7524 * See {@link #resolveServiceAsUser(Intent, int, int)}. 7525 * @hide 7526 */ 7527 @Nullable resolveServiceAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7528 public ResolveInfo resolveServiceAsUser(@NonNull Intent intent, 7529 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 7530 throw new UnsupportedOperationException( 7531 "resolveServiceAsUser not implemented in subclass"); 7532 } 7533 7534 /** 7535 * Retrieve all services that can match the given intent. 7536 * 7537 * Use {@link #queryIntentServices(Intent, ResolveInfoFlags)} when long flags are needed. 7538 * 7539 * @param intent The desired intent as per resolveService(). 7540 * @param flags Additional option flags to modify the data returned. 7541 * @return Returns a List of ResolveInfo objects containing one entry for 7542 * each matching service, ordered from best to worst. In other 7543 * words, the first item is what would be returned by 7544 * {@link #resolveService}. If there are no matching services, an 7545 * empty list or null is returned. 7546 */ 7547 @NonNull queryIntentServices(@onNull Intent intent, int flags)7548 public abstract List<ResolveInfo> queryIntentServices(@NonNull Intent intent, 7549 int flags); 7550 7551 /** 7552 * See {@link #queryIntentServices(Intent, int)}. 7553 */ 7554 @NonNull queryIntentServices(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7555 public List<ResolveInfo> queryIntentServices(@NonNull Intent intent, 7556 @NonNull ResolveInfoFlags flags) { 7557 throw new UnsupportedOperationException( 7558 "queryIntentServices not implemented in subclass"); 7559 } 7560 7561 /** 7562 * Retrieve all services that can match the given intent for a given user. 7563 * 7564 * Use {@link #queryIntentServicesAsUser(Intent, ResolveInfoFlags, int)} when long flags are 7565 * needed. 7566 * 7567 * @param intent The desired intent as per resolveService(). 7568 * @param flags Additional option flags to modify the data returned. 7569 * @param userId The user id. 7570 * @return Returns a List of ResolveInfo objects containing one entry for 7571 * each matching service, ordered from best to worst. In other 7572 * words, the first item is what would be returned by 7573 * {@link #resolveService}. If there are no matching services, an 7574 * empty list or null is returned. 7575 * @hide 7576 */ 7577 @SuppressWarnings("HiddenAbstractMethod") 7578 @NonNull 7579 @UnsupportedAppUsage queryIntentServicesAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7580 public abstract List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 7581 int flags, @UserIdInt int userId); 7582 7583 /** 7584 * See {@link #queryIntentServicesAsUser(Intent, int, int)}. 7585 * @hide 7586 */ 7587 @NonNull queryIntentServicesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7588 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 7589 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 7590 throw new UnsupportedOperationException( 7591 "queryIntentServicesAsUser not implemented in subclass"); 7592 } 7593 7594 /** 7595 * Retrieve all services that can match the given intent for a given user. 7596 * 7597 * Use {@link #queryIntentServicesAsUser(Intent, ResolveInfoFlags, UserHandle)} when long flags 7598 * are needed. 7599 * 7600 * @param intent The desired intent as per resolveService(). 7601 * @param flags Additional option flags to modify the data returned. 7602 * @param user The user being queried. 7603 * @return Returns a List of ResolveInfo objects containing one entry for 7604 * each matching service, ordered from best to worst. In other 7605 * words, the first item is what would be returned by 7606 * {@link #resolveService}. If there are no matching services, an 7607 * empty list or null is returned. 7608 * @hide 7609 */ 7610 @NonNull 7611 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 7612 @SystemApi queryIntentServicesAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)7613 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 7614 int flags, @NonNull UserHandle user) { 7615 return queryIntentServicesAsUser(intent, flags, user.getIdentifier()); 7616 } 7617 7618 /** 7619 * See {@link #queryIntentServicesAsUser(Intent, int, UserHandle)}. 7620 * @hide 7621 */ 7622 @NonNull 7623 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 7624 @SystemApi queryIntentServicesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)7625 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 7626 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) { 7627 return queryIntentServicesAsUser(intent, flags, user.getIdentifier()); 7628 } 7629 /** 7630 * Retrieve all providers that can match the given intent. 7631 * 7632 * Use {@link #queryIntentContentProvidersAsUser(Intent, ResolveInfoFlags, int)} when long flags 7633 * are needed. 7634 * 7635 * @param intent An intent containing all of the desired specification 7636 * (action, data, type, category, and/or component). 7637 * @param flags Additional option flags to modify the data returned. 7638 * @param userId The user id. 7639 * @return Returns a List of ResolveInfo objects containing one entry for 7640 * each matching provider, ordered from best to worst. If there are 7641 * no matching services, an empty list or null is returned. 7642 * @hide 7643 */ 7644 @SuppressWarnings("HiddenAbstractMethod") 7645 @NonNull 7646 @UnsupportedAppUsage queryIntentContentProvidersAsUser( @onNull Intent intent, int flags, @UserIdInt int userId)7647 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 7648 @NonNull Intent intent, int flags, @UserIdInt int userId); 7649 7650 /** 7651 * See {@link #queryIntentContentProvidersAsUser(Intent, int, int)}. 7652 * @hide 7653 */ 7654 @NonNull queryIntentContentProvidersAsUser( @onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7655 protected List<ResolveInfo> queryIntentContentProvidersAsUser( 7656 @NonNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 7657 throw new UnsupportedOperationException( 7658 "queryIntentContentProvidersAsUser not implemented in subclass"); 7659 } 7660 7661 /** 7662 * Retrieve all providers that can match the given intent. 7663 * 7664 * Use {@link #queryIntentContentProvidersAsUser(Intent, ResolveInfoFlags, UserHandle)} when 7665 * long flags are needed. 7666 * 7667 * @param intent An intent containing all of the desired specification 7668 * (action, data, type, category, and/or component). 7669 * @param flags Additional option flags to modify the data returned. 7670 * @param user The user being queried. 7671 * @return Returns a List of ResolveInfo objects containing one entry for 7672 * each matching provider, ordered from best to worst. If there are 7673 * no matching services, an empty list or null is returned. 7674 * @hide 7675 */ 7676 @NonNull 7677 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 7678 @SystemApi queryIntentContentProvidersAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)7679 public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent, 7680 int flags, @NonNull UserHandle user) { 7681 return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier()); 7682 } 7683 7684 /** 7685 * See {@link #queryIntentContentProvidersAsUser(Intent, int, UserHandle)}. 7686 * @hide 7687 */ 7688 @NonNull 7689 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 7690 @SystemApi queryIntentContentProvidersAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)7691 public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent, 7692 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) { 7693 return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier()); 7694 } 7695 7696 /** 7697 * Retrieve all providers that can match the given intent. 7698 * 7699 * Use {@link #queryIntentContentProviders(Intent, ResolveInfoFlags)} when long flags are 7700 * needed. 7701 * 7702 * @param intent An intent containing all of the desired specification 7703 * (action, data, type, category, and/or component). 7704 * @param flags Additional option flags to modify the data returned. 7705 * @return Returns a List of ResolveInfo objects containing one entry for 7706 * each matching provider, ordered from best to worst. If there are 7707 * no matching services, an empty list or null is returned. 7708 */ 7709 @NonNull queryIntentContentProviders(@onNull Intent intent, int flags)7710 public abstract List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent, 7711 int flags); 7712 7713 /** 7714 * See {@link #queryIntentContentProviders(Intent, int)}. 7715 */ 7716 @NonNull queryIntentContentProviders(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7717 public List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent, 7718 @NonNull ResolveInfoFlags flags) { 7719 throw new UnsupportedOperationException( 7720 "queryIntentContentProviders not implemented in subclass"); 7721 } 7722 7723 /** 7724 * Find a single content provider by its authority. 7725 * <p> 7726 * Example:<p> 7727 * <pre> 7728 * Uri uri = Uri.parse("content://com.example.app.provider/table1"); 7729 * ProviderInfo info = packageManager.resolveContentProvider(uri.getAuthority(), flags); 7730 * </pre> 7731 * 7732 * Use {@link #resolveContentProvider(String, ComponentInfoFlags)} when long flags are needed. 7733 * 7734 * @param authority The authority of the provider to find. 7735 * @param flags Additional option flags to modify the data returned. 7736 * @return A {@link ProviderInfo} object containing information about the 7737 * provider. If a provider was not found, returns null. 7738 */ 7739 @Nullable resolveContentProvider(@onNull String authority, int flags)7740 public abstract ProviderInfo resolveContentProvider(@NonNull String authority, 7741 int flags); 7742 7743 /** 7744 * See {@link #resolveContentProvider(String, int)}. 7745 */ 7746 @Nullable resolveContentProvider(@onNull String authority, @NonNull ComponentInfoFlags flags)7747 public ProviderInfo resolveContentProvider(@NonNull String authority, 7748 @NonNull ComponentInfoFlags flags) { 7749 throw new UnsupportedOperationException( 7750 "resolveContentProvider not implemented in subclass"); 7751 } 7752 7753 /** 7754 * Find a single content provider by its base path name. 7755 * 7756 * Use {@link #resolveContentProviderAsUser(String, ComponentInfoFlags, int)} when long flags 7757 * are needed. 7758 * 7759 * @param providerName The name of the provider to find. 7760 * @param flags Additional option flags to modify the data returned. 7761 * @param userId The user id. 7762 * @return A {@link ProviderInfo} object containing information about the 7763 * provider. If a provider was not found, returns null. 7764 * @hide 7765 */ 7766 @SuppressWarnings("HiddenAbstractMethod") 7767 @Nullable 7768 @UnsupportedAppUsage resolveContentProviderAsUser(@onNull String providerName, int flags, @UserIdInt int userId)7769 public abstract ProviderInfo resolveContentProviderAsUser(@NonNull String providerName, 7770 int flags, @UserIdInt int userId); 7771 7772 /** 7773 * See {@link #resolveContentProviderAsUser(String, int, int)}. 7774 * @hide 7775 */ 7776 @Nullable resolveContentProviderAsUser(@onNull String providerName, @NonNull ComponentInfoFlags flags, @UserIdInt int userId)7777 public ProviderInfo resolveContentProviderAsUser(@NonNull String providerName, 7778 @NonNull ComponentInfoFlags flags, @UserIdInt int userId) { 7779 throw new UnsupportedOperationException( 7780 "resolveContentProviderAsUser not implemented in subclass"); 7781 } 7782 7783 /** 7784 * Retrieve content provider information. 7785 * <p> 7786 * <em>Note: unlike most other methods, an empty result set is indicated 7787 * by a null return instead of an empty list.</em> 7788 * 7789 * Use {@link #queryContentProviders(String, int, ComponentInfoFlags)} when long flags are 7790 * needed. 7791 * 7792 * @param processName If non-null, limits the returned providers to only 7793 * those that are hosted by the given process. If null, all 7794 * content providers are returned. 7795 * @param uid If <var>processName</var> is non-null, this is the required 7796 * uid owning the requested content providers. 7797 * @param flags Additional option flags to modify the data returned. 7798 * @return A list of {@link ProviderInfo} objects containing one entry for 7799 * each provider either matching <var>processName</var> or, if 7800 * <var>processName</var> is null, all known content providers. 7801 * <em>If there are no matching providers, null is returned.</em> 7802 */ 7803 @NonNull queryContentProviders( @ullable String processName, int uid, int flags)7804 public abstract List<ProviderInfo> queryContentProviders( 7805 @Nullable String processName, int uid, int flags); 7806 7807 /** 7808 * See {@link #queryContentProviders(String, int, int)}. 7809 */ 7810 @NonNull queryContentProviders( @ullable String processName, int uid, @NonNull ComponentInfoFlags flags)7811 public List<ProviderInfo> queryContentProviders( 7812 @Nullable String processName, int uid, @NonNull ComponentInfoFlags flags) { 7813 throw new UnsupportedOperationException( 7814 "queryContentProviders not implemented in subclass"); 7815 } 7816 7817 /** 7818 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null, 7819 * it only returns providers which have metadata with the {@code metaDataKey} key. 7820 * 7821 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider. 7822 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders} 7823 * instead. 7824 * 7825 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly 7826 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata 7827 * to mark GAL providers, rather than intent filters, so we can't use 7828 * {@link #queryIntentContentProviders} for that. 7829 * 7830 * Use {@link #queryContentProviders(String, int, ComponentInfoFlags, String)} when long flags 7831 * are needed. 7832 * 7833 * @hide 7834 */ 7835 @NonNull queryContentProviders(@ullable String processName, int uid, int flags, String metaDataKey)7836 public List<ProviderInfo> queryContentProviders(@Nullable String processName, 7837 int uid, int flags, String metaDataKey) { 7838 // Provide the default implementation for mocks. 7839 return queryContentProviders(processName, uid, flags); 7840 } 7841 7842 /** 7843 * See {@link #queryContentProviders(String, int, int, String)}. 7844 * @hide 7845 */ 7846 @NonNull queryContentProviders(@ullable String processName, int uid, @NonNull ComponentInfoFlags flags, @Nullable String metaDataKey)7847 public List<ProviderInfo> queryContentProviders(@Nullable String processName, 7848 int uid, @NonNull ComponentInfoFlags flags, @Nullable String metaDataKey) { 7849 // Provide the default implementation for mocks. 7850 return queryContentProviders(processName, uid, flags); 7851 } 7852 7853 /** 7854 * Retrieve all of the information we know about a particular 7855 * instrumentation class. 7856 * 7857 * @param className The full name (i.e. 7858 * com.google.apps.contacts.InstrumentList) of an Instrumentation 7859 * class. 7860 * @param flags Additional option flags to modify the data returned. 7861 * @return An {@link InstrumentationInfo} object containing information 7862 * about the instrumentation. 7863 * @throws NameNotFoundException if a package with the given name cannot be 7864 * found on the system. 7865 */ 7866 @NonNull getInstrumentationInfo(@onNull ComponentName className, @InstrumentationInfoFlags int flags)7867 public abstract InstrumentationInfo getInstrumentationInfo(@NonNull ComponentName className, 7868 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 7869 7870 /** 7871 * Retrieve information about available instrumentation code. May be used to 7872 * retrieve either all instrumentation code, or only the code targeting a 7873 * particular package. 7874 * 7875 * @param targetPackage If null, all instrumentation is returned; only the 7876 * instrumentation targeting this package name is returned. 7877 * @param flags Additional option flags to modify the data returned. 7878 * @return A list of {@link InstrumentationInfo} objects containing one 7879 * entry for each matching instrumentation. If there are no 7880 * instrumentation available, returns an empty list. 7881 */ 7882 @NonNull queryInstrumentation(@onNull String targetPackage, @InstrumentationInfoFlags int flags)7883 public abstract List<InstrumentationInfo> queryInstrumentation(@NonNull String targetPackage, 7884 @InstrumentationInfoFlags int flags); 7885 7886 /** 7887 * Retrieve an image from a package. This is a low-level API used by 7888 * the various package manager info structures (such as 7889 * {@link ComponentInfo} to implement retrieval of their associated 7890 * icon. 7891 * 7892 * @param packageName The name of the package that this icon is coming from. 7893 * Cannot be null. 7894 * @param resid The resource identifier of the desired image. Cannot be 0. 7895 * @param appInfo Overall information about <var>packageName</var>. This 7896 * may be null, in which case the application information will be retrieved 7897 * for you if needed; if you already have this information around, it can 7898 * be much more efficient to supply it here. 7899 * 7900 * @return Returns a Drawable holding the requested image. Returns null if 7901 * an image could not be found for any reason. 7902 */ 7903 @Nullable getDrawable(@onNull String packageName, @DrawableRes int resid, @Nullable ApplicationInfo appInfo)7904 public abstract Drawable getDrawable(@NonNull String packageName, @DrawableRes int resid, 7905 @Nullable ApplicationInfo appInfo); 7906 7907 /** 7908 * Retrieve the icon associated with an activity. Given the full name of 7909 * an activity, retrieves the information about it and calls 7910 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 7911 * If the activity cannot be found, NameNotFoundException is thrown. 7912 * 7913 * @param activityName Name of the activity whose icon is to be retrieved. 7914 * 7915 * @return Returns the image of the icon, or the default activity icon if 7916 * it could not be found. Does not return null. 7917 * @throws NameNotFoundException Thrown if the resources for the given 7918 * activity could not be loaded. 7919 * 7920 * @see #getActivityIcon(Intent) 7921 */ 7922 @NonNull getActivityIcon(@onNull ComponentName activityName)7923 public abstract Drawable getActivityIcon(@NonNull ComponentName activityName) 7924 throws NameNotFoundException; 7925 7926 /** 7927 * Retrieve the icon associated with an Intent. If intent.getClassName() is 7928 * set, this simply returns the result of 7929 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 7930 * component and returns the icon associated with the resolved component. 7931 * If intent.getClassName() cannot be found or the Intent cannot be resolved 7932 * to a component, NameNotFoundException is thrown. 7933 * 7934 * @param intent The intent for which you would like to retrieve an icon. 7935 * 7936 * @return Returns the image of the icon, or the default activity icon if 7937 * it could not be found. Does not return null. 7938 * @throws NameNotFoundException Thrown if the resources for application 7939 * matching the given intent could not be loaded. 7940 * 7941 * @see #getActivityIcon(ComponentName) 7942 */ 7943 @NonNull getActivityIcon(@onNull Intent intent)7944 public abstract Drawable getActivityIcon(@NonNull Intent intent) 7945 throws NameNotFoundException; 7946 7947 /** 7948 * Retrieve the banner associated with an activity. Given the full name of 7949 * an activity, retrieves the information about it and calls 7950 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 7951 * banner. If the activity cannot be found, NameNotFoundException is thrown. 7952 * 7953 * @param activityName Name of the activity whose banner is to be retrieved. 7954 * @return Returns the image of the banner, or null if the activity has no 7955 * banner specified. 7956 * @throws NameNotFoundException Thrown if the resources for the given 7957 * activity could not be loaded. 7958 * @see #getActivityBanner(Intent) 7959 */ 7960 @Nullable getActivityBanner(@onNull ComponentName activityName)7961 public abstract Drawable getActivityBanner(@NonNull ComponentName activityName) 7962 throws NameNotFoundException; 7963 7964 /** 7965 * Retrieve the banner associated with an Intent. If intent.getClassName() 7966 * is set, this simply returns the result of 7967 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 7968 * intent's component and returns the banner associated with the resolved 7969 * component. If intent.getClassName() cannot be found or the Intent cannot 7970 * be resolved to a component, NameNotFoundException is thrown. 7971 * 7972 * @param intent The intent for which you would like to retrieve a banner. 7973 * @return Returns the image of the banner, or null if the activity has no 7974 * banner specified. 7975 * @throws NameNotFoundException Thrown if the resources for application 7976 * matching the given intent could not be loaded. 7977 * @see #getActivityBanner(ComponentName) 7978 */ 7979 @Nullable getActivityBanner(@onNull Intent intent)7980 public abstract Drawable getActivityBanner(@NonNull Intent intent) 7981 throws NameNotFoundException; 7982 7983 /** 7984 * Return the generic icon for an activity that is used when no specific 7985 * icon is defined. 7986 * 7987 * @return Drawable Image of the icon. 7988 */ 7989 @NonNull getDefaultActivityIcon()7990 public abstract Drawable getDefaultActivityIcon(); 7991 7992 /** 7993 * Retrieve the icon associated with an application. If it has not defined 7994 * an icon, the default app icon is returned. Does not return null. 7995 * 7996 * @param info Information about application being queried. 7997 * 7998 * @return Returns the image of the icon, or the default application icon 7999 * if it could not be found. 8000 * 8001 * @see #getApplicationIcon(String) 8002 */ 8003 @NonNull getApplicationIcon(@onNull ApplicationInfo info)8004 public abstract Drawable getApplicationIcon(@NonNull ApplicationInfo info); 8005 8006 /** 8007 * Retrieve the icon associated with an application. Given the name of the 8008 * application's package, retrieves the information about it and calls 8009 * getApplicationIcon() to return its icon. If the application cannot be 8010 * found, NameNotFoundException is thrown. 8011 * 8012 * @param packageName Name of the package whose application icon is to be 8013 * retrieved. 8014 * 8015 * @return Returns the image of the icon, or the default application icon 8016 * if it could not be found. Does not return null. 8017 * @throws NameNotFoundException Thrown if the resources for the given 8018 * application could not be loaded. 8019 * 8020 * @see #getApplicationIcon(ApplicationInfo) 8021 */ 8022 @NonNull getApplicationIcon(@onNull String packageName)8023 public abstract Drawable getApplicationIcon(@NonNull String packageName) 8024 throws NameNotFoundException; 8025 8026 /** 8027 * Retrieve the banner associated with an application. 8028 * 8029 * @param info Information about application being queried. 8030 * @return Returns the image of the banner or null if the application has no 8031 * banner specified. 8032 * @see #getApplicationBanner(String) 8033 */ 8034 @Nullable getApplicationBanner(@onNull ApplicationInfo info)8035 public abstract Drawable getApplicationBanner(@NonNull ApplicationInfo info); 8036 8037 /** 8038 * Retrieve the banner associated with an application. Given the name of the 8039 * application's package, retrieves the information about it and calls 8040 * getApplicationIcon() to return its banner. If the application cannot be 8041 * found, NameNotFoundException is thrown. 8042 * 8043 * @param packageName Name of the package whose application banner is to be 8044 * retrieved. 8045 * @return Returns the image of the banner or null if the application has no 8046 * banner specified. 8047 * @throws NameNotFoundException Thrown if the resources for the given 8048 * application could not be loaded. 8049 * @see #getApplicationBanner(ApplicationInfo) 8050 */ 8051 @Nullable getApplicationBanner(@onNull String packageName)8052 public abstract Drawable getApplicationBanner(@NonNull String packageName) 8053 throws NameNotFoundException; 8054 8055 /** 8056 * Retrieve the logo associated with an activity. Given the full name of an 8057 * activity, retrieves the information about it and calls 8058 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 8059 * logo. If the activity cannot be found, NameNotFoundException is thrown. 8060 * 8061 * @param activityName Name of the activity whose logo is to be retrieved. 8062 * @return Returns the image of the logo or null if the activity has no logo 8063 * specified. 8064 * @throws NameNotFoundException Thrown if the resources for the given 8065 * activity could not be loaded. 8066 * @see #getActivityLogo(Intent) 8067 */ 8068 @Nullable getActivityLogo(@onNull ComponentName activityName)8069 public abstract Drawable getActivityLogo(@NonNull ComponentName activityName) 8070 throws NameNotFoundException; 8071 8072 /** 8073 * Retrieve the logo associated with an Intent. If intent.getClassName() is 8074 * set, this simply returns the result of 8075 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 8076 * component and returns the logo associated with the resolved component. 8077 * If intent.getClassName() cannot be found or the Intent cannot be resolved 8078 * to a component, NameNotFoundException is thrown. 8079 * 8080 * @param intent The intent for which you would like to retrieve a logo. 8081 * 8082 * @return Returns the image of the logo, or null if the activity has no 8083 * logo specified. 8084 * 8085 * @throws NameNotFoundException Thrown if the resources for application 8086 * matching the given intent could not be loaded. 8087 * 8088 * @see #getActivityLogo(ComponentName) 8089 */ 8090 @Nullable getActivityLogo(@onNull Intent intent)8091 public abstract Drawable getActivityLogo(@NonNull Intent intent) 8092 throws NameNotFoundException; 8093 8094 /** 8095 * Retrieve the logo associated with an application. If it has not specified 8096 * a logo, this method returns null. 8097 * 8098 * @param info Information about application being queried. 8099 * 8100 * @return Returns the image of the logo, or null if no logo is specified 8101 * by the application. 8102 * 8103 * @see #getApplicationLogo(String) 8104 */ 8105 @Nullable getApplicationLogo(@onNull ApplicationInfo info)8106 public abstract Drawable getApplicationLogo(@NonNull ApplicationInfo info); 8107 8108 /** 8109 * Retrieve the logo associated with an application. Given the name of the 8110 * application's package, retrieves the information about it and calls 8111 * getApplicationLogo() to return its logo. If the application cannot be 8112 * found, NameNotFoundException is thrown. 8113 * 8114 * @param packageName Name of the package whose application logo is to be 8115 * retrieved. 8116 * 8117 * @return Returns the image of the logo, or null if no application logo 8118 * has been specified. 8119 * 8120 * @throws NameNotFoundException Thrown if the resources for the given 8121 * application could not be loaded. 8122 * 8123 * @see #getApplicationLogo(ApplicationInfo) 8124 */ 8125 @Nullable getApplicationLogo(@onNull String packageName)8126 public abstract Drawable getApplicationLogo(@NonNull String packageName) 8127 throws NameNotFoundException; 8128 8129 /** 8130 * If the target user is a managed profile, then this returns a badged copy of the given icon 8131 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use 8132 * {@link #getUserBadgedDrawableForDensity( 8133 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 8134 * <p> 8135 * If the original drawable is a BitmapDrawable and the backing bitmap is 8136 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 8137 * is performed in place and the original drawable is returned. 8138 * </p> 8139 * 8140 * @param drawable The drawable to badge. 8141 * @param user The target user. 8142 * @return A drawable that combines the original icon and a badge as 8143 * determined by the system. 8144 */ 8145 @NonNull getUserBadgedIcon(@onNull Drawable drawable, @NonNull UserHandle user)8146 public abstract Drawable getUserBadgedIcon(@NonNull Drawable drawable, 8147 @NonNull UserHandle user); 8148 8149 /** 8150 * If the target user is a managed profile of the calling user or the caller 8151 * is itself a managed profile, then this returns a badged copy of the given 8152 * drawable allowing the user to distinguish it from the original drawable. 8153 * The caller can specify the location in the bounds of the drawable to be 8154 * badged where the badge should be applied as well as the density of the 8155 * badge to be used. 8156 * <p> 8157 * If the original drawable is a BitmapDrawable and the backing bitmap is 8158 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 8159 * is performed in place and the original drawable is returned. 8160 * </p> 8161 * 8162 * @param drawable The drawable to badge. 8163 * @param user The target user. 8164 * @param badgeLocation Where in the bounds of the badged drawable to place 8165 * the badge. If it's {@code null}, the badge is applied on top of the entire 8166 * drawable being badged. 8167 * @param badgeDensity The optional desired density for the badge as per 8168 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 8169 * the density of the display is used. 8170 * @return A drawable that combines the original drawable and a badge as 8171 * determined by the system. 8172 */ 8173 @NonNull getUserBadgedDrawableForDensity(@onNull Drawable drawable, @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity)8174 public abstract Drawable getUserBadgedDrawableForDensity(@NonNull Drawable drawable, 8175 @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity); 8176 8177 /** 8178 * If the target user is a managed profile of the calling user or the caller 8179 * is itself a managed profile, then this returns a drawable to use as a small 8180 * icon to include in a view to distinguish it from the original icon. 8181 * 8182 * @param user The target user. 8183 * @param density The optional desired density for the badge as per 8184 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 8185 * the density of the current display is used. 8186 * @return the drawable or null if no drawable is required. 8187 * @hide 8188 */ 8189 @SuppressWarnings("HiddenAbstractMethod") 8190 @Nullable 8191 @UnsupportedAppUsage getUserBadgeForDensity(@onNull UserHandle user, int density)8192 public abstract Drawable getUserBadgeForDensity(@NonNull UserHandle user, int density); 8193 8194 /** 8195 * If the target user is a managed profile of the calling user or the caller 8196 * is itself a managed profile, then this returns a drawable to use as a small 8197 * icon to include in a view to distinguish it from the original icon. This version 8198 * doesn't have background protection and should be used over a light background instead of 8199 * a badge. 8200 * 8201 * @param user The target user. 8202 * @param density The optional desired density for the badge as per 8203 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 8204 * the density of the current display is used. 8205 * @return the drawable or null if no drawable is required. 8206 * @hide 8207 */ 8208 @SuppressWarnings("HiddenAbstractMethod") 8209 @Nullable 8210 @UnsupportedAppUsage getUserBadgeForDensityNoBackground(@onNull UserHandle user, int density)8211 public abstract Drawable getUserBadgeForDensityNoBackground(@NonNull UserHandle user, 8212 int density); 8213 8214 /** 8215 * If the target user is a managed profile of the calling user or the caller 8216 * is itself a managed profile, then this returns a copy of the label with 8217 * badging for accessibility services like talkback. E.g. passing in "Email" 8218 * and it might return "Work Email" for Email in the work profile. 8219 * 8220 * @param label The label to change. 8221 * @param user The target user. 8222 * @return A label that combines the original label and a badge as 8223 * determined by the system. 8224 */ 8225 @NonNull getUserBadgedLabel(@onNull CharSequence label, @NonNull UserHandle user)8226 public abstract CharSequence getUserBadgedLabel(@NonNull CharSequence label, 8227 @NonNull UserHandle user); 8228 8229 /** 8230 * Retrieve text from a package. This is a low-level API used by 8231 * the various package manager info structures (such as 8232 * {@link ComponentInfo} to implement retrieval of their associated 8233 * labels and other text. 8234 * 8235 * @param packageName The name of the package that this text is coming from. 8236 * Cannot be null. 8237 * @param resid The resource identifier of the desired text. Cannot be 0. 8238 * @param appInfo Overall information about <var>packageName</var>. This 8239 * may be null, in which case the application information will be retrieved 8240 * for you if needed; if you already have this information around, it can 8241 * be much more efficient to supply it here. 8242 * 8243 * @return Returns a CharSequence holding the requested text. Returns null 8244 * if the text could not be found for any reason. 8245 */ 8246 @Nullable getText(@onNull String packageName, @StringRes int resid, @Nullable ApplicationInfo appInfo)8247 public abstract CharSequence getText(@NonNull String packageName, @StringRes int resid, 8248 @Nullable ApplicationInfo appInfo); 8249 8250 /** 8251 * Retrieve an XML file from a package. This is a low-level API used to 8252 * retrieve XML meta data. 8253 * 8254 * @param packageName The name of the package that this xml is coming from. 8255 * Cannot be null. 8256 * @param resid The resource identifier of the desired xml. Cannot be 0. 8257 * @param appInfo Overall information about <var>packageName</var>. This 8258 * may be null, in which case the application information will be retrieved 8259 * for you if needed; if you already have this information around, it can 8260 * be much more efficient to supply it here. 8261 * 8262 * @return Returns an XmlPullParser allowing you to parse out the XML 8263 * data. Returns null if the xml resource could not be found for any 8264 * reason. 8265 */ 8266 @Nullable getXml(@onNull String packageName, @XmlRes int resid, @Nullable ApplicationInfo appInfo)8267 public abstract XmlResourceParser getXml(@NonNull String packageName, @XmlRes int resid, 8268 @Nullable ApplicationInfo appInfo); 8269 8270 /** 8271 * Return the label to use for this application. 8272 * 8273 * @return Returns a {@link CharSequence} containing the label associated with 8274 * this application, or its name the item does not have a label. 8275 * @param info The {@link ApplicationInfo} of the application to get the label of. 8276 */ 8277 @NonNull getApplicationLabel(@onNull ApplicationInfo info)8278 public abstract CharSequence getApplicationLabel(@NonNull ApplicationInfo info); 8279 8280 /** 8281 * Retrieve the resources associated with an activity. Given the full 8282 * name of an activity, retrieves the information about it and calls 8283 * getResources() to return its application's resources. If the activity 8284 * cannot be found, NameNotFoundException is thrown. 8285 * 8286 * @param activityName Name of the activity whose resources are to be 8287 * retrieved. 8288 * 8289 * @return Returns the application's Resources. 8290 * @throws NameNotFoundException Thrown if the resources for the given 8291 * application could not be loaded. 8292 * 8293 * @see #getResourcesForApplication(ApplicationInfo) 8294 */ 8295 @NonNull getResourcesForActivity(@onNull ComponentName activityName)8296 public abstract Resources getResourcesForActivity(@NonNull ComponentName activityName) 8297 throws NameNotFoundException; 8298 8299 /** 8300 * Retrieve the resources for an application. Throws NameNotFoundException 8301 * if the package is no longer installed. 8302 * 8303 * @param app Information about the desired application. 8304 * 8305 * @return Returns the application's Resources. 8306 * @throws NameNotFoundException Thrown if the resources for the given 8307 * application could not be loaded (most likely because it was uninstalled). 8308 */ 8309 @NonNull getResourcesForApplication(@onNull ApplicationInfo app)8310 public abstract Resources getResourcesForApplication(@NonNull ApplicationInfo app) 8311 throws NameNotFoundException; 8312 8313 /** 8314 * Retrieve the resources for an application for the provided configuration. 8315 * 8316 * @param app Information about the desired application. 8317 * @param configuration Overridden configuration when loading the Resources 8318 * 8319 * @return Returns the application's Resources. 8320 * @throws NameNotFoundException Thrown if the resources for the given 8321 * application could not be loaded (most likely because it was uninstalled). 8322 */ 8323 @NonNull getResourcesForApplication(@onNull ApplicationInfo app, @Nullable Configuration configuration)8324 public Resources getResourcesForApplication(@NonNull ApplicationInfo app, @Nullable 8325 Configuration configuration) throws NameNotFoundException { 8326 return getResourcesForApplication(app); 8327 } 8328 8329 /** 8330 * Retrieve the resources associated with an application. Given the full 8331 * package name of an application, retrieves the information about it and 8332 * calls getResources() to return its application's resources. If the 8333 * appPackageName cannot be found, NameNotFoundException is thrown. 8334 * 8335 * @param packageName Package name of the application whose resources 8336 * are to be retrieved. 8337 * 8338 * @return Returns the application's Resources. 8339 * @throws NameNotFoundException Thrown if the resources for the given 8340 * application could not be loaded. 8341 * 8342 * @see #getResourcesForApplication(ApplicationInfo) 8343 */ 8344 @NonNull getResourcesForApplication(@onNull String packageName)8345 public abstract Resources getResourcesForApplication(@NonNull String packageName) 8346 throws NameNotFoundException; 8347 8348 /** 8349 * Please don't use this function because it is no longer supported. 8350 * 8351 * @deprecated Instead of using this function, please use 8352 * {@link Context#createContextAsUser(UserHandle, int)} to create the specified user 8353 * context, {@link Context#getPackageManager()} to get PackageManager instance for 8354 * the specified user, and then 8355 * {@link PackageManager#getResourcesForApplication(String)} to get the same 8356 * Resources instance. 8357 * @see {@link Context#createContextAsUser(android.os.UserHandle, int)} 8358 * @see {@link Context#getPackageManager()} 8359 * @see {@link android.content.pm.PackageManager#getResourcesForApplication(java.lang.String)} 8360 * TODO(b/170852794): mark maxTargetSdk as {@code Build.VERSION_CODES.S} 8361 * @hide 8362 */ 8363 @SuppressWarnings("HiddenAbstractMethod") 8364 @NonNull 8365 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170928809, 8366 publicAlternatives = "Use {@code Context#createContextAsUser(UserHandle, int)}" 8367 + " to create the relevant user context," 8368 + " {@link android.content.Context#getPackageManager()} and" 8369 + " {@link android.content.pm.PackageManager#getResourcesForApplication(" 8370 + "java.lang.String)}" 8371 + " instead.") 8372 @Deprecated getResourcesForApplicationAsUser(@onNull String packageName, @UserIdInt int userId)8373 public abstract Resources getResourcesForApplicationAsUser(@NonNull String packageName, 8374 @UserIdInt int userId) throws NameNotFoundException; 8375 8376 /** 8377 * Retrieve overall information about an application package defined in a 8378 * package archive file 8379 * 8380 * Use {@link #getPackageArchiveInfo(String, PackageInfoFlags)} when long flags are needed. 8381 * 8382 * @param archiveFilePath The path to the archive file 8383 * @param flags Additional option flags to modify the data returned. 8384 * @return A PackageInfo object containing information about the package 8385 * archive. If the package could not be parsed, returns null. 8386 */ 8387 @Nullable getPackageArchiveInfo(@onNull String archiveFilePath, int flags)8388 public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath, int flags) { 8389 return getPackageArchiveInfo(archiveFilePath, PackageInfoFlags.of(flags)); 8390 } 8391 8392 /** 8393 * See {@link #getPackageArchiveInfo(String, int)}. 8394 */ 8395 @Nullable getPackageArchiveInfo(@onNull String archiveFilePath, @NonNull PackageInfoFlags flags)8396 public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath, 8397 @NonNull PackageInfoFlags flags) { 8398 long flagsBits = flags.getValue(); 8399 final PackageParser parser = new PackageParser(); 8400 parser.setCallback(new PackageParser.CallbackImpl(this)); 8401 final File apkFile = new File(archiveFilePath); 8402 try { 8403 if ((flagsBits & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) { 8404 // Caller expressed an explicit opinion about what encryption 8405 // aware/unaware components they want to see, so fall through and 8406 // give them what they want 8407 } else { 8408 // Caller expressed no opinion, so match everything 8409 flagsBits |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; 8410 } 8411 8412 PackageParser.Package pkg = parser.parsePackage(apkFile, 0, false); 8413 if ((flagsBits & GET_SIGNATURES) != 0 || (flagsBits & GET_SIGNING_CERTIFICATES) != 0) { 8414 PackageParser.collectCertificates(pkg, false /* skipVerify */); 8415 } 8416 return PackageParser.generatePackageInfo(pkg, null, (int) flagsBits, 0, 0, null, 8417 FrameworkPackageUserState.DEFAULT); 8418 } catch (PackageParser.PackageParserException e) { 8419 Log.w(TAG, "Failure to parse package archive", e); 8420 return null; 8421 } 8422 } 8423 8424 /** 8425 * If there is already an application with the given package name installed 8426 * on the system for other users, also install it for the calling user. 8427 * @hide 8428 * 8429 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 8430 */ 8431 @SuppressWarnings("HiddenAbstractMethod") 8432 @Deprecated 8433 @SystemApi installExistingPackage(@onNull String packageName)8434 public abstract int installExistingPackage(@NonNull String packageName) 8435 throws NameNotFoundException; 8436 8437 /** 8438 * If there is already an application with the given package name installed 8439 * on the system for other users, also install it for the calling user. 8440 * @hide 8441 * 8442 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 8443 */ 8444 @SuppressWarnings("HiddenAbstractMethod") 8445 @Deprecated 8446 @SystemApi installExistingPackage(@onNull String packageName, @InstallReason int installReason)8447 public abstract int installExistingPackage(@NonNull String packageName, 8448 @InstallReason int installReason) throws NameNotFoundException; 8449 8450 /** 8451 * If there is already an application with the given package name installed 8452 * on the system for other users, also install it for the specified user. 8453 * @hide 8454 * 8455 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 8456 */ 8457 @SuppressWarnings("HiddenAbstractMethod") 8458 @Deprecated 8459 @RequiresPermission(anyOf = { 8460 Manifest.permission.INSTALL_EXISTING_PACKAGES, 8461 Manifest.permission.INSTALL_PACKAGES, 8462 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 8463 @UnsupportedAppUsage installExistingPackageAsUser(@onNull String packageName, @UserIdInt int userId)8464 public abstract int installExistingPackageAsUser(@NonNull String packageName, 8465 @UserIdInt int userId) throws NameNotFoundException; 8466 8467 /** 8468 * Allows a package listening to the 8469 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 8470 * broadcast} to respond to the package manager. The response must include 8471 * the {@code verificationCode} which is one of 8472 * {@link PackageManager#VERIFICATION_ALLOW} or 8473 * {@link PackageManager#VERIFICATION_REJECT}. 8474 * 8475 * @param id pending package identifier as passed via the 8476 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 8477 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 8478 * or {@link PackageManager#VERIFICATION_REJECT}. 8479 * @throws SecurityException if the caller does not have the 8480 * PACKAGE_VERIFICATION_AGENT permission. 8481 */ verifyPendingInstall(int id, int verificationCode)8482 public abstract void verifyPendingInstall(int id, int verificationCode); 8483 8484 /** 8485 * Allows a package listening to the 8486 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 8487 * broadcast} to extend the default timeout for a response and declare what 8488 * action to perform after the timeout occurs. The response must include 8489 * the {@code verificationCodeAtTimeout} which is one of 8490 * {@link PackageManager#VERIFICATION_ALLOW} or 8491 * {@link PackageManager#VERIFICATION_REJECT}. 8492 * 8493 * This method may only be called once per package id. Additional calls 8494 * will have no effect. 8495 * 8496 * @param id pending package identifier as passed via the 8497 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 8498 * @param verificationCodeAtTimeout either 8499 * {@link PackageManager#VERIFICATION_ALLOW} or 8500 * {@link PackageManager#VERIFICATION_REJECT}. If 8501 * {@code verificationCodeAtTimeout} is neither 8502 * {@link PackageManager#VERIFICATION_ALLOW} or 8503 * {@link PackageManager#VERIFICATION_REJECT}, then 8504 * {@code verificationCodeAtTimeout} will default to 8505 * {@link PackageManager#VERIFICATION_REJECT}. 8506 * @param millisecondsToDelay the amount of time requested for the timeout. 8507 * Must be positive and less than 8508 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 8509 * {@code millisecondsToDelay} is out of bounds, 8510 * {@code millisecondsToDelay} will be set to the closest in 8511 * bounds value; namely, 0 or 8512 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 8513 * @throws SecurityException if the caller does not have the 8514 * PACKAGE_VERIFICATION_AGENT permission. 8515 */ extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay)8516 public abstract void extendVerificationTimeout(int id, 8517 int verificationCodeAtTimeout, long millisecondsToDelay); 8518 8519 /** 8520 * Allows a package listening to the 8521 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification 8522 * broadcast to respond to the package manager. The response must include 8523 * the {@code verificationCode} which is one of 8524 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 8525 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 8526 * 8527 * @param verificationId pending package identifier as passed via the 8528 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 8529 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 8530 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 8531 * @param failedDomains a list of failed domains if the verificationCode is 8532 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 8533 * @throws SecurityException if the caller does not have the 8534 * INTENT_FILTER_VERIFICATION_AGENT permission. 8535 * 8536 * @deprecated Use {@link DomainVerificationManager} APIs. 8537 * @hide 8538 */ 8539 @Deprecated 8540 @SuppressWarnings("HiddenAbstractMethod") 8541 @SystemApi 8542 @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT) verifyIntentFilter(int verificationId, int verificationCode, @NonNull List<String> failedDomains)8543 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 8544 @NonNull List<String> failedDomains); 8545 8546 /** 8547 * Get the status of a Domain Verification Result for an IntentFilter. This is 8548 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 8549 * {@link android.content.IntentFilter#getAutoVerify()} 8550 * 8551 * This is used by the ResolverActivity to change the status depending on what the User select 8552 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 8553 * for a domain. 8554 * 8555 * @param packageName The package name of the Activity associated with the IntentFilter. 8556 * @param userId The user id. 8557 * 8558 * @return The status to set to. This can be 8559 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 8560 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 8561 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 8562 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 8563 * 8564 * @deprecated Use {@link DomainVerificationManager} APIs. 8565 * @hide 8566 */ 8567 @Deprecated 8568 @SuppressWarnings("HiddenAbstractMethod") 8569 @SystemApi 8570 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) getIntentVerificationStatusAsUser(@onNull String packageName, @UserIdInt int userId)8571 public abstract int getIntentVerificationStatusAsUser(@NonNull String packageName, 8572 @UserIdInt int userId); 8573 8574 /** 8575 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 8576 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 8577 * {@link android.content.IntentFilter#getAutoVerify()} 8578 * 8579 * This is used by the ResolverActivity to change the status depending on what the User select 8580 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 8581 * for a domain. 8582 * 8583 * @param packageName The package name of the Activity associated with the IntentFilter. 8584 * @param status The status to set to. This can be 8585 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 8586 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 8587 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 8588 * @param userId The user id. 8589 * 8590 * @return true if the status has been set. False otherwise. 8591 * 8592 * @deprecated This API represents a very dangerous behavior where Settings or a system app with 8593 * the right permissions can force an application to be verified for all of its declared 8594 * domains. This has been removed to prevent unintended usage, and no longer does anything, 8595 * always returning false. If a caller truly wishes to grant <i></i>every</i> declared web 8596 * domain to an application, use 8597 * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, Set, boolean)}, 8598 * passing in all of the domains returned inside 8599 * {@link DomainVerificationManager#getDomainVerificationUserState(String)}. 8600 * 8601 * @hide 8602 */ 8603 @Deprecated 8604 @SuppressWarnings("HiddenAbstractMethod") 8605 @SystemApi 8606 @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS) updateIntentVerificationStatusAsUser(@onNull String packageName, int status, @UserIdInt int userId)8607 public abstract boolean updateIntentVerificationStatusAsUser(@NonNull String packageName, 8608 int status, @UserIdInt int userId); 8609 8610 /** 8611 * Get the list of IntentFilterVerificationInfo for a specific package and User. 8612 * 8613 * @param packageName the package name. When this parameter is set to a non null value, 8614 * the results will be filtered by the package name provided. 8615 * Otherwise, there will be no filtering and it will return a list 8616 * corresponding for all packages 8617 * 8618 * @return a list of IntentFilterVerificationInfo for a specific package. 8619 * 8620 * @deprecated Use {@link DomainVerificationManager} instead. 8621 * @hide 8622 */ 8623 @Deprecated 8624 @SuppressWarnings("HiddenAbstractMethod") 8625 @NonNull 8626 @SystemApi getIntentFilterVerifications( @onNull String packageName)8627 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 8628 @NonNull String packageName); 8629 8630 /** 8631 * Get the list of IntentFilter for a specific package. 8632 * 8633 * @param packageName the package name. This parameter is set to a non null value, 8634 * the list will contain all the IntentFilter for that package. 8635 * Otherwise, the list will be empty. 8636 * 8637 * @return a list of IntentFilter for a specific package. 8638 * 8639 * @hide 8640 */ 8641 @SuppressWarnings("HiddenAbstractMethod") 8642 @NonNull 8643 @SystemApi getAllIntentFilters(@onNull String packageName)8644 public abstract List<IntentFilter> getAllIntentFilters(@NonNull String packageName); 8645 8646 /** 8647 * Get the default Browser package name for a specific user. 8648 * 8649 * @param userId The user id. 8650 * 8651 * @return the package name of the default Browser for the specified user. If the user id passed 8652 * is -1 (all users) it will return a null value. 8653 * 8654 * @hide 8655 */ 8656 @SuppressWarnings("HiddenAbstractMethod") 8657 @Nullable 8658 @SystemApi 8659 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) getDefaultBrowserPackageNameAsUser(@serIdInt int userId)8660 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId); 8661 8662 /** 8663 * Set the default Browser package name for a specific user. 8664 * 8665 * @param packageName The package name of the default Browser. 8666 * @param userId The user id. 8667 * 8668 * @return true if the default Browser for the specified user has been set, 8669 * otherwise return false. If the user id passed is -1 (all users) this call will not 8670 * do anything and just return false. 8671 * 8672 * @hide 8673 */ 8674 @SuppressWarnings("HiddenAbstractMethod") 8675 @SystemApi 8676 @RequiresPermission(allOf = { 8677 Manifest.permission.SET_PREFERRED_APPLICATIONS, 8678 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) setDefaultBrowserPackageNameAsUser(@ullable String packageName, @UserIdInt int userId)8679 public abstract boolean setDefaultBrowserPackageNameAsUser(@Nullable String packageName, 8680 @UserIdInt int userId); 8681 8682 /** 8683 * Change the installer associated with a given package. There are limitations 8684 * on how the installer package can be changed; in particular: 8685 * <ul> 8686 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 8687 * is not signed with the same certificate as the calling application. 8688 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 8689 * has an installer package, and that installer package is not signed with 8690 * the same certificate as the calling application. 8691 * </ul> 8692 * 8693 * @param targetPackage The installed package whose installer will be changed. 8694 * @param installerPackageName The package name of the new installer. May be 8695 * null to clear the association. 8696 */ setInstallerPackageName(@onNull String targetPackage, @Nullable String installerPackageName)8697 public abstract void setInstallerPackageName(@NonNull String targetPackage, 8698 @Nullable String installerPackageName); 8699 8700 /** @hide */ 8701 @SuppressWarnings("HiddenAbstractMethod") 8702 @SystemApi 8703 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES) setUpdateAvailable(@onNull String packageName, boolean updateAvaialble)8704 public abstract void setUpdateAvailable(@NonNull String packageName, boolean updateAvaialble); 8705 8706 /** 8707 * Attempts to delete a package. Since this may take a little while, the 8708 * result will be posted back to the given observer. A deletion will fail if 8709 * the calling context lacks the 8710 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 8711 * named package cannot be found, or if the named package is a system 8712 * package. 8713 * 8714 * @param packageName The name of the package to delete 8715 * @param observer An observer callback to get notified when the package 8716 * deletion is complete. 8717 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 8718 * will be called when that happens. observer may be null to 8719 * indicate that no callback is desired. 8720 * @hide 8721 */ 8722 @SuppressWarnings("HiddenAbstractMethod") 8723 @RequiresPermission(Manifest.permission.DELETE_PACKAGES) 8724 @UnsupportedAppUsage deletePackage(@onNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags)8725 public abstract void deletePackage(@NonNull String packageName, 8726 @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags); 8727 8728 /** 8729 * Attempts to delete a package. Since this may take a little while, the 8730 * result will be posted back to the given observer. A deletion will fail if 8731 * the named package cannot be found, or if the named package is a system 8732 * package. 8733 * 8734 * @param packageName The name of the package to delete 8735 * @param observer An observer callback to get notified when the package 8736 * deletion is complete. 8737 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 8738 * will be called when that happens. observer may be null to 8739 * indicate that no callback is desired. 8740 * @param userId The user Id 8741 * @hide 8742 */ 8743 @SuppressWarnings("HiddenAbstractMethod") 8744 @RequiresPermission(anyOf = { 8745 Manifest.permission.DELETE_PACKAGES, 8746 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 8747 @UnsupportedAppUsage deletePackageAsUser(@onNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId)8748 public abstract void deletePackageAsUser(@NonNull String packageName, 8749 @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags, 8750 @UserIdInt int userId); 8751 8752 /** 8753 * Retrieve the package name of the application that installed a package. This identifies 8754 * which market the package came from. 8755 * 8756 * @param packageName The name of the package to query 8757 * @throws IllegalArgumentException if the given package name is not installed 8758 * 8759 * @deprecated use {@link #getInstallSourceInfo(String)} instead 8760 */ 8761 @SuppressWarnings("HiddenAbstractMethod") 8762 @Deprecated 8763 @Nullable getInstallerPackageName(@onNull String packageName)8764 public abstract String getInstallerPackageName(@NonNull String packageName); 8765 8766 /** 8767 * Retrieves information about how a package was installed or updated. 8768 * <p> 8769 * If the calling application does not hold the INSTALL_PACKAGES permission then 8770 * the result will always return {@code null} from 8771 * {@link InstallSourceInfo#getOriginatingPackageName()}. 8772 * <p> 8773 * If the package that requested the install has been uninstalled, then information about it 8774 * will only be returned from {@link InstallSourceInfo#getInitiatingPackageName()} and 8775 * {@link InstallSourceInfo#getInitiatingPackageSigningInfo()} if the calling package is 8776 * requesting its own install information and is not an instant app. 8777 * 8778 * @param packageName The name of the package to query 8779 * @throws NameNotFoundException if the given package name is not available to the caller. 8780 */ 8781 @NonNull getInstallSourceInfo(@onNull String packageName)8782 public InstallSourceInfo getInstallSourceInfo(@NonNull String packageName) 8783 throws NameNotFoundException { 8784 throw new UnsupportedOperationException("getInstallSourceInfo not implemented"); 8785 } 8786 8787 /** 8788 * Attempts to clear the user data directory of an application. 8789 * Since this may take a little while, the result will 8790 * be posted back to the given observer. A deletion will fail if the 8791 * named package cannot be found, or if the named package is a "system package". 8792 * 8793 * @param packageName The name of the package 8794 * @param observer An observer callback to get notified when the operation is finished 8795 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 8796 * will be called when that happens. observer may be null to indicate that 8797 * no callback is desired. 8798 * 8799 * @hide 8800 */ 8801 @SuppressWarnings("HiddenAbstractMethod") 8802 @UnsupportedAppUsage clearApplicationUserData(@onNull String packageName, @Nullable IPackageDataObserver observer)8803 public abstract void clearApplicationUserData(@NonNull String packageName, 8804 @Nullable IPackageDataObserver observer); 8805 /** 8806 * Attempts to delete the cache files associated with an application. 8807 * Since this may take a little while, the result will 8808 * be posted back to the given observer. A deletion will fail if the calling context 8809 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 8810 * named package cannot be found, or if the named package is a "system package". 8811 * 8812 * @param packageName The name of the package to delete 8813 * @param observer An observer callback to get notified when the cache file deletion 8814 * is complete. 8815 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 8816 * will be called when that happens. observer may be null to indicate that 8817 * no callback is desired. 8818 * 8819 * @hide 8820 */ 8821 @SuppressWarnings("HiddenAbstractMethod") 8822 @UnsupportedAppUsage deleteApplicationCacheFiles(@onNull String packageName, @Nullable IPackageDataObserver observer)8823 public abstract void deleteApplicationCacheFiles(@NonNull String packageName, 8824 @Nullable IPackageDataObserver observer); 8825 8826 /** 8827 * Attempts to delete the cache files associated with an application for a given user. Since 8828 * this may take a little while, the result will be posted back to the given observer. A 8829 * deletion will fail if the calling context lacks the 8830 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package 8831 * cannot be found, or if the named package is a "system package". If {@code userId} does not 8832 * belong to the calling user, the caller must have 8833 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. 8834 * 8835 * @param packageName The name of the package to delete 8836 * @param userId the user for which the cache files needs to be deleted 8837 * @param observer An observer callback to get notified when the cache file deletion is 8838 * complete. 8839 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 8840 * will be called when that happens. observer may be null to indicate that no 8841 * callback is desired. 8842 * @hide 8843 */ 8844 @SuppressWarnings("HiddenAbstractMethod") 8845 @UnsupportedAppUsage deleteApplicationCacheFilesAsUser(@onNull String packageName, @UserIdInt int userId, @Nullable IPackageDataObserver observer)8846 public abstract void deleteApplicationCacheFilesAsUser(@NonNull String packageName, 8847 @UserIdInt int userId, @Nullable IPackageDataObserver observer); 8848 8849 /** 8850 * Free storage by deleting LRU sorted list of cache files across 8851 * all applications. If the currently available free storage 8852 * on the device is greater than or equal to the requested 8853 * free storage, no cache files are cleared. If the currently 8854 * available storage on the device is less than the requested 8855 * free storage, some or all of the cache files across 8856 * all applications are deleted (based on last accessed time) 8857 * to increase the free storage space on the device to 8858 * the requested value. There is no guarantee that clearing all 8859 * the cache files from all applications will clear up 8860 * enough storage to achieve the desired value. 8861 * @param freeStorageSize The number of bytes of storage to be 8862 * freed by the system. Say if freeStorageSize is XX, 8863 * and the current free storage is YY, 8864 * if XX is less than YY, just return. if not free XX-YY number 8865 * of bytes if possible. 8866 * @param observer call back used to notify when 8867 * the operation is completed 8868 * 8869 * @hide 8870 */ 8871 @UnsupportedAppUsage freeStorageAndNotify(long freeStorageSize, @Nullable IPackageDataObserver observer)8872 public void freeStorageAndNotify(long freeStorageSize, 8873 @Nullable IPackageDataObserver observer) { 8874 freeStorageAndNotify(null, freeStorageSize, observer); 8875 } 8876 8877 /** {@hide} */ 8878 @SuppressWarnings("HiddenAbstractMethod") 8879 @UnsupportedAppUsage freeStorageAndNotify(@ullable String volumeUuid, long freeStorageSize, @Nullable IPackageDataObserver observer)8880 public abstract void freeStorageAndNotify(@Nullable String volumeUuid, long freeStorageSize, 8881 @Nullable IPackageDataObserver observer); 8882 8883 /** 8884 * Free storage by deleting LRU sorted list of cache files across 8885 * all applications. If the currently available free storage 8886 * on the device is greater than or equal to the requested 8887 * free storage, no cache files are cleared. If the currently 8888 * available storage on the device is less than the requested 8889 * free storage, some or all of the cache files across 8890 * all applications are deleted (based on last accessed time) 8891 * to increase the free storage space on the device to 8892 * the requested value. There is no guarantee that clearing all 8893 * the cache files from all applications will clear up 8894 * enough storage to achieve the desired value. 8895 * @param freeStorageSize The number of bytes of storage to be 8896 * freed by the system. Say if freeStorageSize is XX, 8897 * and the current free storage is YY, 8898 * if XX is less than YY, just return. if not free XX-YY number 8899 * of bytes if possible. 8900 * @param pi IntentSender call back used to 8901 * notify when the operation is completed.May be null 8902 * to indicate that no call back is desired. 8903 * 8904 * @hide 8905 */ 8906 @UnsupportedAppUsage freeStorage(long freeStorageSize, @Nullable IntentSender pi)8907 public void freeStorage(long freeStorageSize, @Nullable IntentSender pi) { 8908 freeStorage(null, freeStorageSize, pi); 8909 } 8910 8911 /** {@hide} */ 8912 @SuppressWarnings("HiddenAbstractMethod") 8913 @UnsupportedAppUsage freeStorage(@ullable String volumeUuid, long freeStorageSize, @Nullable IntentSender pi)8914 public abstract void freeStorage(@Nullable String volumeUuid, long freeStorageSize, 8915 @Nullable IntentSender pi); 8916 8917 /** 8918 * Retrieve the size information for a package. 8919 * Since this may take a little while, the result will 8920 * be posted back to the given observer. The calling context 8921 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 8922 * 8923 * @param packageName The name of the package whose size information is to be retrieved 8924 * @param userId The user whose size information should be retrieved. 8925 * @param observer An observer callback to get notified when the operation 8926 * is complete. 8927 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 8928 * The observer's callback is invoked with a PackageStats object(containing the 8929 * code, data and cache sizes of the package) and a boolean value representing 8930 * the status of the operation. observer may be null to indicate that 8931 * no callback is desired. 8932 * 8933 * @deprecated use {@link StorageStatsManager} instead. 8934 * @hide 8935 */ 8936 @SuppressWarnings("HiddenAbstractMethod") 8937 @Deprecated 8938 @UnsupportedAppUsage getPackageSizeInfoAsUser(@onNull String packageName, @UserIdInt int userId, @Nullable IPackageStatsObserver observer)8939 public abstract void getPackageSizeInfoAsUser(@NonNull String packageName, 8940 @UserIdInt int userId, @Nullable IPackageStatsObserver observer); 8941 8942 /** 8943 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 8944 * returns the size for the calling user. 8945 * 8946 * @deprecated use {@link StorageStatsManager} instead. 8947 * @hide 8948 */ 8949 @Deprecated 8950 @UnsupportedAppUsage getPackageSizeInfo(@onNull String packageName, IPackageStatsObserver observer)8951 public void getPackageSizeInfo(@NonNull String packageName, IPackageStatsObserver observer) { 8952 getPackageSizeInfoAsUser(packageName, getUserId(), observer); 8953 } 8954 8955 /** 8956 * @deprecated This function no longer does anything. It is the platform's 8957 * responsibility to assign preferred activities and this cannot be modified 8958 * directly. To determine the activities resolved by the platform, use 8959 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 8960 * an app to be responsible for a particular role and to check current role 8961 * holders, see {@link android.app.role.RoleManager}. 8962 */ 8963 @Deprecated addPackageToPreferred(@onNull String packageName)8964 public abstract void addPackageToPreferred(@NonNull String packageName); 8965 8966 /** 8967 * @deprecated This function no longer does anything. It is the platform's 8968 * responsibility to assign preferred activities and this cannot be modified 8969 * directly. To determine the activities resolved by the platform, use 8970 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 8971 * an app to be responsible for a particular role and to check current role 8972 * holders, see {@link android.app.role.RoleManager}. 8973 */ 8974 @Deprecated removePackageFromPreferred(@onNull String packageName)8975 public abstract void removePackageFromPreferred(@NonNull String packageName); 8976 8977 /** 8978 * Retrieve the list of all currently configured preferred packages. The 8979 * first package on the list is the most preferred, the last is the least 8980 * preferred. 8981 * 8982 * @param flags Additional option flags to modify the data returned. 8983 * @return A List of PackageInfo objects, one for each preferred 8984 * application, in order of preference. 8985 * 8986 * @deprecated This function no longer does anything. It is the platform's 8987 * responsibility to assign preferred activities and this cannot be modified 8988 * directly. To determine the activities resolved by the platform, use 8989 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 8990 * an app to be responsible for a particular role and to check current role 8991 * holders, see {@link android.app.role.RoleManager}. 8992 */ 8993 @NonNull 8994 @Deprecated getPreferredPackages(int flags)8995 public abstract List<PackageInfo> getPreferredPackages(int flags); 8996 8997 /** 8998 * Add a new preferred activity mapping to the system. This will be used 8999 * to automatically select the given activity component when 9000 * {@link Context#startActivity(Intent) Context.startActivity()} finds 9001 * multiple matching activities and also matches the given filter. 9002 * 9003 * @param filter The set of intents under which this activity will be 9004 * made preferred. 9005 * @param match The IntentFilter match category that this preference 9006 * applies to. 9007 * @param set The set of activities that the user was picking from when 9008 * this preference was made. 9009 * @param activity The component name of the activity that is to be 9010 * preferred. 9011 * 9012 * @deprecated This function no longer does anything. It is the platform's 9013 * responsibility to assign preferred activities and this cannot be modified 9014 * directly. To determine the activities resolved by the platform, use 9015 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9016 * an app to be responsible for a particular role and to check current role 9017 * holders, see {@link android.app.role.RoleManager}. 9018 */ 9019 @Deprecated addPreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9020 public abstract void addPreferredActivity(@NonNull IntentFilter filter, int match, 9021 @Nullable ComponentName[] set, @NonNull ComponentName activity); 9022 9023 /** 9024 * Same as {@link #addPreferredActivity(IntentFilter, int, 9025 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 9026 to. 9027 * @hide 9028 * 9029 * @deprecated This function no longer does anything. It is the platform's 9030 * responsibility to assign preferred activities and this cannot be modified 9031 * directly. To determine the activities resolved by the platform, use 9032 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9033 * an app to be responsible for a particular role and to check current role 9034 * holders, see {@link android.app.role.RoleManager}. 9035 */ 9036 @Deprecated 9037 @UnsupportedAppUsage addPreferredActivityAsUser(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId)9038 public void addPreferredActivityAsUser(@NonNull IntentFilter filter, int match, 9039 @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) { 9040 throw new RuntimeException("Not implemented. Must override in a subclass."); 9041 } 9042 9043 /** 9044 * Replaces an existing preferred activity mapping to the system, and if that were not present 9045 * adds a new preferred activity. This will be used 9046 * to automatically select the given activity component when 9047 * {@link Context#startActivity(Intent) Context.startActivity()} finds 9048 * multiple matching activities and also matches the given filter. 9049 * 9050 * @param filter The set of intents under which this activity will be 9051 * made preferred. 9052 * @param match The IntentFilter match category that this preference 9053 * applies to. 9054 * @param set The set of activities that the user was picking from when 9055 * this preference was made. 9056 * @param activity The component name of the activity that is to be 9057 * preferred. 9058 * 9059 * @hide 9060 * 9061 * @deprecated This function no longer does anything. It is the platform's 9062 * responsibility to assign preferred activities and this cannot be modified 9063 * directly. To determine the activities resolved by the platform, use 9064 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9065 * an app to be responsible for a particular role and to check current role 9066 * holders, see {@link android.app.role.RoleManager}. 9067 */ 9068 @SuppressWarnings("HiddenAbstractMethod") 9069 @Deprecated 9070 @UnsupportedAppUsage replacePreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9071 public abstract void replacePreferredActivity(@NonNull IntentFilter filter, int match, 9072 @Nullable ComponentName[] set, @NonNull ComponentName activity); 9073 9074 /** 9075 * Replaces an existing preferred activity mapping to the system, and if that were not present 9076 * adds a new preferred activity. This will be used to automatically select the given activity 9077 * component when {@link Context#startActivity(Intent) Context.startActivity()} finds multiple 9078 * matching activities and also matches the given filter. 9079 * 9080 * @param filter The set of intents under which this activity will be made preferred. 9081 * @param match The IntentFilter match category that this preference applies to. Should be a 9082 * combination of {@link IntentFilter#MATCH_CATEGORY_MASK} and 9083 * {@link IntentFilter#MATCH_ADJUSTMENT_MASK}). 9084 * @param set The set of activities that the user was picking from when this preference was 9085 * made. 9086 * @param activity The component name of the activity that is to be preferred. 9087 * 9088 * @hide 9089 */ 9090 @SystemApi replacePreferredActivity(@onNull IntentFilter filter, int match, @NonNull List<ComponentName> set, @NonNull ComponentName activity)9091 public void replacePreferredActivity(@NonNull IntentFilter filter, int match, 9092 @NonNull List<ComponentName> set, @NonNull ComponentName activity) { 9093 replacePreferredActivity(filter, match, set.toArray(new ComponentName[0]), activity); 9094 } 9095 9096 /** 9097 * @hide 9098 * 9099 * @deprecated This function no longer does anything. It is the platform's 9100 * responsibility to assign preferred activities and this cannot be modified 9101 * directly. To determine the activities resolved by the platform, use 9102 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9103 * an app to be responsible for a particular role and to check current role 9104 * holders, see {@link android.app.role.RoleManager}. 9105 */ 9106 @Deprecated 9107 @UnsupportedAppUsage replacePreferredActivityAsUser(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId)9108 public void replacePreferredActivityAsUser(@NonNull IntentFilter filter, int match, 9109 @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) { 9110 throw new RuntimeException("Not implemented. Must override in a subclass."); 9111 } 9112 9113 /** 9114 * Remove all preferred activity mappings, previously added with 9115 * {@link #addPreferredActivity}, from the 9116 * system whose activities are implemented in the given package name. 9117 * An application can only clear its own package(s). 9118 * 9119 * @param packageName The name of the package whose preferred activity 9120 * mappings are to be removed. 9121 * 9122 * @deprecated This function no longer does anything. It is the platform's 9123 * responsibility to assign preferred activities and this cannot be modified 9124 * directly. To determine the activities resolved by the platform, use 9125 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9126 * an app to be responsible for a particular role and to check current role 9127 * holders, see {@link android.app.role.RoleManager}. 9128 */ 9129 @Deprecated clearPackagePreferredActivities(@onNull String packageName)9130 public abstract void clearPackagePreferredActivities(@NonNull String packageName); 9131 9132 /** 9133 * Same as {@link #addPreferredActivity(IntentFilter, int, ComponentName[], ComponentName)}, 9134 * but removes all existing entries that match this filter. 9135 * @hide 9136 */ addUniquePreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9137 public void addUniquePreferredActivity(@NonNull IntentFilter filter, int match, 9138 @Nullable ComponentName[] set, @NonNull ComponentName activity) { 9139 throw new UnsupportedOperationException( 9140 "addUniquePreferredActivity not implemented in subclass"); 9141 } 9142 9143 /** 9144 * Retrieve all preferred activities, previously added with 9145 * {@link #addPreferredActivity}, that are 9146 * currently registered with the system. 9147 * 9148 * @param outFilters A required list in which to place the filters of all of the 9149 * preferred activities. 9150 * @param outActivities A required list in which to place the component names of 9151 * all of the preferred activities. 9152 * @param packageName An optional package in which you would like to limit 9153 * the list. If null, all activities will be returned; if non-null, only 9154 * those activities in the given package are returned. 9155 * 9156 * @return Returns the total number of registered preferred activities 9157 * (the number of distinct IntentFilter records, not the number of unique 9158 * activity components) that were found. 9159 * 9160 * @deprecated This function no longer does anything. It is the platform's 9161 * responsibility to assign preferred activities and this cannot be modified 9162 * directly. To determine the activities resolved by the platform, use 9163 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9164 * an app to be responsible for a particular role and to check current role 9165 * holders, see {@link android.app.role.RoleManager}. 9166 */ 9167 @Deprecated getPreferredActivities(@onNull List<IntentFilter> outFilters, @NonNull List<ComponentName> outActivities, @Nullable String packageName)9168 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 9169 @NonNull List<ComponentName> outActivities, @Nullable String packageName); 9170 9171 /** 9172 * Ask for the set of available 'home' activities and the current explicit 9173 * default, if any. 9174 * @hide 9175 */ 9176 @SuppressWarnings("HiddenAbstractMethod") 9177 @Nullable 9178 @UnsupportedAppUsage getHomeActivities(@onNull List<ResolveInfo> outActivities)9179 public abstract ComponentName getHomeActivities(@NonNull List<ResolveInfo> outActivities); 9180 9181 /** 9182 * Set the enabled setting for a package component (activity, receiver, service, provider). 9183 * This setting will override any enabled state which may have been set by the component in its 9184 * manifest. 9185 * 9186 * <p>Consider using {@link #setComponentEnabledSettings(List)} if multiple components need to 9187 * be updated atomically. 9188 * 9189 * @param componentName The component to enable 9190 * @param newState The new enabled state for the component. 9191 * @param flags Optional behavior flags. 9192 */ 9193 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 9194 conditional = true) setComponentEnabledSetting(@onNull ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags)9195 public abstract void setComponentEnabledSetting(@NonNull ComponentName componentName, 9196 @EnabledState int newState, @EnabledFlags int flags); 9197 9198 /** 9199 * Set the enabled settings for package components such as activities, receivers, services and 9200 * providers. This setting will override any enabled state which may have been set by the 9201 * component in its manifest. 9202 * 9203 * <p>This api accepts a list of component changes, and applies them all atomically. The 9204 * application can use this api if components have dependencies and need to be updated 9205 * atomically. 9206 * 9207 * <p>The permission is not required if target components are running under the same uid with 9208 * the caller. 9209 * 9210 * @param settings The list of component enabled settings to update. Note that an 9211 * {@link IllegalArgumentException} is thrown if the duplicated component name 9212 * is in the list or there's a conflict {@link #DONT_KILL_APP} flag between 9213 * different components in the same package. 9214 * 9215 * @see #setComponentEnabledSetting(ComponentName, int, int) 9216 */ 9217 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 9218 conditional = true) setComponentEnabledSettings(@onNull List<ComponentEnabledSetting> settings)9219 public void setComponentEnabledSettings(@NonNull List<ComponentEnabledSetting> settings) { 9220 throw new UnsupportedOperationException("setComponentEnabledSettings not implemented" 9221 + "in subclass"); 9222 } 9223 9224 /** 9225 * Return the enabled setting for a package component (activity, 9226 * receiver, service, provider). This returns the last value set by 9227 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 9228 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 9229 * the value originally specified in the manifest has not been modified. 9230 * 9231 * @param componentName The component to retrieve. 9232 * @return Returns the current enabled state for the component. 9233 */ getComponentEnabledSetting( @onNull ComponentName componentName)9234 public abstract @EnabledState int getComponentEnabledSetting( 9235 @NonNull ComponentName componentName); 9236 9237 /** 9238 * Set whether a synthetic app details activity will be generated if the app has no enabled 9239 * launcher activity. Disabling this allows the app to have no launcher icon. 9240 * 9241 * @param packageName The package name of the app 9242 * @param enabled The new enabled state for the synthetic app details activity. 9243 * 9244 * @hide 9245 */ 9246 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 9247 conditional = true) 9248 @SystemApi setSyntheticAppDetailsActivityEnabled(@onNull String packageName, boolean enabled)9249 public void setSyntheticAppDetailsActivityEnabled(@NonNull String packageName, 9250 boolean enabled) { 9251 throw new UnsupportedOperationException( 9252 "setSyntheticAppDetailsActivityEnabled not implemented"); 9253 } 9254 9255 9256 /** 9257 * Return whether a synthetic app details activity will be generated if the app has no enabled 9258 * launcher activity. 9259 * 9260 * @param packageName The package name of the app 9261 * @return Returns the enabled state for the synthetic app details activity. 9262 * 9263 * 9264 */ getSyntheticAppDetailsActivityEnabled(@onNull String packageName)9265 public boolean getSyntheticAppDetailsActivityEnabled(@NonNull String packageName) { 9266 throw new UnsupportedOperationException( 9267 "getSyntheticAppDetailsActivityEnabled not implemented"); 9268 } 9269 9270 /** 9271 * Set the enabled setting for an application 9272 * This setting will override any enabled state which may have been set by the application in 9273 * its manifest. It also overrides the enabled state set in the manifest for any of the 9274 * application's components. It does not override any enabled state set by 9275 * {@link #setComponentEnabledSetting} for any of the application's components. 9276 * 9277 * @param packageName The package name of the application to enable 9278 * @param newState The new enabled state for the application. 9279 * @param flags Optional behavior flags. 9280 */ 9281 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 9282 conditional = true) setApplicationEnabledSetting(@onNull String packageName, @EnabledState int newState, @EnabledFlags int flags)9283 public abstract void setApplicationEnabledSetting(@NonNull String packageName, 9284 @EnabledState int newState, @EnabledFlags int flags); 9285 9286 /** 9287 * Return the enabled setting for an application. This returns 9288 * the last value set by 9289 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 9290 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 9291 * the value originally specified in the manifest has not been modified. 9292 * 9293 * @param packageName The package name of the application to retrieve. 9294 * @return Returns the current enabled state for the application. 9295 * @throws IllegalArgumentException if the named package does not exist. 9296 */ getApplicationEnabledSetting(@onNull String packageName)9297 public abstract @EnabledState int getApplicationEnabledSetting(@NonNull String packageName); 9298 9299 /** 9300 * Flush the package restrictions for a given user to disk. This forces the package restrictions 9301 * like component and package enabled settings to be written to disk and avoids the delay that 9302 * is otherwise present when changing those settings. 9303 * 9304 * @param userId Ther userId of the user whose restrictions are to be flushed. 9305 * @hide 9306 */ 9307 @SuppressWarnings("HiddenAbstractMethod") 9308 @UnsupportedAppUsage flushPackageRestrictionsAsUser(@serIdInt int userId)9309 public abstract void flushPackageRestrictionsAsUser(@UserIdInt int userId); 9310 9311 /** 9312 * Puts the package in a hidden state, which is almost like an uninstalled state, 9313 * making the package unavailable, but it doesn't remove the data or the actual 9314 * package file. Application can be unhidden by either resetting the hidden state 9315 * or by installing it, such as with {@link #installExistingPackage(String)} 9316 * @hide 9317 */ 9318 @SuppressWarnings("HiddenAbstractMethod") 9319 @UnsupportedAppUsage setApplicationHiddenSettingAsUser(@onNull String packageName, boolean hidden, @NonNull UserHandle userHandle)9320 public abstract boolean setApplicationHiddenSettingAsUser(@NonNull String packageName, 9321 boolean hidden, @NonNull UserHandle userHandle); 9322 9323 /** 9324 * Returns the hidden state of a package. 9325 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 9326 * @hide 9327 */ 9328 @SuppressWarnings("HiddenAbstractMethod") 9329 @UnsupportedAppUsage getApplicationHiddenSettingAsUser(@onNull String packageName, @NonNull UserHandle userHandle)9330 public abstract boolean getApplicationHiddenSettingAsUser(@NonNull String packageName, 9331 @NonNull UserHandle userHandle); 9332 9333 /** 9334 * Sets the state of a system app. 9335 * 9336 * This method can be used to change a system app's hidden-until-installed state (via 9337 * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN} and 9338 * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE} or its installation state (via 9339 * {@link #SYSTEM_APP_STATE_INSTALLED} and {@link #SYSTEM_APP_STATE_UNINSTALLED}. 9340 * 9341 * This API may only be called from {@link android.os.Process#SYSTEM_UID} or 9342 * {@link android.os.Process#PHONE_UID}. 9343 * 9344 * @param packageName Package name of the app. 9345 * @param state State of the app. 9346 * @hide 9347 */ 9348 @SystemApi setSystemAppState(@onNull String packageName, @SystemAppState int state)9349 public void setSystemAppState(@NonNull String packageName, @SystemAppState int state) { 9350 throw new RuntimeException("Not implemented. Must override in a subclass"); 9351 } 9352 9353 /** 9354 * Return whether the device has been booted into safe mode. 9355 */ isSafeMode()9356 public abstract boolean isSafeMode(); 9357 9358 /** 9359 * Adds a listener for permission changes for installed packages. 9360 * 9361 * @param listener The listener to add. 9362 * 9363 * @hide 9364 */ 9365 //@Deprecated 9366 @SuppressWarnings("HiddenAbstractMethod") 9367 @SystemApi 9368 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) addOnPermissionsChangeListener( @onNull OnPermissionsChangedListener listener)9369 public abstract void addOnPermissionsChangeListener( 9370 @NonNull OnPermissionsChangedListener listener); 9371 9372 /** 9373 * Remvoes a listener for permission changes for installed packages. 9374 * 9375 * @param listener The listener to remove. 9376 * 9377 * @hide 9378 */ 9379 //@Deprecated 9380 @SuppressWarnings("HiddenAbstractMethod") 9381 @SystemApi 9382 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) removeOnPermissionsChangeListener( @onNull OnPermissionsChangedListener listener)9383 public abstract void removeOnPermissionsChangeListener( 9384 @NonNull OnPermissionsChangedListener listener); 9385 9386 /** 9387 * Return the {@link KeySet} associated with the String alias for this 9388 * application. 9389 * 9390 * @param alias The alias for a given {@link KeySet} as defined in the 9391 * application's AndroidManifest.xml. 9392 * @hide 9393 */ 9394 @SuppressWarnings("HiddenAbstractMethod") 9395 @NonNull 9396 @UnsupportedAppUsage getKeySetByAlias(@onNull String packageName, @NonNull String alias)9397 public abstract KeySet getKeySetByAlias(@NonNull String packageName, @NonNull String alias); 9398 9399 /** Return the signing {@link KeySet} for this application. 9400 * @hide 9401 */ 9402 @SuppressWarnings("HiddenAbstractMethod") 9403 @NonNull 9404 @UnsupportedAppUsage getSigningKeySet(@onNull String packageName)9405 public abstract KeySet getSigningKeySet(@NonNull String packageName); 9406 9407 /** 9408 * Return whether the package denoted by packageName has been signed by all 9409 * of the keys specified by the {@link KeySet} ks. This will return true if 9410 * the package has been signed by additional keys (a superset) as well. 9411 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 9412 * @hide 9413 */ 9414 @SuppressWarnings("HiddenAbstractMethod") 9415 @UnsupportedAppUsage isSignedBy(@onNull String packageName, @NonNull KeySet ks)9416 public abstract boolean isSignedBy(@NonNull String packageName, @NonNull KeySet ks); 9417 9418 /** 9419 * Return whether the package denoted by packageName has been signed by all 9420 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 9421 * {@link #isSignedBy(String packageName, KeySet ks)}. 9422 * @hide 9423 */ 9424 @SuppressWarnings("HiddenAbstractMethod") 9425 @UnsupportedAppUsage isSignedByExactly(@onNull String packageName, @NonNull KeySet ks)9426 public abstract boolean isSignedByExactly(@NonNull String packageName, @NonNull KeySet ks); 9427 9428 /** 9429 * Flag to denote no restrictions. This should be used to clear any restrictions that may have 9430 * been previously set for the package. 9431 * @hide 9432 * @see #setDistractingPackageRestrictions(String[], int) 9433 */ 9434 @SystemApi 9435 public static final int RESTRICTION_NONE = 0x0; 9436 9437 /** 9438 * Flag to denote that a package should be hidden from any suggestions to the user. 9439 * @hide 9440 * @see #setDistractingPackageRestrictions(String[], int) 9441 */ 9442 @SystemApi 9443 public static final int RESTRICTION_HIDE_FROM_SUGGESTIONS = 0x00000001; 9444 9445 /** 9446 * Flag to denote that a package's notifications should be hidden. 9447 * @hide 9448 * @see #setDistractingPackageRestrictions(String[], int) 9449 */ 9450 @SystemApi 9451 public static final int RESTRICTION_HIDE_NOTIFICATIONS = 0x00000002; 9452 9453 /** 9454 * Restriction flags to set on a package that is considered as distracting to the user. 9455 * These should help the user to restrict their usage of these apps. 9456 * 9457 * @see #setDistractingPackageRestrictions(String[], int) 9458 * @hide 9459 */ 9460 @IntDef(flag = true, prefix = {"RESTRICTION_"}, value = { 9461 RESTRICTION_NONE, 9462 RESTRICTION_HIDE_FROM_SUGGESTIONS, 9463 RESTRICTION_HIDE_NOTIFICATIONS 9464 }) 9465 @Retention(RetentionPolicy.SOURCE) 9466 public @interface DistractionRestriction {} 9467 9468 /** 9469 * Mark or unmark the given packages as distracting to the user. 9470 * These packages can have certain restrictions set that should discourage the user to launch 9471 * them often. For example, notifications from such an app can be hidden, or the app can be 9472 * removed from launcher suggestions, so the user is able to restrict their use of these apps. 9473 * 9474 * <p>The caller must hold {@link android.Manifest.permission#SUSPEND_APPS} to use this API. 9475 * 9476 * @param packages Packages to mark as distracting. 9477 * @param restrictionFlags Any combination of restrictions to impose on the given packages. 9478 * {@link #RESTRICTION_NONE} can be used to clear any existing 9479 * restrictions. 9480 * @return A list of packages that could not have the {@code restrictionFlags} set. The system 9481 * may prevent restricting critical packages to preserve normal device function. 9482 * 9483 * @hide 9484 * @see #RESTRICTION_NONE 9485 * @see #RESTRICTION_HIDE_FROM_SUGGESTIONS 9486 * @see #RESTRICTION_HIDE_NOTIFICATIONS 9487 */ 9488 @SystemApi 9489 @RequiresPermission(android.Manifest.permission.SUSPEND_APPS) 9490 @NonNull setDistractingPackageRestrictions(@onNull String[] packages, @DistractionRestriction int restrictionFlags)9491 public String[] setDistractingPackageRestrictions(@NonNull String[] packages, 9492 @DistractionRestriction int restrictionFlags) { 9493 throw new UnsupportedOperationException( 9494 "setDistractingPackageRestrictions not implemented"); 9495 } 9496 9497 /** 9498 * Puts the package in a suspended state, where attempts at starting activities are denied. 9499 * 9500 * <p>It doesn't remove the data or the actual package file. The application's notifications 9501 * will be hidden, any of its started activities will be stopped and it will not be able to 9502 * show toasts or system alert windows or ring the device. 9503 * 9504 * <p>When the user tries to launch a suspended app, a system dialog with the given 9505 * {@code dialogMessage} will be shown instead. Since the message is supplied to the system as 9506 * a {@link String}, the caller needs to take care of localization as needed. 9507 * The dialog message can optionally contain a placeholder for the name of the suspended app. 9508 * The system uses {@link String#format(Locale, String, Object...) String.format} to insert the 9509 * app name into the message, so an example format string could be {@code "The app %1$s is 9510 * currently suspended"}. This makes it easier for callers to provide a single message which 9511 * works for all the packages being suspended in a single call. 9512 * 9513 * <p>The package must already be installed. If the package is uninstalled while suspended 9514 * the package will no longer be suspended. </p> 9515 * 9516 * <p>Optionally, the suspending app can provide extra information in the form of 9517 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 9518 * launcher to support customization that they might need to handle the suspended state. 9519 * 9520 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API. 9521 * 9522 * @param packageNames The names of the packages to set the suspended status. 9523 * @param suspended If set to {@code true}, the packages will be suspended, if set to 9524 * {@code false}, the packages will be unsuspended. 9525 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 9526 * which will be shared with the apps being suspended. Ignored if 9527 * {@code suspended} is false. 9528 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 9529 * provide which will be shared with the launcher. Ignored if 9530 * {@code suspended} is false. 9531 * @param dialogMessage The message to be displayed to the user, when they try to launch a 9532 * suspended app. 9533 * 9534 * @return an array of package names for which the suspended status could not be set as 9535 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}. 9536 * 9537 * @deprecated use {@link #setPackagesSuspended(String[], boolean, PersistableBundle, 9538 * PersistableBundle, android.content.pm.SuspendDialogInfo)} instead. 9539 * 9540 * @hide 9541 */ 9542 @SystemApi 9543 @Deprecated 9544 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 9545 @Nullable setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable String dialogMessage)9546 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended, 9547 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 9548 @Nullable String dialogMessage) { 9549 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 9550 } 9551 9552 /** 9553 * Puts the given packages in a suspended state, where attempts at starting activities are 9554 * denied. 9555 * 9556 * <p>The suspended application's notifications and all of its windows will be hidden, any 9557 * of its started activities will be stopped and it won't be able to ring the device. 9558 * It doesn't remove the data or the actual package file. 9559 * 9560 * <p>When the user tries to launch a suspended app, a system dialog alerting them that the app 9561 * is suspended will be shown instead. 9562 * The caller can optionally customize the dialog by passing a {@link SuspendDialogInfo} object 9563 * to this API. This dialog will have a button that starts the 9564 * {@link Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS} intent if the suspending app declares an 9565 * activity which handles this action. 9566 * 9567 * <p>The packages being suspended must already be installed. If a package is uninstalled, it 9568 * will no longer be suspended. 9569 * 9570 * <p>Optionally, the suspending app can provide extra information in the form of 9571 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 9572 * launcher to support customization that they might need to handle the suspended state. 9573 * 9574 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API. 9575 * 9576 * @param packageNames The names of the packages to set the suspended status. 9577 * @param suspended If set to {@code true}, the packages will be suspended, if set to 9578 * {@code false}, the packages will be unsuspended. 9579 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 9580 * which will be shared with the apps being suspended. Ignored if 9581 * {@code suspended} is false. 9582 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 9583 * provide which will be shared with the launcher. Ignored if 9584 * {@code suspended} is false. 9585 * @param dialogInfo An optional {@link SuspendDialogInfo} object describing the dialog that 9586 * should be shown to the user when they try to launch a suspended app. 9587 * Ignored if {@code suspended} is false. 9588 * 9589 * @return an array of package names for which the suspended status could not be set as 9590 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}. 9591 * 9592 * @see #isPackageSuspended 9593 * @see SuspendDialogInfo 9594 * @see SuspendDialogInfo.Builder 9595 * @see Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS 9596 * 9597 * @hide 9598 */ 9599 @SystemApi 9600 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 9601 @Nullable setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable SuspendDialogInfo dialogInfo)9602 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended, 9603 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 9604 @Nullable SuspendDialogInfo dialogInfo) { 9605 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 9606 } 9607 9608 /** 9609 * Returns any packages in a given set of packages that cannot be suspended via a call to {@link 9610 * #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, 9611 * SuspendDialogInfo) setPackagesSuspended}. The platform prevents suspending certain critical 9612 * packages to keep the device in a functioning state, e.g. the default dialer and launcher. 9613 * Apps need to hold {@link Manifest.permission#SUSPEND_APPS SUSPEND_APPS} to call this API. 9614 * 9615 * <p> 9616 * Note that this set of critical packages can change with time, so even though a package name 9617 * was not returned by this call, it does not guarantee that a subsequent call to 9618 * {@link #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, 9619 * SuspendDialogInfo) setPackagesSuspended} for that package will succeed, especially if 9620 * significant time elapsed between the two calls. 9621 * 9622 * @param packageNames The packages to check. 9623 * @return A list of packages that can not be currently suspended by the system. 9624 * @hide 9625 */ 9626 @SystemApi 9627 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 9628 @NonNull getUnsuspendablePackages(@onNull String[] packageNames)9629 public String[] getUnsuspendablePackages(@NonNull String[] packageNames) { 9630 throw new UnsupportedOperationException("getUnsuspendablePackages not implemented"); 9631 } 9632 9633 /** 9634 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 9635 * @param packageName The name of the package to get the suspended status of. 9636 * @param userId The user id. 9637 * @return {@code true} if the package is suspended or {@code false} if the package is not 9638 * suspended. 9639 * @throws IllegalArgumentException if the package was not found. 9640 * @hide 9641 */ 9642 @SuppressWarnings("HiddenAbstractMethod") 9643 @UnsupportedAppUsage isPackageSuspendedForUser(@onNull String packageName, int userId)9644 public abstract boolean isPackageSuspendedForUser(@NonNull String packageName, int userId); 9645 9646 /** 9647 * Query if an app is currently suspended. 9648 * 9649 * @return {@code true} if the given package is suspended, {@code false} otherwise 9650 * @throws NameNotFoundException if the package could not be found. 9651 * 9652 * @see #isPackageSuspended() 9653 */ isPackageSuspended(@onNull String packageName)9654 public boolean isPackageSuspended(@NonNull String packageName) throws NameNotFoundException { 9655 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 9656 } 9657 9658 /** 9659 * Apps can query this to know if they have been suspended. A system app with the permission 9660 * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state. 9661 * 9662 * <p>While in this state, the application's notifications will be hidden, any of its started 9663 * activities will be stopped and it will not be able to show toasts or dialogs or play audio. 9664 * When the user tries to launch a suspended app, the system will, instead, show a 9665 * dialog to the user informing them that they cannot use this app while it is suspended. 9666 * 9667 * <p>When an app is put into this state, the broadcast action 9668 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast 9669 * receivers that included this action in their intent-filters, <em>including manifest 9670 * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED} 9671 * is delivered when a previously suspended app is taken out of this state. Apps are expected to 9672 * use these to gracefully deal with transitions to and from this state. 9673 * 9674 * @return {@code true} if the calling package has been suspended, {@code false} otherwise. 9675 * 9676 * @see #getSuspendedPackageAppExtras() 9677 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 9678 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 9679 */ isPackageSuspended()9680 public boolean isPackageSuspended() { 9681 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 9682 } 9683 9684 /** 9685 * Returns a {@link Bundle} of extras that was meant to be sent to the calling app when it was 9686 * suspended. An app with the permission {@code android.permission.SUSPEND_APPS} can supply this 9687 * to the system at the time of suspending an app. 9688 * 9689 * <p>This is the same {@link Bundle} that is sent along with the broadcast 9690 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED}, whenever the app is suspended. The contents of 9691 * this {@link Bundle} are a contract between the suspended app and the suspending app. 9692 * 9693 * <p>Note: These extras are optional, so if no extras were supplied to the system, this method 9694 * will return {@code null}, even when the calling app has been suspended. 9695 * 9696 * @return A {@link Bundle} containing the extras for the app, or {@code null} if the 9697 * package is not currently suspended. 9698 * 9699 * @see #isPackageSuspended() 9700 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 9701 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 9702 * @see Intent#EXTRA_SUSPENDED_PACKAGE_EXTRAS 9703 */ getSuspendedPackageAppExtras()9704 public @Nullable Bundle getSuspendedPackageAppExtras() { 9705 throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented"); 9706 } 9707 9708 /** 9709 * Provide a hint of what the {@link ApplicationInfo#category} value should 9710 * be for the given package. 9711 * <p> 9712 * This hint can only be set by the app which installed this package, as 9713 * determined by {@link #getInstallerPackageName(String)}. 9714 * 9715 * @param packageName the package to change the category hint for. 9716 * @param categoryHint the category hint to set. 9717 */ 9718 @SuppressWarnings("HiddenAbstractMethod") setApplicationCategoryHint(@onNull String packageName, @ApplicationInfo.Category int categoryHint)9719 public abstract void setApplicationCategoryHint(@NonNull String packageName, 9720 @ApplicationInfo.Category int categoryHint); 9721 9722 /** {@hide} */ isMoveStatusFinished(int status)9723 public static boolean isMoveStatusFinished(int status) { 9724 return (status < 0 || status > 100); 9725 } 9726 9727 /** {@hide} */ 9728 public static abstract class MoveCallback { onCreated(int moveId, Bundle extras)9729 public void onCreated(int moveId, Bundle extras) {} onStatusChanged(int moveId, int status, long estMillis)9730 public abstract void onStatusChanged(int moveId, int status, long estMillis); 9731 } 9732 9733 /** {@hide} */ 9734 @SuppressWarnings("HiddenAbstractMethod") 9735 @UnsupportedAppUsage getMoveStatus(int moveId)9736 public abstract int getMoveStatus(int moveId); 9737 9738 /** {@hide} */ 9739 @SuppressWarnings("HiddenAbstractMethod") 9740 @UnsupportedAppUsage registerMoveCallback(@onNull MoveCallback callback, @NonNull Handler handler)9741 public abstract void registerMoveCallback(@NonNull MoveCallback callback, 9742 @NonNull Handler handler); 9743 /** {@hide} */ 9744 @SuppressWarnings("HiddenAbstractMethod") 9745 @UnsupportedAppUsage unregisterMoveCallback(@onNull MoveCallback callback)9746 public abstract void unregisterMoveCallback(@NonNull MoveCallback callback); 9747 9748 /** {@hide} */ 9749 @SuppressWarnings("HiddenAbstractMethod") 9750 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) movePackage(@onNull String packageName, @NonNull VolumeInfo vol)9751 public abstract int movePackage(@NonNull String packageName, @NonNull VolumeInfo vol); 9752 /** {@hide} */ 9753 @SuppressWarnings("HiddenAbstractMethod") 9754 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getPackageCurrentVolume(@onNull ApplicationInfo app)9755 public abstract @Nullable VolumeInfo getPackageCurrentVolume(@NonNull ApplicationInfo app); 9756 /** {@hide} */ 9757 @SuppressWarnings("HiddenAbstractMethod") 9758 @NonNull 9759 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getPackageCandidateVolumes( @onNull ApplicationInfo app)9760 public abstract List<VolumeInfo> getPackageCandidateVolumes( 9761 @NonNull ApplicationInfo app); 9762 9763 /** {@hide} */ 9764 @SuppressWarnings("HiddenAbstractMethod") movePrimaryStorage(@onNull VolumeInfo vol)9765 public abstract int movePrimaryStorage(@NonNull VolumeInfo vol); 9766 /** {@hide} */ 9767 @SuppressWarnings("HiddenAbstractMethod") getPrimaryStorageCurrentVolume()9768 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 9769 /** {@hide} */ 9770 @SuppressWarnings("HiddenAbstractMethod") getPrimaryStorageCandidateVolumes()9771 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 9772 9773 /** 9774 * Returns the device identity that verifiers can use to associate their scheme to a particular 9775 * device. This should not be used by anything other than a package verifier. 9776 * 9777 * @return identity that uniquely identifies current device 9778 * @hide 9779 */ 9780 @SuppressWarnings("HiddenAbstractMethod") 9781 @NonNull getVerifierDeviceIdentity()9782 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 9783 9784 /** 9785 * Returns true if the device is upgrading, such as first boot after OTA. 9786 * 9787 * @hide 9788 */ 9789 @SuppressWarnings("HiddenAbstractMethod") 9790 @UnsupportedAppUsage isUpgrade()9791 public abstract boolean isUpgrade(); 9792 9793 /** 9794 * Returns true if the device is upgrading, such as first boot after OTA. 9795 */ isDeviceUpgrading()9796 public boolean isDeviceUpgrading() { 9797 return false; 9798 } 9799 9800 /** 9801 * Return interface that offers the ability to install, upgrade, and remove 9802 * applications on the device. 9803 */ getPackageInstaller()9804 public abstract @NonNull PackageInstaller getPackageInstaller(); 9805 9806 /** 9807 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 9808 * intents sent from the user with id sourceUserId can also be be resolved 9809 * by activities in the user with id targetUserId if they match the 9810 * specified intent filter. 9811 * 9812 * @param filter The {@link IntentFilter} the intent has to match 9813 * @param sourceUserId The source user id. 9814 * @param targetUserId The target user id. 9815 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 9816 * {@link #ONLY_IF_NO_MATCH_FOUND}. 9817 * @hide 9818 */ 9819 @SuppressWarnings("HiddenAbstractMethod") 9820 @UnsupportedAppUsage 9821 @TestApi addCrossProfileIntentFilter(@onNull IntentFilter filter, @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags)9822 public abstract void addCrossProfileIntentFilter(@NonNull IntentFilter filter, 9823 @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags); 9824 9825 /** 9826 * Removes all {@code CrossProfileIntentFilter}s which matches the specified intent filer, 9827 * source, target and flag. 9828 * 9829 * @param filter The {@link IntentFilter} the intent has to match 9830 * @param sourceUserId The source user id. 9831 * @param targetUserId The target user id. 9832 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 9833 * {@link #ONLY_IF_NO_MATCH_FOUND}. 9834 * @hide 9835 */ removeCrossProfileIntentFilter(@onNull IntentFilter filter, @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags)9836 public boolean removeCrossProfileIntentFilter(@NonNull IntentFilter filter, 9837 @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags) { 9838 throw new UnsupportedOperationException( 9839 "removeCrossProfileIntentFilter not implemented in subclass"); 9840 } 9841 9842 /** 9843 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 9844 * as their source, and have been set by the app calling this method. 9845 * 9846 * @param sourceUserId The source user id. 9847 * @hide 9848 */ 9849 @SuppressWarnings("HiddenAbstractMethod") 9850 @UnsupportedAppUsage 9851 @TestApi clearCrossProfileIntentFilters(@serIdInt int sourceUserId)9852 public abstract void clearCrossProfileIntentFilters(@UserIdInt int sourceUserId); 9853 9854 /** 9855 * @hide 9856 */ 9857 @SuppressWarnings("HiddenAbstractMethod") 9858 @NonNull 9859 @UnsupportedAppUsage loadItemIcon(@onNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo)9860 public abstract Drawable loadItemIcon(@NonNull PackageItemInfo itemInfo, 9861 @Nullable ApplicationInfo appInfo); 9862 9863 /** 9864 * @hide 9865 */ 9866 @SuppressWarnings("HiddenAbstractMethod") 9867 @NonNull 9868 @UnsupportedAppUsage loadUnbadgedItemIcon(@onNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo)9869 public abstract Drawable loadUnbadgedItemIcon(@NonNull PackageItemInfo itemInfo, 9870 @Nullable ApplicationInfo appInfo); 9871 9872 /** {@hide} */ 9873 @SuppressWarnings("HiddenAbstractMethod") 9874 @UnsupportedAppUsage isPackageAvailable(@onNull String packageName)9875 public abstract boolean isPackageAvailable(@NonNull String packageName); 9876 9877 /** {@hide} */ 9878 @NonNull 9879 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) installStatusToString(int status, @Nullable String msg)9880 public static String installStatusToString(int status, @Nullable String msg) { 9881 final String str = installStatusToString(status); 9882 if (msg != null) { 9883 return str + ": " + msg; 9884 } else { 9885 return str; 9886 } 9887 } 9888 9889 /** {@hide} */ 9890 @NonNull 9891 @UnsupportedAppUsage installStatusToString(int status)9892 public static String installStatusToString(int status) { 9893 switch (status) { 9894 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 9895 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 9896 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 9897 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 9898 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 9899 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 9900 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 9901 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 9902 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 9903 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 9904 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 9905 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 9906 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 9907 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 9908 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 9909 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 9910 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 9911 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 9912 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 9913 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 9914 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 9915 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 9916 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 9917 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 9918 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 9919 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 9920 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 9921 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 9922 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 9923 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 9924 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 9925 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 9926 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 9927 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 9928 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 9929 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 9930 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 9931 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 9932 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 9933 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 9934 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 9935 case INSTALL_FAILED_BAD_DEX_METADATA: return "INSTALL_FAILED_BAD_DEX_METADATA"; 9936 case INSTALL_FAILED_MISSING_SPLIT: return "INSTALL_FAILED_MISSING_SPLIT"; 9937 case INSTALL_FAILED_DEPRECATED_SDK_VERSION: return "INSTALL_FAILED_DEPRECATED_SDK_VERSION"; 9938 case INSTALL_FAILED_BAD_SIGNATURE: return "INSTALL_FAILED_BAD_SIGNATURE"; 9939 case INSTALL_FAILED_WRONG_INSTALLED_VERSION: return "INSTALL_FAILED_WRONG_INSTALLED_VERSION"; 9940 case INSTALL_FAILED_PROCESS_NOT_DEFINED: return "INSTALL_FAILED_PROCESS_NOT_DEFINED"; 9941 case INSTALL_FAILED_SESSION_INVALID: return "INSTALL_FAILED_SESSION_INVALID"; 9942 case INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST: 9943 return "INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST"; 9944 default: return Integer.toString(status); 9945 } 9946 } 9947 9948 /** {@hide} */ installStatusToPublicStatus(int status)9949 public static int installStatusToPublicStatus(int status) { 9950 switch (status) { 9951 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 9952 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 9953 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 9954 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 9955 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 9956 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 9957 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 9958 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 9959 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 9960 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9961 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 9962 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 9963 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9964 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 9965 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9966 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 9967 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9968 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9969 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 9970 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 9971 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 9972 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 9973 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 9974 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 9975 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 9976 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 9977 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 9978 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 9979 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 9980 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 9981 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 9982 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 9983 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 9984 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 9985 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 9986 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 9987 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 9988 case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID; 9989 case INSTALL_FAILED_BAD_SIGNATURE: return PackageInstaller.STATUS_FAILURE_INVALID; 9990 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 9991 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9992 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 9993 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9994 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 9995 case INSTALL_FAILED_MISSING_SPLIT: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9996 case INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE: return PackageInstaller.STATUS_FAILURE_BLOCKED; 9997 case INSTALL_FAILED_DEPRECATED_SDK_VERSION: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 9998 default: return PackageInstaller.STATUS_FAILURE; 9999 } 10000 } 10001 10002 /** {@hide} */ 10003 @NonNull deleteStatusToString(int status, @Nullable String msg)10004 public static String deleteStatusToString(int status, @Nullable String msg) { 10005 final String str = deleteStatusToString(status); 10006 if (msg != null) { 10007 return str + ": " + msg; 10008 } else { 10009 return str; 10010 } 10011 } 10012 10013 /** {@hide} */ 10014 @NonNull 10015 @UnsupportedAppUsage deleteStatusToString(int status)10016 public static String deleteStatusToString(int status) { 10017 switch (status) { 10018 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 10019 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 10020 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 10021 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 10022 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 10023 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 10024 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY"; 10025 case DELETE_FAILED_APP_PINNED: return "DELETE_FAILED_APP_PINNED"; 10026 default: return Integer.toString(status); 10027 } 10028 } 10029 10030 /** {@hide} */ deleteStatusToPublicStatus(int status)10031 public static int deleteStatusToPublicStatus(int status) { 10032 switch (status) { 10033 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 10034 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 10035 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10036 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10037 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10038 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 10039 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10040 case DELETE_FAILED_APP_PINNED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10041 default: return PackageInstaller.STATUS_FAILURE; 10042 } 10043 } 10044 10045 /** {@hide} */ 10046 @NonNull permissionFlagToString(int flag)10047 public static String permissionFlagToString(int flag) { 10048 switch (flag) { 10049 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 10050 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 10051 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 10052 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 10053 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 10054 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 10055 case FLAG_PERMISSION_REVOKE_WHEN_REQUESTED: return "REVOKE_WHEN_REQUESTED"; 10056 case FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED: return "USER_SENSITIVE_WHEN_GRANTED"; 10057 case FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED: return "USER_SENSITIVE_WHEN_DENIED"; 10058 case FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT: return "RESTRICTION_INSTALLER_EXEMPT"; 10059 case FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT: return "RESTRICTION_SYSTEM_EXEMPT"; 10060 case FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT: return "RESTRICTION_UPGRADE_EXEMPT"; 10061 case FLAG_PERMISSION_APPLY_RESTRICTION: return "APPLY_RESTRICTION"; 10062 case FLAG_PERMISSION_GRANTED_BY_ROLE: return "GRANTED_BY_ROLE"; 10063 case FLAG_PERMISSION_REVOKED_COMPAT: return "REVOKED_COMPAT"; 10064 case FLAG_PERMISSION_ONE_TIME: return "ONE_TIME"; 10065 case FLAG_PERMISSION_AUTO_REVOKED: return "AUTO_REVOKED"; 10066 default: return Integer.toString(flag); 10067 } 10068 } 10069 10070 /** {@hide} */ 10071 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 10072 private final IPackageDeleteObserver mLegacy; 10073 LegacyPackageDeleteObserver(IPackageDeleteObserver legacy)10074 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 10075 mLegacy = legacy; 10076 } 10077 10078 @Override onPackageDeleted(String basePackageName, int returnCode, String msg)10079 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 10080 if (mLegacy == null) return; 10081 try { 10082 mLegacy.packageDeleted(basePackageName, returnCode); 10083 } catch (RemoteException ignored) { 10084 } 10085 } 10086 } 10087 10088 /** 10089 * A parcelable class to pass as an intent extra to the PackageInstaller. When an uninstall is 10090 * completed (both successfully or unsuccessfully), the result is sent to the uninstall 10091 * initiators. 10092 * 10093 * @hide 10094 */ 10095 @SystemApi 10096 public static final class UninstallCompleteCallback implements Parcelable { 10097 private IPackageDeleteObserver2 mBinder; 10098 10099 /** @hide */ 10100 @IntDef(prefix = { "DELETE_" }, value = { 10101 DELETE_SUCCEEDED, 10102 DELETE_FAILED_INTERNAL_ERROR, 10103 DELETE_FAILED_DEVICE_POLICY_MANAGER, 10104 DELETE_FAILED_USER_RESTRICTED, 10105 DELETE_FAILED_OWNER_BLOCKED, 10106 DELETE_FAILED_ABORTED, 10107 DELETE_FAILED_USED_SHARED_LIBRARY, 10108 DELETE_FAILED_APP_PINNED, 10109 }) 10110 @Retention(RetentionPolicy.SOURCE) 10111 public @interface DeleteStatus{} 10112 10113 /** @hide */ UninstallCompleteCallback(@onNull IBinder binder)10114 public UninstallCompleteCallback(@NonNull IBinder binder) { 10115 mBinder = IPackageDeleteObserver2.Stub.asInterface(binder); 10116 } 10117 10118 /** @hide */ UninstallCompleteCallback(Parcel in)10119 private UninstallCompleteCallback(Parcel in) { 10120 mBinder = IPackageDeleteObserver2.Stub.asInterface(in.readStrongBinder()); 10121 } 10122 10123 public static final @NonNull Parcelable.Creator<UninstallCompleteCallback> CREATOR = 10124 new Parcelable.Creator<>() { 10125 public UninstallCompleteCallback createFromParcel(Parcel source) { 10126 return new UninstallCompleteCallback(source); 10127 } 10128 10129 public UninstallCompleteCallback[] newArray(int size) { 10130 return new UninstallCompleteCallback[size]; 10131 } 10132 }; 10133 10134 /** 10135 * Called when an uninstallation is completed successfully or unsuccessfully. 10136 * 10137 * @param packageName The name of the package being uninstalled. 10138 * @param resultCode Result code of the operation. 10139 * @param errorMessage Error message if any. 10140 * 10141 * @hide */ 10142 @SystemApi onUninstallComplete(@onNull String packageName, @DeleteStatus int resultCode, @Nullable String errorMessage)10143 public void onUninstallComplete(@NonNull String packageName, @DeleteStatus int resultCode, 10144 @Nullable String errorMessage) { 10145 try { 10146 mBinder.onPackageDeleted(packageName, resultCode, errorMessage); 10147 } catch (RemoteException e) { 10148 // no-op 10149 } 10150 } 10151 10152 /** @hide */ 10153 @Override describeContents()10154 public int describeContents() { 10155 return 0; 10156 } 10157 10158 /** @hide */ 10159 @Override writeToParcel(@onNull Parcel dest, int flags)10160 public void writeToParcel(@NonNull Parcel dest, int flags) { 10161 dest.writeStrongBinder(mBinder.asBinder()); 10162 } 10163 } 10164 10165 /** 10166 * Return the install reason that was recorded when a package was first 10167 * installed for a specific user. Requesting the install reason for another 10168 * user will require the permission INTERACT_ACROSS_USERS_FULL. 10169 * 10170 * @param packageName The package for which to retrieve the install reason 10171 * @param user The user for whom to retrieve the install reason 10172 * @return The install reason. If the package is not installed for the given 10173 * user, {@code INSTALL_REASON_UNKNOWN} is returned. 10174 * @hide 10175 */ 10176 @SuppressWarnings("HiddenAbstractMethod") 10177 @TestApi 10178 @InstallReason getInstallReason(@onNull String packageName, @NonNull UserHandle user)10179 public abstract int getInstallReason(@NonNull String packageName, @NonNull UserHandle user); 10180 10181 /** 10182 * Checks whether the calling package is allowed to request package installs through package 10183 * installer. Apps are encouraged to call this API before launching the package installer via 10184 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the 10185 * user can explicitly choose what external sources they trust to install apps on the device. 10186 * If this API returns false, the install request will be blocked by the package installer and 10187 * a dialog will be shown to the user with an option to launch settings to change their 10188 * preference. An application must target Android O or higher and declare permission 10189 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API. 10190 * 10191 * @return true if the calling package is trusted by the user to request install packages on 10192 * the device, false otherwise. 10193 * @see android.content.Intent#ACTION_INSTALL_PACKAGE 10194 * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES 10195 */ canRequestPackageInstalls()10196 public abstract boolean canRequestPackageInstalls(); 10197 10198 /** 10199 * Return the {@link ComponentName} of the activity providing Settings for the Instant App 10200 * resolver. 10201 * 10202 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS} 10203 * @hide 10204 */ 10205 @SuppressWarnings("HiddenAbstractMethod") 10206 @Nullable 10207 @SystemApi getInstantAppResolverSettingsComponent()10208 public abstract ComponentName getInstantAppResolverSettingsComponent(); 10209 10210 /** 10211 * Return the {@link ComponentName} of the activity responsible for installing instant 10212 * applications. 10213 * 10214 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE} 10215 * @hide 10216 */ 10217 @SuppressWarnings("HiddenAbstractMethod") 10218 @Nullable 10219 @SystemApi getInstantAppInstallerComponent()10220 public abstract ComponentName getInstantAppInstallerComponent(); 10221 10222 /** 10223 * Return the Android Id for a given Instant App. 10224 * 10225 * @see {@link android.provider.Settings.Secure#ANDROID_ID} 10226 * @hide 10227 */ 10228 @SuppressWarnings("HiddenAbstractMethod") 10229 @Nullable getInstantAppAndroidId(@onNull String packageName, @NonNull UserHandle user)10230 public abstract String getInstantAppAndroidId(@NonNull String packageName, 10231 @NonNull UserHandle user); 10232 10233 /** 10234 * Callback use to notify the callers of module registration that the operation 10235 * has finished. 10236 * 10237 * @hide 10238 */ 10239 @SystemApi 10240 public static abstract class DexModuleRegisterCallback { onDexModuleRegistered(String dexModulePath, boolean success, String message)10241 public abstract void onDexModuleRegistered(String dexModulePath, boolean success, 10242 String message); 10243 } 10244 10245 /** 10246 * Register an application dex module with the package manager. 10247 * 10248 * This call no longer does anything. If a callback is given it is called with a false success 10249 * value. 10250 * 10251 * @param dexModulePath the absolute path of the dex module. 10252 * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will 10253 * be called once the registration finishes. 10254 * 10255 * @hide 10256 */ 10257 @SuppressWarnings("HiddenAbstractMethod") 10258 @SystemApi registerDexModule(@onNull String dexModulePath, @Nullable DexModuleRegisterCallback callback)10259 public abstract void registerDexModule(@NonNull String dexModulePath, 10260 @Nullable DexModuleRegisterCallback callback); 10261 10262 /** 10263 * Returns the {@link ArtManager} associated with this package manager. 10264 * 10265 * @hide 10266 */ 10267 @SystemApi getArtManager()10268 public @NonNull ArtManager getArtManager() { 10269 throw new UnsupportedOperationException("getArtManager not implemented in subclass"); 10270 } 10271 10272 /** 10273 * Sets or clears the harmful app warning details for the given app. 10274 * 10275 * When set, any attempt to launch an activity in this package will be intercepted and a 10276 * warning dialog will be shown to the user instead, with the given warning. The user 10277 * will have the option to proceed with the activity launch, or to uninstall the application. 10278 * 10279 * @param packageName The full name of the package to warn on. 10280 * @param warning A warning string to display to the user describing the threat posed by the 10281 * application, or null to clear the warning. 10282 * 10283 * @hide 10284 */ 10285 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 10286 @SystemApi setHarmfulAppWarning(@onNull String packageName, @Nullable CharSequence warning)10287 public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) { 10288 throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass"); 10289 } 10290 10291 /** 10292 * Returns the harmful app warning string for the given app, or null if there is none set. 10293 * 10294 * @param packageName The full name of the desired package. 10295 * 10296 * @hide 10297 */ 10298 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 10299 @Nullable 10300 @SystemApi getHarmfulAppWarning(@onNull String packageName)10301 public CharSequence getHarmfulAppWarning(@NonNull String packageName) { 10302 throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass"); 10303 } 10304 10305 /** @hide */ 10306 @IntDef(prefix = { "CERT_INPUT_" }, value = { 10307 CERT_INPUT_RAW_X509, 10308 CERT_INPUT_SHA256 10309 }) 10310 @Retention(RetentionPolicy.SOURCE) 10311 public @interface CertificateInputType {} 10312 10313 /** 10314 * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could 10315 * be generated using an {@code CertificateFactory} 10316 */ 10317 public static final int CERT_INPUT_RAW_X509 = 0; 10318 10319 /** 10320 * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509 10321 * Certificate. 10322 */ 10323 public static final int CERT_INPUT_SHA256 = 1; 10324 10325 /** 10326 * Searches the set of signing certificates by which the given package has proven to have been 10327 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 10328 * since it takes into account the possibility of signing certificate rotation, except in the 10329 * case of packages that are signed by multiple certificates, for which signing certificate 10330 * rotation is not supported. This method is analogous to using {@code getPackageInfo} with 10331 * {@code GET_SIGNING_CERTIFICATES} and then searching through the resulting {@code 10332 * signingInfo} field to see if the desired certificate is present. 10333 * 10334 * @param packageName package whose signing certificates to check 10335 * @param certificate signing certificate for which to search 10336 * @param type representation of the {@code certificate} 10337 * @return true if this package was or is signed by exactly the certificate {@code certificate} 10338 */ hasSigningCertificate(@onNull String packageName, @NonNull byte[] certificate, @CertificateInputType int type)10339 public boolean hasSigningCertificate(@NonNull String packageName, @NonNull byte[] certificate, 10340 @CertificateInputType int type) { 10341 throw new UnsupportedOperationException( 10342 "hasSigningCertificate not implemented in subclass"); 10343 } 10344 10345 /** 10346 * Searches the set of signing certificates by which the package(s) for the given uid has proven 10347 * to have been signed. For multiple packages sharing the same uid, this will return the 10348 * signing certificates found in the signing history of the "newest" package, where "newest" 10349 * indicates the package with the newest signing certificate in the shared uid group. This 10350 * method should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 10351 * since it takes into account the possibility of signing certificate rotation, except in the 10352 * case of packages that are signed by multiple certificates, for which signing certificate 10353 * rotation is not supported. This method is analogous to using {@code getPackagesForUid} 10354 * followed by {@code getPackageInfo} with {@code GET_SIGNING_CERTIFICATES}, selecting the 10355 * {@code PackageInfo} of the newest-signed bpackage , and finally searching through the 10356 * resulting {@code signingInfo} field to see if the desired certificate is there. 10357 * 10358 * @param uid uid whose signing certificates to check 10359 * @param certificate signing certificate for which to search 10360 * @param type representation of the {@code certificate} 10361 * @return true if this package was or is signed by exactly the certificate {@code certificate} 10362 */ hasSigningCertificate( int uid, @NonNull byte[] certificate, @CertificateInputType int type)10363 public boolean hasSigningCertificate( 10364 int uid, @NonNull byte[] certificate, @CertificateInputType int type) { 10365 throw new UnsupportedOperationException( 10366 "hasSigningCertificate not implemented in subclass"); 10367 } 10368 10369 /** 10370 * Trust any Installer to provide checksums for the package. 10371 * @see #requestChecksums 10372 */ 10373 public static final @NonNull List<Certificate> TRUST_ALL = Collections.singletonList(null); 10374 10375 /** 10376 * Don't trust any Installer to provide checksums for the package. 10377 * This effectively disables optimized Installer-enforced checksums. 10378 * @see #requestChecksums 10379 */ 10380 public static final @NonNull List<Certificate> TRUST_NONE = Collections.singletonList(null); 10381 10382 /** Listener that gets notified when checksums are available. */ 10383 @FunctionalInterface 10384 public interface OnChecksumsReadyListener { 10385 /** 10386 * Called when the checksums are available. 10387 * 10388 * @param checksums array of checksums. 10389 */ onChecksumsReady(@onNull List<ApkChecksum> checksums)10390 void onChecksumsReady(@NonNull List<ApkChecksum> checksums); 10391 } 10392 10393 /** 10394 * Requests the checksums for APKs within a package. 10395 * The checksums will be returned asynchronously via onChecksumsReadyListener. 10396 * 10397 * By default returns all readily available checksums: 10398 * - enforced by platform, 10399 * - enforced by installer. 10400 * If caller needs a specific checksum kind, they can specify it as required. 10401 * 10402 * <b>Caution: Android can not verify installer-provided checksums. Make sure you specify 10403 * trusted installers.</b> 10404 * 10405 * @param packageName whose checksums to return. 10406 * @param includeSplits whether to include checksums for non-base splits. 10407 * @param required explicitly request the checksum types. May incur significant 10408 * CPU/memory/disk usage. 10409 * @param trustedInstallers for checksums enforced by installer, which installers are to be 10410 * trusted. 10411 * {@link #TRUST_ALL} will return checksums from any installer, 10412 * {@link #TRUST_NONE} disables optimized installer-enforced checksums, 10413 * otherwise the list has to be non-empty list of certificates. 10414 * @param onChecksumsReadyListener called once when the results are available. 10415 * @throws CertificateEncodingException if an encoding error occurs for trustedInstallers. 10416 * @throws IllegalArgumentException if the list of trusted installer certificates is empty. 10417 * @throws NameNotFoundException if a package with the given name cannot be found on the system. 10418 */ requestChecksums(@onNull String packageName, boolean includeSplits, @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers, @NonNull OnChecksumsReadyListener onChecksumsReadyListener)10419 public void requestChecksums(@NonNull String packageName, boolean includeSplits, 10420 @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers, 10421 @NonNull OnChecksumsReadyListener onChecksumsReadyListener) 10422 throws CertificateEncodingException, NameNotFoundException { 10423 throw new UnsupportedOperationException("requestChecksums not implemented in subclass"); 10424 } 10425 10426 /** 10427 * @return the default text classifier package name, or null if there's none. 10428 * 10429 * @hide 10430 */ 10431 @Nullable 10432 @TestApi getDefaultTextClassifierPackageName()10433 public String getDefaultTextClassifierPackageName() { 10434 throw new UnsupportedOperationException( 10435 "getDefaultTextClassifierPackageName not implemented in subclass"); 10436 } 10437 10438 /** 10439 * @return the system defined text classifier package names, or null if there's none. 10440 * 10441 * @hide 10442 */ 10443 @Nullable 10444 @TestApi getSystemTextClassifierPackageName()10445 public String getSystemTextClassifierPackageName() { 10446 throw new UnsupportedOperationException( 10447 "getSystemTextClassifierPackageName not implemented in subclass"); 10448 } 10449 10450 /** 10451 * @return attention service package name, or null if there's none. 10452 * 10453 * @hide 10454 */ getAttentionServicePackageName()10455 public String getAttentionServicePackageName() { 10456 throw new UnsupportedOperationException( 10457 "getAttentionServicePackageName not implemented in subclass"); 10458 } 10459 10460 /** 10461 * @return rotation resolver service's package name, or null if there's none. 10462 * 10463 * @hide 10464 */ getRotationResolverPackageName()10465 public String getRotationResolverPackageName() { 10466 throw new UnsupportedOperationException( 10467 "getRotationResolverPackageName not implemented in subclass"); 10468 } 10469 10470 /** 10471 * @return the wellbeing app package name, or null if it's not defined by the OEM. 10472 * 10473 * @hide 10474 */ 10475 @Nullable 10476 @TestApi getWellbeingPackageName()10477 public String getWellbeingPackageName() { 10478 throw new UnsupportedOperationException( 10479 "getWellbeingPackageName not implemented in subclass"); 10480 } 10481 10482 /** 10483 * @return the system defined app predictor package name, or null if there's none. 10484 * 10485 * @hide 10486 */ 10487 @Nullable getAppPredictionServicePackageName()10488 public String getAppPredictionServicePackageName() { 10489 throw new UnsupportedOperationException( 10490 "getAppPredictionServicePackageName not implemented in subclass"); 10491 } 10492 10493 /** 10494 * @return the system defined content capture service package name, or null if there's none. 10495 * 10496 * @hide 10497 */ 10498 @Nullable getSystemCaptionsServicePackageName()10499 public String getSystemCaptionsServicePackageName() { 10500 throw new UnsupportedOperationException( 10501 "getSystemCaptionsServicePackageName not implemented in subclass"); 10502 } 10503 10504 /** 10505 * @return the system defined setup wizard package name, or null if there's none. 10506 * 10507 * @hide 10508 */ 10509 @Nullable getSetupWizardPackageName()10510 public String getSetupWizardPackageName() { 10511 throw new UnsupportedOperationException( 10512 "getSetupWizardPackageName not implemented in subclass"); 10513 } 10514 10515 /** 10516 * @deprecated This function throws an {@link UnsupportedOperationException}. For pre-granting 10517 * permissions, instead of looking up the package that provides {@code ContentCaptureService}, 10518 * use roles. 10519 * 10520 * @hide 10521 */ 10522 // This function cannot yet be removed because it is referenced from GTS tests. The tests have 10523 // been updated to not rely on it when running on Android T and above, but in order to compile 10524 // the tests we must keep this method. 10525 @Deprecated 10526 @TestApi 10527 @Nullable getContentCaptureServicePackageName()10528 public final String getContentCaptureServicePackageName() { 10529 throw new UnsupportedOperationException( 10530 "getContentCaptureServicePackageName is deprecated"); 10531 } 10532 10533 /** 10534 * @return the incident report approver app package name, or null if it's not defined 10535 * by the OEM. 10536 * 10537 * @hide 10538 */ 10539 @SystemApi 10540 @Nullable getIncidentReportApproverPackageName()10541 public String getIncidentReportApproverPackageName() { 10542 throw new UnsupportedOperationException( 10543 "getIncidentReportApproverPackageName not implemented in subclass"); 10544 } 10545 10546 /** 10547 * @return whether a given package's state is protected, e.g. package cannot be disabled, 10548 * suspended, hidden or force stopped. 10549 * 10550 * @hide 10551 */ isPackageStateProtected(@onNull String packageName, @UserIdInt int userId)10552 public boolean isPackageStateProtected(@NonNull String packageName, @UserIdInt int userId) { 10553 throw new UnsupportedOperationException( 10554 "isPackageStateProtected not implemented in subclass"); 10555 } 10556 10557 /** 10558 * Notify to the rest of the system that a new device configuration has 10559 * been prepared and that it is time to refresh caches. 10560 * 10561 * @see android.content.Intent#ACTION_DEVICE_CUSTOMIZATION_READY 10562 * 10563 * @hide 10564 */ 10565 @SystemApi sendDeviceCustomizationReadyBroadcast()10566 public void sendDeviceCustomizationReadyBroadcast() { 10567 throw new UnsupportedOperationException( 10568 "sendDeviceCustomizationReadyBroadcast not implemented in subclass"); 10569 } 10570 10571 /** 10572 * <p> 10573 * <strong>Note: </strong>In retrospect it would have been preferred to use 10574 * more inclusive terminology when naming this API. Similar APIs added will 10575 * refrain from using the term "whitelist". 10576 * </p> 10577 * 10578 * @return whether this package is whitelisted from having its runtime permission be 10579 * auto-revoked if unused for an extended period of time. 10580 */ isAutoRevokeWhitelisted()10581 public boolean isAutoRevokeWhitelisted() { 10582 throw new UnsupportedOperationException( 10583 "isAutoRevokeWhitelisted not implemented in subclass"); 10584 } 10585 10586 /** 10587 * Returns if the provided drawable represents the default activity icon provided by the system. 10588 * 10589 * PackageManager silently returns a default application icon for any package/activity if the 10590 * app itself does not define one or if the system encountered any error when loading the icon. 10591 * 10592 * Developers can use this to check implement app specific logic around retrying or caching. 10593 * 10594 * @return true if the drawable represents the default activity icon, false otherwise 10595 * @see #getDefaultActivityIcon() 10596 * @see #getActivityIcon 10597 * @see LauncherActivityInfo#getIcon(int) 10598 */ isDefaultApplicationIcon(@onNull Drawable drawable)10599 public boolean isDefaultApplicationIcon(@NonNull Drawable drawable) { 10600 int resId = drawable instanceof AdaptiveIconDrawable 10601 ? ((AdaptiveIconDrawable) drawable).getSourceDrawableResId() : Resources.ID_NULL; 10602 return resId == com.android.internal.R.drawable.sym_def_app_icon 10603 || resId == com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon; 10604 } 10605 10606 /** 10607 * Sets MIME group's MIME types. 10608 * 10609 * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific 10610 * group name to avoid namespace collisions, e.g. "com.example:myFeature". 10611 * 10612 * @param mimeGroup MIME group to modify. 10613 * @param mimeTypes new MIME types contained by MIME group. 10614 * @throws IllegalArgumentException if the MIME group was not declared in the manifest. 10615 */ setMimeGroup(@onNull String mimeGroup, @NonNull Set<String> mimeTypes)10616 public void setMimeGroup(@NonNull String mimeGroup, @NonNull Set<String> mimeTypes) { 10617 throw new UnsupportedOperationException( 10618 "setMimeGroup not implemented in subclass"); 10619 } 10620 10621 /** 10622 * Gets all MIME types contained by MIME group. 10623 * 10624 * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific 10625 * group name to avoid namespace collisions, e.g. "com.example:myFeature". 10626 * 10627 * @param mimeGroup MIME group to retrieve. 10628 * @return MIME types contained by the MIME group. 10629 * @throws IllegalArgumentException if the MIME group was not declared in the manifest. 10630 */ 10631 @NonNull getMimeGroup(@onNull String mimeGroup)10632 public Set<String> getMimeGroup(@NonNull String mimeGroup) { 10633 throw new UnsupportedOperationException( 10634 "getMimeGroup not implemented in subclass"); 10635 } 10636 10637 /** 10638 * Returns the property defined in the given package's <appliction> tag. 10639 * 10640 * @throws NameNotFoundException if either the given package is not installed or if the 10641 * given property is not defined within the <application> tag. 10642 */ 10643 @NonNull getProperty(@onNull String propertyName, @NonNull String packageName)10644 public Property getProperty(@NonNull String propertyName, @NonNull String packageName) 10645 throws NameNotFoundException { 10646 throw new UnsupportedOperationException( 10647 "getProperty not implemented in subclass"); 10648 } 10649 10650 /** 10651 * Returns the property defined in the given component declaration. 10652 * 10653 * @throws NameNotFoundException if either the given component does not exist or if the 10654 * given property is not defined within the component declaration. 10655 */ 10656 @NonNull getProperty(@onNull String propertyName, @NonNull ComponentName component)10657 public Property getProperty(@NonNull String propertyName, @NonNull ComponentName component) 10658 throws NameNotFoundException { 10659 throw new UnsupportedOperationException( 10660 "getProperty not implemented in subclass"); 10661 } 10662 10663 /** 10664 * If the provided className is {@code null}, returns the property defined on the application. 10665 * Otherwise, returns the property defined on the component. 10666 * 10667 * @throws NameNotFoundException if the given package is not installed on the calling user or 10668 * component does not exist or if the given property is not defined within the manifest. 10669 * @hide 10670 */ 10671 @NonNull getPropertyAsUser(@onNull String propertyName, @NonNull String packageName, @Nullable String className, int userId)10672 public Property getPropertyAsUser(@NonNull String propertyName, @NonNull String packageName, 10673 @Nullable String className, int userId) throws NameNotFoundException { 10674 throw new UnsupportedOperationException( 10675 "getPropertyAsUser not implemented in subclass"); 10676 } 10677 10678 /** 10679 * Returns the property definition for all <application> tags. 10680 * <p>If the property is not defined with any <application> tag, 10681 * returns and empty list. 10682 */ 10683 @NonNull queryApplicationProperty(@onNull String propertyName)10684 public List<Property> queryApplicationProperty(@NonNull String propertyName) { 10685 throw new UnsupportedOperationException( 10686 "qeuryApplicationProperty not implemented in subclass"); 10687 } 10688 10689 /** 10690 * Returns the property definition for all <activity> and <activity-alias> tags. 10691 * <p>If the property is not defined with any <activity> and <activity-alias> tag, 10692 * returns and empty list. 10693 */ 10694 @NonNull queryActivityProperty(@onNull String propertyName)10695 public List<Property> queryActivityProperty(@NonNull String propertyName) { 10696 throw new UnsupportedOperationException( 10697 "qeuryActivityProperty not implemented in subclass"); 10698 } 10699 10700 /** 10701 * Returns the property definition for all <provider> tags. 10702 * <p>If the property is not defined with any <provider> tag, 10703 * returns and empty list. 10704 */ 10705 @NonNull queryProviderProperty(@onNull String propertyName)10706 public List<Property> queryProviderProperty(@NonNull String propertyName) { 10707 throw new UnsupportedOperationException( 10708 "qeuryProviderProperty not implemented in subclass"); 10709 } 10710 10711 /** 10712 * Returns the property definition for all <receiver> tags. 10713 * <p>If the property is not defined with any <receiver> tag, 10714 * returns and empty list. 10715 */ 10716 @NonNull queryReceiverProperty(@onNull String propertyName)10717 public List<Property> queryReceiverProperty(@NonNull String propertyName) { 10718 throw new UnsupportedOperationException( 10719 "qeuryReceiverProperty not implemented in subclass"); 10720 } 10721 10722 /** 10723 * Returns the property definition for all <service> tags. 10724 * <p>If the property is not defined with any <service> tag, 10725 * returns and empty list. 10726 */ 10727 @NonNull queryServiceProperty(@onNull String propertyName)10728 public List<Property> queryServiceProperty(@NonNull String propertyName) { 10729 throw new UnsupportedOperationException( 10730 "qeuryServiceProperty not implemented in subclass"); 10731 } 10732 10733 /** 10734 * Returns {@code true} if the source package is able to query for details about the 10735 * target package. Applications that share details about other applications should 10736 * use this API to determine if those details should be withheld from callers that 10737 * do not otherwise have visibility of them. 10738 * <p> 10739 * Note: The caller must be able to query for details about the source and target 10740 * package. A {@link NameNotFoundException} is thrown if it isn't. 10741 * 10742 * @param sourcePackageName The source package that would receive details about the 10743 * target package. 10744 * @param targetPackageName The target package whose details would be shared with the 10745 * source package. 10746 * @return {@code true} if the source package is able to query for details about the 10747 * target package. 10748 * @throws NameNotFoundException if either a given package can not be found on the 10749 * system, or if the caller is not able to query for details about the source or 10750 * target package. 10751 */ canPackageQuery(@onNull String sourcePackageName, @NonNull String targetPackageName)10752 public boolean canPackageQuery(@NonNull String sourcePackageName, 10753 @NonNull String targetPackageName) throws NameNotFoundException { 10754 throw new UnsupportedOperationException( 10755 "canPackageQuery not implemented in subclass"); 10756 } 10757 10758 /** 10759 * Same as {@link #canPackageQuery(String, String)} but accepts an array of target packages to 10760 * be queried. 10761 * 10762 * @param sourcePackageName The source package that would receive details about the 10763 * target package. 10764 * @param targetPackageNames An array of target packages whose details would be shared with the 10765 * source package. 10766 * @return An array of booleans where each member specifies whether the source package is able 10767 * to query for details about the target package given by the corresponding value at the same 10768 * index in the array of target packages. 10769 * @throws NameNotFoundException if either a given package can not be found on the 10770 * system, or if the caller is not able to query for details about the source or 10771 * target packages. 10772 */ 10773 @NonNull canPackageQuery(@onNull String sourcePackageName, @NonNull String[] targetPackageNames)10774 public boolean[] canPackageQuery(@NonNull String sourcePackageName, 10775 @NonNull String[] targetPackageNames) throws NameNotFoundException { 10776 throw new UnsupportedOperationException( 10777 "canPackageQuery not implemented in subclass"); 10778 } 10779 10780 /** 10781 * Makes a package that provides an authority {@code visibleAuthority} become visible to the 10782 * application {@code recipientUid}. 10783 * 10784 * @throws SecurityException when called by a package other than the contacts provider 10785 * @hide 10786 */ makeProviderVisible(int recipientUid, String visibleAuthority)10787 public void makeProviderVisible(int recipientUid, String visibleAuthority) { 10788 try { 10789 ActivityThread.getPackageManager().makeProviderVisible(recipientUid, visibleAuthority); 10790 } catch (RemoteException e) { 10791 throw e.rethrowFromSystemServer(); 10792 } 10793 } 10794 10795 /** 10796 * Makes the package associated with the uid {@code visibleUid} become visible to the 10797 * recipient application. The recipient application can receive the details about the 10798 * visible package if successful. 10799 * <p> 10800 * Read <a href="/training/basics/intents/package-visibility">package visibility</a> for more 10801 * information. 10802 * 10803 * @param recipientUid The uid of the application that is being given access to {@code 10804 * visibleUid} 10805 * @param visibleUid The uid of the application that is becoming accessible to {@code 10806 * recipientAppId} 10807 * @hide 10808 */ 10809 @RequiresPermission(android.Manifest.permission.MAKE_UID_VISIBLE) 10810 @TestApi 10811 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) makeUidVisible(int recipientUid, int visibleUid)10812 public void makeUidVisible(int recipientUid, int visibleUid) { 10813 throw new UnsupportedOperationException( 10814 "makeUidVisible not implemented in subclass"); 10815 } 10816 10817 // Some of the flags don't affect the query result, but let's be conservative and cache 10818 // each combination of flags separately. 10819 10820 private static final class ApplicationInfoQuery { 10821 final String packageName; 10822 final long flags; 10823 final int userId; 10824 ApplicationInfoQuery(@ullable String packageName, @ApplicationInfoFlagsBits long flags, int userId)10825 ApplicationInfoQuery(@Nullable String packageName, @ApplicationInfoFlagsBits long flags, 10826 int userId) { 10827 this.packageName = packageName; 10828 this.flags = flags; 10829 this.userId = userId; 10830 } 10831 10832 @Override toString()10833 public String toString() { 10834 return String.format( 10835 "ApplicationInfoQuery(packageName=\"%s\", flags=%s, userId=%s)", 10836 packageName, flags, userId); 10837 } 10838 10839 @Override hashCode()10840 public int hashCode() { 10841 int hash = Objects.hashCode(packageName); 10842 hash = hash * 13 + Objects.hashCode(flags); 10843 hash = hash * 13 + Objects.hashCode(userId); 10844 return hash; 10845 } 10846 10847 @Override equals(@ullable Object rval)10848 public boolean equals(@Nullable Object rval) { 10849 if (rval == null) { 10850 return false; 10851 } 10852 ApplicationInfoQuery other; 10853 try { 10854 other = (ApplicationInfoQuery) rval; 10855 } catch (ClassCastException ex) { 10856 return false; 10857 } 10858 return Objects.equals(packageName, other.packageName) 10859 && flags == other.flags 10860 && userId == other.userId; 10861 } 10862 } 10863 getApplicationInfoAsUserUncached( String packageName, @ApplicationInfoFlagsBits long flags, int userId)10864 private static ApplicationInfo getApplicationInfoAsUserUncached( 10865 String packageName, @ApplicationInfoFlagsBits long flags, int userId) { 10866 try { 10867 return ActivityThread.getPackageManager() 10868 .getApplicationInfo(packageName, flags, userId); 10869 } catch (RemoteException e) { 10870 throw e.rethrowFromSystemServer(); 10871 } 10872 } 10873 10874 private static final PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo> 10875 sApplicationInfoCache = 10876 new PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo>( 10877 32, PermissionManager.CACHE_KEY_PACKAGE_INFO, 10878 "getApplicationInfo") { 10879 @Override 10880 public ApplicationInfo recompute(ApplicationInfoQuery query) { 10881 return getApplicationInfoAsUserUncached( 10882 query.packageName, query.flags, query.userId); 10883 } 10884 @Override 10885 public boolean resultEquals(ApplicationInfo cached, ApplicationInfo fetched) { 10886 // Implementing this debug check for ApplicationInfo would require a 10887 // complicated deep comparison, so just bypass it for now. 10888 return true; 10889 } 10890 }; 10891 10892 /** @hide */ getApplicationInfoAsUserCached( String packageName, @ApplicationInfoFlagsBits long flags, int userId)10893 public static ApplicationInfo getApplicationInfoAsUserCached( 10894 String packageName, @ApplicationInfoFlagsBits long flags, int userId) { 10895 return sApplicationInfoCache.query( 10896 new ApplicationInfoQuery(packageName, flags, userId)); 10897 } 10898 10899 /** 10900 * Make getApplicationInfoAsUser() bypass the cache in this process. 10901 * 10902 * @hide 10903 */ disableApplicationInfoCache()10904 public static void disableApplicationInfoCache() { 10905 sApplicationInfoCache.disableLocal(); 10906 } 10907 10908 private static final PropertyInvalidatedCache.AutoCorker sCacheAutoCorker = 10909 new PropertyInvalidatedCache.AutoCorker(PermissionManager.CACHE_KEY_PACKAGE_INFO); 10910 10911 /** 10912 * Invalidate caches of package and permission information system-wide. 10913 * 10914 * @hide 10915 */ invalidatePackageInfoCache()10916 public static void invalidatePackageInfoCache() { 10917 sCacheAutoCorker.autoCork(); 10918 } 10919 10920 // Some of the flags don't affect the query result, but let's be conservative and cache 10921 // each combination of flags separately. 10922 10923 private static final class PackageInfoQuery { 10924 final String packageName; 10925 final long flags; 10926 final int userId; 10927 PackageInfoQuery(@ullable String packageName, @PackageInfoFlagsBits long flags, int userId)10928 PackageInfoQuery(@Nullable String packageName, @PackageInfoFlagsBits long flags, int userId) { 10929 this.packageName = packageName; 10930 this.flags = flags; 10931 this.userId = userId; 10932 } 10933 10934 @Override toString()10935 public String toString() { 10936 return String.format( 10937 "PackageInfoQuery(packageName=\"%s\", flags=%s, userId=%s)", 10938 packageName, flags, userId); 10939 } 10940 10941 @Override hashCode()10942 public int hashCode() { 10943 int hash = Objects.hashCode(packageName); 10944 hash = hash * 13 + Objects.hashCode(flags); 10945 hash = hash * 13 + Objects.hashCode(userId); 10946 return hash; 10947 } 10948 10949 @Override equals(@ullable Object rval)10950 public boolean equals(@Nullable Object rval) { 10951 if (rval == null) { 10952 return false; 10953 } 10954 PackageInfoQuery other; 10955 try { 10956 other = (PackageInfoQuery) rval; 10957 } catch (ClassCastException ex) { 10958 return false; 10959 } 10960 return Objects.equals(packageName, other.packageName) 10961 && flags == other.flags 10962 && userId == other.userId; 10963 } 10964 } 10965 getPackageInfoAsUserUncached( String packageName, @PackageInfoFlagsBits long flags, int userId)10966 private static PackageInfo getPackageInfoAsUserUncached( 10967 String packageName, @PackageInfoFlagsBits long flags, int userId) { 10968 try { 10969 return ActivityThread.getPackageManager().getPackageInfo(packageName, flags, userId); 10970 } catch (RemoteException e) { 10971 throw e.rethrowFromSystemServer(); 10972 } 10973 } 10974 10975 private static final PropertyInvalidatedCache<PackageInfoQuery, PackageInfo> 10976 sPackageInfoCache = 10977 new PropertyInvalidatedCache<PackageInfoQuery, PackageInfo>( 10978 64, PermissionManager.CACHE_KEY_PACKAGE_INFO, 10979 "getPackageInfo") { 10980 @Override 10981 public PackageInfo recompute(PackageInfoQuery query) { 10982 return getPackageInfoAsUserUncached( 10983 query.packageName, query.flags, query.userId); 10984 } 10985 @Override 10986 public boolean resultEquals(PackageInfo cached, PackageInfo fetched) { 10987 // Implementing this debug check for PackageInfo would require a 10988 // complicated deep comparison, so just bypass it for now. 10989 return true; 10990 } 10991 }; 10992 10993 /** @hide */ getPackageInfoAsUserCached( String packageName, @PackageInfoFlagsBits long flags, int userId)10994 public static PackageInfo getPackageInfoAsUserCached( 10995 String packageName, @PackageInfoFlagsBits long flags, int userId) { 10996 return sPackageInfoCache.query(new PackageInfoQuery(packageName, flags, userId)); 10997 } 10998 10999 /** 11000 * Make getPackageInfoAsUser() bypass the cache in this process. 11001 * @hide 11002 */ disablePackageInfoCache()11003 public static void disablePackageInfoCache() { 11004 sPackageInfoCache.disableLocal(); 11005 } 11006 11007 /** 11008 * Inhibit package info cache invalidations when correct. 11009 * 11010 * @hide */ corkPackageInfoCache()11011 public static void corkPackageInfoCache() { 11012 PropertyInvalidatedCache.corkInvalidations(PermissionManager.CACHE_KEY_PACKAGE_INFO); 11013 } 11014 11015 /** 11016 * Enable package info cache invalidations. 11017 * 11018 * @hide */ uncorkPackageInfoCache()11019 public static void uncorkPackageInfoCache() { 11020 PropertyInvalidatedCache.uncorkInvalidations(PermissionManager.CACHE_KEY_PACKAGE_INFO); 11021 } 11022 11023 /** 11024 * Returns the token to be used by the subsequent calls to holdLock(). 11025 * @hide 11026 */ 11027 @RequiresPermission(android.Manifest.permission.INJECT_EVENTS) 11028 @TestApi getHoldLockToken()11029 public IBinder getHoldLockToken() { 11030 try { 11031 return ActivityThread.getPackageManager().getHoldLockToken(); 11032 } catch (RemoteException e) { 11033 throw e.rethrowFromSystemServer(); 11034 } 11035 } 11036 11037 /** 11038 * Holds the PM lock for the specified amount of milliseconds. 11039 * Intended for use by the tests that need to imitate lock contention. 11040 * The token should be obtained by 11041 * {@link android.content.pm.PackageManager#getHoldLockToken()}. 11042 * @hide 11043 */ 11044 @TestApi holdLock(IBinder token, int durationMs)11045 public void holdLock(IBinder token, int durationMs) { 11046 try { 11047 ActivityThread.getPackageManager().holdLock(token, durationMs); 11048 } catch (RemoteException e) { 11049 throw e.rethrowFromSystemServer(); 11050 } 11051 } 11052 11053 /** 11054 * Set a list of apps to keep around as APKs even if no user has currently installed it. 11055 * @param packageList List of package names to keep cached. 11056 * 11057 * @hide 11058 */ 11059 @RequiresPermission(android.Manifest.permission.KEEP_UNINSTALLED_PACKAGES) 11060 @TestApi setKeepUninstalledPackages(@onNull List<String> packageList)11061 public void setKeepUninstalledPackages(@NonNull List<String> packageList) { 11062 try { 11063 ActivityThread.getPackageManager().setKeepUninstalledPackages(packageList); 11064 } catch (RemoteException e) { 11065 throw e.rethrowFromSystemServer(); 11066 } 11067 } 11068 11069 /** 11070 * Checks if a package is blocked from uninstall for a particular user. A package can be 11071 * blocked from being uninstalled by a device owner or profile owner. 11072 * See {@link DevicePolicyManager#setUninstallBlocked(ComponentName, String, boolean)}. 11073 * 11074 * @param packageName Name of the package being uninstalled. 11075 * @param user UserHandle who's ability to uninstall a package is being checked. 11076 * 11077 * @hide 11078 */ 11079 @SystemApi 11080 @NonNull canUserUninstall(@onNull String packageName, @NonNull UserHandle user)11081 public boolean canUserUninstall(@NonNull String packageName, @NonNull UserHandle user){ 11082 throw new UnsupportedOperationException( 11083 "canUserUninstall not implemented in subclass"); 11084 } 11085 11086 /** 11087 * See {@link android.provider.Settings.Global#SHOW_NEW_APP_INSTALLED_NOTIFICATION_ENABLED}. 11088 * 11089 * @hide 11090 */ 11091 @SystemApi 11092 @NonNull shouldShowNewAppInstalledNotification()11093 public boolean shouldShowNewAppInstalledNotification() { 11094 throw new UnsupportedOperationException( 11095 "isShowNewAppInstalledNotificationEnabled not implemented in subclass"); 11096 } 11097 11098 /** 11099 * Attempt to relinquish the update ownership of the given package. Only the current 11100 * update owner of the given package can use this API. 11101 * 11102 * @param targetPackage The installed package whose update owner will be changed. 11103 * @throws IllegalArgumentException if the given package is invalid. 11104 * @throws SecurityException if you are not the current update owner of the given package. 11105 * 11106 * @see PackageInstaller.SessionParams#setRequestUpdateOwnership 11107 */ relinquishUpdateOwnership(@onNull String targetPackage)11108 public void relinquishUpdateOwnership(@NonNull String targetPackage) { 11109 throw new UnsupportedOperationException( 11110 "relinquishUpdateOwnership not implemented in subclass"); 11111 } 11112 } 11113