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