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 static android.app.PropertyInvalidatedCache.MODULE_SYSTEM; 20 import static android.content.pm.SigningInfo.AppSigningSchemeVersion; 21 import static android.media.audio.Flags.FLAG_FEATURE_SPATIAL_AUDIO_HEADTRACKING_LOW_LATENCY; 22 23 import static com.android.internal.pm.pkg.parsing.ParsingPackageUtils.PARSE_COLLECT_CERTIFICATES; 24 25 import android.Manifest; 26 import android.annotation.CallbackExecutor; 27 import android.annotation.CheckResult; 28 import android.annotation.DrawableRes; 29 import android.annotation.FlaggedApi; 30 import android.annotation.IntDef; 31 import android.annotation.IntRange; 32 import android.annotation.LongDef; 33 import android.annotation.NonNull; 34 import android.annotation.Nullable; 35 import android.annotation.RequiresPermission; 36 import android.annotation.SdkConstant; 37 import android.annotation.SdkConstant.SdkConstantType; 38 import android.annotation.StringRes; 39 import android.annotation.SuppressLint; 40 import android.annotation.SystemApi; 41 import android.annotation.TestApi; 42 import android.annotation.UserIdInt; 43 import android.annotation.WorkerThread; 44 import android.annotation.XmlRes; 45 import android.app.ActivityManager; 46 import android.app.ActivityThread; 47 import android.app.AppDetailsActivity; 48 import android.app.PackageDeleteObserver; 49 import android.app.PackageInstallObserver; 50 import android.app.PropertyInvalidatedCache; 51 import android.app.admin.DevicePolicyManager; 52 import android.app.usage.StorageStatsManager; 53 import android.companion.virtual.VirtualDeviceManager; 54 import android.compat.annotation.ChangeId; 55 import android.compat.annotation.EnabledSince; 56 import android.compat.annotation.UnsupportedAppUsage; 57 import android.content.ComponentName; 58 import android.content.Context; 59 import android.content.Intent; 60 import android.content.IntentFilter; 61 import android.content.IntentSender; 62 import android.content.pm.PackageInstaller.SessionParams; 63 import android.content.pm.dex.ArtManager; 64 import android.content.pm.parsing.result.ParseResult; 65 import android.content.pm.parsing.result.ParseTypeImpl; 66 import android.content.pm.verify.domain.DomainVerificationManager; 67 import android.content.res.Configuration; 68 import android.content.res.Resources; 69 import android.content.res.TypedArray; 70 import android.content.res.XmlResourceParser; 71 import android.graphics.Rect; 72 import android.graphics.drawable.AdaptiveIconDrawable; 73 import android.graphics.drawable.Drawable; 74 import android.net.ConnectivityManager; 75 import android.net.wifi.WifiManager; 76 import android.os.Build; 77 import android.os.Bundle; 78 import android.os.Handler; 79 import android.os.IBinder; 80 import android.os.IRemoteCallback; 81 import android.os.Parcel; 82 import android.os.ParcelFileDescriptor; 83 import android.os.Parcelable; 84 import android.os.PersistableBundle; 85 import android.os.RemoteException; 86 import android.os.UserHandle; 87 import android.os.UserManager; 88 import android.os.incremental.IncrementalManager; 89 import android.os.storage.StorageManager; 90 import android.os.storage.VolumeInfo; 91 import android.permission.PermissionManager; 92 import android.telephony.TelephonyManager; 93 import android.telephony.UiccCardInfo; 94 import android.telephony.gba.GbaService; 95 import android.telephony.ims.ImsService; 96 import android.telephony.ims.ProvisioningManager; 97 import android.telephony.ims.RcsUceAdapter; 98 import android.telephony.ims.SipDelegateManager; 99 import android.util.AndroidException; 100 import android.util.Log; 101 import android.util.apk.ApkSignatureVerifier; 102 103 import com.android.internal.annotations.VisibleForTesting; 104 import com.android.internal.pm.parsing.PackageInfoCommonUtils; 105 import com.android.internal.pm.parsing.PackageParser2; 106 import com.android.internal.pm.parsing.PackageParserException; 107 import com.android.internal.pm.parsing.pkg.ParsedPackage; 108 import com.android.internal.util.ArrayUtils; 109 import com.android.internal.util.DataClass; 110 111 import dalvik.system.VMRuntime; 112 113 import java.io.File; 114 import java.io.IOException; 115 import java.lang.annotation.Retention; 116 import java.lang.annotation.RetentionPolicy; 117 import java.security.cert.Certificate; 118 import java.security.cert.CertificateEncodingException; 119 import java.util.Collections; 120 import java.util.List; 121 import java.util.Locale; 122 import java.util.Objects; 123 import java.util.Set; 124 import java.util.UUID; 125 import java.util.concurrent.Executor; 126 import java.util.function.Consumer; 127 import java.util.function.Function; 128 129 /** 130 * Class for retrieving various kinds of information related to the application 131 * packages that are currently installed on the device. 132 * 133 * You can find this class through {@link Context#getPackageManager}. 134 * 135 * <p class="note"><strong>Note: </strong>If your app targets Android 11 (API level 30) or 136 * higher, the methods in this class each return a filtered list of apps. Learn more about how to 137 * <a href="/training/basics/intents/package-visibility">manage package visibility</a>. 138 * </p> 139 */ 140 @android.ravenwood.annotation.RavenwoodKeepPartialClass 141 public abstract class PackageManager { 142 private static final String TAG = "PackageManager"; 143 144 /** {@hide} */ 145 public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true; 146 147 /** {@hide} */ 148 public static final boolean ENABLE_SHARED_UID_MIGRATION = true; 149 150 /** 151 * This exception is thrown when a given package, application, or component 152 * name cannot be found. 153 */ 154 @android.ravenwood.annotation.RavenwoodKeepWholeClass 155 public static class NameNotFoundException extends AndroidException { NameNotFoundException()156 public NameNotFoundException() { 157 } 158 NameNotFoundException(String name)159 public NameNotFoundException(String name) { 160 super(name); 161 } 162 } 163 164 /** 165 * <application> level {@link android.content.pm.PackageManager.Property} tag specifying 166 * the XML resource ID containing an application's media capabilities XML file 167 * 168 * For example: 169 * <application> 170 * <property android:name="android.media.PROPERTY_MEDIA_CAPABILITIES" 171 * android:resource="@xml/media_capabilities"> 172 * <application> 173 */ 174 public static final String PROPERTY_MEDIA_CAPABILITIES = 175 "android.media.PROPERTY_MEDIA_CAPABILITIES"; 176 177 /** 178 * <application> level {@link android.content.pm.PackageManager.Property} tag 179 * specifying the XML resource ID containing the declaration of the self-certified network 180 * capabilities used by the application. 181 * 182 * <p> Starting from Android 14, usage of some network capabilities in 183 * {@link android.net.ConnectivityManager#requestNetwork} require the application to 184 * declare its usage of that particular capability in this resource. Only some capabilities 185 * require a declaration. Please look up the specific capability you want to use in 186 * {@link android.net.NetworkCapabilities} to see if it needs declaration in this property. 187 * 188 * For example: 189 * <application> 190 * <property android:name="android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES" 191 * android:resource="@xml/self_certified_network_capabilities"> 192 * <application> 193 * 194 * <p> The detail format of self_certified_network_capabilities.xml is described in 195 * {@link android.net.NetworkRequest} 196 */ 197 public static final String PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES = 198 "android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES"; 199 200 /** 201 * <application> level {@link android.content.pm.PackageManager.Property} tag 202 * specifying whether the app should be put into the "restricted" backup mode when it's started 203 * for backup and restore operations. 204 * 205 * <p> See <a 206 * href="https://developer.android.com/identity/data/autobackup#ImplementingBackupAgent"> for 207 * information about restricted mode</a>. 208 * 209 * <p> Starting with Android 16 apps may not be started in restricted mode based on this 210 * property. 211 * 212 * <p><b>Syntax:</b> 213 * <pre> 214 * <application> 215 * <property 216 * android:name="android.app.backup.PROPERTY_USE_RESTRICTED_BACKUP_MODE" 217 * android:value="true|false"/> 218 * </application> 219 * </pre> 220 * 221 * <p>If this property is set, the operating system will respect it for now (see Note below). 222 * If it's not set, the behavior depends on the SDK level that the app is targeting. For apps 223 * targeting SDK level {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or lower, the 224 * property defaults to {@code true}. For apps targeting SDK level 225 * {@link android.os.Build.VERSION_CODES#BAKLAVA} or higher, the operating system will make a 226 * decision dynamically. 227 * 228 * <p>Note: It's not recommended to set this property to {@code true} unless absolutely 229 * necessary. In a future Android version, this property may be deprecated in favor of removing 230 * restricted mode completely. 231 */ 232 @FlaggedApi(com.android.server.backup.Flags.FLAG_ENABLE_RESTRICTED_MODE_CHANGES) 233 public static final String PROPERTY_USE_RESTRICTED_BACKUP_MODE = 234 "android.app.backup.PROPERTY_USE_RESTRICTED_BACKUP_MODE"; 235 236 /** 237 * Application level property that an app can specify to opt-out from having private data 238 * directories both on the internal and external storages. 239 * 240 * <p>Changing the value of this property during app update is not supported, and such updates 241 * will be rejected. 242 * 243 * <p>This should only be set by platform apps that know what they are doing. 244 * 245 * @hide 246 */ 247 public static final String PROPERTY_NO_APP_DATA_STORAGE = 248 "android.internal.PROPERTY_NO_APP_DATA_STORAGE"; 249 250 /** 251 * <service> level {@link android.content.pm.PackageManager.Property} tag specifying 252 * the actual use case of the service if it's foreground service with the type 253 * {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SPECIAL_USE}. 254 * 255 * <p> 256 * For example: 257 * <service> 258 * <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" 259 * android:value="foo"/> 260 * </service> 261 */ 262 public static final String PROPERTY_SPECIAL_USE_FGS_SUBTYPE = 263 "android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"; 264 265 /** 266 * Application level {@link android.content.pm.PackageManager.Property PackageManager 267 * .Property} for an app to inform the system that the app can be opted-in or opted-out 268 * from the compatibility treatment that rotates camera output by 90 degrees on landscape 269 * sensors on devices known to have compatibility issues. 270 * 271 * <p>The treatment is disabled by default but device manufacturers can enable the treatment 272 * using their discretion to improve camera compatibility. With this property set to 273 * {@code false}, the rotation will not be applied. A value of {@code true} 274 * will ensure that rotation is applied, provided it is enabled for the device. In most cases, 275 * if rotation is the desired behavior this property need not be set. However, if your app 276 * experiences stretching or incorrect rotation on these devices, explicitly setting this to 277 * {@code true} may resolve that behavior. Apps should set this to {@code false} if there 278 * is confidence that the app handles 279 * {@link android.hardware.camera2.CameraCharacteristics#SENSOR_ORIENTATION} correctly. 280 * See <a href="https://developer.android.com/training/camera2/camera-preview"> the 281 * documentation for best practice.</a> 282 * 283 * <p><b>Syntax:</b> 284 * <pre> 285 * <application> 286 * <property 287 * android:name="android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT" 288 * android:value="true|false"/> 289 * </application> 290 * </pre> 291 */ 292 public static final String PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT = 293 "android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT"; 294 295 /** 296 * Application level {@link android.content.pm.PackageManager.Property PackageManager 297 * .Property} for a privileged system installer to define a list of up to 500 packages that 298 * should not have their updates owned by any installer. The list must be provided via a default 299 * XML resource with the following format: 300 * 301 * <pre> 302 * <deny-ownership>PACKAGE_NAME</deny-ownership> 303 * <deny-ownership>PACKAGE_NAME</deny-ownership> 304 * </pre> 305 * 306 * <b>NOTE:</b> Installers that provide this property will not granted update ownership for any 307 * packages that they request update ownership of. 308 * @hide 309 */ 310 public static final String PROPERTY_LEGACY_UPDATE_OWNERSHIP_DENYLIST = 311 "android.app.PROPERTY_LEGACY_UPDATE_OWNERSHIP_DENYLIST"; 312 313 /** 314 * Application level {@link android.content.pm.PackageManager.Property PackageManager 315 * .Property} for a app to inform the installer that a file containing the app's android 316 * safety label data is bundled into the APK as a raw resource. 317 * 318 * <p>For example: 319 * <pre> 320 * <application> 321 * <property 322 * android:name="android.content.PROPERTY_ANDROID_SAFETY_LABEL" 323 * android:resource="@raw/app-metadata"/> 324 * </application> 325 * </pre> 326 * @hide 327 */ 328 public static final String PROPERTY_ANDROID_SAFETY_LABEL = 329 "android.content.PROPERTY_ANDROID_SAFETY_LABEL"; 330 331 /** 332 * A property value set within the manifest. 333 * <p> 334 * The value of a property will only have a single type, as defined by 335 * the property itself. 336 * 337 * <p class="note"><strong>Note:</strong> 338 * In android version {@link Build.VERSION_CODES#VANILLA_ICE_CREAM} and earlier, 339 * the {@code equals} and {@code hashCode} methods for this class may not function as expected. 340 */ 341 public static final class Property implements Parcelable { 342 private static final int TYPE_BOOLEAN = 1; 343 private static final int TYPE_FLOAT = 2; 344 private static final int TYPE_INTEGER = 3; 345 private static final int TYPE_RESOURCE = 4; 346 private static final int TYPE_STRING = 5; 347 private final String mName; 348 private final int mType; 349 private final String mClassName; 350 private final String mPackageName; 351 private boolean mBooleanValue; 352 private float mFloatValue; 353 private int mIntegerValue; 354 private String mStringValue; 355 356 /** @hide */ 357 @VisibleForTesting Property(@onNull String name, int type, @NonNull String packageName, @Nullable String className)358 public Property(@NonNull String name, int type, 359 @NonNull String packageName, @Nullable String className) { 360 if (type < TYPE_BOOLEAN || type > TYPE_STRING) { 361 throw new IllegalArgumentException("Invalid type"); 362 } 363 this.mName = Objects.requireNonNull(name); 364 this.mType = type; 365 this.mPackageName = Objects.requireNonNull(packageName); 366 this.mClassName = className; 367 } 368 /** @hide */ Property(@onNull String name, boolean value, String packageName, String className)369 public Property(@NonNull String name, boolean value, 370 String packageName, String className) { 371 this(name, TYPE_BOOLEAN, packageName, className); 372 mBooleanValue = value; 373 } 374 /** @hide */ Property(@onNull String name, float value, String packageName, String className)375 public Property(@NonNull String name, float value, 376 String packageName, String className) { 377 this(name, TYPE_FLOAT, packageName, className); 378 mFloatValue = value; 379 } 380 /** @hide */ Property(@onNull String name, int value, boolean isResource, String packageName, String className)381 public Property(@NonNull String name, int value, boolean isResource, 382 String packageName, String className) { 383 this(name, isResource ? TYPE_RESOURCE : TYPE_INTEGER, packageName, className); 384 mIntegerValue = value; 385 } 386 /** @hide */ Property(@onNull String name, String value, String packageName, String className)387 public Property(@NonNull String name, String value, 388 String packageName, String className) { 389 this(name, TYPE_STRING, packageName, className); 390 mStringValue = value; 391 } 392 393 /** @hide */ 394 @VisibleForTesting getType()395 public int getType() { 396 return mType; 397 } 398 399 /** 400 * Returns the name of the property. 401 */ getName()402 @NonNull public String getName() { 403 return mName; 404 } 405 406 /** 407 * Returns the name of the package where this this property was defined. 408 */ getPackageName()409 @NonNull public String getPackageName() { 410 return mPackageName; 411 } 412 413 /** 414 * Returns the classname of the component where this property was defined. 415 * <p>If the property was defined within and <application> tag, returns 416 * {@code null} 417 */ getClassName()418 @Nullable public String getClassName() { 419 return mClassName; 420 } 421 422 /** 423 * Returns the boolean value set for the property. 424 * <p>If the property is not of a boolean type, returns {@code false}. 425 */ getBoolean()426 public boolean getBoolean() { 427 return mBooleanValue; 428 } 429 430 /** 431 * Returns {@code true} if the property is a boolean type. Otherwise {@code false}. 432 */ isBoolean()433 public boolean isBoolean() { 434 return mType == TYPE_BOOLEAN; 435 } 436 437 /** 438 * Returns the float value set for the property. 439 * <p>If the property is not of a float type, returns {@code 0.0}. 440 */ getFloat()441 public float getFloat() { 442 return mFloatValue; 443 } 444 445 /** 446 * Returns {@code true} if the property is a float type. Otherwise {@code false}. 447 */ isFloat()448 public boolean isFloat() { 449 return mType == TYPE_FLOAT; 450 } 451 452 /** 453 * Returns the integer value set for the property. 454 * <p>If the property is not of an integer type, returns {@code 0}. 455 */ getInteger()456 public int getInteger() { 457 return mType == TYPE_INTEGER ? mIntegerValue : 0; 458 } 459 460 /** 461 * Returns {@code true} if the property is an integer type. Otherwise {@code false}. 462 */ isInteger()463 public boolean isInteger() { 464 return mType == TYPE_INTEGER; 465 } 466 467 /** 468 * Returns the a resource id set for the property. 469 * <p>If the property is not of a resource id type, returns {@code 0}. 470 */ getResourceId()471 public int getResourceId() { 472 return mType == TYPE_RESOURCE ? mIntegerValue : 0; 473 } 474 475 /** 476 * Returns {@code true} if the property is a resource id type. Otherwise {@code false}. 477 */ isResourceId()478 public boolean isResourceId() { 479 return mType == TYPE_RESOURCE; 480 } 481 482 /** 483 * Returns the a String value set for the property. 484 * <p>If the property is not a String type, returns {@code null}. 485 */ getString()486 @Nullable public String getString() { 487 return mStringValue; 488 } 489 490 /** 491 * Returns {@code true} if the property is a String type. Otherwise {@code false}. 492 */ isString()493 public boolean isString() { 494 return mType == TYPE_STRING; 495 } 496 497 /** 498 * Adds a mapping from the given key to this property's value in the provided 499 * {@link android.os.Bundle}. If the provided {@link android.os.Bundle} is 500 * {@code null}, creates a new {@link android.os.Bundle}. 501 * @hide 502 */ toBundle(Bundle outBundle)503 public Bundle toBundle(Bundle outBundle) { 504 final Bundle b = outBundle == null || outBundle == Bundle.EMPTY 505 ? new Bundle() : outBundle; 506 if (mType == TYPE_BOOLEAN) { 507 b.putBoolean(mName, mBooleanValue); 508 } else if (mType == TYPE_FLOAT) { 509 b.putFloat(mName, mFloatValue); 510 } else if (mType == TYPE_INTEGER) { 511 b.putInt(mName, mIntegerValue); 512 } else if (mType == TYPE_RESOURCE) { 513 b.putInt(mName, mIntegerValue); 514 } else if (mType == TYPE_STRING) { 515 b.putString(mName, mStringValue); 516 } 517 return b; 518 } 519 520 @Override describeContents()521 public int describeContents() { 522 return 0; 523 } 524 525 @Override writeToParcel(@onNull Parcel dest, int flags)526 public void writeToParcel(@NonNull Parcel dest, int flags) { 527 dest.writeString(mName); 528 dest.writeInt(mType); 529 dest.writeString(mPackageName); 530 dest.writeString(mClassName); 531 if (mType == TYPE_BOOLEAN) { 532 dest.writeBoolean(mBooleanValue); 533 } else if (mType == TYPE_FLOAT) { 534 dest.writeFloat(mFloatValue); 535 } else if (mType == TYPE_INTEGER) { 536 dest.writeInt(mIntegerValue); 537 } else if (mType == TYPE_RESOURCE) { 538 dest.writeInt(mIntegerValue); 539 } else if (mType == TYPE_STRING) { 540 dest.writeString(mStringValue); 541 } 542 } 543 544 @NonNull 545 public static final Creator<Property> CREATOR = new Creator<Property>() { 546 @Override 547 public Property createFromParcel(@NonNull Parcel source) { 548 final String name = source.readString(); 549 final int type = source.readInt(); 550 final String packageName = source.readString(); 551 final String className = source.readString(); 552 if (type == TYPE_BOOLEAN) { 553 return new Property(name, source.readBoolean(), packageName, className); 554 } else if (type == TYPE_FLOAT) { 555 return new Property(name, source.readFloat(), packageName, className); 556 } else if (type == TYPE_INTEGER) { 557 return new Property(name, source.readInt(), false, packageName, className); 558 } else if (type == TYPE_RESOURCE) { 559 return new Property(name, source.readInt(), true, packageName, className); 560 } else if (type == TYPE_STRING) { 561 return new Property(name, source.readString(), packageName, className); 562 } 563 return null; 564 } 565 566 @Override 567 public Property[] newArray(int size) { 568 return new Property[size]; 569 } 570 }; 571 572 @Override equals(Object obj)573 public boolean equals(Object obj) { 574 if (!(obj instanceof Property)) { 575 return false; 576 } 577 final Property property = (Property) obj; 578 return mType == property.mType && 579 Objects.equals(mName, property.mName) && 580 Objects.equals(mClassName, property.mClassName) && 581 Objects.equals(mPackageName, property.mPackageName) && 582 (mType == TYPE_BOOLEAN ? mBooleanValue == property.mBooleanValue : 583 mType == TYPE_FLOAT ? Float.compare(mFloatValue, property.mFloatValue) == 0 : 584 mType == TYPE_INTEGER ? mIntegerValue == property.mIntegerValue : 585 mType == TYPE_RESOURCE ? mIntegerValue == property.mIntegerValue : 586 mStringValue.equals(property.mStringValue)); 587 } 588 589 @Override hashCode()590 public int hashCode() { 591 int result = Objects.hash(mName, mType, mClassName, mPackageName); 592 if (mType == TYPE_BOOLEAN) { 593 result = 31 * result + (mBooleanValue ? 1 : 0); 594 } else if (mType == TYPE_FLOAT) { 595 result = 31 * result + Float.floatToIntBits(mFloatValue); 596 } else if (mType == TYPE_INTEGER) { 597 result = 31 * result + mIntegerValue; 598 } else if (mType == TYPE_RESOURCE) { 599 result = 31 * result + mIntegerValue; 600 } else if (mType == TYPE_STRING) { 601 result = 31 * result + mStringValue.hashCode(); 602 } 603 return result; 604 } 605 } 606 607 /** 608 * The class containing the enabled setting of a package component. 609 * <p> 610 * This is used by the {@link #setComponentEnabledSettings(List)} to support the batch updates 611 * of the enabled settings of components. 612 * 613 * @see #setComponentEnabledSettings(List) 614 */ 615 @DataClass(genConstructor = false) 616 public static final class ComponentEnabledSetting implements Parcelable { 617 /** 618 * The package name of the application to enable the setting. 619 */ 620 private final @Nullable String mPackageName; 621 622 /** 623 * The component name of the application to enable the setting. 624 */ 625 private final @Nullable ComponentName mComponentName; 626 627 /** 628 * The new enabled state 629 */ 630 private final @EnabledState int mEnabledState; 631 632 /** 633 * The optional behavior flag 634 */ 635 private final @EnabledFlags int mEnabledFlags; 636 637 /** 638 * Create an instance of the ComponentEnabledSetting for the component level's enabled 639 * setting update. 640 * 641 * @param componentName The component name to update the enabled setting. 642 * @param newState The new enabled state. 643 * @param flags The optional behavior flags. 644 */ ComponentEnabledSetting(@onNull ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags)645 public ComponentEnabledSetting(@NonNull ComponentName componentName, 646 @EnabledState int newState, @EnabledFlags int flags) { 647 mPackageName = null; 648 mComponentName = Objects.requireNonNull(componentName); 649 mEnabledState = newState; 650 mEnabledFlags = flags; 651 } 652 653 /** 654 * Create an instance of the ComponentEnabledSetting for the application level's enabled 655 * setting update. 656 * 657 * @param packageName The package name to update the enabled setting. 658 * @param newState The new enabled state. 659 * @param flags The optional behavior flags. 660 * @hide 661 */ ComponentEnabledSetting(@onNull String packageName, @EnabledState int newState, @EnabledFlags int flags)662 public ComponentEnabledSetting(@NonNull String packageName, 663 @EnabledState int newState, @EnabledFlags int flags) { 664 mPackageName = Objects.requireNonNull(packageName); 665 mComponentName = null; 666 mEnabledState = newState; 667 mEnabledFlags = flags; 668 } 669 670 /** 671 * Returns the package name of the setting. 672 * 673 * @return the package name. 674 * @hide 675 */ getPackageName()676 public @NonNull String getPackageName() { 677 if (isComponent()) { 678 return mComponentName.getPackageName(); 679 } 680 return mPackageName; 681 } 682 683 /** 684 * Returns the component class name of the setting. 685 * 686 * @return the class name. 687 * @hide 688 */ getClassName()689 public @Nullable String getClassName() { 690 if (isComponent()) { 691 return mComponentName.getClassName(); 692 } 693 return null; 694 } 695 696 /** 697 * Whether or not this is for the component level's enabled setting update. 698 * 699 * @return {@code true} if it's the component level enabled setting update. 700 * @hide 701 */ isComponent()702 public boolean isComponent() { 703 return mComponentName != null; 704 } 705 706 707 708 // Code below generated by codegen v1.0.23. 709 // 710 // DO NOT MODIFY! 711 // CHECKSTYLE:OFF Generated code 712 // 713 // To regenerate run: 714 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/PackageManager.java 715 // 716 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 717 // Settings > Editor > Code Style > Formatter Control 718 //@formatter:off 719 720 721 /** 722 * The component name of the application to enable the setting. 723 */ 724 @DataClass.Generated.Member getComponentName()725 public @Nullable ComponentName getComponentName() { 726 return mComponentName; 727 } 728 729 /** 730 * The new enabled state 731 */ 732 @DataClass.Generated.Member getEnabledState()733 public @EnabledState int getEnabledState() { 734 return mEnabledState; 735 } 736 737 /** 738 * The optional behavior flag 739 */ 740 @DataClass.Generated.Member getEnabledFlags()741 public @EnabledFlags int getEnabledFlags() { 742 return mEnabledFlags; 743 } 744 745 @Override 746 @DataClass.Generated.Member writeToParcel(@onNull Parcel dest, int flags)747 public void writeToParcel(@NonNull Parcel dest, int flags) { 748 // You can override field parcelling by defining methods like: 749 // void parcelFieldName(Parcel dest, int flags) { ... } 750 751 byte flg = 0; 752 if (mPackageName != null) flg |= 0x1; 753 if (mComponentName != null) flg |= 0x2; 754 dest.writeByte(flg); 755 if (mPackageName != null) dest.writeString(mPackageName); 756 if (mComponentName != null) dest.writeTypedObject(mComponentName, flags); 757 dest.writeInt(mEnabledState); 758 dest.writeInt(mEnabledFlags); 759 } 760 761 @Override 762 @DataClass.Generated.Member describeContents()763 public int describeContents() { return 0; } 764 765 /** @hide */ 766 @SuppressWarnings({"unchecked", "RedundantCast"}) 767 @DataClass.Generated.Member ComponentEnabledSetting(@onNull Parcel in)768 /* package-private */ ComponentEnabledSetting(@NonNull Parcel in) { 769 // You can override field unparcelling by defining methods like: 770 // static FieldType unparcelFieldName(Parcel in) { ... } 771 772 byte flg = in.readByte(); 773 String packageName = (flg & 0x1) == 0 ? null : in.readString(); 774 ComponentName componentName = (flg & 0x2) == 0 ? null : (ComponentName) in.readTypedObject(ComponentName.CREATOR); 775 int enabledState = in.readInt(); 776 int enabledFlags = in.readInt(); 777 778 this.mPackageName = packageName; 779 this.mComponentName = componentName; 780 this.mEnabledState = enabledState; 781 com.android.internal.util.AnnotationValidations.validate( 782 EnabledState.class, null, mEnabledState); 783 this.mEnabledFlags = enabledFlags; 784 com.android.internal.util.AnnotationValidations.validate( 785 EnabledFlags.class, null, mEnabledFlags); 786 787 // onConstructed(); // You can define this method to get a callback 788 } 789 790 @DataClass.Generated.Member 791 public static final @NonNull Parcelable.Creator<ComponentEnabledSetting> CREATOR 792 = new Parcelable.Creator<ComponentEnabledSetting>() { 793 @Override 794 public ComponentEnabledSetting[] newArray(int size) { 795 return new ComponentEnabledSetting[size]; 796 } 797 798 @Override 799 public ComponentEnabledSetting createFromParcel(@NonNull Parcel in) { 800 return new ComponentEnabledSetting(in); 801 } 802 }; 803 804 @DataClass.Generated( 805 time = 1628668290863L, 806 codegenVersion = "1.0.23", 807 sourceFile = "frameworks/base/core/java/android/content/pm/PackageManager.java", 808 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)") 809 @Deprecated __metadata()810 private void __metadata() {} 811 812 //@formatter:on 813 // End of generated code 814 815 } 816 817 /** 818 * Listener for changes in permissions granted to a UID. 819 * 820 * @hide 821 */ 822 @SystemApi 823 public interface OnPermissionsChangedListener { 824 /** 825 * Called when the permissions for a UID change for the default device. 826 * 827 * @param uid The UID with a change. 828 * @see Context#DEVICE_ID_DEFAULT 829 */ onPermissionsChanged(int uid)830 void onPermissionsChanged(int uid); 831 832 /** 833 * Called when the permissions for a UID change for a device, including virtual devices. 834 * 835 * @param uid The UID of permission change event. 836 * @param persistentDeviceId The persistent device ID of permission change event. 837 * 838 * @see VirtualDeviceManager.VirtualDevice#getPersistentDeviceId() 839 * @see VirtualDeviceManager#PERSISTENT_DEVICE_ID_DEFAULT 840 */ 841 @FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED) onPermissionsChanged(int uid, @NonNull String persistentDeviceId)842 default void onPermissionsChanged(int uid, @NonNull String persistentDeviceId) { 843 Objects.requireNonNull(persistentDeviceId); 844 if (Objects.equals(persistentDeviceId, 845 VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)) { 846 onPermissionsChanged(uid); 847 } 848 } 849 } 850 851 /** @hide */ 852 public static final int TYPE_UNKNOWN = 0; 853 /** @hide */ 854 public static final int TYPE_ACTIVITY = 1; 855 /** @hide */ 856 public static final int TYPE_RECEIVER = 2; 857 /** @hide */ 858 public static final int TYPE_SERVICE = 3; 859 /** @hide */ 860 public static final int TYPE_PROVIDER = 4; 861 /** @hide */ 862 public static final int TYPE_APPLICATION = 5; 863 /** @hide */ 864 @IntDef(prefix = { "TYPE_" }, value = { 865 TYPE_UNKNOWN, 866 TYPE_ACTIVITY, 867 TYPE_RECEIVER, 868 TYPE_SERVICE, 869 TYPE_PROVIDER, 870 }) 871 @Retention(RetentionPolicy.SOURCE) 872 public @interface ComponentType {} 873 874 /** @hide */ 875 @IntDef(prefix = { "TYPE_" }, value = { 876 TYPE_UNKNOWN, 877 TYPE_ACTIVITY, 878 TYPE_RECEIVER, 879 TYPE_SERVICE, 880 TYPE_PROVIDER, 881 TYPE_APPLICATION, 882 }) 883 @Retention(RetentionPolicy.SOURCE) 884 public @interface PropertyLocation {} 885 886 /** 887 * As a guiding principle: 888 * <p> 889 * {@code GET_} flags are used to request additional data that may have been 890 * elided to save wire space. 891 * <p> 892 * {@code MATCH_} flags are used to include components or packages that 893 * would have otherwise been omitted from a result set by current system 894 * state. 895 */ 896 897 /** @hide */ 898 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 899 GET_ACTIVITIES, 900 GET_CONFIGURATIONS, 901 GET_GIDS, 902 GET_INSTRUMENTATION, 903 GET_INTENT_FILTERS, 904 GET_META_DATA, 905 GET_PERMISSIONS, 906 GET_PROVIDERS, 907 GET_RECEIVERS, 908 GET_SERVICES, 909 GET_SHARED_LIBRARY_FILES, 910 GET_SIGNATURES, 911 GET_SIGNING_CERTIFICATES, 912 GET_URI_PERMISSION_PATTERNS, 913 MATCH_UNINSTALLED_PACKAGES, 914 MATCH_DISABLED_COMPONENTS, 915 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 916 MATCH_SYSTEM_ONLY, 917 MATCH_FACTORY_ONLY, 918 MATCH_ANY_USER, 919 MATCH_DEBUG_TRIAGED_MISSING, 920 MATCH_INSTANT, 921 MATCH_APEX, 922 MATCH_ARCHIVED_PACKAGES, 923 GET_DISABLED_COMPONENTS, 924 GET_DISABLED_UNTIL_USED_COMPONENTS, 925 GET_UNINSTALLED_PACKAGES, 926 MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS, 927 MATCH_DIRECT_BOOT_AWARE, 928 MATCH_DIRECT_BOOT_UNAWARE, 929 GET_ATTRIBUTIONS_LONG, 930 }) 931 @Retention(RetentionPolicy.SOURCE) 932 public @interface PackageInfoFlagsBits {} 933 934 /** @hide */ 935 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 936 GET_META_DATA, 937 GET_SHARED_LIBRARY_FILES, 938 MATCH_UNINSTALLED_PACKAGES, 939 MATCH_SYSTEM_ONLY, 940 MATCH_DEBUG_TRIAGED_MISSING, 941 MATCH_DISABLED_COMPONENTS, 942 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 943 MATCH_INSTANT, 944 MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, 945 GET_DISABLED_UNTIL_USED_COMPONENTS, 946 GET_UNINSTALLED_PACKAGES, 947 MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS, 948 MATCH_APEX, 949 MATCH_ARCHIVED_PACKAGES, 950 }) 951 @Retention(RetentionPolicy.SOURCE) 952 public @interface ApplicationInfoFlagsBits {} 953 954 /** @hide */ 955 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 956 GET_META_DATA, 957 GET_SHARED_LIBRARY_FILES, 958 MATCH_ALL, 959 MATCH_DEBUG_TRIAGED_MISSING, 960 MATCH_DEFAULT_ONLY, 961 MATCH_DISABLED_COMPONENTS, 962 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 963 MATCH_DIRECT_BOOT_AUTO, 964 MATCH_DIRECT_BOOT_AWARE, 965 MATCH_DIRECT_BOOT_UNAWARE, 966 MATCH_SYSTEM_ONLY, 967 MATCH_UNINSTALLED_PACKAGES, 968 MATCH_INSTANT, 969 MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, 970 GET_DISABLED_COMPONENTS, 971 GET_DISABLED_UNTIL_USED_COMPONENTS, 972 GET_UNINSTALLED_PACKAGES, 973 MATCH_QUARANTINED_COMPONENTS, 974 }) 975 @Retention(RetentionPolicy.SOURCE) 976 public @interface ComponentInfoFlagsBits {} 977 978 /** @hide */ 979 @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 980 GET_META_DATA, 981 GET_RESOLVED_FILTER, 982 GET_SHARED_LIBRARY_FILES, 983 MATCH_ALL, 984 MATCH_DEBUG_TRIAGED_MISSING, 985 MATCH_DISABLED_COMPONENTS, 986 MATCH_DISABLED_UNTIL_USED_COMPONENTS, 987 MATCH_DEFAULT_ONLY, 988 MATCH_DIRECT_BOOT_AUTO, 989 MATCH_DIRECT_BOOT_AWARE, 990 MATCH_DIRECT_BOOT_UNAWARE, 991 MATCH_SYSTEM_ONLY, 992 MATCH_UNINSTALLED_PACKAGES, 993 MATCH_INSTANT, 994 GET_DISABLED_COMPONENTS, 995 GET_DISABLED_UNTIL_USED_COMPONENTS, 996 GET_UNINSTALLED_PACKAGES, 997 MATCH_CLONE_PROFILE_LONG, 998 MATCH_QUARANTINED_COMPONENTS, 999 }) 1000 @Retention(RetentionPolicy.SOURCE) 1001 public @interface ResolveInfoFlagsBits {} 1002 1003 /** @hide */ 1004 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 1005 MATCH_ALL, 1006 }) 1007 @Retention(RetentionPolicy.SOURCE) 1008 public @interface InstalledModulesFlags {} 1009 1010 /** @hide */ 1011 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 1012 GET_META_DATA, 1013 }) 1014 @Retention(RetentionPolicy.SOURCE) 1015 public @interface PermissionInfoFlags {} 1016 1017 /** @hide */ 1018 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 1019 GET_META_DATA, 1020 }) 1021 @Retention(RetentionPolicy.SOURCE) 1022 public @interface PermissionGroupInfoFlags {} 1023 1024 /** @hide */ 1025 @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = { 1026 GET_META_DATA, 1027 }) 1028 @Retention(RetentionPolicy.SOURCE) 1029 public @interface InstrumentationInfoFlags {} 1030 1031 //------------------------------------------------------------------------- 1032 // Beginning of GET_ and MATCH_ flags 1033 //------------------------------------------------------------------------- 1034 1035 /** 1036 * {@link PackageInfo} flag: return information about 1037 * activities in the package in {@link PackageInfo#activities}. 1038 */ 1039 public static final int GET_ACTIVITIES = 0x00000001; 1040 1041 /** 1042 * {@link PackageInfo} flag: return information about 1043 * intent receivers in the package in 1044 * {@link PackageInfo#receivers}. 1045 */ 1046 public static final int GET_RECEIVERS = 0x00000002; 1047 1048 /** 1049 * {@link PackageInfo} flag: return information about 1050 * services in the package in {@link PackageInfo#services}. 1051 */ 1052 public static final int GET_SERVICES = 0x00000004; 1053 1054 /** 1055 * {@link PackageInfo} flag: return information about 1056 * content providers in the package in 1057 * {@link PackageInfo#providers}. 1058 */ 1059 public static final int GET_PROVIDERS = 0x00000008; 1060 1061 /** 1062 * {@link PackageInfo} flag: return information about 1063 * instrumentation in the package in 1064 * {@link PackageInfo#instrumentation}. 1065 */ 1066 public static final int GET_INSTRUMENTATION = 0x00000010; 1067 1068 /** 1069 * {@link PackageInfo} flag: return information about the 1070 * intent filters supported by the activity. 1071 * 1072 * @deprecated The platform does not support getting {@link IntentFilter}s for the package. 1073 */ 1074 @Deprecated 1075 public static final int GET_INTENT_FILTERS = 0x00000020; 1076 1077 /** 1078 * {@link PackageInfo} flag: return information about the 1079 * signatures included in the package. 1080 * 1081 * @deprecated use {@code GET_SIGNING_CERTIFICATES} instead 1082 */ 1083 @Deprecated 1084 public static final int GET_SIGNATURES = 0x00000040; 1085 1086 /** 1087 * {@link ResolveInfo} flag: return the IntentFilter that 1088 * was matched for a particular ResolveInfo in 1089 * {@link ResolveInfo#filter}. 1090 */ 1091 public static final int GET_RESOLVED_FILTER = 0x00000040; 1092 1093 /** 1094 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData} 1095 * data {@link android.os.Bundle}s that are associated with a component. 1096 * This applies for any API returning a ComponentInfo subclass. 1097 */ 1098 public static final int GET_META_DATA = 0x00000080; 1099 1100 /** 1101 * {@link PackageInfo} flag: return the 1102 * {@link PackageInfo#gids group ids} that are associated with an 1103 * application. 1104 * This applies for any API returning a PackageInfo class, either 1105 * directly or nested inside of another. 1106 */ 1107 public static final int GET_GIDS = 0x00000100; 1108 1109 /** 1110 * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS} 1111 */ 1112 @Deprecated 1113 public static final int GET_DISABLED_COMPONENTS = 0x00000200; 1114 1115 /** 1116 * {@link PackageInfo} flag: include disabled components in the returned info. 1117 */ 1118 public static final int MATCH_DISABLED_COMPONENTS = 0x00000200; 1119 1120 /** 1121 * {@link ApplicationInfo} flag: return the 1122 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries} 1123 * that are associated with an application. 1124 * This applies for any API returning an ApplicationInfo class, either 1125 * directly or nested inside of another. 1126 */ 1127 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400; 1128 1129 /** 1130 * {@link ProviderInfo} flag: return the 1131 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns} 1132 * that are associated with a content provider. 1133 * This applies for any API returning a ProviderInfo class, either 1134 * directly or nested inside of another. 1135 */ 1136 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800; 1137 /** 1138 * {@link PackageInfo} flag: return information about 1139 * permissions in the package in 1140 * {@link PackageInfo#permissions}. 1141 */ 1142 public static final int GET_PERMISSIONS = 0x00001000; 1143 1144 /** 1145 * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES} 1146 */ 1147 @Deprecated 1148 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000; 1149 1150 /** 1151 * Flag parameter to retrieve some information about all applications (even 1152 * uninstalled ones) which have data directories. This state could have 1153 * resulted if applications have been deleted with flag 1154 * {@code DELETE_KEEP_DATA} with a possibility of being replaced or 1155 * reinstalled in future. 1156 * <p> 1157 * Note: this flag may cause less information about currently installed 1158 * applications to be returned. 1159 * <p> 1160 * Note: use of this flag requires the android.permission.QUERY_ALL_PACKAGES 1161 * permission to see uninstalled packages. 1162 */ 1163 public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000; 1164 1165 /** 1166 * {@link PackageInfo} flag: return information about 1167 * hardware preferences in 1168 * {@link PackageInfo#configPreferences PackageInfo.configPreferences}, 1169 * and requested features in {@link PackageInfo#reqFeatures} and 1170 * {@link PackageInfo#featureGroups}. 1171 */ 1172 public static final int GET_CONFIGURATIONS = 0x00004000; 1173 1174 /** 1175 * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}. 1176 */ 1177 @Deprecated 1178 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 1179 1180 /** 1181 * {@link PackageInfo} flag: include disabled components which are in 1182 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED} 1183 * in the returned info. Note that if you set this flag, applications 1184 * that are in this disabled state will be reported as enabled. 1185 */ 1186 public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 1187 1188 /** 1189 * Resolution and querying flag: if set, only filters that support the 1190 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for 1191 * matching. This is a synonym for including the CATEGORY_DEFAULT in your 1192 * supplied Intent. 1193 */ 1194 public static final int MATCH_DEFAULT_ONLY = 0x00010000; 1195 1196 /** 1197 * Querying flag: if set and if the platform is doing any filtering of the 1198 * results, then the filtering will not happen. This is a synonym for saying 1199 * that all results should be returned. 1200 * <p> 1201 * <em>This flag should be used with extreme care.</em> 1202 */ 1203 public static final int MATCH_ALL = 0x00020000; 1204 1205 /** 1206 * Querying flag: match components which are direct boot <em>unaware</em> in 1207 * the returned info, regardless of the current user state. 1208 * <p> 1209 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor 1210 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is 1211 * to match only runnable components based on the user state. For example, 1212 * when a user is started but credentials have not been presented yet, the 1213 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE} 1214 * components are returned. Once the user credentials have been presented, 1215 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE} 1216 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned. 1217 * 1218 * @see UserManager#isUserUnlocked() 1219 */ 1220 public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000; 1221 1222 /** 1223 * Querying flag: match components which are direct boot <em>aware</em> in 1224 * the returned info, regardless of the current user state. 1225 * <p> 1226 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor 1227 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is 1228 * to match only runnable components based on the user state. For example, 1229 * when a user is started but credentials have not been presented yet, the 1230 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE} 1231 * components are returned. Once the user credentials have been presented, 1232 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE} 1233 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned. 1234 * 1235 * @see UserManager#isUserUnlocked() 1236 */ 1237 public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000; 1238 1239 /** 1240 * Querying flag: include only components from applications that are marked 1241 * with {@link ApplicationInfo#FLAG_SYSTEM}. 1242 */ 1243 public static final int MATCH_SYSTEM_ONLY = 0x00100000; 1244 1245 /** 1246 * Internal {@link PackageInfo} flag: include only components on the system image. 1247 * This will not return information on any unbundled update to system components. 1248 * @hide 1249 */ 1250 @SystemApi 1251 public static final int MATCH_FACTORY_ONLY = 0x00200000; 1252 1253 /** 1254 * Allows querying of packages installed for any user, not just the specific one. This flag 1255 * is only meant for use by apps that have INTERACT_ACROSS_USERS permission. 1256 * @hide 1257 */ 1258 @SystemApi 1259 public static final int MATCH_ANY_USER = 0x00400000; 1260 1261 /** 1262 * Combination of MATCH_ANY_USER and MATCH_UNINSTALLED_PACKAGES to mean any known 1263 * package. 1264 * @hide 1265 */ 1266 @TestApi 1267 public static final int MATCH_KNOWN_PACKAGES = MATCH_UNINSTALLED_PACKAGES | MATCH_ANY_USER; 1268 1269 /** 1270 * Internal {@link PackageInfo} flag: include components that are part of an 1271 * instant app. By default, instant app components are not matched. 1272 * @hide 1273 */ 1274 @SystemApi 1275 public static final int MATCH_INSTANT = 0x00800000; 1276 1277 /** 1278 * Internal {@link PackageInfo} flag: include only components that are exposed to 1279 * instant apps. Matched components may have been either explicitly or implicitly 1280 * exposed. 1281 * @hide 1282 */ 1283 public static final int MATCH_VISIBLE_TO_INSTANT_APP_ONLY = 0x01000000; 1284 1285 /** 1286 * Internal {@link PackageInfo} flag: include only components that have been 1287 * explicitly exposed to instant apps. 1288 * @hide 1289 */ 1290 public static final int MATCH_EXPLICITLY_VISIBLE_ONLY = 0x02000000; 1291 1292 /** 1293 * Internal {@link PackageInfo} flag: include static shared and SDK libraries. 1294 * Apps that depend on static shared/SDK libs can always access the version 1295 * of the lib they depend on. System/shell/root can access all shared 1296 * libs regardless of dependency but need to explicitly ask for them 1297 * via this flag. 1298 * @hide 1299 */ 1300 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 1301 public static final int MATCH_STATIC_SHARED_AND_SDK_LIBRARIES = 0x04000000; 1302 1303 /** 1304 * {@link PackageInfo} flag: return the signing certificates associated with 1305 * this package. Each entry is a signing certificate that the package 1306 * has proven it is authorized to use, usually a past signing certificate from 1307 * which it has rotated. 1308 */ 1309 public static final int GET_SIGNING_CERTIFICATES = 0x08000000; 1310 1311 /** 1312 * Querying flag: automatically match components based on their Direct Boot 1313 * awareness and the current user state. 1314 * <p> 1315 * Since the default behavior is to automatically apply the current user 1316 * state, this is effectively a sentinel value that doesn't change the 1317 * output of any queries based on its presence or absence. 1318 * <p> 1319 * Instead, this value can be useful in conjunction with 1320 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()} 1321 * to detect when a caller is relying on implicit automatic matching, 1322 * instead of confirming the explicit behavior they want, using a 1323 * combination of these flags: 1324 * <ul> 1325 * <li>{@link #MATCH_DIRECT_BOOT_AWARE} 1326 * <li>{@link #MATCH_DIRECT_BOOT_UNAWARE} 1327 * <li>{@link #MATCH_DIRECT_BOOT_AUTO} 1328 * </ul> 1329 */ 1330 public static final int MATCH_DIRECT_BOOT_AUTO = 0x10000000; 1331 1332 /** @hide */ 1333 @Deprecated 1334 public static final int MATCH_DEBUG_TRIAGED_MISSING = MATCH_DIRECT_BOOT_AUTO; 1335 1336 /** 1337 * @deprecated Use {@link #MATCH_CLONE_PROFILE_LONG} instead. 1338 * 1339 * @hide 1340 */ 1341 @Deprecated 1342 @SystemApi 1343 public static final int MATCH_CLONE_PROFILE = 0x20000000; 1344 1345 /** 1346 * {@link PackageInfo} flag: include system apps that are in the uninstalled state and have 1347 * been set to be hidden until installed via {@link #setSystemAppState}. 1348 * @hide 1349 */ 1350 @SystemApi 1351 public static final int MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS = 0x20000000; 1352 1353 /** 1354 * {@link PackageInfo} flag: include APEX packages that are currently 1355 * installed. In APEX terminology, this corresponds to packages that are 1356 * currently active, i.e. mounted and available to other processes of the OS. 1357 * In particular, this flag alone will not match APEX files that are staged 1358 * for activation at next reboot. 1359 */ 1360 public static final int MATCH_APEX = 0x40000000; 1361 1362 /** 1363 * @deprecated Use {@link #GET_ATTRIBUTIONS_LONG} to avoid unintended sign extension. 1364 */ 1365 @Deprecated 1366 public static final int GET_ATTRIBUTIONS = 0x80000000; 1367 1368 /** 1369 * {@link PackageInfo} flag: return all attributions declared in the package manifest 1370 */ 1371 public static final long GET_ATTRIBUTIONS_LONG = 0x80000000L; 1372 1373 /** 1374 * Flag parameter to also retrieve some information about archived packages. 1375 * Packages can be archived through {@link PackageInstaller#requestArchive} and do not have any 1376 * APKs stored on the device, but do keep the data directory. 1377 * <p> Note: Archived apps are a subset of apps returned by {@link #MATCH_UNINSTALLED_PACKAGES}. 1378 * <p> Note: this flag may cause less information about currently installed 1379 * applications to be returned. 1380 * <p> Note: use of this flag requires the android.permission.QUERY_ALL_PACKAGES 1381 * permission to see uninstalled packages. 1382 */ 1383 @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING) 1384 public static final long MATCH_ARCHIVED_PACKAGES = 1L << 32; 1385 1386 /** 1387 * Querying flag: always match components of packages in quarantined state. 1388 * @see #isPackageQuarantined 1389 */ 1390 @FlaggedApi(android.content.pm.Flags.FLAG_QUARANTINED_ENABLED) 1391 public static final long MATCH_QUARANTINED_COMPONENTS = 1L << 33; 1392 1393 /** 1394 * {@link ResolveInfo} flag: allow matching components across clone profile 1395 * <p> 1396 * This flag is used only for query and not resolution, the default behaviour would be to 1397 * restrict querying across clone profile. This flag would be honored only if caller have 1398 * permission {@link Manifest.permission.QUERY_CLONED_APPS}. 1399 * 1400 * @hide 1401 */ 1402 @FlaggedApi(android.content.pm.Flags.FLAG_FIX_DUPLICATED_FLAGS) 1403 @SystemApi 1404 public static final long MATCH_CLONE_PROFILE_LONG = 1L << 34; 1405 1406 //------------------------------------------------------------------------- 1407 // End of GET_ and MATCH_ flags 1408 //------------------------------------------------------------------------- 1409 1410 /** 1411 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when 1412 * resolving an intent that matches the {@code CrossProfileIntentFilter}, 1413 * the current profile will be skipped. Only activities in the target user 1414 * can respond to the intent. 1415 * 1416 * @hide 1417 */ 1418 public static final int SKIP_CURRENT_PROFILE = 0x00000002; 1419 1420 /** 1421 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: 1422 * activities in the other profiles can respond to the intent only if no activity with 1423 * non-negative priority in current profile can respond to the intent. 1424 * @hide 1425 */ 1426 public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004; 1427 1428 /** @hide */ 1429 @IntDef(flag = true, prefix = { "MODULE_" }, value = { 1430 MODULE_APEX_NAME, 1431 }) 1432 @Retention(RetentionPolicy.SOURCE) 1433 public @interface ModuleInfoFlags {} 1434 1435 /** 1436 * Flag for {@link #getModuleInfo}: allow ModuleInfo to be retrieved using the apex module 1437 * name, rather than the package name. 1438 * 1439 * @hide 1440 */ 1441 @SystemApi 1442 public static final int MODULE_APEX_NAME = 0x00000001; 1443 1444 /** @hide */ 1445 @IntDef(prefix = { "PERMISSION_" }, value = { 1446 PERMISSION_GRANTED, 1447 PERMISSION_DENIED 1448 }) 1449 @Retention(RetentionPolicy.SOURCE) 1450 public @interface PermissionResult {} 1451 1452 /** 1453 * Permission check result: this is returned by {@link #checkPermission} 1454 * if the permission has been granted to the given package. 1455 */ 1456 public static final int PERMISSION_GRANTED = 0; 1457 1458 /** 1459 * Permission check result: this is returned by {@link #checkPermission} 1460 * if the permission has not been granted to the given package. 1461 */ 1462 public static final int PERMISSION_DENIED = -1; 1463 1464 /** @hide */ 1465 @IntDef(prefix = { "SIGNATURE_" }, value = { 1466 SIGNATURE_MATCH, 1467 SIGNATURE_NEITHER_SIGNED, 1468 SIGNATURE_FIRST_NOT_SIGNED, 1469 SIGNATURE_SECOND_NOT_SIGNED, 1470 SIGNATURE_NO_MATCH, 1471 SIGNATURE_UNKNOWN_PACKAGE, 1472 }) 1473 @Retention(RetentionPolicy.SOURCE) 1474 public @interface SignatureResult {} 1475 1476 /** 1477 * Signature check result: this is returned by {@link #checkSignatures} 1478 * if all signatures on the two packages match. 1479 */ 1480 public static final int SIGNATURE_MATCH = 0; 1481 1482 /** 1483 * Signature check result: this is returned by {@link #checkSignatures} 1484 * if neither of the two packages is signed. 1485 */ 1486 public static final int SIGNATURE_NEITHER_SIGNED = 1; 1487 1488 /** 1489 * Signature check result: this is returned by {@link #checkSignatures} 1490 * if the first package is not signed but the second is. 1491 */ 1492 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1; 1493 1494 /** 1495 * Signature check result: this is returned by {@link #checkSignatures} 1496 * if the second package is not signed but the first is. 1497 */ 1498 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2; 1499 1500 /** 1501 * Signature check result: this is returned by {@link #checkSignatures} 1502 * if not all signatures on both packages match. 1503 */ 1504 public static final int SIGNATURE_NO_MATCH = -3; 1505 1506 /** 1507 * Signature check result: this is returned by {@link #checkSignatures} 1508 * if either of the packages are not valid. 1509 */ 1510 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; 1511 1512 /** @hide */ 1513 @IntDef(prefix = { "COMPONENT_ENABLED_STATE_" }, value = { 1514 COMPONENT_ENABLED_STATE_DEFAULT, 1515 COMPONENT_ENABLED_STATE_ENABLED, 1516 COMPONENT_ENABLED_STATE_DISABLED, 1517 COMPONENT_ENABLED_STATE_DISABLED_USER, 1518 COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED, 1519 }) 1520 @Retention(RetentionPolicy.SOURCE) 1521 public @interface EnabledState {} 1522 1523 /** 1524 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and 1525 * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 1526 * component or application is in its default enabled state (as specified in 1527 * its manifest). 1528 * <p> 1529 * Explicitly setting the component state to this value restores it's 1530 * enabled state to whatever is set in the manifest. 1531 */ 1532 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; 1533 1534 /** 1535 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 1536 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 1537 * component or application has been explictily enabled, regardless of 1538 * what it has specified in its manifest. 1539 */ 1540 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; 1541 1542 /** 1543 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 1544 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 1545 * component or application has been explicitly disabled, regardless of 1546 * what it has specified in its manifest. 1547 */ 1548 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; 1549 1550 /** 1551 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The 1552 * user has explicitly disabled the application, regardless of what it has 1553 * specified in its manifest. Because this is due to the user's request, 1554 * they may re-enable it if desired through the appropriate system UI. This 1555 * option currently <strong>cannot</strong> be used with 1556 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 1557 */ 1558 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; 1559 1560 /** 1561 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This 1562 * application should be considered, until the point where the user actually 1563 * wants to use it. This means that it will not normally show up to the user 1564 * (such as in the launcher), but various parts of the user interface can 1565 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow 1566 * the user to select it (as for example an IME, device admin, etc). Such code, 1567 * once the user has selected the app, should at that point also make it enabled. 1568 * This option currently <strong>can not</strong> be used with 1569 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 1570 */ 1571 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4; 1572 1573 /** @hide */ 1574 @Retention(RetentionPolicy.SOURCE) 1575 @IntDef(prefix = { "ROLLBACK_DATA_POLICY_" }, value = { 1576 ROLLBACK_DATA_POLICY_RESTORE, 1577 ROLLBACK_DATA_POLICY_WIPE, 1578 ROLLBACK_DATA_POLICY_RETAIN 1579 }) 1580 public @interface RollbackDataPolicy {} 1581 1582 /** 1583 * User data will be backed up during install and restored during rollback. 1584 * 1585 * @hide 1586 */ 1587 @SystemApi 1588 public static final int ROLLBACK_DATA_POLICY_RESTORE = 0; 1589 1590 /** 1591 * User data won't be backed up during install but will be wiped out during rollback. 1592 * 1593 * @hide 1594 */ 1595 @SystemApi 1596 public static final int ROLLBACK_DATA_POLICY_WIPE = 1; 1597 1598 /** 1599 * User data won't be backed up during install and will remain unchanged during rollback. 1600 * 1601 * @hide 1602 */ 1603 @SystemApi 1604 public static final int ROLLBACK_DATA_POLICY_RETAIN = 2; 1605 1606 /** @hide */ 1607 @IntDef(prefix = {"ROLLBACK_USER_IMPACT_"}, value = { 1608 ROLLBACK_USER_IMPACT_LOW, 1609 ROLLBACK_USER_IMPACT_HIGH, 1610 ROLLBACK_USER_IMPACT_ONLY_MANUAL, 1611 }) 1612 @Retention(RetentionPolicy.SOURCE) 1613 public @interface RollbackImpactLevel {} 1614 1615 /** 1616 * Rollback will be performed automatically in response to native crashes on startup or 1617 * persistent service crashes. More suitable for apps that do not store any user data. 1618 * 1619 * @hide 1620 */ 1621 @SystemApi 1622 public static final int ROLLBACK_USER_IMPACT_LOW = 0; 1623 1624 /** 1625 * Rollback will be performed automatically only when the device is found to be unrecoverable. 1626 * More suitable for apps that store user data and have higher impact on user. 1627 * 1628 * @hide 1629 */ 1630 @SystemApi 1631 public static final int ROLLBACK_USER_IMPACT_HIGH = 1; 1632 1633 /** 1634 * Rollback will not be performed automatically. It can be triggered externally. 1635 * 1636 * @hide 1637 */ 1638 @SystemApi 1639 public static final int ROLLBACK_USER_IMPACT_ONLY_MANUAL = 2; 1640 1641 /** @hide */ 1642 @IntDef(flag = true, prefix = { "INSTALL_" }, value = { 1643 INSTALL_REPLACE_EXISTING, 1644 INSTALL_ALLOW_TEST, 1645 INSTALL_INTERNAL, 1646 INSTALL_FROM_ADB, 1647 INSTALL_ALL_USERS, 1648 INSTALL_REQUEST_DOWNGRADE, 1649 INSTALL_GRANT_ALL_REQUESTED_PERMISSIONS, 1650 INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS, 1651 INSTALL_FORCE_VOLUME_UUID, 1652 INSTALL_FORCE_PERMISSION_PROMPT, 1653 INSTALL_INSTANT_APP, 1654 INSTALL_DONT_KILL_APP, 1655 INSTALL_FULL_APP, 1656 INSTALL_ALLOCATE_AGGRESSIVE, 1657 INSTALL_VIRTUAL_PRELOAD, 1658 INSTALL_APEX, 1659 INSTALL_ENABLE_ROLLBACK, 1660 INSTALL_ALLOW_DOWNGRADE, 1661 INSTALL_STAGED, 1662 INSTALL_REQUEST_UPDATE_OWNERSHIP, 1663 INSTALL_IGNORE_DEXOPT_PROFILE, 1664 INSTALL_UNARCHIVE_DRAFT, 1665 INSTALL_UNARCHIVE, 1666 }) 1667 @Retention(RetentionPolicy.SOURCE) 1668 public @interface InstallFlags {} 1669 1670 /** 1671 * Install flags that can only be used in development workflows (e.g. {@code adb install}). 1672 * @hide 1673 */ 1674 @IntDef(flag = true, prefix = { "INSTALL_DEVELOPMENT_" }, value = { 1675 INSTALL_DEVELOPMENT_FORCE_NON_STAGED_APEX_UPDATE, 1676 }) 1677 @Retention(RetentionPolicy.SOURCE) 1678 public @interface DevelopmentInstallFlags {} 1679 1680 /** 1681 * Flag parameter for {@link #installPackage} to indicate that you want to 1682 * replace an already installed package, if one exists. 1683 * 1684 * @hide 1685 */ 1686 @UnsupportedAppUsage 1687 public static final int INSTALL_REPLACE_EXISTING = 0x00000002; 1688 1689 /** 1690 * Flag parameter for {@link #installPackage} to indicate that you want to 1691 * allow test packages (those that have set android:testOnly in their 1692 * manifest) to be installed. 1693 * @hide 1694 */ 1695 public static final int INSTALL_ALLOW_TEST = 0x00000004; 1696 1697 /** 1698 * Flag parameter for {@link #installPackage} to indicate that this package 1699 * must be installed to internal storage. 1700 * 1701 * @hide 1702 */ 1703 public static final int INSTALL_INTERNAL = 0x00000010; 1704 1705 /** 1706 * Flag parameter for {@link #installPackage} to indicate that this install 1707 * was initiated via ADB. 1708 * 1709 * @hide 1710 */ 1711 public static final int INSTALL_FROM_ADB = 0x00000020; 1712 1713 /** 1714 * Flag parameter for {@link #installPackage} to indicate that this install 1715 * should immediately be visible to all users. 1716 * 1717 * @hide 1718 */ 1719 public static final int INSTALL_ALL_USERS = 0x00000040; 1720 1721 /** 1722 * Flag parameter for {@link #installPackage} to indicate that an upgrade to a lower version 1723 * of a package than currently installed has been requested. 1724 * 1725 * <p>Note that this flag doesn't guarantee that downgrade will be performed. That decision 1726 * depends 1727 * on whenever: 1728 * <ul> 1729 * <li>An app is debuggable. 1730 * <li>Or a build is debuggable. 1731 * <li>Or {@link #INSTALL_ALLOW_DOWNGRADE} is set. 1732 * </ul> 1733 * 1734 * @hide 1735 */ 1736 public static final int INSTALL_REQUEST_DOWNGRADE = 0x00000080; 1737 1738 /** 1739 * Flag parameter for package install to indicate that all requested permissions should be 1740 * granted to the package. If {@link #INSTALL_ALL_USERS} is set the runtime permissions will 1741 * be granted to all users, otherwise only to the owner. 1742 * <p/> 1743 * If this flag is set, {@link SessionParams#setPermissionState(String, int)} should not be 1744 * called. 1745 * 1746 * @hide 1747 */ 1748 public static final int INSTALL_GRANT_ALL_REQUESTED_PERMISSIONS = 0x00000100; 1749 1750 /** {@hide} */ 1751 public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200; 1752 1753 /** 1754 * Flag parameter for {@link #installPackage} to indicate that we always want to force 1755 * the prompt for permission approval. This overrides any special behaviour for internal 1756 * components. 1757 * 1758 * @hide 1759 */ 1760 public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400; 1761 1762 /** 1763 * Flag parameter for {@link #installPackage} to indicate that this package is 1764 * to be installed as a lightweight "ephemeral" app. 1765 * 1766 * @hide 1767 */ 1768 public static final int INSTALL_INSTANT_APP = 0x00000800; 1769 1770 /** 1771 * Flag parameter for {@link #installPackage} to indicate that this package contains 1772 * a feature split to an existing application and the existing application should not 1773 * be killed during the installation process. 1774 * 1775 * @hide 1776 */ 1777 public static final int INSTALL_DONT_KILL_APP = 0x00001000; 1778 1779 /** 1780 * Flag parameter for {@link #installPackage} to indicate that this package is 1781 * to be installed as a heavy weight app. This is fundamentally the opposite of 1782 * {@link #INSTALL_INSTANT_APP}. 1783 * 1784 * @hide 1785 */ 1786 public static final int INSTALL_FULL_APP = 0x00004000; 1787 1788 /** 1789 * Flag parameter for {@link #installPackage} to indicate that this package 1790 * is critical to system health or security, meaning the system should use 1791 * {@link StorageManager#FLAG_ALLOCATE_AGGRESSIVE} internally. 1792 * 1793 * @hide 1794 */ 1795 public static final int INSTALL_ALLOCATE_AGGRESSIVE = 0x00008000; 1796 1797 /** 1798 * Flag parameter for {@link #installPackage} to indicate that this package 1799 * is a virtual preload. 1800 * 1801 * @hide 1802 */ 1803 public static final int INSTALL_VIRTUAL_PRELOAD = 0x00010000; 1804 1805 /** 1806 * Flag parameter for {@link #installPackage} to indicate that this package 1807 * is an APEX package 1808 * 1809 * @hide 1810 */ 1811 public static final int INSTALL_APEX = 0x00020000; 1812 1813 /** 1814 * Flag parameter for {@link #installPackage} to indicate that rollback 1815 * should be enabled for this install. 1816 * 1817 * @hide 1818 */ 1819 public static final int INSTALL_ENABLE_ROLLBACK = 0x00040000; 1820 1821 /** 1822 * Flag parameter for {@link #installPackage} to indicate that package verification should be 1823 * disabled for this package. 1824 * 1825 * @hide 1826 */ 1827 public static final int INSTALL_DISABLE_VERIFICATION = 0x00080000; 1828 1829 /** 1830 * Flag parameter for {@link #installPackage} to indicate that 1831 * {@link #INSTALL_REQUEST_DOWNGRADE} should be allowed. 1832 * 1833 * @hide 1834 */ 1835 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00100000; 1836 1837 /** 1838 * Flag parameter for {@link #installPackage} to indicate that this package 1839 * is being installed as part of a staged install. 1840 * 1841 * @hide 1842 */ 1843 public static final int INSTALL_STAGED = 0x00200000; 1844 1845 /** 1846 * Flag parameter for {@link #installPackage} to indicate that all restricted 1847 * permissions should be allowlisted. If {@link #INSTALL_ALL_USERS} 1848 * is set the restricted permissions will be allowlisted for all users, otherwise 1849 * only to the owner. 1850 * 1851 * <p> 1852 * <strong>Note: </strong>In retrospect it would have been preferred to use 1853 * more inclusive terminology when naming this API. Similar APIs added will 1854 * refrain from using the term "whitelist". 1855 * </p> 1856 * 1857 * @hide 1858 */ 1859 public static final int INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS = 0x00400000; 1860 1861 /** 1862 * Flag parameter for {@link #installPackage} to indicate that check whether given APEX can be 1863 * updated should be disabled for this install. 1864 * @hide 1865 */ 1866 public static final int INSTALL_DISABLE_ALLOWED_APEX_UPDATE_CHECK = 0x00800000; 1867 1868 /** 1869 * Flag parameter for {@link #installPackage} to bypass the low targer sdk version block 1870 * for this install. 1871 * 1872 * @hide 1873 */ 1874 public static final int INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK = 0x01000000; 1875 1876 /** 1877 * Flag parameter for {@link SessionParams} to indicate that the 1878 * update ownership enforcement is requested. 1879 * @hide 1880 */ 1881 public static final int INSTALL_REQUEST_UPDATE_OWNERSHIP = 1 << 25; 1882 1883 /** 1884 * Flag parameter for {@link PackageInstaller.SessionParams} to indicate that this 1885 * session is from a managed user or profile. 1886 * @hide 1887 */ 1888 public static final int INSTALL_FROM_MANAGED_USER_OR_PROFILE = 1 << 26; 1889 1890 /** 1891 * Flag parameter for {@link PackageInstaller.SessionParams} to indicate that this 1892 * session is for archived package installation. 1893 * @hide 1894 */ 1895 public static final int INSTALL_ARCHIVED = 1 << 27; 1896 1897 /** 1898 * If set, all dexopt profiles are ignored by dexopt during the installation, including the 1899 * profile in the DM file and the profile embedded in the APK file. If an invalid profile is 1900 * provided during installation, no warning will be reported by {@code adb install}. 1901 * 1902 * This option does not affect later dexopt operations (e.g., background dexopt and manual `pm 1903 * compile` invocations). 1904 * 1905 * @hide 1906 */ 1907 public static final int INSTALL_IGNORE_DEXOPT_PROFILE = 1 << 28; 1908 1909 /** 1910 * If set, then the session is a draft session created for an upcoming unarchival by its 1911 * installer. 1912 * 1913 * @see PackageInstaller#requestUnarchive 1914 * 1915 * @hide 1916 */ 1917 public static final int INSTALL_UNARCHIVE_DRAFT = 1 << 29; 1918 1919 /** 1920 * If set, then the {@link PackageInstaller.Session} is an unarchival. 1921 * 1922 * @see PackageInstaller#requestUnarchive 1923 * 1924 * @hide 1925 */ 1926 public static final int INSTALL_UNARCHIVE = 1 << 30; 1927 1928 /** 1929 * Flag parameter for {@link #installPackage} to force a non-staged update of an APEX. This is 1930 * a development-only feature and should not be used on end user devices. 1931 * 1932 * @hide 1933 */ 1934 public static final int INSTALL_DEVELOPMENT_FORCE_NON_STAGED_APEX_UPDATE = 1; 1935 1936 /** @hide */ 1937 @IntDef(flag = true, value = { 1938 DONT_KILL_APP, 1939 SYNCHRONOUS, 1940 }) 1941 @Retention(RetentionPolicy.SOURCE) 1942 public @interface EnabledFlags {} 1943 1944 /** 1945 * Flag parameter for 1946 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 1947 * that you don't want to kill the app containing the component. Be careful when you set this 1948 * since changing component states can make the containing application's behavior unpredictable. 1949 */ 1950 public static final int DONT_KILL_APP = 0x00000001; 1951 1952 /** 1953 * Flag parameter for 1954 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 1955 * that the given user's package restrictions state will be serialised to disk after the 1956 * component state has been updated. Note that this is synchronous disk access, so calls using 1957 * this flag should be run on a background thread. 1958 */ 1959 public static final int SYNCHRONOUS = 0x00000002; 1960 1961 /** @hide */ 1962 @IntDef(flag = true, value = { 1963 FLAG_SUSPEND_QUARANTINED, 1964 }) 1965 @Retention(RetentionPolicy.SOURCE) 1966 public @interface SuspendedFlags {} 1967 1968 /** 1969 * Flag parameter {@link #setPackagesSuspended(String[], boolean, PersistableBundle, 1970 * PersistableBundle, android.content.pm.SuspendDialogInfo, int)}: 1971 * Apps in this state not only appear suspended for all user visible purposes (eg, Launcher, 1972 * ShareSheet), but also individual components of the app can behave as disabled depending on 1973 * the importance of the calling app. 1974 * 1975 * @hide 1976 */ 1977 @SystemApi 1978 @FlaggedApi(android.content.pm.Flags.FLAG_QUARANTINED_ENABLED) 1979 public static final int FLAG_SUSPEND_QUARANTINED = 0x00000001; 1980 1981 /** @hide */ 1982 @IntDef(prefix = { "INSTALL_REASON_" }, value = { 1983 INSTALL_REASON_UNKNOWN, 1984 INSTALL_REASON_POLICY, 1985 INSTALL_REASON_DEVICE_RESTORE, 1986 INSTALL_REASON_DEVICE_SETUP, 1987 INSTALL_REASON_USER, 1988 INSTALL_REASON_ROLLBACK 1989 }) 1990 @Retention(RetentionPolicy.SOURCE) 1991 public @interface InstallReason {} 1992 1993 /** 1994 * Code indicating that the reason for installing this package is unknown. 1995 */ 1996 public static final int INSTALL_REASON_UNKNOWN = 0; 1997 1998 /** 1999 * Code indicating that this package was installed due to enterprise policy. 2000 */ 2001 public static final int INSTALL_REASON_POLICY = 1; 2002 2003 /** 2004 * Code indicating that this package was installed as part of restoring from another device. 2005 */ 2006 public static final int INSTALL_REASON_DEVICE_RESTORE = 2; 2007 2008 /** 2009 * Code indicating that this package was installed as part of device setup. 2010 */ 2011 public static final int INSTALL_REASON_DEVICE_SETUP = 3; 2012 2013 /** 2014 * Code indicating that the package installation was initiated by the user. 2015 */ 2016 public static final int INSTALL_REASON_USER = 4; 2017 2018 /** 2019 * Code indicating that the package installation was a rollback initiated by RollbackManager. 2020 * 2021 * @hide 2022 */ 2023 public static final int INSTALL_REASON_ROLLBACK = 5; 2024 2025 /** @hide */ 2026 @IntDef(prefix = { "INSTALL_SCENARIO_" }, value = { 2027 INSTALL_SCENARIO_DEFAULT, 2028 INSTALL_SCENARIO_FAST, 2029 INSTALL_SCENARIO_BULK, 2030 INSTALL_SCENARIO_BULK_SECONDARY, 2031 }) 2032 @Retention(RetentionPolicy.SOURCE) 2033 public @interface InstallScenario {} 2034 2035 /** 2036 * A value to indicate the lack of CUJ information, disabling all installation scenario logic. 2037 */ 2038 public static final int INSTALL_SCENARIO_DEFAULT = 0; 2039 2040 /** 2041 * Installation scenario providing the fastest "install button to launch" experience possible. 2042 */ 2043 public static final int INSTALL_SCENARIO_FAST = 1; 2044 2045 /** 2046 * Installation scenario indicating a bulk operation with the desired result of a fully 2047 * optimized application. If the system is busy or resources are scarce the system will 2048 * perform less work to avoid impacting system health. 2049 * 2050 * Examples of bulk installation scenarios might include device restore, background updates of 2051 * multiple applications, or user-triggered updates for all applications. 2052 * 2053 * The decision to use BULK or BULK_SECONDARY should be based on the desired user experience. 2054 * BULK_SECONDARY operations may take less time to complete but, when they do, will produce 2055 * less optimized applications. The device state (e.g. memory usage or battery status) should 2056 * not be considered when making this decision as those factors are taken into account by the 2057 * Package Manager when acting on the installation scenario. 2058 */ 2059 public static final int INSTALL_SCENARIO_BULK = 2; 2060 2061 /** 2062 * Installation scenario indicating a bulk operation that prioritizes minimal system health 2063 * impact over application optimization. The application may undergo additional optimization 2064 * if the system is idle and system resources are abundant. The more elements of a bulk 2065 * operation that are marked BULK_SECONDARY, the faster the entire bulk operation will be. 2066 * 2067 * See the comments for INSTALL_SCENARIO_BULK for more information. 2068 */ 2069 public static final int INSTALL_SCENARIO_BULK_SECONDARY = 3; 2070 2071 /** @hide */ 2072 @IntDef(prefix = { "UNINSTALL_REASON_" }, value = { 2073 UNINSTALL_REASON_UNKNOWN, 2074 UNINSTALL_REASON_USER_TYPE, 2075 }) 2076 @Retention(RetentionPolicy.SOURCE) 2077 public @interface UninstallReason {} 2078 2079 /** 2080 * Code indicating that the reason for uninstalling this package is unknown. 2081 * @hide 2082 */ 2083 public static final int UNINSTALL_REASON_UNKNOWN = 0; 2084 2085 /** 2086 * Code indicating that this package was uninstalled due to the type of user. 2087 * See UserSystemPackageInstaller 2088 * @hide 2089 */ 2090 public static final int UNINSTALL_REASON_USER_TYPE = 1; 2091 2092 /** 2093 * @hide 2094 */ 2095 public static final int INSTALL_UNKNOWN = 0; 2096 2097 /** 2098 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2099 * on success. 2100 * 2101 * @hide 2102 */ 2103 @SystemApi 2104 public static final int INSTALL_SUCCEEDED = 1; 2105 2106 /** 2107 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2108 * if the package is already installed. 2109 * 2110 * @hide 2111 */ 2112 @SystemApi 2113 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; 2114 2115 /** 2116 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2117 * if the package archive file is invalid. 2118 * 2119 * @hide 2120 */ 2121 @SystemApi 2122 public static final int INSTALL_FAILED_INVALID_APK = -2; 2123 2124 /** 2125 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2126 * if the URI passed in is invalid. 2127 * 2128 * @hide 2129 */ 2130 @SystemApi 2131 public static final int INSTALL_FAILED_INVALID_URI = -3; 2132 2133 /** 2134 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2135 * if the package manager service found that the device didn't have enough storage space to 2136 * install the app. 2137 * 2138 * @hide 2139 */ 2140 @SystemApi 2141 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; 2142 2143 /** 2144 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2145 * if a package is already installed with the same name. 2146 * 2147 * @hide 2148 */ 2149 @SystemApi 2150 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; 2151 2152 /** 2153 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2154 * if the requested shared user does not exist. 2155 * 2156 * @hide 2157 */ 2158 @SystemApi 2159 public static final int INSTALL_FAILED_NO_SHARED_USER = -6; 2160 2161 /** 2162 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2163 * if a previously installed package of the same name has a different signature than the new 2164 * package (and the old package's data was not removed). 2165 * 2166 * @hide 2167 */ 2168 @SystemApi 2169 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; 2170 2171 /** 2172 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2173 * if the new package is requested a shared user which is already installed on the device and 2174 * does not have matching signature. 2175 * 2176 * @hide 2177 */ 2178 @SystemApi 2179 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; 2180 2181 /** 2182 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2183 * if the new package uses a shared library that is not available. 2184 * 2185 * @hide 2186 */ 2187 @SystemApi 2188 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; 2189 2190 /** 2191 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2192 * when the package being replaced is a system app and the caller didn't provide the 2193 * {@link #DELETE_SYSTEM_APP} flag. 2194 * 2195 * @hide 2196 */ 2197 @SystemApi 2198 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; 2199 2200 /** 2201 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2202 * if the new package failed while optimizing and validating its dex files, either because there 2203 * was not enough storage or the validation failed. 2204 * 2205 * @hide 2206 */ 2207 @SystemApi 2208 public static final int INSTALL_FAILED_DEXOPT = -11; 2209 2210 /** 2211 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2212 * if the new package failed because the current SDK version is older than that required by the 2213 * package. 2214 * 2215 * @hide 2216 */ 2217 @SystemApi 2218 public static final int INSTALL_FAILED_OLDER_SDK = -12; 2219 2220 /** 2221 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2222 * if the new package failed because it contains a content provider with the same authority as a 2223 * provider already installed in the system. 2224 * 2225 * @hide 2226 */ 2227 @SystemApi 2228 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 2229 2230 /** 2231 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2232 * if the new package failed because the current SDK version is newer than that required by the 2233 * package. 2234 * 2235 * @hide 2236 */ 2237 @SystemApi 2238 public static final int INSTALL_FAILED_NEWER_SDK = -14; 2239 2240 /** 2241 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2242 * if the new package failed because it has specified that it is a test-only package and the 2243 * caller has not supplied the {@link #INSTALL_ALLOW_TEST} flag. 2244 * 2245 * @hide 2246 */ 2247 @SystemApi 2248 public static final int INSTALL_FAILED_TEST_ONLY = -15; 2249 2250 /** 2251 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2252 * if the package being installed contains native code, but none that is compatible with the 2253 * device's CPU_ABI. 2254 * 2255 * @hide 2256 */ 2257 @SystemApi 2258 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; 2259 2260 /** 2261 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2262 * if the new package uses a feature that is not available. 2263 * 2264 * @hide 2265 */ 2266 @SystemApi 2267 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 2268 2269 // ------ Errors related to sdcard 2270 /** 2271 * Installation return code: this is passed in the 2272 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if a secure container mount point couldn't be 2273 * accessed on external media. 2274 * 2275 * @hide 2276 */ 2277 @SystemApi 2278 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; 2279 2280 /** 2281 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2282 * if the new package couldn't be installed in the specified install location. 2283 * 2284 * @hide 2285 */ 2286 @SystemApi 2287 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; 2288 2289 /** 2290 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2291 * if the new package couldn't be installed in the specified install location because the media 2292 * is not available. 2293 * 2294 * @hide 2295 */ 2296 @SystemApi 2297 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; 2298 2299 /** 2300 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2301 * if the new package couldn't be installed because the verification timed out. 2302 * 2303 * @hide 2304 */ 2305 @SystemApi 2306 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; 2307 2308 /** 2309 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2310 * if the new package couldn't be installed because the verification did not succeed. 2311 * 2312 * @hide 2313 */ 2314 @SystemApi 2315 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; 2316 2317 /** 2318 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2319 * if the package changed from what the calling program expected. 2320 * 2321 * @hide 2322 */ 2323 @SystemApi 2324 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; 2325 2326 /** 2327 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2328 * if the new package is assigned a different UID than it previously held. 2329 * 2330 * @hide 2331 */ 2332 public static final int INSTALL_FAILED_UID_CHANGED = -24; 2333 2334 /** 2335 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2336 * if the new package has an older version code than the currently installed package. 2337 * 2338 * @hide 2339 */ 2340 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; 2341 2342 /** 2343 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2344 * if the old package has target SDK high enough to support runtime permission and the new 2345 * package has target SDK low enough to not support runtime permissions. 2346 * 2347 * @hide 2348 */ 2349 @SystemApi 2350 public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26; 2351 2352 /** 2353 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2354 * if the new package attempts to downgrade the target sandbox version of the app. 2355 * 2356 * @hide 2357 */ 2358 @SystemApi 2359 public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27; 2360 2361 /** 2362 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2363 * if the new package requires at least one split and it was not provided. 2364 * 2365 * @hide 2366 */ 2367 public static final int INSTALL_FAILED_MISSING_SPLIT = -28; 2368 2369 /** 2370 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2371 * if the new package targets a deprecated SDK version. 2372 * 2373 * @hide 2374 */ 2375 public static final int INSTALL_FAILED_DEPRECATED_SDK_VERSION = -29; 2376 2377 /** 2378 * Installation parse return code: this is passed in the 2379 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was given a path that is not a 2380 * file, or does not end with the expected '.apk' extension. 2381 * 2382 * @hide 2383 */ 2384 @SystemApi 2385 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; 2386 2387 /** 2388 * Installation parse return code: this is passed in the 2389 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was unable to retrieve the 2390 * AndroidManifest.xml file. 2391 * 2392 * @hide 2393 */ 2394 @SystemApi 2395 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; 2396 2397 /** 2398 * Installation parse return code: this is passed in the 2399 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered an unexpected 2400 * exception. 2401 * 2402 * @hide 2403 */ 2404 @SystemApi 2405 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; 2406 2407 /** 2408 * Installation parse return code: this is passed in the 2409 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any certificates in 2410 * the .apk. 2411 * 2412 * @hide 2413 */ 2414 @SystemApi 2415 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; 2416 2417 /** 2418 * Installation parse return code: this is passed in the 2419 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser found inconsistent certificates on 2420 * the files in the .apk. 2421 * 2422 * @hide 2423 */ 2424 @SystemApi 2425 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; 2426 2427 /** 2428 * Installation parse return code: this is passed in the 2429 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a 2430 * CertificateEncodingException in one of the files in the .apk. 2431 * 2432 * @hide 2433 */ 2434 @SystemApi 2435 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; 2436 2437 /** 2438 * Installation parse return code: this is passed in the 2439 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad or missing 2440 * package name in the manifest. 2441 * 2442 * @hide 2443 */ 2444 @SystemApi 2445 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; 2446 2447 /** 2448 * Installation parse return code: tthis is passed in the 2449 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad shared user id 2450 * name in the manifest. 2451 * 2452 * @hide 2453 */ 2454 @SystemApi 2455 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; 2456 2457 /** 2458 * Installation parse return code: this is passed in the 2459 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered some structural 2460 * problem in the manifest. 2461 * 2462 * @hide 2463 */ 2464 @SystemApi 2465 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; 2466 2467 /** 2468 * Installation parse return code: this is passed in the 2469 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any actionable tags 2470 * (instrumentation or application) in the manifest. 2471 * 2472 * @hide 2473 */ 2474 @SystemApi 2475 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 2476 2477 /** 2478 * Installation failed return code: this is passed in the 2479 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2480 * because of system issues. 2481 * 2482 * @hide 2483 */ 2484 @SystemApi 2485 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; 2486 2487 /** 2488 * Installation failed return code: this is passed in the 2489 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2490 * because the user is restricted from installing apps. 2491 * 2492 * @hide 2493 */ 2494 public static final int INSTALL_FAILED_USER_RESTRICTED = -111; 2495 2496 /** 2497 * Installation failed return code: this is passed in the 2498 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2499 * because it is attempting to define a permission that is already defined by some existing 2500 * package. 2501 * <p> 2502 * The package name of the app which has already defined the permission is passed to a 2503 * {@link PackageInstallObserver}, if any, as the {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string 2504 * extra; and the name of the permission being redefined is passed in the 2505 * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra. 2506 * 2507 * @hide 2508 */ 2509 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; 2510 2511 /** 2512 * Installation failed return code: this is passed in the 2513 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2514 * because its packaged native code did not match any of the ABIs supported by the system. 2515 * 2516 * @hide 2517 */ 2518 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113; 2519 2520 /** 2521 * Internal return code for NativeLibraryHelper methods to indicate that the package 2522 * being processed did not contain any native code. This is placed here only so that 2523 * it can belong to the same value space as the other install failure codes. 2524 * 2525 * @hide 2526 */ 2527 @UnsupportedAppUsage 2528 public static final int NO_NATIVE_LIBRARIES = -114; 2529 2530 /** {@hide} */ 2531 public static final int INSTALL_FAILED_ABORTED = -115; 2532 2533 /** 2534 * Installation failed return code: install type is incompatible with some other 2535 * installation flags supplied for the operation; or other circumstances such as trying 2536 * to upgrade a system app via an Incremental or instant app install. 2537 * @hide 2538 */ 2539 public static final int INSTALL_FAILED_SESSION_INVALID = -116; 2540 2541 /** 2542 * Installation parse return code: this is passed in the 2543 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the dex metadata file is invalid or 2544 * if there was no matching apk file for a dex metadata file. 2545 * 2546 * @hide 2547 */ 2548 public static final int INSTALL_FAILED_BAD_DEX_METADATA = -117; 2549 2550 /** 2551 * Installation parse return code: this is passed in the 2552 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if there is any signature problem. 2553 * 2554 * @hide 2555 */ 2556 public static final int INSTALL_FAILED_BAD_SIGNATURE = -118; 2557 2558 /** 2559 * Installation failed return code: a new staged session was attempted to be committed while 2560 * there is already one in-progress or new session has package that is already staged. 2561 * 2562 * @hide 2563 */ 2564 public static final int INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS = -119; 2565 2566 /** 2567 * Installation failed return code: one of the child sessions does not match the parent session 2568 * in respect to staged or rollback enabled parameters. 2569 * 2570 * @hide 2571 */ 2572 public static final int INSTALL_FAILED_MULTIPACKAGE_INCONSISTENCY = -120; 2573 2574 /** 2575 * Installation failed return code: the required installed version code 2576 * does not match the currently installed package version code. 2577 * 2578 * @hide 2579 */ 2580 public static final int INSTALL_FAILED_WRONG_INSTALLED_VERSION = -121; 2581 2582 /** 2583 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2584 * if the new package failed because it contains a request to use a process that was not 2585 * explicitly defined as part of its <processes> tag. 2586 * 2587 * @hide 2588 */ 2589 public static final int INSTALL_FAILED_PROCESS_NOT_DEFINED = -122; 2590 2591 /** 2592 * Installation failed return code: the {@code resources.arsc} of one of the APKs being 2593 * installed is compressed or not aligned on a 4-byte boundary. Resource tables that cannot be 2594 * memory mapped exert excess memory pressure on the system and drastically slow down 2595 * construction of {@link Resources} objects. 2596 * 2597 * @hide 2598 */ 2599 public static final int INSTALL_PARSE_FAILED_RESOURCES_ARSC_COMPRESSED = -124; 2600 2601 /** 2602 * Installation failed return code: the package was skipped and should be ignored. 2603 * 2604 * The reason for the skip is undefined. 2605 * @hide 2606 */ 2607 public static final int INSTALL_PARSE_FAILED_SKIPPED = -125; 2608 2609 /** 2610 * Installation failed return code: this is passed in the 2611 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2612 * because it is attempting to define a permission group that is already defined by some 2613 * existing package. 2614 * 2615 * @hide 2616 */ 2617 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION_GROUP = -126; 2618 2619 /** 2620 * Installation failed return code: this is passed in the 2621 * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package 2622 * because it is attempting to define a permission in a group that does not exists or that is 2623 * defined by an packages with an incompatible certificate. 2624 * 2625 * @hide 2626 */ 2627 public static final int INSTALL_FAILED_BAD_PERMISSION_GROUP = -127; 2628 2629 /** 2630 * Installation failed return code: an error occurred during the activation phase of this 2631 * session. 2632 * 2633 * @hide 2634 */ 2635 public static final int INSTALL_ACTIVATION_FAILED = -128; 2636 2637 /** 2638 * Installation failed return code: requesting user pre-approval is currently unavailable. 2639 * 2640 * @hide 2641 */ 2642 public static final int INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE = -129; 2643 2644 /** 2645 * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} 2646 * if the new package declares bad certificate digest for a shared library in the package 2647 * manifest. 2648 * 2649 * @hide 2650 */ 2651 public static final int INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST = -130; 2652 2653 /** 2654 * Installation failed return code: if the system failed to install the package that 2655 * {@link android.R.attr#multiArch} is true in its manifest because its packaged 2656 * native code did not match all of the natively ABIs supported by the system. 2657 * 2658 * @hide 2659 */ 2660 public static final int INSTALL_FAILED_MULTI_ARCH_NOT_MATCH_ALL_NATIVE_ABIS = -131; 2661 2662 /** 2663 * App minimum aspect ratio set by the user which will override app-defined aspect ratio. 2664 * 2665 * @hide 2666 */ 2667 @IntDef(prefix = { "USER_MIN_ASPECT_RATIO_" }, value = { 2668 USER_MIN_ASPECT_RATIO_UNSET, 2669 USER_MIN_ASPECT_RATIO_SPLIT_SCREEN, 2670 USER_MIN_ASPECT_RATIO_DISPLAY_SIZE, 2671 USER_MIN_ASPECT_RATIO_4_3, 2672 USER_MIN_ASPECT_RATIO_16_9, 2673 USER_MIN_ASPECT_RATIO_3_2, 2674 USER_MIN_ASPECT_RATIO_FULLSCREEN, 2675 USER_MIN_ASPECT_RATIO_APP_DEFAULT, 2676 }) 2677 @Retention(RetentionPolicy.SOURCE) 2678 public @interface UserMinAspectRatio {} 2679 2680 /** 2681 * No aspect ratio override has been set by user. 2682 * 2683 * @hide 2684 */ 2685 public static final int USER_MIN_ASPECT_RATIO_UNSET = 0; 2686 2687 /** 2688 * Aspect ratio override code: user forces app to split screen aspect ratio. This is adjusted to 2689 * half of the screen without the split screen divider. 2690 * 2691 * @hide 2692 */ 2693 public static final int USER_MIN_ASPECT_RATIO_SPLIT_SCREEN = 1; 2694 2695 /** 2696 * Aspect ratio override code: user forces app to the aspect ratio of the device display size. 2697 * This will be the portrait aspect ratio of the device if the app has fixed portrait 2698 * orientation or the landscape aspect ratio of the device if the app has fixed landscape 2699 * orientation. 2700 * 2701 * @hide 2702 */ 2703 public static final int USER_MIN_ASPECT_RATIO_DISPLAY_SIZE = 2; 2704 2705 /** 2706 * Aspect ratio override code: user forces app to 4:3 min aspect ratio 2707 * @hide 2708 */ 2709 public static final int USER_MIN_ASPECT_RATIO_4_3 = 3; 2710 2711 /** 2712 * Aspect ratio override code: user forces app to 16:9 min aspect ratio 2713 * @hide 2714 */ 2715 public static final int USER_MIN_ASPECT_RATIO_16_9 = 4; 2716 2717 /** 2718 * Aspect ratio override code: user forces app to 3:2 min aspect ratio 2719 * @hide 2720 */ 2721 public static final int USER_MIN_ASPECT_RATIO_3_2 = 5; 2722 2723 /** 2724 * Aspect ratio override code: user forces app to fullscreen 2725 * @hide 2726 */ 2727 public static final int USER_MIN_ASPECT_RATIO_FULLSCREEN = 6; 2728 2729 /** 2730 * Aspect ratio override code: user sets to app's default aspect ratio. 2731 * This resets both the user-forced aspect ratio, and the device manufacturer 2732 * per-app override {@link ActivityInfo#OVERRIDE_ANY_ORIENTATION_TO_USER}. 2733 * It is different from {@link #USER_MIN_ASPECT_RATIO_UNSET} as the latter may 2734 * apply the device manufacturer per-app orientation override if any, 2735 * @hide 2736 */ 2737 public static final int USER_MIN_ASPECT_RATIO_APP_DEFAULT = 7; 2738 2739 /** @hide */ 2740 @IntDef(flag = true, prefix = { "DELETE_" }, value = { 2741 DELETE_KEEP_DATA, 2742 DELETE_ALL_USERS, 2743 DELETE_SYSTEM_APP, 2744 DELETE_DONT_KILL_APP, 2745 DELETE_CHATTY, 2746 }) 2747 @Retention(RetentionPolicy.SOURCE) 2748 public @interface DeleteFlags {} 2749 2750 /** 2751 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the 2752 * package's data directory. 2753 * 2754 * @hide 2755 */ 2756 @SystemApi 2757 public static final int DELETE_KEEP_DATA = 0x00000001; 2758 2759 /** 2760 * Flag parameter for {@link #deletePackage} to indicate that you want the 2761 * package deleted for all users. 2762 * 2763 * @hide 2764 */ 2765 @SystemApi 2766 public static final int DELETE_ALL_USERS = 0x00000002; 2767 2768 /** 2769 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling 2770 * uninstall on a system that has been updated, then don't do the normal process 2771 * of uninstalling the update and rolling back to the older system version (which 2772 * needs to happen for all users); instead, just mark the app as uninstalled for 2773 * the current user. 2774 * 2775 * @hide 2776 */ 2777 public static final int DELETE_SYSTEM_APP = 0x00000004; 2778 2779 /** 2780 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling 2781 * uninstall on a package that is replaced to provide new feature splits, the 2782 * existing application should not be killed during the removal process. 2783 * 2784 * @hide 2785 */ 2786 public static final int DELETE_DONT_KILL_APP = 0x00000008; 2787 2788 /** 2789 * Flag parameter for {@link PackageInstaller#uninstall(VersionedPackage, int, IntentSender)} to 2790 * indicate that the deletion is an archival. This 2791 * flag is only for internal usage as part of 2792 * {@link PackageInstaller#requestArchive}. 2793 */ 2794 @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING) 2795 public static final int DELETE_ARCHIVE = 0x00000010; 2796 2797 /** 2798 * Flag parameter for {@link #deletePackage} to indicate that package deletion 2799 * should be chatty. 2800 * 2801 * @hide 2802 */ 2803 public static final int DELETE_CHATTY = 0x80000000; 2804 2805 /** 2806 * Return code for when package deletion succeeds. This is passed to the 2807 * {@link IPackageDeleteObserver} if the system succeeded in deleting the 2808 * package. 2809 * 2810 * @hide 2811 */ 2812 @SystemApi 2813 public static final int DELETE_SUCCEEDED = 1; 2814 2815 /** 2816 * Deletion failed return code: this is passed to the 2817 * {@link IPackageDeleteObserver} if the system failed to delete the package 2818 * for an unspecified reason. 2819 * 2820 * @hide 2821 */ 2822 @SystemApi 2823 public static final int DELETE_FAILED_INTERNAL_ERROR = -1; 2824 2825 /** 2826 * Deletion failed return code: this is passed to the 2827 * {@link IPackageDeleteObserver} if the system failed to delete the package 2828 * because it is the active DevicePolicy manager. 2829 * 2830 * @hide 2831 */ 2832 @SystemApi 2833 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; 2834 2835 /** 2836 * Deletion failed return code: this is passed to the 2837 * {@link IPackageDeleteObserver} if the system failed to delete the package 2838 * since the user is restricted. 2839 * 2840 * @hide 2841 */ 2842 public static final int DELETE_FAILED_USER_RESTRICTED = -3; 2843 2844 /** 2845 * Deletion failed return code: this is passed to the 2846 * {@link IPackageDeleteObserver} if the system failed to delete the package 2847 * because a profile or device owner has marked the package as 2848 * uninstallable. 2849 * 2850 * @hide 2851 */ 2852 @SystemApi 2853 public static final int DELETE_FAILED_OWNER_BLOCKED = -4; 2854 2855 /** {@hide} */ 2856 @SystemApi 2857 public static final int DELETE_FAILED_ABORTED = -5; 2858 2859 /** 2860 * Deletion failed return code: this is passed to the 2861 * {@link IPackageDeleteObserver} if the system failed to delete the package 2862 * because the packge is a shared library used by other installed packages. 2863 * {@hide} */ 2864 public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6; 2865 2866 /** 2867 * Deletion failed return code: this is passed to the 2868 * {@link IPackageDeleteObserver} if the system failed to delete the package 2869 * because there is an app pinned. 2870 * 2871 * @hide 2872 */ 2873 public static final int DELETE_FAILED_APP_PINNED = -7; 2874 2875 /** 2876 * Deletion failed return code: this is passed to the 2877 * {@link IPackageDeleteObserver} if the system failed to delete the package 2878 * for any child profile with {@link UserProperties#getDeleteAppWithParent()} as true. 2879 * @hide 2880 */ 2881 public static final int DELETE_FAILED_FOR_CHILD_PROFILE = -8; 2882 2883 /** 2884 * Return code that is passed to the {@link IPackageMoveObserver} when the 2885 * package has been successfully moved by the system. 2886 * 2887 * @hide 2888 */ 2889 public static final int MOVE_SUCCEEDED = -100; 2890 2891 /** 2892 * Error code that is passed to the {@link IPackageMoveObserver} when the 2893 * package hasn't been successfully moved by the system because of 2894 * insufficient memory on specified media. 2895 * 2896 * @hide 2897 */ 2898 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1; 2899 2900 /** 2901 * Error code that is passed to the {@link IPackageMoveObserver} if the 2902 * specified package doesn't exist. 2903 * 2904 * @hide 2905 */ 2906 public static final int MOVE_FAILED_DOESNT_EXIST = -2; 2907 2908 /** 2909 * Error code that is passed to the {@link IPackageMoveObserver} if the 2910 * specified package cannot be moved since its a system package. 2911 * 2912 * @hide 2913 */ 2914 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3; 2915 2916 /** 2917 * Error code that is passed to the {@link IPackageMoveObserver} if the 2918 * specified package cannot be moved to the specified location. 2919 * 2920 * @hide 2921 */ 2922 public static final int MOVE_FAILED_INVALID_LOCATION = -5; 2923 2924 /** 2925 * Error code that is passed to the {@link IPackageMoveObserver} if the 2926 * specified package cannot be moved to the specified location. 2927 * 2928 * @hide 2929 */ 2930 public static final int MOVE_FAILED_INTERNAL_ERROR = -6; 2931 2932 /** 2933 * Error code that is passed to the {@link IPackageMoveObserver} if the 2934 * specified package already has an operation pending in the queue. 2935 * 2936 * @hide 2937 */ 2938 public static final int MOVE_FAILED_OPERATION_PENDING = -7; 2939 2940 /** 2941 * Error code that is passed to the {@link IPackageMoveObserver} if the 2942 * specified package cannot be moved since it contains a device admin. 2943 * 2944 * @hide 2945 */ 2946 public static final int MOVE_FAILED_DEVICE_ADMIN = -8; 2947 2948 /** 2949 * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow 2950 * non-system apps to be moved to internal storage. 2951 * 2952 * @hide 2953 */ 2954 public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9; 2955 2956 /** @hide */ 2957 public static final int MOVE_FAILED_LOCKED_USER = -10; 2958 2959 /** 2960 * Flag parameter for {@link #movePackage} to indicate that 2961 * the package should be moved to internal storage if its 2962 * been installed on external media. 2963 * @hide 2964 */ 2965 @Deprecated 2966 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2967 public static final int MOVE_INTERNAL = 0x00000001; 2968 2969 /** 2970 * Flag parameter for {@link #movePackage} to indicate that 2971 * the package should be moved to external media. 2972 * @hide 2973 */ 2974 @Deprecated 2975 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2976 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 2977 2978 /** {@hide} */ 2979 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID"; 2980 2981 /** 2982 * Extra field name for notifying package change event. Currently, it is used by PackageMonitor. 2983 * @hide 2984 */ 2985 public static final String EXTRA_PACKAGE_MONITOR_CALLBACK_RESULT = 2986 "android.content.pm.extra.EXTRA_PACKAGE_MONITOR_CALLBACK_RESULT"; 2987 2988 /** 2989 * Usable by the required verifier as the {@code verificationCode} argument 2990 * for {@link PackageManager#verifyPendingInstall} to indicate that it will 2991 * allow the installation to proceed without any of the optional verifiers 2992 * needing to vote. 2993 * 2994 * @hide 2995 */ 2996 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2; 2997 2998 /** 2999 * Used as the {@code verificationCode} argument for 3000 * {@link PackageManager#verifyPendingInstall} to indicate that the calling 3001 * package verifier allows the installation to proceed. 3002 */ 3003 public static final int VERIFICATION_ALLOW = 1; 3004 3005 /** 3006 * Used as the {@code verificationCode} argument for 3007 * {@link PackageManager#verifyPendingInstall} to indicate the calling 3008 * package verifier does not vote to allow the installation to proceed. 3009 */ 3010 public static final int VERIFICATION_REJECT = -1; 3011 3012 /** 3013 * Used as the {@code verificationCode} argument for 3014 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 3015 * IntentFilter Verifier confirms that the IntentFilter is verified. 3016 * 3017 * @deprecated Use {@link DomainVerificationManager} APIs. 3018 * @hide 3019 */ 3020 @Deprecated 3021 @SystemApi 3022 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1; 3023 3024 /** 3025 * Used as the {@code verificationCode} argument for 3026 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 3027 * IntentFilter Verifier confirms that the IntentFilter is NOT verified. 3028 * 3029 * @deprecated Use {@link DomainVerificationManager} APIs. 3030 * @hide 3031 */ 3032 @Deprecated 3033 @SystemApi 3034 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1; 3035 3036 /** 3037 * Internal status code to indicate that an IntentFilter verification result is not specified. 3038 * 3039 * @deprecated Use {@link DomainVerificationManager} APIs. 3040 * @hide 3041 */ 3042 @Deprecated 3043 @SystemApi 3044 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0; 3045 3046 /** 3047 * Used as the {@code status} argument for 3048 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 3049 * will always be prompted the Intent Disambiguation Dialog if there are two 3050 * or more Intent resolved for the IntentFilter's domain(s). 3051 * 3052 * @deprecated Use {@link DomainVerificationManager} APIs. 3053 * @hide 3054 */ 3055 @Deprecated 3056 @SystemApi 3057 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1; 3058 3059 /** 3060 * Used as the {@code status} argument for 3061 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 3062 * will never be prompted the Intent Disambiguation Dialog if there are two 3063 * or more resolution of the Intent. The default App for the domain(s) 3064 * specified in the IntentFilter will also ALWAYS be used. 3065 * 3066 * @deprecated Use {@link DomainVerificationManager} APIs. 3067 * @hide 3068 */ 3069 @Deprecated 3070 @SystemApi 3071 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2; 3072 3073 /** 3074 * Used as the {@code status} argument for 3075 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 3076 * may be prompted the Intent Disambiguation Dialog if there are two or more 3077 * Intent resolved. The default App for the domain(s) specified in the 3078 * IntentFilter will also NEVER be presented to the User. 3079 * 3080 * @deprecated Use {@link DomainVerificationManager} APIs. 3081 * @hide 3082 */ 3083 @Deprecated 3084 @SystemApi 3085 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3; 3086 3087 /** 3088 * Used as the {@code status} argument for 3089 * {@link #updateIntentVerificationStatusAsUser} to indicate that this app 3090 * should always be considered as an ambiguous candidate for handling the 3091 * matching Intent even if there are other candidate apps in the "always" 3092 * state. Put another way: if there are any 'always ask' apps in a set of 3093 * more than one candidate app, then a disambiguation is *always* presented 3094 * even if there is another candidate app with the 'always' state. 3095 * 3096 * @deprecated Use {@link DomainVerificationManager} APIs. 3097 * @hide 3098 */ 3099 @Deprecated 3100 @SystemApi 3101 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4; 3102 3103 3104 /** 3105 * Indicates that the app metadata does not exist or its source is unknown. 3106 * @hide 3107 */ 3108 @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE) 3109 @SystemApi 3110 public static final int APP_METADATA_SOURCE_UNKNOWN = 0; 3111 /** 3112 * Indicates that the app metadata is provided by the APK itself. 3113 * @hide 3114 */ 3115 @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE) 3116 @SystemApi 3117 public static final int APP_METADATA_SOURCE_APK = 1; 3118 /** 3119 * Indicates that the app metadata is provided by the installer that installed the app. 3120 * @hide 3121 */ 3122 @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE) 3123 @SystemApi 3124 public static final int APP_METADATA_SOURCE_INSTALLER = 2; 3125 /** 3126 * Indicates that the app metadata is provided as part of the system image. 3127 * @hide 3128 */ 3129 @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE) 3130 @SystemApi 3131 public static final int APP_METADATA_SOURCE_SYSTEM_IMAGE = 3; 3132 3133 /** @hide */ 3134 @IntDef(flag = true, prefix = { "APP_METADATA_SOURCE_" }, value = { 3135 APP_METADATA_SOURCE_UNKNOWN, 3136 APP_METADATA_SOURCE_APK, 3137 APP_METADATA_SOURCE_INSTALLER, 3138 APP_METADATA_SOURCE_SYSTEM_IMAGE, 3139 }) 3140 @Retention(RetentionPolicy.SOURCE) 3141 public @interface AppMetadataSource {} 3142 3143 /** 3144 * Can be used as the {@code millisecondsToDelay} argument for 3145 * {@link PackageManager#extendVerificationTimeout}. This is the 3146 * maximum time {@code PackageManager} waits for the verification 3147 * agent to return (in milliseconds). 3148 */ 3149 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000; 3150 3151 /** 3152 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's 3153 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or 3154 * lag in sound input or output. 3155 */ 3156 @SdkConstant(SdkConstantType.FEATURE) 3157 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; 3158 3159 /** 3160 * Feature for {@link #getSystemAvailableFeatures} and 3161 * {@link #hasSystemFeature}: The device includes at least one form of audio 3162 * output, as defined in the Android Compatibility Definition Document (CDD) 3163 * <a href="https://source.android.com/compatibility/android-cdd#7_8_audio">section 7.8 Audio</a>. 3164 */ 3165 @SdkConstant(SdkConstantType.FEATURE) 3166 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output"; 3167 3168 /** 3169 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3170 * The device has professional audio level of functionality and performance. 3171 */ 3172 @SdkConstant(SdkConstantType.FEATURE) 3173 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro"; 3174 3175 /** 3176 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature} 3177 * which indicates whether head tracking for spatial audio operates with low-latency, 3178 * as defined by the CDD criteria for the feature. 3179 * 3180 */ 3181 @SdkConstant(SdkConstantType.FEATURE) 3182 @FlaggedApi(FLAG_FEATURE_SPATIAL_AUDIO_HEADTRACKING_LOW_LATENCY) 3183 public static final String FEATURE_AUDIO_SPATIAL_HEADTRACKING_LOW_LATENCY = 3184 "android.hardware.audio.spatial.headtracking.low_latency"; 3185 3186 /** 3187 * Feature for {@link #getSystemAvailableFeatures} and 3188 * {@link #hasSystemFeature}: The device is capable of communicating with 3189 * other devices via Bluetooth. 3190 */ 3191 @SdkConstant(SdkConstantType.FEATURE) 3192 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 3193 3194 /** 3195 * Feature for {@link #getSystemAvailableFeatures} and 3196 * {@link #hasSystemFeature}: The device is capable of communicating with 3197 * other devices via Bluetooth Low Energy radio. 3198 */ 3199 @SdkConstant(SdkConstantType.FEATURE) 3200 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 3201 3202 /** 3203 * Feature for {@link #getSystemAvailableFeatures} and 3204 * {@link #hasSystemFeature}: The device is capable of ranging with 3205 * other devices using channel sounding via Bluetooth Low Energy radio. 3206 */ 3207 @FlaggedApi(com.android.ranging.flags.Flags.FLAG_RANGING_CS_ENABLED) 3208 @SdkConstant(SdkConstantType.FEATURE) 3209 public static final String FEATURE_BLUETOOTH_LE_CHANNEL_SOUNDING = 3210 "android.hardware.bluetooth_le.channel_sounding"; 3211 3212 /** 3213 * Feature for {@link #getSystemAvailableFeatures} and 3214 * {@link #hasSystemFeature}: The device has a camera facing away 3215 * from the screen. 3216 */ 3217 @SdkConstant(SdkConstantType.FEATURE) 3218 public static final String FEATURE_CAMERA = "android.hardware.camera"; 3219 3220 /** 3221 * Feature for {@link #getSystemAvailableFeatures} and 3222 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 3223 */ 3224 @SdkConstant(SdkConstantType.FEATURE) 3225 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 3226 3227 /** 3228 * Feature for {@link #getSystemAvailableFeatures} and 3229 * {@link #hasSystemFeature}: The device has at least one camera pointing in 3230 * some direction, or can support an external camera being connected to it. 3231 */ 3232 @SdkConstant(SdkConstantType.FEATURE) 3233 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 3234 3235 /** 3236 * Feature for {@link #getSystemAvailableFeatures} and 3237 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 3238 * The external camera may not always be connected or available to applications to use. 3239 */ 3240 @SdkConstant(SdkConstantType.FEATURE) 3241 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 3242 3243 /** 3244 * Feature for {@link #getSystemAvailableFeatures} and 3245 * {@link #hasSystemFeature}: The device's camera supports flash. 3246 */ 3247 @SdkConstant(SdkConstantType.FEATURE) 3248 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 3249 3250 /** 3251 * Feature for {@link #getSystemAvailableFeatures} and 3252 * {@link #hasSystemFeature}: The device has a front facing camera. 3253 */ 3254 @SdkConstant(SdkConstantType.FEATURE) 3255 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 3256 3257 /** 3258 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 3259 * of the cameras on the device supports the 3260 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 3261 * capability level. 3262 */ 3263 @SdkConstant(SdkConstantType.FEATURE) 3264 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 3265 3266 /** 3267 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 3268 * of the cameras on the device supports the 3269 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 3270 * capability level. 3271 */ 3272 @SdkConstant(SdkConstantType.FEATURE) 3273 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 3274 "android.hardware.camera.capability.manual_sensor"; 3275 3276 /** 3277 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 3278 * of the cameras on the device supports the 3279 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 3280 * capability level. 3281 */ 3282 @SdkConstant(SdkConstantType.FEATURE) 3283 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 3284 "android.hardware.camera.capability.manual_post_processing"; 3285 3286 /** 3287 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 3288 * of the cameras on the device supports the 3289 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 3290 * capability level. 3291 */ 3292 @SdkConstant(SdkConstantType.FEATURE) 3293 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 3294 "android.hardware.camera.capability.raw"; 3295 3296 /** 3297 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 3298 * of the cameras on the device supports the 3299 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING 3300 * MOTION_TRACKING} capability level. 3301 */ 3302 @SdkConstant(SdkConstantType.FEATURE) 3303 public static final String FEATURE_CAMERA_AR = 3304 "android.hardware.camera.ar"; 3305 3306 /** 3307 * Feature for {@link #getSystemAvailableFeatures} and 3308 * {@link #hasSystemFeature}: The device's main front and back cameras can stream 3309 * concurrently as described in {@link 3310 * android.hardware.camera2.CameraManager#getConcurrentCameraIds()}. 3311 * </p> 3312 * <p>While {@link android.hardware.camera2.CameraManager#getConcurrentCameraIds()} and 3313 * associated APIs are only available on API level 30 or newer, this feature flag may be 3314 * advertised by devices on API levels below 30. If present on such a device, the same 3315 * guarantees hold: The main front and main back camera can be used at the same time, with 3316 * guaranteed stream configurations as defined in the table for concurrent streaming at 3317 * {@link android.hardware.camera2.CameraDevice#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)}. 3318 * </p> 3319 */ 3320 @SdkConstant(SdkConstantType.FEATURE) 3321 public static final String FEATURE_CAMERA_CONCURRENT = "android.hardware.camera.concurrent"; 3322 3323 /** 3324 * Feature for {@link #getSystemAvailableFeatures} and 3325 * {@link #hasSystemFeature}: The device is capable of communicating with 3326 * consumer IR devices. 3327 */ 3328 @SdkConstant(SdkConstantType.FEATURE) 3329 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 3330 3331 /** 3332 * Feature for {@link #getSystemAvailableFeatures} and 3333 * {@link #hasSystemFeature}: The device supports a Context Hub, used to expose the 3334 * functionalities in {@link android.hardware.location.ContextHubManager}. 3335 * 3336 * @hide 3337 */ 3338 @SystemApi 3339 @SdkConstant(SdkConstantType.FEATURE) 3340 public static final String FEATURE_CONTEXT_HUB = "android.hardware.context_hub"; 3341 3342 /** {@hide} */ 3343 @SdkConstant(SdkConstantType.FEATURE) 3344 public static final String FEATURE_CTS = "android.software.cts"; 3345 3346 /** 3347 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3348 * is opted-in to render the application using Automotive App Host 3349 * 3350 * @hide 3351 */ 3352 @SdkConstant(SdkConstantType.FEATURE) 3353 public static final String FEATURE_CAR_TEMPLATES_HOST = 3354 "android.software.car.templates_host"; 3355 3356 /** 3357 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:If this 3358 * feature is supported, the device should also declare {@link #FEATURE_AUTOMOTIVE} and show 3359 * a UI that can display multiple tasks at the same time on a single display. The user can 3360 * perform multiple actions on different tasks simultaneously. Apps open in split screen mode 3361 * by default, instead of full screen. Unlike Android's multi-window mode, where users can 3362 * choose how to display apps, the device determines how apps are shown. 3363 * 3364 * @hide 3365 */ 3366 @SdkConstant(SdkConstantType.FEATURE) 3367 public static final String FEATURE_CAR_SPLITSCREEN_MULTITASKING = 3368 "android.software.car.splitscreen_multitasking"; 3369 3370 /** 3371 * Feature for {@link #getSystemAvailableFeatures} and 3372 * {@link #hasSystemFeature}: This device is capable of launching apps in automotive display 3373 * compatibility mode. 3374 * @hide 3375 */ 3376 @SdkConstant(SdkConstantType.FEATURE) 3377 public static final String FEATURE_CAR_DISPLAY_COMPATIBILITY = 3378 "android.software.car.display_compatibility"; 3379 3380 /** 3381 * Feature for {@link #getSystemAvailableFeatures} and 3382 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports 3383 * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware 3384 * at the given feature version. 3385 * 3386 * <p>Known feature versions include: 3387 * <ul> 3388 * <li><code>202009</code>: corresponds to the features included in the Identity Credential 3389 * API shipped in Android 11. 3390 * <li><code>202101</code>: corresponds to the features included in the Identity Credential 3391 * API shipped in Android 12. 3392 * <li><code>202201</code>: corresponds to the features included in the Identity Credential 3393 * API shipped in Android 13. 3394 * </ul> 3395 */ 3396 @SdkConstant(SdkConstantType.FEATURE) 3397 public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE = 3398 "android.hardware.identity_credential"; 3399 3400 /** 3401 * Feature for {@link #getSystemAvailableFeatures} and 3402 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports 3403 * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware 3404 * with direct access at the given feature version. 3405 * See {@link #FEATURE_IDENTITY_CREDENTIAL_HARDWARE} for known feature versions. 3406 */ 3407 @SdkConstant(SdkConstantType.FEATURE) 3408 public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE_DIRECT_ACCESS = 3409 "android.hardware.identity_credential_direct_access"; 3410 3411 /** 3412 * Feature for {@link #getSystemAvailableFeatures} and 3413 * {@link #hasSystemFeature}: The device supports one or more methods of 3414 * reporting current location. 3415 */ 3416 @SdkConstant(SdkConstantType.FEATURE) 3417 public static final String FEATURE_LOCATION = "android.hardware.location"; 3418 3419 /** 3420 * Feature for {@link #getSystemAvailableFeatures} and 3421 * {@link #hasSystemFeature}: The device has a Global Positioning System 3422 * receiver and can report precise location. 3423 */ 3424 @SdkConstant(SdkConstantType.FEATURE) 3425 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 3426 3427 /** 3428 * Feature for {@link #getSystemAvailableFeatures} and 3429 * {@link #hasSystemFeature}: The device can report location with coarse 3430 * accuracy using a network-based geolocation system. 3431 */ 3432 @SdkConstant(SdkConstantType.FEATURE) 3433 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 3434 3435 /** 3436 * Feature for {@link #getSystemAvailableFeatures} and 3437 * {@link #hasSystemFeature}: The device supports FeliCa communication, which is based on 3438 * ISO/IEC 18092 and JIS X 6319-4. 3439 * 3440 * @hide 3441 */ 3442 @SdkConstant(SdkConstantType.FEATURE) 3443 public static final String FEATURE_FELICA = "android.hardware.felica"; 3444 3445 /** 3446 * Feature for {@link #getSystemAvailableFeatures} and 3447 * {@link #hasSystemFeature}: The device's 3448 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns 3449 * true. 3450 */ 3451 @SdkConstant(SdkConstantType.FEATURE) 3452 public static final String FEATURE_RAM_LOW = "android.hardware.ram.low"; 3453 3454 /** 3455 * Feature for {@link #getSystemAvailableFeatures} and 3456 * {@link #hasSystemFeature}: The device's 3457 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns 3458 * false. 3459 */ 3460 @SdkConstant(SdkConstantType.FEATURE) 3461 public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal"; 3462 3463 /** 3464 * Feature for {@link #getSystemAvailableFeatures} and 3465 * {@link #hasSystemFeature}: The device can record audio via a 3466 * microphone. 3467 */ 3468 @SdkConstant(SdkConstantType.FEATURE) 3469 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 3470 3471 /** 3472 * Feature for {@link #getSystemAvailableFeatures} and 3473 * {@link #hasSystemFeature}: The device can communicate using Near-Field 3474 * Communications (NFC). 3475 */ 3476 @SdkConstant(SdkConstantType.FEATURE) 3477 public static final String FEATURE_NFC = "android.hardware.nfc"; 3478 3479 /** 3480 * Feature for {@link #getSystemAvailableFeatures} and 3481 * {@link #hasSystemFeature}: The device supports host- 3482 * based NFC card emulation. 3483 * 3484 * TODO remove when depending apps have moved to new constant. 3485 * @hide 3486 * @deprecated 3487 */ 3488 @Deprecated 3489 @SdkConstant(SdkConstantType.FEATURE) 3490 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 3491 3492 /** 3493 * Feature for {@link #getSystemAvailableFeatures} and 3494 * {@link #hasSystemFeature}: The device supports host- 3495 * based NFC card emulation. 3496 */ 3497 @SdkConstant(SdkConstantType.FEATURE) 3498 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 3499 3500 /** 3501 * Feature for {@link #getSystemAvailableFeatures} and 3502 * {@link #hasSystemFeature}: The device supports host- 3503 * based NFC-F card emulation. 3504 */ 3505 @SdkConstant(SdkConstantType.FEATURE) 3506 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef"; 3507 3508 /** 3509 * Feature for {@link #getSystemAvailableFeatures} and 3510 * {@link #hasSystemFeature}: The device supports uicc- 3511 * based NFC card emulation. 3512 */ 3513 @SdkConstant(SdkConstantType.FEATURE) 3514 public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC = 3515 "android.hardware.nfc.uicc"; 3516 3517 /** 3518 * Feature for {@link #getSystemAvailableFeatures} and 3519 * {@link #hasSystemFeature}: The device supports eSE- 3520 * based NFC card emulation. 3521 */ 3522 @SdkConstant(SdkConstantType.FEATURE) 3523 public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE = "android.hardware.nfc.ese"; 3524 3525 /** 3526 * Feature for {@link #getSystemAvailableFeatures} and 3527 * {@link #hasSystemFeature}: The device supports NFC charging. 3528 */ 3529 @SdkConstant(SdkConstantType.FEATURE) 3530 @FlaggedApi(android.nfc.Flags.FLAG_ENABLE_NFC_CHARGING) 3531 public static final String FEATURE_NFC_CHARGING = "android.hardware.nfc.charging"; 3532 3533 /** 3534 * Feature for {@link #getSystemAvailableFeatures} and 3535 * {@link #hasSystemFeature}: The Beam API is enabled on the device. 3536 */ 3537 @SdkConstant(SdkConstantType.FEATURE) 3538 public static final String FEATURE_NFC_BEAM = "android.sofware.nfc.beam"; 3539 3540 /** 3541 * Feature for {@link #getSystemAvailableFeatures} and 3542 * {@link #hasSystemFeature}: The device supports any 3543 * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION}, 3544 * {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF}, or {@link #FEATURE_NFC_CHARGING} features. 3545 * 3546 * @hide 3547 */ 3548 @SdkConstant(SdkConstantType.FEATURE) 3549 public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any"; 3550 3551 /** 3552 * Feature for {@link #getSystemAvailableFeatures} and 3553 * {@link #hasSystemFeature}: The device contains support for installing SDKs to a work 3554 * profile. 3555 * 3556 * @hide 3557 */ 3558 @SdkConstant(SdkConstantType.FEATURE) 3559 public static final String FEATURE_SDK_SANDBOX_WORK_PROFILE_INSTALL = 3560 "android.software.sdksandbox.sdk_install_work_profile"; 3561 3562 /** 3563 * Feature for {@link #getSystemAvailableFeatures} and 3564 * {@link #hasSystemFeature}: The device supports Open Mobile API capable UICC-based secure 3565 * elements. 3566 */ 3567 @SdkConstant(SdkConstantType.FEATURE) 3568 public static final String FEATURE_SE_OMAPI_UICC = "android.hardware.se.omapi.uicc"; 3569 3570 /** 3571 * Feature for {@link #getSystemAvailableFeatures} and 3572 * {@link #hasSystemFeature}: The device supports Open Mobile API capable eSE-based secure 3573 * elements. 3574 */ 3575 @SdkConstant(SdkConstantType.FEATURE) 3576 public static final String FEATURE_SE_OMAPI_ESE = "android.hardware.se.omapi.ese"; 3577 3578 /** 3579 * Feature for {@link #getSystemAvailableFeatures} and 3580 * {@link #hasSystemFeature}: The device supports Open Mobile API capable SD-based secure 3581 * elements. 3582 */ 3583 @SdkConstant(SdkConstantType.FEATURE) 3584 public static final String FEATURE_SE_OMAPI_SD = "android.hardware.se.omapi.sd"; 3585 3586 /** 3587 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device is 3588 * compatible with Android's security model. 3589 * 3590 * <p>See sections 2 and 9 in the 3591 * <a href="https://source.android.com/compatibility/android-cdd">Android CDD</a> for more 3592 * details. 3593 */ 3594 @SdkConstant(SdkConstantType.FEATURE) 3595 public static final String FEATURE_SECURITY_MODEL_COMPATIBLE = 3596 "android.hardware.security.model.compatible"; 3597 3598 /** 3599 * Feature for {@link #getSystemAvailableFeatures} and 3600 * {@link #hasSystemFeature}: The device supports the OpenGL ES 3601 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 3602 * Android Extension Pack</a>. 3603 */ 3604 @SdkConstant(SdkConstantType.FEATURE) 3605 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 3606 3607 /** 3608 * Feature for {@link #getSystemAvailableFeatures()} and {@link #hasSystemFeature(String)}. 3609 * This feature indicates whether device supports 3610 * <a href="https://source.android.com/docs/core/virtualization">Android Virtualization Framework</a>. 3611 * 3612 * @hide 3613 */ 3614 @SystemApi 3615 @SdkConstant(SdkConstantType.FEATURE) 3616 public static final String FEATURE_VIRTUALIZATION_FRAMEWORK = 3617 "android.software.virtualization_framework"; 3618 3619 /** 3620 * Feature for {@link #getSystemAvailableFeatures} and 3621 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 3622 * implementation on this device is hardware accelerated, and the Vulkan native API will 3623 * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what 3624 * level of optional hardware features limits it supports. 3625 * <p> 3626 * Level 0 includes the base Vulkan requirements as well as: 3627 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul> 3628 * <p> 3629 * Level 1 additionally includes: 3630 * <ul> 3631 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li> 3632 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li> 3633 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li> 3634 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li> 3635 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li> 3636 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li> 3637 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li> 3638 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li> 3639 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li> 3640 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li> 3641 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li> 3642 * </ul> 3643 */ 3644 @SdkConstant(SdkConstantType.FEATURE) 3645 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level"; 3646 3647 /** 3648 * Feature for {@link #getSystemAvailableFeatures} and 3649 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 3650 * implementation on this device is hardware accelerated, and the Vulkan native API will 3651 * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what 3652 * level of optional compute features that device supports beyond the Vulkan 1.0 requirements. 3653 * <p> 3654 * Compute level 0 indicates: 3655 * <ul> 3656 * <li>The {@code VK_KHR_variable_pointers} extension and 3657 * {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are 3658 supported.</li> 3659 * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li> 3660 * </ul> 3661 */ 3662 @SdkConstant(SdkConstantType.FEATURE) 3663 public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute"; 3664 3665 /** 3666 * Feature for {@link #getSystemAvailableFeatures} and 3667 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 3668 * implementation on this device is hardware accelerated, and the feature version will indicate 3669 * the highest {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices 3670 * that support the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The 3671 * feature version uses the same encoding as Vulkan version numbers: 3672 * <ul> 3673 * <li>Major version number in bits 31-22</li> 3674 * <li>Minor version number in bits 21-12</li> 3675 * <li>Patch version number in bits 11-0</li> 3676 * </ul> 3677 * A version of 1.1.0 or higher also indicates: 3678 * <ul> 3679 * <li>The {@code VK_ANDROID_external_memory_android_hardware_buffer} extension is 3680 * supported.</li> 3681 * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li> 3682 * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is 3683 * supported.</li> 3684 * </ul> 3685 * A subset of devices that support Vulkan 1.1 do so via software emulation. For more 3686 * information, see 3687 * <a href="{@docRoot}ndk/guides/graphics/design-notes">Vulkan Design Guidelines</a>. 3688 */ 3689 @SdkConstant(SdkConstantType.FEATURE) 3690 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version"; 3691 3692 /** 3693 * Feature for {@link #getSystemAvailableFeatures} and 3694 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version 3695 * specifies a date such that the device is known to pass the Vulkan dEQP test suite associated 3696 * with that date. The date is encoded as follows: 3697 * <ul> 3698 * <li>Year in bits 31-16</li> 3699 * <li>Month in bits 15-8</li> 3700 * <li>Day in bits 7-0</li> 3701 * </ul> 3702 * <p> 3703 * Example: 2019-03-01 is encoded as 0x07E30301, and would indicate that the device passes the 3704 * Vulkan dEQP test suite version that was current on 2019-03-01. 3705 */ 3706 @SdkConstant(SdkConstantType.FEATURE) 3707 public static final String FEATURE_VULKAN_DEQP_LEVEL = "android.software.vulkan.deqp.level"; 3708 3709 /** 3710 * Feature for {@link #getSystemAvailableFeatures} and 3711 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version 3712 * specifies a date such that the device is known to pass the OpenGLES dEQP test suite 3713 * associated with that date. The date is encoded as follows: 3714 * <ul> 3715 * <li>Year in bits 31-16</li> 3716 * <li>Month in bits 15-8</li> 3717 * <li>Day in bits 7-0</li> 3718 * </ul> 3719 * <p> 3720 * Example: 2021-03-01 is encoded as 0x07E50301, and would indicate that the device passes the 3721 * OpenGL ES dEQP test suite version that was current on 2021-03-01. 3722 */ 3723 @SdkConstant(SdkConstantType.FEATURE) 3724 public static final String FEATURE_OPENGLES_DEQP_LEVEL = "android.software.opengles.deqp.level"; 3725 3726 /** 3727 * Feature for {@link #getSystemAvailableFeatures} and 3728 * {@link #hasSystemFeature}: The device includes broadcast radio tuner. 3729 * @hide 3730 */ 3731 @SystemApi 3732 @SdkConstant(SdkConstantType.FEATURE) 3733 public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio"; 3734 3735 /** 3736 * Feature for {@link #getSystemAvailableFeatures} and 3737 * {@link #hasSystemFeature}: The device has a secure implementation of keyguard, meaning the 3738 * device supports PIN, pattern and password as defined in Android CDD 3739 */ 3740 @SdkConstant(SdkConstantType.FEATURE) 3741 public static final String FEATURE_SECURE_LOCK_SCREEN = "android.software.secure_lock_screen"; 3742 3743 /** 3744 * Feature for {@link #getSystemAvailableFeatures} and 3745 * {@link #hasSystemFeature}: The device includes an accelerometer. 3746 */ 3747 @SdkConstant(SdkConstantType.FEATURE) 3748 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 3749 3750 /** 3751 * Feature for {@link #getSystemAvailableFeatures} and 3752 * {@link #hasSystemFeature}: The device includes a barometer (air 3753 * pressure sensor.) 3754 */ 3755 @SdkConstant(SdkConstantType.FEATURE) 3756 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 3757 3758 /** 3759 * Feature for {@link #getSystemAvailableFeatures} and 3760 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 3761 */ 3762 @SdkConstant(SdkConstantType.FEATURE) 3763 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 3764 3765 /** 3766 * Feature for {@link #getSystemAvailableFeatures} and 3767 * {@link #hasSystemFeature}: The device includes a gyroscope. 3768 */ 3769 @SdkConstant(SdkConstantType.FEATURE) 3770 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 3771 3772 /** 3773 * Feature for {@link #getSystemAvailableFeatures} and 3774 * {@link #hasSystemFeature}: The device includes a limited axes accelerometer. 3775 */ 3776 @SdkConstant(SdkConstantType.FEATURE) 3777 public static final String FEATURE_SENSOR_ACCELEROMETER_LIMITED_AXES = 3778 "android.hardware.sensor.accelerometer_limited_axes"; 3779 3780 /** 3781 * Feature for {@link #getSystemAvailableFeatures} and 3782 * {@link #hasSystemFeature}: The device includes a limited axes gyroscope. 3783 */ 3784 @SdkConstant(SdkConstantType.FEATURE) 3785 public static final String FEATURE_SENSOR_GYROSCOPE_LIMITED_AXES = 3786 "android.hardware.sensor.gyroscope_limited_axes"; 3787 3788 /** 3789 * Feature for {@link #getSystemAvailableFeatures} and 3790 * {@link #hasSystemFeature}: The device includes an uncalibrated limited axes accelerometer. 3791 */ 3792 @SdkConstant(SdkConstantType.FEATURE) 3793 public static final String FEATURE_SENSOR_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED = 3794 "android.hardware.sensor.accelerometer_limited_axes_uncalibrated"; 3795 3796 /** 3797 * Feature for {@link #getSystemAvailableFeatures} and 3798 * {@link #hasSystemFeature}: The device includes an uncalibrated limited axes gyroscope. 3799 */ 3800 @SdkConstant(SdkConstantType.FEATURE) 3801 public static final String FEATURE_SENSOR_GYROSCOPE_LIMITED_AXES_UNCALIBRATED = 3802 "android.hardware.sensor.gyroscope_limited_axes_uncalibrated"; 3803 3804 /** 3805 * Feature for {@link #getSystemAvailableFeatures} and 3806 * {@link #hasSystemFeature}: The device includes a light sensor. 3807 */ 3808 @SdkConstant(SdkConstantType.FEATURE) 3809 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 3810 3811 /** 3812 * Feature for {@link #getSystemAvailableFeatures} and 3813 * {@link #hasSystemFeature}: The device includes a proximity sensor. 3814 */ 3815 @SdkConstant(SdkConstantType.FEATURE) 3816 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 3817 3818 /** 3819 * Feature for {@link #getSystemAvailableFeatures} and 3820 * {@link #hasSystemFeature}: The device includes a hardware step counter. 3821 */ 3822 @SdkConstant(SdkConstantType.FEATURE) 3823 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 3824 3825 /** 3826 * Feature for {@link #getSystemAvailableFeatures} and 3827 * {@link #hasSystemFeature}: The device includes a hardware step detector. 3828 */ 3829 @SdkConstant(SdkConstantType.FEATURE) 3830 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 3831 3832 /** 3833 * Feature for {@link #getSystemAvailableFeatures} and 3834 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 3835 */ 3836 @SdkConstant(SdkConstantType.FEATURE) 3837 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 3838 3839 /** 3840 * Feature for {@link #getSystemAvailableFeatures} and 3841 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram. 3842 */ 3843 @SdkConstant(SdkConstantType.FEATURE) 3844 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 3845 "android.hardware.sensor.heartrate.ecg"; 3846 3847 /** 3848 * Feature for {@link #getSystemAvailableFeatures} and 3849 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 3850 */ 3851 @SdkConstant(SdkConstantType.FEATURE) 3852 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 3853 "android.hardware.sensor.relative_humidity"; 3854 3855 /** 3856 * Feature for {@link #getSystemAvailableFeatures} and 3857 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 3858 */ 3859 @SdkConstant(SdkConstantType.FEATURE) 3860 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 3861 "android.hardware.sensor.ambient_temperature"; 3862 3863 /** 3864 * Feature for {@link #getSystemAvailableFeatures} and 3865 * {@link #hasSystemFeature}: The device includes a hinge angle sensor. 3866 */ 3867 @SdkConstant(SdkConstantType.FEATURE) 3868 public static final String FEATURE_SENSOR_HINGE_ANGLE = "android.hardware.sensor.hinge_angle"; 3869 3870 /** 3871 * Feature for {@link #getSystemAvailableFeatures} and 3872 * {@link #hasSystemFeature}: The device includes a heading sensor. 3873 */ 3874 @SdkConstant(SdkConstantType.FEATURE) 3875 public static final String FEATURE_SENSOR_HEADING = "android.hardware.sensor.heading"; 3876 3877 /** 3878 * Feature for {@link #getSystemAvailableFeatures} and 3879 * {@link #hasSystemFeature}: The device supports exposing head tracker sensors from peripheral 3880 * devices via the dynamic sensors API. 3881 */ 3882 @SdkConstant(SdkConstantType.FEATURE) 3883 public static final String FEATURE_SENSOR_DYNAMIC_HEAD_TRACKER = "android.hardware.sensor.dynamic.head_tracker"; 3884 3885 /** 3886 * Feature for {@link #getSystemAvailableFeatures} and 3887 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 3888 * capabilities. 3889 */ 3890 @SdkConstant(SdkConstantType.FEATURE) 3891 public static final String FEATURE_HIFI_SENSORS = 3892 "android.hardware.sensor.hifi_sensors"; 3893 3894 /** 3895 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3896 * The device supports a hardware mechanism for invoking an assist gesture. 3897 * @see android.provider.Settings.Secure#ASSIST_GESTURE_ENABLED 3898 * @hide 3899 */ 3900 @SdkConstant(SdkConstantType.FEATURE) 3901 public static final String FEATURE_ASSIST_GESTURE = "android.hardware.sensor.assist"; 3902 3903 /** 3904 * Feature for {@link #getSystemAvailableFeatures} and 3905 * {@link #hasSystemFeature}: The device has a telephony radio with data 3906 * communication support. 3907 */ 3908 @SdkConstant(SdkConstantType.FEATURE) 3909 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 3910 3911 /** 3912 * Feature for {@link #getSystemAvailableFeatures} and 3913 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 3914 * 3915 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined. 3916 */ 3917 @SdkConstant(SdkConstantType.FEATURE) 3918 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 3919 3920 /** 3921 * Feature for {@link #getSystemAvailableFeatures} and 3922 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 3923 * 3924 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined. 3925 */ 3926 @SdkConstant(SdkConstantType.FEATURE) 3927 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 3928 3929 /** 3930 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3931 * The device supports telephony carrier restriction mechanism. 3932 * 3933 * <p>Devices declaring this feature must have an implementation of the 3934 * {@link android.telephony.TelephonyManager#getAllowedCarriers} and 3935 * {@link android.telephony.TelephonyManager#setAllowedCarriers}. 3936 * 3937 * This feature should only be defined if {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 3938 * has been defined. 3939 * @hide 3940 */ 3941 @SystemApi 3942 @SdkConstant(SdkConstantType.FEATURE) 3943 public static final String FEATURE_TELEPHONY_CARRIERLOCK = 3944 "android.hardware.telephony.carrierlock"; 3945 3946 /** 3947 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3948 * supports embedded subscriptions on eUICCs. 3949 * 3950 * This feature should only be defined if {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 3951 * has been defined. 3952 */ 3953 @SdkConstant(SdkConstantType.FEATURE) 3954 public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc"; 3955 3956 /** 3957 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3958 * supports multiple enabled profiles on eUICCs. 3959 * 3960 * <p>Devices declaring this feature must have an implementation of the 3961 * {@link UiccCardInfo#getPorts}, 3962 * {@link UiccCardInfo#isMultipleEnabledProfilesSupported} and 3963 * {@link android.telephony.euicc.EuiccManager#switchToSubscription (with portIndex)}. 3964 * 3965 * This feature should only be defined if {@link #FEATURE_TELEPHONY_EUICC} have been defined. 3966 */ 3967 @SdkConstant(SdkConstantType.FEATURE) 3968 public static final String FEATURE_TELEPHONY_EUICC_MEP = "android.hardware.telephony.euicc.mep"; 3969 3970 /** 3971 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3972 * supports cell-broadcast reception using the MBMS APIs. 3973 * 3974 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 3975 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined. 3976 */ 3977 @SdkConstant(SdkConstantType.FEATURE) 3978 public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms"; 3979 3980 /** 3981 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3982 * supports attaching to IMS implementations using the ImsService API in telephony. 3983 * 3984 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_DATA} has been defined. 3985 */ 3986 @SdkConstant(SdkConstantType.FEATURE) 3987 public static final String FEATURE_TELEPHONY_IMS = "android.hardware.telephony.ims"; 3988 3989 /** 3990 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 3991 * supports a single IMS registration as defined by carrier networks in the IMS service 3992 * implementation using the {@link ImsService} API, {@link GbaService} API, and IRadio 1.6 HAL. 3993 * <p> 3994 * When set, the device must fully support the following APIs for an application to implement 3995 * IMS single registration: 3996 * <ul> 3997 * <li> Updating RCS provisioning status using the {@link ProvisioningManager} API to supply an 3998 * RCC.14 defined XML and notify IMS applications of Auto Configuration Server (ACS) or 3999 * proprietary server provisioning updates.</li> 4000 * <li>Opening a delegate in the device IMS service to forward SIP traffic to the carrier's 4001 * network using the {@link SipDelegateManager} API</li> 4002 * <li>Listening to EPS dedicated bearer establishment via the 4003 * {@link ConnectivityManager#registerQosCallback} 4004 * API to indicate to the application when to start/stop media traffic.</li> 4005 * <li>Implementing Generic Bootstrapping Architecture (GBA) and providing the associated 4006 * authentication keys to applications 4007 * requesting this information via the {@link TelephonyManager#bootstrapAuthenticationRequest} 4008 * API</li> 4009 * <li>Implementing RCS User Capability Exchange using the {@link RcsUceAdapter} API</li> 4010 * </ul> 4011 * <p> 4012 * This feature should only be defined if {@link #FEATURE_TELEPHONY_IMS} is also defined. 4013 * @hide 4014 */ 4015 @SystemApi 4016 @SdkConstant(SdkConstantType.FEATURE) 4017 public static final String FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION = 4018 "android.hardware.telephony.ims.singlereg"; 4019 4020 /** 4021 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4022 * The device supports Telecom Service APIs. 4023 */ 4024 @SdkConstant(SdkConstantType.FEATURE) 4025 public static final String FEATURE_TELECOM = "android.software.telecom"; 4026 4027 /** 4028 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4029 * The device supports Telephony APIs for calling service. 4030 * 4031 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_RADIO_ACCESS}, 4032 * {@link #FEATURE_TELEPHONY_SUBSCRIPTION}, and {@link #FEATURE_TELECOM} have been defined. 4033 */ 4034 @SdkConstant(SdkConstantType.FEATURE) 4035 public static final String FEATURE_TELEPHONY_CALLING = "android.hardware.telephony.calling"; 4036 4037 /** 4038 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4039 * The device supports Telephony APIs for data service. 4040 * 4041 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 4042 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined. 4043 */ 4044 @SdkConstant(SdkConstantType.FEATURE) 4045 public static final String FEATURE_TELEPHONY_DATA = "android.hardware.telephony.data"; 4046 4047 /** 4048 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4049 * The device supports Telephony APIs for SMS and MMS. 4050 * 4051 * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION} 4052 * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined. 4053 */ 4054 @SdkConstant(SdkConstantType.FEATURE) 4055 public static final String FEATURE_TELEPHONY_MESSAGING = "android.hardware.telephony.messaging"; 4056 4057 /** 4058 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4059 * The device supports Telephony APIs for the radio access. 4060 * 4061 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined. 4062 */ 4063 @SdkConstant(SdkConstantType.FEATURE) 4064 public static final String FEATURE_TELEPHONY_RADIO_ACCESS = 4065 "android.hardware.telephony.radio.access"; 4066 4067 /** 4068 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4069 * The device supports Telephony APIs for Satellite communication. 4070 * 4071 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_MESSAGING} 4072 * has been defined. 4073 * 4074 * @hide 4075 */ 4076 @SdkConstant(SdkConstantType.FEATURE) 4077 public static final String FEATURE_TELEPHONY_SATELLITE = "android.hardware.telephony.satellite"; 4078 4079 /** 4080 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4081 * The device supports Telephony APIs for the subscription. 4082 * 4083 * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined. 4084 */ 4085 @SdkConstant(SdkConstantType.FEATURE) 4086 public static final String FEATURE_TELEPHONY_SUBSCRIPTION = 4087 "android.hardware.telephony.subscription"; 4088 4089 /** 4090 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4091 * The device is capable of communicating with other devices via 4092 * <a href="https://www.threadgroup.org">Thread</a> networking protocol. 4093 */ 4094 @FlaggedApi(com.android.net.thread.platform.flags.Flags.FLAG_THREAD_ENABLED_PLATFORM) 4095 @SdkConstant(SdkConstantType.FEATURE) 4096 public static final String FEATURE_THREAD_NETWORK = "android.hardware.thread_network"; 4097 4098 /** 4099 * Feature for {@link #getSystemAvailableFeatures} and 4100 * {@link #hasSystemFeature}: The device is capable of communicating with 4101 * other devices via ultra wideband. 4102 */ 4103 @SdkConstant(SdkConstantType.FEATURE) 4104 public static final String FEATURE_UWB = "android.hardware.uwb"; 4105 4106 /** 4107 * Feature for {@link #getSystemAvailableFeatures} and 4108 * {@link #hasSystemFeature}: The device supports connecting to USB devices 4109 * as the USB host. 4110 */ 4111 @SdkConstant(SdkConstantType.FEATURE) 4112 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 4113 4114 /** 4115 * Feature for {@link #getSystemAvailableFeatures} and 4116 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 4117 */ 4118 @SdkConstant(SdkConstantType.FEATURE) 4119 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 4120 4121 /** 4122 * Feature for {@link #getSystemAvailableFeatures} and 4123 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 4124 */ 4125 @SdkConstant(SdkConstantType.FEATURE) 4126 public static final String FEATURE_SIP = "android.software.sip"; 4127 4128 /** 4129 * Feature for {@link #getSystemAvailableFeatures} and 4130 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 4131 */ 4132 @SdkConstant(SdkConstantType.FEATURE) 4133 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 4134 4135 /** 4136 * Feature for {@link #getSystemAvailableFeatures} and 4137 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 4138 * @deprecated use {@link #FEATURE_TELECOM} instead. 4139 */ 4140 @Deprecated 4141 @SdkConstant(SdkConstantType.FEATURE) 4142 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 4143 4144 /** 4145 * Feature for {@link #getSystemAvailableFeatures} and 4146 * {@link #hasSystemFeature}: The device's display has a touch screen. 4147 */ 4148 @SdkConstant(SdkConstantType.FEATURE) 4149 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 4150 4151 /** 4152 * Feature for {@link #getSystemAvailableFeatures} and 4153 * {@link #hasSystemFeature}: The device's touch screen supports 4154 * multitouch sufficient for basic two-finger gesture detection. 4155 */ 4156 @SdkConstant(SdkConstantType.FEATURE) 4157 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 4158 4159 /** 4160 * Feature for {@link #getSystemAvailableFeatures} and 4161 * {@link #hasSystemFeature}: The device's touch screen is capable of 4162 * tracking two or more fingers fully independently. 4163 */ 4164 @SdkConstant(SdkConstantType.FEATURE) 4165 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 4166 4167 /** 4168 * Feature for {@link #getSystemAvailableFeatures} and 4169 * {@link #hasSystemFeature}: The device's touch screen is capable of 4170 * tracking a full hand of fingers fully independently -- that is, 5 or 4171 * more simultaneous independent pointers. 4172 */ 4173 @SdkConstant(SdkConstantType.FEATURE) 4174 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 4175 4176 /** 4177 * Feature for {@link #getSystemAvailableFeatures} and 4178 * {@link #hasSystemFeature}: The device does not have a touch screen, but 4179 * does support touch emulation for basic events. For instance, the 4180 * device might use a mouse or remote control to drive a cursor, and 4181 * emulate basic touch pointer events like down, up, drag, etc. All 4182 * devices that support android.hardware.touchscreen or a sub-feature are 4183 * presumed to also support faketouch. 4184 */ 4185 @SdkConstant(SdkConstantType.FEATURE) 4186 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 4187 4188 /** 4189 * Feature for {@link #getSystemAvailableFeatures} and 4190 * {@link #hasSystemFeature}: The device does not have a touch screen, but 4191 * does support touch emulation for basic events that supports distinct 4192 * tracking of two or more fingers. This is an extension of 4193 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 4194 * that unlike a distinct multitouch screen as defined by 4195 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 4196 * devices will not actually provide full two-finger gestures since the 4197 * input is being transformed to cursor movement on the screen. That is, 4198 * single finger gestures will move a cursor; two-finger swipes will 4199 * result in single-finger touch events; other two-finger gestures will 4200 * result in the corresponding two-finger touch event. 4201 */ 4202 @SdkConstant(SdkConstantType.FEATURE) 4203 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 4204 4205 /** 4206 * Feature for {@link #getSystemAvailableFeatures} and 4207 * {@link #hasSystemFeature}: The device does not have a touch screen, but 4208 * does support touch emulation for basic events that supports tracking 4209 * a hand of fingers (5 or more fingers) fully independently. 4210 * This is an extension of 4211 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 4212 * that unlike a multitouch screen as defined by 4213 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 4214 * gestures can be detected due to the limitations described for 4215 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 4216 */ 4217 @SdkConstant(SdkConstantType.FEATURE) 4218 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 4219 4220 /** 4221 * Feature for {@link #getSystemAvailableFeatures} and 4222 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 4223 */ 4224 @SdkConstant(SdkConstantType.FEATURE) 4225 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 4226 4227 /** 4228 * Feature for {@link #getSystemAvailableFeatures} and 4229 * {@link #hasSystemFeature}: The device has biometric hardware to perform face authentication. 4230 */ 4231 @SdkConstant(SdkConstantType.FEATURE) 4232 public static final String FEATURE_FACE = "android.hardware.biometrics.face"; 4233 4234 /** 4235 * Feature for {@link #getSystemAvailableFeatures} and 4236 * {@link #hasSystemFeature}: The device has biometric hardware to perform iris authentication. 4237 */ 4238 @SdkConstant(SdkConstantType.FEATURE) 4239 public static final String FEATURE_IRIS = "android.hardware.biometrics.iris"; 4240 4241 /** 4242 * Feature for {@link #getSystemAvailableFeatures} and 4243 * {@link #hasSystemFeature}: The device supports portrait orientation 4244 * screens. For backwards compatibility, you can assume that if neither 4245 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 4246 * both portrait and landscape. 4247 */ 4248 @SdkConstant(SdkConstantType.FEATURE) 4249 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 4250 4251 /** 4252 * Feature for {@link #getSystemAvailableFeatures} and 4253 * {@link #hasSystemFeature}: The device supports landscape orientation 4254 * screens. For backwards compatibility, you can assume that if neither 4255 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 4256 * both portrait and landscape. 4257 */ 4258 @SdkConstant(SdkConstantType.FEATURE) 4259 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 4260 4261 /** 4262 * Feature for {@link #getSystemAvailableFeatures} and 4263 * {@link #hasSystemFeature}: The device supports live wallpapers. 4264 */ 4265 @SdkConstant(SdkConstantType.FEATURE) 4266 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 4267 /** 4268 * Feature for {@link #getSystemAvailableFeatures} and 4269 * {@link #hasSystemFeature}: The device supports app widgets. 4270 */ 4271 @SdkConstant(SdkConstantType.FEATURE) 4272 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 4273 /** 4274 * Feature for {@link #getSystemAvailableFeatures} and 4275 * {@link #hasSystemFeature}: The device supports the 4276 * {@link android.R.attr#cantSaveState} API. 4277 */ 4278 @SdkConstant(SdkConstantType.FEATURE) 4279 public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state"; 4280 4281 /** 4282 * @hide 4283 * Feature for {@link #getSystemAvailableFeatures} and 4284 * {@link #hasSystemFeature}: The device supports 4285 * {@link android.service.games.GameService}. 4286 * 4287 * @hide 4288 */ 4289 @SdkConstant(SdkConstantType.FEATURE) 4290 @SystemApi 4291 public static final String FEATURE_GAME_SERVICE = "android.software.game_service"; 4292 4293 /** 4294 * @hide 4295 * Feature for {@link #getSystemAvailableFeatures} and 4296 * {@link #hasSystemFeature}: The device supports 4297 * {@link android.service.voice.VoiceInteractionService} and 4298 * {@link android.app.VoiceInteractor}. 4299 */ 4300 @SdkConstant(SdkConstantType.FEATURE) 4301 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 4302 4303 4304 /** 4305 * Feature for {@link #getSystemAvailableFeatures} and 4306 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 4307 * by third party applications. 4308 */ 4309 @SdkConstant(SdkConstantType.FEATURE) 4310 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 4311 4312 /** 4313 * Feature for {@link #getSystemAvailableFeatures} and 4314 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 4315 * with the {@link android.inputmethodservice.InputMethodService} API. 4316 */ 4317 @SdkConstant(SdkConstantType.FEATURE) 4318 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 4319 4320 /** 4321 * Feature for {@link #getSystemAvailableFeatures} and 4322 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 4323 */ 4324 @SdkConstant(SdkConstantType.FEATURE) 4325 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 4326 4327 /** 4328 * Feature for {@link #getSystemAvailableFeatures} and 4329 * {@link #hasSystemFeature}: The device supports leanback UI. This is 4330 * typically used in a living room television experience, but is a software 4331 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 4332 * feature will use resources associated with the "television" UI mode. 4333 */ 4334 @SdkConstant(SdkConstantType.FEATURE) 4335 public static final String FEATURE_LEANBACK = "android.software.leanback"; 4336 4337 /** 4338 * Feature for {@link #getSystemAvailableFeatures} and 4339 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 4340 * applications designed for this experience should be run, though this is 4341 * not enforced by the system. 4342 */ 4343 @SdkConstant(SdkConstantType.FEATURE) 4344 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 4345 4346 /** 4347 * Feature for {@link #getSystemAvailableFeatures} and 4348 * {@link #hasSystemFeature}: The device supports live TV and can display 4349 * contents from TV inputs implemented with the 4350 * {@link android.media.tv.TvInputService} API. 4351 */ 4352 @SdkConstant(SdkConstantType.FEATURE) 4353 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 4354 4355 /** 4356 * Feature for {@link #getSystemAvailableFeatures} and 4357 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 4358 */ 4359 @SdkConstant(SdkConstantType.FEATURE) 4360 public static final String FEATURE_WIFI = "android.hardware.wifi"; 4361 4362 /** 4363 * Feature for {@link #getSystemAvailableFeatures} and 4364 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 4365 */ 4366 @SdkConstant(SdkConstantType.FEATURE) 4367 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 4368 4369 /** 4370 * Feature for {@link #getSystemAvailableFeatures} and 4371 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware. 4372 */ 4373 @SdkConstant(SdkConstantType.FEATURE) 4374 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware"; 4375 4376 /** 4377 * Feature for {@link #getSystemAvailableFeatures} and 4378 * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all 4379 * Passpoint related APIs in {@link WifiManager} are supported. Refer to 4380 * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info. 4381 */ 4382 @SdkConstant(SdkConstantType.FEATURE) 4383 public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint"; 4384 4385 /** 4386 * Feature for {@link #getSystemAvailableFeatures} and 4387 * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc). 4388 */ 4389 @SdkConstant(SdkConstantType.FEATURE) 4390 public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt"; 4391 4392 4393 /** 4394 * Feature for {@link #getSystemAvailableFeatures} and 4395 * {@link #hasSystemFeature}: The device supports LoWPAN networking. 4396 * @hide 4397 */ 4398 @SdkConstant(SdkConstantType.FEATURE) 4399 public static final String FEATURE_LOWPAN = "android.hardware.lowpan"; 4400 4401 /** 4402 * Feature for {@link #getSystemAvailableFeatures} and 4403 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 4404 * on a vehicle headunit. A headunit here is defined to be inside a 4405 * vehicle that may or may not be moving. A headunit uses either a 4406 * primary display in the center console and/or additional displays in 4407 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 4408 * have limited size and resolution. The user will likely be focused on 4409 * driving so limiting driver distraction is a primary concern. User input 4410 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 4411 * like interfaces. 4412 */ 4413 @SdkConstant(SdkConstantType.FEATURE) 4414 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 4415 4416 /** 4417 * Feature for {@link #getSystemAvailableFeatures} and 4418 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 4419 * on a television. Television here is defined to be a typical living 4420 * room television experience: displayed on a big screen, where the user 4421 * is sitting far away from it, and the dominant form of input will be 4422 * something like a DPAD, not through touch or mouse. 4423 * @deprecated use {@link #FEATURE_LEANBACK} instead. 4424 */ 4425 @Deprecated 4426 @SdkConstant(SdkConstantType.FEATURE) 4427 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 4428 4429 /** 4430 * Feature for {@link #getSystemAvailableFeatures} and 4431 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 4432 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 4433 * the wrist. The user is very close when interacting with the device. 4434 */ 4435 @SdkConstant(SdkConstantType.FEATURE) 4436 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 4437 4438 /** 4439 * Feature for {@link #getSystemAvailableFeatures} and 4440 * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded 4441 * device is defined as a full stack Android device with or without a display and no 4442 * user-installable apps. 4443 */ 4444 @SdkConstant(SdkConstantType.FEATURE) 4445 public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded"; 4446 4447 /** 4448 * Feature for {@link #getSystemAvailableFeatures} and 4449 * {@link #hasSystemFeature}: This is a device dedicated to be primarily used 4450 * with keyboard, mouse or touchpad. This includes traditional desktop 4451 * computers, laptops and variants such as convertibles or detachables. 4452 * Due to the larger screen, the device will most likely use the 4453 * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well. 4454 */ 4455 @SdkConstant(SdkConstantType.FEATURE) 4456 public static final String FEATURE_PC = "android.hardware.type.pc"; 4457 4458 /** 4459 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4460 * The device supports printing. 4461 */ 4462 @SdkConstant(SdkConstantType.FEATURE) 4463 public static final String FEATURE_PRINTING = "android.software.print"; 4464 4465 /** 4466 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4467 * The device supports {@link android.companion.CompanionDeviceManager#associate associating} 4468 * with devices via {@link android.companion.CompanionDeviceManager}. 4469 */ 4470 @SdkConstant(SdkConstantType.FEATURE) 4471 public static final String FEATURE_COMPANION_DEVICE_SETUP 4472 = "android.software.companion_device_setup"; 4473 4474 /** 4475 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4476 * The device can perform backup and restore operations on installed applications. 4477 */ 4478 @SdkConstant(SdkConstantType.FEATURE) 4479 public static final String FEATURE_BACKUP = "android.software.backup"; 4480 4481 /** 4482 * Feature for {@link #getSystemAvailableFeatures} and 4483 * {@link #hasSystemFeature}: The device supports freeform window management. 4484 * Windows have title bars and can be moved and resized. 4485 */ 4486 @SdkConstant(SdkConstantType.FEATURE) 4487 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 4488 = "android.software.freeform_window_management"; 4489 4490 /** 4491 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4492 * The device supports picture-in-picture multi-window mode. 4493 */ 4494 @SdkConstant(SdkConstantType.FEATURE) 4495 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 4496 4497 /** 4498 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4499 * The device supports expanded picture-in-picture multi-window mode. 4500 * 4501 * @see android.app.PictureInPictureParams.Builder#setExpandedAspectRatio 4502 */ 4503 @SdkConstant(SdkConstantType.FEATURE) 4504 public static final String FEATURE_EXPANDED_PICTURE_IN_PICTURE 4505 = "android.software.expanded_picture_in_picture"; 4506 4507 /** 4508 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4509 * The device supports running activities on secondary displays. Displays here 4510 * refers to both physical and virtual displays. Disabling this feature can impact 4511 * support for application projection use-cases and support for virtual devices 4512 * on the device. 4513 */ 4514 @SdkConstant(SdkConstantType.FEATURE) 4515 public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS 4516 = "android.software.activities_on_secondary_displays"; 4517 4518 /** 4519 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4520 * The device supports creating secondary users and managed profiles via 4521 * {@link DevicePolicyManager}. 4522 */ 4523 @SdkConstant(SdkConstantType.FEATURE) 4524 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 4525 4526 /** 4527 * @hide 4528 * TODO: Remove after dependencies updated b/17392243 4529 */ 4530 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 4531 4532 /** 4533 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4534 * The device supports verified boot. 4535 */ 4536 @SdkConstant(SdkConstantType.FEATURE) 4537 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 4538 4539 /** 4540 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4541 * The device supports secure removal of users. When a user is deleted the data associated 4542 * with that user is securely deleted and no longer available. 4543 */ 4544 @SdkConstant(SdkConstantType.FEATURE) 4545 public static final String FEATURE_SECURELY_REMOVES_USERS 4546 = "android.software.securely_removes_users"; 4547 4548 /** {@hide} */ 4549 @TestApi 4550 @SdkConstant(SdkConstantType.FEATURE) 4551 public static final String FEATURE_FILE_BASED_ENCRYPTION 4552 = "android.software.file_based_encryption"; 4553 4554 /** {@hide} */ 4555 @TestApi 4556 @SdkConstant(SdkConstantType.FEATURE) 4557 public static final String FEATURE_ADOPTABLE_STORAGE 4558 = "android.software.adoptable_storage"; 4559 4560 /** 4561 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4562 * The device has a full implementation of the android.webkit.* APIs. Devices 4563 * lacking this feature will not have a functioning WebView implementation. 4564 */ 4565 @SdkConstant(SdkConstantType.FEATURE) 4566 public static final String FEATURE_WEBVIEW = "android.software.webview"; 4567 4568 /** 4569 * Feature for {@link #getSystemAvailableFeatures} and 4570 * {@link #hasSystemFeature}: This device supports ethernet. 4571 */ 4572 @SdkConstant(SdkConstantType.FEATURE) 4573 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 4574 4575 /** 4576 * Feature for {@link #getSystemAvailableFeatures} and 4577 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 4578 * @hide 4579 */ 4580 @TestApi 4581 @SdkConstant(SdkConstantType.FEATURE) 4582 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 4583 4584 /** 4585 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4586 * The device has all of the inputs necessary to be considered a compatible game controller, or 4587 * includes a compatible game controller in the box. 4588 */ 4589 @SdkConstant(SdkConstantType.FEATURE) 4590 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 4591 4592 /** 4593 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4594 * The device has a full implementation of the android.media.midi.* APIs. 4595 */ 4596 @SdkConstant(SdkConstantType.FEATURE) 4597 public static final String FEATURE_MIDI = "android.software.midi"; 4598 4599 /** 4600 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4601 * The device implements an optimized mode for virtual reality (VR) applications that handles 4602 * stereoscopic rendering of notifications, and disables most monocular system UI components 4603 * while a VR application has user focus. 4604 * Devices declaring this feature must include an application implementing a 4605 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 4606 * {@link android.app.Activity#setVrModeEnabled}. 4607 * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead. 4608 */ 4609 @Deprecated 4610 @SdkConstant(SdkConstantType.FEATURE) 4611 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 4612 4613 /** 4614 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4615 * The device implements an optimized mode for virtual reality (VR) applications that handles 4616 * stereoscopic rendering of notifications, disables most monocular system UI components 4617 * while a VR application has user focus and meets extra CDD requirements to provide a 4618 * high-quality VR experience. 4619 * Devices declaring this feature must include an application implementing a 4620 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 4621 * {@link android.app.Activity#setVrModeEnabled}. 4622 * and must meet CDD requirements to provide a high-quality VR experience. 4623 */ 4624 @SdkConstant(SdkConstantType.FEATURE) 4625 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE 4626 = "android.hardware.vr.high_performance"; 4627 4628 /** 4629 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4630 * The device supports autofill of user credentials, addresses, credit cards, etc 4631 * via integration with {@link android.service.autofill.AutofillService autofill 4632 * providers}. 4633 */ 4634 @SdkConstant(SdkConstantType.FEATURE) 4635 public static final String FEATURE_AUTOFILL = "android.software.autofill"; 4636 4637 /** 4638 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4639 * The device implements headtracking suitable for a VR device. 4640 */ 4641 @SdkConstant(SdkConstantType.FEATURE) 4642 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking"; 4643 4644 /** 4645 * Feature for {@link #getSystemAvailableFeatures} and 4646 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements 4647 * the Android Keystore backed by an isolated execution environment. The version indicates 4648 * which features are implemented in the isolated execution environment: 4649 * <ul> 4650 * <li>400: Inclusion of module information (via tag MODULE_HASH) in the attestation record. 4651 * <li>300: Ability to include a second IMEI in the ID attestation record, see 4652 * {@link android.app.admin.DevicePolicyManager#ID_TYPE_IMEI}. 4653 * <li>200: Hardware support for Curve 25519 (including both Ed25519 signature generation and 4654 * X25519 key agreement). 4655 * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support 4656 * for app-generated attestation keys (see {@link 4657 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}). 4658 * <li>41: Hardware enforcement of device-unlocked keys (see {@link 4659 * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}). 4660 * <li>40: Support for wrapped key import (see {@link 4661 * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link 4662 * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}), 4663 * attestation (see {@link 4664 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}), 4665 * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure 4666 * hardware, and support for requiring user authentication before a key can be used. 4667 * </ul> 4668 * This feature version is guaranteed to be set for all devices launching with Android 12 and 4669 * may be set on devices launching with an earlier version. If the feature version is set, it 4670 * will at least have the value 40. If it's not set the device may have a version of 4671 * hardware-backed keystore but it may not support all features listed above. 4672 */ 4673 @SdkConstant(SdkConstantType.FEATURE) 4674 public static final String FEATURE_HARDWARE_KEYSTORE = "android.hardware.hardware_keystore"; 4675 4676 /** 4677 * Feature for {@link #getSystemAvailableFeatures}, {@link #hasSystemFeature(String)}, and 4678 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements 4679 * the Android Keystore backed by a dedicated secure processor referred to as 4680 * <a href="https://source.android.com/security/best-practices/hardware#strongbox-keymaster"> 4681 * StrongBox</a>. If this feature has a version, the version number indicates which features are 4682 * implemented in StrongBox: 4683 * <ul> 4684 * <li>400: Inclusion of module information (via tag MODULE_HASH) in the attestation record. 4685 * <li>300: Ability to include a second IMEI in the ID attestation record, see 4686 * {@link android.app.admin.DevicePolicyManager#ID_TYPE_IMEI}. 4687 * <li>200: No new features for StrongBox (the Android Keystore environment backed by an 4688 * isolated execution environment has gained support for Curve 25519 in this version, but 4689 * the implementation backed by a dedicated secure processor is not expected to implement it). 4690 * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support 4691 * for app-generated attestation keys (see {@link 4692 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}). 4693 * <li>41: Hardware enforcement of device-unlocked keys (see {@link 4694 * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}). 4695 * <li>40: Support for wrapped key import (see {@link 4696 * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link 4697 * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}), 4698 * attestation (see {@link 4699 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}), 4700 * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure 4701 * hardware, and support for requiring user authentication before a key can be used. 4702 * </ul> 4703 * If a device has StrongBox, this feature version number is guaranteed to be set for all 4704 * devices launching with Android 12 and may be set on devices launching with an earlier 4705 * version. If the feature version is set, it will at least have the value 40. If it's not 4706 * set the device may have StrongBox but it may not support all features listed above. 4707 */ 4708 @SdkConstant(SdkConstantType.FEATURE) 4709 public static final String FEATURE_STRONGBOX_KEYSTORE = 4710 "android.hardware.strongbox_keystore"; 4711 4712 /** 4713 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4714 * The device does not have slices implementation. 4715 * @hide 4716 */ 4717 @SdkConstant(SdkConstantType.FEATURE) 4718 public static final String FEATURE_SLICES_DISABLED = "android.software.slices_disabled"; 4719 4720 /** 4721 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4722 * The device supports device-unique Keystore attestations. Only available on devices that 4723 * also support {@link #FEATURE_STRONGBOX_KEYSTORE}, and can only be used by device owner 4724 * apps (see {@link android.app.admin.DevicePolicyManager#generateKeyPair}). 4725 * @hide 4726 */ 4727 @SdkConstant(SdkConstantType.FEATURE) 4728 public static final String FEATURE_DEVICE_UNIQUE_ATTESTATION = 4729 "android.hardware.device_unique_attestation"; 4730 4731 /** 4732 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4733 * The device has a Keymaster implementation that supports Device ID attestation. 4734 * 4735 * @see DevicePolicyManager#isDeviceIdAttestationSupported 4736 * @hide 4737 */ 4738 @SdkConstant(SdkConstantType.FEATURE) 4739 public static final String FEATURE_DEVICE_ID_ATTESTATION = 4740 "android.software.device_id_attestation"; 4741 4742 /** 4743 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4744 * the requisite kernel support for multinetworking-capable IPsec tunnels. 4745 * 4746 * <p>This feature implies that the device supports XFRM Interfaces (CONFIG_XFRM_INTERFACE), or 4747 * VTIs with kernel patches allowing updates of output/set mark via UPDSA. 4748 */ 4749 @SdkConstant(SdkConstantType.FEATURE) 4750 public static final String FEATURE_IPSEC_TUNNELS = "android.software.ipsec_tunnels"; 4751 4752 /** 4753 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4754 * the requisite kernel support for migrating IPsec tunnels to new source/destination addresses. 4755 * 4756 * <p>This feature implies that the device supports XFRM Migration (CONFIG_XFRM_MIGRATE) and has 4757 * the kernel fixes to support cross-address-family IPsec tunnel migration 4758 */ 4759 @SdkConstant(SdkConstantType.FEATURE) 4760 public static final String FEATURE_IPSEC_TUNNEL_MIGRATION = 4761 "android.software.ipsec_tunnel_migration"; 4762 4763 /** 4764 * Feature for {@link #getSystemAvailableFeatures} and 4765 * {@link #hasSystemFeature}: The device supports a system interface for the user to select 4766 * and bind device control services provided by applications. 4767 * 4768 * @see android.service.controls.ControlsProviderService 4769 */ 4770 @SdkConstant(SdkConstantType.FEATURE) 4771 public static final String FEATURE_CONTROLS = "android.software.controls"; 4772 4773 /** 4774 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4775 * the requisite hardware support to support reboot escrow of synthetic password for updates. 4776 * 4777 * <p>This feature implies that the device has the RebootEscrow HAL implementation. 4778 * 4779 * @hide 4780 */ 4781 @SystemApi 4782 @SdkConstant(SdkConstantType.FEATURE) 4783 public static final String FEATURE_REBOOT_ESCROW = "android.hardware.reboot_escrow"; 4784 4785 /** 4786 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4787 * the requisite kernel support to support incremental delivery aka Incremental FileSystem. 4788 * 4789 * feature not present - IncFs is not present on the device. 4790 * 1 - IncFs v1, core features, no PerUid support. Optional in R. 4791 * 2 - IncFs v2, PerUid support, fs-verity support. Required in S. 4792 * 4793 * @see IncrementalManager#isFeatureEnabled 4794 * @see IncrementalManager#getVersion() 4795 * @hide 4796 */ 4797 @SystemApi 4798 @SdkConstant(SdkConstantType.FEATURE) 4799 public static final String FEATURE_INCREMENTAL_DELIVERY = 4800 "android.software.incremental_delivery"; 4801 4802 /** 4803 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4804 * has the requisite kernel support for the EROFS filesystem present in 4.19 kernels as a 4805 * staging driver, which lacks 0padding and big pcluster support. 4806 * 4807 * @hide 4808 */ 4809 @SystemApi 4810 @SdkConstant(SdkConstantType.FEATURE) 4811 public static final String FEATURE_EROFS_LEGACY = "android.software.erofs_legacy"; 4812 4813 /** 4814 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4815 * has the requisite kernel support for the EROFS filesystem present in 5.10 kernels, which 4816 * has 0padding, big pcluster, and chunked index support. 4817 * 4818 * @hide 4819 */ 4820 @SystemApi 4821 @SdkConstant(SdkConstantType.FEATURE) 4822 public static final String FEATURE_EROFS = "android.software.erofs"; 4823 4824 /** 4825 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 4826 * The device has tuner hardware to support tuner operations. 4827 * 4828 * <p>This feature implies that the device has the tuner HAL implementation. 4829 * 4830 * @hide 4831 */ 4832 @SdkConstant(SdkConstantType.FEATURE) 4833 public static final String FEATURE_TUNER = "android.hardware.tv.tuner"; 4834 4835 /** 4836 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4837 * the necessary changes to support app enumeration. 4838 * 4839 * @hide 4840 */ 4841 @SdkConstant(SdkConstantType.FEATURE) 4842 public static final String FEATURE_APP_ENUMERATION = "android.software.app_enumeration"; 4843 4844 /** 4845 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4846 * a Keystore implementation that can only enforce limited use key in hardware with max usage 4847 * count equals to 1. 4848 */ 4849 @SdkConstant(SdkConstantType.FEATURE) 4850 public static final String FEATURE_KEYSTORE_SINGLE_USE_KEY = 4851 "android.hardware.keystore.single_use_key"; 4852 4853 /** 4854 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4855 * a Keystore implementation that can enforce limited use key in hardware with any max usage 4856 * count (including count equals to 1). 4857 */ 4858 @SdkConstant(SdkConstantType.FEATURE) 4859 public static final String FEATURE_KEYSTORE_LIMITED_USE_KEY = 4860 "android.hardware.keystore.limited_use_key"; 4861 4862 /** 4863 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4864 * a Keystore implementation that can create application-specific attestation keys. 4865 * See {@link android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias}. 4866 */ 4867 @SdkConstant(SdkConstantType.FEATURE) 4868 public static final String FEATURE_KEYSTORE_APP_ATTEST_KEY = 4869 "android.hardware.keystore.app_attest_key"; 4870 4871 /** 4872 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4873 * is opted-in to receive per-app compatibility overrides that are applied in 4874 * {@link com.android.server.compat.overrides.AppCompatOverridesService}. 4875 * 4876 * @hide 4877 */ 4878 @SdkConstant(SdkConstantType.FEATURE) 4879 public static final String FEATURE_APP_COMPAT_OVERRIDES = 4880 "android.software.app_compat_overrides"; 4881 4882 /** 4883 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4884 * supports communal mode, 4885 * 4886 * @hide 4887 */ 4888 @SdkConstant(SdkConstantType.FEATURE) 4889 @TestApi 4890 public static final String FEATURE_COMMUNAL_MODE = "android.software.communal_mode"; 4891 4892 /** 4893 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4894 * supports dream overlay feature, which is an informational layer shown on top of dreams. 4895 * 4896 * @hide 4897 */ 4898 @SdkConstant(SdkConstantType.FEATURE) 4899 public static final String FEATURE_DREAM_OVERLAY = "android.software.dream_overlay"; 4900 4901 /** 4902 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4903 * supports window magnification. 4904 * 4905 * @see android.accessibilityservice.MagnificationConfig#MAGNIFICATION_MODE_WINDOW 4906 */ 4907 @SdkConstant(SdkConstantType.FEATURE) 4908 public static final String FEATURE_WINDOW_MAGNIFICATION = 4909 "android.software.window_magnification"; 4910 4911 /** 4912 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4913 * supports retrieval of user credentials, via integration with credential providers. 4914 */ 4915 @SdkConstant(SdkConstantType.FEATURE) 4916 public static final String FEATURE_CREDENTIALS = "android.software.credentials"; 4917 4918 /** 4919 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4920 * supports locking (for example, by a financing provider in case of a missed payment). 4921 */ 4922 @SdkConstant(SdkConstantType.FEATURE) 4923 public static final String FEATURE_DEVICE_LOCK = "android.software.device_lock"; 4924 4925 /** 4926 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 4927 * supports showing location-based suggestions for wallet cards provided by the default payment 4928 * app. 4929 */ 4930 @SdkConstant(SdkConstantType.FEATURE) 4931 public static final String FEATURE_WALLET_LOCATION_BASED_SUGGESTIONS = 4932 "android.software.wallet_location_based_suggestions"; 4933 4934 /** 4935 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4936 * the rotary encoder hardware to support rotating bezel on watch. 4937 * 4938 * @hide 4939 */ 4940 @SdkConstant(SdkConstantType.FEATURE) 4941 public static final String FEATURE_ROTARY_ENCODER_LOW_RES = 4942 "android.hardware.rotaryencoder.lowres"; 4943 4944 /** 4945 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 4946 * support for contextual search helper. 4947 * 4948 * @hide 4949 */ 4950 @SdkConstant(SdkConstantType.FEATURE) 4951 public static final String FEATURE_CONTEXTUAL_SEARCH_HELPER = 4952 "android.software.contextualsearch"; 4953 4954 /** 4955 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: This device 4956 * supports XR input from XR controllers. 4957 */ 4958 @FlaggedApi(android.xr.Flags.FLAG_XR_MANIFEST_ENTRIES) 4959 @SdkConstant(SdkConstantType.FEATURE) 4960 public static final String FEATURE_XR_INPUT_CONTROLLER = 4961 "android.hardware.xr.input.controller"; 4962 4963 /** 4964 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: This device 4965 * supports XR input from the user's hands. 4966 */ 4967 @FlaggedApi(android.xr.Flags.FLAG_XR_MANIFEST_ENTRIES) 4968 @SdkConstant(SdkConstantType.FEATURE) 4969 public static final String FEATURE_XR_INPUT_HAND_TRACKING = 4970 "android.hardware.xr.input.hand_tracking"; 4971 4972 /** 4973 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: This device 4974 * supports XR input from the user's eye gaze. 4975 */ 4976 @FlaggedApi(android.xr.Flags.FLAG_XR_MANIFEST_ENTRIES) 4977 @SdkConstant(SdkConstantType.FEATURE) 4978 public static final String FEATURE_XR_INPUT_EYE_TRACKING = 4979 "android.hardware.xr.input.eye_tracking"; 4980 4981 /** 4982 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: This device 4983 * supports <a href="https://www.khronos.org/openxr/">OpenXR</a>. The feature version indicates 4984 * the highest version of OpenXR supported by the device using the following encoding: 4985 * <ul> 4986 * <li> Major version in bits 31-16</li> 4987 * <li> Minor version in bits 15-0</li> 4988 * </ul> 4989 * This is the same encoding as the top 32 bits of an {@code XrVersion}. 4990 * <p> 4991 * Example: OpenXR 1.1 support is encoded as 0x00010001. 4992 */ 4993 @FlaggedApi(android.xr.Flags.FLAG_XR_MANIFEST_ENTRIES) 4994 @SdkConstant(SdkConstantType.FEATURE) 4995 public static final String FEATURE_XR_API_OPENXR = 4996 "android.software.xr.api.openxr"; 4997 4998 /** 4999 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: This device 5000 * supports the Android XR Spatial APIs. The feature version indicates the highest version of 5001 * the Android XR Spatial APIs supported by the device. 5002 * 5003 * <p>Also see <a href="https://developer.android.com/develop/xr">Develop with the Android XR 5004 * SDK</a>. 5005 */ 5006 @FlaggedApi(android.xr.Flags.FLAG_XR_MANIFEST_ENTRIES) 5007 @SdkConstant(SdkConstantType.FEATURE) 5008 public static final String FEATURE_XR_API_SPATIAL = 5009 "android.software.xr.api.spatial"; 5010 5011 /** @hide */ 5012 public static final boolean APP_ENUMERATION_ENABLED_BY_DEFAULT = true; 5013 5014 /** 5015 * Extra field name for the URI to a verification file. Passed to a package verifier. 5016 * 5017 * @hide 5018 */ 5019 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 5020 5021 /** 5022 * Extra field name for the ID of a package pending verification. Passed to 5023 * a package verifier and is used to call back to 5024 * {@link PackageManager#verifyPendingInstall(int, int)} 5025 */ 5026 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 5027 5028 /** 5029 * Extra field name for the package identifier which is trying to install 5030 * the package. 5031 * 5032 * @hide 5033 */ 5034 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 5035 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 5036 5037 /** 5038 * Extra field name for the requested install flags for a package pending 5039 * verification. Passed to a package verifier. 5040 * 5041 * @hide 5042 */ 5043 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 5044 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 5045 5046 /** 5047 * Extra field name for the uid of who is requesting to install 5048 * the package. 5049 * 5050 * @hide 5051 */ 5052 public static final String EXTRA_VERIFICATION_INSTALLER_UID 5053 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 5054 5055 /** 5056 * Extra field name for the package name of a package pending verification. 5057 * 5058 * @hide 5059 */ 5060 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 5061 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 5062 5063 /** 5064 * Extra field name for the result of a verification, either 5065 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 5066 * Passed to package verifiers after a package is verified. 5067 */ 5068 public static final String EXTRA_VERIFICATION_RESULT 5069 = "android.content.pm.extra.VERIFICATION_RESULT"; 5070 5071 /** 5072 * Extra field name for tracking whether user action 5073 * was requested for a particular install, either {@code true} or {@code false}. 5074 * @hide 5075 */ 5076 public static final String EXTRA_USER_ACTION_REQUIRED 5077 = "android.content.pm.extra.USER_ACTION_REQUIRED"; 5078 5079 /** 5080 * Extra field name for the version code of a package pending verification. 5081 * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead. 5082 * @hide 5083 */ 5084 @Deprecated 5085 public static final String EXTRA_VERIFICATION_VERSION_CODE 5086 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 5087 5088 /** 5089 * Extra field name for the long version code of a package pending verification 5090 * @hide 5091 */ 5092 public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE = 5093 "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE"; 5094 5095 /** 5096 * Extra field name for the Merkle tree root hash of a package. 5097 * <p>Passed to a package verifier both prior to verification and as a result 5098 * of verification. 5099 * <p>The value of the extra is a specially formatted list: 5100 * {@code filename1:HASH_1;filename2:HASH_2;...;filenameN:HASH_N} 5101 * <p>The extra must include an entry for every APK within an installation. If 5102 * a hash is not physically present, a hash value of {@code 0} will be used. 5103 * <p>The root hash is generated using SHA-256, no salt with a 4096 byte block 5104 * size. See the description of the 5105 * <a href="https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#merkle-tree">fs-verity merkle-tree</a> 5106 * for more details. 5107 * @hide 5108 */ 5109 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 5110 public static final String EXTRA_VERIFICATION_ROOT_HASH = 5111 "android.content.pm.extra.VERIFICATION_ROOT_HASH"; 5112 5113 /** 5114 * Extra field name for the ID of a intent filter pending verification. 5115 * Passed to an intent filter verifier and is used to call back to 5116 * {@link #verifyIntentFilter} 5117 * 5118 * @deprecated Use DomainVerificationManager APIs. 5119 * @hide 5120 */ 5121 @Deprecated 5122 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 5123 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 5124 5125 /** 5126 * Extra field name for the scheme used for an intent filter pending verification. Passed to 5127 * an intent filter verifier and is used to construct the URI to verify against. 5128 * 5129 * Usually this is "https" 5130 * 5131 * @deprecated Use DomainVerificationManager APIs. 5132 * @hide 5133 */ 5134 @Deprecated 5135 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 5136 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 5137 5138 /** 5139 * Extra field name for the host names to be used for an intent filter pending verification. 5140 * Passed to an intent filter verifier and is used to construct the URI to verify the 5141 * intent filter. 5142 * 5143 * This is a space delimited list of hosts. 5144 * 5145 * @deprecated Use DomainVerificationManager APIs. 5146 * @hide 5147 */ 5148 @Deprecated 5149 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 5150 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 5151 5152 /** 5153 * Extra field name for the package name to be used for an intent filter pending verification. 5154 * Passed to an intent filter verifier and is used to check the verification responses coming 5155 * from the hosts. Each host response will need to include the package name of APK containing 5156 * the intent filter. 5157 * 5158 * @deprecated Use DomainVerificationManager APIs. 5159 * @hide 5160 */ 5161 @Deprecated 5162 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 5163 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 5164 5165 /** 5166 * The action used to request that the user approve a permission request 5167 * from the application. 5168 * 5169 * @hide 5170 */ 5171 @SystemApi 5172 public static final String ACTION_REQUEST_PERMISSIONS = 5173 "android.content.pm.action.REQUEST_PERMISSIONS"; 5174 5175 /** 5176 * The action used to request that the user approve a permission request 5177 * from the application. Sent from an application other than the one whose permissions 5178 * will be granted. Can only be used by the system server. 5179 * 5180 * @hide 5181 */ 5182 @SystemApi 5183 public static final String ACTION_REQUEST_PERMISSIONS_FOR_OTHER = 5184 "android.content.pm.action.REQUEST_PERMISSIONS_FOR_OTHER"; 5185 5186 /** 5187 * The names of the requested permissions. 5188 * <p> 5189 * <strong>Type:</strong> String[] 5190 * </p> 5191 * 5192 * @hide 5193 */ 5194 @SystemApi 5195 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 5196 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 5197 5198 /** 5199 * The deviceId for which the permissions are requested, {@link Context#DEVICE_ID_DEFAULT} 5200 * is the default device ID. 5201 * <p> 5202 * <strong>Type:</strong> int 5203 * </p> 5204 * 5205 * @hide 5206 */ 5207 @SystemApi 5208 @FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED) 5209 public static final String EXTRA_REQUEST_PERMISSIONS_DEVICE_ID = 5210 "android.content.pm.extra.REQUEST_PERMISSIONS_DEVICE_ID"; 5211 5212 /** 5213 * The results from the permissions request. 5214 * <p> 5215 * <strong>Type:</strong> int[] of #PermissionResult 5216 * </p> 5217 * 5218 * @hide 5219 */ 5220 @SystemApi 5221 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 5222 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 5223 5224 /** 5225 * Indicates that the package requesting permissions has legacy access for some permissions, 5226 * or had it, but it was recently revoked. These request dialogs may show different text, 5227 * indicating that the app is requesting continued access to a permission. Will be cleared 5228 * from any permission request intent, if set by a non-system server app. 5229 * <p> 5230 * <strong>Type:</strong> String[] 5231 * </p> 5232 * 5233 * @hide 5234 */ 5235 @SystemApi 5236 public static final String EXTRA_REQUEST_PERMISSIONS_LEGACY_ACCESS_PERMISSION_NAMES 5237 = "android.content.pm.extra.REQUEST_PERMISSIONS_LEGACY_ACCESS_PERMISSION_NAMES"; 5238 5239 /** 5240 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 5241 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 5242 * the existing definition for the permission. 5243 * @hide 5244 */ 5245 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 5246 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 5247 5248 /** 5249 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 5250 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 5251 * being redundantly defined by the package being installed. 5252 * @hide 5253 */ 5254 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 5255 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 5256 5257 /** 5258 * Permission flag: The permission is set in its current state 5259 * by the user and apps can still request it at runtime. 5260 * 5261 * @hide 5262 */ 5263 @SystemApi 5264 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 5265 5266 /** 5267 * Permission flag: The permission is set in its current state 5268 * by the user and it is fixed, i.e. apps can no longer request 5269 * this permission. 5270 * 5271 * @hide 5272 */ 5273 @SystemApi 5274 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 5275 5276 /** 5277 * Permission flag: The permission is set in its current state 5278 * by device policy and neither apps nor the user can change 5279 * its state. 5280 * 5281 * @hide 5282 */ 5283 @SystemApi 5284 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 5285 5286 /** 5287 * Permission flag: The permission is set in a granted state but 5288 * access to resources it guards is restricted by other means to 5289 * enable revoking a permission on legacy apps that do not support 5290 * runtime permissions. If this permission is upgraded to runtime 5291 * because the app was updated to support runtime permissions, the 5292 * the permission will be revoked in the upgrade process. 5293 * 5294 * @deprecated Renamed to {@link #FLAG_PERMISSION_REVOKED_COMPAT}. 5295 * 5296 * @hide 5297 */ 5298 @Deprecated 5299 @SystemApi 5300 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 5301 5302 /** 5303 * Permission flag: The permission is set in its current state 5304 * because the app is a component that is a part of the system. 5305 * 5306 * @hide 5307 */ 5308 @SystemApi 5309 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 5310 5311 /** 5312 * Permission flag: The permission is granted by default because it 5313 * enables app functionality that is expected to work out-of-the-box 5314 * for providing a smooth user experience. For example, the phone app 5315 * is expected to have the phone permission. 5316 * 5317 * @hide 5318 */ 5319 @SystemApi 5320 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 5321 5322 /** 5323 * Permission flag: If app targetSDK < M, then the permission has to be reviewed before any of 5324 * the app components can run. If app targetSDK >= M, then the system might need to show a 5325 * request dialog for this permission on behalf of an app. 5326 * 5327 * @hide 5328 */ 5329 @SystemApi 5330 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 5331 5332 /** 5333 * Permission flag: The permission has not been explicitly requested by 5334 * the app but has been added automatically by the system. Revoke once 5335 * the app does explicitly request it. 5336 * 5337 * @hide 5338 */ 5339 @TestApi 5340 @SystemApi 5341 public static final int FLAG_PERMISSION_REVOKE_WHEN_REQUESTED = 1 << 7; 5342 5343 /** 5344 * Permission flag: The permission's usage should be made highly visible to the user 5345 * when granted. 5346 * 5347 * @hide 5348 */ 5349 @SystemApi 5350 public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED = 1 << 8; 5351 5352 /** 5353 * Permission flag: The permission's usage should be made highly visible to the user 5354 * when denied. 5355 * 5356 * @hide 5357 */ 5358 @SystemApi 5359 public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED = 1 << 9; 5360 5361 /** 5362 * Permission flag: The permission is restricted but the app is exempt 5363 * from the restriction and is allowed to hold this permission in its 5364 * full form and the exemption is provided by the installer on record. 5365 * 5366 * @hide 5367 */ 5368 @SystemApi 5369 public static final int FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT = 1 << 11; 5370 5371 /** 5372 * Permission flag: The permission is restricted but the app is exempt 5373 * from the restriction and is allowed to hold this permission in its 5374 * full form and the exemption is provided by the system due to its 5375 * permission policy. 5376 * 5377 * @hide 5378 */ 5379 @SystemApi 5380 public static final int FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT = 1 << 12; 5381 5382 /** 5383 * Permission flag: The permission is restricted but the app is exempt 5384 * from the restriction and is allowed to hold this permission and the 5385 * exemption is provided by the system when upgrading from an OS version 5386 * where the permission was not restricted to an OS version where the 5387 * permission is restricted. 5388 * 5389 * @hide 5390 */ 5391 @SystemApi 5392 public static final int FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT = 1 << 13; 5393 5394 5395 /** 5396 * Permission flag: The permission is disabled but may be granted. If 5397 * disabled the data protected by the permission should be protected 5398 * by a no-op (empty list, default error, etc) instead of crashing the 5399 * client. 5400 * 5401 * @hide 5402 */ 5403 @SystemApi 5404 public static final int FLAG_PERMISSION_APPLY_RESTRICTION = 1 << 14; 5405 5406 /** 5407 * Permission flag: The permission is granted because the application holds a role. 5408 * 5409 * @hide 5410 */ 5411 @SystemApi 5412 public static final int FLAG_PERMISSION_GRANTED_BY_ROLE = 1 << 15; 5413 5414 /** 5415 * Permission flag: The permission should have been revoked but is kept granted for 5416 * compatibility. The data protected by the permission should be protected by a no-op (empty 5417 * list, default error, etc) instead of crashing the client. The permission will be revoked if 5418 * the app is upgraded to supports it. 5419 * 5420 * @hide 5421 */ 5422 @SystemApi 5423 public static final int FLAG_PERMISSION_REVOKED_COMPAT = FLAG_PERMISSION_REVOKE_ON_UPGRADE; 5424 5425 /** 5426 * Permission flag: The permission is one-time and should be revoked automatically on app 5427 * inactivity 5428 * 5429 * @hide 5430 */ 5431 @SystemApi 5432 public static final int FLAG_PERMISSION_ONE_TIME = 1 << 16; 5433 5434 /** 5435 * Permission flag: Whether permission was revoked by auto-revoke. 5436 * 5437 * @hide 5438 */ 5439 @SystemApi 5440 public static final int FLAG_PERMISSION_AUTO_REVOKED = 1 << 17; 5441 5442 /** 5443 * Permission flag: This location permission is selected as the level of granularity of 5444 * location accuracy. 5445 * Example: If this flag is set for ACCESS_FINE_LOCATION, FINE location is the selected location 5446 * accuracy for location permissions. 5447 * 5448 * @hide 5449 */ 5450 @SystemApi 5451 public static final int FLAG_PERMISSION_SELECTED_LOCATION_ACCURACY = 1 << 19; 5452 5453 /** 5454 * Permission flags: Reserved for use by the permission controller. The platform and any 5455 * packages besides the permission controller should not assume any definition about these 5456 * flags. 5457 * @hide 5458 */ 5459 @SystemApi 5460 public static final int FLAGS_PERMISSION_RESERVED_PERMISSION_CONTROLLER = 1 << 28 | 1 << 29 5461 | 1 << 30 | 1 << 31; 5462 5463 /** 5464 * Permission flags: Bitwise or of all permission flags allowing an 5465 * exemption for a restricted permission. 5466 * @hide 5467 */ 5468 public static final int FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT = 5469 FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT 5470 | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT 5471 | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT; 5472 5473 /** 5474 * Mask for all permission flags. 5475 * 5476 * @hide 5477 * 5478 * @deprecated Don't use - does not capture all flags. 5479 */ 5480 @Deprecated 5481 @SystemApi 5482 public static final int MASK_PERMISSION_FLAGS = 0xFF; 5483 5484 /** 5485 * Mask for all permission flags. 5486 * 5487 * @hide 5488 */ 5489 public static final int MASK_PERMISSION_FLAGS_ALL = FLAG_PERMISSION_USER_SET 5490 | FLAG_PERMISSION_USER_FIXED 5491 | FLAG_PERMISSION_POLICY_FIXED 5492 | FLAG_PERMISSION_REVOKE_ON_UPGRADE 5493 | FLAG_PERMISSION_SYSTEM_FIXED 5494 | FLAG_PERMISSION_GRANTED_BY_DEFAULT 5495 | FLAG_PERMISSION_REVIEW_REQUIRED 5496 | FLAG_PERMISSION_REVOKE_WHEN_REQUESTED 5497 | FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED 5498 | FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED 5499 | FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT 5500 | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT 5501 | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT 5502 | FLAG_PERMISSION_APPLY_RESTRICTION 5503 | FLAG_PERMISSION_GRANTED_BY_ROLE 5504 | FLAG_PERMISSION_REVOKED_COMPAT 5505 | FLAG_PERMISSION_ONE_TIME 5506 | FLAG_PERMISSION_AUTO_REVOKED; 5507 5508 /** 5509 * Injected activity in app that forwards user to setting activity of that app. 5510 * 5511 * @hide 5512 */ 5513 public static final String APP_DETAILS_ACTIVITY_CLASS_NAME = AppDetailsActivity.class.getName(); 5514 5515 /** 5516 * Permission whitelist flag: permissions whitelisted by the system. 5517 * Permissions can also be whitelisted by the installer, on upgrade, or on 5518 * role grant. 5519 * 5520 * <p> 5521 * <strong>Note: </strong>In retrospect it would have been preferred to use 5522 * more inclusive terminology when naming this API. Similar APIs added will 5523 * refrain from using the term "whitelist". 5524 * </p> 5525 */ 5526 public static final int FLAG_PERMISSION_WHITELIST_SYSTEM = 1 << 0; 5527 5528 /** 5529 * Permission whitelist flag: permissions whitelisted by the installer. 5530 * Permissions can also be whitelisted by the system, on upgrade, or on role 5531 * grant. 5532 * 5533 * <p> 5534 * <strong>Note: </strong>In retrospect it would have been preferred to use 5535 * more inclusive terminology when naming this API. Similar APIs added will 5536 * refrain from using the term "whitelist". 5537 * </p> 5538 */ 5539 public static final int FLAG_PERMISSION_WHITELIST_INSTALLER = 1 << 1; 5540 5541 /** 5542 * Permission whitelist flag: permissions whitelisted by the system 5543 * when upgrading from an OS version where the permission was not 5544 * restricted to an OS version where the permission is restricted. 5545 * Permissions can also be whitelisted by the installer, the system, or on 5546 * role grant. 5547 * 5548 * <p> 5549 * <strong>Note: </strong>In retrospect it would have been preferred to use 5550 * more inclusive terminology when naming this API. Similar APIs added will 5551 * refrain from using the term "whitelist". 5552 * </p> 5553 */ 5554 public static final int FLAG_PERMISSION_WHITELIST_UPGRADE = 1 << 2; 5555 5556 /** @hide */ 5557 @IntDef(flag = true, prefix = {"FLAG_PERMISSION_WHITELIST_"}, value = { 5558 FLAG_PERMISSION_WHITELIST_SYSTEM, 5559 FLAG_PERMISSION_WHITELIST_INSTALLER, 5560 FLAG_PERMISSION_WHITELIST_UPGRADE 5561 }) 5562 @Retention(RetentionPolicy.SOURCE) 5563 public @interface PermissionWhitelistFlags {} 5564 5565 /** 5566 * This is a library that contains components apps can invoke. For 5567 * example, a services for apps to bind to, or standard chooser UI, 5568 * etc. This library is versioned and backwards compatible. Clients 5569 * should check its version via {@link android.ext.services.Version 5570 * #getVersionCode()} and avoid calling APIs added in later versions. 5571 * <p> 5572 * This shared library no longer exists since Android R. 5573 * 5574 * @see #getServicesSystemSharedLibraryPackageName() 5575 * 5576 * @hide 5577 */ 5578 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 5579 @TestApi 5580 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 5581 5582 /** 5583 * This is a library that contains components apps can dynamically 5584 * load. For example, new widgets, helper classes, etc. This library 5585 * is versioned and backwards compatible. Clients should check its 5586 * version via {@link android.ext.shared.Version#getVersionCode()} 5587 * and avoid calling APIs added in later versions. 5588 * 5589 * @hide 5590 */ 5591 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 5592 @TestApi 5593 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 5594 5595 /** @hide */ 5596 @IntDef({ 5597 NOTIFY_PACKAGE_USE_ACTIVITY, 5598 NOTIFY_PACKAGE_USE_SERVICE, 5599 NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE, 5600 NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER, 5601 NOTIFY_PACKAGE_USE_CONTENT_PROVIDER, 5602 NOTIFY_PACKAGE_USE_BACKUP, 5603 NOTIFY_PACKAGE_USE_CROSS_PACKAGE, 5604 NOTIFY_PACKAGE_USE_INSTRUMENTATION, 5605 }) 5606 public @interface NotifyReason { 5607 } 5608 5609 /** 5610 * Used when starting a process for an Activity. 5611 * 5612 * @hide 5613 */ 5614 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0; 5615 5616 /** 5617 * Used when starting a process for a Service. 5618 * 5619 * @hide 5620 */ 5621 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1; 5622 5623 /** 5624 * Used when moving a Service to the foreground. 5625 * 5626 * @hide 5627 */ 5628 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2; 5629 5630 /** 5631 * Used when starting a process for a BroadcastReceiver. 5632 * 5633 * @hide 5634 */ 5635 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3; 5636 5637 /** 5638 * Used when starting a process for a ContentProvider. 5639 * 5640 * @hide 5641 */ 5642 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4; 5643 5644 /** 5645 * Used when starting a process for a BroadcastReceiver. 5646 * 5647 * @hide 5648 */ 5649 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5; 5650 5651 /** 5652 * Used with Context.getClassLoader() across Android packages. 5653 * 5654 * @hide 5655 */ 5656 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6; 5657 5658 /** 5659 * Used when starting a package within a process for Instrumentation. 5660 * 5661 * @hide 5662 */ 5663 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7; 5664 5665 /** 5666 * Total number of usage reasons. 5667 * 5668 * @hide 5669 */ 5670 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8; 5671 5672 /** 5673 * Constant for specifying the highest installed package version code. 5674 */ 5675 public static final int VERSION_CODE_HIGHEST = -1; 5676 5677 /** 5678 * Apps targeting Android R and above will need to declare the packages and intents they intend 5679 * to use to get details about other apps on a device. Such declarations must be made via the 5680 * {@code <queries>} tag in the manifest. 5681 * 5682 * @hide 5683 */ 5684 @ChangeId 5685 @EnabledSince(targetSdkVersion = Build.VERSION_CODES.R) 5686 public static final long FILTER_APPLICATION_QUERY = 135549675L; 5687 5688 /** {@hide} */ 5689 @IntDef(prefix = {"SYSTEM_APP_STATE_"}, value = { 5690 SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN, 5691 SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE, 5692 SYSTEM_APP_STATE_INSTALLED, 5693 SYSTEM_APP_STATE_UNINSTALLED 5694 }) 5695 @Retention(RetentionPolicy.SOURCE) 5696 public @interface SystemAppState {} 5697 5698 /** 5699 * Constant for use with {@link #setSystemAppState} to mark a system app as hidden until 5700 * installation. 5701 * @hide 5702 */ 5703 @SystemApi 5704 public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN = 0; 5705 5706 /** 5707 * Constant for use with {@link #setSystemAppState} to mark a system app as not hidden until 5708 * installation. 5709 * @hide 5710 */ 5711 @SystemApi 5712 public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE = 1; 5713 5714 /** 5715 * Constant for use with {@link #setSystemAppState} to change a system app's state to installed. 5716 * @hide 5717 */ 5718 @SystemApi 5719 public static final int SYSTEM_APP_STATE_INSTALLED = 2; 5720 5721 /** 5722 * Constant for use with {@link #setSystemAppState} to change a system app's state to 5723 * uninstalled. 5724 * @hide 5725 */ 5726 @SystemApi 5727 public static final int SYSTEM_APP_STATE_UNINSTALLED = 3; 5728 5729 /** 5730 * A manifest property to control app's participation in {@code adb backup}. Should only 5731 * be used by system / privileged apps. 5732 * 5733 * @hide 5734 */ 5735 public static final String PROPERTY_ALLOW_ADB_BACKUP = "android.backup.ALLOW_ADB_BACKUP"; 5736 5737 /** 5738 * Flags class that wraps around the bitmask flags used in methods that retrieve package or 5739 * application info. 5740 * @hide 5741 */ 5742 @android.ravenwood.annotation.RavenwoodKeepWholeClass 5743 public static class Flags { 5744 final long mValue; Flags(long value)5745 protected Flags(long value) { 5746 mValue = value; 5747 } getValue()5748 public long getValue() { 5749 return mValue; 5750 } 5751 } 5752 5753 /** 5754 * Specific flags used for retrieving package info. Example: 5755 * {@code PackageManager.getPackageInfo(packageName, PackageInfoFlags.of(0)} 5756 */ 5757 @android.ravenwood.annotation.RavenwoodKeepWholeClass 5758 public final static class PackageInfoFlags extends Flags { PackageInfoFlags(@ackageInfoFlagsBits long value)5759 private PackageInfoFlags(@PackageInfoFlagsBits long value) { 5760 super(value); 5761 } 5762 @NonNull of(@ackageInfoFlagsBits long value)5763 public static PackageInfoFlags of(@PackageInfoFlagsBits long value) { 5764 return new PackageInfoFlags(value); 5765 } 5766 } 5767 5768 /** 5769 * Specific flags used for retrieving application info. 5770 */ 5771 @android.ravenwood.annotation.RavenwoodKeepWholeClass 5772 public final static class ApplicationInfoFlags extends Flags { ApplicationInfoFlags(@pplicationInfoFlagsBits long value)5773 private ApplicationInfoFlags(@ApplicationInfoFlagsBits long value) { 5774 super(value); 5775 } 5776 @NonNull of(@pplicationInfoFlagsBits long value)5777 public static ApplicationInfoFlags of(@ApplicationInfoFlagsBits long value) { 5778 return new ApplicationInfoFlags(value); 5779 } 5780 } 5781 5782 /** 5783 * Specific flags used for retrieving component info. 5784 */ 5785 @android.ravenwood.annotation.RavenwoodKeepWholeClass 5786 public final static class ComponentInfoFlags extends Flags { ComponentInfoFlags(@omponentInfoFlagsBits long value)5787 private ComponentInfoFlags(@ComponentInfoFlagsBits long value) { 5788 super(value); 5789 } 5790 @NonNull of(@omponentInfoFlagsBits long value)5791 public static ComponentInfoFlags of(@ComponentInfoFlagsBits long value) { 5792 return new ComponentInfoFlags(value); 5793 } 5794 } 5795 5796 /** 5797 * Specific flags used for retrieving resolve info. 5798 */ 5799 @android.ravenwood.annotation.RavenwoodKeepWholeClass 5800 public final static class ResolveInfoFlags extends Flags { ResolveInfoFlags(@esolveInfoFlagsBits long value)5801 private ResolveInfoFlags(@ResolveInfoFlagsBits long value) { 5802 super(value); 5803 } 5804 @NonNull of(@esolveInfoFlagsBits long value)5805 public static ResolveInfoFlags of(@ResolveInfoFlagsBits long value) { 5806 return new ResolveInfoFlags(value); 5807 } 5808 } 5809 5810 /** {@hide} */ getUserId()5811 public int getUserId() { 5812 return UserHandle.myUserId(); 5813 } 5814 5815 /** 5816 * @deprecated Do not instantiate or subclass - obtain an instance from 5817 * {@link Context#getPackageManager} 5818 */ 5819 @Deprecated PackageManager()5820 public PackageManager() {} 5821 5822 /** 5823 * Retrieve overall information about an application package that is 5824 * installed on the system. 5825 * 5826 * Use {@link #getPackageInfo(String, PackageInfoFlags)} when long flags are needed. 5827 * 5828 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5829 * desired package. 5830 * @param flags Additional option flags to modify the data returned. 5831 * @return A PackageInfo object containing information about the package. If 5832 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 5833 * is not found in the list of installed applications, the package 5834 * information is retrieved from the list of uninstalled 5835 * applications (which includes installed applications as well as 5836 * applications with data directory i.e. applications which had been 5837 * deleted with {@code DELETE_KEEP_DATA} flag set). 5838 * @throws NameNotFoundException if no such package is available to the 5839 * caller. 5840 */ getPackageInfo(@onNull String packageName, int flags)5841 public abstract PackageInfo getPackageInfo(@NonNull String packageName, int flags) 5842 throws NameNotFoundException; 5843 5844 /** 5845 * See {@link #getPackageInfo(String, int)} 5846 */ 5847 @NonNull getPackageInfo(@onNull String packageName, @NonNull PackageInfoFlags flags)5848 public PackageInfo getPackageInfo(@NonNull String packageName, @NonNull PackageInfoFlags flags) 5849 throws NameNotFoundException { 5850 throw new UnsupportedOperationException( 5851 "getPackageInfo not implemented in subclass"); 5852 } 5853 5854 /** 5855 * Retrieve overall information about an application package that is 5856 * installed on the system. This method can be used for retrieving 5857 * information about packages for which multiple versions can be installed 5858 * at the time. Currently only packages hosting static shared libraries can 5859 * have multiple installed versions. The method can also be used to get info 5860 * for a package that has a single version installed by passing 5861 * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage} 5862 * constructor. 5863 * 5864 * Use {@link #getPackageInfo(VersionedPackage, PackageInfoFlags)} when long flags are needed. 5865 * 5866 * @param versionedPackage The versioned package for which to query. 5867 * @param flags Additional option flags to modify the data returned. 5868 * @return A PackageInfo object containing information about the package. If 5869 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 5870 * is not found in the list of installed applications, the package 5871 * information is retrieved from the list of uninstalled 5872 * applications (which includes installed applications as well as 5873 * applications with data directory i.e. applications which had been 5874 * deleted with {@code DELETE_KEEP_DATA} flag set). 5875 * @throws NameNotFoundException if no such package is available to the 5876 * caller. 5877 */ getPackageInfo(@onNull VersionedPackage versionedPackage, int flags)5878 public abstract PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage, 5879 int flags) throws NameNotFoundException; 5880 5881 /** 5882 * See {@link #getPackageInfo(VersionedPackage, int)} 5883 */ 5884 @NonNull getPackageInfo(@onNull VersionedPackage versionedPackage, @NonNull PackageInfoFlags flags)5885 public PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage, 5886 @NonNull PackageInfoFlags flags) throws NameNotFoundException { 5887 throw new UnsupportedOperationException( 5888 "getPackageInfo not implemented in subclass"); 5889 } 5890 5891 /** 5892 * Retrieve overall information about an application package that is 5893 * installed on the system. 5894 * 5895 * Use {@link #getPackageInfoAsUser(String, PackageInfoFlags, int)} when long flags are needed. 5896 * 5897 * @param packageName The full name (i.e. com.google.apps.contacts) of the 5898 * desired package. 5899 * @param flags Additional option flags to modify the data returned. 5900 * @param userId The user id. 5901 * @return A PackageInfo object containing information about the package. If 5902 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 5903 * is not found in the list of installed applications, the package 5904 * information is retrieved from the list of uninstalled 5905 * applications (which includes installed applications as well as 5906 * applications with data directory i.e. applications which had been 5907 * deleted with {@code DELETE_KEEP_DATA} flag set). 5908 * @throws NameNotFoundException if no such package is available to the 5909 * caller. 5910 * @hide 5911 */ 5912 @SuppressWarnings("HiddenAbstractMethod") 5913 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 5914 @UnsupportedAppUsage getPackageInfoAsUser(@onNull String packageName, int flags, @UserIdInt int userId)5915 public abstract PackageInfo getPackageInfoAsUser(@NonNull String packageName, 5916 int flags, @UserIdInt int userId) throws NameNotFoundException; 5917 5918 /** 5919 * See {@link #getPackageInfoAsUser(String, int, int)} 5920 * @hide 5921 */ 5922 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 5923 @NonNull getPackageInfoAsUser(@onNull String packageName, @NonNull PackageInfoFlags flags, @UserIdInt int userId)5924 public PackageInfo getPackageInfoAsUser(@NonNull String packageName, 5925 @NonNull PackageInfoFlags flags, @UserIdInt int userId) throws NameNotFoundException { 5926 throw new UnsupportedOperationException( 5927 "getPackageInfoAsUser not implemented in subclass"); 5928 } 5929 5930 /** 5931 * Map from the current package names in use on the device to whatever 5932 * the current canonical name of that package is. 5933 * @param packageNames Array of current names to be mapped. 5934 * @return Returns an array of the same size as the original, containing 5935 * the canonical name for each package. 5936 */ currentToCanonicalPackageNames(@onNull String[] packageNames)5937 public abstract String[] currentToCanonicalPackageNames(@NonNull String[] packageNames); 5938 5939 /** 5940 * Map from a packages canonical name to the current name in use on the device. 5941 * @param packageNames Array of new names to be mapped. 5942 * @return Returns an array of the same size as the original, containing 5943 * the current name for each package. 5944 */ canonicalToCurrentPackageNames(@onNull String[] packageNames)5945 public abstract String[] canonicalToCurrentPackageNames(@NonNull String[] packageNames); 5946 5947 /** 5948 * Returns a "good" intent to launch a front-door activity in a package. 5949 * This is used, for example, to implement an "open" button when browsing 5950 * through packages. The current implementation looks first for a main 5951 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 5952 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 5953 * <code>null</code> if neither are found. 5954 * 5955 * <p>Consider using {@link #getLaunchIntentSenderForPackage(String)} if 5956 * the caller is not allowed to query for the <code>packageName</code>. 5957 * 5958 * @param packageName The name of the package to inspect. 5959 * 5960 * @return A fully-qualified {@link Intent} that can be used to launch the 5961 * main activity in the package. Returns <code>null</code> if the package 5962 * does not contain such an activity, or if <em>packageName</em> is not 5963 * recognized. 5964 * 5965 * @see #getLaunchIntentSenderForPackage(String) 5966 */ getLaunchIntentForPackage(@onNull String packageName)5967 public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName); 5968 5969 /** 5970 * Returns a "good" intent to launch a front-door activity in a package. 5971 * This is used, for example, to implement an "open" button when browsing 5972 * through packages. The current implementation looks first for a main 5973 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 5974 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 5975 * <code>null</code> if neither are found. 5976 * 5977 * <p>Consider using {@link #getLaunchIntentSenderForPackage(String)} if 5978 * the caller is not allowed to query for the <code>packageName</code>. 5979 * 5980 * @param packageName The name of the package to inspect. 5981 * @param includeDirectBootUnaware When {@code true}, activities that are direct-boot-unaware 5982 * will be considered even if the device hasn't been unlocked (i.e. querying will be done 5983 * with {@code MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE}). 5984 * 5985 * @return A fully-qualified {@link Intent} that can be used to launch the 5986 * main activity in the package. Returns <code>null</code> if the package 5987 * does not contain such an activity, or if <em>packageName</em> is not 5988 * recognized. 5989 * 5990 * @see #getLaunchIntentSenderForPackage(String) 5991 * 5992 * @hide 5993 */ getLaunchIntentForPackage(@onNull String packageName, boolean includeDirectBootUnaware)5994 public @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName, 5995 boolean includeDirectBootUnaware) { 5996 throw new UnsupportedOperationException( 5997 "getLaunchIntentForPackage(packageName, includeDirectBootUnaware) not implemented" 5998 + " in subclass"); 5999 } 6000 6001 /** 6002 * Return a "good" intent to launch a front-door Leanback activity in a 6003 * package, for use for example to implement an "open" button when browsing 6004 * through packages. The current implementation will look for a main 6005 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 6006 * return null if no main leanback activities are found. 6007 * 6008 * @param packageName The name of the package to inspect. 6009 * @return Returns either a fully-qualified Intent that can be used to launch 6010 * the main Leanback activity in the package, or null if the package 6011 * does not contain such an activity. 6012 */ getLeanbackLaunchIntentForPackage(@onNull String packageName)6013 public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName); 6014 6015 /** 6016 * Return a "good" intent to launch a front-door Car activity in a 6017 * package, for use for example to implement an "open" button when browsing 6018 * through packages. The current implementation will look for a main 6019 * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or 6020 * return null if no main car activities are found. 6021 * 6022 * @param packageName The name of the package to inspect. 6023 * @return Returns either a fully-qualified Intent that can be used to launch 6024 * the main Car activity in the package, or null if the package 6025 * does not contain such an activity. 6026 * @hide 6027 */ 6028 @SuppressWarnings("HiddenAbstractMethod") getCarLaunchIntentForPackage(@onNull String packageName)6029 public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName); 6030 6031 /** 6032 * Returns an {@link IntentSender} that can be used to launch a front-door activity in a 6033 * package. This is used, for example, to implement an "open" button when browsing through 6034 * packages. The current implementation is the same with 6035 * {@link #getLaunchIntentForPackage(String)}. Instead of returning the {@link Intent}, it 6036 * returns the {@link IntentSender} which is not restricted by the package visibility. 6037 * 6038 * <p>The caller can invoke 6039 * {@link IntentSender#sendIntent(Context, int, Intent, IntentSender.OnFinished, Handler)} 6040 * to launch the activity. An {@link IntentSender.SendIntentException} is thrown if the 6041 * package does not contain such an activity, or if <em>packageName</em> is not recognized. 6042 * 6043 * @param packageName The name of the package to inspect. 6044 * @return Returns a {@link IntentSender} to launch the activity. 6045 * 6046 * @see #getLaunchIntentForPackage(String) 6047 */ getLaunchIntentSenderForPackage(@onNull String packageName)6048 public @NonNull IntentSender getLaunchIntentSenderForPackage(@NonNull String packageName) { 6049 throw new UnsupportedOperationException("getLaunchIntentSenderForPackage not implemented" 6050 + "in subclass"); 6051 } 6052 6053 /** 6054 * Return an array of all of the POSIX secondary group IDs that have been 6055 * assigned to the given package. 6056 * <p> 6057 * Note that the same package may have different GIDs under different 6058 * {@link UserHandle} on the same device. 6059 * 6060 * @param packageName The full name (i.e. com.google.apps.contacts) of the 6061 * desired package. 6062 * @return Returns an int array of the assigned GIDs, or null if there are 6063 * none. 6064 * @throws NameNotFoundException if no such package is available to the 6065 * caller. 6066 */ getPackageGids(@onNull String packageName)6067 public abstract int[] getPackageGids(@NonNull String packageName) 6068 throws NameNotFoundException; 6069 6070 /** 6071 * Return an array of all of the POSIX secondary group IDs that have been 6072 * assigned to the given package. 6073 * <p> 6074 * Note that the same package may have different GIDs under different 6075 * {@link UserHandle} on the same device. 6076 * 6077 * Use {@link #getPackageGids(String, PackageInfoFlags)} when long flags are needed. 6078 * 6079 * @param packageName The full name (i.e. com.google.apps.contacts) of the 6080 * desired package. 6081 * @return Returns an int array of the assigned gids, or null if there are 6082 * none. 6083 * @throws NameNotFoundException if no such package is available to the 6084 * caller. 6085 */ 6086 getPackageGids(@onNull String packageName, int flags)6087 public abstract int[] getPackageGids(@NonNull String packageName, int flags) 6088 throws NameNotFoundException; 6089 6090 /** 6091 * See {@link #getPackageGids(String, int)}. 6092 */ 6093 @Nullable getPackageGids(@onNull String packageName, @NonNull PackageInfoFlags flags)6094 public int[] getPackageGids(@NonNull String packageName, @NonNull PackageInfoFlags flags) 6095 throws NameNotFoundException { 6096 throw new UnsupportedOperationException( 6097 "getPackageGids not implemented in subclass"); 6098 } 6099 6100 /** 6101 * Return the UID associated with the given package name. 6102 * <p> 6103 * Note that the same package will have different UIDs under different 6104 * {@link UserHandle} on the same device. 6105 * 6106 * Use {@link #getPackageUid(String, PackageInfoFlags)} when long flags are needed. 6107 * 6108 * @param packageName The full name (i.e. com.google.apps.contacts) of the 6109 * desired package. 6110 * @return Returns an integer UID who owns the given package name. 6111 * @throws NameNotFoundException if no such package is available to the 6112 * caller. 6113 */ getPackageUid(@onNull String packageName, int flags)6114 public abstract int getPackageUid(@NonNull String packageName, int flags) 6115 throws NameNotFoundException; 6116 6117 /** 6118 * See {@link #getPackageUid(String, int)}. 6119 */ getPackageUid(@onNull String packageName, @NonNull PackageInfoFlags flags)6120 public int getPackageUid(@NonNull String packageName, @NonNull PackageInfoFlags flags) 6121 throws NameNotFoundException { 6122 throw new UnsupportedOperationException( 6123 "getPackageUid not implemented in subclass"); 6124 } 6125 6126 /** 6127 * Return the UID associated with the given package name. 6128 * <p> 6129 * Note that the same package will have different UIDs under different 6130 * {@link UserHandle} on the same device. 6131 * 6132 * @param packageName The full name (i.e. com.google.apps.contacts) of the 6133 * desired package. 6134 * @param userId The user handle identifier to look up the package under. 6135 * @return Returns an integer UID who owns the given package name. 6136 * @throws NameNotFoundException if no such package is available to the 6137 * caller. 6138 * @hide 6139 */ 6140 @SuppressWarnings("HiddenAbstractMethod") 6141 @UnsupportedAppUsage getPackageUidAsUser(@onNull String packageName, @UserIdInt int userId)6142 public abstract int getPackageUidAsUser(@NonNull String packageName, @UserIdInt int userId) 6143 throws NameNotFoundException; 6144 6145 /** 6146 * See {@link #getPackageUidAsUser(String, PackageInfoFlags, int)}. 6147 * Use {@link #getPackageUidAsUser(String, PackageInfoFlags, int)} when long flags are needed. 6148 * @hide 6149 */ 6150 @SuppressWarnings("HiddenAbstractMethod") 6151 @UnsupportedAppUsage getPackageUidAsUser(@onNull String packageName, int flags, @UserIdInt int userId)6152 public abstract int getPackageUidAsUser(@NonNull String packageName, 6153 int flags, @UserIdInt int userId) throws NameNotFoundException; 6154 6155 /** 6156 * Return the UID associated with the given package name. 6157 * <p> 6158 * Note that the same package will have different UIDs under different 6159 * {@link UserHandle} on the same device. 6160 * 6161 * @param packageName The full name (i.e. com.google.apps.contacts) of the 6162 * desired package. 6163 * @param flags Additional option flags to modify the data returned. 6164 * @param userId The user handle identifier to look up the package under. 6165 * @return Returns an integer UID who owns the given package name. 6166 * @throws NameNotFoundException if no such package is available to the 6167 * caller. 6168 * @hide 6169 */ 6170 @SystemApi 6171 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) getPackageUidAsUser(@onNull String packageName, @NonNull PackageInfoFlags flags, @UserIdInt int userId)6172 public int getPackageUidAsUser(@NonNull String packageName, @NonNull PackageInfoFlags flags, 6173 @UserIdInt int userId) throws NameNotFoundException { 6174 throw new UnsupportedOperationException( 6175 "getPackageUidAsUser not implemented in subclass"); 6176 } 6177 6178 /** 6179 * Retrieve all of the information we know about a particular permission. 6180 * 6181 * @param permName The fully qualified name (i.e. com.google.permission.LOGIN) 6182 * of the permission you are interested in. 6183 * @param flags Additional option flags to modify the data returned. 6184 * @return Returns a {@link PermissionInfo} containing information about the 6185 * permission. 6186 * @throws NameNotFoundException if a package with the given name cannot be 6187 * found on the system. 6188 */ 6189 //@Deprecated getPermissionInfo(@onNull String permName, @PermissionInfoFlags int flags)6190 public abstract PermissionInfo getPermissionInfo(@NonNull String permName, 6191 @PermissionInfoFlags int flags) throws NameNotFoundException; 6192 6193 /** 6194 * Query for all of the permissions associated with a particular group. 6195 * 6196 * @param permissionGroup The fully qualified name (i.e. com.google.permission.LOGIN) 6197 * of the permission group you are interested in. Use {@code null} to 6198 * find all of the permissions not associated with a group. 6199 * @param flags Additional option flags to modify the data returned. 6200 * @return Returns a list of {@link PermissionInfo} containing information 6201 * about all of the permissions in the given group. 6202 * @throws NameNotFoundException if a group with the given name cannot be 6203 * found on the system. 6204 */ 6205 //@Deprecated 6206 @NonNull queryPermissionsByGroup(@ullable String permissionGroup, @PermissionInfoFlags int flags)6207 public abstract List<PermissionInfo> queryPermissionsByGroup(@Nullable String permissionGroup, 6208 @PermissionInfoFlags int flags) throws NameNotFoundException; 6209 6210 /** 6211 * Returns true if some permissions are individually controlled. 6212 * 6213 * <p>The user usually grants and revokes permission-groups. If this option is set some 6214 * dangerous system permissions can be revoked/granted by the user separately from their group. 6215 * 6216 * @hide 6217 */ 6218 @SuppressWarnings("HiddenAbstractMethod") 6219 @SystemApi arePermissionsIndividuallyControlled()6220 public abstract boolean arePermissionsIndividuallyControlled(); 6221 6222 /** 6223 * Returns true if wireless consent mode is enabled 6224 * 6225 * @hide 6226 */ 6227 @SuppressWarnings("HiddenAbstractMethod") isWirelessConsentModeEnabled()6228 public abstract boolean isWirelessConsentModeEnabled(); 6229 6230 /** 6231 * Retrieve all of the information we know about a particular group of 6232 * permissions. 6233 * 6234 * @param groupName The fully qualified name (i.e. 6235 * com.google.permission_group.APPS) of the permission you are 6236 * interested in. 6237 * @param flags Additional option flags to modify the data returned. 6238 * @return Returns a {@link PermissionGroupInfo} containing information 6239 * about the permission. 6240 * @throws NameNotFoundException if a package with the given name cannot be 6241 * found on the system. 6242 */ 6243 //@Deprecated 6244 @NonNull getPermissionGroupInfo(@onNull String groupName, @PermissionGroupInfoFlags int flags)6245 public abstract PermissionGroupInfo getPermissionGroupInfo(@NonNull String groupName, 6246 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 6247 6248 /** 6249 * Retrieve all of the known permission groups in the system. 6250 * 6251 * @param flags Additional option flags to modify the data returned. 6252 * @return Returns a list of {@link PermissionGroupInfo} containing 6253 * information about all of the known permission groups. 6254 */ 6255 //@Deprecated 6256 @NonNull getAllPermissionGroups( @ermissionGroupInfoFlags int flags)6257 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 6258 @PermissionGroupInfoFlags int flags); 6259 6260 /** 6261 * Get the platform-defined permissions which belong to a particular permission group. 6262 * 6263 * @param permissionGroupName the permission group whose permissions are desired 6264 * @param executor the {@link Executor} on which to invoke the callback 6265 * @param callback the callback which will receive a list of the platform-defined permissions in 6266 * the group, or empty if the group is not a valid platform-defined permission 6267 * group, or there was an exception 6268 */ getPlatformPermissionsForGroup(@onNull String permissionGroupName, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<List<String>> callback)6269 public void getPlatformPermissionsForGroup(@NonNull String permissionGroupName, 6270 @NonNull @CallbackExecutor Executor executor, 6271 @NonNull Consumer<List<String>> callback) {} 6272 6273 /** 6274 * Get the platform-defined permission group of a particular permission, if the permission is a 6275 * platform-defined permission. 6276 * 6277 * @param permissionName the permission whose group is desired 6278 * @param executor the {@link Executor} on which to invoke the callback 6279 * @param callback the callback which will receive the name of the permission group this 6280 * permission belongs to, or {@code null} if it has no group, is not a 6281 * platform-defined permission, or there was an exception 6282 */ getGroupOfPlatformPermission(@onNull String permissionName, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback)6283 public void getGroupOfPlatformPermission(@NonNull String permissionName, 6284 @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback) {} 6285 6286 /** 6287 * Retrieve all of the information we know about a particular 6288 * package/application. 6289 * 6290 * Use {@link #getApplicationInfo(String, ApplicationInfoFlags)} when long flags are needed. 6291 * 6292 * @param packageName The full name (i.e. com.google.apps.contacts) of an 6293 * application. 6294 * @param flags Additional option flags to modify the data returned. 6295 * @return An {@link ApplicationInfo} containing information about the 6296 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if 6297 * the package is not found in the list of installed applications, 6298 * the application information is retrieved from the list of 6299 * uninstalled applications (which includes installed applications 6300 * as well as applications with data directory i.e. applications 6301 * which had been deleted with {@code DELETE_KEEP_DATA} flag set). 6302 * @throws NameNotFoundException if a package with the given name cannot be 6303 * found on the system. 6304 */ 6305 @NonNull getApplicationInfo(@onNull String packageName, int flags)6306 public abstract ApplicationInfo getApplicationInfo(@NonNull String packageName, 6307 int flags) throws NameNotFoundException; 6308 6309 /** 6310 * See {@link #getApplicationInfo(String, int)}. 6311 */ 6312 @NonNull getApplicationInfo(@onNull String packageName, @NonNull ApplicationInfoFlags flags)6313 public ApplicationInfo getApplicationInfo(@NonNull String packageName, 6314 @NonNull ApplicationInfoFlags flags) throws NameNotFoundException { 6315 throw new UnsupportedOperationException( 6316 "getApplicationInfo not implemented in subclass"); 6317 } 6318 6319 /** 6320 * Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, int)} when long flags are 6321 * needed. 6322 * {@hide} 6323 */ 6324 @SuppressWarnings("HiddenAbstractMethod") 6325 @NonNull 6326 @UnsupportedAppUsage getApplicationInfoAsUser(@onNull String packageName, int flags, @UserIdInt int userId)6327 public abstract ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 6328 int flags, @UserIdInt int userId) throws NameNotFoundException; 6329 6330 /** {@hide} */ 6331 @NonNull getApplicationInfoAsUser(@onNull String packageName, @NonNull ApplicationInfoFlags flags, @UserIdInt int userId)6332 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 6333 @NonNull ApplicationInfoFlags flags, @UserIdInt int userId) 6334 throws NameNotFoundException { 6335 throw new UnsupportedOperationException( 6336 "getApplicationInfoAsUser not implemented in subclass"); 6337 } 6338 6339 /** 6340 * Retrieve all of the information we know about a particular 6341 * package/application, for a specific user. 6342 * 6343 * Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, UserHandle)} when long 6344 * flags are needed. 6345 * 6346 * @param packageName The full name (i.e. com.google.apps.contacts) of an 6347 * application. 6348 * @param flags Additional option flags to modify the data returned. 6349 * @return An {@link ApplicationInfo} containing information about the 6350 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if 6351 * the package is not found in the list of installed applications, 6352 * the application information is retrieved from the list of 6353 * uninstalled applications (which includes installed applications 6354 * as well as applications with data directory i.e. applications 6355 * which had been deleted with {@code DELETE_KEEP_DATA} flag set). 6356 * @throws NameNotFoundException if a package with the given name cannot be 6357 * found on the system. 6358 * @hide 6359 */ 6360 @NonNull 6361 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 6362 @SystemApi getApplicationInfoAsUser(@onNull String packageName, int flags, @NonNull UserHandle user)6363 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 6364 int flags, @NonNull UserHandle user) 6365 throws NameNotFoundException { 6366 return getApplicationInfoAsUser(packageName, flags, user.getIdentifier()); 6367 } 6368 6369 /** 6370 * See {@link #getApplicationInfoAsUser(String, int, UserHandle)}. 6371 * @hide 6372 */ 6373 @NonNull 6374 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 6375 @SystemApi getApplicationInfoAsUser(@onNull String packageName, @NonNull ApplicationInfoFlags flags, @NonNull UserHandle user)6376 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 6377 @NonNull ApplicationInfoFlags flags, @NonNull UserHandle user) 6378 throws NameNotFoundException { 6379 return getApplicationInfoAsUser(packageName, flags, user.getIdentifier()); 6380 } 6381 6382 /** 6383 * @return The target SDK version for the given package name. 6384 * @throws NameNotFoundException if a package with the given name cannot be found on the system. 6385 */ 6386 @IntRange(from = 0) getTargetSdkVersion(@onNull String packageName)6387 public int getTargetSdkVersion(@NonNull String packageName) throws NameNotFoundException { 6388 throw new UnsupportedOperationException(); 6389 } 6390 6391 /** 6392 * Retrieve all of the information we know about a particular activity 6393 * class. 6394 * 6395 * Use {@link #getActivityInfo(ComponentName, ComponentInfoFlags)} when long flags are needed. 6396 * 6397 * @param component The full component name (i.e. 6398 * com.google.apps.contacts/com.google.apps.contacts. 6399 * ContactsList) of an Activity class. 6400 * @param flags Additional option flags to modify the data returned. 6401 * @return An {@link ActivityInfo} containing information about the 6402 * activity. 6403 * @throws NameNotFoundException if a package with the given name cannot be 6404 * found on the system. 6405 */ 6406 @NonNull getActivityInfo(@onNull ComponentName component, int flags)6407 public abstract ActivityInfo getActivityInfo(@NonNull ComponentName component, 6408 int flags) throws NameNotFoundException; 6409 6410 /** 6411 * See {@link #getActivityInfo(ComponentName, int)}. 6412 */ 6413 @NonNull getActivityInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)6414 public ActivityInfo getActivityInfo(@NonNull ComponentName component, 6415 @NonNull ComponentInfoFlags flags) throws NameNotFoundException { 6416 throw new UnsupportedOperationException( 6417 "getActivityInfo not implemented in subclass"); 6418 } 6419 6420 /** 6421 * Retrieve all of the information we know about a particular receiver 6422 * class. 6423 * 6424 * Use {@link #getReceiverInfo(ComponentName, ComponentInfoFlags)} when long flags are needed. 6425 * 6426 * @param component The full component name (i.e. 6427 * com.google.apps.calendar/com.google.apps.calendar. 6428 * CalendarAlarm) of a Receiver class. 6429 * @param flags Additional option flags to modify the data returned. 6430 * @return An {@link ActivityInfo} containing information about the 6431 * receiver. 6432 * @throws NameNotFoundException if a package with the given name cannot be 6433 * found on the system. 6434 */ 6435 @NonNull getReceiverInfo(@onNull ComponentName component, int flags)6436 public abstract ActivityInfo getReceiverInfo(@NonNull ComponentName component, 6437 int flags) throws NameNotFoundException; 6438 6439 /** 6440 * See {@link #getReceiverInfo(ComponentName, int)}. 6441 */ 6442 @NonNull getReceiverInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)6443 public ActivityInfo getReceiverInfo(@NonNull ComponentName component, 6444 @NonNull ComponentInfoFlags flags) throws NameNotFoundException { 6445 throw new UnsupportedOperationException( 6446 "getReceiverInfo not implemented in subclass"); 6447 } 6448 6449 /** 6450 * Retrieve all of the information we know about a particular service class. 6451 * 6452 * Use {@link #getServiceInfo(ComponentName, ComponentInfoFlags)} when long flags are needed. 6453 * 6454 * @param component The full component name (i.e. 6455 * com.google.apps.media/com.google.apps.media. 6456 * BackgroundPlayback) of a Service class. 6457 * @param flags Additional option flags to modify the data returned. 6458 * @return A {@link ServiceInfo} object containing information about the 6459 * service. 6460 * @throws NameNotFoundException if the component cannot be found on the system. 6461 */ 6462 @NonNull getServiceInfo(@onNull ComponentName component, int flags)6463 public abstract ServiceInfo getServiceInfo(@NonNull ComponentName component, 6464 int flags) throws NameNotFoundException; 6465 6466 /** 6467 * See {@link #getServiceInfo(ComponentName, int)}. 6468 */ 6469 @NonNull getServiceInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)6470 public ServiceInfo getServiceInfo(@NonNull ComponentName component, 6471 @NonNull ComponentInfoFlags flags) throws NameNotFoundException { 6472 throw new UnsupportedOperationException( 6473 "getServiceInfo not implemented in subclass"); 6474 } 6475 6476 /** 6477 * Retrieve all of the information we know about a particular content 6478 * provider class. 6479 * 6480 * Use {@link #getProviderInfo(ComponentName, ComponentInfoFlags)} when long flags are needed. 6481 * 6482 * @param component The full component name (i.e. 6483 * com.google.providers.media/com.google.providers.media. 6484 * MediaProvider) of a ContentProvider class. 6485 * @param flags Additional option flags to modify the data returned. 6486 * @return A {@link ProviderInfo} object containing information about the 6487 * provider. 6488 * @throws NameNotFoundException if a package with the given name cannot be 6489 * found on the system. 6490 */ 6491 @NonNull getProviderInfo(@onNull ComponentName component, int flags)6492 public abstract ProviderInfo getProviderInfo(@NonNull ComponentName component, 6493 int flags) throws NameNotFoundException; 6494 6495 /** 6496 * See {@link #getProviderInfo(ComponentName, int)}. 6497 */ 6498 @NonNull getProviderInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)6499 public ProviderInfo getProviderInfo(@NonNull ComponentName component, 6500 @NonNull ComponentInfoFlags flags) throws NameNotFoundException { 6501 throw new UnsupportedOperationException( 6502 "getProviderInfo not implemented in subclass"); 6503 } 6504 6505 /** 6506 * Retrieve information for a particular module. 6507 * 6508 * @param packageName The name of the module. 6509 * @param flags Additional option flags to modify the data returned. 6510 * @return A {@link ModuleInfo} object containing information about the 6511 * module. 6512 * @throws NameNotFoundException if a module with the given name cannot be 6513 * found on the system. 6514 */ 6515 @NonNull getModuleInfo(@onNull String packageName, @ModuleInfoFlags int flags)6516 public ModuleInfo getModuleInfo(@NonNull String packageName, @ModuleInfoFlags int flags) 6517 throws NameNotFoundException { 6518 throw new UnsupportedOperationException( 6519 "getModuleInfo not implemented in subclass"); 6520 } 6521 6522 /** 6523 * Return a List of all modules that are installed. 6524 * 6525 * @param flags Additional option flags to modify the data returned. 6526 * @return A {@link List} of {@link ModuleInfo} objects, one for each installed 6527 * module, containing information about the module. In the unlikely case 6528 * there are no installed modules, an empty list is returned. 6529 */ 6530 @NonNull getInstalledModules(@nstalledModulesFlags int flags)6531 public List<ModuleInfo> getInstalledModules(@InstalledModulesFlags int flags) { 6532 throw new UnsupportedOperationException( 6533 "getInstalledModules not implemented in subclass"); 6534 } 6535 6536 /** 6537 * Return a List of all packages that are installed for the current user. 6538 * 6539 * Use {@link #getInstalledPackages(PackageInfoFlags)} when long flags are needed. 6540 * 6541 * @param flags Additional option flags to modify the data returned. 6542 * @return A List of PackageInfo objects, one for each installed package, 6543 * containing information about the package. In the unlikely case 6544 * there are no installed packages, an empty list is returned. If 6545 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 6546 * information is retrieved from the list of uninstalled 6547 * applications (which includes installed applications as well as 6548 * applications with data directory i.e. applications which had been 6549 * deleted with {@code DELETE_KEEP_DATA} flag set). 6550 */ 6551 @NonNull getInstalledPackages(int flags)6552 public abstract List<PackageInfo> getInstalledPackages(int flags); 6553 6554 /** 6555 * See {@link #getInstalledPackages(int)}. 6556 */ 6557 @NonNull getInstalledPackages(@onNull PackageInfoFlags flags)6558 public List<PackageInfo> getInstalledPackages(@NonNull PackageInfoFlags flags) { 6559 throw new UnsupportedOperationException( 6560 "getInstalledPackages not implemented in subclass"); 6561 } 6562 6563 /** 6564 * Returns the app metadata for a package. 6565 * 6566 * @param packageName The package name for which to get the app metadata. 6567 * @return A PersistableBundle containing the app metadata that was provided by the installer. 6568 * In the case where a package does not have any metadata, an empty PersistableBundle is 6569 * returned. 6570 * @throws NameNotFoundException if no such package is available to the caller. 6571 * @hide 6572 */ 6573 @NonNull 6574 @SystemApi 6575 @RequiresPermission(Manifest.permission.GET_APP_METADATA) getAppMetadata(@onNull String packageName)6576 public PersistableBundle getAppMetadata(@NonNull String packageName) 6577 throws NameNotFoundException { 6578 throw new UnsupportedOperationException("getAppMetadata not implemented in subclass"); 6579 } 6580 6581 6582 /** 6583 * Returns the source of the app metadata that is currently associated with the given package. 6584 * The value can be {@link #APP_METADATA_SOURCE_UNKNOWN}, {@link #APP_METADATA_SOURCE_APK}, 6585 * {@link #APP_METADATA_SOURCE_INSTALLER} or {@link #APP_METADATA_SOURCE_SYSTEM_IMAGE}. 6586 * 6587 * Note: an app can have the app metadata included in the APK, but if the installer also 6588 * provides an app metadata during the installation, the one provided by the installer will 6589 * take precedence. 6590 * 6591 * @param packageName The package name for which to get the app metadata source. 6592 * @throws NameNotFoundException if no such package is available to the caller. 6593 * @throws SecurityException if the caller doesn't have the required permission. 6594 * @hide 6595 */ 6596 @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE) 6597 @SystemApi 6598 @RequiresPermission(Manifest.permission.GET_APP_METADATA) getAppMetadataSource(@onNull String packageName)6599 public @AppMetadataSource int getAppMetadataSource(@NonNull String packageName) 6600 throws NameNotFoundException { 6601 throw new UnsupportedOperationException("getAppMetadataSource not implemented in subclass"); 6602 } 6603 6604 /** 6605 * Return a List of all installed packages that are currently holding any of 6606 * the given permissions. 6607 * 6608 * Use {@link #getPackagesHoldingPermissions(String[], PackageInfoFlags)} when long flags are 6609 * needed. 6610 * 6611 * @param flags Additional option flags to modify the data returned. 6612 * @return A List of PackageInfo objects, one for each installed package 6613 * that holds any of the permissions that were provided, containing 6614 * information about the package. If no installed packages hold any 6615 * of the permissions, an empty list is returned. If flag 6616 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 6617 * information is retrieved from the list of uninstalled 6618 * applications (which includes installed applications as well as 6619 * applications with data directory i.e. applications which had been 6620 * deleted with {@code DELETE_KEEP_DATA} flag set). 6621 */ 6622 @NonNull getPackagesHoldingPermissions( @onNull String[] permissions, int flags)6623 public abstract List<PackageInfo> getPackagesHoldingPermissions( 6624 @NonNull String[] permissions, int flags); 6625 6626 /** 6627 * See {@link #getPackagesHoldingPermissions(String[], int)}. 6628 */ 6629 @NonNull getPackagesHoldingPermissions( @onNull String[] permissions, @NonNull PackageInfoFlags flags)6630 public List<PackageInfo> getPackagesHoldingPermissions( 6631 @NonNull String[] permissions, @NonNull PackageInfoFlags flags) { 6632 throw new UnsupportedOperationException( 6633 "getPackagesHoldingPermissions not implemented in subclass"); 6634 } 6635 6636 /** 6637 * Return a List of all packages that are installed on the device, for a 6638 * specific user. 6639 * 6640 * Use {@link #getInstalledPackagesAsUser(PackageInfoFlags, int)} when long flags are needed. 6641 * 6642 * @param flags Additional option flags to modify the data returned. 6643 * @param userId The user for whom the installed packages are to be listed 6644 * @return A List of PackageInfo objects, one for each installed package, 6645 * containing information about the package. In the unlikely case 6646 * there are no installed packages, an empty list is returned. If 6647 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 6648 * information is retrieved from the list of uninstalled 6649 * applications (which includes installed applications as well as 6650 * applications with data directory i.e. applications which had been 6651 * deleted with {@code DELETE_KEEP_DATA} flag set). 6652 * @hide 6653 */ 6654 @SuppressWarnings("HiddenAbstractMethod") 6655 @NonNull 6656 @SystemApi 6657 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) getInstalledPackagesAsUser(int flags, @UserIdInt int userId)6658 public abstract List<PackageInfo> getInstalledPackagesAsUser(int flags, 6659 @UserIdInt int userId); 6660 6661 /** 6662 * See {@link #getInstalledPackagesAsUser(int, int)}. 6663 * @hide 6664 */ 6665 @NonNull 6666 @SystemApi 6667 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) getInstalledPackagesAsUser(@onNull PackageInfoFlags flags, @UserIdInt int userId)6668 public List<PackageInfo> getInstalledPackagesAsUser(@NonNull PackageInfoFlags flags, 6669 @UserIdInt int userId) { 6670 throw new UnsupportedOperationException( 6671 "getApplicationInfoAsUser not implemented in subclass"); 6672 } 6673 6674 /** 6675 * Check whether a particular package has been granted a particular 6676 * permission. 6677 * <p> 6678 * <strong>Note: </strong>This API returns the underlying permission state 6679 * as-is and is mostly intended for permission managing system apps. To 6680 * perform an access check for a certain app, please use the 6681 * {@link Context#checkPermission} APIs instead. 6682 * 6683 * @param permName The name of the permission you are checking for. 6684 * @param packageName The name of the package you are checking against. 6685 * 6686 * @return If the package has the permission, PERMISSION_GRANTED is 6687 * returned. If it does not have the permission, PERMISSION_DENIED 6688 * is returned. 6689 * 6690 * @see #PERMISSION_GRANTED 6691 * @see #PERMISSION_DENIED 6692 */ 6693 @CheckResult 6694 @PermissionResult checkPermission(@onNull String permName, @NonNull String packageName)6695 public abstract int checkPermission(@NonNull String permName, 6696 @NonNull String packageName); 6697 6698 /** 6699 * Checks whether a particular permissions has been revoked for a 6700 * package by policy. Typically the device owner or the profile owner 6701 * may apply such a policy. The user cannot grant policy revoked 6702 * permissions, hence the only way for an app to get such a permission 6703 * is by a policy change. 6704 * 6705 * @param permName The name of the permission you are checking for. 6706 * @param packageName The name of the package you are checking against. 6707 * 6708 * @return Whether the permission is restricted by policy. 6709 */ 6710 @CheckResult 6711 //@Deprecated isPermissionRevokedByPolicy(@onNull String permName, @NonNull String packageName)6712 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 6713 @NonNull String packageName); 6714 6715 /** 6716 * Gets the package name of the component controlling runtime permissions. 6717 * 6718 * @return the package name of the component controlling runtime permissions 6719 * 6720 * @hide 6721 */ 6722 @NonNull 6723 @SystemApi 6724 @TestApi 6725 @SuppressLint("UnflaggedApi") // Promoting from @SystemApi(MODULE_LIBRARIES) getPermissionControllerPackageName()6726 public String getPermissionControllerPackageName() { 6727 throw new RuntimeException("Not implemented. Must override in a subclass."); 6728 } 6729 6730 /** 6731 * Returns the package name of the component implementing sdk sandbox service. 6732 * 6733 * @return the package name of the component implementing sdk sandbox service 6734 * 6735 * @hide 6736 */ 6737 @NonNull 6738 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 6739 @TestApi getSdkSandboxPackageName()6740 public String getSdkSandboxPackageName() { 6741 throw new RuntimeException("Not implemented. Must override in a subclass."); 6742 } 6743 6744 /** 6745 * Add a new dynamic permission to the system. For this to work, your 6746 * package must have defined a permission tree through the 6747 * {@link android.R.styleable#AndroidManifestPermissionTree 6748 * <permission-tree>} tag in its manifest. A package can only add 6749 * permissions to trees that were defined by either its own package or 6750 * another with the same user id; a permission is in a tree if it 6751 * matches the name of the permission tree + ".": for example, 6752 * "com.foo.bar" is a member of the permission tree "com.foo". 6753 * 6754 * <p>It is good to make your permission tree name descriptive, because you 6755 * are taking possession of that entire set of permission names. Thus, it 6756 * must be under a domain you control, with a suffix that will not match 6757 * any normal permissions that may be declared in any applications that 6758 * are part of that domain. 6759 * 6760 * <p>New permissions must be added before 6761 * any .apks are installed that use those permissions. Permissions you 6762 * add through this method are remembered across reboots of the device. 6763 * If the given permission already exists, the info you supply here 6764 * will be used to update it. 6765 * 6766 * @deprecated Support for dynamic permissions is going to be removed, and apps that use dynamic 6767 * permissions should declare their permissions statically inside their app manifest instead. 6768 * This method will become a no-op in a future Android release and eventually be removed from 6769 * the SDK. 6770 * 6771 * @param info Description of the permission to be added. 6772 * 6773 * @return Returns true if a new permission was created, false if an 6774 * existing one was updated. 6775 * 6776 * @throws SecurityException if you are not allowed to add the 6777 * given permission name. 6778 * 6779 * @see #removePermission(String) 6780 */ 6781 @SuppressWarnings("HiddenAbstractMethod") 6782 @FlaggedApi(android.permission.flags.Flags.FLAG_PERMISSION_TREE_APIS_DEPRECATED) 6783 @Deprecated addPermission(@onNull PermissionInfo info)6784 public abstract boolean addPermission(@NonNull PermissionInfo info); 6785 6786 /** 6787 * Like {@link #addPermission(PermissionInfo)} but asynchronously 6788 * persists the package manager state after returning from the call, 6789 * allowing it to return quicker and batch a series of adds at the 6790 * expense of no guarantee the added permission will be retained if 6791 * the device is rebooted before it is written. 6792 * 6793 * @deprecated Support for dynamic permissions is going to be removed, and apps that use dynamic 6794 * permissions should declare their permissions statically inside their app manifest instead. 6795 * This method will become a no-op in a future Android release and eventually be removed from 6796 * the SDK. 6797 */ 6798 @SuppressWarnings("HiddenAbstractMethod") 6799 @FlaggedApi(android.permission.flags.Flags.FLAG_PERMISSION_TREE_APIS_DEPRECATED) 6800 @Deprecated addPermissionAsync(@onNull PermissionInfo info)6801 public abstract boolean addPermissionAsync(@NonNull PermissionInfo info); 6802 6803 /** 6804 * Removes a permission that was previously added with 6805 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 6806 * -- you are only allowed to remove permissions that you are allowed 6807 * to add. 6808 * 6809 * @deprecated Support for dynamic permissions is going to be removed, and apps that use dynamic 6810 * permissions should declare their permissions statically inside their app manifest instead. 6811 * This method will become a no-op in a future Android release and eventually be removed from 6812 * the SDK. 6813 * 6814 * @param permName The name of the permission to remove. 6815 * 6816 * @throws SecurityException if you are not allowed to remove the 6817 * given permission name. 6818 * 6819 * @see #addPermission(PermissionInfo) 6820 */ 6821 @SuppressWarnings("HiddenAbstractMethod") 6822 @FlaggedApi(android.permission.flags.Flags.FLAG_PERMISSION_TREE_APIS_DEPRECATED) 6823 @Deprecated removePermission(@onNull String permName)6824 public abstract void removePermission(@NonNull String permName); 6825 6826 /** 6827 * Permission flags set when granting or revoking a permission. 6828 * 6829 * @removed mistakenly exposed as system-api previously 6830 */ 6831 @IntDef(prefix = { "FLAG_PERMISSION_" }, value = { 6832 FLAG_PERMISSION_USER_SET, 6833 FLAG_PERMISSION_USER_FIXED, 6834 FLAG_PERMISSION_POLICY_FIXED, 6835 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 6836 FLAG_PERMISSION_SYSTEM_FIXED, 6837 FLAG_PERMISSION_GRANTED_BY_DEFAULT, 6838 FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED, 6839 FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED, 6840 /* 6841 FLAG_PERMISSION_REVOKE_WHEN_REQUESED 6842 */ 6843 FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT, 6844 FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT, 6845 FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT, 6846 FLAG_PERMISSION_APPLY_RESTRICTION, 6847 FLAG_PERMISSION_GRANTED_BY_ROLE, 6848 FLAG_PERMISSION_REVOKED_COMPAT, 6849 FLAG_PERMISSION_ONE_TIME, 6850 FLAG_PERMISSION_AUTO_REVOKED 6851 }) 6852 @Retention(RetentionPolicy.SOURCE) 6853 public @interface PermissionFlags {} 6854 6855 /** 6856 * Grant a runtime permission to an application which the application does not 6857 * already have. The permission must have been requested by the application. 6858 * If the application is not allowed to hold the permission, a {@link 6859 * java.lang.SecurityException} is thrown. If the package or permission is 6860 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 6861 * <p> 6862 * <strong>Note: </strong>Using this API requires holding 6863 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is 6864 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 6865 * </p> 6866 * 6867 * @param packageName The package to which to grant the permission. 6868 * @param permName The permission name to grant. 6869 * @param user The user for which to grant the permission. 6870 * 6871 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 6872 * 6873 * @hide 6874 */ 6875 //@Deprecated 6876 @SuppressWarnings("HiddenAbstractMethod") 6877 @SystemApi 6878 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) grantRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user)6879 public abstract void grantRuntimePermission(@NonNull String packageName, 6880 @NonNull String permName, @NonNull UserHandle user); 6881 6882 /** 6883 * Revoke a runtime permission that was previously granted by {@link 6884 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 6885 * permission must have been requested by and granted to the application. 6886 * If the application is not allowed to hold the permission, a {@link 6887 * java.lang.SecurityException} is thrown. If the package or permission is 6888 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 6889 * <p> 6890 * <strong>Note: </strong>Using this API requires holding 6891 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 6892 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 6893 * </p> 6894 * 6895 * @param packageName The package from which to revoke the permission. 6896 * @param permName The permission name to revoke. 6897 * @param user The user for which to revoke the permission. 6898 * 6899 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 6900 * 6901 * @hide 6902 */ 6903 //@Deprecated 6904 @SuppressWarnings("HiddenAbstractMethod") 6905 @SystemApi 6906 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) revokeRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user)6907 public abstract void revokeRuntimePermission(@NonNull String packageName, 6908 @NonNull String permName, @NonNull UserHandle user); 6909 6910 /** 6911 * Revoke a runtime permission that was previously granted by {@link 6912 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 6913 * permission must have been requested by and granted to the application. 6914 * If the application is not allowed to hold the permission, a {@link 6915 * java.lang.SecurityException} is thrown. If the package or permission is 6916 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 6917 * <p> 6918 * <strong>Note: </strong>Using this API requires holding 6919 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 6920 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 6921 * </p> 6922 * 6923 * @param packageName The package from which to revoke the permission. 6924 * @param permName The permission name to revoke. 6925 * @param user The user for which to revoke the permission. 6926 * @param reason The reason for the revoke. 6927 * 6928 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 6929 * 6930 * @hide 6931 */ 6932 //@Deprecated 6933 @SystemApi 6934 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) revokeRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user, @NonNull String reason)6935 public void revokeRuntimePermission(@NonNull String packageName, 6936 @NonNull String permName, @NonNull UserHandle user, @NonNull String reason) { 6937 revokeRuntimePermission(packageName, permName, user); 6938 } 6939 6940 /** 6941 * Gets the state flags associated with a permission. 6942 * 6943 * @param permName The permission for which to get the flags. 6944 * @param packageName The package name for which to get the flags. 6945 * @param user The user for which to get permission flags. 6946 * @return The permission flags. 6947 * 6948 * @hide 6949 */ 6950 //@Deprecated 6951 @SuppressWarnings("HiddenAbstractMethod") 6952 @SystemApi 6953 @RequiresPermission(anyOf = { 6954 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 6955 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS, 6956 android.Manifest.permission.GET_RUNTIME_PERMISSIONS 6957 }) 6958 @PermissionFlags getPermissionFlags(@onNull String permName, @NonNull String packageName, @NonNull UserHandle user)6959 public abstract int getPermissionFlags(@NonNull String permName, 6960 @NonNull String packageName, @NonNull UserHandle user); 6961 6962 /** 6963 * Updates the flags associated with a permission by replacing the flags in 6964 * the specified mask with the provided flag values. 6965 * 6966 * @param permName The permission for which to update the flags. 6967 * @param packageName The package name for which to update the flags. 6968 * @param flagMask The flags which to replace. 6969 * @param flagValues The flags with which to replace. 6970 * @param user The user for which to update the permission flags. 6971 * 6972 * @hide 6973 */ 6974 //@Deprecated 6975 @SuppressWarnings("HiddenAbstractMethod") 6976 @SystemApi 6977 @RequiresPermission(anyOf = { 6978 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 6979 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS 6980 }) updatePermissionFlags(@onNull String permName, @NonNull String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues, @NonNull UserHandle user)6981 public abstract void updatePermissionFlags(@NonNull String permName, 6982 @NonNull String packageName, @PermissionFlags int flagMask, 6983 @PermissionFlags int flagValues, @NonNull UserHandle user); 6984 6985 /** 6986 * Gets the restricted permissions that have been whitelisted and the app 6987 * is allowed to have them granted in their full form. 6988 * 6989 * <p> Permissions can be hard restricted which means that the app cannot hold 6990 * them or soft restricted where the app can hold the permission but in a weaker 6991 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 6992 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 6993 * depends on the permission declaration. Whitelisting a hard restricted permission 6994 * allows for the to hold that permission and whitelisting a soft restricted 6995 * permission allows the app to hold the permission in its full, unrestricted form. 6996 * 6997 * <p><ol>There are four allowlists: 6998 * 6999 * <li>one for cases where the system permission policy whitelists a permission 7000 * This list corresponds to the{@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 7001 * Can only be accessed by pre-installed holders of a dedicated permission. 7002 * 7003 * <li>one for cases where the system whitelists the permission when upgrading 7004 * from an OS version in which the permission was not restricted to an OS version 7005 * in which the permission is restricted. This list corresponds to the {@link 7006 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be accessed by pre-installed 7007 * holders of a dedicated permission or the installer on record. 7008 * 7009 * <li>one for cases where the installer of the package whitelists a permission. 7010 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 7011 * Can be accessed by pre-installed holders of a dedicated permission or the 7012 * installer on record. 7013 * </ol> 7014 * 7015 * <p> 7016 * <strong>Note: </strong>In retrospect it would have been preferred to use 7017 * more inclusive terminology when naming this API. Similar APIs added will 7018 * refrain from using the term "whitelist". 7019 * </p> 7020 * 7021 * @param packageName The app for which to get whitelisted permissions. 7022 * @param whitelistFlag The flag to determine which whitelist to query. Only one flag 7023 * can be passed.s 7024 * @return The whitelisted permissions that are on any of the whitelists you query for. 7025 * 7026 * @see #addWhitelistedRestrictedPermission(String, String, int) 7027 * @see #removeWhitelistedRestrictedPermission(String, String, int) 7028 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 7029 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 7030 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 7031 * 7032 * @throws SecurityException if you try to access a whitelist that you have no access to. 7033 */ 7034 //@Deprecated 7035 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 7036 conditional = true) getWhitelistedRestrictedPermissions( @onNull String packageName, @PermissionWhitelistFlags int whitelistFlag)7037 public @NonNull Set<String> getWhitelistedRestrictedPermissions( 7038 @NonNull String packageName, @PermissionWhitelistFlags int whitelistFlag) { 7039 return Collections.emptySet(); 7040 } 7041 7042 /** 7043 * Adds a whitelisted restricted permission for an app. 7044 * 7045 * <p> Permissions can be hard restricted which means that the app cannot hold 7046 * them or soft restricted where the app can hold the permission but in a weaker 7047 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 7048 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 7049 * depends on the permission declaration. Whitelisting a hard restricted permission 7050 * allows for the to hold that permission and whitelisting a soft restricted 7051 * permission allows the app to hold the permission in its full, unrestricted form. 7052 * 7053 * <p><ol>There are four whitelists: 7054 * 7055 * <li>one for cases where the system permission policy whitelists a permission 7056 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 7057 * Can only be modified by pre-installed holders of a dedicated permission. 7058 * 7059 * <li>one for cases where the system whitelists the permission when upgrading 7060 * from an OS version in which the permission was not restricted to an OS version 7061 * in which the permission is restricted. This list corresponds to the {@link 7062 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 7063 * holders of a dedicated permission. The installer on record can only remove 7064 * permissions from this whitelist. 7065 * 7066 * <li>one for cases where the installer of the package whitelists a permission. 7067 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 7068 * Can be modified by pre-installed holders of a dedicated permission or the installer 7069 * on record. 7070 * </ol> 7071 * 7072 * <p>You need to specify the whitelists for which to set the whitelisted permissions 7073 * which will clear the previous whitelisted permissions and replace them with the 7074 * provided ones. 7075 * 7076 * <p> 7077 * <strong>Note: </strong>In retrospect it would have been preferred to use 7078 * more inclusive terminology when naming this API. Similar APIs added will 7079 * refrain from using the term "whitelist". 7080 * </p> 7081 * 7082 * @param packageName The app for which to get whitelisted permissions. 7083 * @param permName The whitelisted permission to add. 7084 * @param whitelistFlags The whitelists to which to add. Passing multiple flags 7085 * updates all specified whitelists. 7086 * @return Whether the permission was added to the whitelist. 7087 * 7088 * @see #getWhitelistedRestrictedPermissions(String, int) 7089 * @see #removeWhitelistedRestrictedPermission(String, String, int) 7090 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 7091 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 7092 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 7093 * 7094 * @throws SecurityException if you try to modify a whitelist that you have no access to. 7095 */ 7096 //@Deprecated 7097 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 7098 conditional = true) addWhitelistedRestrictedPermission(@onNull String packageName, @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags)7099 public boolean addWhitelistedRestrictedPermission(@NonNull String packageName, 7100 @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) { 7101 return false; 7102 } 7103 7104 /** 7105 * Removes a whitelisted restricted permission for an app. 7106 * 7107 * <p> Permissions can be hard restricted which means that the app cannot hold 7108 * them or soft restricted where the app can hold the permission but in a weaker 7109 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 7110 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 7111 * depends on the permission declaration. Whitelisting a hard restricted permission 7112 * allows for the to hold that permission and whitelisting a soft restricted 7113 * permission allows the app to hold the permission in its full, unrestricted form. 7114 * 7115 * <p><ol>There are four whitelists: 7116 * 7117 * <li>one for cases where the system permission policy whitelists a permission 7118 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 7119 * Can only be modified by pre-installed holders of a dedicated permission. 7120 * 7121 * <li>one for cases where the system whitelists the permission when upgrading 7122 * from an OS version in which the permission was not restricted to an OS version 7123 * in which the permission is restricted. This list corresponds to the {@link 7124 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 7125 * holders of a dedicated permission. The installer on record can only remove 7126 * permissions from this whitelist. 7127 * 7128 * <li>one for cases where the installer of the package whitelists a permission. 7129 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 7130 * Can be modified by pre-installed holders of a dedicated permission or the installer 7131 * on record. 7132 * 7133 * <li>one for cases where the system exempts the permission when upgrading 7134 * from an OS version in which the permission was not restricted to an OS version 7135 * in which the permission is restricted. This list corresponds to the {@link 7136 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 7137 * holders of a dedicated permission. The installer on record can only remove 7138 * permissions from this allowlist. 7139 * </ol> 7140 * 7141 * <p>You need to specify the whitelists for which to set the whitelisted permissions 7142 * which will clear the previous whitelisted permissions and replace them with the 7143 * provided ones. 7144 * 7145 * <p> 7146 * <strong>Note: </strong>In retrospect it would have been preferred to use 7147 * more inclusive terminology when naming this API. Similar APIs added will 7148 * refrain from using the term "whitelist". 7149 * </p> 7150 * 7151 * @param packageName The app for which to get whitelisted permissions. 7152 * @param permName The whitelisted permission to remove. 7153 * @param whitelistFlags The whitelists from which to remove. Passing multiple flags 7154 * updates all specified whitelists. 7155 * @return Whether the permission was removed from the whitelist. 7156 * 7157 * @see #getWhitelistedRestrictedPermissions(String, int) 7158 * @see #addWhitelistedRestrictedPermission(String, String, int) 7159 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 7160 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 7161 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 7162 * 7163 * @throws SecurityException if you try to modify a whitelist that you have no access to. 7164 */ 7165 //@Deprecated 7166 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 7167 conditional = true) removeWhitelistedRestrictedPermission(@onNull String packageName, @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags)7168 public boolean removeWhitelistedRestrictedPermission(@NonNull String packageName, 7169 @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) { 7170 return false; 7171 } 7172 7173 /** 7174 * Marks an application exempt from having its permissions be automatically revoked when 7175 * the app is unused for an extended period of time. 7176 * 7177 * Only the installer on record that installed the given package is allowed to call this. 7178 * 7179 * Packages start in whitelisted state, and it is the installer's responsibility to 7180 * un-whitelist the packages it installs, unless auto-revoking permissions from that package 7181 * would cause breakages beyond having to re-request the permission(s). 7182 * 7183 * <p> 7184 * <strong>Note: </strong>In retrospect it would have been preferred to use 7185 * more inclusive terminology when naming this API. Similar APIs added will 7186 * refrain from using the term "whitelist". 7187 * </p> 7188 * 7189 * @param packageName The app for which to set exemption. 7190 * @param whitelisted Whether the app should be whitelisted. 7191 * 7192 * @return whether any change took effect. 7193 * 7194 * @see #isAutoRevokeWhitelisted 7195 * 7196 * @throws SecurityException if you you have no access to modify this. 7197 */ 7198 //@Deprecated 7199 @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS, 7200 conditional = true) setAutoRevokeWhitelisted(@onNull String packageName, boolean whitelisted)7201 public boolean setAutoRevokeWhitelisted(@NonNull String packageName, boolean whitelisted) { 7202 return false; 7203 } 7204 7205 /** 7206 * Checks whether an application is exempt from having its permissions be automatically revoked 7207 * when the app is unused for an extended period of time. 7208 * 7209 * Only the installer on record that installed the given package, or a holder of 7210 * {@code WHITELIST_AUTO_REVOKE_PERMISSIONS} is allowed to call this. 7211 * 7212 * <p> 7213 * <strong>Note: </strong>In retrospect it would have been preferred to use 7214 * more inclusive terminology when naming this API. Similar APIs added will 7215 * refrain from using the term "whitelist". 7216 * </p> 7217 * 7218 * @param packageName The app for which to set exemption. 7219 * 7220 * @return Whether the app is whitelisted. 7221 * 7222 * @see #setAutoRevokeWhitelisted 7223 * 7224 * @throws SecurityException if you you have no access to this. 7225 */ 7226 //@Deprecated 7227 @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS, 7228 conditional = true) isAutoRevokeWhitelisted(@onNull String packageName)7229 public boolean isAutoRevokeWhitelisted(@NonNull String packageName) { 7230 return false; 7231 } 7232 7233 7234 /** 7235 * Gets whether you should show UI with rationale for requesting a permission. 7236 * You should do this only if you do not have the permission and the context in 7237 * which the permission is requested does not clearly communicate to the user 7238 * what would be the benefit from grating this permission. 7239 * 7240 * @param permName A permission your app wants to request. 7241 * @return Whether you can show permission rationale UI. 7242 * 7243 * @hide 7244 */ 7245 //@Deprecated 7246 @SuppressWarnings("HiddenAbstractMethod") 7247 @UnsupportedAppUsage shouldShowRequestPermissionRationale(@onNull String permName)7248 public abstract boolean shouldShowRequestPermissionRationale(@NonNull String permName); 7249 7250 /** 7251 * Gets the localized label that corresponds to the option in settings for granting 7252 * background access. 7253 * 7254 * <p>The intended use is for apps to reference this label in its instruction for users to grant 7255 * a background permission. 7256 * 7257 * @return the localized label that corresponds to the settings option for granting 7258 * background access 7259 */ 7260 @NonNull getBackgroundPermissionOptionLabel()7261 public CharSequence getBackgroundPermissionOptionLabel() { 7262 return ""; 7263 } 7264 7265 /** 7266 * Returns an {@link android.content.Intent} suitable for passing to 7267 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 7268 * which prompts the user to grant permissions to this application. 7269 * 7270 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 7271 * 7272 * @hide 7273 */ 7274 @NonNull 7275 @UnsupportedAppUsage buildRequestPermissionsIntent(@onNull String[] permissions)7276 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 7277 if (ArrayUtils.isEmpty(permissions)) { 7278 throw new IllegalArgumentException("permission cannot be null or empty"); 7279 } 7280 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 7281 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 7282 intent.setPackage(getPermissionControllerPackageName()); 7283 return intent; 7284 } 7285 7286 /** 7287 * Compare the signatures of two packages to determine if the same 7288 * signature appears in both of them. If they do contain the same 7289 * signature, then they are allowed special privileges when working 7290 * with each other: they can share the same user-id, run instrumentation 7291 * against each other, etc. 7292 * 7293 * @param packageName1 First package name whose signature will be compared. 7294 * @param packageName2 Second package name whose signature will be compared. 7295 * 7296 * @return Returns an integer indicating whether all signatures on the 7297 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 7298 * all signatures match or < 0 if there is not a match ({@link 7299 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 7300 * 7301 * @see #checkSignatures(int, int) 7302 */ 7303 @CheckResult 7304 @SignatureResult checkSignatures(@onNull String packageName1, @NonNull String packageName2)7305 public abstract int checkSignatures(@NonNull String packageName1, 7306 @NonNull String packageName2); 7307 7308 /** 7309 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 7310 * the two packages to be checked. This can be useful, for example, 7311 * when doing the check in an IPC, where the UID is the only identity 7312 * available. It is functionally identical to determining the package 7313 * associated with the UIDs and checking their signatures. 7314 * 7315 * @param uid1 First UID whose signature will be compared. 7316 * @param uid2 Second UID whose signature will be compared. 7317 * 7318 * @return Returns an integer indicating whether all signatures on the 7319 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 7320 * all signatures match or < 0 if there is not a match ({@link 7321 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 7322 * 7323 * @see #checkSignatures(String, String) 7324 */ 7325 @CheckResult checkSignatures(int uid1, int uid2)7326 public abstract @SignatureResult int checkSignatures(int uid1, int uid2); 7327 7328 /** 7329 * Retrieve the names of all packages that are associated with a particular 7330 * user id. In most cases, this will be a single package name, the package 7331 * that has been assigned that user id. Where there are multiple packages 7332 * sharing the same user id through the "sharedUserId" mechanism, all 7333 * packages with that id will be returned. 7334 * 7335 * @param uid The user id for which you would like to retrieve the 7336 * associated packages. 7337 * 7338 * @return Returns an array of one or more packages assigned to the user 7339 * id, or null if there are no known packages with the given id. 7340 */ getPackagesForUid(int uid)7341 public abstract @Nullable String[] getPackagesForUid(int uid); 7342 7343 /** 7344 * Retrieve the official name associated with a uid. This name is 7345 * guaranteed to never change, though it is possible for the underlying 7346 * uid to be changed. That is, if you are storing information about 7347 * uids in persistent storage, you should use the string returned 7348 * by this function instead of the raw uid. 7349 * 7350 * @param uid The uid for which you would like to retrieve a name. 7351 * @return Returns a unique name for the given uid, or null if the 7352 * uid is not currently assigned. 7353 */ getNameForUid(int uid)7354 public abstract @Nullable String getNameForUid(int uid); 7355 7356 /** 7357 * Retrieves the official names associated with each given uid. 7358 * @see #getNameForUid(int) 7359 * 7360 * @hide 7361 */ 7362 @SuppressWarnings({"HiddenAbstractMethod", "NullableCollection"}) 7363 @TestApi getNamesForUids(int[] uids)7364 public abstract @Nullable String[] getNamesForUids(int[] uids); 7365 7366 /** 7367 * Return the user id associated with a shared user name. Multiple 7368 * applications can specify a shared user name in their manifest and thus 7369 * end up using a common uid. This might be used for new applications 7370 * that use an existing shared user name and need to know the uid of the 7371 * shared user. 7372 * 7373 * @param sharedUserName The shared user name whose uid is to be retrieved. 7374 * @return Returns the UID associated with the shared user. 7375 * @throws NameNotFoundException if a package with the given name cannot be 7376 * found on the system. 7377 * @hide 7378 */ 7379 @SuppressWarnings("HiddenAbstractMethod") 7380 @UnsupportedAppUsage getUidForSharedUser(@onNull String sharedUserName)7381 public abstract int getUidForSharedUser(@NonNull String sharedUserName) 7382 throws NameNotFoundException; 7383 7384 /** 7385 * Return a List of all application packages that are installed for the 7386 * current user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 7387 * applications including those deleted with {@code DELETE_KEEP_DATA} 7388 * (partially installed apps with data directory) will be returned. 7389 * 7390 * Use {@link #getInstalledApplications(ApplicationInfoFlags)} when long flags are needed. 7391 * 7392 * @param flags Additional option flags to modify the data returned. 7393 * @return A List of ApplicationInfo objects, one for each installed 7394 * application. In the unlikely case there are no installed 7395 * packages, an empty list is returned. If flag 7396 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 7397 * information is retrieved from the list of uninstalled 7398 * applications (which includes installed applications as well as 7399 * applications with data directory i.e. applications which had been 7400 * deleted with {@code DELETE_KEEP_DATA} flag set). 7401 */ 7402 @NonNull getInstalledApplications(int flags)7403 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 7404 7405 /** 7406 * See {@link #getInstalledApplications(int)} 7407 * @param flags 7408 */ 7409 @NonNull getInstalledApplications(@onNull ApplicationInfoFlags flags)7410 public List<ApplicationInfo> getInstalledApplications(@NonNull ApplicationInfoFlags flags) { 7411 throw new UnsupportedOperationException( 7412 "getInstalledApplications not implemented in subclass"); 7413 } 7414 /** 7415 * Return a List of all application packages that are installed on the 7416 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been 7417 * set, a list of all applications including those deleted with 7418 * {@code DELETE_KEEP_DATA} (partially installed apps with data directory) 7419 * will be returned. 7420 * 7421 * Use {@link #getInstalledApplicationsAsUser(ApplicationInfoFlags, int)} when long flags are 7422 * needed. 7423 * 7424 * @param flags Additional option flags to modify the data returned. 7425 * @param userId The user for whom the installed applications are to be 7426 * listed 7427 * @return A List of ApplicationInfo objects, one for each installed 7428 * application. In the unlikely case there are no installed 7429 * packages, an empty list is returned. If flag 7430 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 7431 * information is retrieved from the list of uninstalled 7432 * applications (which includes installed applications as well as 7433 * applications with data directory i.e. applications which had been 7434 * deleted with {@code DELETE_KEEP_DATA} flag set). 7435 * @hide 7436 */ 7437 @SuppressWarnings("HiddenAbstractMethod") 7438 @NonNull 7439 @TestApi getInstalledApplicationsAsUser( int flags, @UserIdInt int userId)7440 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser( 7441 int flags, @UserIdInt int userId); 7442 7443 /** 7444 * See {@link #getInstalledApplicationsAsUser(int, int}. 7445 * @hide 7446 */ 7447 @NonNull 7448 @TestApi getInstalledApplicationsAsUser( @onNull ApplicationInfoFlags flags, @UserIdInt int userId)7449 public List<ApplicationInfo> getInstalledApplicationsAsUser( 7450 @NonNull ApplicationInfoFlags flags, @UserIdInt int userId) { 7451 throw new UnsupportedOperationException( 7452 "getInstalledApplicationsAsUser not implemented in subclass"); 7453 } 7454 7455 /** 7456 * Gets the instant applications the user recently used. 7457 * 7458 * @return The instant app list. 7459 * 7460 * @hide 7461 */ 7462 @SuppressWarnings("HiddenAbstractMethod") 7463 @SystemApi 7464 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) getInstantApps()7465 public abstract @NonNull List<InstantAppInfo> getInstantApps(); 7466 7467 /** 7468 * Gets the icon for an instant application. 7469 * 7470 * @param packageName The app package name. 7471 * 7472 * @hide 7473 */ 7474 @SuppressWarnings("HiddenAbstractMethod") 7475 @SystemApi 7476 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) getInstantAppIcon(String packageName)7477 public abstract @Nullable Drawable getInstantAppIcon(String packageName); 7478 7479 /** 7480 * Gets whether this application is an instant app. 7481 * 7482 * @return Whether caller is an instant app. 7483 * 7484 * @see #isInstantApp(String) 7485 * @see #updateInstantAppCookie(byte[]) 7486 * @see #getInstantAppCookie() 7487 * @see #getInstantAppCookieMaxBytes() 7488 */ isInstantApp()7489 public abstract boolean isInstantApp(); 7490 7491 /** 7492 * Gets whether the given package is an instant app. 7493 * 7494 * @param packageName The package to check 7495 * @return Whether the given package is an instant app. 7496 * 7497 * @see #isInstantApp() 7498 * @see #updateInstantAppCookie(byte[]) 7499 * @see #getInstantAppCookie() 7500 * @see #getInstantAppCookieMaxBytes() 7501 * @see #clearInstantAppCookie() 7502 */ isInstantApp(@onNull String packageName)7503 public abstract boolean isInstantApp(@NonNull String packageName); 7504 7505 /** 7506 * Gets the maximum size in bytes of the cookie data an instant app 7507 * can store on the device. 7508 * 7509 * @return The max cookie size in bytes. 7510 * 7511 * @see #isInstantApp() 7512 * @see #isInstantApp(String) 7513 * @see #updateInstantAppCookie(byte[]) 7514 * @see #getInstantAppCookie() 7515 * @see #clearInstantAppCookie() 7516 */ getInstantAppCookieMaxBytes()7517 public abstract int getInstantAppCookieMaxBytes(); 7518 7519 /** 7520 * deprecated 7521 * @hide 7522 */ 7523 @SuppressWarnings("HiddenAbstractMethod") getInstantAppCookieMaxSize()7524 public abstract int getInstantAppCookieMaxSize(); 7525 7526 /** 7527 * Gets the instant application cookie for this app. Non 7528 * instant apps and apps that were instant but were upgraded 7529 * to normal apps can still access this API. For instant apps 7530 * this cookie is cached for some time after uninstall while for 7531 * normal apps the cookie is deleted after the app is uninstalled. 7532 * The cookie is always present while the app is installed. 7533 * 7534 * @return The cookie. 7535 * 7536 * @see #isInstantApp() 7537 * @see #isInstantApp(String) 7538 * @see #updateInstantAppCookie(byte[]) 7539 * @see #getInstantAppCookieMaxBytes() 7540 * @see #clearInstantAppCookie() 7541 */ getInstantAppCookie()7542 public abstract @NonNull byte[] getInstantAppCookie(); 7543 7544 /** 7545 * Clears the instant application cookie for the calling app. 7546 * 7547 * @see #isInstantApp() 7548 * @see #isInstantApp(String) 7549 * @see #getInstantAppCookieMaxBytes() 7550 * @see #getInstantAppCookie() 7551 * @see #clearInstantAppCookie() 7552 */ clearInstantAppCookie()7553 public abstract void clearInstantAppCookie(); 7554 7555 /** 7556 * Updates the instant application cookie for the calling app. Non 7557 * instant apps and apps that were instant but were upgraded 7558 * to normal apps can still access this API. For instant apps 7559 * this cookie is cached for some time after uninstall while for 7560 * normal apps the cookie is deleted after the app is uninstalled. 7561 * The cookie is always present while the app is installed. The 7562 * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}. 7563 * Passing <code>null</code> or an empty array clears the cookie. 7564 * </p> 7565 * 7566 * @param cookie The cookie data. 7567 * 7568 * @see #isInstantApp() 7569 * @see #isInstantApp(String) 7570 * @see #getInstantAppCookieMaxBytes() 7571 * @see #getInstantAppCookie() 7572 * @see #clearInstantAppCookie() 7573 * 7574 * @throws IllegalArgumentException if the array exceeds max cookie size. 7575 */ updateInstantAppCookie(@ullable byte[] cookie)7576 public abstract void updateInstantAppCookie(@Nullable byte[] cookie); 7577 7578 /** 7579 * @removed 7580 */ 7581 @SuppressWarnings("HiddenAbstractMethod") setInstantAppCookie(@ullable byte[] cookie)7582 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie); 7583 7584 /** 7585 * Get a list of shared libraries that are available on the 7586 * system. 7587 * 7588 * @return An array of shared library names that are 7589 * available on the system, or null if none are installed. 7590 * 7591 */ 7592 @Nullable getSystemSharedLibraryNames()7593 public abstract String[] getSystemSharedLibraryNames(); 7594 7595 /** 7596 * Get a list of shared libraries on the device. 7597 * 7598 * Use {@link #getSharedLibraries(PackageInfoFlags)} when long flags are needed. 7599 * 7600 * @param flags To filter the libraries to return. 7601 * @return The shared library list. 7602 * 7603 * @see #MATCH_UNINSTALLED_PACKAGES 7604 */ getSharedLibraries(int flags)7605 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(int flags); 7606 7607 /** 7608 * See {@link #getSharedLibraries(int)}. 7609 * @param flags 7610 */ getSharedLibraries(@onNull PackageInfoFlags flags)7611 public @NonNull List<SharedLibraryInfo> getSharedLibraries(@NonNull PackageInfoFlags flags) { 7612 throw new UnsupportedOperationException( 7613 "getSharedLibraries() not implemented in subclass"); 7614 } 7615 7616 /** 7617 * Get a list of shared libraries on the device. 7618 * 7619 * Use {@link #getSharedLibrariesAsUser(PackageInfoFlags, int)} when long flags are needed. 7620 * 7621 * @param flags To filter the libraries to return. 7622 * @param userId The user to query for. 7623 * @return The shared library list. 7624 * 7625 * @see #MATCH_FACTORY_ONLY 7626 * @see #MATCH_KNOWN_PACKAGES 7627 * @see #MATCH_ANY_USER 7628 * @see #MATCH_UNINSTALLED_PACKAGES 7629 * 7630 * @hide 7631 */ 7632 @SuppressWarnings("HiddenAbstractMethod") getSharedLibrariesAsUser(int flags, @UserIdInt int userId)7633 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(int flags, 7634 @UserIdInt int userId); 7635 7636 /** 7637 * See {@link #getSharedLibrariesAsUser(int, int)}. 7638 * @hide 7639 */ getSharedLibrariesAsUser( @onNull PackageInfoFlags flags, @UserIdInt int userId)7640 public @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser( 7641 @NonNull PackageInfoFlags flags, @UserIdInt int userId) { 7642 throw new UnsupportedOperationException( 7643 "getSharedLibrariesAsUser() not implemented in subclass"); 7644 } 7645 7646 /** 7647 * Get the list of shared libraries declared by a package. 7648 * 7649 * Use {@link #getDeclaredSharedLibraries(String, PackageInfoFlags)} when long flags are needed. 7650 * 7651 * @param packageName the package name to query 7652 * @param flags the flags to filter packages 7653 * @return the shared library list 7654 * 7655 * @hide 7656 */ 7657 @SuppressWarnings("HiddenAbstractMethod") 7658 @NonNull 7659 @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES) 7660 @SystemApi getDeclaredSharedLibraries(@onNull String packageName, int flags)7661 public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName, 7662 int flags) { 7663 throw new UnsupportedOperationException( 7664 "getDeclaredSharedLibraries() not implemented in subclass"); 7665 } 7666 7667 /** 7668 * See {@link #getDeclaredSharedLibraries(String, int)}. 7669 * @hide 7670 */ 7671 @NonNull 7672 @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES) 7673 @SystemApi getDeclaredSharedLibraries(@onNull String packageName, @NonNull PackageInfoFlags flags)7674 public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName, 7675 @NonNull PackageInfoFlags flags) { 7676 throw new UnsupportedOperationException( 7677 "getDeclaredSharedLibraries() not implemented in subclass"); 7678 } 7679 7680 /** 7681 * Get the name of the package hosting the services shared library. 7682 * <p> 7683 * Note that this package is no longer a shared library since Android R. It is now a package 7684 * that hosts for a bunch of updatable services that the system binds to. 7685 * 7686 * @return The library host package. 7687 * 7688 * @hide 7689 */ 7690 @SuppressWarnings("HiddenAbstractMethod") 7691 @UnsupportedAppUsage 7692 @TestApi getServicesSystemSharedLibraryPackageName()7693 public abstract @NonNull String getServicesSystemSharedLibraryPackageName(); 7694 7695 /** 7696 * Get the name of the package hosting the shared components shared library. 7697 * 7698 * @return The library host package. 7699 * 7700 * @hide 7701 */ 7702 @SuppressWarnings("HiddenAbstractMethod") 7703 @UnsupportedAppUsage 7704 @TestApi getSharedSystemSharedLibraryPackageName()7705 public abstract @NonNull String getSharedSystemSharedLibraryPackageName(); 7706 7707 /** 7708 * Returns the names of the packages that have been changed 7709 * [eg. added, removed or updated] since the given sequence 7710 * number. 7711 * <p>If no packages have been changed, returns <code>null</code>. 7712 * <p>The sequence number starts at <code>0</code> and is 7713 * reset every boot. 7714 * @param sequenceNumber The first sequence number for which to retrieve package changes. 7715 * @see android.provider.Settings.Global#BOOT_COUNT 7716 */ getChangedPackages( @ntRangefrom=0) int sequenceNumber)7717 public abstract @Nullable ChangedPackages getChangedPackages( 7718 @IntRange(from=0) int sequenceNumber); 7719 7720 /** 7721 * Get a list of features that are available on the 7722 * system. 7723 * 7724 * @return An array of FeatureInfo classes describing the features 7725 * that are available on the system, or null if there are none(!!). 7726 */ 7727 @NonNull getSystemAvailableFeatures()7728 public abstract FeatureInfo[] getSystemAvailableFeatures(); 7729 7730 /** 7731 * Check whether the given feature name is one of the available features as 7732 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 7733 * presence of <em>any</em> version of the given feature name; use 7734 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 7735 * 7736 * @return Returns true if the devices supports the feature, else false. 7737 */ hasSystemFeature(@onNull String featureName)7738 public abstract boolean hasSystemFeature(@NonNull String featureName); 7739 7740 /** 7741 * Check whether the given feature name and version is one of the available 7742 * features as returned by {@link #getSystemAvailableFeatures()}. Since 7743 * features are defined to always be backwards compatible, this returns true 7744 * if the available feature version is greater than or equal to the 7745 * requested version. 7746 * 7747 * @return Returns true if the devices supports the feature, else false. 7748 */ hasSystemFeature(@onNull String featureName, int version)7749 public abstract boolean hasSystemFeature(@NonNull String featureName, int version); 7750 7751 /** 7752 * Determine the best action to perform for a given Intent. This is how 7753 * {@link Intent#resolveActivity} finds an activity if a class has not been 7754 * explicitly specified. 7755 * <p> 7756 * <em>Note:</em> if using an implicit Intent (without an explicit 7757 * ComponentName specified), be sure to consider whether to set the 7758 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 7759 * activity in the same way that 7760 * {@link android.content.Context#startActivity(Intent)} and 7761 * {@link android.content.Intent#resolveActivity(PackageManager) 7762 * Intent.resolveActivity(PackageManager)} do. 7763 * </p> 7764 * 7765 * Use {@link #resolveActivity(Intent, ResolveInfoFlags)} when long flags are needed. 7766 * 7767 * @param intent An intent containing all of the desired specification 7768 * (action, data, type, category, and/or component). 7769 * @param flags Additional option flags to modify the data returned. The 7770 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7771 * resolution to only those activities that support the 7772 * {@link android.content.Intent#CATEGORY_DEFAULT}. 7773 * @return Returns a ResolveInfo object containing the final activity intent 7774 * that was determined to be the best action. Returns null if no 7775 * matching activity was found. If multiple matching activities are 7776 * found and there is no default set, returns a ResolveInfo object 7777 * containing something else, such as the activity resolver. 7778 */ 7779 @Nullable resolveActivity(@onNull Intent intent, int flags)7780 public abstract ResolveInfo resolveActivity(@NonNull Intent intent, int flags); 7781 7782 /** 7783 * See {@link #resolveActivity(Intent, int)}. 7784 */ 7785 @Nullable resolveActivity(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7786 public ResolveInfo resolveActivity(@NonNull Intent intent, @NonNull ResolveInfoFlags flags) { 7787 throw new UnsupportedOperationException( 7788 "resolveActivity not implemented in subclass"); 7789 } 7790 7791 /** 7792 * Determine the best action to perform for a given Intent for a given user. 7793 * This is how {@link Intent#resolveActivity} finds an activity if a class 7794 * has not been explicitly specified. 7795 * <p> 7796 * <em>Note:</em> if using an implicit Intent (without an explicit 7797 * ComponentName specified), be sure to consider whether to set the 7798 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 7799 * activity in the same way that 7800 * {@link android.content.Context#startActivity(Intent)} and 7801 * {@link android.content.Intent#resolveActivity(PackageManager) 7802 * Intent.resolveActivity(PackageManager)} do. 7803 * </p> 7804 * 7805 * Use {@link #resolveActivityAsUser(Intent, ResolveInfoFlags, int)} when long flags are needed. 7806 * 7807 * @param intent An intent containing all of the desired specification 7808 * (action, data, type, category, and/or component). 7809 * @param flags Additional option flags to modify the data returned. The 7810 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7811 * resolution to only those activities that support the 7812 * {@link android.content.Intent#CATEGORY_DEFAULT}. 7813 * @param userId The user id. 7814 * @return Returns a ResolveInfo object containing the final activity intent 7815 * that was determined to be the best action. Returns null if no 7816 * matching activity was found. If multiple matching activities are 7817 * found and there is no default set, returns a ResolveInfo object 7818 * containing something else, such as the activity resolver. 7819 * @hide 7820 */ 7821 @SuppressWarnings("HiddenAbstractMethod") 7822 @Nullable 7823 @UnsupportedAppUsage resolveActivityAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7824 public abstract ResolveInfo resolveActivityAsUser(@NonNull Intent intent, 7825 int flags, @UserIdInt int userId); 7826 7827 /** 7828 * See {@link #resolveActivityAsUser(Intent, int, int)}. 7829 * @hide 7830 */ 7831 @Nullable resolveActivityAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7832 public ResolveInfo resolveActivityAsUser(@NonNull Intent intent, 7833 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 7834 throw new UnsupportedOperationException( 7835 "resolveActivityAsUser not implemented in subclass"); 7836 } 7837 7838 /** 7839 * Retrieve all activities that can be performed for the given intent. 7840 * 7841 * Use {@link #queryIntentActivities(Intent, ResolveInfoFlags)} when long flags are needed. 7842 * 7843 * @param intent The desired intent as per resolveActivity(). 7844 * @param flags Additional option flags to modify the data returned. The 7845 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7846 * resolution to only those activities that support the 7847 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 7848 * {@link #MATCH_ALL} to prevent any filtering of the results. 7849 * @return Returns a List of ResolveInfo objects containing one entry for 7850 * each matching activity, ordered from best to worst. In other 7851 * words, the first item is what would be returned by 7852 * {@link #resolveActivity}. If there are no matching activities, an 7853 * empty list is returned. 7854 */ 7855 @NonNull queryIntentActivities(@onNull Intent intent, int flags)7856 public abstract List<ResolveInfo> queryIntentActivities(@NonNull Intent intent, int flags); 7857 7858 /** 7859 * See {@link #queryIntentActivities(Intent, int)}. 7860 */ 7861 @NonNull queryIntentActivities(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7862 public List<ResolveInfo> queryIntentActivities(@NonNull Intent intent, 7863 @NonNull ResolveInfoFlags flags) { 7864 throw new UnsupportedOperationException( 7865 "queryIntentActivities not implemented in subclass"); 7866 } 7867 7868 /** 7869 * Retrieve all activities that can be performed for the given intent, for a 7870 * specific user. 7871 * 7872 * Use {@link #queryIntentActivitiesAsUser(Intent, ResolveInfoFlags, int)} when long flags are 7873 * needed. 7874 * 7875 * @param intent The desired intent as per resolveActivity(). 7876 * @param flags Additional option flags to modify the data returned. The 7877 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7878 * resolution to only those activities that support the 7879 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 7880 * {@link #MATCH_ALL} to prevent any filtering of the results. 7881 * @return Returns a List of ResolveInfo objects containing one entry for 7882 * each matching activity, ordered from best to worst. In other 7883 * words, the first item is what would be returned by 7884 * {@link #resolveActivity}. If there are no matching activities, an 7885 * empty list is returned. 7886 * @hide 7887 */ 7888 @SuppressWarnings("HiddenAbstractMethod") 7889 @NonNull 7890 @UnsupportedAppUsage queryIntentActivitiesAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7891 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 7892 int flags, @UserIdInt int userId); 7893 7894 /** 7895 * See {@link #queryIntentActivitiesAsUser(Intent, int, int)}. 7896 * @hide 7897 */ 7898 @NonNull queryIntentActivitiesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7899 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 7900 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 7901 throw new UnsupportedOperationException( 7902 "queryIntentActivitiesAsUser not implemented in subclass"); 7903 } 7904 7905 /** 7906 * Retrieve all activities that can be performed for the given intent, for a 7907 * specific user. 7908 * 7909 * Use {@link #queryIntentActivitiesAsUser(Intent, ResolveInfoFlags, UserHandle)} when long 7910 * flags are needed. 7911 * 7912 * @param intent The desired intent as per resolveActivity(). 7913 * @param flags Additional option flags to modify the data returned. The 7914 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7915 * resolution to only those activities that support the 7916 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 7917 * {@link #MATCH_ALL} to prevent any filtering of the results. 7918 * @param user The user being queried. 7919 * @return Returns a List of ResolveInfo objects containing one entry for 7920 * each matching activity, ordered from best to worst. In other 7921 * words, the first item is what would be returned by 7922 * {@link #resolveActivity}. If there are no matching activities, an 7923 * empty list is returned. 7924 * @hide 7925 */ 7926 @SuppressWarnings("HiddenAbstractMethod") 7927 @NonNull 7928 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 7929 @SystemApi queryIntentActivitiesAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)7930 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 7931 int flags, @NonNull UserHandle user) { 7932 return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier()); 7933 } 7934 7935 /** 7936 * See {@link #queryIntentActivitiesAsUser(Intent, int, UserHandle)}. 7937 * @hide 7938 */ 7939 @NonNull 7940 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 7941 @SystemApi queryIntentActivitiesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)7942 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 7943 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) { 7944 return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier()); 7945 } 7946 7947 /** 7948 * Retrieve a set of activities that should be presented to the user as 7949 * similar options. This is like {@link #queryIntentActivities}, except it 7950 * also allows you to supply a list of more explicit Intents that you would 7951 * like to resolve to particular options, and takes care of returning the 7952 * final ResolveInfo list in a reasonable order, with no duplicates, based 7953 * on those inputs. 7954 * 7955 * Use {@link #queryIntentActivityOptions(ComponentName, List, Intent, ResolveInfoFlags)} when 7956 * long flags are needed. 7957 * 7958 * @param caller The class name of the activity that is making the request. 7959 * This activity will never appear in the output list. Can be 7960 * null. 7961 * @param specifics An array of Intents that should be resolved to the first 7962 * specific results. Can be null. 7963 * @param intent The desired intent as per resolveActivity(). 7964 * @param flags Additional option flags to modify the data returned. The 7965 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 7966 * resolution to only those activities that support the 7967 * {@link android.content.Intent#CATEGORY_DEFAULT}. 7968 * @return Returns a List of ResolveInfo objects containing one entry for 7969 * each matching activity. The list is ordered first by all of the 7970 * intents resolved in <var>specifics</var> and then any additional 7971 * activities that can handle <var>intent</var> but did not get 7972 * included by one of the <var>specifics</var> intents. If there are 7973 * no matching activities, an empty list is returned. 7974 */ 7975 @NonNull queryIntentActivityOptions(@ullable ComponentName caller, @Nullable Intent[] specifics, @NonNull Intent intent, int flags)7976 public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller, 7977 @Nullable Intent[] specifics, @NonNull Intent intent, int flags); 7978 7979 /** 7980 * See {@link #queryIntentActivityOptions(ComponentName, Intent[], Intent, int)}. 7981 */ 7982 @NonNull queryIntentActivityOptions(@ullable ComponentName caller, @Nullable List<Intent> specifics, @NonNull Intent intent, @NonNull ResolveInfoFlags flags)7983 public List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller, 7984 @Nullable List<Intent> specifics, @NonNull Intent intent, 7985 @NonNull ResolveInfoFlags flags) { 7986 throw new UnsupportedOperationException( 7987 "queryIntentActivityOptions not implemented in subclass"); 7988 } 7989 7990 /** 7991 * Retrieve all receivers that can handle a broadcast of the given intent. 7992 * 7993 * Use {@link #queryBroadcastReceivers(Intent, ResolveInfoFlags)} when long flags are needed. 7994 * 7995 * @param intent The desired intent as per resolveActivity(). 7996 * @param flags Additional option flags to modify the data returned. 7997 * @return Returns a List of ResolveInfo objects containing one entry for 7998 * each matching receiver, ordered from best to worst. If there are 7999 * no matching receivers, returns an empty list. 8000 */ 8001 @NonNull queryBroadcastReceivers(@onNull Intent intent, int flags)8002 public abstract List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, int flags); 8003 8004 /** 8005 * See {@link #queryBroadcastReceivers(Intent, int)}. 8006 */ 8007 @NonNull queryBroadcastReceivers(@onNull Intent intent, @NonNull ResolveInfoFlags flags)8008 public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, 8009 @NonNull ResolveInfoFlags flags) { 8010 throw new UnsupportedOperationException( 8011 "queryBroadcastReceivers not implemented in subclass"); 8012 } 8013 8014 /** 8015 * Retrieve all receivers that can handle a broadcast of the given intent, 8016 * for a specific user. 8017 * 8018 * Use {@link #queryBroadcastReceiversAsUser(Intent, ResolveInfoFlags, UserHandle)} when long 8019 * flags are needed. 8020 * 8021 * @param intent The desired intent as per resolveActivity(). 8022 * @param flags Additional option flags to modify the data returned. 8023 * @param userHandle UserHandle of the user being queried. 8024 * @return Returns a List of ResolveInfo objects containing one entry for 8025 * each matching receiver, ordered from best to worst. If there are 8026 * no matching receivers, returns an empty list. 8027 * @hide 8028 */ 8029 @SuppressWarnings("HiddenAbstractMethod") 8030 @NonNull 8031 @SystemApi 8032 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) queryBroadcastReceiversAsUser(@onNull Intent intent, int flags, UserHandle userHandle)8033 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 8034 int flags, UserHandle userHandle) { 8035 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 8036 } 8037 8038 /** 8039 * See {@link #queryBroadcastReceiversAsUser(Intent, int, UserHandle)}. 8040 * @hide 8041 */ 8042 @NonNull 8043 @SystemApi 8044 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) queryBroadcastReceiversAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle userHandle)8045 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 8046 @NonNull ResolveInfoFlags flags, @NonNull UserHandle userHandle) { 8047 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 8048 } 8049 8050 /** 8051 * @hide 8052 * Use {@link #queryBroadcastReceiversAsUser(Intent, ResolveInfoFlags, int)} when long flags are 8053 * needed. 8054 */ 8055 @SuppressWarnings("HiddenAbstractMethod") 8056 @NonNull 8057 @UnsupportedAppUsage queryBroadcastReceiversAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)8058 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 8059 int flags, @UserIdInt int userId); 8060 8061 /** 8062 * See {@link #queryBroadcastReceiversAsUser(Intent, int, int)}. 8063 * @hide 8064 */ 8065 @NonNull queryBroadcastReceiversAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)8066 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 8067 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 8068 throw new UnsupportedOperationException( 8069 "queryBroadcastReceiversAsUser not implemented in subclass"); 8070 } 8071 8072 8073 /** @deprecated @hide */ 8074 @NonNull 8075 @Deprecated 8076 @UnsupportedAppUsage queryBroadcastReceivers(@onNull Intent intent, int flags, @UserIdInt int userId)8077 public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, 8078 int flags, @UserIdInt int userId) { 8079 final String msg = "Shame on you for calling the hidden API " 8080 + "queryBroadcastReceivers(). Shame!"; 8081 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) { 8082 throw new UnsupportedOperationException(msg); 8083 } else { 8084 Log.d(TAG, msg); 8085 return queryBroadcastReceiversAsUser(intent, flags, userId); 8086 } 8087 } 8088 8089 /** 8090 * Determine the best service to handle for a given Intent. 8091 * 8092 * Use {@link #resolveService(Intent, ResolveInfoFlags)} when long flags are needed. 8093 * 8094 * @param intent An intent containing all of the desired specification 8095 * (action, data, type, category, and/or component). 8096 * @param flags Additional option flags to modify the data returned. 8097 * @return Returns a ResolveInfo object containing the final service intent 8098 * that was determined to be the best action. Returns null if no 8099 * matching service was found. 8100 */ 8101 @Nullable resolveService(@onNull Intent intent, int flags)8102 public abstract ResolveInfo resolveService(@NonNull Intent intent, int flags); 8103 8104 /** 8105 * See {@link #resolveService(Intent, int)}. 8106 */ 8107 @Nullable resolveService(@onNull Intent intent, @NonNull ResolveInfoFlags flags)8108 public ResolveInfo resolveService(@NonNull Intent intent, @NonNull ResolveInfoFlags flags) { 8109 throw new UnsupportedOperationException( 8110 "resolveService not implemented in subclass"); 8111 } 8112 8113 /** 8114 * @hide 8115 * Use {@link #resolveServiceAsUser(Intent, ResolveInfoFlags, int)} when long flags are needed. 8116 */ 8117 @SuppressWarnings("HiddenAbstractMethod") 8118 @Nullable resolveServiceAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)8119 public abstract ResolveInfo resolveServiceAsUser(@NonNull Intent intent, 8120 int flags, @UserIdInt int userId); 8121 8122 /** 8123 * See {@link #resolveServiceAsUser(Intent, int, int)}. 8124 * @hide 8125 */ 8126 @Nullable resolveServiceAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)8127 public ResolveInfo resolveServiceAsUser(@NonNull Intent intent, 8128 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 8129 throw new UnsupportedOperationException( 8130 "resolveServiceAsUser not implemented in subclass"); 8131 } 8132 8133 /** 8134 * Retrieve all services that can match the given intent. 8135 * 8136 * Use {@link #queryIntentServices(Intent, ResolveInfoFlags)} when long flags are needed. 8137 * 8138 * @param intent The desired intent as per resolveService(). 8139 * @param flags Additional option flags to modify the data returned. 8140 * @return Returns a List of ResolveInfo objects containing one entry for 8141 * each matching service, ordered from best to worst. In other 8142 * words, the first item is what would be returned by 8143 * {@link #resolveService}. If there are no matching services, 8144 * returns an empty list. 8145 */ 8146 @NonNull queryIntentServices(@onNull Intent intent, int flags)8147 public abstract List<ResolveInfo> queryIntentServices(@NonNull Intent intent, 8148 int flags); 8149 8150 /** 8151 * See {@link #queryIntentServices(Intent, int)}. 8152 */ 8153 @NonNull queryIntentServices(@onNull Intent intent, @NonNull ResolveInfoFlags flags)8154 public List<ResolveInfo> queryIntentServices(@NonNull Intent intent, 8155 @NonNull ResolveInfoFlags flags) { 8156 throw new UnsupportedOperationException( 8157 "queryIntentServices not implemented in subclass"); 8158 } 8159 8160 /** 8161 * Retrieve all services that can match the given intent for a given user. 8162 * 8163 * Use {@link #queryIntentServicesAsUser(Intent, ResolveInfoFlags, int)} when long flags are 8164 * needed. 8165 * 8166 * @param intent The desired intent as per resolveService(). 8167 * @param flags Additional option flags to modify the data returned. 8168 * @param userId The user id. 8169 * @return Returns a List of ResolveInfo objects containing one entry for 8170 * each matching service, ordered from best to worst. In other 8171 * words, the first item is what would be returned by 8172 * {@link #resolveService}. If there are no matching services, 8173 * returns an empty list. 8174 * @hide 8175 */ 8176 @SuppressWarnings("HiddenAbstractMethod") 8177 @NonNull 8178 @UnsupportedAppUsage queryIntentServicesAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)8179 public abstract List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 8180 int flags, @UserIdInt int userId); 8181 8182 /** 8183 * See {@link #queryIntentServicesAsUser(Intent, int, int)}. 8184 * @hide 8185 */ 8186 @NonNull queryIntentServicesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)8187 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 8188 @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 8189 throw new UnsupportedOperationException( 8190 "queryIntentServicesAsUser not implemented in subclass"); 8191 } 8192 8193 /** 8194 * Retrieve all services that can match the given intent for a given user. 8195 * 8196 * Use {@link #queryIntentServicesAsUser(Intent, ResolveInfoFlags, UserHandle)} when long flags 8197 * are needed. 8198 * 8199 * @param intent The desired intent as per resolveService(). 8200 * @param flags Additional option flags to modify the data returned. 8201 * @param user The user being queried. 8202 * @return Returns a List of ResolveInfo objects containing one entry for 8203 * each matching service, ordered from best to worst. In other 8204 * words, the first item is what would be returned by 8205 * {@link #resolveService}. If there are no matching services, 8206 * returns an empty list. 8207 * @hide 8208 */ 8209 @NonNull 8210 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 8211 @SystemApi queryIntentServicesAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)8212 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 8213 int flags, @NonNull UserHandle user) { 8214 return queryIntentServicesAsUser(intent, flags, user.getIdentifier()); 8215 } 8216 8217 /** 8218 * See {@link #queryIntentServicesAsUser(Intent, int, UserHandle)}. 8219 * @hide 8220 */ 8221 @NonNull 8222 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 8223 @SystemApi queryIntentServicesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)8224 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 8225 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) { 8226 return queryIntentServicesAsUser(intent, flags, user.getIdentifier()); 8227 } 8228 /** 8229 * Retrieve all providers that can match the given intent. 8230 * 8231 * Use {@link #queryIntentContentProvidersAsUser(Intent, ResolveInfoFlags, int)} when long flags 8232 * are needed. 8233 * 8234 * @param intent An intent containing all of the desired specification 8235 * (action, data, type, category, and/or component). 8236 * @param flags Additional option flags to modify the data returned. 8237 * @param userId The user id. 8238 * @return Returns a List of ResolveInfo objects containing one entry for 8239 * each matching provider, ordered from best to worst. If there are 8240 * no matching services, returns an empty list. 8241 * @hide 8242 */ 8243 @SuppressWarnings("HiddenAbstractMethod") 8244 @NonNull 8245 @UnsupportedAppUsage queryIntentContentProvidersAsUser( @onNull Intent intent, int flags, @UserIdInt int userId)8246 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 8247 @NonNull Intent intent, int flags, @UserIdInt int userId); 8248 8249 /** 8250 * See {@link #queryIntentContentProvidersAsUser(Intent, int, int)}. 8251 * @hide 8252 */ 8253 @NonNull queryIntentContentProvidersAsUser( @onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)8254 protected List<ResolveInfo> queryIntentContentProvidersAsUser( 8255 @NonNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId) { 8256 throw new UnsupportedOperationException( 8257 "queryIntentContentProvidersAsUser not implemented in subclass"); 8258 } 8259 8260 /** 8261 * Retrieve all providers that can match the given intent. 8262 * 8263 * Use {@link #queryIntentContentProvidersAsUser(Intent, ResolveInfoFlags, UserHandle)} when 8264 * long flags are needed. 8265 * 8266 * @param intent An intent containing all of the desired specification 8267 * (action, data, type, category, and/or component). 8268 * @param flags Additional option flags to modify the data returned. 8269 * @param user The user being queried. 8270 * @return Returns a List of ResolveInfo objects containing one entry for 8271 * each matching provider, ordered from best to worst. If there are 8272 * no matching services, returns an empty list. 8273 * @hide 8274 */ 8275 @NonNull 8276 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 8277 @SystemApi queryIntentContentProvidersAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)8278 public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent, 8279 int flags, @NonNull UserHandle user) { 8280 return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier()); 8281 } 8282 8283 /** 8284 * See {@link #queryIntentContentProvidersAsUser(Intent, int, UserHandle)}. 8285 * @hide 8286 */ 8287 @NonNull 8288 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 8289 @SystemApi queryIntentContentProvidersAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)8290 public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent, 8291 @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) { 8292 return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier()); 8293 } 8294 8295 /** 8296 * Retrieve all providers that can match the given intent. 8297 * 8298 * Use {@link #queryIntentContentProviders(Intent, ResolveInfoFlags)} when long flags are 8299 * needed. 8300 * 8301 * @param intent An intent containing all of the desired specification 8302 * (action, data, type, category, and/or component). 8303 * @param flags Additional option flags to modify the data returned. 8304 * @return Returns a List of ResolveInfo objects containing one entry for 8305 * each matching provider, ordered from best to worst. If there are 8306 * no matching services, returns an empty list. 8307 */ 8308 @NonNull queryIntentContentProviders(@onNull Intent intent, int flags)8309 public abstract List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent, 8310 int flags); 8311 8312 /** 8313 * See {@link #queryIntentContentProviders(Intent, int)}. 8314 */ 8315 @NonNull queryIntentContentProviders(@onNull Intent intent, @NonNull ResolveInfoFlags flags)8316 public List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent, 8317 @NonNull ResolveInfoFlags flags) { 8318 throw new UnsupportedOperationException( 8319 "queryIntentContentProviders not implemented in subclass"); 8320 } 8321 8322 /** 8323 * Find a single content provider by its authority. 8324 * <p> 8325 * Example:<p> 8326 * <pre> 8327 * Uri uri = Uri.parse("content://com.example.app.provider/table1"); 8328 * ProviderInfo info = packageManager.resolveContentProvider(uri.getAuthority(), flags); 8329 * </pre> 8330 * 8331 * Use {@link #resolveContentProvider(String, ComponentInfoFlags)} when long flags are needed. 8332 * 8333 * @param authority The authority of the provider to find. 8334 * @param flags Additional option flags to modify the data returned. 8335 * @return A {@link ProviderInfo} object containing information about the 8336 * provider. If a provider was not found, returns null. 8337 */ 8338 @Nullable resolveContentProvider(@onNull String authority, int flags)8339 public abstract ProviderInfo resolveContentProvider(@NonNull String authority, 8340 int flags); 8341 8342 /** 8343 * See {@link #resolveContentProvider(String, int)}. 8344 */ 8345 @Nullable resolveContentProvider(@onNull String authority, @NonNull ComponentInfoFlags flags)8346 public ProviderInfo resolveContentProvider(@NonNull String authority, 8347 @NonNull ComponentInfoFlags flags) { 8348 throw new UnsupportedOperationException( 8349 "resolveContentProvider not implemented in subclass"); 8350 } 8351 8352 /** 8353 * Find a single content provider by its base path name. 8354 * 8355 * Use {@link #resolveContentProviderAsUser(String, ComponentInfoFlags, int)} when long flags 8356 * are needed. 8357 * 8358 * @param providerName The name of the provider to find. 8359 * @param flags Additional option flags to modify the data returned. 8360 * @param userId The user id. 8361 * @return A {@link ProviderInfo} object containing information about the 8362 * provider. If a provider was not found, returns null. 8363 * @hide 8364 */ 8365 @SuppressWarnings("HiddenAbstractMethod") 8366 @Nullable 8367 @UnsupportedAppUsage resolveContentProviderAsUser(@onNull String providerName, int flags, @UserIdInt int userId)8368 public abstract ProviderInfo resolveContentProviderAsUser(@NonNull String providerName, 8369 int flags, @UserIdInt int userId); 8370 8371 /** 8372 * See {@link #resolveContentProviderAsUser(String, int, int)}. 8373 * @hide 8374 */ 8375 @Nullable resolveContentProviderAsUser(@onNull String providerName, @NonNull ComponentInfoFlags flags, @UserIdInt int userId)8376 public ProviderInfo resolveContentProviderAsUser(@NonNull String providerName, 8377 @NonNull ComponentInfoFlags flags, @UserIdInt int userId) { 8378 throw new UnsupportedOperationException( 8379 "resolveContentProviderAsUser not implemented in subclass"); 8380 } 8381 8382 /** 8383 * Resolve content providers with a given authority, for a specific callingUid. 8384 * @param authority Authority of the content provider 8385 * @param flags Additional option flags to modify the data returned. 8386 * @param callingUid UID of the caller who's access to the content provider is to be checked 8387 8388 * @return ProviderInfo of the resolved content provider. 8389 * @hide 8390 */ 8391 @Nullable 8392 @FlaggedApi(android.content.pm.Flags.FLAG_UID_BASED_PROVIDER_LOOKUP) 8393 @RequiresPermission(Manifest.permission.RESOLVE_COMPONENT_FOR_UID) 8394 @SystemApi resolveContentProviderForUid(@onNull String authority, @NonNull ComponentInfoFlags flags, int callingUid)8395 public ProviderInfo resolveContentProviderForUid(@NonNull String authority, 8396 @NonNull ComponentInfoFlags flags, int callingUid) { 8397 throw new UnsupportedOperationException( 8398 "resolveContentProviderForUid not implemented in subclass"); 8399 } 8400 8401 /** 8402 * Retrieve content provider information. 8403 * <p> 8404 * <em>Note: unlike most other methods, an empty result set is indicated 8405 * by a null return instead of an empty list.</em> 8406 * 8407 * Use {@link #queryContentProviders(String, int, ComponentInfoFlags)} when long flags are 8408 * needed. 8409 * 8410 * @param processName If non-null, limits the returned providers to only 8411 * those that are hosted by the given process. If null, all 8412 * content providers are returned. 8413 * @param uid If <var>processName</var> is non-null, this is the required 8414 * uid owning the requested content providers. 8415 * @param flags Additional option flags to modify the data returned. 8416 * @return A list of {@link ProviderInfo} objects containing one entry for 8417 * each provider either matching <var>processName</var> or, if 8418 * <var>processName</var> is null, all known content providers. 8419 * <em>If there are no matching providers, null is returned.</em> 8420 */ 8421 @NonNull queryContentProviders( @ullable String processName, int uid, int flags)8422 public abstract List<ProviderInfo> queryContentProviders( 8423 @Nullable String processName, int uid, int flags); 8424 8425 /** 8426 * See {@link #queryContentProviders(String, int, int)}. 8427 */ 8428 @NonNull queryContentProviders( @ullable String processName, int uid, @NonNull ComponentInfoFlags flags)8429 public List<ProviderInfo> queryContentProviders( 8430 @Nullable String processName, int uid, @NonNull ComponentInfoFlags flags) { 8431 throw new UnsupportedOperationException( 8432 "queryContentProviders not implemented in subclass"); 8433 } 8434 8435 /** 8436 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null, 8437 * it only returns providers which have metadata with the {@code metaDataKey} key. 8438 * 8439 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider. 8440 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders} 8441 * instead. 8442 * 8443 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly 8444 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata 8445 * to mark GAL providers, rather than intent filters, so we can't use 8446 * {@link #queryIntentContentProviders} for that. 8447 * 8448 * Use {@link #queryContentProviders(String, int, ComponentInfoFlags, String)} when long flags 8449 * are needed. 8450 * 8451 * @hide 8452 */ 8453 @NonNull queryContentProviders(@ullable String processName, int uid, int flags, String metaDataKey)8454 public List<ProviderInfo> queryContentProviders(@Nullable String processName, 8455 int uid, int flags, String metaDataKey) { 8456 // Provide the default implementation for mocks. 8457 return queryContentProviders(processName, uid, flags); 8458 } 8459 8460 /** 8461 * See {@link #queryContentProviders(String, int, int, String)}. 8462 * @hide 8463 */ 8464 @NonNull queryContentProviders(@ullable String processName, int uid, @NonNull ComponentInfoFlags flags, @Nullable String metaDataKey)8465 public List<ProviderInfo> queryContentProviders(@Nullable String processName, 8466 int uid, @NonNull ComponentInfoFlags flags, @Nullable String metaDataKey) { 8467 // Provide the default implementation for mocks. 8468 return queryContentProviders(processName, uid, flags); 8469 } 8470 8471 /** 8472 * Retrieve all of the information we know about a particular 8473 * instrumentation class. 8474 * 8475 * @param className The full name (i.e. 8476 * com.google.apps.contacts.InstrumentList) of an Instrumentation 8477 * class. 8478 * @param flags Additional option flags to modify the data returned. 8479 * @return An {@link InstrumentationInfo} object containing information 8480 * about the instrumentation. 8481 * @throws NameNotFoundException if a package with the given name cannot be 8482 * found on the system. 8483 */ 8484 @NonNull getInstrumentationInfo(@onNull ComponentName className, @InstrumentationInfoFlags int flags)8485 public abstract InstrumentationInfo getInstrumentationInfo(@NonNull ComponentName className, 8486 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 8487 8488 /** 8489 * Retrieve information about available instrumentation code. May be used to 8490 * retrieve either all instrumentation code, or only the code targeting a 8491 * particular package. 8492 * 8493 * @param targetPackage If null, all instrumentation is returned; only the 8494 * instrumentation targeting this package name is returned. 8495 * @param flags Additional option flags to modify the data returned. 8496 * @return A list of {@link InstrumentationInfo} objects containing one 8497 * entry for each matching instrumentation. If there are no 8498 * instrumentation available, returns an empty list. 8499 */ 8500 @NonNull queryInstrumentation(@onNull String targetPackage, @InstrumentationInfoFlags int flags)8501 public abstract List<InstrumentationInfo> queryInstrumentation(@NonNull String targetPackage, 8502 @InstrumentationInfoFlags int flags); 8503 8504 /** 8505 * Retrieve an image from a package. This is a low-level API used by 8506 * the various package manager info structures (such as 8507 * {@link ComponentInfo} to implement retrieval of their associated 8508 * icon. 8509 * 8510 * @param packageName The name of the package that this icon is coming from. 8511 * Cannot be null. 8512 * @param resid The resource identifier of the desired image. Cannot be 0. 8513 * @param appInfo Overall information about <var>packageName</var>. This 8514 * may be null, in which case the application information will be retrieved 8515 * for you if needed; if you already have this information around, it can 8516 * be much more efficient to supply it here. 8517 * 8518 * @return Returns a Drawable holding the requested image. Returns null if 8519 * an image could not be found for any reason. 8520 */ 8521 @Nullable getDrawable(@onNull String packageName, @DrawableRes int resid, @Nullable ApplicationInfo appInfo)8522 public abstract Drawable getDrawable(@NonNull String packageName, @DrawableRes int resid, 8523 @Nullable ApplicationInfo appInfo); 8524 8525 /** 8526 * Retrieve the icon associated with an activity. Given the full name of 8527 * an activity, retrieves the information about it and calls 8528 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 8529 * If the activity cannot be found, NameNotFoundException is thrown. 8530 * 8531 * @param activityName Name of the activity whose icon is to be retrieved. 8532 * 8533 * @return Returns the image of the icon, or the default activity icon if 8534 * it could not be found. Does not return null. 8535 * @throws NameNotFoundException Thrown if the resources for the given 8536 * activity could not be loaded. 8537 * 8538 * @see #getActivityIcon(Intent) 8539 */ 8540 @NonNull getActivityIcon(@onNull ComponentName activityName)8541 public abstract Drawable getActivityIcon(@NonNull ComponentName activityName) 8542 throws NameNotFoundException; 8543 8544 /** 8545 * Retrieve the icon associated with an Intent. If intent.getClassName() is 8546 * set, this simply returns the result of 8547 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 8548 * component and returns the icon associated with the resolved component. 8549 * If intent.getClassName() cannot be found or the Intent cannot be resolved 8550 * to a component, NameNotFoundException is thrown. 8551 * 8552 * @param intent The intent for which you would like to retrieve an icon. 8553 * 8554 * @return Returns the image of the icon, or the default activity icon if 8555 * it could not be found. Does not return null. 8556 * @throws NameNotFoundException Thrown if the resources for application 8557 * matching the given intent could not be loaded. 8558 * 8559 * @see #getActivityIcon(ComponentName) 8560 */ 8561 @NonNull getActivityIcon(@onNull Intent intent)8562 public abstract Drawable getActivityIcon(@NonNull Intent intent) 8563 throws NameNotFoundException; 8564 8565 /** 8566 * Retrieve the banner associated with an activity. Given the full name of 8567 * an activity, retrieves the information about it and calls 8568 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 8569 * banner. If the activity cannot be found, NameNotFoundException is thrown. 8570 * 8571 * @param activityName Name of the activity whose banner is to be retrieved. 8572 * @return Returns the image of the banner, or null if the activity has no 8573 * banner specified. 8574 * @throws NameNotFoundException Thrown if the resources for the given 8575 * activity could not be loaded. 8576 * @see #getActivityBanner(Intent) 8577 */ 8578 @Nullable getActivityBanner(@onNull ComponentName activityName)8579 public abstract Drawable getActivityBanner(@NonNull ComponentName activityName) 8580 throws NameNotFoundException; 8581 8582 /** 8583 * Retrieve the banner associated with an Intent. If intent.getClassName() 8584 * is set, this simply returns the result of 8585 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 8586 * intent's component and returns the banner associated with the resolved 8587 * component. If intent.getClassName() cannot be found or the Intent cannot 8588 * be resolved to a component, NameNotFoundException is thrown. 8589 * 8590 * @param intent The intent for which you would like to retrieve a banner. 8591 * @return Returns the image of the banner, or null if the activity has no 8592 * banner specified. 8593 * @throws NameNotFoundException Thrown if the resources for application 8594 * matching the given intent could not be loaded. 8595 * @see #getActivityBanner(ComponentName) 8596 */ 8597 @Nullable getActivityBanner(@onNull Intent intent)8598 public abstract Drawable getActivityBanner(@NonNull Intent intent) 8599 throws NameNotFoundException; 8600 8601 /** 8602 * Return the generic icon for an activity that is used when no specific 8603 * icon is defined. 8604 * 8605 * @return Drawable Image of the icon. 8606 */ 8607 @NonNull getDefaultActivityIcon()8608 public abstract Drawable getDefaultActivityIcon(); 8609 8610 /** 8611 * Retrieve the icon associated with an application. If it has not defined 8612 * an icon, the default app icon is returned. Does not return null. 8613 * 8614 * @param info Information about application being queried. 8615 * 8616 * @return Returns the image of the icon, or the default application icon 8617 * if it could not be found. 8618 * 8619 * @see #getApplicationIcon(String) 8620 */ 8621 @NonNull getApplicationIcon(@onNull ApplicationInfo info)8622 public abstract Drawable getApplicationIcon(@NonNull ApplicationInfo info); 8623 8624 /** 8625 * Retrieve the icon associated with an application. Given the name of the 8626 * application's package, retrieves the information about it and calls 8627 * getApplicationIcon() to return its icon. If the application cannot be 8628 * found, NameNotFoundException is thrown. 8629 * 8630 * @param packageName Name of the package whose application icon is to be 8631 * retrieved. 8632 * 8633 * @return Returns the image of the icon, or the default application icon 8634 * if it could not be found. Does not return null. 8635 * @throws NameNotFoundException Thrown if the resources for the given 8636 * application could not be loaded. 8637 * 8638 * @see #getApplicationIcon(ApplicationInfo) 8639 */ 8640 @NonNull getApplicationIcon(@onNull String packageName)8641 public abstract Drawable getApplicationIcon(@NonNull String packageName) 8642 throws NameNotFoundException; 8643 8644 /** 8645 * Retrieve the banner associated with an application. 8646 * 8647 * @param info Information about application being queried. 8648 * @return Returns the image of the banner or null if the application has no 8649 * banner specified. 8650 * @see #getApplicationBanner(String) 8651 */ 8652 @Nullable getApplicationBanner(@onNull ApplicationInfo info)8653 public abstract Drawable getApplicationBanner(@NonNull ApplicationInfo info); 8654 8655 /** 8656 * Retrieve the banner associated with an application. Given the name of the 8657 * application's package, retrieves the information about it and calls 8658 * getApplicationIcon() to return its banner. If the application cannot be 8659 * found, NameNotFoundException is thrown. 8660 * 8661 * @param packageName Name of the package whose application banner is to be 8662 * retrieved. 8663 * @return Returns the image of the banner or null if the application has no 8664 * banner specified. 8665 * @throws NameNotFoundException Thrown if the resources for the given 8666 * application could not be loaded. 8667 * @see #getApplicationBanner(ApplicationInfo) 8668 */ 8669 @Nullable getApplicationBanner(@onNull String packageName)8670 public abstract Drawable getApplicationBanner(@NonNull String packageName) 8671 throws NameNotFoundException; 8672 8673 /** 8674 * Retrieve the logo associated with an activity. Given the full name of an 8675 * activity, retrieves the information about it and calls 8676 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 8677 * logo. If the activity cannot be found, NameNotFoundException is thrown. 8678 * 8679 * @param activityName Name of the activity whose logo is to be retrieved. 8680 * @return Returns the image of the logo or null if the activity has no logo 8681 * specified. 8682 * @throws NameNotFoundException Thrown if the resources for the given 8683 * activity could not be loaded. 8684 * @see #getActivityLogo(Intent) 8685 */ 8686 @Nullable getActivityLogo(@onNull ComponentName activityName)8687 public abstract Drawable getActivityLogo(@NonNull ComponentName activityName) 8688 throws NameNotFoundException; 8689 8690 /** 8691 * Retrieve the logo associated with an Intent. If intent.getClassName() is 8692 * set, this simply returns the result of 8693 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 8694 * component and returns the logo associated with the resolved component. 8695 * If intent.getClassName() cannot be found or the Intent cannot be resolved 8696 * to a component, NameNotFoundException is thrown. 8697 * 8698 * @param intent The intent for which you would like to retrieve a logo. 8699 * 8700 * @return Returns the image of the logo, or null if the activity has no 8701 * logo specified. 8702 * 8703 * @throws NameNotFoundException Thrown if the resources for application 8704 * matching the given intent could not be loaded. 8705 * 8706 * @see #getActivityLogo(ComponentName) 8707 */ 8708 @Nullable getActivityLogo(@onNull Intent intent)8709 public abstract Drawable getActivityLogo(@NonNull Intent intent) 8710 throws NameNotFoundException; 8711 8712 /** 8713 * Retrieve the logo associated with an application. If it has not specified 8714 * a logo, this method returns null. 8715 * 8716 * @param info Information about application being queried. 8717 * 8718 * @return Returns the image of the logo, or null if no logo is specified 8719 * by the application. 8720 * 8721 * @see #getApplicationLogo(String) 8722 */ 8723 @Nullable getApplicationLogo(@onNull ApplicationInfo info)8724 public abstract Drawable getApplicationLogo(@NonNull ApplicationInfo info); 8725 8726 /** 8727 * Retrieve the logo associated with an application. Given the name of the 8728 * application's package, retrieves the information about it and calls 8729 * getApplicationLogo() to return its logo. If the application cannot be 8730 * found, NameNotFoundException is thrown. 8731 * 8732 * @param packageName Name of the package whose application logo is to be 8733 * retrieved. 8734 * 8735 * @return Returns the image of the logo, or null if no application logo 8736 * has been specified. 8737 * 8738 * @throws NameNotFoundException Thrown if the resources for the given 8739 * application could not be loaded. 8740 * 8741 * @see #getApplicationLogo(ApplicationInfo) 8742 */ 8743 @Nullable getApplicationLogo(@onNull String packageName)8744 public abstract Drawable getApplicationLogo(@NonNull String packageName) 8745 throws NameNotFoundException; 8746 8747 /** 8748 * If the target user is a managed profile, then this returns a badged copy of the given icon 8749 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use 8750 * {@link #getUserBadgedDrawableForDensity( 8751 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 8752 * <p> 8753 * If the original drawable is a BitmapDrawable and the backing bitmap is 8754 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 8755 * is performed in place and the original drawable is returned. 8756 * </p> 8757 * 8758 * @param drawable The drawable to badge. 8759 * @param user The target user. 8760 * @return A drawable that combines the original icon and a badge as 8761 * determined by the system. 8762 */ 8763 @NonNull getUserBadgedIcon(@onNull Drawable drawable, @NonNull UserHandle user)8764 public abstract Drawable getUserBadgedIcon(@NonNull Drawable drawable, 8765 @NonNull UserHandle user); 8766 8767 /** 8768 * If the target user is a managed profile of the calling user or the caller 8769 * is itself a managed profile, then this returns a badged copy of the given 8770 * drawable allowing the user to distinguish it from the original drawable. 8771 * The caller can specify the location in the bounds of the drawable to be 8772 * badged where the badge should be applied as well as the density of the 8773 * badge to be used. 8774 * <p> 8775 * If the original drawable is a BitmapDrawable and the backing bitmap is 8776 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 8777 * is performed in place and the original drawable is returned. 8778 * </p> 8779 * 8780 * @param drawable The drawable to badge. 8781 * @param user The target user. 8782 * @param badgeLocation Where in the bounds of the badged drawable to place 8783 * the badge. If it's {@code null}, the badge is applied on top of the entire 8784 * drawable being badged. 8785 * @param badgeDensity The optional desired density for the badge as per 8786 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 8787 * the density of the display is used. 8788 * @return A drawable that combines the original drawable and a badge as 8789 * determined by the system. 8790 */ 8791 @NonNull getUserBadgedDrawableForDensity(@onNull Drawable drawable, @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity)8792 public abstract Drawable getUserBadgedDrawableForDensity(@NonNull Drawable drawable, 8793 @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity); 8794 8795 /** 8796 * If the target user is a managed profile of the calling user or the caller 8797 * is itself a managed profile, then this returns a drawable to use as a small 8798 * icon to include in a view to distinguish it from the original icon. 8799 * 8800 * @param user The target user. 8801 * @param density The optional desired density for the badge as per 8802 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 8803 * the density of the current display is used. 8804 * @return the drawable or null if no drawable is required. 8805 * @hide 8806 */ 8807 @SuppressWarnings("HiddenAbstractMethod") 8808 @Nullable 8809 @UnsupportedAppUsage getUserBadgeForDensity(@onNull UserHandle user, int density)8810 public abstract Drawable getUserBadgeForDensity(@NonNull UserHandle user, int density); 8811 8812 /** 8813 * If the target user is a managed profile of the calling user or the caller 8814 * is itself a managed profile, then this returns a drawable to use as a small 8815 * icon to include in a view to distinguish it from the original icon. This version 8816 * doesn't have background protection and should be used over a light background instead of 8817 * a badge. 8818 * 8819 * @param user The target user. 8820 * @param density The optional desired density for the badge as per 8821 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 8822 * the density of the current display is used. 8823 * @return the drawable or null if no drawable is required. 8824 * @hide 8825 */ 8826 @SuppressWarnings("HiddenAbstractMethod") 8827 @Nullable 8828 @UnsupportedAppUsage getUserBadgeForDensityNoBackground(@onNull UserHandle user, int density)8829 public abstract Drawable getUserBadgeForDensityNoBackground(@NonNull UserHandle user, 8830 int density); 8831 8832 /** 8833 * If the target user is a managed profile of the calling user or the caller 8834 * is itself a managed profile, then this returns a copy of the label with 8835 * badging for accessibility services like talkback. E.g. passing in "Email" 8836 * and it might return "Work Email" for Email in the work profile. 8837 * 8838 * @param label The label to change. 8839 * @param user The target user. 8840 * @return A label that combines the original label and a badge as 8841 * determined by the system. 8842 */ 8843 @NonNull getUserBadgedLabel(@onNull CharSequence label, @NonNull UserHandle user)8844 public abstract CharSequence getUserBadgedLabel(@NonNull CharSequence label, 8845 @NonNull UserHandle user); 8846 8847 /** 8848 * Retrieve text from a package. This is a low-level API used by 8849 * the various package manager info structures (such as 8850 * {@link ComponentInfo} to implement retrieval of their associated 8851 * labels and other text. 8852 * 8853 * @param packageName The name of the package that this text is coming from. 8854 * Cannot be null. 8855 * @param resid The resource identifier of the desired text. Cannot be 0. 8856 * @param appInfo Overall information about <var>packageName</var>. This 8857 * may be null, in which case the application information will be retrieved 8858 * for you if needed; if you already have this information around, it can 8859 * be much more efficient to supply it here. 8860 * 8861 * @return Returns a CharSequence holding the requested text. Returns null 8862 * if the text could not be found for any reason. 8863 */ 8864 @Nullable getText(@onNull String packageName, @StringRes int resid, @Nullable ApplicationInfo appInfo)8865 public abstract CharSequence getText(@NonNull String packageName, @StringRes int resid, 8866 @Nullable ApplicationInfo appInfo); 8867 8868 /** 8869 * Retrieve an XML file from a package. This is a low-level API used to 8870 * retrieve XML meta data. 8871 * 8872 * @param packageName The name of the package that this xml is coming from. 8873 * Cannot be null. 8874 * @param resid The resource identifier of the desired xml. Cannot be 0. 8875 * @param appInfo Overall information about <var>packageName</var>. This 8876 * may be null, in which case the application information will be retrieved 8877 * for you if needed; if you already have this information around, it can 8878 * be much more efficient to supply it here. 8879 * 8880 * @return Returns an XmlPullParser allowing you to parse out the XML 8881 * data. Returns null if the xml resource could not be found for any 8882 * reason. 8883 */ 8884 @Nullable getXml(@onNull String packageName, @XmlRes int resid, @Nullable ApplicationInfo appInfo)8885 public abstract XmlResourceParser getXml(@NonNull String packageName, @XmlRes int resid, 8886 @Nullable ApplicationInfo appInfo); 8887 8888 /** 8889 * Return the label to use for this application. 8890 * 8891 * @return Returns a {@link CharSequence} containing the label associated with 8892 * this application, or its name the item does not have a label. 8893 * @param info The {@link ApplicationInfo} of the application to get the label of. 8894 */ 8895 @NonNull getApplicationLabel(@onNull ApplicationInfo info)8896 public abstract CharSequence getApplicationLabel(@NonNull ApplicationInfo info); 8897 8898 /** 8899 * Retrieve the resources associated with an activity. Given the full 8900 * name of an activity, retrieves the information about it and calls 8901 * getResources() to return its application's resources. If the activity 8902 * cannot be found, NameNotFoundException is thrown. 8903 * 8904 * @param activityName Name of the activity whose resources are to be 8905 * retrieved. 8906 * 8907 * @return Returns the application's Resources. 8908 * @throws NameNotFoundException Thrown if the resources for the given 8909 * application could not be loaded. 8910 * 8911 * @see #getResourcesForApplication(ApplicationInfo) 8912 */ 8913 @NonNull getResourcesForActivity(@onNull ComponentName activityName)8914 public abstract Resources getResourcesForActivity(@NonNull ComponentName activityName) 8915 throws NameNotFoundException; 8916 8917 /** 8918 * Retrieve the resources for an application. Throws NameNotFoundException 8919 * if the package is no longer installed. 8920 * 8921 * @param app Information about the desired application. 8922 * 8923 * @return Returns the application's Resources. 8924 * @throws NameNotFoundException Thrown if the resources for the given 8925 * application could not be loaded (most likely because it was uninstalled). 8926 */ 8927 @NonNull getResourcesForApplication(@onNull ApplicationInfo app)8928 public abstract Resources getResourcesForApplication(@NonNull ApplicationInfo app) 8929 throws NameNotFoundException; 8930 8931 /** 8932 * Retrieve the resources for an application for the provided configuration. 8933 * 8934 * @param app Information about the desired application. 8935 * @param configuration Overridden configuration when loading the Resources 8936 * 8937 * @return Returns the application's Resources. 8938 * @throws NameNotFoundException Thrown if the resources for the given 8939 * application could not be loaded (most likely because it was uninstalled). 8940 */ 8941 @NonNull getResourcesForApplication(@onNull ApplicationInfo app, @Nullable Configuration configuration)8942 public Resources getResourcesForApplication(@NonNull ApplicationInfo app, @Nullable 8943 Configuration configuration) throws NameNotFoundException { 8944 return getResourcesForApplication(app); 8945 } 8946 8947 /** 8948 * Retrieve the resources associated with an application. Given the full 8949 * package name of an application, retrieves the information about it and 8950 * calls getResources() to return its application's resources. If the 8951 * appPackageName cannot be found, NameNotFoundException is thrown. 8952 * 8953 * @param packageName Package name of the application whose resources 8954 * are to be retrieved. 8955 * 8956 * @return Returns the application's Resources. 8957 * @throws NameNotFoundException Thrown if the resources for the given 8958 * application could not be loaded. 8959 * 8960 * @see #getResourcesForApplication(ApplicationInfo) 8961 */ 8962 @NonNull getResourcesForApplication(@onNull String packageName)8963 public abstract Resources getResourcesForApplication(@NonNull String packageName) 8964 throws NameNotFoundException; 8965 8966 /** 8967 * Please don't use this function because it is no longer supported. 8968 * 8969 * @deprecated Instead of using this function, please use 8970 * {@link Context#createContextAsUser(UserHandle, int)} to create the specified user 8971 * context, {@link Context#getPackageManager()} to get PackageManager instance for 8972 * the specified user, and then 8973 * {@link PackageManager#getResourcesForApplication(String)} to get the same 8974 * Resources instance. 8975 * @see {@link Context#createContextAsUser(android.os.UserHandle, int)} 8976 * @see {@link Context#getPackageManager()} 8977 * @see {@link android.content.pm.PackageManager#getResourcesForApplication(java.lang.String)} 8978 * TODO(b/170852794): mark maxTargetSdk as {@code Build.VERSION_CODES.S} 8979 * @hide 8980 */ 8981 @SuppressWarnings("HiddenAbstractMethod") 8982 @NonNull 8983 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170928809, 8984 publicAlternatives = "Use {@code Context#createContextAsUser(UserHandle, int)}" 8985 + " to create the relevant user context," 8986 + " {@link android.content.Context#getPackageManager()} and" 8987 + " {@link android.content.pm.PackageManager#getResourcesForApplication(" 8988 + "java.lang.String)}" 8989 + " instead.") 8990 @Deprecated getResourcesForApplicationAsUser(@onNull String packageName, @UserIdInt int userId)8991 public abstract Resources getResourcesForApplicationAsUser(@NonNull String packageName, 8992 @UserIdInt int userId) throws NameNotFoundException; 8993 8994 /** 8995 * Retrieve overall information about an application package defined in a 8996 * package archive file 8997 * 8998 * Use {@link #getPackageArchiveInfo(String, PackageInfoFlags)} when long flags are needed. 8999 * 9000 * @param archiveFilePath The path to the archive file 9001 * @param flags Additional option flags to modify the data returned. 9002 * @return A PackageInfo object containing information about the package 9003 * archive. If the package could not be parsed, returns null. 9004 */ 9005 @Nullable getPackageArchiveInfo(@onNull String archiveFilePath, int flags)9006 public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath, int flags) { 9007 return getPackageArchiveInfo(archiveFilePath, PackageInfoFlags.of(flags)); 9008 } 9009 9010 /** 9011 * See {@link #getPackageArchiveInfo(String, int)}. 9012 */ 9013 @Nullable getPackageArchiveInfo(@onNull String archiveFilePath, @NonNull PackageInfoFlags flags)9014 public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath, 9015 @NonNull PackageInfoFlags flags) { 9016 final File apkFile = new File(archiveFilePath); 9017 9018 @PackageInfoFlagsBits long flagsBits = flags.getValue(); 9019 if ((flagsBits & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) { 9020 // Caller expressed an explicit opinion about what encryption 9021 // aware/unaware components they want to see, so fall through and 9022 // give them what they want 9023 } else { 9024 // Caller expressed no opinion, so match everything 9025 flagsBits |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; 9026 } 9027 9028 int parserFlags = 0; 9029 if ((flagsBits & (GET_SIGNATURES | GET_SIGNING_CERTIFICATES)) != 0) { 9030 parserFlags |= PARSE_COLLECT_CERTIFICATES; 9031 } 9032 9033 final PackageParser2 parser2 = new PackageParser2(/*separateProcesses*/ null, 9034 /*displayMetrics*/ null,/*cacher*/ null, 9035 new PackageParser2.Callback() { 9036 @Override 9037 public boolean hasFeature(String feature) { 9038 return PackageManager.this.hasSystemFeature(feature); 9039 } 9040 9041 @NonNull 9042 @Override 9043 public Set<String> getHiddenApiWhitelistedApps() { 9044 return Collections.emptySet(); 9045 } 9046 9047 @NonNull 9048 @Override 9049 public Set<String> getInstallConstraintsAllowlist() { 9050 return Collections.emptySet(); 9051 } 9052 9053 @Override 9054 public boolean isChangeEnabled(long changeId, 9055 @androidx.annotation.NonNull ApplicationInfo appInfo) { 9056 return false; 9057 } 9058 }); 9059 9060 try { 9061 ParsedPackage pp = parser2.parsePackage(apkFile, parserFlags, false); 9062 pp.hideAsFinal(); 9063 9064 return PackageInfoCommonUtils.generate(pp, flagsBits, UserHandle.myUserId()); 9065 } catch (PackageParserException e) { 9066 Log.w(TAG, "Failure to parse package archive apkFile= " +apkFile); 9067 return null; 9068 } finally { 9069 parser2.close(); 9070 } 9071 } 9072 9073 /** 9074 * If there is already an application with the given package name installed 9075 * on the system for other users, also install it for the calling user. 9076 * @hide 9077 * 9078 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 9079 */ 9080 @SuppressWarnings("HiddenAbstractMethod") 9081 @Deprecated 9082 @SystemApi installExistingPackage(@onNull String packageName)9083 public abstract int installExistingPackage(@NonNull String packageName) 9084 throws NameNotFoundException; 9085 9086 /** 9087 * If there is already an application with the given package name installed 9088 * on the system for other users, also install it for the calling user. 9089 * @hide 9090 * 9091 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 9092 */ 9093 @SuppressWarnings("HiddenAbstractMethod") 9094 @Deprecated 9095 @SystemApi installExistingPackage(@onNull String packageName, @InstallReason int installReason)9096 public abstract int installExistingPackage(@NonNull String packageName, 9097 @InstallReason int installReason) throws NameNotFoundException; 9098 9099 /** 9100 * If there is already an application with the given package name installed 9101 * on the system for other users, also install it for the specified user. 9102 * @hide 9103 * 9104 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 9105 */ 9106 @SuppressWarnings("HiddenAbstractMethod") 9107 @Deprecated 9108 @RequiresPermission(anyOf = { 9109 Manifest.permission.INSTALL_EXISTING_PACKAGES, 9110 Manifest.permission.INSTALL_PACKAGES, 9111 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 9112 @UnsupportedAppUsage installExistingPackageAsUser(@onNull String packageName, @UserIdInt int userId)9113 public abstract int installExistingPackageAsUser(@NonNull String packageName, 9114 @UserIdInt int userId) throws NameNotFoundException; 9115 9116 /** 9117 * Allows a package listening to the 9118 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 9119 * broadcast} to respond to the package manager. The response must include 9120 * the {@code verificationCode} which is one of 9121 * {@link PackageManager#VERIFICATION_ALLOW} or 9122 * {@link PackageManager#VERIFICATION_REJECT}. 9123 * 9124 * @param id pending package identifier as passed via the 9125 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 9126 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 9127 * or {@link PackageManager#VERIFICATION_REJECT}. 9128 * @throws SecurityException if the caller does not have the 9129 * PACKAGE_VERIFICATION_AGENT permission. 9130 */ verifyPendingInstall(int id, int verificationCode)9131 public abstract void verifyPendingInstall(int id, int verificationCode); 9132 9133 /** 9134 * Allows a package listening to the 9135 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 9136 * broadcast} to extend the default timeout for a response and declare what 9137 * action to perform after the timeout occurs. The response must include 9138 * the {@code verificationCodeAtTimeout} which is one of 9139 * {@link PackageManager#VERIFICATION_ALLOW} or 9140 * {@link PackageManager#VERIFICATION_REJECT}. 9141 * 9142 * This method may only be called once per package id. Additional calls 9143 * will have no effect. 9144 * 9145 * @param id pending package identifier as passed via the 9146 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 9147 * @param verificationCodeAtTimeout either 9148 * {@link PackageManager#VERIFICATION_ALLOW} or 9149 * {@link PackageManager#VERIFICATION_REJECT}. If 9150 * {@code verificationCodeAtTimeout} is neither 9151 * {@link PackageManager#VERIFICATION_ALLOW} or 9152 * {@link PackageManager#VERIFICATION_REJECT}, then 9153 * {@code verificationCodeAtTimeout} will default to 9154 * {@link PackageManager#VERIFICATION_REJECT}. 9155 * @param millisecondsToDelay the amount of time requested for the timeout. 9156 * Must be positive and less than 9157 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 9158 * {@code millisecondsToDelay} is out of bounds, 9159 * {@code millisecondsToDelay} will be set to the closest in 9160 * bounds value; namely, 0 or 9161 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 9162 * @throws SecurityException if the caller does not have the 9163 * PACKAGE_VERIFICATION_AGENT permission. 9164 */ extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay)9165 public abstract void extendVerificationTimeout(int id, 9166 int verificationCodeAtTimeout, long millisecondsToDelay); 9167 9168 /** 9169 * Allows a package listening to the 9170 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification 9171 * broadcast to respond to the package manager. The response must include 9172 * the {@code verificationCode} which is one of 9173 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 9174 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 9175 * 9176 * @param verificationId pending package identifier as passed via the 9177 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 9178 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 9179 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 9180 * @param failedDomains a list of failed domains if the verificationCode is 9181 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 9182 * @throws SecurityException if the caller does not have the 9183 * INTENT_FILTER_VERIFICATION_AGENT permission. 9184 * 9185 * @deprecated Use {@link DomainVerificationManager} APIs. 9186 * @hide 9187 */ 9188 @Deprecated 9189 @SuppressWarnings("HiddenAbstractMethod") 9190 @SystemApi 9191 @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT) verifyIntentFilter(int verificationId, int verificationCode, @NonNull List<String> failedDomains)9192 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 9193 @NonNull List<String> failedDomains); 9194 9195 /** 9196 * Get the status of a Domain Verification Result for an IntentFilter. This is 9197 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 9198 * {@link android.content.IntentFilter#getAutoVerify()} 9199 * 9200 * This is used by the ResolverActivity to change the status depending on what the User select 9201 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 9202 * for a domain. 9203 * 9204 * @param packageName The package name of the Activity associated with the IntentFilter. 9205 * @param userId The user id. 9206 * 9207 * @return The status to set to. This can be 9208 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 9209 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 9210 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 9211 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 9212 * 9213 * @deprecated Use {@link DomainVerificationManager} APIs. 9214 * @hide 9215 */ 9216 @Deprecated 9217 @SuppressWarnings("HiddenAbstractMethod") 9218 @SystemApi 9219 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) getIntentVerificationStatusAsUser(@onNull String packageName, @UserIdInt int userId)9220 public abstract int getIntentVerificationStatusAsUser(@NonNull String packageName, 9221 @UserIdInt int userId); 9222 9223 /** 9224 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 9225 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 9226 * {@link android.content.IntentFilter#getAutoVerify()} 9227 * 9228 * This is used by the ResolverActivity to change the status depending on what the User select 9229 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 9230 * for a domain. 9231 * 9232 * @param packageName The package name of the Activity associated with the IntentFilter. 9233 * @param status The status to set to. This can be 9234 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 9235 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 9236 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 9237 * @param userId The user id. 9238 * 9239 * @return true if the status has been set. False otherwise. 9240 * 9241 * @deprecated This API represents a very dangerous behavior where Settings or a system app with 9242 * the right permissions can force an application to be verified for all of its declared 9243 * domains. This has been removed to prevent unintended usage, and no longer does anything, 9244 * always returning false. If a caller truly wishes to grant <i></i>every</i> declared web 9245 * domain to an application, use 9246 * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, Set, boolean)}, 9247 * passing in all of the domains returned inside 9248 * {@link DomainVerificationManager#getDomainVerificationUserState(String)}. 9249 * 9250 * @hide 9251 */ 9252 @Deprecated 9253 @SuppressWarnings("HiddenAbstractMethod") 9254 @SystemApi 9255 @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS) updateIntentVerificationStatusAsUser(@onNull String packageName, int status, @UserIdInt int userId)9256 public abstract boolean updateIntentVerificationStatusAsUser(@NonNull String packageName, 9257 int status, @UserIdInt int userId); 9258 9259 /** 9260 * Get the list of IntentFilterVerificationInfo for a specific package and User. 9261 * 9262 * @param packageName the package name. When this parameter is set to a non null value, 9263 * the results will be filtered by the package name provided. 9264 * Otherwise, there will be no filtering and it will return a list 9265 * corresponding for all packages 9266 * 9267 * @return a list of IntentFilterVerificationInfo for a specific package. 9268 * 9269 * @deprecated Use {@link DomainVerificationManager} instead. 9270 * @hide 9271 */ 9272 @Deprecated 9273 @SuppressWarnings("HiddenAbstractMethod") 9274 @NonNull 9275 @SystemApi getIntentFilterVerifications( @onNull String packageName)9276 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 9277 @NonNull String packageName); 9278 9279 /** 9280 * Get the list of IntentFilter for a specific package. 9281 * 9282 * @param packageName the package name. This parameter is set to a non null value, 9283 * the list will contain all the IntentFilter for that package. 9284 * Otherwise, the list will be empty. 9285 * 9286 * @return a list of IntentFilter for a specific package. 9287 * 9288 * @hide 9289 */ 9290 @SuppressWarnings("HiddenAbstractMethod") 9291 @NonNull 9292 @SystemApi getAllIntentFilters(@onNull String packageName)9293 public abstract List<IntentFilter> getAllIntentFilters(@NonNull String packageName); 9294 9295 /** 9296 * Get the default Browser package name for a specific user. 9297 * 9298 * @param userId The user id. 9299 * 9300 * @return the package name of the default Browser for the specified user. If the user id passed 9301 * is -1 (all users) it will return a null value. 9302 * 9303 * @hide 9304 */ 9305 @SuppressWarnings("HiddenAbstractMethod") 9306 @Nullable 9307 @SystemApi 9308 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) getDefaultBrowserPackageNameAsUser(@serIdInt int userId)9309 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId); 9310 9311 /** 9312 * Set the default Browser package name for a specific user. 9313 * 9314 * @param packageName The package name of the default Browser. 9315 * @param userId The user id. 9316 * 9317 * @return true if the default Browser for the specified user has been set, 9318 * otherwise return false. If the user id passed is -1 (all users) this call will not 9319 * do anything and just return false. 9320 * 9321 * @hide 9322 */ 9323 @SuppressWarnings("HiddenAbstractMethod") 9324 @SystemApi 9325 @RequiresPermission(allOf = { 9326 Manifest.permission.SET_PREFERRED_APPLICATIONS, 9327 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) setDefaultBrowserPackageNameAsUser(@ullable String packageName, @UserIdInt int userId)9328 public abstract boolean setDefaultBrowserPackageNameAsUser(@Nullable String packageName, 9329 @UserIdInt int userId); 9330 9331 /** 9332 * Change the installer associated with a given package. There are limitations 9333 * on how the installer package can be changed; in particular: 9334 * <ul> 9335 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 9336 * is not signed with the same certificate as the calling application. 9337 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 9338 * has an installer package, and that installer package is not signed with 9339 * the same certificate as the calling application. 9340 * </ul> 9341 * 9342 * @param targetPackage The installed package whose installer will be changed. 9343 * @param installerPackageName The package name of the new installer. May be 9344 * null to clear the association. 9345 */ setInstallerPackageName(@onNull String targetPackage, @Nullable String installerPackageName)9346 public abstract void setInstallerPackageName(@NonNull String targetPackage, 9347 @Nullable String installerPackageName); 9348 9349 /** @hide */ 9350 @SuppressWarnings("HiddenAbstractMethod") 9351 @SystemApi 9352 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES) setUpdateAvailable(@onNull String packageName, boolean updateAvaialble)9353 public abstract void setUpdateAvailable(@NonNull String packageName, boolean updateAvaialble); 9354 9355 /** 9356 * Attempts to delete a package. Since this may take a little while, the 9357 * result will be posted back to the given observer. A deletion will fail if 9358 * the calling context lacks the 9359 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 9360 * named package cannot be found, or if the named package is a system 9361 * package. 9362 * 9363 * @param packageName The name of the package to delete 9364 * @param observer An observer callback to get notified when the package 9365 * deletion is complete. 9366 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 9367 * will be called when that happens. observer may be null to 9368 * indicate that no callback is desired. 9369 * @hide 9370 */ 9371 @SuppressWarnings("HiddenAbstractMethod") 9372 @RequiresPermission(Manifest.permission.DELETE_PACKAGES) 9373 @UnsupportedAppUsage deletePackage(@onNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags)9374 public abstract void deletePackage(@NonNull String packageName, 9375 @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags); 9376 9377 /** 9378 * Attempts to delete a package. Since this may take a little while, the 9379 * result will be posted back to the given observer. A deletion will fail if 9380 * the named package cannot be found, or if the named package is a system 9381 * package. 9382 * 9383 * @param packageName The name of the package to delete 9384 * @param observer An observer callback to get notified when the package 9385 * deletion is complete. 9386 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 9387 * will be called when that happens. observer may be null to 9388 * indicate that no callback is desired. 9389 * @param userId The user Id 9390 * @hide 9391 */ 9392 @SuppressWarnings("HiddenAbstractMethod") 9393 @RequiresPermission(anyOf = { 9394 Manifest.permission.DELETE_PACKAGES, 9395 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 9396 @UnsupportedAppUsage deletePackageAsUser(@onNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId)9397 public abstract void deletePackageAsUser(@NonNull String packageName, 9398 @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags, 9399 @UserIdInt int userId); 9400 9401 /** 9402 * Retrieve the package name of the application that installed a package. This identifies 9403 * which market the package came from. 9404 * 9405 * @param packageName The name of the package to query 9406 * @throws IllegalArgumentException if the given package name is not installed 9407 * 9408 * @deprecated use {@link #getInstallSourceInfo(String)} instead 9409 */ 9410 @SuppressWarnings("HiddenAbstractMethod") 9411 @Deprecated 9412 @Nullable getInstallerPackageName(@onNull String packageName)9413 public abstract String getInstallerPackageName(@NonNull String packageName); 9414 9415 /** 9416 * Retrieves information about how a package was installed or updated. 9417 * <p> 9418 * If the calling application does not hold the INSTALL_PACKAGES permission then 9419 * the result will always return {@code null} from 9420 * {@link InstallSourceInfo#getOriginatingPackageName()}. 9421 * <p> 9422 * If the package that requested the install has been uninstalled, then information about it 9423 * will only be returned from {@link InstallSourceInfo#getInitiatingPackageName()} and 9424 * {@link InstallSourceInfo#getInitiatingPackageSigningInfo()} if the calling package is 9425 * requesting its own install information and is not an instant app. 9426 * 9427 * @param packageName The name of the package to query 9428 * @throws NameNotFoundException if the given package name is not available to the caller. 9429 */ 9430 @NonNull getInstallSourceInfo(@onNull String packageName)9431 public InstallSourceInfo getInstallSourceInfo(@NonNull String packageName) 9432 throws NameNotFoundException { 9433 throw new UnsupportedOperationException("getInstallSourceInfo not implemented"); 9434 } 9435 9436 /** 9437 * Returns true if an app is archivable. 9438 * 9439 * @throws NameNotFoundException if the given package name is not available to the caller. 9440 * @see PackageInstaller#requestArchive 9441 */ 9442 @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING) isAppArchivable(@onNull String packageName)9443 public boolean isAppArchivable(@NonNull String packageName) throws NameNotFoundException { 9444 throw new UnsupportedOperationException("isAppArchivable not implemented"); 9445 } 9446 9447 /** 9448 * Attempts to clear the user data directory of an application. 9449 * Since this may take a little while, the result will 9450 * be posted back to the given observer. A deletion will fail if the 9451 * named package cannot be found, or if the named package is a "system package". 9452 * 9453 * @param packageName The name of the package 9454 * @param observer An observer callback to get notified when the operation is finished 9455 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 9456 * will be called when that happens. observer may be null to indicate that 9457 * no callback is desired. 9458 * 9459 * @hide 9460 */ 9461 @SuppressWarnings("HiddenAbstractMethod") 9462 @UnsupportedAppUsage clearApplicationUserData(@onNull String packageName, @Nullable IPackageDataObserver observer)9463 public abstract void clearApplicationUserData(@NonNull String packageName, 9464 @Nullable IPackageDataObserver observer); 9465 /** 9466 * Attempts to delete the cache files associated with an application. 9467 * Since this may take a little while, the result will 9468 * be posted back to the given observer. A deletion will fail if the calling context 9469 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 9470 * named package cannot be found, or if the named package is a "system package". 9471 * 9472 * @param packageName The name of the package to delete 9473 * @param observer An observer callback to get notified when the cache file deletion 9474 * is complete. 9475 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 9476 * will be called when that happens. observer may be null to indicate that 9477 * no callback is desired. 9478 * 9479 * @hide 9480 */ 9481 @SuppressWarnings("HiddenAbstractMethod") 9482 @UnsupportedAppUsage deleteApplicationCacheFiles(@onNull String packageName, @Nullable IPackageDataObserver observer)9483 public abstract void deleteApplicationCacheFiles(@NonNull String packageName, 9484 @Nullable IPackageDataObserver observer); 9485 9486 /** 9487 * Attempts to delete the cache files associated with an application for a given user. Since 9488 * this may take a little while, the result will be posted back to the given observer. A 9489 * deletion will fail if the calling context lacks the 9490 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package 9491 * cannot be found, or if the named package is a "system package". If {@code userId} does not 9492 * belong to the calling user, the caller must have 9493 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. 9494 * 9495 * @param packageName The name of the package to delete 9496 * @param userId the user for which the cache files needs to be deleted 9497 * @param observer An observer callback to get notified when the cache file deletion is 9498 * complete. 9499 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 9500 * will be called when that happens. observer may be null to indicate that no 9501 * callback is desired. 9502 * @hide 9503 */ 9504 @SuppressWarnings("HiddenAbstractMethod") 9505 @UnsupportedAppUsage deleteApplicationCacheFilesAsUser(@onNull String packageName, @UserIdInt int userId, @Nullable IPackageDataObserver observer)9506 public abstract void deleteApplicationCacheFilesAsUser(@NonNull String packageName, 9507 @UserIdInt int userId, @Nullable IPackageDataObserver observer); 9508 9509 /** 9510 * Free storage by deleting LRU sorted list of cache files across 9511 * all applications. If the currently available free storage 9512 * on the device is greater than or equal to the requested 9513 * free storage, no cache files are cleared. If the currently 9514 * available storage on the device is less than the requested 9515 * free storage, some or all of the cache files across 9516 * all applications are deleted (based on last accessed time) 9517 * to increase the free storage space on the device to 9518 * the requested value. There is no guarantee that clearing all 9519 * the cache files from all applications will clear up 9520 * enough storage to achieve the desired value. 9521 * @param freeStorageSize The number of bytes of storage to be 9522 * freed by the system. Say if freeStorageSize is XX, 9523 * and the current free storage is YY, 9524 * if XX is less than YY, just return. if not free XX-YY number 9525 * of bytes if possible. 9526 * @param observer call back used to notify when 9527 * the operation is completed 9528 * 9529 * @hide 9530 */ 9531 @UnsupportedAppUsage freeStorageAndNotify(long freeStorageSize, @Nullable IPackageDataObserver observer)9532 public void freeStorageAndNotify(long freeStorageSize, 9533 @Nullable IPackageDataObserver observer) { 9534 freeStorageAndNotify(null, freeStorageSize, observer); 9535 } 9536 9537 /** {@hide} */ 9538 @SuppressWarnings("HiddenAbstractMethod") 9539 @UnsupportedAppUsage freeStorageAndNotify(@ullable String volumeUuid, long freeStorageSize, @Nullable IPackageDataObserver observer)9540 public abstract void freeStorageAndNotify(@Nullable String volumeUuid, long freeStorageSize, 9541 @Nullable IPackageDataObserver observer); 9542 9543 /** 9544 * Free storage by deleting LRU sorted list of cache files across 9545 * all applications. If the currently available free storage 9546 * on the device is greater than or equal to the requested 9547 * free storage, no cache files are cleared. If the currently 9548 * available storage on the device is less than the requested 9549 * free storage, some or all of the cache files across 9550 * all applications are deleted (based on last accessed time) 9551 * to increase the free storage space on the device to 9552 * the requested value. There is no guarantee that clearing all 9553 * the cache files from all applications will clear up 9554 * enough storage to achieve the desired value. 9555 * @param freeStorageSize The number of bytes of storage to be 9556 * freed by the system. Say if freeStorageSize is XX, 9557 * and the current free storage is YY, 9558 * if XX is less than YY, just return. if not free XX-YY number 9559 * of bytes if possible. 9560 * @param pi IntentSender call back used to 9561 * notify when the operation is completed.May be null 9562 * to indicate that no call back is desired. 9563 * 9564 * @hide 9565 */ 9566 @UnsupportedAppUsage freeStorage(long freeStorageSize, @Nullable IntentSender pi)9567 public void freeStorage(long freeStorageSize, @Nullable IntentSender pi) { 9568 freeStorage(null, freeStorageSize, pi); 9569 } 9570 9571 /** {@hide} */ 9572 @SuppressWarnings("HiddenAbstractMethod") 9573 @UnsupportedAppUsage freeStorage(@ullable String volumeUuid, long freeStorageSize, @Nullable IntentSender pi)9574 public abstract void freeStorage(@Nullable String volumeUuid, long freeStorageSize, 9575 @Nullable IntentSender pi); 9576 9577 /** 9578 * Retrieve the size information for a package. 9579 * Since this may take a little while, the result will 9580 * be posted back to the given observer. The calling context 9581 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 9582 * 9583 * @param packageName The name of the package whose size information is to be retrieved 9584 * @param userId The user whose size information should be retrieved. 9585 * @param observer An observer callback to get notified when the operation 9586 * is complete. 9587 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 9588 * The observer's callback is invoked with a PackageStats object(containing the 9589 * code, data and cache sizes of the package) and a boolean value representing 9590 * the status of the operation. observer may be null to indicate that 9591 * no callback is desired. 9592 * 9593 * @deprecated use {@link StorageStatsManager} instead. 9594 * @hide 9595 */ 9596 @SuppressWarnings("HiddenAbstractMethod") 9597 @Deprecated 9598 @UnsupportedAppUsage getPackageSizeInfoAsUser(@onNull String packageName, @UserIdInt int userId, @Nullable IPackageStatsObserver observer)9599 public abstract void getPackageSizeInfoAsUser(@NonNull String packageName, 9600 @UserIdInt int userId, @Nullable IPackageStatsObserver observer); 9601 9602 /** 9603 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 9604 * returns the size for the calling user. 9605 * 9606 * @deprecated use {@link StorageStatsManager} instead. 9607 * @hide 9608 */ 9609 @Deprecated 9610 @UnsupportedAppUsage getPackageSizeInfo(@onNull String packageName, IPackageStatsObserver observer)9611 public void getPackageSizeInfo(@NonNull String packageName, IPackageStatsObserver observer) { 9612 getPackageSizeInfoAsUser(packageName, getUserId(), observer); 9613 } 9614 9615 /** 9616 * @deprecated This function no longer does anything. It is the platform's 9617 * responsibility to assign preferred activities and this cannot be modified 9618 * directly. To determine the activities resolved by the platform, use 9619 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9620 * an app to be responsible for a particular role and to check current role 9621 * holders, see {@link android.app.role.RoleManager}. 9622 */ 9623 @Deprecated addPackageToPreferred(@onNull String packageName)9624 public abstract void addPackageToPreferred(@NonNull String packageName); 9625 9626 /** 9627 * @deprecated This function no longer does anything. It is the platform's 9628 * responsibility to assign preferred activities and this cannot be modified 9629 * directly. To determine the activities resolved by the platform, use 9630 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9631 * an app to be responsible for a particular role and to check current role 9632 * holders, see {@link android.app.role.RoleManager}. 9633 */ 9634 @Deprecated removePackageFromPreferred(@onNull String packageName)9635 public abstract void removePackageFromPreferred(@NonNull String packageName); 9636 9637 /** 9638 * Retrieve the list of all currently configured preferred packages. The 9639 * first package on the list is the most preferred, the last is the least 9640 * preferred. 9641 * 9642 * @param flags Additional option flags to modify the data returned. 9643 * @return A List of PackageInfo objects, one for each preferred 9644 * application, in order of preference. 9645 * 9646 * @deprecated This function no longer does anything. It is the platform's 9647 * responsibility to assign preferred activities and this cannot be modified 9648 * directly. To determine the activities resolved by the platform, use 9649 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9650 * an app to be responsible for a particular role and to check current role 9651 * holders, see {@link android.app.role.RoleManager}. 9652 */ 9653 @NonNull 9654 @Deprecated getPreferredPackages(int flags)9655 public abstract List<PackageInfo> getPreferredPackages(int flags); 9656 9657 /** 9658 * Add a new preferred activity mapping to the system. This will be used 9659 * to automatically select the given activity component when 9660 * {@link Context#startActivity(Intent) Context.startActivity()} finds 9661 * multiple matching activities and also matches the given filter. 9662 * 9663 * @param filter The set of intents under which this activity will be 9664 * made preferred. 9665 * @param match The IntentFilter match category that this preference 9666 * applies to. 9667 * @param set The set of activities that the user was picking from when 9668 * this preference was made. 9669 * @param activity The component name of the activity that is to be 9670 * preferred. 9671 * 9672 * @deprecated This function no longer does anything. It is the platform's 9673 * responsibility to assign preferred activities and this cannot be modified 9674 * directly. To determine the activities resolved by the platform, use 9675 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9676 * an app to be responsible for a particular role and to check current role 9677 * holders, see {@link android.app.role.RoleManager}. 9678 */ 9679 @Deprecated addPreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9680 public abstract void addPreferredActivity(@NonNull IntentFilter filter, int match, 9681 @Nullable ComponentName[] set, @NonNull ComponentName activity); 9682 9683 /** 9684 * Same as {@link #addPreferredActivity(IntentFilter, int, 9685 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 9686 to. 9687 * @hide 9688 * 9689 * @deprecated This function no longer does anything. It is the platform's 9690 * responsibility to assign preferred activities and this cannot be modified 9691 * directly. To determine the activities resolved by the platform, use 9692 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9693 * an app to be responsible for a particular role and to check current role 9694 * holders, see {@link android.app.role.RoleManager}. 9695 */ 9696 @Deprecated 9697 @UnsupportedAppUsage addPreferredActivityAsUser(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId)9698 public void addPreferredActivityAsUser(@NonNull IntentFilter filter, int match, 9699 @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) { 9700 throw new RuntimeException("Not implemented. Must override in a subclass."); 9701 } 9702 9703 /** 9704 * Replaces an existing preferred activity mapping to the system, and if that were not present 9705 * adds a new preferred activity. This will be used 9706 * to automatically select the given activity component when 9707 * {@link Context#startActivity(Intent) Context.startActivity()} finds 9708 * multiple matching activities and also matches the given filter. 9709 * 9710 * @param filter The set of intents under which this activity will be 9711 * made preferred. 9712 * @param match The IntentFilter match category that this preference 9713 * applies to. 9714 * @param set The set of activities that the user was picking from when 9715 * this preference was made. 9716 * @param activity The component name of the activity that is to be 9717 * preferred. 9718 * 9719 * @hide 9720 * 9721 * @deprecated This function no longer does anything. It is the platform's 9722 * responsibility to assign preferred activities and this cannot be modified 9723 * directly. To determine the activities resolved by the platform, use 9724 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9725 * an app to be responsible for a particular role and to check current role 9726 * holders, see {@link android.app.role.RoleManager}. 9727 */ 9728 @SuppressWarnings("HiddenAbstractMethod") 9729 @Deprecated 9730 @UnsupportedAppUsage replacePreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9731 public abstract void replacePreferredActivity(@NonNull IntentFilter filter, int match, 9732 @Nullable ComponentName[] set, @NonNull ComponentName activity); 9733 9734 /** 9735 * Replaces an existing preferred activity mapping to the system, and if that were not present 9736 * adds a new preferred activity. This will be used to automatically select the given activity 9737 * component when {@link Context#startActivity(Intent) Context.startActivity()} finds multiple 9738 * matching activities and also matches the given filter. 9739 * 9740 * @param filter The set of intents under which this activity will be made preferred. 9741 * @param match The IntentFilter match category that this preference applies to. Should be a 9742 * combination of {@link IntentFilter#MATCH_CATEGORY_MASK} and 9743 * {@link IntentFilter#MATCH_ADJUSTMENT_MASK}). 9744 * @param set The set of activities that the user was picking from when this preference was 9745 * made. 9746 * @param activity The component name of the activity that is to be preferred. 9747 * 9748 * @hide 9749 */ 9750 @SystemApi replacePreferredActivity(@onNull IntentFilter filter, int match, @NonNull List<ComponentName> set, @NonNull ComponentName activity)9751 public void replacePreferredActivity(@NonNull IntentFilter filter, int match, 9752 @NonNull List<ComponentName> set, @NonNull ComponentName activity) { 9753 replacePreferredActivity(filter, match, set.toArray(new ComponentName[0]), activity); 9754 } 9755 9756 /** 9757 * @hide 9758 * 9759 * @deprecated This function no longer does anything. It is the platform's 9760 * responsibility to assign preferred activities and this cannot be modified 9761 * directly. To determine the activities resolved by the platform, use 9762 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9763 * an app to be responsible for a particular role and to check current role 9764 * holders, see {@link android.app.role.RoleManager}. 9765 */ 9766 @Deprecated 9767 @UnsupportedAppUsage replacePreferredActivityAsUser(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId)9768 public void replacePreferredActivityAsUser(@NonNull IntentFilter filter, int match, 9769 @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) { 9770 throw new RuntimeException("Not implemented. Must override in a subclass."); 9771 } 9772 9773 /** 9774 * Remove all preferred activity mappings, previously added with 9775 * {@link #addPreferredActivity}, from the 9776 * system whose activities are implemented in the given package name. 9777 * An application can only clear its own package(s). 9778 * 9779 * @param packageName The name of the package whose preferred activity 9780 * mappings are to be removed. 9781 * 9782 * @deprecated This function no longer does anything. It is the platform's 9783 * responsibility to assign preferred activities and this cannot be modified 9784 * directly. To determine the activities resolved by the platform, use 9785 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9786 * an app to be responsible for a particular role and to check current role 9787 * holders, see {@link android.app.role.RoleManager}. 9788 */ 9789 @Deprecated clearPackagePreferredActivities(@onNull String packageName)9790 public abstract void clearPackagePreferredActivities(@NonNull String packageName); 9791 9792 /** 9793 * Same as {@link #addPreferredActivity(IntentFilter, int, ComponentName[], ComponentName)}, 9794 * but removes all existing entries that match this filter. 9795 * @hide 9796 */ addUniquePreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9797 public void addUniquePreferredActivity(@NonNull IntentFilter filter, int match, 9798 @Nullable ComponentName[] set, @NonNull ComponentName activity) { 9799 throw new UnsupportedOperationException( 9800 "addUniquePreferredActivity not implemented in subclass"); 9801 } 9802 9803 /** 9804 * Retrieve all preferred activities, previously added with 9805 * {@link #addPreferredActivity}, that are 9806 * currently registered with the system. 9807 * 9808 * @param outFilters A required list in which to place the filters of all of the 9809 * preferred activities. 9810 * @param outActivities A required list in which to place the component names of 9811 * all of the preferred activities. 9812 * @param packageName An optional package in which you would like to limit 9813 * the list. If null, all activities will be returned; if non-null, only 9814 * those activities in the given package are returned. 9815 * 9816 * @return Returns the total number of registered preferred activities 9817 * (the number of distinct IntentFilter records, not the number of unique 9818 * activity components) that were found. 9819 * 9820 * @deprecated This function no longer does anything. It is the platform's 9821 * responsibility to assign preferred activities and this cannot be modified 9822 * directly. To determine the activities resolved by the platform, use 9823 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 9824 * an app to be responsible for a particular role and to check current role 9825 * holders, see {@link android.app.role.RoleManager}. 9826 */ 9827 @Deprecated getPreferredActivities(@onNull List<IntentFilter> outFilters, @NonNull List<ComponentName> outActivities, @Nullable String packageName)9828 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 9829 @NonNull List<ComponentName> outActivities, @Nullable String packageName); 9830 9831 /** 9832 * Ask for the set of available 'home' activities and the current explicit 9833 * default, if any. 9834 * @hide 9835 */ 9836 @SuppressWarnings("HiddenAbstractMethod") 9837 @Nullable 9838 @UnsupportedAppUsage getHomeActivities(@onNull List<ResolveInfo> outActivities)9839 public abstract ComponentName getHomeActivities(@NonNull List<ResolveInfo> outActivities); 9840 9841 /** 9842 * Set the enabled setting for a package component (activity, receiver, service, provider). 9843 * This setting will override any enabled state which may have been set by the component in its 9844 * manifest. 9845 * 9846 * <p>Consider using {@link #setComponentEnabledSettings(List)} if multiple components need to 9847 * be updated atomically. 9848 * 9849 * @param componentName The component to enable 9850 * @param newState The new enabled state for the component. 9851 * @param flags Optional behavior flags. 9852 */ 9853 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 9854 conditional = true) setComponentEnabledSetting(@onNull ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags)9855 public abstract void setComponentEnabledSetting(@NonNull ComponentName componentName, 9856 @EnabledState int newState, @EnabledFlags int flags); 9857 9858 /** 9859 * Set the enabled settings for package components such as activities, receivers, services and 9860 * providers. This setting will override any enabled state which may have been set by the 9861 * component in its manifest. 9862 * 9863 * <p>This api accepts a list of component changes, and applies them all atomically. The 9864 * application can use this api if components have dependencies and need to be updated 9865 * atomically. 9866 * 9867 * <p>The permission is not required if target components are running under the same uid with 9868 * the caller. 9869 * 9870 * @param settings The list of component enabled settings to update. Note that an 9871 * {@link IllegalArgumentException} is thrown if the duplicated component name 9872 * is in the list or there's a conflict {@link #DONT_KILL_APP} flag between 9873 * different components in the same package. 9874 * 9875 * @see #setComponentEnabledSetting(ComponentName, int, int) 9876 */ 9877 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 9878 conditional = true) setComponentEnabledSettings(@onNull List<ComponentEnabledSetting> settings)9879 public void setComponentEnabledSettings(@NonNull List<ComponentEnabledSetting> settings) { 9880 throw new UnsupportedOperationException("setComponentEnabledSettings not implemented" 9881 + "in subclass"); 9882 } 9883 9884 /** 9885 * Return the enabled setting for a package component (activity, 9886 * receiver, service, provider). This returns the last value set by 9887 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 9888 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 9889 * the value originally specified in the manifest has not been modified. 9890 * 9891 * @param componentName The component to retrieve. 9892 * @return Returns the current enabled state for the component. 9893 */ getComponentEnabledSetting( @onNull ComponentName componentName)9894 public abstract @EnabledState int getComponentEnabledSetting( 9895 @NonNull ComponentName componentName); 9896 9897 /** 9898 * Set whether a synthetic app details activity will be generated if the app has no enabled 9899 * launcher activity. Disabling this allows the app to have no launcher icon. 9900 * 9901 * @param packageName The package name of the app 9902 * @param enabled The new enabled state for the synthetic app details activity. 9903 * 9904 * @hide 9905 */ 9906 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 9907 conditional = true) 9908 @SystemApi setSyntheticAppDetailsActivityEnabled(@onNull String packageName, boolean enabled)9909 public void setSyntheticAppDetailsActivityEnabled(@NonNull String packageName, 9910 boolean enabled) { 9911 throw new UnsupportedOperationException( 9912 "setSyntheticAppDetailsActivityEnabled not implemented"); 9913 } 9914 9915 9916 /** 9917 * Return whether a synthetic app details activity will be generated if the app has no enabled 9918 * launcher activity. 9919 * 9920 * @param packageName The package name of the app 9921 * @return Returns the enabled state for the synthetic app details activity. 9922 * 9923 * 9924 */ getSyntheticAppDetailsActivityEnabled(@onNull String packageName)9925 public boolean getSyntheticAppDetailsActivityEnabled(@NonNull String packageName) { 9926 throw new UnsupportedOperationException( 9927 "getSyntheticAppDetailsActivityEnabled not implemented"); 9928 } 9929 9930 /** 9931 * Set the enabled setting for an application 9932 * This setting will override any enabled state which may have been set by the application in 9933 * its manifest. It also overrides the enabled state set in the manifest for any of the 9934 * application's components. It does not override any enabled state set by 9935 * {@link #setComponentEnabledSetting} for any of the application's components. 9936 * 9937 * @param packageName The package name of the application to enable 9938 * @param newState The new enabled state for the application. 9939 * @param flags Optional behavior flags. 9940 */ 9941 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 9942 conditional = true) setApplicationEnabledSetting(@onNull String packageName, @EnabledState int newState, @EnabledFlags int flags)9943 public abstract void setApplicationEnabledSetting(@NonNull String packageName, 9944 @EnabledState int newState, @EnabledFlags int flags); 9945 9946 /** 9947 * Return the enabled setting for an application. This returns 9948 * the last value set by 9949 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 9950 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 9951 * the value originally specified in the manifest has not been modified. 9952 * 9953 * @param packageName The package name of the application to retrieve. 9954 * @return Returns the current enabled state for the application. 9955 * @throws IllegalArgumentException if the named package does not exist. 9956 */ getApplicationEnabledSetting(@onNull String packageName)9957 public abstract @EnabledState int getApplicationEnabledSetting(@NonNull String packageName); 9958 9959 /** 9960 * Flush the package restrictions for a given user to disk. This forces the package restrictions 9961 * like component and package enabled settings to be written to disk and avoids the delay that 9962 * is otherwise present when changing those settings. 9963 * 9964 * @param userId Ther userId of the user whose restrictions are to be flushed. 9965 * @hide 9966 */ 9967 @SuppressWarnings("HiddenAbstractMethod") 9968 @UnsupportedAppUsage flushPackageRestrictionsAsUser(@serIdInt int userId)9969 public abstract void flushPackageRestrictionsAsUser(@UserIdInt int userId); 9970 9971 /** 9972 * Puts the package in a hidden state, which is almost like an uninstalled state, 9973 * making the package unavailable, but it doesn't remove the data or the actual 9974 * package file. Application can be unhidden by either resetting the hidden state 9975 * or by installing it, such as with {@link #installExistingPackage(String)} 9976 * @hide 9977 */ 9978 @SuppressWarnings("HiddenAbstractMethod") 9979 @UnsupportedAppUsage setApplicationHiddenSettingAsUser(@onNull String packageName, boolean hidden, @NonNull UserHandle userHandle)9980 public abstract boolean setApplicationHiddenSettingAsUser(@NonNull String packageName, 9981 boolean hidden, @NonNull UserHandle userHandle); 9982 9983 /** 9984 * Returns the hidden state of a package. 9985 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 9986 * @hide 9987 */ 9988 @SuppressWarnings("HiddenAbstractMethod") 9989 @UnsupportedAppUsage getApplicationHiddenSettingAsUser(@onNull String packageName, @NonNull UserHandle userHandle)9990 public abstract boolean getApplicationHiddenSettingAsUser(@NonNull String packageName, 9991 @NonNull UserHandle userHandle); 9992 9993 /** 9994 * Sets the state of a system app. 9995 * 9996 * This method can be used to change a system app's hidden-until-installed state (via 9997 * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN} and 9998 * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE} or its installation state (via 9999 * {@link #SYSTEM_APP_STATE_INSTALLED} and {@link #SYSTEM_APP_STATE_UNINSTALLED}. 10000 * 10001 * This API may only be called from {@link android.os.Process#SYSTEM_UID} or 10002 * {@link android.os.Process#PHONE_UID}. 10003 * 10004 * @param packageName Package name of the app. 10005 * @param state State of the app. 10006 * @hide 10007 */ 10008 @SystemApi setSystemAppState(@onNull String packageName, @SystemAppState int state)10009 public void setSystemAppState(@NonNull String packageName, @SystemAppState int state) { 10010 throw new RuntimeException("Not implemented. Must override in a subclass"); 10011 } 10012 10013 /** 10014 * Return whether the device has been booted into safe mode. 10015 */ isSafeMode()10016 public abstract boolean isSafeMode(); 10017 10018 /** 10019 * Adds a listener for permission changes for installed packages. 10020 * 10021 * @param listener The listener to add. 10022 * 10023 * @hide 10024 */ 10025 //@Deprecated 10026 @SuppressWarnings("HiddenAbstractMethod") 10027 @SystemApi 10028 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) addOnPermissionsChangeListener( @onNull OnPermissionsChangedListener listener)10029 public abstract void addOnPermissionsChangeListener( 10030 @NonNull OnPermissionsChangedListener listener); 10031 10032 /** 10033 * Remvoes a listener for permission changes for installed packages. 10034 * 10035 * @param listener The listener to remove. 10036 * 10037 * @hide 10038 */ 10039 //@Deprecated 10040 @SuppressWarnings("HiddenAbstractMethod") 10041 @SystemApi 10042 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) removeOnPermissionsChangeListener( @onNull OnPermissionsChangedListener listener)10043 public abstract void removeOnPermissionsChangeListener( 10044 @NonNull OnPermissionsChangedListener listener); 10045 10046 /** 10047 * Return the {@link KeySet} associated with the String alias for this 10048 * application. 10049 * 10050 * @param alias The alias for a given {@link KeySet} as defined in the 10051 * application's AndroidManifest.xml. 10052 * @hide 10053 */ 10054 @SuppressWarnings("HiddenAbstractMethod") 10055 @NonNull 10056 @UnsupportedAppUsage getKeySetByAlias(@onNull String packageName, @NonNull String alias)10057 public abstract KeySet getKeySetByAlias(@NonNull String packageName, @NonNull String alias); 10058 10059 /** Return the signing {@link KeySet} for this application. 10060 * @hide 10061 */ 10062 @SuppressWarnings("HiddenAbstractMethod") 10063 @NonNull 10064 @UnsupportedAppUsage getSigningKeySet(@onNull String packageName)10065 public abstract KeySet getSigningKeySet(@NonNull String packageName); 10066 10067 /** 10068 * Return whether the package denoted by packageName has been signed by all 10069 * of the keys specified by the {@link KeySet} ks. This will return true if 10070 * the package has been signed by additional keys (a superset) as well. 10071 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 10072 * @hide 10073 */ 10074 @SuppressWarnings("HiddenAbstractMethod") 10075 @UnsupportedAppUsage isSignedBy(@onNull String packageName, @NonNull KeySet ks)10076 public abstract boolean isSignedBy(@NonNull String packageName, @NonNull KeySet ks); 10077 10078 /** 10079 * Return whether the package denoted by packageName has been signed by all 10080 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 10081 * {@link #isSignedBy(String packageName, KeySet ks)}. 10082 * @hide 10083 */ 10084 @SuppressWarnings("HiddenAbstractMethod") 10085 @UnsupportedAppUsage isSignedByExactly(@onNull String packageName, @NonNull KeySet ks)10086 public abstract boolean isSignedByExactly(@NonNull String packageName, @NonNull KeySet ks); 10087 10088 /** 10089 * Flag to denote no restrictions. This should be used to clear any restrictions that may have 10090 * been previously set for the package. 10091 * @hide 10092 * @see #setDistractingPackageRestrictions(String[], int) 10093 */ 10094 @SystemApi 10095 public static final int RESTRICTION_NONE = 0x0; 10096 10097 /** 10098 * Flag to denote that a package should be hidden from any suggestions to the user. 10099 * @hide 10100 * @see #setDistractingPackageRestrictions(String[], int) 10101 */ 10102 @SystemApi 10103 public static final int RESTRICTION_HIDE_FROM_SUGGESTIONS = 0x00000001; 10104 10105 /** 10106 * Flag to denote that a package's notifications should be hidden. 10107 * @hide 10108 * @see #setDistractingPackageRestrictions(String[], int) 10109 */ 10110 @SystemApi 10111 public static final int RESTRICTION_HIDE_NOTIFICATIONS = 0x00000002; 10112 10113 /** 10114 * Restriction flags to set on a package that is considered as distracting to the user. 10115 * These should help the user to restrict their usage of these apps. 10116 * 10117 * @see #setDistractingPackageRestrictions(String[], int) 10118 * @hide 10119 */ 10120 @IntDef(flag = true, prefix = {"RESTRICTION_"}, value = { 10121 RESTRICTION_NONE, 10122 RESTRICTION_HIDE_FROM_SUGGESTIONS, 10123 RESTRICTION_HIDE_NOTIFICATIONS 10124 }) 10125 @Retention(RetentionPolicy.SOURCE) 10126 public @interface DistractionRestriction {} 10127 10128 /** 10129 * Mark or unmark the given packages as distracting to the user. 10130 * These packages can have certain restrictions set that should discourage the user to launch 10131 * them often. For example, notifications from such an app can be hidden, or the app can be 10132 * removed from launcher suggestions, so the user is able to restrict their use of these apps. 10133 * 10134 * <p>The caller must hold {@link android.Manifest.permission#SUSPEND_APPS} to use this API. 10135 * 10136 * @param packages Packages to mark as distracting. 10137 * @param restrictionFlags Any combination of restrictions to impose on the given packages. 10138 * {@link #RESTRICTION_NONE} can be used to clear any existing 10139 * restrictions. 10140 * @return A list of packages that could not have the {@code restrictionFlags} set. The system 10141 * may prevent restricting critical packages to preserve normal device function. 10142 * 10143 * @hide 10144 * @see #RESTRICTION_NONE 10145 * @see #RESTRICTION_HIDE_FROM_SUGGESTIONS 10146 * @see #RESTRICTION_HIDE_NOTIFICATIONS 10147 */ 10148 @SystemApi 10149 @RequiresPermission(android.Manifest.permission.SUSPEND_APPS) 10150 @NonNull setDistractingPackageRestrictions(@onNull String[] packages, @DistractionRestriction int restrictionFlags)10151 public String[] setDistractingPackageRestrictions(@NonNull String[] packages, 10152 @DistractionRestriction int restrictionFlags) { 10153 throw new UnsupportedOperationException( 10154 "setDistractingPackageRestrictions not implemented"); 10155 } 10156 10157 /** 10158 * Puts the package in a suspended state, where attempts at starting activities are denied. 10159 * 10160 * <p>It doesn't remove the data or the actual package file. The application's notifications 10161 * will be hidden, any of its started activities will be stopped and it will not be able to 10162 * show toasts or system alert windows or ring the device. 10163 * 10164 * <p>When the user tries to launch a suspended app, a system dialog with the given 10165 * {@code dialogMessage} will be shown instead. Since the message is supplied to the system as 10166 * a {@link String}, the caller needs to take care of localization as needed. 10167 * The dialog message can optionally contain a placeholder for the name of the suspended app. 10168 * The system uses {@link String#format(Locale, String, Object...) String.format} to insert the 10169 * app name into the message, so an example format string could be {@code "The app %1$s is 10170 * currently suspended"}. This makes it easier for callers to provide a single message which 10171 * works for all the packages being suspended in a single call. 10172 * 10173 * <p>The package must already be installed. If the package is uninstalled while suspended 10174 * the package will no longer be suspended. </p> 10175 * 10176 * <p>Optionally, the suspending app can provide extra information in the form of 10177 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 10178 * launcher to support customization that they might need to handle the suspended state. 10179 * 10180 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API. 10181 * 10182 * @param packageNames The names of the packages to set the suspended status. 10183 * @param suspended If set to {@code true}, the packages will be suspended, if set to 10184 * {@code false}, the packages will be unsuspended. 10185 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 10186 * which will be shared with the apps being suspended. Ignored if 10187 * {@code suspended} is false. 10188 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 10189 * provide which will be shared with the launcher. Ignored if 10190 * {@code suspended} is false. 10191 * @param dialogMessage The message to be displayed to the user, when they try to launch a 10192 * suspended app. 10193 * 10194 * @return an array of package names for which the suspended status could not be set as 10195 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}. 10196 * 10197 * @deprecated use {@link #setPackagesSuspended(String[], boolean, PersistableBundle, 10198 * PersistableBundle, android.content.pm.SuspendDialogInfo)} instead. 10199 * 10200 * @hide 10201 */ 10202 @SystemApi 10203 @Deprecated 10204 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 10205 @Nullable setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable String dialogMessage)10206 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended, 10207 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 10208 @Nullable String dialogMessage) { 10209 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 10210 } 10211 10212 /** 10213 * Puts the given packages in a suspended state, where attempts at starting activities are 10214 * denied. 10215 * 10216 * <p>The suspended application's notifications and all of its windows will be hidden, any 10217 * of its started activities will be stopped and it won't be able to ring the device. 10218 * It doesn't remove the data or the actual package file. 10219 * 10220 * <p>When the user tries to launch a suspended app, a system dialog alerting them that the app 10221 * is suspended will be shown instead. 10222 * The caller can optionally customize the dialog by passing a {@link SuspendDialogInfo} object 10223 * to this API. This dialog will have a button that starts the 10224 * {@link Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS} intent if the suspending app declares an 10225 * activity which handles this action. 10226 * 10227 * <p>The packages being suspended must already be installed. If a package is uninstalled, it 10228 * will no longer be suspended. 10229 * 10230 * <p>Optionally, the suspending app can provide extra information in the form of 10231 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 10232 * launcher to support customization that they might need to handle the suspended state. 10233 * 10234 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API except for 10235 * device owner and profile owner. 10236 * 10237 * @param packageNames The names of the packages to set the suspended status. 10238 * @param suspended If set to {@code true}, the packages will be suspended, if set to 10239 * {@code false}, the packages will be unsuspended. 10240 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 10241 * which will be shared with the apps being suspended. Ignored if 10242 * {@code suspended} is false. 10243 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 10244 * provide which will be shared with the launcher. Ignored if 10245 * {@code suspended} is false. 10246 * @param dialogInfo An optional {@link SuspendDialogInfo} object describing the dialog that 10247 * should be shown to the user when they try to launch a suspended app. 10248 * Ignored if {@code suspended} is false. 10249 * 10250 * @return an array of package names for which the suspended status could not be set as 10251 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}. 10252 * 10253 * @see #isPackageSuspended 10254 * @see SuspendDialogInfo 10255 * @see SuspendDialogInfo.Builder 10256 * @see Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS 10257 * 10258 * @hide 10259 */ 10260 @SystemApi 10261 @RequiresPermission(value=Manifest.permission.SUSPEND_APPS, conditional=true) 10262 @Nullable setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable SuspendDialogInfo dialogInfo)10263 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended, 10264 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 10265 @Nullable SuspendDialogInfo dialogInfo) { 10266 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 10267 } 10268 10269 /** 10270 * Puts the given packages in a suspended state, where attempts at starting activities are 10271 * denied. 10272 * 10273 * <p>The suspended application's notifications and all of its windows will be hidden, any 10274 * of its started activities will be stopped and it won't be able to ring the device. 10275 * It doesn't remove the data or the actual package file. 10276 * 10277 * <p>When the user tries to launch a suspended app, a system dialog alerting them that the app 10278 * is suspended will be shown instead. 10279 * The caller can optionally customize the dialog by passing a {@link SuspendDialogInfo} object 10280 * to this API. This dialog will have a button that starts the 10281 * {@link Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS} intent if the suspending app declares an 10282 * activity which handles this action. 10283 * 10284 * <p>The packages being suspended must already be installed. If a package is uninstalled, it 10285 * will no longer be suspended. 10286 * 10287 * <p>Optionally, the suspending app can provide extra information in the form of 10288 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 10289 * launcher to support customization that they might need to handle the suspended state. 10290 * 10291 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API except for 10292 * device owner and profile owner or the {@link Manifest.permission#QUARANTINE_APPS} if the 10293 * caller is using {@link #FLAG_SUSPEND_QUARANTINED}. 10294 * 10295 * @param packageNames The names of the packages to set the suspended status. 10296 * @param suspended If set to {@code true}, the packages will be suspended, if set to 10297 * {@code false}, the packages will be unsuspended. 10298 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 10299 * which will be shared with the apps being suspended. Ignored if 10300 * {@code suspended} is false. 10301 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 10302 * provide which will be shared with the launcher. Ignored if 10303 * {@code suspended} is false. 10304 * @param dialogInfo An optional {@link SuspendDialogInfo} object describing the dialog that 10305 * should be shown to the user when they try to launch a suspended app. 10306 * Ignored if {@code suspended} is false. 10307 * @param flags Optional behavior flags. 10308 * 10309 * @return an array of package names for which the suspended status could not be set as 10310 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}. 10311 * 10312 * @see #isPackageSuspended 10313 * @see SuspendDialogInfo 10314 * @see SuspendDialogInfo.Builder 10315 * @see Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS 10316 * 10317 * @hide 10318 */ 10319 @SystemApi 10320 @FlaggedApi(android.content.pm.Flags.FLAG_QUARANTINED_ENABLED) 10321 @RequiresPermission(anyOf = { 10322 Manifest.permission.SUSPEND_APPS, 10323 Manifest.permission.QUARANTINE_APPS 10324 }, conditional = true) 10325 @SuppressLint("NullableCollection") 10326 @Nullable setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable SuspendDialogInfo dialogInfo, @SuspendedFlags int flags)10327 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended, 10328 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 10329 @Nullable SuspendDialogInfo dialogInfo, @SuspendedFlags int flags) { 10330 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 10331 } 10332 10333 /** 10334 * Returns any packages in a given set of packages that cannot be suspended via a call to {@link 10335 * #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, 10336 * SuspendDialogInfo) setPackagesSuspended}. The platform prevents suspending certain critical 10337 * packages to keep the device in a functioning state, e.g. the default dialer and launcher. 10338 * Apps need to hold {@link Manifest.permission#SUSPEND_APPS SUSPEND_APPS} to call this API. 10339 * 10340 * <p> 10341 * Note that this set of critical packages can change with time, so even though a package name 10342 * was not returned by this call, it does not guarantee that a subsequent call to 10343 * {@link #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, 10344 * SuspendDialogInfo) setPackagesSuspended} for that package will succeed, especially if 10345 * significant time elapsed between the two calls. 10346 * 10347 * @param packageNames The packages to check. 10348 * @return A list of packages that can not be currently suspended by the system. 10349 * @hide 10350 */ 10351 @SystemApi 10352 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 10353 @NonNull getUnsuspendablePackages(@onNull String[] packageNames)10354 public String[] getUnsuspendablePackages(@NonNull String[] packageNames) { 10355 throw new UnsupportedOperationException("getUnsuspendablePackages not implemented"); 10356 } 10357 10358 /** 10359 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 10360 * @param packageName The name of the package to get the suspended status of. 10361 * @param userId The user id. 10362 * @return {@code true} if the package is suspended or {@code false} if the package is not 10363 * suspended. 10364 * @throws IllegalArgumentException if the package was not found. 10365 * @hide 10366 */ 10367 @SuppressWarnings("HiddenAbstractMethod") 10368 @UnsupportedAppUsage isPackageSuspendedForUser(@onNull String packageName, int userId)10369 public abstract boolean isPackageSuspendedForUser(@NonNull String packageName, int userId); 10370 10371 /** 10372 * Query if an app is currently suspended. 10373 * 10374 * @return {@code true} if the given package is suspended, {@code false} otherwise 10375 * @throws NameNotFoundException if the package could not be found. 10376 * 10377 * @see #isPackageSuspended() 10378 */ isPackageSuspended(@onNull String packageName)10379 public boolean isPackageSuspended(@NonNull String packageName) throws NameNotFoundException { 10380 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 10381 } 10382 10383 /** 10384 * Apps can query this to know if they have been suspended. A system app with the permission 10385 * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state. 10386 * 10387 * <p>While in this state, the application's notifications will be hidden, any of its started 10388 * activities will be stopped and it will not be able to show toasts or dialogs or play audio. 10389 * When the user tries to launch a suspended app, the system will, instead, show a 10390 * dialog to the user informing them that they cannot use this app while it is suspended. 10391 * 10392 * <p>When an app is put into this state, the broadcast action 10393 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast 10394 * receivers that included this action in their intent-filters, <em>including manifest 10395 * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED} 10396 * is delivered when a previously suspended app is taken out of this state. Apps are expected to 10397 * use these to gracefully deal with transitions to and from this state. 10398 * 10399 * @return {@code true} if the calling package has been suspended, {@code false} otherwise. 10400 * 10401 * @see #getSuspendedPackageAppExtras() 10402 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 10403 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 10404 */ isPackageSuspended()10405 public boolean isPackageSuspended() { 10406 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 10407 } 10408 10409 /** 10410 * Returns a {@link Bundle} of extras that was meant to be sent to the calling app when it was 10411 * suspended. An app with the permission {@code android.permission.SUSPEND_APPS} can supply this 10412 * to the system at the time of suspending an app. 10413 * 10414 * <p>This is the same {@link Bundle} that is sent along with the broadcast 10415 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED}, whenever the app is suspended. The contents of 10416 * this {@link Bundle} are a contract between the suspended app and the suspending app. 10417 * 10418 * <p>Note: These extras are optional, so if no extras were supplied to the system, this method 10419 * will return {@code null}, even when the calling app has been suspended. 10420 * 10421 * @return A {@link Bundle} containing the extras for the app, or {@code null} if the 10422 * package is not currently suspended. 10423 * 10424 * @see #isPackageSuspended() 10425 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 10426 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 10427 * @see Intent#EXTRA_SUSPENDED_PACKAGE_EXTRAS 10428 */ getSuspendedPackageAppExtras()10429 public @Nullable Bundle getSuspendedPackageAppExtras() { 10430 throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented"); 10431 } 10432 10433 /** 10434 * Get the name of the package that suspended the given package. Packages can be suspended by 10435 * device administrators or apps holding {@link android.Manifest.permission#MANAGE_USERS} or 10436 * {@link android.Manifest.permission#SUSPEND_APPS}. 10437 * 10438 * <p> 10439 * <strong>Note:</strong>This API doesn't support cross user suspension and should only be used 10440 * for testing. 10441 * @param suspendedPackage The package that has been suspended. 10442 * @return Name of the package that suspended the given package. Returns {@code null} if the 10443 * given package is not currently suspended and the platform package name - i.e. 10444 * {@code "android"} - if the package was suspended by a device admin. 10445 * @hide 10446 */ getSuspendingPackage(@onNull String suspendedPackage)10447 public @Nullable String getSuspendingPackage(@NonNull String suspendedPackage) { 10448 throw new UnsupportedOperationException("getSuspendingPackage not implemented"); 10449 } 10450 10451 /** 10452 * Query if an app is currently stopped. 10453 * 10454 * @return {@code true} if the given package is stopped, {@code false} otherwise 10455 * @throws NameNotFoundException if the package could not be found. 10456 * @see ApplicationInfo#FLAG_STOPPED 10457 */ 10458 @FlaggedApi(android.content.pm.Flags.FLAG_STAY_STOPPED) isPackageStopped(@onNull String packageName)10459 public boolean isPackageStopped(@NonNull String packageName) throws NameNotFoundException { 10460 throw new UnsupportedOperationException("isPackageStopped not implemented"); 10461 } 10462 10463 /** 10464 * Query if an app is currently quarantined. 10465 * A misbehaving app can be quarantined by e.g. a system of another privileged entity. 10466 * Quarantined apps are similar to disabled, but still visible in e.g. Launcher. 10467 * Only activities of such apps can still be queried, but not services etc. 10468 * Quarantined apps can't be bound to, and won't receive broadcasts. 10469 * They can't be resolved, unless {@link #MATCH_QUARANTINED_COMPONENTS} specified. 10470 * 10471 * @return {@code true} if the given package is quarantined, {@code false} otherwise 10472 * @throws NameNotFoundException if the package could not be found. 10473 */ 10474 @FlaggedApi(android.content.pm.Flags.FLAG_QUARANTINED_ENABLED) isPackageQuarantined(@onNull String packageName)10475 public boolean isPackageQuarantined(@NonNull String packageName) throws NameNotFoundException { 10476 throw new UnsupportedOperationException("isPackageQuarantined not implemented"); 10477 } 10478 /** 10479 * Provide a hint of what the {@link ApplicationInfo#category} value should 10480 * be for the given package. 10481 * <p> 10482 * This hint can only be set by the app which installed this package, as 10483 * determined by {@link #getInstallerPackageName(String)}. 10484 * 10485 * @param packageName the package to change the category hint for. 10486 * @param categoryHint the category hint to set. 10487 */ 10488 @SuppressWarnings("HiddenAbstractMethod") setApplicationCategoryHint(@onNull String packageName, @ApplicationInfo.Category int categoryHint)10489 public abstract void setApplicationCategoryHint(@NonNull String packageName, 10490 @ApplicationInfo.Category int categoryHint); 10491 10492 /** {@hide} */ isMoveStatusFinished(int status)10493 public static boolean isMoveStatusFinished(int status) { 10494 return (status < 0 || status > 100); 10495 } 10496 10497 /** {@hide} */ 10498 public static abstract class MoveCallback { onCreated(int moveId, Bundle extras)10499 public void onCreated(int moveId, Bundle extras) {} onStatusChanged(int moveId, int status, long estMillis)10500 public abstract void onStatusChanged(int moveId, int status, long estMillis); 10501 } 10502 10503 /** {@hide} */ 10504 @SuppressWarnings("HiddenAbstractMethod") 10505 @UnsupportedAppUsage getMoveStatus(int moveId)10506 public abstract int getMoveStatus(int moveId); 10507 10508 /** {@hide} */ 10509 @SuppressWarnings("HiddenAbstractMethod") 10510 @UnsupportedAppUsage registerMoveCallback(@onNull MoveCallback callback, @NonNull Handler handler)10511 public abstract void registerMoveCallback(@NonNull MoveCallback callback, 10512 @NonNull Handler handler); 10513 /** {@hide} */ 10514 @SuppressWarnings("HiddenAbstractMethod") 10515 @UnsupportedAppUsage unregisterMoveCallback(@onNull MoveCallback callback)10516 public abstract void unregisterMoveCallback(@NonNull MoveCallback callback); 10517 10518 /** {@hide} */ 10519 @SuppressWarnings("HiddenAbstractMethod") 10520 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) movePackage(@onNull String packageName, @NonNull VolumeInfo vol)10521 public abstract int movePackage(@NonNull String packageName, @NonNull VolumeInfo vol); 10522 /** {@hide} */ 10523 @SuppressWarnings("HiddenAbstractMethod") 10524 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getPackageCurrentVolume(@onNull ApplicationInfo app)10525 public abstract @Nullable VolumeInfo getPackageCurrentVolume(@NonNull ApplicationInfo app); 10526 /** {@hide} */ 10527 @SuppressWarnings("HiddenAbstractMethod") 10528 @NonNull 10529 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getPackageCandidateVolumes( @onNull ApplicationInfo app)10530 public abstract List<VolumeInfo> getPackageCandidateVolumes( 10531 @NonNull ApplicationInfo app); 10532 10533 /** {@hide} */ 10534 @SuppressWarnings("HiddenAbstractMethod") movePrimaryStorage(@onNull VolumeInfo vol)10535 public abstract int movePrimaryStorage(@NonNull VolumeInfo vol); 10536 /** {@hide} */ 10537 @SuppressWarnings("HiddenAbstractMethod") getPrimaryStorageCurrentVolume()10538 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 10539 /** {@hide} */ 10540 @SuppressWarnings("HiddenAbstractMethod") getPrimaryStorageCandidateVolumes()10541 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 10542 10543 /** 10544 * Returns the device identity that verifiers can use to associate their scheme to a particular 10545 * device. This should not be used by anything other than a package verifier. 10546 * 10547 * @return identity that uniquely identifies current device 10548 * @hide 10549 */ 10550 @SuppressWarnings("HiddenAbstractMethod") 10551 @NonNull getVerifierDeviceIdentity()10552 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 10553 10554 /** 10555 * Returns true if the device is upgrading, such as first boot after OTA. 10556 * 10557 * @hide 10558 */ 10559 @SuppressWarnings("HiddenAbstractMethod") 10560 @UnsupportedAppUsage isUpgrade()10561 public abstract boolean isUpgrade(); 10562 10563 /** 10564 * Returns true if the device is upgrading, such as first boot after OTA. 10565 */ isDeviceUpgrading()10566 public boolean isDeviceUpgrading() { 10567 return false; 10568 } 10569 10570 /** 10571 * Return interface that offers the ability to install, upgrade, and remove 10572 * applications on the device. 10573 */ getPackageInstaller()10574 public abstract @NonNull PackageInstaller getPackageInstaller(); 10575 10576 /** 10577 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 10578 * intents sent from the user with id sourceUserId can also be be resolved 10579 * by activities in the user with id targetUserId if they match the 10580 * specified intent filter. 10581 * 10582 * @param filter The {@link IntentFilter} the intent has to match 10583 * @param sourceUserId The source user id. 10584 * @param targetUserId The target user id. 10585 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 10586 * {@link #ONLY_IF_NO_MATCH_FOUND}. 10587 * @hide 10588 */ 10589 @SuppressWarnings("HiddenAbstractMethod") 10590 @UnsupportedAppUsage 10591 @TestApi addCrossProfileIntentFilter(@onNull IntentFilter filter, @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags)10592 public abstract void addCrossProfileIntentFilter(@NonNull IntentFilter filter, 10593 @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags); 10594 10595 /** 10596 * Removes all {@code CrossProfileIntentFilter}s which matches the specified intent filer, 10597 * source, target and flag. 10598 * 10599 * @param filter The {@link IntentFilter} the intent has to match 10600 * @param sourceUserId The source user id. 10601 * @param targetUserId The target user id. 10602 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 10603 * {@link #ONLY_IF_NO_MATCH_FOUND}. 10604 * @hide 10605 */ removeCrossProfileIntentFilter(@onNull IntentFilter filter, @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags)10606 public boolean removeCrossProfileIntentFilter(@NonNull IntentFilter filter, 10607 @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags) { 10608 throw new UnsupportedOperationException( 10609 "removeCrossProfileIntentFilter not implemented in subclass"); 10610 } 10611 10612 /** 10613 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 10614 * as their source, and have been set by the app calling this method. 10615 * 10616 * @param sourceUserId The source user id. 10617 * @hide 10618 */ 10619 @SuppressWarnings("HiddenAbstractMethod") 10620 @UnsupportedAppUsage 10621 @TestApi clearCrossProfileIntentFilters(@serIdInt int sourceUserId)10622 public abstract void clearCrossProfileIntentFilters(@UserIdInt int sourceUserId); 10623 10624 /** 10625 * @hide 10626 */ 10627 @SuppressWarnings("HiddenAbstractMethod") 10628 @NonNull 10629 @UnsupportedAppUsage loadItemIcon(@onNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo)10630 public abstract Drawable loadItemIcon(@NonNull PackageItemInfo itemInfo, 10631 @Nullable ApplicationInfo appInfo); 10632 10633 /** 10634 * @hide 10635 */ 10636 @SuppressWarnings("HiddenAbstractMethod") 10637 @NonNull 10638 @UnsupportedAppUsage loadUnbadgedItemIcon(@onNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo)10639 public abstract Drawable loadUnbadgedItemIcon(@NonNull PackageItemInfo itemInfo, 10640 @Nullable ApplicationInfo appInfo); 10641 10642 /** {@hide} */ 10643 @SuppressWarnings("HiddenAbstractMethod") 10644 @UnsupportedAppUsage isPackageAvailable(@onNull String packageName)10645 public abstract boolean isPackageAvailable(@NonNull String packageName); 10646 10647 /** {@hide} */ 10648 @NonNull 10649 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) installStatusToString(int status, @Nullable String msg)10650 public static String installStatusToString(int status, @Nullable String msg) { 10651 final String str = installStatusToString(status); 10652 if (msg != null) { 10653 return str + ": " + msg; 10654 } else { 10655 return str; 10656 } 10657 } 10658 10659 /** {@hide} */ 10660 @NonNull 10661 @UnsupportedAppUsage installStatusToString(int status)10662 public static String installStatusToString(int status) { 10663 switch (status) { 10664 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 10665 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 10666 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 10667 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 10668 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 10669 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 10670 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 10671 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 10672 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 10673 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 10674 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 10675 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 10676 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 10677 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 10678 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 10679 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 10680 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 10681 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 10682 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 10683 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 10684 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 10685 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 10686 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 10687 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 10688 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 10689 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 10690 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 10691 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 10692 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 10693 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 10694 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 10695 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 10696 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 10697 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 10698 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 10699 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 10700 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 10701 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 10702 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 10703 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 10704 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 10705 case INSTALL_FAILED_BAD_DEX_METADATA: return "INSTALL_FAILED_BAD_DEX_METADATA"; 10706 case INSTALL_FAILED_MISSING_SPLIT: return "INSTALL_FAILED_MISSING_SPLIT"; 10707 case INSTALL_FAILED_DEPRECATED_SDK_VERSION: return "INSTALL_FAILED_DEPRECATED_SDK_VERSION"; 10708 case INSTALL_FAILED_BAD_SIGNATURE: return "INSTALL_FAILED_BAD_SIGNATURE"; 10709 case INSTALL_FAILED_WRONG_INSTALLED_VERSION: return "INSTALL_FAILED_WRONG_INSTALLED_VERSION"; 10710 case INSTALL_FAILED_PROCESS_NOT_DEFINED: return "INSTALL_FAILED_PROCESS_NOT_DEFINED"; 10711 case INSTALL_FAILED_SESSION_INVALID: return "INSTALL_FAILED_SESSION_INVALID"; 10712 case INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST: 10713 return "INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST"; 10714 case INSTALL_FAILED_MULTI_ARCH_NOT_MATCH_ALL_NATIVE_ABIS: 10715 return "INSTALL_FAILED_MULTI_ARCH_NOT_MATCH_ALL_NATIVE_ABIS"; 10716 default: return Integer.toString(status); 10717 } 10718 } 10719 10720 /** {@hide} */ installStatusToPublicStatus(int status)10721 public static int installStatusToPublicStatus(int status) { 10722 switch (status) { 10723 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 10724 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10725 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 10726 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 10727 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 10728 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10729 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10730 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10731 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10732 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10733 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10734 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 10735 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10736 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10737 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10738 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 10739 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10740 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10741 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 10742 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 10743 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 10744 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 10745 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 10746 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 10747 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 10748 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 10749 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 10750 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 10751 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 10752 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 10753 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 10754 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 10755 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 10756 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 10757 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 10758 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 10759 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 10760 case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID; 10761 case INSTALL_FAILED_BAD_SIGNATURE: return PackageInstaller.STATUS_FAILURE_INVALID; 10762 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 10763 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10764 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10765 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10766 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 10767 case INSTALL_FAILED_MISSING_SPLIT: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10768 case INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10769 case INSTALL_FAILED_DEPRECATED_SDK_VERSION: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 10770 default: return PackageInstaller.STATUS_FAILURE; 10771 } 10772 } 10773 10774 /** {@hide} */ 10775 @NonNull deleteStatusToString(int status, @Nullable String msg)10776 public static String deleteStatusToString(int status, @Nullable String msg) { 10777 final String str = deleteStatusToString(status); 10778 if (msg != null) { 10779 return str + ": " + msg; 10780 } else { 10781 return str; 10782 } 10783 } 10784 10785 /** {@hide} */ 10786 @NonNull 10787 @UnsupportedAppUsage deleteStatusToString(int status)10788 public static String deleteStatusToString(int status) { 10789 switch (status) { 10790 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 10791 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 10792 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 10793 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 10794 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 10795 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 10796 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY"; 10797 case DELETE_FAILED_APP_PINNED: return "DELETE_FAILED_APP_PINNED"; 10798 default: return Integer.toString(status); 10799 } 10800 } 10801 10802 /** {@hide} */ deleteStatusToPublicStatus(int status)10803 public static int deleteStatusToPublicStatus(int status) { 10804 switch (status) { 10805 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 10806 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 10807 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10808 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10809 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10810 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 10811 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT; 10812 case DELETE_FAILED_APP_PINNED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 10813 default: return PackageInstaller.STATUS_FAILURE; 10814 } 10815 } 10816 10817 /** {@hide} */ 10818 @NonNull permissionFlagToString(int flag)10819 public static String permissionFlagToString(int flag) { 10820 switch (flag) { 10821 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 10822 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 10823 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 10824 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 10825 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 10826 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 10827 case FLAG_PERMISSION_REVOKE_WHEN_REQUESTED: return "REVOKE_WHEN_REQUESTED"; 10828 case FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED: return "USER_SENSITIVE_WHEN_GRANTED"; 10829 case FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED: return "USER_SENSITIVE_WHEN_DENIED"; 10830 case FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT: return "RESTRICTION_INSTALLER_EXEMPT"; 10831 case FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT: return "RESTRICTION_SYSTEM_EXEMPT"; 10832 case FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT: return "RESTRICTION_UPGRADE_EXEMPT"; 10833 case FLAG_PERMISSION_APPLY_RESTRICTION: return "APPLY_RESTRICTION"; 10834 case FLAG_PERMISSION_GRANTED_BY_ROLE: return "GRANTED_BY_ROLE"; 10835 case FLAG_PERMISSION_REVOKED_COMPAT: return "REVOKED_COMPAT"; 10836 case FLAG_PERMISSION_ONE_TIME: return "ONE_TIME"; 10837 case FLAG_PERMISSION_AUTO_REVOKED: return "AUTO_REVOKED"; 10838 default: return Integer.toString(flag); 10839 } 10840 } 10841 10842 /** {@hide} */ 10843 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 10844 private final IPackageDeleteObserver mLegacy; 10845 LegacyPackageDeleteObserver(IPackageDeleteObserver legacy)10846 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 10847 mLegacy = legacy; 10848 } 10849 10850 @Override onPackageDeleted(String basePackageName, int returnCode, String msg)10851 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 10852 if (mLegacy == null) return; 10853 try { 10854 mLegacy.packageDeleted(basePackageName, returnCode); 10855 } catch (RemoteException ignored) { 10856 } 10857 } 10858 } 10859 10860 /** 10861 * A parcelable class to pass as an intent extra to the PackageInstaller. When an uninstall is 10862 * completed (both successfully or unsuccessfully), the result is sent to the uninstall 10863 * initiators. 10864 * 10865 * @hide 10866 */ 10867 @SystemApi 10868 public static final class UninstallCompleteCallback implements Parcelable { 10869 private IPackageDeleteObserver2 mBinder; 10870 10871 /** @hide */ 10872 @IntDef(prefix = { "DELETE_" }, value = { 10873 DELETE_SUCCEEDED, 10874 DELETE_FAILED_INTERNAL_ERROR, 10875 DELETE_FAILED_DEVICE_POLICY_MANAGER, 10876 DELETE_FAILED_USER_RESTRICTED, 10877 DELETE_FAILED_OWNER_BLOCKED, 10878 DELETE_FAILED_ABORTED, 10879 DELETE_FAILED_USED_SHARED_LIBRARY, 10880 DELETE_FAILED_APP_PINNED, 10881 }) 10882 @Retention(RetentionPolicy.SOURCE) 10883 public @interface DeleteStatus{} 10884 10885 /** @hide */ UninstallCompleteCallback(@onNull IBinder binder)10886 public UninstallCompleteCallback(@NonNull IBinder binder) { 10887 mBinder = IPackageDeleteObserver2.Stub.asInterface(binder); 10888 } 10889 10890 /** @hide */ UninstallCompleteCallback(Parcel in)10891 private UninstallCompleteCallback(Parcel in) { 10892 mBinder = IPackageDeleteObserver2.Stub.asInterface(in.readStrongBinder()); 10893 } 10894 10895 public static final @NonNull Parcelable.Creator<UninstallCompleteCallback> CREATOR = 10896 new Parcelable.Creator<>() { 10897 public UninstallCompleteCallback createFromParcel(Parcel source) { 10898 return new UninstallCompleteCallback(source); 10899 } 10900 10901 public UninstallCompleteCallback[] newArray(int size) { 10902 return new UninstallCompleteCallback[size]; 10903 } 10904 }; 10905 10906 /** 10907 * Called when an uninstallation is completed successfully or unsuccessfully. 10908 * 10909 * @param packageName The name of the package being uninstalled. 10910 * @param resultCode Result code of the operation. 10911 * @param errorMessage Error message if any. 10912 * 10913 * @hide */ 10914 @SystemApi onUninstallComplete(@onNull String packageName, @DeleteStatus int resultCode, @Nullable String errorMessage)10915 public void onUninstallComplete(@NonNull String packageName, @DeleteStatus int resultCode, 10916 @Nullable String errorMessage) { 10917 try { 10918 mBinder.onPackageDeleted(packageName, resultCode, errorMessage); 10919 } catch (RemoteException e) { 10920 // no-op 10921 } 10922 } 10923 10924 /** @hide */ 10925 @Override describeContents()10926 public int describeContents() { 10927 return 0; 10928 } 10929 10930 /** @hide */ 10931 @Override writeToParcel(@onNull Parcel dest, int flags)10932 public void writeToParcel(@NonNull Parcel dest, int flags) { 10933 dest.writeStrongBinder(mBinder.asBinder()); 10934 } 10935 } 10936 10937 /** 10938 * Return the install reason that was recorded when a package was first 10939 * installed for a specific user. Requesting the install reason for another 10940 * user will require the permission INTERACT_ACROSS_USERS_FULL. 10941 * 10942 * @param packageName The package for which to retrieve the install reason 10943 * @param user The user for whom to retrieve the install reason 10944 * @return The install reason. If the package is not installed for the given 10945 * user, {@code INSTALL_REASON_UNKNOWN} is returned. 10946 * @hide 10947 */ 10948 @SuppressWarnings("HiddenAbstractMethod") 10949 @TestApi 10950 @InstallReason getInstallReason(@onNull String packageName, @NonNull UserHandle user)10951 public abstract int getInstallReason(@NonNull String packageName, @NonNull UserHandle user); 10952 10953 /** 10954 * Checks whether the calling package is allowed to request package installs through package 10955 * installer. Apps are encouraged to call this API before launching the package installer via 10956 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the 10957 * user can explicitly choose what external sources they trust to install apps on the device. 10958 * If this API returns false, the install request will be blocked by the package installer and 10959 * a dialog will be shown to the user with an option to launch settings to change their 10960 * preference. An application must target Android O or higher and declare permission 10961 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API. 10962 * 10963 * @return true if the calling package is trusted by the user to request install packages on 10964 * the device, false otherwise. 10965 * @see android.content.Intent#ACTION_INSTALL_PACKAGE 10966 * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES 10967 */ canRequestPackageInstalls()10968 public abstract boolean canRequestPackageInstalls(); 10969 10970 /** 10971 * Return the {@link ComponentName} of the activity providing Settings for the Instant App 10972 * resolver. 10973 * 10974 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS} 10975 * @hide 10976 */ 10977 @SuppressWarnings("HiddenAbstractMethod") 10978 @Nullable 10979 @SystemApi getInstantAppResolverSettingsComponent()10980 public abstract ComponentName getInstantAppResolverSettingsComponent(); 10981 10982 /** 10983 * Return the {@link ComponentName} of the activity responsible for installing instant 10984 * applications. 10985 * 10986 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE} 10987 * @hide 10988 */ 10989 @SuppressWarnings("HiddenAbstractMethod") 10990 @Nullable 10991 @SystemApi getInstantAppInstallerComponent()10992 public abstract ComponentName getInstantAppInstallerComponent(); 10993 10994 /** 10995 * Return the Android Id for a given Instant App. 10996 * 10997 * @see {@link android.provider.Settings.Secure#ANDROID_ID} 10998 * @hide 10999 */ 11000 @SuppressWarnings("HiddenAbstractMethod") 11001 @Nullable getInstantAppAndroidId(@onNull String packageName, @NonNull UserHandle user)11002 public abstract String getInstantAppAndroidId(@NonNull String packageName, 11003 @NonNull UserHandle user); 11004 11005 /** 11006 * Callback use to notify the callers of module registration that the operation 11007 * has finished. 11008 * 11009 * @hide 11010 */ 11011 @SystemApi 11012 public static abstract class DexModuleRegisterCallback { onDexModuleRegistered(String dexModulePath, boolean success, String message)11013 public abstract void onDexModuleRegistered(String dexModulePath, boolean success, 11014 String message); 11015 } 11016 11017 /** 11018 * Register an application dex module with the package manager. 11019 * 11020 * This call no longer does anything. If a callback is given it is called with a false success 11021 * value. 11022 * 11023 * @param dexModulePath the absolute path of the dex module. 11024 * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will 11025 * be called once the registration finishes. 11026 * 11027 * @hide 11028 */ 11029 @SuppressWarnings("HiddenAbstractMethod") 11030 @SystemApi registerDexModule(@onNull String dexModulePath, @Nullable DexModuleRegisterCallback callback)11031 public abstract void registerDexModule(@NonNull String dexModulePath, 11032 @Nullable DexModuleRegisterCallback callback); 11033 11034 /** 11035 * Returns the {@link ArtManager} associated with this package manager. 11036 * 11037 * @hide 11038 */ 11039 @SystemApi getArtManager()11040 public @NonNull ArtManager getArtManager() { 11041 throw new UnsupportedOperationException("getArtManager not implemented in subclass"); 11042 } 11043 11044 /** 11045 * Sets or clears the harmful app warning details for the given app. 11046 * 11047 * When set, any attempt to launch an activity in this package will be intercepted and a 11048 * warning dialog will be shown to the user instead, with the given warning. The user 11049 * will have the option to proceed with the activity launch, or to uninstall the application. 11050 * 11051 * @param packageName The full name of the package to warn on. 11052 * @param warning A warning string to display to the user describing the threat posed by the 11053 * application, or null to clear the warning. 11054 * 11055 * @hide 11056 */ 11057 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 11058 @SystemApi setHarmfulAppWarning(@onNull String packageName, @Nullable CharSequence warning)11059 public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) { 11060 throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass"); 11061 } 11062 11063 /** 11064 * Set the page compat mode override for given package 11065 * 11066 * @hide 11067 */ 11068 @FlaggedApi(android.content.pm.Flags.FLAG_APP_COMPAT_OPTION_16KB) setPageSizeAppCompatFlagsSettingsOverride(@onNull String packageName, boolean enabled)11069 public void setPageSizeAppCompatFlagsSettingsOverride(@NonNull String packageName, 11070 boolean enabled) { 11071 throw new UnsupportedOperationException( 11072 "setPageSizeAppCompatFlagsSettingsOverride not implemented in subclass"); 11073 } 11074 11075 /** 11076 * Check whether page size app compat mode is enabled for given package 11077 * 11078 * @hide 11079 */ 11080 @FlaggedApi(android.content.pm.Flags.FLAG_APP_COMPAT_OPTION_16KB) isPageSizeCompatEnabled(@onNull String packageName)11081 public boolean isPageSizeCompatEnabled(@NonNull String packageName) { 11082 throw new UnsupportedOperationException( 11083 "isPageSizeCompatEnabled not implemented in subclass"); 11084 } 11085 11086 /** 11087 * Get the page size app compat warning dialog to show at app launch time 11088 * 11089 * @hide 11090 */ 11091 @Nullable 11092 @FlaggedApi(android.content.pm.Flags.FLAG_APP_COMPAT_OPTION_16KB) getPageSizeCompatWarningMessage(@onNull String packageName)11093 public String getPageSizeCompatWarningMessage(@NonNull String packageName) { 11094 throw new UnsupportedOperationException( 11095 "getPageSizeCompatWarningMessage not implemented in subclass"); 11096 } 11097 11098 /** 11099 * Returns the harmful app warning string for the given app, or null if there is none set. 11100 * 11101 * @param packageName The full name of the desired package. 11102 * 11103 * @hide 11104 */ 11105 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 11106 @Nullable 11107 @SystemApi getHarmfulAppWarning(@onNull String packageName)11108 public CharSequence getHarmfulAppWarning(@NonNull String packageName) { 11109 throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass"); 11110 } 11111 11112 /** @hide */ 11113 @IntDef(prefix = { "CERT_INPUT_" }, value = { 11114 CERT_INPUT_RAW_X509, 11115 CERT_INPUT_SHA256 11116 }) 11117 @Retention(RetentionPolicy.SOURCE) 11118 public @interface CertificateInputType {} 11119 11120 /** 11121 * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could 11122 * be generated using an {@code CertificateFactory} 11123 */ 11124 public static final int CERT_INPUT_RAW_X509 = 0; 11125 11126 /** 11127 * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509 11128 * Certificate. 11129 */ 11130 public static final int CERT_INPUT_SHA256 = 1; 11131 11132 /** 11133 * Searches the set of signing certificates by which the given package has proven to have been 11134 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 11135 * since it takes into account the possibility of signing certificate rotation, except in the 11136 * case of packages that are signed by multiple certificates, for which signing certificate 11137 * rotation is not supported. This method is analogous to using {@code getPackageInfo} with 11138 * {@code GET_SIGNING_CERTIFICATES} and then searching through the resulting {@code 11139 * signingInfo} field to see if the desired certificate is present. 11140 * 11141 * @param packageName package whose signing certificates to check 11142 * @param certificate signing certificate for which to search 11143 * @param type representation of the {@code certificate} 11144 * @return true if this package was or is signed by exactly the certificate {@code certificate} 11145 */ hasSigningCertificate(@onNull String packageName, @NonNull byte[] certificate, @CertificateInputType int type)11146 public boolean hasSigningCertificate(@NonNull String packageName, @NonNull byte[] certificate, 11147 @CertificateInputType int type) { 11148 throw new UnsupportedOperationException( 11149 "hasSigningCertificate not implemented in subclass"); 11150 } 11151 11152 /** 11153 * Searches the set of signing certificates by which the package(s) for the given uid has proven 11154 * to have been signed. For multiple packages sharing the same uid, this will return the 11155 * signing certificates found in the signing history of the "newest" package, where "newest" 11156 * indicates the package with the newest signing certificate in the shared uid group. This 11157 * method should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 11158 * since it takes into account the possibility of signing certificate rotation, except in the 11159 * case of packages that are signed by multiple certificates, for which signing certificate 11160 * rotation is not supported. This method is analogous to using {@code getPackagesForUid} 11161 * followed by {@code getPackageInfo} with {@code GET_SIGNING_CERTIFICATES}, selecting the 11162 * {@code PackageInfo} of the newest-signed bpackage , and finally searching through the 11163 * resulting {@code signingInfo} field to see if the desired certificate is there. 11164 * 11165 * @param uid uid whose signing certificates to check 11166 * @param certificate signing certificate for which to search 11167 * @param type representation of the {@code certificate} 11168 * @return true if this package was or is signed by exactly the certificate {@code certificate} 11169 */ hasSigningCertificate( int uid, @NonNull byte[] certificate, @CertificateInputType int type)11170 public boolean hasSigningCertificate( 11171 int uid, @NonNull byte[] certificate, @CertificateInputType int type) { 11172 throw new UnsupportedOperationException( 11173 "hasSigningCertificate not implemented in subclass"); 11174 } 11175 11176 /** 11177 * Trust any Installer to provide checksums for the package. 11178 * @see #requestChecksums 11179 */ 11180 public static final @NonNull List<Certificate> TRUST_ALL = Collections.singletonList(null); 11181 11182 /** 11183 * Don't trust any Installer to provide checksums for the package. 11184 * This effectively disables optimized Installer-enforced checksums. 11185 * @see #requestChecksums 11186 */ 11187 public static final @NonNull List<Certificate> TRUST_NONE = Collections.singletonList(null); 11188 11189 /** Listener that gets notified when checksums are available. */ 11190 @FunctionalInterface 11191 public interface OnChecksumsReadyListener { 11192 /** 11193 * Called when the checksums are available. 11194 * 11195 * @param checksums array of checksums. 11196 */ onChecksumsReady(@onNull List<ApkChecksum> checksums)11197 void onChecksumsReady(@NonNull List<ApkChecksum> checksums); 11198 } 11199 11200 /** 11201 * Requests the checksums for APKs within a package. 11202 * The checksums will be returned asynchronously via onChecksumsReadyListener. 11203 * 11204 * By default returns all readily available checksums: 11205 * - enforced by platform, 11206 * - enforced by installer. 11207 * If caller needs a specific checksum kind, they can specify it as required. 11208 * 11209 * <b>Caution: Android can not verify installer-provided checksums. Make sure you specify 11210 * trusted installers.</b> 11211 * 11212 * @param packageName whose checksums to return. 11213 * @param includeSplits whether to include checksums for non-base splits. 11214 * @param required explicitly request the checksum types. May incur significant 11215 * CPU/memory/disk usage. 11216 * @param trustedInstallers for checksums enforced by installer, which installers are to be 11217 * trusted. 11218 * {@link #TRUST_ALL} will return checksums from any installer, 11219 * {@link #TRUST_NONE} disables optimized installer-enforced checksums, 11220 * otherwise the list has to be non-empty list of certificates. 11221 * @param onChecksumsReadyListener called once when the results are available. 11222 * @throws CertificateEncodingException if an encoding error occurs for trustedInstallers. 11223 * @throws IllegalArgumentException if the list of trusted installer certificates is empty. 11224 * @throws NameNotFoundException if a package with the given name cannot be found on the system. 11225 */ requestChecksums(@onNull String packageName, boolean includeSplits, @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers, @NonNull OnChecksumsReadyListener onChecksumsReadyListener)11226 public void requestChecksums(@NonNull String packageName, boolean includeSplits, 11227 @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers, 11228 @NonNull OnChecksumsReadyListener onChecksumsReadyListener) 11229 throws CertificateEncodingException, NameNotFoundException { 11230 throw new UnsupportedOperationException("requestChecksums not implemented in subclass"); 11231 } 11232 11233 /** 11234 * @return the default text classifier package name, or null if there's none. 11235 * 11236 * @hide 11237 */ 11238 @Nullable 11239 @TestApi getDefaultTextClassifierPackageName()11240 public String getDefaultTextClassifierPackageName() { 11241 throw new UnsupportedOperationException( 11242 "getDefaultTextClassifierPackageName not implemented in subclass"); 11243 } 11244 11245 /** 11246 * @return the system defined text classifier package names, or null if there's none. 11247 * 11248 * @hide 11249 */ 11250 @Nullable 11251 @TestApi getSystemTextClassifierPackageName()11252 public String getSystemTextClassifierPackageName() { 11253 throw new UnsupportedOperationException( 11254 "getSystemTextClassifierPackageName not implemented in subclass"); 11255 } 11256 11257 /** 11258 * @return attention service package name, or null if there's none. 11259 * 11260 * @hide 11261 */ getAttentionServicePackageName()11262 public String getAttentionServicePackageName() { 11263 throw new UnsupportedOperationException( 11264 "getAttentionServicePackageName not implemented in subclass"); 11265 } 11266 11267 /** 11268 * @return rotation resolver service's package name, or null if there's none. 11269 * 11270 * @hide 11271 */ getRotationResolverPackageName()11272 public String getRotationResolverPackageName() { 11273 throw new UnsupportedOperationException( 11274 "getRotationResolverPackageName not implemented in subclass"); 11275 } 11276 11277 /** 11278 * @return the wellbeing app package name, or null if it's not defined by the OEM. 11279 * 11280 * @hide 11281 */ 11282 @Nullable 11283 @TestApi getWellbeingPackageName()11284 public String getWellbeingPackageName() { 11285 throw new UnsupportedOperationException( 11286 "getWellbeingPackageName not implemented in subclass"); 11287 } 11288 11289 /** 11290 * @return the system defined app predictor package name, or null if there's none. 11291 * 11292 * @hide 11293 */ 11294 @Nullable getAppPredictionServicePackageName()11295 public String getAppPredictionServicePackageName() { 11296 throw new UnsupportedOperationException( 11297 "getAppPredictionServicePackageName not implemented in subclass"); 11298 } 11299 11300 /** 11301 * @return the system defined content capture service package name, or null if there's none. 11302 * 11303 * @hide 11304 */ 11305 @Nullable getSystemCaptionsServicePackageName()11306 public String getSystemCaptionsServicePackageName() { 11307 throw new UnsupportedOperationException( 11308 "getSystemCaptionsServicePackageName not implemented in subclass"); 11309 } 11310 11311 /** 11312 * @return the system defined setup wizard package name, or null if there's none. 11313 * 11314 * @hide 11315 */ 11316 @Nullable getSetupWizardPackageName()11317 public String getSetupWizardPackageName() { 11318 throw new UnsupportedOperationException( 11319 "getSetupWizardPackageName not implemented in subclass"); 11320 } 11321 11322 /** 11323 * @deprecated This function throws an {@link UnsupportedOperationException}. For pre-granting 11324 * permissions, instead of looking up the package that provides {@code ContentCaptureService}, 11325 * use roles. 11326 * 11327 * @hide 11328 */ 11329 // This function cannot yet be removed because it is referenced from GTS tests. The tests have 11330 // been updated to not rely on it when running on Android T and above, but in order to compile 11331 // the tests we must keep this method. 11332 @Deprecated 11333 @TestApi 11334 @Nullable getContentCaptureServicePackageName()11335 public final String getContentCaptureServicePackageName() { 11336 throw new UnsupportedOperationException( 11337 "getContentCaptureServicePackageName is deprecated"); 11338 } 11339 11340 /** 11341 * @return the incident report approver app package name, or null if it's not defined 11342 * by the OEM. 11343 * 11344 * @hide 11345 */ 11346 @SystemApi 11347 @Nullable getIncidentReportApproverPackageName()11348 public String getIncidentReportApproverPackageName() { 11349 throw new UnsupportedOperationException( 11350 "getIncidentReportApproverPackageName not implemented in subclass"); 11351 } 11352 11353 /** 11354 * @return whether a given package's state is protected, e.g. package cannot be disabled, 11355 * suspended, hidden or force stopped. 11356 * 11357 * @hide 11358 */ isPackageStateProtected(@onNull String packageName, @UserIdInt int userId)11359 public boolean isPackageStateProtected(@NonNull String packageName, @UserIdInt int userId) { 11360 throw new UnsupportedOperationException( 11361 "isPackageStateProtected not implemented in subclass"); 11362 } 11363 11364 /** 11365 * Notify to the rest of the system that a new device configuration has 11366 * been prepared and that it is time to refresh caches. 11367 * 11368 * @see android.content.Intent#ACTION_DEVICE_CUSTOMIZATION_READY 11369 * 11370 * @hide 11371 */ 11372 @SystemApi sendDeviceCustomizationReadyBroadcast()11373 public void sendDeviceCustomizationReadyBroadcast() { 11374 throw new UnsupportedOperationException( 11375 "sendDeviceCustomizationReadyBroadcast not implemented in subclass"); 11376 } 11377 11378 /** 11379 * <p> 11380 * <strong>Note: </strong>In retrospect it would have been preferred to use 11381 * more inclusive terminology when naming this API. Similar APIs added will 11382 * refrain from using the term "whitelist". 11383 * </p> 11384 * 11385 * @return whether this package is whitelisted from having its runtime permission be 11386 * auto-revoked if unused for an extended period of time. 11387 */ isAutoRevokeWhitelisted()11388 public boolean isAutoRevokeWhitelisted() { 11389 throw new UnsupportedOperationException( 11390 "isAutoRevokeWhitelisted not implemented in subclass"); 11391 } 11392 11393 /** 11394 * Returns if the provided drawable represents the default activity icon provided by the system. 11395 * 11396 * PackageManager silently returns a default application icon for any package/activity if the 11397 * app itself does not define one or if the system encountered any error when loading the icon. 11398 * 11399 * Developers can use this to check implement app specific logic around retrying or caching. 11400 * 11401 * @return true if the drawable represents the default activity icon, false otherwise 11402 * @see #getDefaultActivityIcon() 11403 * @see #getActivityIcon 11404 * @see LauncherActivityInfo#getIcon(int) 11405 */ isDefaultApplicationIcon(@onNull Drawable drawable)11406 public boolean isDefaultApplicationIcon(@NonNull Drawable drawable) { 11407 int resId = drawable instanceof AdaptiveIconDrawable 11408 ? ((AdaptiveIconDrawable) drawable).getSourceDrawableResId() : Resources.ID_NULL; 11409 return resId == com.android.internal.R.drawable.sym_def_app_icon 11410 || resId == com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon; 11411 } 11412 11413 /** 11414 * Sets MIME group's MIME types. 11415 * 11416 * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific 11417 * group name to avoid namespace collisions, e.g. "com.example:myFeature". 11418 * 11419 * @param mimeGroup MIME group to modify. 11420 * @param mimeTypes new MIME types contained by MIME group. 11421 * @throws IllegalArgumentException if the MIME group was not declared in the manifest. 11422 */ setMimeGroup(@onNull String mimeGroup, @NonNull Set<String> mimeTypes)11423 public void setMimeGroup(@NonNull String mimeGroup, @NonNull Set<String> mimeTypes) { 11424 throw new UnsupportedOperationException( 11425 "setMimeGroup not implemented in subclass"); 11426 } 11427 11428 /** 11429 * Gets all MIME types contained by MIME group. 11430 * 11431 * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific 11432 * group name to avoid namespace collisions, e.g. "com.example:myFeature". 11433 * 11434 * @param mimeGroup MIME group to retrieve. 11435 * @return MIME types contained by the MIME group. 11436 * @throws IllegalArgumentException if the MIME group was not declared in the manifest. 11437 */ 11438 @NonNull getMimeGroup(@onNull String mimeGroup)11439 public Set<String> getMimeGroup(@NonNull String mimeGroup) { 11440 throw new UnsupportedOperationException( 11441 "getMimeGroup not implemented in subclass"); 11442 } 11443 11444 /** 11445 * Returns the property defined in the given package's <application> tag. 11446 * 11447 * @throws NameNotFoundException if either the given package is not installed or if the 11448 * given property is not defined within the <application> tag. 11449 */ 11450 @NonNull getProperty(@onNull String propertyName, @NonNull String packageName)11451 public Property getProperty(@NonNull String propertyName, @NonNull String packageName) 11452 throws NameNotFoundException { 11453 throw new UnsupportedOperationException( 11454 "getProperty not implemented in subclass"); 11455 } 11456 11457 /** 11458 * Returns the property defined in the given component declaration. 11459 * 11460 * @throws NameNotFoundException if either the given component does not exist or if the 11461 * given property is not defined within the component declaration. 11462 */ 11463 @NonNull getProperty(@onNull String propertyName, @NonNull ComponentName component)11464 public Property getProperty(@NonNull String propertyName, @NonNull ComponentName component) 11465 throws NameNotFoundException { 11466 throw new UnsupportedOperationException( 11467 "getProperty not implemented in subclass"); 11468 } 11469 11470 /** 11471 * If the provided className is {@code null}, returns the property defined on the application. 11472 * Otherwise, returns the property defined on the component. 11473 * 11474 * @throws NameNotFoundException if the given package is not installed on the calling user or 11475 * component does not exist or if the given property is not defined within the manifest. 11476 * @hide 11477 */ 11478 @NonNull getPropertyAsUser(@onNull String propertyName, @NonNull String packageName, @Nullable String className, int userId)11479 public Property getPropertyAsUser(@NonNull String propertyName, @NonNull String packageName, 11480 @Nullable String className, int userId) throws NameNotFoundException { 11481 throw new UnsupportedOperationException( 11482 "getPropertyAsUser not implemented in subclass"); 11483 } 11484 11485 /** 11486 * Returns the property definition for all <application> tags. 11487 * <p>If the property is not defined with any <application> tag, 11488 * returns and empty list. 11489 */ 11490 @NonNull queryApplicationProperty(@onNull String propertyName)11491 public List<Property> queryApplicationProperty(@NonNull String propertyName) { 11492 throw new UnsupportedOperationException( 11493 "qeuryApplicationProperty not implemented in subclass"); 11494 } 11495 11496 /** 11497 * Returns the property definition for all <activity> and <activity-alias> tags. 11498 * <p>If the property is not defined with any <activity> and <activity-alias> tag, 11499 * returns and empty list. 11500 */ 11501 @NonNull queryActivityProperty(@onNull String propertyName)11502 public List<Property> queryActivityProperty(@NonNull String propertyName) { 11503 throw new UnsupportedOperationException( 11504 "qeuryActivityProperty not implemented in subclass"); 11505 } 11506 11507 /** 11508 * Returns the property definition for all <provider> tags. 11509 * <p>If the property is not defined with any <provider> tag, 11510 * returns and empty list. 11511 */ 11512 @NonNull queryProviderProperty(@onNull String propertyName)11513 public List<Property> queryProviderProperty(@NonNull String propertyName) { 11514 throw new UnsupportedOperationException( 11515 "qeuryProviderProperty not implemented in subclass"); 11516 } 11517 11518 /** 11519 * Returns the property definition for all <receiver> tags. 11520 * <p>If the property is not defined with any <receiver> tag, 11521 * returns and empty list. 11522 */ 11523 @NonNull queryReceiverProperty(@onNull String propertyName)11524 public List<Property> queryReceiverProperty(@NonNull String propertyName) { 11525 throw new UnsupportedOperationException( 11526 "qeuryReceiverProperty not implemented in subclass"); 11527 } 11528 11529 /** 11530 * Returns the property definition for all <service> tags. 11531 * <p>If the property is not defined with any <service> tag, 11532 * returns and empty list. 11533 */ 11534 @NonNull queryServiceProperty(@onNull String propertyName)11535 public List<Property> queryServiceProperty(@NonNull String propertyName) { 11536 throw new UnsupportedOperationException( 11537 "qeuryServiceProperty not implemented in subclass"); 11538 } 11539 11540 /** 11541 * Returns {@code true} if the source package is able to query for details about the 11542 * target package. Applications that share details about other applications should 11543 * use this API to determine if those details should be withheld from callers that 11544 * do not otherwise have visibility of them. 11545 * <p> 11546 * Note: The caller must be able to query for details about the source and target 11547 * package. A {@link NameNotFoundException} is thrown if it isn't. 11548 * 11549 * @param sourcePackageName The source package that would receive details about the 11550 * target package. 11551 * @param targetPackageName The target package whose details would be shared with the 11552 * source package. 11553 * @return {@code true} if the source package is able to query for details about the 11554 * target package. 11555 * @throws NameNotFoundException if either a given package can not be found on the 11556 * system, or if the caller is not able to query for details about the source or 11557 * target package. 11558 */ canPackageQuery(@onNull String sourcePackageName, @NonNull String targetPackageName)11559 public boolean canPackageQuery(@NonNull String sourcePackageName, 11560 @NonNull String targetPackageName) throws NameNotFoundException { 11561 throw new UnsupportedOperationException( 11562 "canPackageQuery not implemented in subclass"); 11563 } 11564 11565 /** 11566 * Same as {@link #canPackageQuery(String, String)} but accepts an array of target packages to 11567 * be queried. 11568 * 11569 * @param sourcePackageName The source package that would receive details about the 11570 * target package. 11571 * @param targetPackageNames An array of target packages whose details would be shared with the 11572 * source package. 11573 * @return An array of booleans where each member specifies whether the source package is able 11574 * to query for details about the target package given by the corresponding value at the same 11575 * index in the array of target packages. 11576 * @throws NameNotFoundException if either a given package can not be found on the 11577 * system, or if the caller is not able to query for details about the source or 11578 * target packages. 11579 */ 11580 @NonNull canPackageQuery(@onNull String sourcePackageName, @NonNull String[] targetPackageNames)11581 public boolean[] canPackageQuery(@NonNull String sourcePackageName, 11582 @NonNull String[] targetPackageNames) throws NameNotFoundException { 11583 throw new UnsupportedOperationException( 11584 "canPackageQuery not implemented in subclass"); 11585 } 11586 11587 /** 11588 * Makes a package that provides an authority {@code visibleAuthority} become visible to the 11589 * application {@code recipientUid}. 11590 * 11591 * @throws SecurityException when called by a package other than the contacts provider 11592 * @hide 11593 */ makeProviderVisible(int recipientUid, String visibleAuthority)11594 public void makeProviderVisible(int recipientUid, String visibleAuthority) { 11595 try { 11596 ActivityThread.getPackageManager().makeProviderVisible(recipientUid, visibleAuthority); 11597 } catch (RemoteException e) { 11598 throw e.rethrowFromSystemServer(); 11599 } 11600 } 11601 11602 /** 11603 * Makes the package associated with the uid {@code visibleUid} become visible to the 11604 * recipient application. The recipient application can receive the details about the 11605 * visible package if successful. 11606 * <p> 11607 * Read <a href="/training/basics/intents/package-visibility">package visibility</a> for more 11608 * information. 11609 * 11610 * @param recipientUid The uid of the application that is being given access to {@code 11611 * visibleUid} 11612 * @param visibleUid The uid of the application that is becoming accessible to {@code 11613 * recipientAppId} 11614 * @hide 11615 */ 11616 @RequiresPermission(android.Manifest.permission.MAKE_UID_VISIBLE) 11617 @TestApi 11618 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) makeUidVisible(int recipientUid, int visibleUid)11619 public void makeUidVisible(int recipientUid, int visibleUid) { 11620 throw new UnsupportedOperationException( 11621 "makeUidVisible not implemented in subclass"); 11622 } 11623 11624 /** 11625 * Return archived package info for the package or null if the package is not installed. 11626 * @see PackageInstaller#installPackageArchived 11627 */ 11628 @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING) getArchivedPackage(@onNull String packageName)11629 public @Nullable ArchivedPackageInfo getArchivedPackage(@NonNull String packageName) { 11630 throw new UnsupportedOperationException( 11631 "getArchivedPackage not implemented in subclass"); 11632 } 11633 11634 // Some of the flags don't affect the query result, but let's be conservative and cache 11635 // each combination of flags separately. 11636 11637 private static final class ApplicationInfoQuery { 11638 final String packageName; 11639 final long flags; 11640 final int userId; 11641 ApplicationInfoQuery(@ullable String packageName, @ApplicationInfoFlagsBits long flags, int userId)11642 ApplicationInfoQuery(@Nullable String packageName, @ApplicationInfoFlagsBits long flags, 11643 int userId) { 11644 this.packageName = packageName; 11645 this.flags = flags; 11646 this.userId = userId; 11647 } 11648 11649 @Override toString()11650 public String toString() { 11651 return String.format( 11652 "ApplicationInfoQuery(packageName=\"%s\", flags=%s, userId=%s)", 11653 packageName, flags, userId); 11654 } 11655 11656 @Override hashCode()11657 public int hashCode() { 11658 int hash = Objects.hashCode(packageName); 11659 hash = hash * 13 + Objects.hashCode(flags); 11660 hash = hash * 13 + Objects.hashCode(userId); 11661 return hash; 11662 } 11663 11664 @Override equals(@ullable Object rval)11665 public boolean equals(@Nullable Object rval) { 11666 if (rval == null) { 11667 return false; 11668 } 11669 ApplicationInfoQuery other; 11670 try { 11671 other = (ApplicationInfoQuery) rval; 11672 } catch (ClassCastException ex) { 11673 return false; 11674 } 11675 return Objects.equals(packageName, other.packageName) 11676 && flags == other.flags 11677 && userId == other.userId; 11678 } 11679 } 11680 getApplicationInfoAsUserUncached( String packageName, @ApplicationInfoFlagsBits long flags, int userId)11681 private static ApplicationInfo getApplicationInfoAsUserUncached( 11682 String packageName, @ApplicationInfoFlagsBits long flags, int userId) { 11683 try { 11684 return ActivityThread.getPackageManager() 11685 .getApplicationInfo(packageName, flags, userId); 11686 } catch (RemoteException e) { 11687 throw e.rethrowFromSystemServer(); 11688 } 11689 } 11690 packageInfoApi()11691 private static String packageInfoApi() { 11692 return PropertyInvalidatedCache.apiFromProperty( 11693 PermissionManager.CACHE_KEY_PACKAGE_INFO_CACHE); 11694 } 11695 11696 // The maximum number of entries to keep in the packageInfo and applicationInfo caches. 11697 private final static int MAX_INFO_CACHE_ENTRIES = 2048; 11698 11699 /** @hide */ 11700 @VisibleForTesting 11701 public static final PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo> 11702 sApplicationInfoCache = new PropertyInvalidatedCache<>( 11703 new PropertyInvalidatedCache.Args(MODULE_SYSTEM) 11704 .maxEntries(MAX_INFO_CACHE_ENTRIES).api(packageInfoApi()).cacheNulls(true), 11705 "getApplicationInfo", null) { 11706 11707 @Override 11708 public ApplicationInfo recompute(ApplicationInfoQuery query) { 11709 return getApplicationInfoAsUserUncached( 11710 query.packageName, query.flags, query.userId); 11711 } 11712 @Override 11713 public boolean resultEquals(ApplicationInfo cached, ApplicationInfo fetched) { 11714 // Implementing this debug check for ApplicationInfo would require a 11715 // complicated deep comparison, so just bypass it for now. 11716 return true; 11717 } 11718 }; 11719 11720 /** @hide */ getApplicationInfoAsUserCached( String packageName, @ApplicationInfoFlagsBits long flags, int userId)11721 public static ApplicationInfo getApplicationInfoAsUserCached( 11722 String packageName, @ApplicationInfoFlagsBits long flags, int userId) { 11723 return sApplicationInfoCache.query( 11724 new ApplicationInfoQuery(packageName, flags, userId)); 11725 } 11726 11727 /** 11728 * Make getApplicationInfoAsUser() bypass the cache in this process. 11729 * 11730 * @hide 11731 */ disableApplicationInfoCache()11732 public static void disableApplicationInfoCache() { 11733 sApplicationInfoCache.disableLocal(); 11734 } 11735 11736 // Some of the flags don't affect the query result, but let's be conservative and cache 11737 // each combination of flags separately. 11738 11739 private static final class PackageInfoQuery { 11740 final String packageName; 11741 final long flags; 11742 final int userId; 11743 PackageInfoQuery(@ullable String packageName, @PackageInfoFlagsBits long flags, int userId)11744 PackageInfoQuery(@Nullable String packageName, @PackageInfoFlagsBits long flags, int userId) { 11745 this.packageName = packageName; 11746 this.flags = flags; 11747 this.userId = userId; 11748 } 11749 11750 @Override toString()11751 public String toString() { 11752 return String.format( 11753 "PackageInfoQuery(packageName=\"%s\", flags=%s, userId=%s)", 11754 packageName, flags, userId); 11755 } 11756 11757 @Override hashCode()11758 public int hashCode() { 11759 int hash = Objects.hashCode(packageName); 11760 hash = hash * 13 + Objects.hashCode(flags); 11761 hash = hash * 13 + Objects.hashCode(userId); 11762 return hash; 11763 } 11764 11765 @Override equals(@ullable Object rval)11766 public boolean equals(@Nullable Object rval) { 11767 if (rval == null) { 11768 return false; 11769 } 11770 PackageInfoQuery other; 11771 try { 11772 other = (PackageInfoQuery) rval; 11773 } catch (ClassCastException ex) { 11774 return false; 11775 } 11776 return Objects.equals(packageName, other.packageName) 11777 && flags == other.flags 11778 && userId == other.userId; 11779 } 11780 } 11781 getPackageInfoAsUserUncached( String packageName, @PackageInfoFlagsBits long flags, int userId)11782 private static PackageInfo getPackageInfoAsUserUncached( 11783 String packageName, @PackageInfoFlagsBits long flags, int userId) { 11784 try { 11785 return ActivityThread.getPackageManager().getPackageInfo(packageName, flags, userId); 11786 } catch (RemoteException e) { 11787 throw e.rethrowFromSystemServer(); 11788 } 11789 } 11790 11791 private static final PropertyInvalidatedCache<PackageInfoQuery, PackageInfo> 11792 sPackageInfoCache = new PropertyInvalidatedCache<>( 11793 new PropertyInvalidatedCache.Args(MODULE_SYSTEM) 11794 .maxEntries(MAX_INFO_CACHE_ENTRIES).api(packageInfoApi()).cacheNulls(true), 11795 "getPackageInfo", null) { 11796 11797 @Override 11798 public PackageInfo recompute(PackageInfoQuery query) { 11799 return getPackageInfoAsUserUncached( 11800 query.packageName, query.flags, query.userId); 11801 } 11802 @Override 11803 public boolean resultEquals(PackageInfo cached, PackageInfo fetched) { 11804 // Implementing this debug check for PackageInfo would require a 11805 // complicated deep comparison, so just bypass it for now. 11806 return true; 11807 } 11808 }; 11809 11810 /** @hide */ getPackageInfoAsUserCached( String packageName, @PackageInfoFlagsBits long flags, int userId)11811 public static PackageInfo getPackageInfoAsUserCached( 11812 String packageName, @PackageInfoFlagsBits long flags, int userId) { 11813 return sPackageInfoCache.query(new PackageInfoQuery(packageName, flags, userId)); 11814 } 11815 11816 /** 11817 * Make getPackageInfoAsUser() bypass the cache in this process. 11818 * @hide 11819 */ disablePackageInfoCache()11820 public static void disablePackageInfoCache() { 11821 sPackageInfoCache.disableLocal(); 11822 } 11823 11824 /** 11825 * Inhibit package info cache invalidations when correct. 11826 * 11827 * @hide 11828 */ corkPackageInfoCache()11829 public static void corkPackageInfoCache() { 11830 sPackageInfoCache.corkInvalidations(); 11831 } 11832 11833 /** 11834 * Enable package info cache invalidations. 11835 * 11836 * @hide 11837 */ uncorkPackageInfoCache()11838 public static void uncorkPackageInfoCache() { 11839 sPackageInfoCache.uncorkInvalidations(); 11840 } 11841 11842 // This auto-corker is obsolete once the separate permission notifications feature is 11843 // committed. 11844 private static final PropertyInvalidatedCache.AutoCorker sCacheAutoCorker = 11845 PropertyInvalidatedCache.separatePermissionNotificationsEnabled() 11846 ? null 11847 : new PropertyInvalidatedCache 11848 .AutoCorker(PermissionManager.CACHE_KEY_PACKAGE_INFO_CACHE); 11849 11850 /** 11851 * Invalidate caches of package and permission information system-wide. 11852 * 11853 * @hide 11854 */ invalidatePackageInfoCache()11855 public static void invalidatePackageInfoCache() { 11856 if (PropertyInvalidatedCache.separatePermissionNotificationsEnabled()) { 11857 sPackageInfoCache.invalidateCache(); 11858 } else { 11859 sCacheAutoCorker.autoCork(); 11860 } 11861 } 11862 11863 /** 11864 * Returns the token to be used by the subsequent calls to holdLock(). 11865 * @hide 11866 */ 11867 @RequiresPermission(android.Manifest.permission.INJECT_EVENTS) 11868 @TestApi getHoldLockToken()11869 public IBinder getHoldLockToken() { 11870 try { 11871 return ActivityThread.getPackageManager().getHoldLockToken(); 11872 } catch (RemoteException e) { 11873 throw e.rethrowFromSystemServer(); 11874 } 11875 } 11876 11877 /** 11878 * Holds the PM lock for the specified amount of milliseconds. 11879 * Intended for use by the tests that need to imitate lock contention. 11880 * The token should be obtained by 11881 * {@link android.content.pm.PackageManager#getHoldLockToken()}. 11882 * @hide 11883 */ 11884 @TestApi holdLock(IBinder token, int durationMs)11885 public void holdLock(IBinder token, int durationMs) { 11886 try { 11887 ActivityThread.getPackageManager().holdLock(token, durationMs); 11888 } catch (RemoteException e) { 11889 throw e.rethrowFromSystemServer(); 11890 } 11891 } 11892 11893 /** 11894 * Set a list of apps to keep around as APKs even if no user has currently installed it. 11895 * @param packageList List of package names to keep cached. 11896 * 11897 * @hide 11898 */ 11899 @RequiresPermission(android.Manifest.permission.KEEP_UNINSTALLED_PACKAGES) 11900 @TestApi setKeepUninstalledPackages(@onNull List<String> packageList)11901 public void setKeepUninstalledPackages(@NonNull List<String> packageList) { 11902 try { 11903 ActivityThread.getPackageManager().setKeepUninstalledPackages(packageList); 11904 } catch (RemoteException e) { 11905 throw e.rethrowFromSystemServer(); 11906 } 11907 } 11908 11909 /** 11910 * Checks if a package is blocked from uninstall for a particular user. A package can be 11911 * blocked from being uninstalled by a device owner or profile owner. 11912 * See {@link DevicePolicyManager#setUninstallBlocked(ComponentName, String, boolean)}. 11913 * 11914 * @param packageName Name of the package being uninstalled. 11915 * @param user UserHandle who's ability to uninstall a package is being checked. 11916 * 11917 * @hide 11918 */ 11919 @SystemApi 11920 @NonNull canUserUninstall(@onNull String packageName, @NonNull UserHandle user)11921 public boolean canUserUninstall(@NonNull String packageName, @NonNull UserHandle user){ 11922 throw new UnsupportedOperationException( 11923 "canUserUninstall not implemented in subclass"); 11924 } 11925 11926 /** 11927 * See {@link android.provider.Settings.Global#SHOW_NEW_APP_INSTALLED_NOTIFICATION_ENABLED}. 11928 * 11929 * @hide 11930 */ 11931 @SystemApi 11932 @NonNull shouldShowNewAppInstalledNotification()11933 public boolean shouldShowNewAppInstalledNotification() { 11934 throw new UnsupportedOperationException( 11935 "isShowNewAppInstalledNotificationEnabled not implemented in subclass"); 11936 } 11937 11938 /** 11939 * Attempt to relinquish the update ownership of the given package. Only the current 11940 * update owner of the given package can use this API. 11941 * 11942 * @param targetPackage The installed package whose update owner will be changed. 11943 * @throws IllegalArgumentException if the given package is invalid. 11944 * @throws SecurityException if you are not the current update owner of the given package. 11945 * 11946 * @see PackageInstaller.SessionParams#setRequestUpdateOwnership 11947 */ relinquishUpdateOwnership(@onNull String targetPackage)11948 public void relinquishUpdateOwnership(@NonNull String targetPackage) { 11949 throw new UnsupportedOperationException( 11950 "relinquishUpdateOwnership not implemented in subclass"); 11951 } 11952 11953 /** 11954 * Register for notifications of package changes such as install, removal and other events. 11955 * 11956 * @param callback the callback to register for receiving the change events 11957 * @param userId The id of registered user 11958 * @hide 11959 */ registerPackageMonitorCallback(@onNull IRemoteCallback callback, int userId)11960 public void registerPackageMonitorCallback(@NonNull IRemoteCallback callback, int userId) { 11961 throw new UnsupportedOperationException( 11962 "registerPackageMonitorCallback not implemented in subclass"); 11963 } 11964 11965 /** 11966 * Unregister for notifications of package changes such as install, removal and other events. 11967 * 11968 * @param callback the callback to unregister for receiving the change events 11969 * @see #registerPackageMonitorCallback(IRemoteCallback, int) 11970 * @hide 11971 */ unregisterPackageMonitorCallback(@onNull IRemoteCallback callback)11972 public void unregisterPackageMonitorCallback(@NonNull IRemoteCallback callback) { 11973 throw new UnsupportedOperationException( 11974 "unregisterPackageMonitorCallback not implemented in subclass"); 11975 } 11976 11977 /** 11978 * Retrieve AndroidManifest.xml information for the given application apk file. 11979 * 11980 * <p>Example: 11981 * 11982 * <pre><code> 11983 * Bundle result; 11984 * try { 11985 * result = getContext().getPackageManager().parseAndroidManifest(apkFile, 11986 * xmlResourceParser -> { 11987 * Bundle bundle = new Bundle(); 11988 * // Search the start tag 11989 * int type; 11990 * while ((type = xmlResourceParser.next()) != XmlPullParser.START_TAG 11991 * && type != XmlPullParser.END_DOCUMENT) { 11992 * } 11993 * if (type != XmlPullParser.START_TAG) { 11994 * return bundle; 11995 * } 11996 * 11997 * // Start to read the tags and attributes from the xmlResourceParser 11998 * if (!xmlResourceParser.getName().equals("manifest")) { 11999 * return bundle; 12000 * } 12001 * String packageName = xmlResourceParser.getAttributeValue(null, "package"); 12002 * bundle.putString("package", packageName); 12003 * 12004 * // Continue to read the tags and attributes from the xmlResourceParser 12005 * 12006 * return bundle; 12007 * }); 12008 * } catch (IOException e) { 12009 * } 12010 * </code></pre> 12011 * 12012 * Note: When the parserFunction is invoked, the client can read the AndroidManifest.xml 12013 * information by the XmlResourceParser object. After leaving the parserFunction, the 12014 * XmlResourceParser object will be closed. The caller should also handle the exception for 12015 * calling this method. 12016 * 12017 * @param apkFile The file of an application apk. 12018 * @param parserFunction The parserFunction will be invoked with the XmlResourceParser object 12019 * after getting the AndroidManifest.xml of an application package. 12020 * 12021 * @return Returns the result of the {@link Function#apply(Object)}. 12022 * 12023 * @throws IOException if the AndroidManifest.xml of an application package cannot be 12024 * read or accessed. 12025 */ 12026 @FlaggedApi(android.content.pm.Flags.FLAG_GET_PACKAGE_INFO) 12027 @WorkerThread parseAndroidManifest(@onNull File apkFile, @NonNull Function<XmlResourceParser, T> parserFunction)12028 public <T> T parseAndroidManifest(@NonNull File apkFile, 12029 @NonNull Function<XmlResourceParser, T> parserFunction) throws IOException { 12030 throw new UnsupportedOperationException( 12031 "parseAndroidManifest not implemented in subclass"); 12032 } 12033 12034 /** 12035 * Similar to {@link #parseAndroidManifest(File, Function)}, but accepting a file descriptor 12036 * instead of a File object. 12037 * 12038 * @param apkFileDescriptor The file descriptor of an application apk. 12039 * The parserFunction will be invoked with the XmlResourceParser object 12040 * after getting the AndroidManifest.xml of an application package. 12041 * 12042 * @return Returns the result of the {@link Function#apply(Object)}. 12043 * 12044 * @throws IOException if the AndroidManifest.xml of an application package cannot be 12045 * read or accessed. 12046 */ 12047 @FlaggedApi(android.content.pm.Flags.FLAG_GET_PACKAGE_INFO_WITH_FD) 12048 @WorkerThread parseAndroidManifest(@onNull ParcelFileDescriptor apkFileDescriptor, @NonNull Function<XmlResourceParser, T> parserFunction)12049 public <T> T parseAndroidManifest(@NonNull ParcelFileDescriptor apkFileDescriptor, 12050 @NonNull Function<XmlResourceParser, T> parserFunction) throws IOException { 12051 throw new UnsupportedOperationException( 12052 "parseAndroidManifest not implemented in subclass"); 12053 } 12054 12055 /** 12056 * @param info The {@link ServiceInfo} to pull the attributes from. 12057 * @param name The name of the Xml metadata where the attributes are stored. 12058 * @param rootTag The root tag of the attributes. 12059 * @return A {@link TypedArray} of attributes if successful, {@code null} otherwise. 12060 * @hide 12061 */ extractPackageItemInfoAttributes(PackageItemInfo info, String name, String rootTag, int[] attributes)12062 public TypedArray extractPackageItemInfoAttributes(PackageItemInfo info, String name, 12063 String rootTag, int[] attributes) { 12064 throw new UnsupportedOperationException( 12065 "parseServiceMetadata not implemented in subclass"); 12066 } 12067 12068 /** 12069 * Verifies and returns the 12070 * <a href="https://source.android.com/docs/security/features/apksigning">app signing</a> 12071 * information of the file at the given path. This operation takes a few milliseconds. 12072 * 12073 * Unlike {@link #getPackageArchiveInfo(String, PackageInfoFlags)} with {@link 12074 * #GET_SIGNING_CERTIFICATES}, this method does not require the file to be a package archive 12075 * file. 12076 * 12077 * @throws SigningInfoException if the verification fails 12078 */ 12079 @FlaggedApi(android.content.pm.Flags.FLAG_CLOUD_COMPILATION_PM) getVerifiedSigningInfo(@onNull String path, @AppSigningSchemeVersion int minAppSigningSchemeVersion)12080 public static @NonNull SigningInfo getVerifiedSigningInfo(@NonNull String path, 12081 @AppSigningSchemeVersion int minAppSigningSchemeVersion) throws SigningInfoException { 12082 ParseTypeImpl input = ParseTypeImpl.forDefaultParsing(); 12083 ParseResult<SigningDetails> result = 12084 ApkSignatureVerifier.verify(input, path, minAppSigningSchemeVersion); 12085 if (result.isError()) { 12086 throw new SigningInfoException( 12087 result.getErrorCode(), result.getErrorMessage(), result.getException()); 12088 } 12089 return new SigningInfo(result.getResult()); 12090 } 12091 12092 /** 12093 * As the generated feature count is useful for classes that may not be compiled in the same 12094 * annotation processing unit as PackageManager, we redeclare it here for visibility. 12095 * 12096 * @hide 12097 */ 12098 @VisibleForTesting 12099 public static final int SDK_FEATURE_COUNT = 12100 com.android.internal.pm.SystemFeaturesMetadata.SDK_FEATURE_COUNT; 12101 12102 /** 12103 * Returns a stable index for PackageManager-defined features. 12104 * 12105 * <p> Similar to {@link #SDK_FEATURE_COUNT}, we redeclare this utility method generated by the 12106 * annotation processor for internal visibility. 12107 * 12108 * @return index in [0, {@link #SDK_FEATURECOUNT}) for PackageManager-defined features, else -1. 12109 * @hide 12110 */ 12111 @VisibleForTesting maybeGetSdkFeatureIndex(String featureName)12112 public static int maybeGetSdkFeatureIndex(String featureName) { 12113 return com.android.internal.pm.SystemFeaturesMetadata.maybeGetSdkFeatureIndex(featureName); 12114 } 12115 } 12116