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 2478 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports 2479 * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware 2480 * at the given feature version. 2481 * 2482 * <p>Known feature versions include: 2483 * <ul> 2484 * <li><code>202009</code>: corresponds to the features included in the Identity Credential 2485 * API shipped in Android 11. 2486 * <li><code>202101</code>: corresponds to the features included in the Identity Credential 2487 * API shipped in Android 12. 2488 * </ul> 2489 */ 2490 @SdkConstant(SdkConstantType.FEATURE) 2491 public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE = 2492 "android.hardware.identity_credential"; 2493 2494 /** 2495 * Feature for {@link #getSystemAvailableFeatures} and 2496 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports 2497 * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware 2498 * with direct access at the given feature version. 2499 * See {@link #FEATURE_IDENTITY_CREDENTIAL_HARDWARE} for known feature versions. 2500 */ 2501 @SdkConstant(SdkConstantType.FEATURE) 2502 public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE_DIRECT_ACCESS = 2503 "android.hardware.identity_credential_direct_access"; 2504 2505 /** 2506 * Feature for {@link #getSystemAvailableFeatures} and 2507 * {@link #hasSystemFeature}: The device supports one or more methods of 2508 * reporting current location. 2509 */ 2510 @SdkConstant(SdkConstantType.FEATURE) 2511 public static final String FEATURE_LOCATION = "android.hardware.location"; 2512 2513 /** 2514 * Feature for {@link #getSystemAvailableFeatures} and 2515 * {@link #hasSystemFeature}: The device has a Global Positioning System 2516 * receiver and can report precise location. 2517 */ 2518 @SdkConstant(SdkConstantType.FEATURE) 2519 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 2520 2521 /** 2522 * Feature for {@link #getSystemAvailableFeatures} and 2523 * {@link #hasSystemFeature}: The device can report location with coarse 2524 * accuracy using a network-based geolocation system. 2525 */ 2526 @SdkConstant(SdkConstantType.FEATURE) 2527 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 2528 2529 /** 2530 * Feature for {@link #getSystemAvailableFeatures} and 2531 * {@link #hasSystemFeature}: The device's 2532 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns 2533 * true. 2534 */ 2535 @SdkConstant(SdkConstantType.FEATURE) 2536 public static final String FEATURE_RAM_LOW = "android.hardware.ram.low"; 2537 2538 /** 2539 * Feature for {@link #getSystemAvailableFeatures} and 2540 * {@link #hasSystemFeature}: The device's 2541 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns 2542 * false. 2543 */ 2544 @SdkConstant(SdkConstantType.FEATURE) 2545 public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal"; 2546 2547 /** 2548 * Feature for {@link #getSystemAvailableFeatures} and 2549 * {@link #hasSystemFeature}: The device can record audio via a 2550 * microphone. 2551 */ 2552 @SdkConstant(SdkConstantType.FEATURE) 2553 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 2554 2555 /** 2556 * Feature for {@link #getSystemAvailableFeatures} and 2557 * {@link #hasSystemFeature}: The device can communicate using Near-Field 2558 * Communications (NFC). 2559 */ 2560 @SdkConstant(SdkConstantType.FEATURE) 2561 public static final String FEATURE_NFC = "android.hardware.nfc"; 2562 2563 /** 2564 * Feature for {@link #getSystemAvailableFeatures} and 2565 * {@link #hasSystemFeature}: The device supports host- 2566 * based NFC card emulation. 2567 * 2568 * TODO remove when depending apps have moved to new constant. 2569 * @hide 2570 * @deprecated 2571 */ 2572 @Deprecated 2573 @SdkConstant(SdkConstantType.FEATURE) 2574 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 2575 2576 /** 2577 * Feature for {@link #getSystemAvailableFeatures} and 2578 * {@link #hasSystemFeature}: The device supports host- 2579 * based NFC card emulation. 2580 */ 2581 @SdkConstant(SdkConstantType.FEATURE) 2582 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 2583 2584 /** 2585 * Feature for {@link #getSystemAvailableFeatures} and 2586 * {@link #hasSystemFeature}: The device supports host- 2587 * based NFC-F card emulation. 2588 */ 2589 @SdkConstant(SdkConstantType.FEATURE) 2590 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef"; 2591 2592 /** 2593 * Feature for {@link #getSystemAvailableFeatures} and 2594 * {@link #hasSystemFeature}: The device supports uicc- 2595 * based NFC card emulation. 2596 */ 2597 @SdkConstant(SdkConstantType.FEATURE) 2598 public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC = 2599 "android.hardware.nfc.uicc"; 2600 2601 /** 2602 * Feature for {@link #getSystemAvailableFeatures} and 2603 * {@link #hasSystemFeature}: The device supports eSE- 2604 * based NFC card emulation. 2605 */ 2606 @SdkConstant(SdkConstantType.FEATURE) 2607 public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE = "android.hardware.nfc.ese"; 2608 2609 /** 2610 * Feature for {@link #getSystemAvailableFeatures} and 2611 * {@link #hasSystemFeature}: The Beam API is enabled on the device. 2612 */ 2613 @SdkConstant(SdkConstantType.FEATURE) 2614 public static final String FEATURE_NFC_BEAM = "android.sofware.nfc.beam"; 2615 2616 /** 2617 * Feature for {@link #getSystemAvailableFeatures} and 2618 * {@link #hasSystemFeature}: The device supports any 2619 * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION}, 2620 * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features. 2621 * 2622 * @hide 2623 */ 2624 @SdkConstant(SdkConstantType.FEATURE) 2625 public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any"; 2626 2627 /** 2628 * Feature for {@link #getSystemAvailableFeatures} and 2629 * {@link #hasSystemFeature}: The device supports Open Mobile API capable UICC-based secure 2630 * elements. 2631 */ 2632 @SdkConstant(SdkConstantType.FEATURE) 2633 public static final String FEATURE_SE_OMAPI_UICC = "android.hardware.se.omapi.uicc"; 2634 2635 /** 2636 * Feature for {@link #getSystemAvailableFeatures} and 2637 * {@link #hasSystemFeature}: The device supports Open Mobile API capable eSE-based secure 2638 * elements. 2639 */ 2640 @SdkConstant(SdkConstantType.FEATURE) 2641 public static final String FEATURE_SE_OMAPI_ESE = "android.hardware.se.omapi.ese"; 2642 2643 /** 2644 * Feature for {@link #getSystemAvailableFeatures} and 2645 * {@link #hasSystemFeature}: The device supports Open Mobile API capable SD-based secure 2646 * elements. 2647 */ 2648 @SdkConstant(SdkConstantType.FEATURE) 2649 public static final String FEATURE_SE_OMAPI_SD = "android.hardware.se.omapi.sd"; 2650 2651 /** 2652 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device is 2653 * compatible with Android’s security model. 2654 * 2655 * <p>See sections 2 and 9 in the 2656 * <a href="https://source.android.com/compatibility/android-cdd">Android CDD</a> for more 2657 * details. 2658 */ 2659 @SdkConstant(SdkConstantType.FEATURE) 2660 public static final String FEATURE_SECURITY_MODEL_COMPATIBLE = 2661 "android.hardware.security.model.compatible"; 2662 2663 /** 2664 * Feature for {@link #getSystemAvailableFeatures} and 2665 * {@link #hasSystemFeature}: The device supports the OpenGL ES 2666 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 2667 * Android Extension Pack</a>. 2668 */ 2669 @SdkConstant(SdkConstantType.FEATURE) 2670 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 2671 2672 /** 2673 * Feature for {@link #getSystemAvailableFeatures} and 2674 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 2675 * implementation on this device is hardware accelerated, and the Vulkan native API will 2676 * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what 2677 * level of optional hardware features limits it supports. 2678 * <p> 2679 * Level 0 includes the base Vulkan requirements as well as: 2680 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul> 2681 * <p> 2682 * Level 1 additionally includes: 2683 * <ul> 2684 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li> 2685 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li> 2686 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li> 2687 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li> 2688 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li> 2689 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li> 2690 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li> 2691 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li> 2692 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li> 2693 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li> 2694 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li> 2695 * </ul> 2696 */ 2697 @SdkConstant(SdkConstantType.FEATURE) 2698 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level"; 2699 2700 /** 2701 * Feature for {@link #getSystemAvailableFeatures} and 2702 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 2703 * implementation on this device is hardware accelerated, and the Vulkan native API will 2704 * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what 2705 * level of optional compute features that device supports beyond the Vulkan 1.0 requirements. 2706 * <p> 2707 * Compute level 0 indicates: 2708 * <ul> 2709 * <li>The {@code VK_KHR_variable_pointers} extension and 2710 * {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are 2711 supported.</li> 2712 * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li> 2713 * </ul> 2714 */ 2715 @SdkConstant(SdkConstantType.FEATURE) 2716 public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute"; 2717 2718 /** 2719 * Feature for {@link #getSystemAvailableFeatures} and 2720 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan 2721 * implementation on this device is hardware accelerated, and the feature version will indicate 2722 * the highest {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices 2723 * that support the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The 2724 * feature version uses the same encoding as Vulkan version numbers: 2725 * <ul> 2726 * <li>Major version number in bits 31-22</li> 2727 * <li>Minor version number in bits 21-12</li> 2728 * <li>Patch version number in bits 11-0</li> 2729 * </ul> 2730 * A version of 1.1.0 or higher also indicates: 2731 * <ul> 2732 * <li>The {@code VK_ANDROID_external_memory_android_hardware_buffer} extension is 2733 * supported.</li> 2734 * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li> 2735 * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is 2736 * supported.</li> 2737 * </ul> 2738 * A subset of devices that support Vulkan 1.1 do so via software emulation. For more 2739 * information, see 2740 * <a href="{@docRoot}ndk/guides/graphics/design-notes">Vulkan Design Guidelines</a>. 2741 */ 2742 @SdkConstant(SdkConstantType.FEATURE) 2743 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version"; 2744 2745 /** 2746 * Feature for {@link #getSystemAvailableFeatures} and 2747 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version 2748 * specifies a date such that the device is known to pass the Vulkan dEQP test suite associated 2749 * with that date. The date is encoded as follows: 2750 * <ul> 2751 * <li>Year in bits 31-16</li> 2752 * <li>Month in bits 15-8</li> 2753 * <li>Day in bits 7-0</li> 2754 * </ul> 2755 * <p> 2756 * Example: 2019-03-01 is encoded as 0x07E30301, and would indicate that the device passes the 2757 * Vulkan dEQP test suite version that was current on 2019-03-01. 2758 */ 2759 @SdkConstant(SdkConstantType.FEATURE) 2760 public static final String FEATURE_VULKAN_DEQP_LEVEL = "android.software.vulkan.deqp.level"; 2761 2762 /** 2763 * Feature for {@link #getSystemAvailableFeatures} and 2764 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version 2765 * specifies a date such that the device is known to pass the OpenGLES dEQP test suite 2766 * associated with that date. The date is encoded as follows: 2767 * <ul> 2768 * <li>Year in bits 31-16</li> 2769 * <li>Month in bits 15-8</li> 2770 * <li>Day in bits 7-0</li> 2771 * </ul> 2772 * <p> 2773 * Example: 2021-03-01 is encoded as 0x07E50301, and would indicate that the device passes the 2774 * OpenGL ES dEQP test suite version that was current on 2021-03-01. 2775 */ 2776 @SdkConstant(SdkConstantType.FEATURE) 2777 public static final String FEATURE_OPENGLES_DEQP_LEVEL = "android.software.opengles.deqp.level"; 2778 2779 /** 2780 * Feature for {@link #getSystemAvailableFeatures} and 2781 * {@link #hasSystemFeature}: The device includes broadcast radio tuner. 2782 * @hide 2783 */ 2784 @SystemApi 2785 @SdkConstant(SdkConstantType.FEATURE) 2786 public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio"; 2787 2788 /** 2789 * Feature for {@link #getSystemAvailableFeatures} and 2790 * {@link #hasSystemFeature}: The device has a secure implementation of keyguard, meaning the 2791 * device supports PIN, pattern and password as defined in Android CDD 2792 */ 2793 @SdkConstant(SdkConstantType.FEATURE) 2794 public static final String FEATURE_SECURE_LOCK_SCREEN = "android.software.secure_lock_screen"; 2795 2796 /** 2797 * Feature for {@link #getSystemAvailableFeatures} and 2798 * {@link #hasSystemFeature}: The device includes an accelerometer. 2799 */ 2800 @SdkConstant(SdkConstantType.FEATURE) 2801 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 2802 2803 /** 2804 * Feature for {@link #getSystemAvailableFeatures} and 2805 * {@link #hasSystemFeature}: The device includes a barometer (air 2806 * pressure sensor.) 2807 */ 2808 @SdkConstant(SdkConstantType.FEATURE) 2809 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 2810 2811 /** 2812 * Feature for {@link #getSystemAvailableFeatures} and 2813 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 2814 */ 2815 @SdkConstant(SdkConstantType.FEATURE) 2816 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 2817 2818 /** 2819 * Feature for {@link #getSystemAvailableFeatures} and 2820 * {@link #hasSystemFeature}: The device includes a gyroscope. 2821 */ 2822 @SdkConstant(SdkConstantType.FEATURE) 2823 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 2824 2825 /** 2826 * Feature for {@link #getSystemAvailableFeatures} and 2827 * {@link #hasSystemFeature}: The device includes a light sensor. 2828 */ 2829 @SdkConstant(SdkConstantType.FEATURE) 2830 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 2831 2832 /** 2833 * Feature for {@link #getSystemAvailableFeatures} and 2834 * {@link #hasSystemFeature}: The device includes a proximity sensor. 2835 */ 2836 @SdkConstant(SdkConstantType.FEATURE) 2837 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 2838 2839 /** 2840 * Feature for {@link #getSystemAvailableFeatures} and 2841 * {@link #hasSystemFeature}: The device includes a hardware step counter. 2842 */ 2843 @SdkConstant(SdkConstantType.FEATURE) 2844 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 2845 2846 /** 2847 * Feature for {@link #getSystemAvailableFeatures} and 2848 * {@link #hasSystemFeature}: The device includes a hardware step detector. 2849 */ 2850 @SdkConstant(SdkConstantType.FEATURE) 2851 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 2852 2853 /** 2854 * Feature for {@link #getSystemAvailableFeatures} and 2855 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 2856 */ 2857 @SdkConstant(SdkConstantType.FEATURE) 2858 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 2859 2860 /** 2861 * Feature for {@link #getSystemAvailableFeatures} and 2862 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram. 2863 */ 2864 @SdkConstant(SdkConstantType.FEATURE) 2865 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 2866 "android.hardware.sensor.heartrate.ecg"; 2867 2868 /** 2869 * Feature for {@link #getSystemAvailableFeatures} and 2870 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 2871 */ 2872 @SdkConstant(SdkConstantType.FEATURE) 2873 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 2874 "android.hardware.sensor.relative_humidity"; 2875 2876 /** 2877 * Feature for {@link #getSystemAvailableFeatures} and 2878 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 2879 */ 2880 @SdkConstant(SdkConstantType.FEATURE) 2881 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 2882 "android.hardware.sensor.ambient_temperature"; 2883 2884 /** 2885 * Feature for {@link #getSystemAvailableFeatures} and 2886 * {@link #hasSystemFeature}: The device includes a hinge angle sensor. 2887 */ 2888 @SdkConstant(SdkConstantType.FEATURE) 2889 public static final String FEATURE_SENSOR_HINGE_ANGLE = "android.hardware.sensor.hinge_angle"; 2890 2891 /** 2892 * Feature for {@link #getSystemAvailableFeatures} and 2893 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 2894 * capabilities. 2895 */ 2896 @SdkConstant(SdkConstantType.FEATURE) 2897 public static final String FEATURE_HIFI_SENSORS = 2898 "android.hardware.sensor.hifi_sensors"; 2899 2900 /** 2901 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2902 * The device supports a hardware mechanism for invoking an assist gesture. 2903 * @see android.provider.Settings.Secure#ASSIST_GESTURE_ENABLED 2904 * @hide 2905 */ 2906 @SdkConstant(SdkConstantType.FEATURE) 2907 public static final String FEATURE_ASSIST_GESTURE = "android.hardware.sensor.assist"; 2908 2909 /** 2910 * Feature for {@link #getSystemAvailableFeatures} and 2911 * {@link #hasSystemFeature}: The device has a telephony radio with data 2912 * communication support. 2913 */ 2914 @SdkConstant(SdkConstantType.FEATURE) 2915 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 2916 2917 /** 2918 * Feature for {@link #getSystemAvailableFeatures} and 2919 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 2920 */ 2921 @SdkConstant(SdkConstantType.FEATURE) 2922 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 2923 2924 /** 2925 * Feature for {@link #getSystemAvailableFeatures} and 2926 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 2927 */ 2928 @SdkConstant(SdkConstantType.FEATURE) 2929 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 2930 2931 /** 2932 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2933 * The device supports telephony carrier restriction mechanism. 2934 * 2935 * <p>Devices declaring this feature must have an implementation of the 2936 * {@link android.telephony.TelephonyManager#getAllowedCarriers} and 2937 * {@link android.telephony.TelephonyManager#setAllowedCarriers}. 2938 * @hide 2939 */ 2940 @SystemApi 2941 @SdkConstant(SdkConstantType.FEATURE) 2942 public static final String FEATURE_TELEPHONY_CARRIERLOCK = 2943 "android.hardware.telephony.carrierlock"; 2944 2945 /** 2946 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 2947 * supports embedded subscriptions on eUICCs. 2948 */ 2949 @SdkConstant(SdkConstantType.FEATURE) 2950 public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc"; 2951 2952 /** 2953 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 2954 * supports cell-broadcast reception using the MBMS APIs. 2955 */ 2956 @SdkConstant(SdkConstantType.FEATURE) 2957 public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms"; 2958 2959 /** 2960 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 2961 * supports attaching to IMS implementations using the ImsService API in telephony. 2962 */ 2963 @SdkConstant(SdkConstantType.FEATURE) 2964 public static final String FEATURE_TELEPHONY_IMS = "android.hardware.telephony.ims"; 2965 2966 /** 2967 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 2968 * supports a single IMS registration as defined by carrier networks in the IMS service 2969 * implementation using the {@link ImsService} API, {@link GbaService} API, and IRadio 1.6 HAL. 2970 * <p> 2971 * When set, the device must fully support the following APIs for an application to implement 2972 * IMS single registration: 2973 * <ul> 2974 * <li> Updating RCS provisioning status using the {@link ProvisioningManager} API to supply an 2975 * RCC.14 defined XML and notify IMS applications of Auto Configuration Server (ACS) or 2976 * proprietary server provisioning updates.</li> 2977 * <li>Opening a delegate in the device IMS service to forward SIP traffic to the carrier's 2978 * network using the {@link SipDelegateManager} API</li> 2979 * <li>Listening to EPS dedicated bearer establishment via the 2980 * {@link ConnectivityManager#registerQosCallback} 2981 * API to indicate to the application when to start/stop media traffic.</li> 2982 * <li>Implementing Generic Bootstrapping Architecture (GBA) and providing the associated 2983 * authentication keys to applications 2984 * requesting this information via the {@link TelephonyManager#bootstrapAuthenticationRequest} 2985 * API</li> 2986 * <li>Implementing RCS User Capability Exchange using the {@link RcsUceAdapter} API</li> 2987 * </ul> 2988 * <p> 2989 * This feature should only be defined if {@link #FEATURE_TELEPHONY_IMS} is also defined. 2990 * @hide 2991 */ 2992 @SystemApi 2993 @SdkConstant(SdkConstantType.FEATURE) 2994 public static final String FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION = 2995 "android.hardware.telephony.ims.singlereg"; 2996 2997 /** 2998 * Feature for {@link #getSystemAvailableFeatures} and 2999 * {@link #hasSystemFeature}: The device is capable of communicating with 3000 * other devices via ultra wideband. 3001 * @hide 3002 */ 3003 @SdkConstant(SdkConstantType.FEATURE) 3004 public static final String FEATURE_UWB = "android.hardware.uwb"; 3005 3006 /** 3007 * Feature for {@link #getSystemAvailableFeatures} and 3008 * {@link #hasSystemFeature}: The device supports connecting to USB devices 3009 * as the USB host. 3010 */ 3011 @SdkConstant(SdkConstantType.FEATURE) 3012 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 3013 3014 /** 3015 * Feature for {@link #getSystemAvailableFeatures} and 3016 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 3017 */ 3018 @SdkConstant(SdkConstantType.FEATURE) 3019 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 3020 3021 /** 3022 * Feature for {@link #getSystemAvailableFeatures} and 3023 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 3024 */ 3025 @SdkConstant(SdkConstantType.FEATURE) 3026 public static final String FEATURE_SIP = "android.software.sip"; 3027 3028 /** 3029 * Feature for {@link #getSystemAvailableFeatures} and 3030 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 3031 */ 3032 @SdkConstant(SdkConstantType.FEATURE) 3033 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 3034 3035 /** 3036 * Feature for {@link #getSystemAvailableFeatures} and 3037 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 3038 */ 3039 @SdkConstant(SdkConstantType.FEATURE) 3040 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 3041 3042 /** 3043 * Feature for {@link #getSystemAvailableFeatures} and 3044 * {@link #hasSystemFeature}: The device's display has a touch screen. 3045 */ 3046 @SdkConstant(SdkConstantType.FEATURE) 3047 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 3048 3049 /** 3050 * Feature for {@link #getSystemAvailableFeatures} and 3051 * {@link #hasSystemFeature}: The device's touch screen supports 3052 * multitouch sufficient for basic two-finger gesture detection. 3053 */ 3054 @SdkConstant(SdkConstantType.FEATURE) 3055 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 3056 3057 /** 3058 * Feature for {@link #getSystemAvailableFeatures} and 3059 * {@link #hasSystemFeature}: The device's touch screen is capable of 3060 * tracking two or more fingers fully independently. 3061 */ 3062 @SdkConstant(SdkConstantType.FEATURE) 3063 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 3064 3065 /** 3066 * Feature for {@link #getSystemAvailableFeatures} and 3067 * {@link #hasSystemFeature}: The device's touch screen is capable of 3068 * tracking a full hand of fingers fully independently -- that is, 5 or 3069 * more simultaneous independent pointers. 3070 */ 3071 @SdkConstant(SdkConstantType.FEATURE) 3072 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 3073 3074 /** 3075 * Feature for {@link #getSystemAvailableFeatures} and 3076 * {@link #hasSystemFeature}: The device does not have a touch screen, but 3077 * does support touch emulation for basic events. For instance, the 3078 * device might use a mouse or remote control to drive a cursor, and 3079 * emulate basic touch pointer events like down, up, drag, etc. All 3080 * devices that support android.hardware.touchscreen or a sub-feature are 3081 * presumed to also support faketouch. 3082 */ 3083 @SdkConstant(SdkConstantType.FEATURE) 3084 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 3085 3086 /** 3087 * Feature for {@link #getSystemAvailableFeatures} and 3088 * {@link #hasSystemFeature}: The device does not have a touch screen, but 3089 * does support touch emulation for basic events that supports distinct 3090 * tracking of two or more fingers. This is an extension of 3091 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 3092 * that unlike a distinct multitouch screen as defined by 3093 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 3094 * devices will not actually provide full two-finger gestures since the 3095 * input is being transformed to cursor movement on the screen. That is, 3096 * single finger gestures will move a cursor; two-finger swipes will 3097 * result in single-finger touch events; other two-finger gestures will 3098 * result in the corresponding two-finger touch event. 3099 */ 3100 @SdkConstant(SdkConstantType.FEATURE) 3101 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 3102 3103 /** 3104 * Feature for {@link #getSystemAvailableFeatures} and 3105 * {@link #hasSystemFeature}: The device does not have a touch screen, but 3106 * does support touch emulation for basic events that supports tracking 3107 * a hand of fingers (5 or more fingers) fully independently. 3108 * This is an extension of 3109 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 3110 * that unlike a multitouch screen as defined by 3111 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 3112 * gestures can be detected due to the limitations described for 3113 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 3114 */ 3115 @SdkConstant(SdkConstantType.FEATURE) 3116 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 3117 3118 /** 3119 * Feature for {@link #getSystemAvailableFeatures} and 3120 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 3121 */ 3122 @SdkConstant(SdkConstantType.FEATURE) 3123 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 3124 3125 /** 3126 * Feature for {@link #getSystemAvailableFeatures} and 3127 * {@link #hasSystemFeature}: The device has biometric hardware to perform face authentication. 3128 */ 3129 @SdkConstant(SdkConstantType.FEATURE) 3130 public static final String FEATURE_FACE = "android.hardware.biometrics.face"; 3131 3132 /** 3133 * Feature for {@link #getSystemAvailableFeatures} and 3134 * {@link #hasSystemFeature}: The device has biometric hardware to perform iris authentication. 3135 */ 3136 @SdkConstant(SdkConstantType.FEATURE) 3137 public static final String FEATURE_IRIS = "android.hardware.biometrics.iris"; 3138 3139 /** 3140 * Feature for {@link #getSystemAvailableFeatures} and 3141 * {@link #hasSystemFeature}: The device supports portrait orientation 3142 * screens. For backwards compatibility, you can assume that if neither 3143 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 3144 * both portrait and landscape. 3145 */ 3146 @SdkConstant(SdkConstantType.FEATURE) 3147 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 3148 3149 /** 3150 * Feature for {@link #getSystemAvailableFeatures} and 3151 * {@link #hasSystemFeature}: The device supports landscape orientation 3152 * screens. For backwards compatibility, you can assume that if neither 3153 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 3154 * both portrait and landscape. 3155 */ 3156 @SdkConstant(SdkConstantType.FEATURE) 3157 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 3158 3159 /** 3160 * Feature for {@link #getSystemAvailableFeatures} and 3161 * {@link #hasSystemFeature}: The device supports live wallpapers. 3162 */ 3163 @SdkConstant(SdkConstantType.FEATURE) 3164 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 3165 /** 3166 * Feature for {@link #getSystemAvailableFeatures} and 3167 * {@link #hasSystemFeature}: The device supports app widgets. 3168 */ 3169 @SdkConstant(SdkConstantType.FEATURE) 3170 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 3171 /** 3172 * Feature for {@link #getSystemAvailableFeatures} and 3173 * {@link #hasSystemFeature}: The device supports the 3174 * {@link android.R.attr#cantSaveState} API. 3175 */ 3176 @SdkConstant(SdkConstantType.FEATURE) 3177 public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state"; 3178 3179 /** 3180 * @hide 3181 * Feature for {@link #getSystemAvailableFeatures} and 3182 * {@link #hasSystemFeature}: The device supports 3183 * {@link android.service.voice.VoiceInteractionService} and 3184 * {@link android.app.VoiceInteractor}. 3185 */ 3186 @SdkConstant(SdkConstantType.FEATURE) 3187 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 3188 3189 3190 /** 3191 * Feature for {@link #getSystemAvailableFeatures} and 3192 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 3193 * by third party applications. 3194 */ 3195 @SdkConstant(SdkConstantType.FEATURE) 3196 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 3197 3198 /** 3199 * Feature for {@link #getSystemAvailableFeatures} and 3200 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 3201 * with the {@link android.inputmethodservice.InputMethodService} API. 3202 */ 3203 @SdkConstant(SdkConstantType.FEATURE) 3204 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 3205 3206 /** 3207 * Feature for {@link #getSystemAvailableFeatures} and 3208 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 3209 */ 3210 @SdkConstant(SdkConstantType.FEATURE) 3211 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 3212 3213 /** 3214 * Feature for {@link #getSystemAvailableFeatures} and 3215 * {@link #hasSystemFeature}: The device supports leanback UI. This is 3216 * typically used in a living room television experience, but is a software 3217 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 3218 * feature will use resources associated with the "television" UI mode. 3219 */ 3220 @SdkConstant(SdkConstantType.FEATURE) 3221 public static final String FEATURE_LEANBACK = "android.software.leanback"; 3222 3223 /** 3224 * Feature for {@link #getSystemAvailableFeatures} and 3225 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 3226 * applications designed for this experience should be run, though this is 3227 * not enforced by the system. 3228 */ 3229 @SdkConstant(SdkConstantType.FEATURE) 3230 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 3231 3232 /** 3233 * Feature for {@link #getSystemAvailableFeatures} and 3234 * {@link #hasSystemFeature}: The device supports live TV and can display 3235 * contents from TV inputs implemented with the 3236 * {@link android.media.tv.TvInputService} API. 3237 */ 3238 @SdkConstant(SdkConstantType.FEATURE) 3239 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 3240 3241 /** 3242 * Feature for {@link #getSystemAvailableFeatures} and 3243 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 3244 */ 3245 @SdkConstant(SdkConstantType.FEATURE) 3246 public static final String FEATURE_WIFI = "android.hardware.wifi"; 3247 3248 /** 3249 * Feature for {@link #getSystemAvailableFeatures} and 3250 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 3251 */ 3252 @SdkConstant(SdkConstantType.FEATURE) 3253 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 3254 3255 /** 3256 * Feature for {@link #getSystemAvailableFeatures} and 3257 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware. 3258 */ 3259 @SdkConstant(SdkConstantType.FEATURE) 3260 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware"; 3261 3262 /** 3263 * Feature for {@link #getSystemAvailableFeatures} and 3264 * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all 3265 * Passpoint related APIs in {@link WifiManager} are supported. Refer to 3266 * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info. 3267 */ 3268 @SdkConstant(SdkConstantType.FEATURE) 3269 public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint"; 3270 3271 /** 3272 * Feature for {@link #getSystemAvailableFeatures} and 3273 * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc). 3274 */ 3275 @SdkConstant(SdkConstantType.FEATURE) 3276 public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt"; 3277 3278 3279 /** 3280 * Feature for {@link #getSystemAvailableFeatures} and 3281 * {@link #hasSystemFeature}: The device supports LoWPAN networking. 3282 * @hide 3283 */ 3284 @SdkConstant(SdkConstantType.FEATURE) 3285 public static final String FEATURE_LOWPAN = "android.hardware.lowpan"; 3286 3287 /** 3288 * Feature for {@link #getSystemAvailableFeatures} and 3289 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 3290 * on a vehicle headunit. A headunit here is defined to be inside a 3291 * vehicle that may or may not be moving. A headunit uses either a 3292 * primary display in the center console and/or additional displays in 3293 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 3294 * have limited size and resolution. The user will likely be focused on 3295 * driving so limiting driver distraction is a primary concern. User input 3296 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 3297 * like interfaces. 3298 */ 3299 @SdkConstant(SdkConstantType.FEATURE) 3300 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 3301 3302 /** 3303 * Feature for {@link #getSystemAvailableFeatures} and 3304 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 3305 * on a television. Television here is defined to be a typical living 3306 * room television experience: displayed on a big screen, where the user 3307 * is sitting far away from it, and the dominant form of input will be 3308 * something like a DPAD, not through touch or mouse. 3309 * @deprecated use {@link #FEATURE_LEANBACK} instead. 3310 */ 3311 @Deprecated 3312 @SdkConstant(SdkConstantType.FEATURE) 3313 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 3314 3315 /** 3316 * Feature for {@link #getSystemAvailableFeatures} and 3317 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 3318 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 3319 * the wrist. The user is very close when interacting with the device. 3320 */ 3321 @SdkConstant(SdkConstantType.FEATURE) 3322 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 3323 3324 /** 3325 * Feature for {@link #getSystemAvailableFeatures} and 3326 * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded 3327 * device is defined as a full stack Android device with or without a display and no 3328 * user-installable apps. 3329 */ 3330 @SdkConstant(SdkConstantType.FEATURE) 3331 public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded"; 3332 3333 /** 3334 * Feature for {@link #getSystemAvailableFeatures} and 3335 * {@link #hasSystemFeature}: This is a device dedicated to be primarily used 3336 * with keyboard, mouse or touchpad. This includes traditional desktop 3337 * computers, laptops and variants such as convertibles or detachables. 3338 * Due to the larger screen, the device will most likely use the 3339 * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well. 3340 */ 3341 @SdkConstant(SdkConstantType.FEATURE) 3342 public static final String FEATURE_PC = "android.hardware.type.pc"; 3343 3344 /** 3345 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3346 * The device supports printing. 3347 */ 3348 @SdkConstant(SdkConstantType.FEATURE) 3349 public static final String FEATURE_PRINTING = "android.software.print"; 3350 3351 /** 3352 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3353 * The device supports {@link android.companion.CompanionDeviceManager#associate associating} 3354 * with devices via {@link android.companion.CompanionDeviceManager}. 3355 */ 3356 @SdkConstant(SdkConstantType.FEATURE) 3357 public static final String FEATURE_COMPANION_DEVICE_SETUP 3358 = "android.software.companion_device_setup"; 3359 3360 /** 3361 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3362 * The device can perform backup and restore operations on installed applications. 3363 */ 3364 @SdkConstant(SdkConstantType.FEATURE) 3365 public static final String FEATURE_BACKUP = "android.software.backup"; 3366 3367 /** 3368 * Feature for {@link #getSystemAvailableFeatures} and 3369 * {@link #hasSystemFeature}: The device supports freeform window management. 3370 * Windows have title bars and can be moved and resized. 3371 */ 3372 // If this feature is present, you also need to set 3373 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 3374 @SdkConstant(SdkConstantType.FEATURE) 3375 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 3376 = "android.software.freeform_window_management"; 3377 3378 /** 3379 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3380 * The device supports picture-in-picture multi-window mode. 3381 */ 3382 @SdkConstant(SdkConstantType.FEATURE) 3383 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 3384 3385 /** 3386 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3387 * The device supports running activities on secondary displays. 3388 */ 3389 @SdkConstant(SdkConstantType.FEATURE) 3390 public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS 3391 = "android.software.activities_on_secondary_displays"; 3392 3393 /** 3394 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3395 * The device supports creating secondary users and managed profiles via 3396 * {@link DevicePolicyManager}. 3397 */ 3398 @SdkConstant(SdkConstantType.FEATURE) 3399 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 3400 3401 /** 3402 * @hide 3403 * TODO: Remove after dependencies updated b/17392243 3404 */ 3405 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 3406 3407 /** 3408 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3409 * The device supports verified boot. 3410 */ 3411 @SdkConstant(SdkConstantType.FEATURE) 3412 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 3413 3414 /** 3415 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3416 * The device supports secure removal of users. When a user is deleted the data associated 3417 * with that user is securely deleted and no longer available. 3418 */ 3419 @SdkConstant(SdkConstantType.FEATURE) 3420 public static final String FEATURE_SECURELY_REMOVES_USERS 3421 = "android.software.securely_removes_users"; 3422 3423 /** {@hide} */ 3424 @TestApi 3425 @SdkConstant(SdkConstantType.FEATURE) 3426 public static final String FEATURE_FILE_BASED_ENCRYPTION 3427 = "android.software.file_based_encryption"; 3428 3429 /** {@hide} */ 3430 @TestApi 3431 @SdkConstant(SdkConstantType.FEATURE) 3432 public static final String FEATURE_ADOPTABLE_STORAGE 3433 = "android.software.adoptable_storage"; 3434 3435 /** 3436 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3437 * The device has a full implementation of the android.webkit.* APIs. Devices 3438 * lacking this feature will not have a functioning WebView implementation. 3439 */ 3440 @SdkConstant(SdkConstantType.FEATURE) 3441 public static final String FEATURE_WEBVIEW = "android.software.webview"; 3442 3443 /** 3444 * Feature for {@link #getSystemAvailableFeatures} and 3445 * {@link #hasSystemFeature}: This device supports ethernet. 3446 */ 3447 @SdkConstant(SdkConstantType.FEATURE) 3448 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 3449 3450 /** 3451 * Feature for {@link #getSystemAvailableFeatures} and 3452 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 3453 * @hide 3454 */ 3455 @TestApi 3456 @SdkConstant(SdkConstantType.FEATURE) 3457 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 3458 3459 /** 3460 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3461 * The device has all of the inputs necessary to be considered a compatible game controller, or 3462 * includes a compatible game controller in the box. 3463 */ 3464 @SdkConstant(SdkConstantType.FEATURE) 3465 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 3466 3467 /** 3468 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3469 * The device has a full implementation of the android.media.midi.* APIs. 3470 */ 3471 @SdkConstant(SdkConstantType.FEATURE) 3472 public static final String FEATURE_MIDI = "android.software.midi"; 3473 3474 /** 3475 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3476 * The device implements an optimized mode for virtual reality (VR) applications that handles 3477 * stereoscopic rendering of notifications, and disables most monocular system UI components 3478 * while a VR application has user focus. 3479 * Devices declaring this feature must include an application implementing a 3480 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 3481 * {@link android.app.Activity#setVrModeEnabled}. 3482 * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead. 3483 */ 3484 @Deprecated 3485 @SdkConstant(SdkConstantType.FEATURE) 3486 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 3487 3488 /** 3489 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3490 * The device implements an optimized mode for virtual reality (VR) applications that handles 3491 * stereoscopic rendering of notifications, disables most monocular system UI components 3492 * while a VR application has user focus and meets extra CDD requirements to provide a 3493 * high-quality VR experience. 3494 * Devices declaring this feature must include an application implementing a 3495 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 3496 * {@link android.app.Activity#setVrModeEnabled}. 3497 * and must meet CDD requirements to provide a high-quality VR experience. 3498 */ 3499 @SdkConstant(SdkConstantType.FEATURE) 3500 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE 3501 = "android.hardware.vr.high_performance"; 3502 3503 /** 3504 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3505 * The device supports autofill of user credentials, addresses, credit cards, etc 3506 * via integration with {@link android.service.autofill.AutofillService autofill 3507 * providers}. 3508 */ 3509 @SdkConstant(SdkConstantType.FEATURE) 3510 public static final String FEATURE_AUTOFILL = "android.software.autofill"; 3511 3512 /** 3513 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3514 * The device implements headtracking suitable for a VR device. 3515 */ 3516 @SdkConstant(SdkConstantType.FEATURE) 3517 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking"; 3518 3519 /** 3520 * Feature for {@link #getSystemAvailableFeatures} and 3521 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements 3522 * the Android Keystore backed by an isolated execution environment. The version indicates 3523 * which features are implemented in the isolated execution environment: 3524 * <ul> 3525 * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support 3526 * for app-generated attestation keys (see {@link 3527 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}). 3528 * <li>41: Hardware enforcement of device-unlocked keys (see {@link 3529 * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}). 3530 * <li>40: Support for wrapped key import (see {@link 3531 * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link 3532 * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}), 3533 * attestation (see {@link 3534 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}), 3535 * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure 3536 * hardware, and support for requiring user authentication before a key can be used. 3537 * </ul> 3538 * This feature version is guaranteed to be set for all devices launching with Android 12 and 3539 * may be set on devices launching with an earlier version. If the feature version is set, it 3540 * will at least have the value 40. If it's not set the device may have a version of 3541 * hardware-backed keystore but it may not support all features listed above. 3542 */ 3543 @SdkConstant(SdkConstantType.FEATURE) 3544 public static final String FEATURE_HARDWARE_KEYSTORE = "android.hardware.hardware_keystore"; 3545 3546 /** 3547 * Feature for {@link #getSystemAvailableFeatures}, {@link #hasSystemFeature(String)}, and 3548 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements 3549 * the Android Keystore backed by a dedicated secure processor referred to as 3550 * <a href="https://source.android.com/security/best-practices/hardware#strongbox-keymaster"> 3551 * StrongBox</a>. If this feature has a version, the version number indicates which features are 3552 * implemented in StrongBox: 3553 * <ul> 3554 * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support 3555 * for app-generated attestation keys (see {@link 3556 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}). 3557 * <li>41: Hardware enforcement of device-unlocked keys (see {@link 3558 * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}). 3559 * <li>40: Support for wrapped key import (see {@link 3560 * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link 3561 * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}), 3562 * attestation (see {@link 3563 * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}), 3564 * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure 3565 * hardware, and support for requiring user authentication before a key can be used. 3566 * </ul> 3567 * If a device has StrongBox, this feature version number is guaranteed to be set for all 3568 * devices launching with Android 12 and may be set on devices launching with an earlier 3569 * version. If the feature version is set, it will at least have the value 40. If it's not 3570 * set the device may have StrongBox but it may not support all features listed above. 3571 */ 3572 @SdkConstant(SdkConstantType.FEATURE) 3573 public static final String FEATURE_STRONGBOX_KEYSTORE = 3574 "android.hardware.strongbox_keystore"; 3575 3576 /** 3577 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3578 * The device does not have slices implementation. 3579 * @hide 3580 */ 3581 @SdkConstant(SdkConstantType.FEATURE) 3582 public static final String FEATURE_SLICES_DISABLED = "android.software.slices_disabled"; 3583 3584 /** 3585 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3586 * The device supports device-unique Keystore attestations. Only available on devices that 3587 * also support {@link #FEATURE_STRONGBOX_KEYSTORE}, and can only be used by device owner 3588 * apps (see {@link android.app.admin.DevicePolicyManager#generateKeyPair}). 3589 * @hide 3590 */ 3591 @SdkConstant(SdkConstantType.FEATURE) 3592 public static final String FEATURE_DEVICE_UNIQUE_ATTESTATION = 3593 "android.hardware.device_unique_attestation"; 3594 3595 /** 3596 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3597 * The device has a Keymaster implementation that supports Device ID attestation. 3598 * 3599 * @see DevicePolicyManager#isDeviceIdAttestationSupported 3600 * @hide 3601 */ 3602 @SdkConstant(SdkConstantType.FEATURE) 3603 public static final String FEATURE_DEVICE_ID_ATTESTATION = 3604 "android.software.device_id_attestation"; 3605 3606 /** 3607 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 3608 * the requisite kernel support for multinetworking-capable IPsec tunnels. 3609 * 3610 * <p>This feature implies that the device supports XFRM Interfaces (CONFIG_XFRM_INTERFACE), or 3611 * VTIs with kernel patches allowing updates of output/set mark via UPDSA. 3612 */ 3613 @SdkConstant(SdkConstantType.FEATURE) 3614 public static final String FEATURE_IPSEC_TUNNELS = "android.software.ipsec_tunnels"; 3615 3616 /** 3617 * Feature for {@link #getSystemAvailableFeatures} and 3618 * {@link #hasSystemFeature}: The device supports a system interface for the user to select 3619 * and bind device control services provided by applications. 3620 * 3621 * @see android.service.controls.ControlsProviderService 3622 */ 3623 @SdkConstant(SdkConstantType.FEATURE) 3624 public static final String FEATURE_CONTROLS = "android.software.controls"; 3625 3626 /** 3627 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 3628 * the requisite hardware support to support reboot escrow of synthetic password for updates. 3629 * 3630 * <p>This feature implies that the device has the RebootEscrow HAL implementation. 3631 * 3632 * @hide 3633 */ 3634 @SystemApi 3635 @SdkConstant(SdkConstantType.FEATURE) 3636 public static final String FEATURE_REBOOT_ESCROW = "android.hardware.reboot_escrow"; 3637 3638 /** 3639 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 3640 * the requisite kernel support to support incremental delivery aka Incremental FileSystem. 3641 * 3642 * feature not present - IncFs is not present on the device. 3643 * 1 - IncFs v1, core features, no PerUid support. Optional in R. 3644 * 2 - IncFs v2, PerUid support, fs-verity support. Required in S. 3645 * 3646 * @see IncrementalManager#isFeatureEnabled 3647 * @see IncrementalManager#getVersion() 3648 * @hide 3649 */ 3650 @SystemApi 3651 @SdkConstant(SdkConstantType.FEATURE) 3652 public static final String FEATURE_INCREMENTAL_DELIVERY = 3653 "android.software.incremental_delivery"; 3654 3655 /** 3656 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 3657 * The device has tuner hardware to support tuner operations. 3658 * 3659 * <p>This feature implies that the device has the tuner HAL implementation. 3660 * 3661 * @hide 3662 */ 3663 @SdkConstant(SdkConstantType.FEATURE) 3664 public static final String FEATURE_TUNER = "android.hardware.tv.tuner"; 3665 3666 /** 3667 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 3668 * the necessary changes to support app enumeration. 3669 * 3670 * @hide 3671 */ 3672 @SdkConstant(SdkConstantType.FEATURE) 3673 public static final String FEATURE_APP_ENUMERATION = "android.software.app_enumeration"; 3674 3675 /** 3676 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 3677 * a Keystore implementation that can only enforce limited use key in hardware with max usage 3678 * count equals to 1. 3679 */ 3680 @SdkConstant(SdkConstantType.FEATURE) 3681 public static final String FEATURE_KEYSTORE_SINGLE_USE_KEY = 3682 "android.hardware.keystore.single_use_key"; 3683 3684 /** 3685 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 3686 * a Keystore implementation that can enforce limited use key in hardware with any max usage 3687 * count (including count equals to 1). 3688 */ 3689 @SdkConstant(SdkConstantType.FEATURE) 3690 public static final String FEATURE_KEYSTORE_LIMITED_USE_KEY = 3691 "android.hardware.keystore.limited_use_key"; 3692 3693 /** 3694 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has 3695 * a Keystore implementation that can create application-specific attestation keys. 3696 * See {@link android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias}. 3697 */ 3698 @SdkConstant(SdkConstantType.FEATURE) 3699 public static final String FEATURE_KEYSTORE_APP_ATTEST_KEY = 3700 "android.hardware.keystore.app_attest_key"; 3701 3702 /** @hide */ 3703 public static final boolean APP_ENUMERATION_ENABLED_BY_DEFAULT = true; 3704 3705 /** 3706 * Extra field name for the URI to a verification file. Passed to a package 3707 * verifier. 3708 * 3709 * @hide 3710 */ 3711 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 3712 3713 /** 3714 * Extra field name for the ID of a package pending verification. Passed to 3715 * a package verifier and is used to call back to 3716 * {@link PackageManager#verifyPendingInstall(int, int)} 3717 */ 3718 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 3719 3720 /** 3721 * Extra field name for the package identifier which is trying to install 3722 * the package. 3723 * 3724 * @hide 3725 */ 3726 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 3727 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 3728 3729 /** 3730 * Extra field name for the requested install flags for a package pending 3731 * verification. Passed to a package verifier. 3732 * 3733 * @hide 3734 */ 3735 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 3736 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 3737 3738 /** 3739 * Extra field name for the uid of who is requesting to install 3740 * the package. 3741 * 3742 * @hide 3743 */ 3744 public static final String EXTRA_VERIFICATION_INSTALLER_UID 3745 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 3746 3747 /** 3748 * Extra field name for the package name of a package pending verification. 3749 * 3750 * @hide 3751 */ 3752 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 3753 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 3754 /** 3755 * Extra field name for the result of a verification, either 3756 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 3757 * Passed to package verifiers after a package is verified. 3758 */ 3759 public static final String EXTRA_VERIFICATION_RESULT 3760 = "android.content.pm.extra.VERIFICATION_RESULT"; 3761 3762 /** 3763 * Extra field name for the version code of a package pending verification. 3764 * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead. 3765 * @hide 3766 */ 3767 @Deprecated 3768 public static final String EXTRA_VERIFICATION_VERSION_CODE 3769 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 3770 3771 /** 3772 * Extra field name for the long version code of a package pending verification. 3773 * 3774 * @hide 3775 */ 3776 public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE = 3777 "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE"; 3778 3779 /** 3780 * Extra field name for the Merkle tree root hash of a package. 3781 * <p>Passed to a package verifier both prior to verification and as a result 3782 * of verification. 3783 * <p>The value of the extra is a specially formatted list: 3784 * {@code filename1:HASH_1;filename2:HASH_2;...;filenameN:HASH_N} 3785 * <p>The extra must include an entry for every APK within an installation. If 3786 * a hash is not physically present, a hash value of {@code 0} will be used. 3787 * <p>The root hash is generated using SHA-256, no salt with a 4096 byte block 3788 * size. See the description of the 3789 * <a href="https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#merkle-tree">fs-verity merkle-tree</a> 3790 * for more details. 3791 * @hide 3792 */ 3793 public static final String EXTRA_VERIFICATION_ROOT_HASH = 3794 "android.content.pm.extra.EXTRA_VERIFICATION_ROOT_HASH"; 3795 3796 /** 3797 * Extra field name for the ID of a intent filter pending verification. 3798 * Passed to an intent filter verifier and is used to call back to 3799 * {@link #verifyIntentFilter} 3800 * 3801 * @deprecated Use DomainVerificationManager APIs. 3802 * @hide 3803 */ 3804 @Deprecated 3805 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 3806 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 3807 3808 /** 3809 * Extra field name for the scheme used for an intent filter pending verification. Passed to 3810 * an intent filter verifier and is used to construct the URI to verify against. 3811 * 3812 * Usually this is "https" 3813 * 3814 * @deprecated Use DomainVerificationManager APIs. 3815 * @hide 3816 */ 3817 @Deprecated 3818 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 3819 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 3820 3821 /** 3822 * Extra field name for the host names to be used for an intent filter pending verification. 3823 * Passed to an intent filter verifier and is used to construct the URI to verify the 3824 * intent filter. 3825 * 3826 * This is a space delimited list of hosts. 3827 * 3828 * @deprecated Use DomainVerificationManager APIs. 3829 * @hide 3830 */ 3831 @Deprecated 3832 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 3833 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 3834 3835 /** 3836 * Extra field name for the package name to be used for an intent filter pending verification. 3837 * Passed to an intent filter verifier and is used to check the verification responses coming 3838 * from the hosts. Each host response will need to include the package name of APK containing 3839 * the intent filter. 3840 * 3841 * @deprecated Use DomainVerificationManager APIs. 3842 * @hide 3843 */ 3844 @Deprecated 3845 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 3846 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 3847 3848 /** 3849 * The action used to request that the user approve a permission request 3850 * from the application. 3851 * 3852 * @hide 3853 */ 3854 @SystemApi 3855 public static final String ACTION_REQUEST_PERMISSIONS = 3856 "android.content.pm.action.REQUEST_PERMISSIONS"; 3857 3858 /** 3859 * The names of the requested permissions. 3860 * <p> 3861 * <strong>Type:</strong> String[] 3862 * </p> 3863 * 3864 * @hide 3865 */ 3866 @SystemApi 3867 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 3868 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 3869 3870 /** 3871 * The results from the permissions request. 3872 * <p> 3873 * <strong>Type:</strong> int[] of #PermissionResult 3874 * </p> 3875 * 3876 * @hide 3877 */ 3878 @SystemApi 3879 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 3880 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 3881 3882 /** 3883 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 3884 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 3885 * the existing definition for the permission. 3886 * @hide 3887 */ 3888 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 3889 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 3890 3891 /** 3892 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 3893 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 3894 * being redundantly defined by the package being installed. 3895 * @hide 3896 */ 3897 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 3898 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 3899 3900 /** 3901 * Permission flag: The permission is set in its current state 3902 * by the user and apps can still request it at runtime. 3903 * 3904 * @hide 3905 */ 3906 @SystemApi 3907 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 3908 3909 /** 3910 * Permission flag: The permission is set in its current state 3911 * by the user and it is fixed, i.e. apps can no longer request 3912 * this permission. 3913 * 3914 * @hide 3915 */ 3916 @SystemApi 3917 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 3918 3919 /** 3920 * Permission flag: The permission is set in its current state 3921 * by device policy and neither apps nor the user can change 3922 * its state. 3923 * 3924 * @hide 3925 */ 3926 @SystemApi 3927 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 3928 3929 /** 3930 * Permission flag: The permission is set in a granted state but 3931 * access to resources it guards is restricted by other means to 3932 * enable revoking a permission on legacy apps that do not support 3933 * runtime permissions. If this permission is upgraded to runtime 3934 * because the app was updated to support runtime permissions, the 3935 * the permission will be revoked in the upgrade process. 3936 * 3937 * @deprecated Renamed to {@link #FLAG_PERMISSION_REVOKED_COMPAT}. 3938 * 3939 * @hide 3940 */ 3941 @Deprecated 3942 @SystemApi 3943 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 3944 3945 /** 3946 * Permission flag: The permission is set in its current state 3947 * because the app is a component that is a part of the system. 3948 * 3949 * @hide 3950 */ 3951 @SystemApi 3952 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 3953 3954 /** 3955 * Permission flag: The permission is granted by default because it 3956 * enables app functionality that is expected to work out-of-the-box 3957 * for providing a smooth user experience. For example, the phone app 3958 * is expected to have the phone permission. 3959 * 3960 * @hide 3961 */ 3962 @SystemApi 3963 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 3964 3965 /** 3966 * Permission flag: The permission has to be reviewed before any of 3967 * the app components can run. 3968 * 3969 * @hide 3970 */ 3971 @SystemApi 3972 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 3973 3974 /** 3975 * Permission flag: The permission has not been explicitly requested by 3976 * the app but has been added automatically by the system. Revoke once 3977 * the app does explicitly request it. 3978 * 3979 * @hide 3980 */ 3981 @TestApi 3982 @SystemApi 3983 public static final int FLAG_PERMISSION_REVOKE_WHEN_REQUESTED = 1 << 7; 3984 3985 /** 3986 * Permission flag: The permission's usage should be made highly visible to the user 3987 * when granted. 3988 * 3989 * @hide 3990 */ 3991 @SystemApi 3992 public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED = 1 << 8; 3993 3994 /** 3995 * Permission flag: The permission's usage should be made highly visible to the user 3996 * when denied. 3997 * 3998 * @hide 3999 */ 4000 @SystemApi 4001 public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED = 1 << 9; 4002 4003 /** 4004 * Permission flag: The permission is restricted but the app is exempt 4005 * from the restriction and is allowed to hold this permission in its 4006 * full form and the exemption is provided by the installer on record. 4007 * 4008 * @hide 4009 */ 4010 @SystemApi 4011 public static final int FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT = 1 << 11; 4012 4013 /** 4014 * Permission flag: The permission is restricted but the app is exempt 4015 * from the restriction and is allowed to hold this permission in its 4016 * full form and the exemption is provided by the system due to its 4017 * permission policy. 4018 * 4019 * @hide 4020 */ 4021 @SystemApi 4022 public static final int FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT = 1 << 12; 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 and the 4027 * exemption is provided by the system when upgrading from an OS version 4028 * where the permission was not restricted to an OS version where the 4029 * permission is restricted. 4030 * 4031 * @hide 4032 */ 4033 @SystemApi 4034 public static final int FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT = 1 << 13; 4035 4036 4037 /** 4038 * Permission flag: The permission is disabled but may be granted. If 4039 * disabled the data protected by the permission should be protected 4040 * by a no-op (empty list, default error, etc) instead of crashing the 4041 * client. 4042 * 4043 * @hide 4044 */ 4045 @SystemApi 4046 public static final int FLAG_PERMISSION_APPLY_RESTRICTION = 1 << 14; 4047 4048 /** 4049 * Permission flag: The permission is granted because the application holds a role. 4050 * 4051 * @hide 4052 */ 4053 @SystemApi 4054 public static final int FLAG_PERMISSION_GRANTED_BY_ROLE = 1 << 15; 4055 4056 /** 4057 * Permission flag: The permission should have been revoked but is kept granted for 4058 * compatibility. The data protected by the permission should be protected by a no-op (empty 4059 * list, default error, etc) instead of crashing the client. The permission will be revoked if 4060 * the app is upgraded to supports it. 4061 * 4062 * @hide 4063 */ 4064 @SystemApi 4065 public static final int FLAG_PERMISSION_REVOKED_COMPAT = FLAG_PERMISSION_REVOKE_ON_UPGRADE; 4066 4067 /** 4068 * Permission flag: The permission is one-time and should be revoked automatically on app 4069 * inactivity 4070 * 4071 * @hide 4072 */ 4073 @SystemApi 4074 public static final int FLAG_PERMISSION_ONE_TIME = 1 << 16; 4075 4076 /** 4077 * Permission flag: Whether permission was revoked by auto-revoke. 4078 * 4079 * @hide 4080 */ 4081 @SystemApi 4082 public static final int FLAG_PERMISSION_AUTO_REVOKED = 1 << 17; 4083 4084 /** 4085 * Permission flag: This location permission is selected as the level of granularity of 4086 * location accuracy. 4087 * Example: If this flag is set for ACCESS_FINE_LOCATION, FINE location is the selected location 4088 * accuracy for location permissions. 4089 * 4090 * @hide 4091 */ 4092 @SystemApi 4093 public static final int FLAG_PERMISSION_SELECTED_LOCATION_ACCURACY = 1 << 19; 4094 4095 /** 4096 * Permission flags: Reserved for use by the permission controller. The platform and any 4097 * packages besides the permission controller should not assume any definition about these 4098 * flags. 4099 * @hide 4100 */ 4101 @SystemApi 4102 public static final int FLAGS_PERMISSION_RESERVED_PERMISSION_CONTROLLER = 1 << 28 | 1 << 29 4103 | 1 << 30 | 1 << 31; 4104 4105 /** 4106 * Permission flags: Bitwise or of all permission flags allowing an 4107 * exemption for a restricted permission. 4108 * @hide 4109 */ 4110 public static final int FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT = 4111 FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT 4112 | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT 4113 | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT; 4114 4115 /** 4116 * Mask for all permission flags. 4117 * 4118 * @hide 4119 * 4120 * @deprecated Don't use - does not capture all flags. 4121 */ 4122 @Deprecated 4123 @SystemApi 4124 public static final int MASK_PERMISSION_FLAGS = 0xFF; 4125 4126 /** 4127 * Mask for all permission flags. 4128 * 4129 * @hide 4130 */ 4131 public static final int MASK_PERMISSION_FLAGS_ALL = FLAG_PERMISSION_USER_SET 4132 | FLAG_PERMISSION_USER_FIXED 4133 | FLAG_PERMISSION_POLICY_FIXED 4134 | FLAG_PERMISSION_REVOKE_ON_UPGRADE 4135 | FLAG_PERMISSION_SYSTEM_FIXED 4136 | FLAG_PERMISSION_GRANTED_BY_DEFAULT 4137 | FLAG_PERMISSION_REVIEW_REQUIRED 4138 | FLAG_PERMISSION_REVOKE_WHEN_REQUESTED 4139 | FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED 4140 | FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED 4141 | FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT 4142 | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT 4143 | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT 4144 | FLAG_PERMISSION_APPLY_RESTRICTION 4145 | FLAG_PERMISSION_GRANTED_BY_ROLE 4146 | FLAG_PERMISSION_REVOKED_COMPAT 4147 | FLAG_PERMISSION_ONE_TIME 4148 | FLAG_PERMISSION_AUTO_REVOKED; 4149 4150 /** 4151 * Injected activity in app that forwards user to setting activity of that app. 4152 * 4153 * @hide 4154 */ 4155 public static final String APP_DETAILS_ACTIVITY_CLASS_NAME = AppDetailsActivity.class.getName(); 4156 4157 /** 4158 * Permission whitelist flag: permissions whitelisted by the system. 4159 * Permissions can also be whitelisted by the installer, on upgrade, or on 4160 * role grant. 4161 * 4162 * <p> 4163 * <strong>Note: </strong>In retrospect it would have been preferred to use 4164 * more inclusive terminology when naming this API. Similar APIs added will 4165 * refrain from using the term "whitelist". 4166 * </p> 4167 */ 4168 public static final int FLAG_PERMISSION_WHITELIST_SYSTEM = 1 << 0; 4169 4170 /** 4171 * Permission whitelist flag: permissions whitelisted by the installer. 4172 * Permissions can also be whitelisted by the system, on upgrade, or on role 4173 * grant. 4174 * 4175 * <p> 4176 * <strong>Note: </strong>In retrospect it would have been preferred to use 4177 * more inclusive terminology when naming this API. Similar APIs added will 4178 * refrain from using the term "whitelist". 4179 * </p> 4180 */ 4181 public static final int FLAG_PERMISSION_WHITELIST_INSTALLER = 1 << 1; 4182 4183 /** 4184 * Permission whitelist flag: permissions whitelisted by the system 4185 * when upgrading from an OS version where the permission was not 4186 * restricted to an OS version where the permission is restricted. 4187 * Permissions can also be whitelisted by the installer, the system, or on 4188 * role grant. 4189 * 4190 * <p> 4191 * <strong>Note: </strong>In retrospect it would have been preferred to use 4192 * more inclusive terminology when naming this API. Similar APIs added will 4193 * refrain from using the term "whitelist". 4194 * </p> 4195 */ 4196 public static final int FLAG_PERMISSION_WHITELIST_UPGRADE = 1 << 2; 4197 4198 /** @hide */ 4199 @IntDef(flag = true, prefix = {"FLAG_PERMISSION_WHITELIST_"}, value = { 4200 FLAG_PERMISSION_WHITELIST_SYSTEM, 4201 FLAG_PERMISSION_WHITELIST_INSTALLER, 4202 FLAG_PERMISSION_WHITELIST_UPGRADE 4203 }) 4204 @Retention(RetentionPolicy.SOURCE) 4205 public @interface PermissionWhitelistFlags {} 4206 4207 /** 4208 * This is a library that contains components apps can invoke. For 4209 * example, a services for apps to bind to, or standard chooser UI, 4210 * etc. This library is versioned and backwards compatible. Clients 4211 * should check its version via {@link android.ext.services.Version 4212 * #getVersionCode()} and avoid calling APIs added in later versions. 4213 * <p> 4214 * This shared library no longer exists since Android R. 4215 * 4216 * @see #getServicesSystemSharedLibraryPackageName() 4217 * 4218 * @hide 4219 */ 4220 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 4221 @TestApi 4222 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 4223 4224 /** 4225 * This is a library that contains components apps can dynamically 4226 * load. For example, new widgets, helper classes, etc. This library 4227 * is versioned and backwards compatible. Clients should check its 4228 * version via {@link android.ext.shared.Version#getVersionCode()} 4229 * and avoid calling APIs added in later versions. 4230 * 4231 * @hide 4232 */ 4233 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 4234 @TestApi 4235 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 4236 4237 /** 4238 * Used when starting a process for an Activity. 4239 * 4240 * @hide 4241 */ 4242 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0; 4243 4244 /** 4245 * Used when starting a process for a Service. 4246 * 4247 * @hide 4248 */ 4249 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1; 4250 4251 /** 4252 * Used when moving a Service to the foreground. 4253 * 4254 * @hide 4255 */ 4256 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2; 4257 4258 /** 4259 * Used when starting a process for a BroadcastReceiver. 4260 * 4261 * @hide 4262 */ 4263 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3; 4264 4265 /** 4266 * Used when starting a process for a ContentProvider. 4267 * 4268 * @hide 4269 */ 4270 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4; 4271 4272 /** 4273 * Used when starting a process for a BroadcastReceiver. 4274 * 4275 * @hide 4276 */ 4277 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5; 4278 4279 /** 4280 * Used with Context.getClassLoader() across Android packages. 4281 * 4282 * @hide 4283 */ 4284 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6; 4285 4286 /** 4287 * Used when starting a package within a process for Instrumentation. 4288 * 4289 * @hide 4290 */ 4291 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7; 4292 4293 /** 4294 * Total number of usage reasons. 4295 * 4296 * @hide 4297 */ 4298 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8; 4299 4300 /** 4301 * Constant for specifying the highest installed package version code. 4302 */ 4303 public static final int VERSION_CODE_HIGHEST = -1; 4304 4305 /** 4306 * Apps targeting Android R and above will need to declare the packages and intents they intend 4307 * to use to get details about other apps on a device. Such declarations must be made via the 4308 * {@code <queries>} tag in the manifest. 4309 * 4310 * @hide 4311 */ 4312 @ChangeId 4313 @EnabledSince(targetSdkVersion = Build.VERSION_CODES.R) 4314 public static final long FILTER_APPLICATION_QUERY = 135549675L; 4315 4316 /** {@hide} */ 4317 @IntDef(prefix = {"SYSTEM_APP_STATE_"}, value = { 4318 SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN, 4319 SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE, 4320 SYSTEM_APP_STATE_INSTALLED, 4321 SYSTEM_APP_STATE_UNINSTALLED 4322 }) 4323 @Retention(RetentionPolicy.SOURCE) 4324 public @interface SystemAppState {} 4325 4326 /** 4327 * Constant for use with {@link #setSystemAppState} to mark a system app as hidden until 4328 * installation. 4329 * @hide 4330 */ 4331 @SystemApi 4332 public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN = 0; 4333 4334 /** 4335 * Constant for use with {@link #setSystemAppState} to mark a system app as not hidden until 4336 * installation. 4337 * @hide 4338 */ 4339 @SystemApi 4340 public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE = 1; 4341 4342 /** 4343 * Constant for use with {@link #setSystemAppState} to change a system app's state to installed. 4344 * @hide 4345 */ 4346 @SystemApi 4347 public static final int SYSTEM_APP_STATE_INSTALLED = 2; 4348 4349 /** 4350 * Constant for use with {@link #setSystemAppState} to change a system app's state to 4351 * uninstalled. 4352 * @hide 4353 */ 4354 @SystemApi 4355 public static final int SYSTEM_APP_STATE_UNINSTALLED = 3; 4356 4357 /** 4358 * A manifest property to control app's participation in {@code adb backup}. Should only 4359 * be used by system / privileged apps. 4360 * 4361 * @hide 4362 */ 4363 public static final String PROPERTY_ALLOW_ADB_BACKUP = "android.backup.ALLOW_ADB_BACKUP"; 4364 4365 /** {@hide} */ getUserId()4366 public int getUserId() { 4367 return UserHandle.myUserId(); 4368 } 4369 4370 /** 4371 * @deprecated Do not instantiate or subclass - obtain an instance from 4372 * {@link Context#getPackageManager} 4373 */ 4374 @Deprecated PackageManager()4375 public PackageManager() {} 4376 4377 /** 4378 * Retrieve overall information about an application package that is 4379 * installed on the system. 4380 * 4381 * @param packageName The full name (i.e. com.google.apps.contacts) of the 4382 * desired package. 4383 * @param flags Additional option flags to modify the data returned. 4384 * @return A PackageInfo object containing information about the package. If 4385 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 4386 * is not found in the list of installed applications, the package 4387 * information is retrieved from the list of uninstalled 4388 * applications (which includes installed applications as well as 4389 * applications with data directory i.e. applications which had been 4390 * deleted with {@code DELETE_KEEP_DATA} flag set). 4391 * @throws NameNotFoundException if a package with the given name cannot be 4392 * found on the system. 4393 */ getPackageInfo(@onNull String packageName, @PackageInfoFlags int flags)4394 public abstract PackageInfo getPackageInfo(@NonNull String packageName, 4395 @PackageInfoFlags int flags) 4396 throws NameNotFoundException; 4397 4398 /** 4399 * Retrieve overall information about an application package that is 4400 * installed on the system. This method can be used for retrieving 4401 * information about packages for which multiple versions can be installed 4402 * at the time. Currently only packages hosting static shared libraries can 4403 * have multiple installed versions. The method can also be used to get info 4404 * for a package that has a single version installed by passing 4405 * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage} 4406 * constructor. 4407 * 4408 * @param versionedPackage The versioned package for which to query. 4409 * @param flags Additional option flags to modify the data returned. 4410 * @return A PackageInfo object containing information about the package. If 4411 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 4412 * is not found in the list of installed applications, the package 4413 * information is retrieved from the list of uninstalled 4414 * applications (which includes installed applications as well as 4415 * applications with data directory i.e. applications which had been 4416 * deleted with {@code DELETE_KEEP_DATA} flag set). 4417 * @throws NameNotFoundException if a package with the given name cannot be 4418 * found on the system. 4419 */ getPackageInfo(@onNull VersionedPackage versionedPackage, @PackageInfoFlags int flags)4420 public abstract PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage, 4421 @PackageInfoFlags int flags) throws NameNotFoundException; 4422 4423 /** 4424 * Retrieve overall information about an application package that is 4425 * installed on the system. 4426 * 4427 * @param packageName The full name (i.e. com.google.apps.contacts) of the 4428 * desired package. 4429 * @param flags Additional option flags to modify the data returned. 4430 * @param userId The user id. 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 * @hide 4441 */ 4442 @SuppressWarnings("HiddenAbstractMethod") 4443 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 4444 @UnsupportedAppUsage getPackageInfoAsUser(@onNull String packageName, @PackageInfoFlags int flags, @UserIdInt int userId)4445 public abstract PackageInfo getPackageInfoAsUser(@NonNull String packageName, 4446 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 4447 4448 /** 4449 * Map from the current package names in use on the device to whatever 4450 * the current canonical name of that package is. 4451 * @param packageNames Array of current names to be mapped. 4452 * @return Returns an array of the same size as the original, containing 4453 * the canonical name for each package. 4454 */ currentToCanonicalPackageNames(@onNull String[] packageNames)4455 public abstract String[] currentToCanonicalPackageNames(@NonNull String[] packageNames); 4456 4457 /** 4458 * Map from a packages canonical name to the current name in use on the device. 4459 * @param packageNames Array of new names to be mapped. 4460 * @return Returns an array of the same size as the original, containing 4461 * the current name for each package. 4462 */ canonicalToCurrentPackageNames(@onNull String[] packageNames)4463 public abstract String[] canonicalToCurrentPackageNames(@NonNull String[] packageNames); 4464 4465 /** 4466 * Returns a "good" intent to launch a front-door activity in a package. 4467 * This is used, for example, to implement an "open" button when browsing 4468 * through packages. The current implementation looks first for a main 4469 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 4470 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 4471 * <code>null</code> if neither are found. 4472 * 4473 * @param packageName The name of the package to inspect. 4474 * 4475 * @return A fully-qualified {@link Intent} that can be used to launch the 4476 * main activity in the package. Returns <code>null</code> if the package 4477 * does not contain such an activity, or if <em>packageName</em> is not 4478 * recognized. 4479 */ getLaunchIntentForPackage(@onNull String packageName)4480 public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName); 4481 4482 /** 4483 * Return a "good" intent to launch a front-door Leanback activity in a 4484 * package, for use for example to implement an "open" button when browsing 4485 * through packages. The current implementation will look for a main 4486 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 4487 * return null if no main leanback activities are found. 4488 * 4489 * @param packageName The name of the package to inspect. 4490 * @return Returns either a fully-qualified Intent that can be used to launch 4491 * the main Leanback activity in the package, or null if the package 4492 * does not contain such an activity. 4493 */ getLeanbackLaunchIntentForPackage(@onNull String packageName)4494 public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName); 4495 4496 /** 4497 * Return a "good" intent to launch a front-door Car activity in a 4498 * package, for use for example to implement an "open" button when browsing 4499 * through packages. The current implementation will look for a main 4500 * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or 4501 * return null if no main car activities are found. 4502 * 4503 * @param packageName The name of the package to inspect. 4504 * @return Returns either a fully-qualified Intent that can be used to launch 4505 * the main Car activity in the package, or null if the package 4506 * does not contain such an activity. 4507 * @hide 4508 */ 4509 @SuppressWarnings("HiddenAbstractMethod") getCarLaunchIntentForPackage(@onNull String packageName)4510 public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName); 4511 4512 /** 4513 * Return an array of all of the POSIX secondary group IDs that have been 4514 * assigned to the given package. 4515 * <p> 4516 * Note that the same package may have different GIDs under different 4517 * {@link UserHandle} on the same device. 4518 * 4519 * @param packageName The full name (i.e. com.google.apps.contacts) of the 4520 * desired package. 4521 * @return Returns an int array of the assigned GIDs, or null if there are 4522 * none. 4523 * @throws NameNotFoundException if a package with the given name cannot be 4524 * found on the system. 4525 */ getPackageGids(@onNull String packageName)4526 public abstract int[] getPackageGids(@NonNull String packageName) 4527 throws NameNotFoundException; 4528 4529 /** 4530 * Return an array of all of the POSIX secondary group IDs that have been 4531 * assigned to the given package. 4532 * <p> 4533 * Note that the same package may have different GIDs under different 4534 * {@link UserHandle} on the same device. 4535 * 4536 * @param packageName The full name (i.e. com.google.apps.contacts) of the 4537 * desired package. 4538 * @return Returns an int array of the assigned gids, or null if there are 4539 * none. 4540 * @throws NameNotFoundException if a package with the given name cannot be 4541 * found on the system. 4542 */ getPackageGids(@onNull String packageName, @PackageInfoFlags int flags)4543 public abstract int[] getPackageGids(@NonNull String packageName, @PackageInfoFlags int flags) 4544 throws NameNotFoundException; 4545 4546 /** 4547 * Return the UID associated with the given package name. 4548 * <p> 4549 * Note that the same package will have different UIDs under different 4550 * {@link UserHandle} on the same device. 4551 * 4552 * @param packageName The full name (i.e. com.google.apps.contacts) of the 4553 * desired package. 4554 * @return Returns an integer UID who owns the given package name. 4555 * @throws NameNotFoundException if a package with the given name can not be 4556 * found on the system. 4557 */ getPackageUid(@onNull String packageName, @PackageInfoFlags int flags)4558 public abstract int getPackageUid(@NonNull String packageName, @PackageInfoFlags int flags) 4559 throws NameNotFoundException; 4560 4561 /** 4562 * Return the UID associated with the given package name. 4563 * <p> 4564 * Note that the same package will have different UIDs under different 4565 * {@link UserHandle} on the same device. 4566 * 4567 * @param packageName The full name (i.e. com.google.apps.contacts) of the 4568 * desired package. 4569 * @param userId The user handle identifier to look up the package under. 4570 * @return Returns an integer UID who owns the given package name. 4571 * @throws NameNotFoundException if a package with the given name can not be 4572 * found on the system. 4573 * @hide 4574 */ 4575 @SuppressWarnings("HiddenAbstractMethod") 4576 @UnsupportedAppUsage getPackageUidAsUser(@onNull String packageName, @UserIdInt int userId)4577 public abstract int getPackageUidAsUser(@NonNull String packageName, @UserIdInt int userId) 4578 throws NameNotFoundException; 4579 4580 /** 4581 * Return the UID associated with the given package name. 4582 * <p> 4583 * Note that the same package will have different UIDs under different 4584 * {@link UserHandle} on the same device. 4585 * 4586 * @param packageName The full name (i.e. com.google.apps.contacts) of the 4587 * desired package. 4588 * @param userId The user handle identifier to look up the package under. 4589 * @return Returns an integer UID who owns the given package name. 4590 * @throws NameNotFoundException if a package with the given name can not be 4591 * found on the system. 4592 * @hide 4593 */ 4594 @SuppressWarnings("HiddenAbstractMethod") 4595 @UnsupportedAppUsage getPackageUidAsUser(@onNull String packageName, @PackageInfoFlags int flags, @UserIdInt int userId)4596 public abstract int getPackageUidAsUser(@NonNull String packageName, 4597 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 4598 4599 /** 4600 * Retrieve all of the information we know about a particular permission. 4601 * 4602 * @param permName The fully qualified name (i.e. com.google.permission.LOGIN) 4603 * of the permission you are interested in. 4604 * @param flags Additional option flags to modify the data returned. 4605 * @return Returns a {@link PermissionInfo} containing information about the 4606 * permission. 4607 * @throws NameNotFoundException if a package with the given name cannot be 4608 * found on the system. 4609 */ 4610 //@Deprecated getPermissionInfo(@onNull String permName, @PermissionInfoFlags int flags)4611 public abstract PermissionInfo getPermissionInfo(@NonNull String permName, 4612 @PermissionInfoFlags int flags) throws NameNotFoundException; 4613 4614 /** 4615 * Query for all of the permissions associated with a particular group. 4616 * 4617 * @param permissionGroup The fully qualified name (i.e. com.google.permission.LOGIN) 4618 * of the permission group you are interested in. Use {@code null} to 4619 * find all of the permissions not associated with a group. 4620 * @param flags Additional option flags to modify the data returned. 4621 * @return Returns a list of {@link PermissionInfo} containing information 4622 * about all of the permissions in the given group. 4623 * @throws NameNotFoundException if a group with the given name cannot be 4624 * found on the system. 4625 */ 4626 //@Deprecated 4627 @NonNull queryPermissionsByGroup(@ullable String permissionGroup, @PermissionInfoFlags int flags)4628 public abstract List<PermissionInfo> queryPermissionsByGroup(@Nullable String permissionGroup, 4629 @PermissionInfoFlags int flags) throws NameNotFoundException; 4630 4631 /** 4632 * Returns true if some permissions are individually controlled. 4633 * 4634 * <p>The user usually grants and revokes permission-groups. If this option is set some 4635 * dangerous system permissions can be revoked/granted by the user separately from their group. 4636 * 4637 * @hide 4638 */ 4639 @SuppressWarnings("HiddenAbstractMethod") 4640 @SystemApi arePermissionsIndividuallyControlled()4641 public abstract boolean arePermissionsIndividuallyControlled(); 4642 4643 /** 4644 * Returns true if wireless consent mode is enabled 4645 * 4646 * @hide 4647 */ 4648 @SuppressWarnings("HiddenAbstractMethod") isWirelessConsentModeEnabled()4649 public abstract boolean isWirelessConsentModeEnabled(); 4650 4651 /** 4652 * Retrieve all of the information we know about a particular group of 4653 * permissions. 4654 * 4655 * @param groupName The fully qualified name (i.e. 4656 * com.google.permission_group.APPS) of the permission you are 4657 * interested in. 4658 * @param flags Additional option flags to modify the data returned. 4659 * @return Returns a {@link PermissionGroupInfo} containing information 4660 * about the permission. 4661 * @throws NameNotFoundException if a package with the given name cannot be 4662 * found on the system. 4663 */ 4664 //@Deprecated 4665 @NonNull getPermissionGroupInfo(@onNull String groupName, @PermissionGroupInfoFlags int flags)4666 public abstract PermissionGroupInfo getPermissionGroupInfo(@NonNull String groupName, 4667 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 4668 4669 /** 4670 * Retrieve all of the known permission groups in the system. 4671 * 4672 * @param flags Additional option flags to modify the data returned. 4673 * @return Returns a list of {@link PermissionGroupInfo} containing 4674 * information about all of the known permission groups. 4675 */ 4676 //@Deprecated 4677 @NonNull getAllPermissionGroups( @ermissionGroupInfoFlags int flags)4678 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 4679 @PermissionGroupInfoFlags int flags); 4680 4681 /** 4682 * Get the platform-defined permissions which belong to a particular permission group. 4683 * 4684 * @param permissionGroupName the permission group whose permissions are desired 4685 * @param executor the {@link Executor} on which to invoke the callback 4686 * @param callback the callback which will receive a list of the platform-defined permissions in 4687 * the group, or empty if the group is not a valid platform-defined permission 4688 * group, or there was an exception 4689 */ getPlatformPermissionsForGroup(@onNull String permissionGroupName, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<List<String>> callback)4690 public void getPlatformPermissionsForGroup(@NonNull String permissionGroupName, 4691 @NonNull @CallbackExecutor Executor executor, 4692 @NonNull Consumer<List<String>> callback) {} 4693 4694 /** 4695 * Get the platform-defined permission group of a particular permission, if the permission is a 4696 * platform-defined permission. 4697 * 4698 * @param permissionName the permission whose group is desired 4699 * @param executor the {@link Executor} on which to invoke the callback 4700 * @param callback the callback which will receive the name of the permission group this 4701 * permission belongs to, or {@code null} if it has no group, is not a 4702 * platform-defined permission, or there was an exception 4703 */ getGroupOfPlatformPermission(@onNull String permissionName, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback)4704 public void getGroupOfPlatformPermission(@NonNull String permissionName, 4705 @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback) {} 4706 4707 /** 4708 * Retrieve all of the information we know about a particular 4709 * package/application. 4710 * 4711 * @param packageName The full name (i.e. com.google.apps.contacts) of an 4712 * application. 4713 * @param flags Additional option flags to modify the data returned. 4714 * @return An {@link ApplicationInfo} containing information about the 4715 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if 4716 * the package is not found in the list of installed applications, 4717 * the application information is retrieved from the list of 4718 * uninstalled applications (which includes installed applications 4719 * as well as applications with data directory i.e. applications 4720 * which had been deleted with {@code DELETE_KEEP_DATA} flag set). 4721 * @throws NameNotFoundException if a package with the given name cannot be 4722 * found on the system. 4723 */ 4724 @NonNull getApplicationInfo(@onNull String packageName, @ApplicationInfoFlags int flags)4725 public abstract ApplicationInfo getApplicationInfo(@NonNull String packageName, 4726 @ApplicationInfoFlags int flags) throws NameNotFoundException; 4727 4728 /** {@hide} */ 4729 @SuppressWarnings("HiddenAbstractMethod") 4730 @NonNull 4731 @UnsupportedAppUsage getApplicationInfoAsUser(@onNull String packageName, @ApplicationInfoFlags int flags, @UserIdInt int userId)4732 public abstract ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 4733 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 4734 4735 /** 4736 * Retrieve all of the information we know about a particular 4737 * package/application, for a specific user. 4738 * 4739 * @param packageName The full name (i.e. com.google.apps.contacts) of an 4740 * application. 4741 * @param flags Additional option flags to modify the data returned. 4742 * @return An {@link ApplicationInfo} containing information about the 4743 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if 4744 * the package is not found in the list of installed applications, 4745 * the application information is retrieved from the list of 4746 * uninstalled applications (which includes installed applications 4747 * as well as applications with data directory i.e. applications 4748 * which had been deleted with {@code DELETE_KEEP_DATA} flag set). 4749 * @throws NameNotFoundException if a package with the given name cannot be 4750 * found on the system. 4751 * @hide 4752 */ 4753 @NonNull 4754 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 4755 @SystemApi getApplicationInfoAsUser(@onNull String packageName, @ApplicationInfoFlags int flags, @NonNull UserHandle user)4756 public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName, 4757 @ApplicationInfoFlags int flags, @NonNull UserHandle user) 4758 throws NameNotFoundException { 4759 return getApplicationInfoAsUser(packageName, flags, user.getIdentifier()); 4760 } 4761 4762 /** 4763 * @return The target SDK version for the given package name. 4764 * @throws NameNotFoundException if a package with the given name cannot be found on the system. 4765 */ 4766 @IntRange(from = 0) getTargetSdkVersion(@onNull String packageName)4767 public int getTargetSdkVersion(@NonNull String packageName) throws NameNotFoundException { 4768 throw new UnsupportedOperationException(); 4769 } 4770 4771 /** 4772 * Retrieve all of the information we know about a particular activity 4773 * class. 4774 * 4775 * @param component The full component name (i.e. 4776 * com.google.apps.contacts/com.google.apps.contacts. 4777 * ContactsList) of an Activity class. 4778 * @param flags Additional option flags to modify the data returned. 4779 * @return An {@link ActivityInfo} containing information about the 4780 * activity. 4781 * @throws NameNotFoundException if a package with the given name cannot be 4782 * found on the system. 4783 */ 4784 @NonNull getActivityInfo(@onNull ComponentName component, @ComponentInfoFlags int flags)4785 public abstract ActivityInfo getActivityInfo(@NonNull ComponentName component, 4786 @ComponentInfoFlags int flags) throws NameNotFoundException; 4787 4788 /** 4789 * Retrieve all of the information we know about a particular receiver 4790 * class. 4791 * 4792 * @param component The full component name (i.e. 4793 * com.google.apps.calendar/com.google.apps.calendar. 4794 * CalendarAlarm) of a Receiver class. 4795 * @param flags Additional option flags to modify the data returned. 4796 * @return An {@link ActivityInfo} containing information about the 4797 * receiver. 4798 * @throws NameNotFoundException if a package with the given name cannot be 4799 * found on the system. 4800 */ 4801 @NonNull getReceiverInfo(@onNull ComponentName component, @ComponentInfoFlags int flags)4802 public abstract ActivityInfo getReceiverInfo(@NonNull ComponentName component, 4803 @ComponentInfoFlags int flags) throws NameNotFoundException; 4804 4805 /** 4806 * Retrieve all of the information we know about a particular service class. 4807 * 4808 * @param component The full component name (i.e. 4809 * com.google.apps.media/com.google.apps.media. 4810 * BackgroundPlayback) of a Service class. 4811 * @param flags Additional option flags to modify the data returned. 4812 * @return A {@link ServiceInfo} object containing information about the 4813 * service. 4814 * @throws NameNotFoundException if the component cannot be found on the system. 4815 */ 4816 @NonNull getServiceInfo(@onNull ComponentName component, @ComponentInfoFlags int flags)4817 public abstract ServiceInfo getServiceInfo(@NonNull ComponentName component, 4818 @ComponentInfoFlags int flags) throws NameNotFoundException; 4819 4820 /** 4821 * Retrieve all of the information we know about a particular content 4822 * provider class. 4823 * 4824 * @param component The full component name (i.e. 4825 * com.google.providers.media/com.google.providers.media. 4826 * MediaProvider) of a ContentProvider class. 4827 * @param flags Additional option flags to modify the data returned. 4828 * @return A {@link ProviderInfo} object containing information about the 4829 * provider. 4830 * @throws NameNotFoundException if a package with the given name cannot be 4831 * found on the system. 4832 */ 4833 @NonNull getProviderInfo(@onNull ComponentName component, @ComponentInfoFlags int flags)4834 public abstract ProviderInfo getProviderInfo(@NonNull ComponentName component, 4835 @ComponentInfoFlags int flags) throws NameNotFoundException; 4836 4837 /** 4838 * Retrieve information for a particular module. 4839 * 4840 * @param packageName The name of the module. 4841 * @param flags Additional option flags to modify the data returned. 4842 * @return A {@link ModuleInfo} object containing information about the 4843 * module. 4844 * @throws NameNotFoundException if a module with the given name cannot be 4845 * found on the system. 4846 */ 4847 @NonNull getModuleInfo(@onNull String packageName, @ModuleInfoFlags int flags)4848 public ModuleInfo getModuleInfo(@NonNull String packageName, @ModuleInfoFlags int flags) 4849 throws NameNotFoundException { 4850 throw new UnsupportedOperationException( 4851 "getModuleInfo not implemented in subclass"); 4852 } 4853 4854 /** 4855 * Return a List of all modules that are installed. 4856 * 4857 * @param flags Additional option flags to modify the data returned. 4858 * @return A {@link List} of {@link ModuleInfo} objects, one for each installed 4859 * module, containing information about the module. In the unlikely case 4860 * there are no installed modules, an empty list is returned. 4861 */ 4862 @NonNull getInstalledModules(@nstalledModulesFlags int flags)4863 public List<ModuleInfo> getInstalledModules(@InstalledModulesFlags int flags) { 4864 throw new UnsupportedOperationException( 4865 "getInstalledModules not implemented in subclass"); 4866 } 4867 4868 /** 4869 * Return a List of all packages that are installed for the current user. 4870 * 4871 * @param flags Additional option flags to modify the data returned. 4872 * @return A List of PackageInfo objects, one for each installed package, 4873 * containing information about the package. In the unlikely case 4874 * there are no installed packages, an empty list is returned. If 4875 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 4876 * information is retrieved from the list of uninstalled 4877 * applications (which includes installed applications as well as 4878 * applications with data directory i.e. applications which had been 4879 * deleted with {@code DELETE_KEEP_DATA} flag set). 4880 */ 4881 @NonNull getInstalledPackages(@ackageInfoFlags int flags)4882 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags); 4883 4884 /** 4885 * Return a List of all installed packages that are currently holding any of 4886 * the given permissions. 4887 * 4888 * @param flags Additional option flags to modify the data returned. 4889 * @return A List of PackageInfo objects, one for each installed package 4890 * that holds any of the permissions that were provided, containing 4891 * information about the package. If no installed packages hold any 4892 * of the permissions, an empty list is returned. If flag 4893 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 4894 * information is retrieved from the list of uninstalled 4895 * applications (which includes installed applications as well as 4896 * applications with data directory i.e. applications which had been 4897 * deleted with {@code DELETE_KEEP_DATA} flag set). 4898 */ 4899 @NonNull getPackagesHoldingPermissions( @onNull String[] permissions, @PackageInfoFlags int flags)4900 public abstract List<PackageInfo> getPackagesHoldingPermissions( 4901 @NonNull String[] permissions, @PackageInfoFlags int flags); 4902 4903 /** 4904 * Return a List of all packages that are installed on the device, for a 4905 * specific user. 4906 * 4907 * @param flags Additional option flags to modify the data returned. 4908 * @param userId The user for whom the installed packages are to be listed 4909 * @return A List of PackageInfo objects, one for each installed package, 4910 * containing information about the package. In the unlikely case 4911 * there are no installed packages, an empty list is returned. If 4912 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 4913 * information is retrieved from the list of uninstalled 4914 * applications (which includes installed applications as well as 4915 * applications with data directory i.e. applications which had been 4916 * deleted with {@code DELETE_KEEP_DATA} flag set). 4917 * @hide 4918 */ 4919 @SuppressWarnings("HiddenAbstractMethod") 4920 @NonNull 4921 @SystemApi 4922 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) getInstalledPackagesAsUser(@ackageInfoFlags int flags, @UserIdInt int userId)4923 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags, 4924 @UserIdInt int userId); 4925 4926 /** 4927 * Check whether a particular package has been granted a particular 4928 * permission. 4929 * 4930 * @param permName The name of the permission you are checking for. 4931 * @param packageName The name of the package you are checking against. 4932 * 4933 * @return If the package has the permission, PERMISSION_GRANTED is 4934 * returned. If it does not have the permission, PERMISSION_DENIED 4935 * is returned. 4936 * 4937 * @see #PERMISSION_GRANTED 4938 * @see #PERMISSION_DENIED 4939 */ 4940 @CheckResult 4941 @PermissionResult checkPermission(@onNull String permName, @NonNull String packageName)4942 public abstract int checkPermission(@NonNull String permName, 4943 @NonNull String packageName); 4944 4945 /** 4946 * Checks whether a particular permissions has been revoked for a 4947 * package by policy. Typically the device owner or the profile owner 4948 * may apply such a policy. The user cannot grant policy revoked 4949 * permissions, hence the only way for an app to get such a permission 4950 * is by a policy change. 4951 * 4952 * @param permName The name of the permission you are checking for. 4953 * @param packageName The name of the package you are checking against. 4954 * 4955 * @return Whether the permission is restricted by policy. 4956 */ 4957 @CheckResult 4958 //@Deprecated isPermissionRevokedByPolicy(@onNull String permName, @NonNull String packageName)4959 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 4960 @NonNull String packageName); 4961 4962 /** 4963 * Gets the package name of the component controlling runtime permissions. 4964 * 4965 * @return the package name of the component controlling runtime permissions 4966 * 4967 * @hide 4968 */ 4969 @NonNull 4970 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4971 @TestApi 4972 @UnsupportedAppUsage getPermissionControllerPackageName()4973 public String getPermissionControllerPackageName() { 4974 throw new RuntimeException("Not implemented. Must override in a subclass."); 4975 } 4976 4977 /** 4978 * Add a new dynamic permission to the system. For this to work, your 4979 * package must have defined a permission tree through the 4980 * {@link android.R.styleable#AndroidManifestPermissionTree 4981 * <permission-tree>} tag in its manifest. A package can only add 4982 * permissions to trees that were defined by either its own package or 4983 * another with the same user id; a permission is in a tree if it 4984 * matches the name of the permission tree + ".": for example, 4985 * "com.foo.bar" is a member of the permission tree "com.foo". 4986 * 4987 * <p>It is good to make your permission tree name descriptive, because you 4988 * are taking possession of that entire set of permission names. Thus, it 4989 * must be under a domain you control, with a suffix that will not match 4990 * any normal permissions that may be declared in any applications that 4991 * are part of that domain. 4992 * 4993 * <p>New permissions must be added before 4994 * any .apks are installed that use those permissions. Permissions you 4995 * add through this method are remembered across reboots of the device. 4996 * If the given permission already exists, the info you supply here 4997 * will be used to update it. 4998 * 4999 * @param info Description of the permission to be added. 5000 * 5001 * @return Returns true if a new permission was created, false if an 5002 * existing one was updated. 5003 * 5004 * @throws SecurityException if you are not allowed to add the 5005 * given permission name. 5006 * 5007 * @see #removePermission(String) 5008 */ 5009 //@Deprecated addPermission(@onNull PermissionInfo info)5010 public abstract boolean addPermission(@NonNull PermissionInfo info); 5011 5012 /** 5013 * Like {@link #addPermission(PermissionInfo)} but asynchronously 5014 * persists the package manager state after returning from the call, 5015 * allowing it to return quicker and batch a series of adds at the 5016 * expense of no guarantee the added permission will be retained if 5017 * the device is rebooted before it is written. 5018 */ 5019 //@Deprecated addPermissionAsync(@onNull PermissionInfo info)5020 public abstract boolean addPermissionAsync(@NonNull PermissionInfo info); 5021 5022 /** 5023 * Removes a permission that was previously added with 5024 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 5025 * -- you are only allowed to remove permissions that you are allowed 5026 * to add. 5027 * 5028 * @param permName The name of the permission to remove. 5029 * 5030 * @throws SecurityException if you are not allowed to remove the 5031 * given permission name. 5032 * 5033 * @see #addPermission(PermissionInfo) 5034 */ 5035 //@Deprecated removePermission(@onNull String permName)5036 public abstract void removePermission(@NonNull String permName); 5037 5038 /** 5039 * Permission flags set when granting or revoking a permission. 5040 * 5041 * @hide 5042 */ 5043 @SystemApi 5044 @IntDef(prefix = { "FLAG_PERMISSION_" }, value = { 5045 FLAG_PERMISSION_USER_SET, 5046 FLAG_PERMISSION_USER_FIXED, 5047 FLAG_PERMISSION_POLICY_FIXED, 5048 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 5049 FLAG_PERMISSION_SYSTEM_FIXED, 5050 FLAG_PERMISSION_GRANTED_BY_DEFAULT, 5051 FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED, 5052 FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED, 5053 /* 5054 FLAG_PERMISSION_REVOKE_WHEN_REQUESED 5055 */ 5056 FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT, 5057 FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT, 5058 FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT, 5059 FLAG_PERMISSION_APPLY_RESTRICTION, 5060 FLAG_PERMISSION_GRANTED_BY_ROLE, 5061 FLAG_PERMISSION_REVOKED_COMPAT, 5062 FLAG_PERMISSION_ONE_TIME, 5063 FLAG_PERMISSION_AUTO_REVOKED 5064 }) 5065 @Retention(RetentionPolicy.SOURCE) 5066 public @interface PermissionFlags {} 5067 5068 /** 5069 * Grant a runtime permission to an application which the application does not 5070 * already have. The permission must have been requested by the application. 5071 * If the application is not allowed to hold the permission, a {@link 5072 * java.lang.SecurityException} is thrown. If the package or permission is 5073 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 5074 * <p> 5075 * <strong>Note: </strong>Using this API requires holding 5076 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is 5077 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 5078 * </p> 5079 * 5080 * @param packageName The package to which to grant the permission. 5081 * @param permName The permission name to grant. 5082 * @param user The user for which to grant the permission. 5083 * 5084 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 5085 * 5086 * @hide 5087 */ 5088 //@Deprecated 5089 @SuppressWarnings("HiddenAbstractMethod") 5090 @SystemApi 5091 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) grantRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user)5092 public abstract void grantRuntimePermission(@NonNull String packageName, 5093 @NonNull String permName, @NonNull UserHandle user); 5094 5095 /** 5096 * Revoke a runtime permission that was previously granted by {@link 5097 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 5098 * permission must have been requested by and granted to the application. 5099 * If the application is not allowed to hold the permission, a {@link 5100 * java.lang.SecurityException} is thrown. If the package or permission is 5101 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 5102 * <p> 5103 * <strong>Note: </strong>Using this API requires holding 5104 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 5105 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 5106 * </p> 5107 * 5108 * @param packageName The package from which to revoke the permission. 5109 * @param permName The permission name to revoke. 5110 * @param user The user for which to revoke the permission. 5111 * 5112 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 5113 * 5114 * @hide 5115 */ 5116 //@Deprecated 5117 @SuppressWarnings("HiddenAbstractMethod") 5118 @SystemApi 5119 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) revokeRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user)5120 public abstract void revokeRuntimePermission(@NonNull String packageName, 5121 @NonNull String permName, @NonNull UserHandle user); 5122 5123 /** 5124 * Revoke a runtime permission that was previously granted by {@link 5125 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 5126 * permission must have been requested by and granted to the application. 5127 * If the application is not allowed to hold the permission, a {@link 5128 * java.lang.SecurityException} is thrown. If the package or permission is 5129 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 5130 * <p> 5131 * <strong>Note: </strong>Using this API requires holding 5132 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 5133 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 5134 * </p> 5135 * 5136 * @param packageName The package from which to revoke the permission. 5137 * @param permName The permission name to revoke. 5138 * @param user The user for which to revoke the permission. 5139 * @param reason The reason for the revoke. 5140 * 5141 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 5142 * 5143 * @hide 5144 */ 5145 //@Deprecated 5146 @SystemApi 5147 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) revokeRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user, @NonNull String reason)5148 public void revokeRuntimePermission(@NonNull String packageName, 5149 @NonNull String permName, @NonNull UserHandle user, @NonNull String reason) { 5150 revokeRuntimePermission(packageName, permName, user); 5151 } 5152 5153 /** 5154 * Gets the state flags associated with a permission. 5155 * 5156 * @param permName The permission for which to get the flags. 5157 * @param packageName The package name for which to get the flags. 5158 * @param user The user for which to get permission flags. 5159 * @return The permission flags. 5160 * 5161 * @hide 5162 */ 5163 //@Deprecated 5164 @SuppressWarnings("HiddenAbstractMethod") 5165 @SystemApi 5166 @RequiresPermission(anyOf = { 5167 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 5168 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS, 5169 android.Manifest.permission.GET_RUNTIME_PERMISSIONS 5170 }) 5171 @PermissionFlags getPermissionFlags(@onNull String permName, @NonNull String packageName, @NonNull UserHandle user)5172 public abstract int getPermissionFlags(@NonNull String permName, 5173 @NonNull String packageName, @NonNull UserHandle user); 5174 5175 /** 5176 * Updates the flags associated with a permission by replacing the flags in 5177 * the specified mask with the provided flag values. 5178 * 5179 * @param permName The permission for which to update the flags. 5180 * @param packageName The package name for which to update the flags. 5181 * @param flagMask The flags which to replace. 5182 * @param flagValues The flags with which to replace. 5183 * @param user The user for which to update the permission flags. 5184 * 5185 * @hide 5186 */ 5187 //@Deprecated 5188 @SuppressWarnings("HiddenAbstractMethod") 5189 @SystemApi 5190 @RequiresPermission(anyOf = { 5191 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 5192 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS 5193 }) updatePermissionFlags(@onNull String permName, @NonNull String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues, @NonNull UserHandle user)5194 public abstract void updatePermissionFlags(@NonNull String permName, 5195 @NonNull String packageName, @PermissionFlags int flagMask, 5196 @PermissionFlags int flagValues, @NonNull UserHandle user); 5197 5198 /** 5199 * Gets the restricted permissions that have been whitelisted and the app 5200 * is allowed to have them granted in their full form. 5201 * 5202 * <p> Permissions can be hard restricted which means that the app cannot hold 5203 * them or soft restricted where the app can hold the permission but in a weaker 5204 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 5205 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 5206 * depends on the permission declaration. Whitelisting a hard restricted permission 5207 * allows for the to hold that permission and whitelisting a soft restricted 5208 * permission allows the app to hold the permission in its full, unrestricted form. 5209 * 5210 * <p><ol>There are four allowlists: 5211 * 5212 * <li>one for cases where the system permission policy whitelists a permission 5213 * This list corresponds to the{@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 5214 * Can only be accessed by pre-installed holders of a dedicated permission. 5215 * 5216 * <li>one for cases where the system whitelists the permission when upgrading 5217 * from an OS version in which the permission was not restricted to an OS version 5218 * in which the permission is restricted. This list corresponds to the {@link 5219 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be accessed by pre-installed 5220 * holders of a dedicated permission or the installer on record. 5221 * 5222 * <li>one for cases where the installer of the package whitelists a permission. 5223 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 5224 * Can be accessed by pre-installed holders of a dedicated permission or the 5225 * installer on record. 5226 * </ol> 5227 * 5228 * <p> 5229 * <strong>Note: </strong>In retrospect it would have been preferred to use 5230 * more inclusive terminology when naming this API. Similar APIs added will 5231 * refrain from using the term "whitelist". 5232 * </p> 5233 * 5234 * @param packageName The app for which to get whitelisted permissions. 5235 * @param whitelistFlag The flag to determine which whitelist to query. Only one flag 5236 * can be passed.s 5237 * @return The whitelisted permissions that are on any of the whitelists you query for. 5238 * 5239 * @see #addWhitelistedRestrictedPermission(String, String, int) 5240 * @see #removeWhitelistedRestrictedPermission(String, String, int) 5241 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 5242 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 5243 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 5244 * 5245 * @throws SecurityException if you try to access a whitelist that you have no access to. 5246 */ 5247 //@Deprecated 5248 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 5249 conditional = true) getWhitelistedRestrictedPermissions( @onNull String packageName, @PermissionWhitelistFlags int whitelistFlag)5250 public @NonNull Set<String> getWhitelistedRestrictedPermissions( 5251 @NonNull String packageName, @PermissionWhitelistFlags int whitelistFlag) { 5252 return Collections.emptySet(); 5253 } 5254 5255 /** 5256 * Adds a whitelisted restricted permission for an app. 5257 * 5258 * <p> Permissions can be hard restricted which means that the app cannot hold 5259 * them or soft restricted where the app can hold the permission but in a weaker 5260 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 5261 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 5262 * depends on the permission declaration. Whitelisting a hard restricted permission 5263 * allows for the to hold that permission and whitelisting a soft restricted 5264 * permission allows the app to hold the permission in its full, unrestricted form. 5265 * 5266 * <p><ol>There are four whitelists: 5267 * 5268 * <li>one for cases where the system permission policy whitelists a permission 5269 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 5270 * Can only be modified by pre-installed holders of a dedicated permission. 5271 * 5272 * <li>one for cases where the system whitelists the permission when upgrading 5273 * from an OS version in which the permission was not restricted to an OS version 5274 * in which the permission is restricted. This list corresponds to the {@link 5275 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 5276 * holders of a dedicated permission. The installer on record can only remove 5277 * permissions from this whitelist. 5278 * 5279 * <li>one for cases where the installer of the package whitelists a permission. 5280 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 5281 * Can be modified by pre-installed holders of a dedicated permission or the installer 5282 * on record. 5283 * </ol> 5284 * 5285 * <p>You need to specify the whitelists for which to set the whitelisted permissions 5286 * which will clear the previous whitelisted permissions and replace them with the 5287 * provided ones. 5288 * 5289 * <p> 5290 * <strong>Note: </strong>In retrospect it would have been preferred to use 5291 * more inclusive terminology when naming this API. Similar APIs added will 5292 * refrain from using the term "whitelist". 5293 * </p> 5294 * 5295 * @param packageName The app for which to get whitelisted permissions. 5296 * @param permName The whitelisted permission to add. 5297 * @param whitelistFlags The whitelists to which to add. Passing multiple flags 5298 * updates all specified whitelists. 5299 * @return Whether the permission was added to the whitelist. 5300 * 5301 * @see #getWhitelistedRestrictedPermissions(String, int) 5302 * @see #removeWhitelistedRestrictedPermission(String, String, int) 5303 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 5304 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 5305 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 5306 * 5307 * @throws SecurityException if you try to modify a whitelist that you have no access to. 5308 */ 5309 //@Deprecated 5310 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 5311 conditional = true) addWhitelistedRestrictedPermission(@onNull String packageName, @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags)5312 public boolean addWhitelistedRestrictedPermission(@NonNull String packageName, 5313 @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) { 5314 return false; 5315 } 5316 5317 /** 5318 * Removes a whitelisted restricted permission for an app. 5319 * 5320 * <p> Permissions can be hard restricted which means that the app cannot hold 5321 * them or soft restricted where the app can hold the permission but in a weaker 5322 * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard 5323 * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted} 5324 * depends on the permission declaration. Whitelisting a hard restricted permission 5325 * allows for the to hold that permission and whitelisting a soft restricted 5326 * permission allows the app to hold the permission in its full, unrestricted form. 5327 * 5328 * <p><ol>There are four whitelists: 5329 * 5330 * <li>one for cases where the system permission policy whitelists a permission 5331 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag. 5332 * Can only be modified by pre-installed holders of a dedicated permission. 5333 * 5334 * <li>one for cases where the system whitelists the permission when upgrading 5335 * from an OS version in which the permission was not restricted to an OS version 5336 * in which the permission is restricted. This list corresponds to the {@link 5337 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 5338 * holders of a dedicated permission. The installer on record can only remove 5339 * permissions from this whitelist. 5340 * 5341 * <li>one for cases where the installer of the package whitelists a permission. 5342 * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag. 5343 * Can be modified by pre-installed holders of a dedicated permission or the installer 5344 * on record. 5345 * 5346 * <li>one for cases where the system exempts the permission when upgrading 5347 * from an OS version in which the permission was not restricted to an OS version 5348 * in which the permission is restricted. This list corresponds to the {@link 5349 * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed 5350 * holders of a dedicated permission. The installer on record can only remove 5351 * permissions from this allowlist. 5352 * </ol> 5353 * 5354 * <p>You need to specify the whitelists for which to set the whitelisted permissions 5355 * which will clear the previous whitelisted permissions and replace them with the 5356 * provided ones. 5357 * 5358 * <p> 5359 * <strong>Note: </strong>In retrospect it would have been preferred to use 5360 * more inclusive terminology when naming this API. Similar APIs added will 5361 * refrain from using the term "whitelist". 5362 * </p> 5363 * 5364 * @param packageName The app for which to get whitelisted permissions. 5365 * @param permName The whitelisted permission to remove. 5366 * @param whitelistFlags The whitelists from which to remove. Passing multiple flags 5367 * updates all specified whitelists. 5368 * @return Whether the permission was removed from the whitelist. 5369 * 5370 * @see #getWhitelistedRestrictedPermissions(String, int) 5371 * @see #addWhitelistedRestrictedPermission(String, String, int) 5372 * @see #FLAG_PERMISSION_WHITELIST_SYSTEM 5373 * @see #FLAG_PERMISSION_WHITELIST_UPGRADE 5374 * @see #FLAG_PERMISSION_WHITELIST_INSTALLER 5375 * 5376 * @throws SecurityException if you try to modify a whitelist that you have no access to. 5377 */ 5378 //@Deprecated 5379 @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS, 5380 conditional = true) removeWhitelistedRestrictedPermission(@onNull String packageName, @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags)5381 public boolean removeWhitelistedRestrictedPermission(@NonNull String packageName, 5382 @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) { 5383 return false; 5384 } 5385 5386 /** 5387 * Marks an application exempt from having its permissions be automatically revoked when 5388 * the app is unused for an extended period of time. 5389 * 5390 * Only the installer on record that installed the given package is allowed to call this. 5391 * 5392 * Packages start in whitelisted state, and it is the installer's responsibility to 5393 * un-whitelist the packages it installs, unless auto-revoking permissions from that package 5394 * would cause breakages beyond having to re-request the permission(s). 5395 * 5396 * <p> 5397 * <strong>Note: </strong>In retrospect it would have been preferred to use 5398 * more inclusive terminology when naming this API. Similar APIs added will 5399 * refrain from using the term "whitelist". 5400 * </p> 5401 * 5402 * @param packageName The app for which to set exemption. 5403 * @param whitelisted Whether the app should be whitelisted. 5404 * 5405 * @return whether any change took effect. 5406 * 5407 * @see #isAutoRevokeWhitelisted 5408 * 5409 * @throws SecurityException if you you have no access to modify this. 5410 */ 5411 //@Deprecated 5412 @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS, 5413 conditional = true) setAutoRevokeWhitelisted(@onNull String packageName, boolean whitelisted)5414 public boolean setAutoRevokeWhitelisted(@NonNull String packageName, boolean whitelisted) { 5415 return false; 5416 } 5417 5418 /** 5419 * Checks whether an application is exempt from having its permissions be automatically revoked 5420 * when the app is unused for an extended period of time. 5421 * 5422 * Only the installer on record that installed the given package, or a holder of 5423 * {@code WHITELIST_AUTO_REVOKE_PERMISSIONS} is allowed to call this. 5424 * 5425 * <p> 5426 * <strong>Note: </strong>In retrospect it would have been preferred to use 5427 * more inclusive terminology when naming this API. Similar APIs added will 5428 * refrain from using the term "whitelist". 5429 * </p> 5430 * 5431 * @param packageName The app for which to set exemption. 5432 * 5433 * @return Whether the app is whitelisted. 5434 * 5435 * @see #setAutoRevokeWhitelisted 5436 * 5437 * @throws SecurityException if you you have no access to this. 5438 */ 5439 //@Deprecated 5440 @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS, 5441 conditional = true) isAutoRevokeWhitelisted(@onNull String packageName)5442 public boolean isAutoRevokeWhitelisted(@NonNull String packageName) { 5443 return false; 5444 } 5445 5446 5447 /** 5448 * Gets whether you should show UI with rationale for requesting a permission. 5449 * You should do this only if you do not have the permission and the context in 5450 * which the permission is requested does not clearly communicate to the user 5451 * what would be the benefit from grating this permission. 5452 * 5453 * @param permName A permission your app wants to request. 5454 * @return Whether you can show permission rationale UI. 5455 * 5456 * @hide 5457 */ 5458 //@Deprecated 5459 @SuppressWarnings("HiddenAbstractMethod") 5460 @UnsupportedAppUsage shouldShowRequestPermissionRationale(@onNull String permName)5461 public abstract boolean shouldShowRequestPermissionRationale(@NonNull String permName); 5462 5463 /** 5464 * Gets the localized label that corresponds to the option in settings for granting 5465 * background access. 5466 * 5467 * <p>The intended use is for apps to reference this label in its instruction for users to grant 5468 * a background permission. 5469 * 5470 * @return the localized label that corresponds to the settings option for granting 5471 * background access 5472 */ 5473 @NonNull getBackgroundPermissionOptionLabel()5474 public CharSequence getBackgroundPermissionOptionLabel() { 5475 return ""; 5476 } 5477 5478 /** 5479 * Returns an {@link android.content.Intent} suitable for passing to 5480 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 5481 * which prompts the user to grant permissions to this application. 5482 * 5483 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 5484 * 5485 * @hide 5486 */ 5487 @NonNull 5488 @UnsupportedAppUsage buildRequestPermissionsIntent(@onNull String[] permissions)5489 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 5490 if (ArrayUtils.isEmpty(permissions)) { 5491 throw new IllegalArgumentException("permission cannot be null or empty"); 5492 } 5493 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 5494 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 5495 intent.setPackage(getPermissionControllerPackageName()); 5496 return intent; 5497 } 5498 5499 /** 5500 * Compare the signatures of two packages to determine if the same 5501 * signature appears in both of them. If they do contain the same 5502 * signature, then they are allowed special privileges when working 5503 * with each other: they can share the same user-id, run instrumentation 5504 * against each other, etc. 5505 * 5506 * @param packageName1 First package name whose signature will be compared. 5507 * @param packageName2 Second package name whose signature will be compared. 5508 * 5509 * @return Returns an integer indicating whether all signatures on the 5510 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 5511 * all signatures match or < 0 if there is not a match ({@link 5512 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 5513 * 5514 * @see #checkSignatures(int, int) 5515 */ 5516 @CheckResult 5517 @SignatureResult checkSignatures(@onNull String packageName1, @NonNull String packageName2)5518 public abstract int checkSignatures(@NonNull String packageName1, 5519 @NonNull String packageName2); 5520 5521 /** 5522 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 5523 * the two packages to be checked. This can be useful, for example, 5524 * when doing the check in an IPC, where the UID is the only identity 5525 * available. It is functionally identical to determining the package 5526 * associated with the UIDs and checking their signatures. 5527 * 5528 * @param uid1 First UID whose signature will be compared. 5529 * @param uid2 Second UID whose signature will be compared. 5530 * 5531 * @return Returns an integer indicating whether all signatures on the 5532 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 5533 * all signatures match or < 0 if there is not a match ({@link 5534 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 5535 * 5536 * @see #checkSignatures(String, String) 5537 */ 5538 @CheckResult checkSignatures(int uid1, int uid2)5539 public abstract @SignatureResult int checkSignatures(int uid1, int uid2); 5540 5541 /** 5542 * Retrieve the names of all packages that are associated with a particular 5543 * user id. In most cases, this will be a single package name, the package 5544 * that has been assigned that user id. Where there are multiple packages 5545 * sharing the same user id through the "sharedUserId" mechanism, all 5546 * packages with that id will be returned. 5547 * 5548 * @param uid The user id for which you would like to retrieve the 5549 * associated packages. 5550 * 5551 * @return Returns an array of one or more packages assigned to the user 5552 * id, or null if there are no known packages with the given id. 5553 */ getPackagesForUid(int uid)5554 public abstract @Nullable String[] getPackagesForUid(int uid); 5555 5556 /** 5557 * Retrieve the official name associated with a uid. This name is 5558 * guaranteed to never change, though it is possible for the underlying 5559 * uid to be changed. That is, if you are storing information about 5560 * uids in persistent storage, you should use the string returned 5561 * by this function instead of the raw uid. 5562 * 5563 * @param uid The uid for which you would like to retrieve a name. 5564 * @return Returns a unique name for the given uid, or null if the 5565 * uid is not currently assigned. 5566 */ getNameForUid(int uid)5567 public abstract @Nullable String getNameForUid(int uid); 5568 5569 /** 5570 * Retrieves the official names associated with each given uid. 5571 * @see #getNameForUid(int) 5572 * 5573 * @hide 5574 */ 5575 @SuppressWarnings({"HiddenAbstractMethod", "NullableCollection"}) 5576 @TestApi getNamesForUids(int[] uids)5577 public abstract @Nullable String[] getNamesForUids(int[] uids); 5578 5579 /** 5580 * Return the user id associated with a shared user name. Multiple 5581 * applications can specify a shared user name in their manifest and thus 5582 * end up using a common uid. This might be used for new applications 5583 * that use an existing shared user name and need to know the uid of the 5584 * shared user. 5585 * 5586 * @param sharedUserName The shared user name whose uid is to be retrieved. 5587 * @return Returns the UID associated with the shared user. 5588 * @throws NameNotFoundException if a package with the given name cannot be 5589 * found on the system. 5590 * @hide 5591 */ 5592 @SuppressWarnings("HiddenAbstractMethod") 5593 @UnsupportedAppUsage getUidForSharedUser(@onNull String sharedUserName)5594 public abstract int getUidForSharedUser(@NonNull String sharedUserName) 5595 throws NameNotFoundException; 5596 5597 /** 5598 * Return a List of all application packages that are installed for the 5599 * current user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 5600 * applications including those deleted with {@code DELETE_KEEP_DATA} 5601 * (partially installed apps with data directory) will be returned. 5602 * 5603 * @param flags Additional option flags to modify the data returned. 5604 * @return A List of ApplicationInfo objects, one for each installed 5605 * application. In the unlikely case there are no installed 5606 * packages, an empty list is returned. If flag 5607 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 5608 * information is retrieved from the list of uninstalled 5609 * applications (which includes installed applications as well as 5610 * applications with data directory i.e. applications which had been 5611 * deleted with {@code DELETE_KEEP_DATA} flag set). 5612 */ 5613 @NonNull getInstalledApplications(@pplicationInfoFlags int flags)5614 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 5615 5616 /** 5617 * Return a List of all application packages that are installed on the 5618 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been 5619 * set, a list of all applications including those deleted with 5620 * {@code DELETE_KEEP_DATA} (partially installed apps with data directory) 5621 * will be returned. 5622 * 5623 * @param flags Additional option flags to modify the data returned. 5624 * @param userId The user for whom the installed applications are to be 5625 * listed 5626 * @return A List of ApplicationInfo objects, one for each installed 5627 * application. In the unlikely case there are no installed 5628 * packages, an empty list is returned. If flag 5629 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 5630 * information is retrieved from the list of uninstalled 5631 * applications (which includes installed applications as well as 5632 * applications with data directory i.e. applications which had been 5633 * deleted with {@code DELETE_KEEP_DATA} flag set). 5634 * @hide 5635 */ 5636 @SuppressWarnings("HiddenAbstractMethod") 5637 @NonNull 5638 @TestApi getInstalledApplicationsAsUser( @pplicationInfoFlags int flags, @UserIdInt int userId)5639 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser( 5640 @ApplicationInfoFlags int flags, @UserIdInt int userId); 5641 5642 /** 5643 * Gets the instant applications the user recently used. 5644 * 5645 * @return The instant app list. 5646 * 5647 * @hide 5648 */ 5649 @SuppressWarnings("HiddenAbstractMethod") 5650 @SystemApi 5651 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) getInstantApps()5652 public abstract @NonNull List<InstantAppInfo> getInstantApps(); 5653 5654 /** 5655 * Gets the icon for an instant application. 5656 * 5657 * @param packageName The app package name. 5658 * 5659 * @hide 5660 */ 5661 @SuppressWarnings("HiddenAbstractMethod") 5662 @SystemApi 5663 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) getInstantAppIcon(String packageName)5664 public abstract @Nullable Drawable getInstantAppIcon(String packageName); 5665 5666 /** 5667 * Gets whether this application is an instant app. 5668 * 5669 * @return Whether caller is an instant app. 5670 * 5671 * @see #isInstantApp(String) 5672 * @see #updateInstantAppCookie(byte[]) 5673 * @see #getInstantAppCookie() 5674 * @see #getInstantAppCookieMaxBytes() 5675 */ isInstantApp()5676 public abstract boolean isInstantApp(); 5677 5678 /** 5679 * Gets whether the given package is an instant app. 5680 * 5681 * @param packageName The package to check 5682 * @return Whether the given package is an instant app. 5683 * 5684 * @see #isInstantApp() 5685 * @see #updateInstantAppCookie(byte[]) 5686 * @see #getInstantAppCookie() 5687 * @see #getInstantAppCookieMaxBytes() 5688 * @see #clearInstantAppCookie() 5689 */ isInstantApp(@onNull String packageName)5690 public abstract boolean isInstantApp(@NonNull String packageName); 5691 5692 /** 5693 * Gets the maximum size in bytes of the cookie data an instant app 5694 * can store on the device. 5695 * 5696 * @return The max cookie size in bytes. 5697 * 5698 * @see #isInstantApp() 5699 * @see #isInstantApp(String) 5700 * @see #updateInstantAppCookie(byte[]) 5701 * @see #getInstantAppCookie() 5702 * @see #clearInstantAppCookie() 5703 */ getInstantAppCookieMaxBytes()5704 public abstract int getInstantAppCookieMaxBytes(); 5705 5706 /** 5707 * deprecated 5708 * @hide 5709 */ 5710 @SuppressWarnings("HiddenAbstractMethod") getInstantAppCookieMaxSize()5711 public abstract int getInstantAppCookieMaxSize(); 5712 5713 /** 5714 * Gets the instant application cookie for this app. Non 5715 * instant apps and apps that were instant but were upgraded 5716 * to normal apps can still access this API. For instant apps 5717 * this cookie is cached for some time after uninstall while for 5718 * normal apps the cookie is deleted after the app is uninstalled. 5719 * The cookie is always present while the app is installed. 5720 * 5721 * @return The cookie. 5722 * 5723 * @see #isInstantApp() 5724 * @see #isInstantApp(String) 5725 * @see #updateInstantAppCookie(byte[]) 5726 * @see #getInstantAppCookieMaxBytes() 5727 * @see #clearInstantAppCookie() 5728 */ getInstantAppCookie()5729 public abstract @NonNull byte[] getInstantAppCookie(); 5730 5731 /** 5732 * Clears the instant application cookie for the calling app. 5733 * 5734 * @see #isInstantApp() 5735 * @see #isInstantApp(String) 5736 * @see #getInstantAppCookieMaxBytes() 5737 * @see #getInstantAppCookie() 5738 * @see #clearInstantAppCookie() 5739 */ clearInstantAppCookie()5740 public abstract void clearInstantAppCookie(); 5741 5742 /** 5743 * Updates the instant application cookie for the calling app. Non 5744 * instant apps and apps that were instant but were upgraded 5745 * to normal apps can still access this API. For instant apps 5746 * this cookie is cached for some time after uninstall while for 5747 * normal apps the cookie is deleted after the app is uninstalled. 5748 * The cookie is always present while the app is installed. The 5749 * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}. 5750 * Passing <code>null</code> or an empty array clears the cookie. 5751 * </p> 5752 * 5753 * @param cookie The cookie data. 5754 * 5755 * @see #isInstantApp() 5756 * @see #isInstantApp(String) 5757 * @see #getInstantAppCookieMaxBytes() 5758 * @see #getInstantAppCookie() 5759 * @see #clearInstantAppCookie() 5760 * 5761 * @throws IllegalArgumentException if the array exceeds max cookie size. 5762 */ updateInstantAppCookie(@ullable byte[] cookie)5763 public abstract void updateInstantAppCookie(@Nullable byte[] cookie); 5764 5765 /** 5766 * @removed 5767 */ 5768 @SuppressWarnings("HiddenAbstractMethod") setInstantAppCookie(@ullable byte[] cookie)5769 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie); 5770 5771 /** 5772 * Get a list of shared libraries that are available on the 5773 * system. 5774 * 5775 * @return An array of shared library names that are 5776 * available on the system, or null if none are installed. 5777 * 5778 */ 5779 @Nullable getSystemSharedLibraryNames()5780 public abstract String[] getSystemSharedLibraryNames(); 5781 5782 /** 5783 * Get a list of shared libraries on the device. 5784 * 5785 * @param flags To filter the libraries to return. 5786 * @return The shared library list. 5787 * 5788 * @see #MATCH_UNINSTALLED_PACKAGES 5789 */ getSharedLibraries( @nstallFlags int flags)5790 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries( 5791 @InstallFlags int flags); 5792 5793 /** 5794 * Get a list of shared libraries on the device. 5795 * 5796 * @param flags To filter the libraries to return. 5797 * @param userId The user to query for. 5798 * @return The shared library list. 5799 * 5800 * @see #MATCH_FACTORY_ONLY 5801 * @see #MATCH_KNOWN_PACKAGES 5802 * @see #MATCH_ANY_USER 5803 * @see #MATCH_UNINSTALLED_PACKAGES 5804 * 5805 * @hide 5806 */ 5807 @SuppressWarnings("HiddenAbstractMethod") getSharedLibrariesAsUser( @nstallFlags int flags, @UserIdInt int userId)5808 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser( 5809 @InstallFlags int flags, @UserIdInt int userId); 5810 5811 /** 5812 * Get the list of shared libraries declared by a package. 5813 * 5814 * @param packageName the package name to query 5815 * @param flags the flags to filter packages 5816 * @return the shared library list 5817 * 5818 * @hide 5819 */ 5820 @SuppressWarnings("HiddenAbstractMethod") 5821 @NonNull 5822 @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES) 5823 @SystemApi getDeclaredSharedLibraries(@onNull String packageName, @InstallFlags int flags)5824 public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName, 5825 @InstallFlags int flags) { 5826 throw new UnsupportedOperationException( 5827 "getDeclaredSharedLibraries() not implemented in subclass"); 5828 } 5829 5830 /** 5831 * Get the name of the package hosting the services shared library. 5832 * <p> 5833 * Note that this package is no longer a shared library since Android R. It is now a package 5834 * that hosts for a bunch of updatable services that the system binds to. 5835 * 5836 * @return The library host package. 5837 * 5838 * @hide 5839 */ 5840 @SuppressWarnings("HiddenAbstractMethod") 5841 @UnsupportedAppUsage 5842 @TestApi getServicesSystemSharedLibraryPackageName()5843 public abstract @NonNull String getServicesSystemSharedLibraryPackageName(); 5844 5845 /** 5846 * Get the name of the package hosting the shared components shared library. 5847 * 5848 * @return The library host package. 5849 * 5850 * @hide 5851 */ 5852 @SuppressWarnings("HiddenAbstractMethod") 5853 @UnsupportedAppUsage 5854 @TestApi getSharedSystemSharedLibraryPackageName()5855 public abstract @NonNull String getSharedSystemSharedLibraryPackageName(); 5856 5857 /** 5858 * Returns the names of the packages that have been changed 5859 * [eg. added, removed or updated] since the given sequence 5860 * number. 5861 * <p>If no packages have been changed, returns <code>null</code>. 5862 * <p>The sequence number starts at <code>0</code> and is 5863 * reset every boot. 5864 * @param sequenceNumber The first sequence number for which to retrieve package changes. 5865 * @see android.provider.Settings.Global#BOOT_COUNT 5866 */ getChangedPackages( @ntRangefrom=0) int sequenceNumber)5867 public abstract @Nullable ChangedPackages getChangedPackages( 5868 @IntRange(from=0) int sequenceNumber); 5869 5870 /** 5871 * Get a list of features that are available on the 5872 * system. 5873 * 5874 * @return An array of FeatureInfo classes describing the features 5875 * that are available on the system, or null if there are none(!!). 5876 */ 5877 @NonNull getSystemAvailableFeatures()5878 public abstract FeatureInfo[] getSystemAvailableFeatures(); 5879 5880 /** 5881 * Check whether the given feature name is one of the available features as 5882 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 5883 * presence of <em>any</em> version of the given feature name; use 5884 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 5885 * 5886 * @return Returns true if the devices supports the feature, else false. 5887 */ hasSystemFeature(@onNull String featureName)5888 public abstract boolean hasSystemFeature(@NonNull String featureName); 5889 5890 /** 5891 * Check whether the given feature name and version is one of the available 5892 * features as returned by {@link #getSystemAvailableFeatures()}. Since 5893 * features are defined to always be backwards compatible, this returns true 5894 * if the available feature version is greater than or equal to the 5895 * requested version. 5896 * 5897 * @return Returns true if the devices supports the feature, else false. 5898 */ hasSystemFeature(@onNull String featureName, int version)5899 public abstract boolean hasSystemFeature(@NonNull String featureName, int version); 5900 5901 /** 5902 * Determine the best action to perform for a given Intent. This is how 5903 * {@link Intent#resolveActivity} finds an activity if a class has not been 5904 * explicitly specified. 5905 * <p> 5906 * <em>Note:</em> if using an implicit Intent (without an explicit 5907 * ComponentName specified), be sure to consider whether to set the 5908 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 5909 * activity in the same way that 5910 * {@link android.content.Context#startActivity(Intent)} and 5911 * {@link android.content.Intent#resolveActivity(PackageManager) 5912 * Intent.resolveActivity(PackageManager)} do. 5913 * </p> 5914 * 5915 * @param intent An intent containing all of the desired specification 5916 * (action, data, type, category, and/or component). 5917 * @param flags Additional option flags to modify the data returned. The 5918 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 5919 * resolution to only those activities that support the 5920 * {@link android.content.Intent#CATEGORY_DEFAULT}. 5921 * @return Returns a ResolveInfo object containing the final activity intent 5922 * that was determined to be the best action. Returns null if no 5923 * matching activity was found. If multiple matching activities are 5924 * found and there is no default set, returns a ResolveInfo object 5925 * containing something else, such as the activity resolver. 5926 */ 5927 @Nullable resolveActivity(@onNull Intent intent, @ResolveInfoFlags int flags)5928 public abstract ResolveInfo resolveActivity(@NonNull Intent intent, 5929 @ResolveInfoFlags int flags); 5930 5931 /** 5932 * Determine the best action to perform for a given Intent for a given user. 5933 * This is how {@link Intent#resolveActivity} finds an activity if a class 5934 * has not been explicitly specified. 5935 * <p> 5936 * <em>Note:</em> if using an implicit Intent (without an explicit 5937 * ComponentName specified), be sure to consider whether to set the 5938 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 5939 * activity in the same way that 5940 * {@link android.content.Context#startActivity(Intent)} and 5941 * {@link android.content.Intent#resolveActivity(PackageManager) 5942 * Intent.resolveActivity(PackageManager)} do. 5943 * </p> 5944 * 5945 * @param intent An intent containing all of the desired specification 5946 * (action, data, type, category, and/or component). 5947 * @param flags Additional option flags to modify the data returned. The 5948 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 5949 * resolution to only those activities that support the 5950 * {@link android.content.Intent#CATEGORY_DEFAULT}. 5951 * @param userId The user id. 5952 * @return Returns a ResolveInfo object containing the final activity intent 5953 * that was determined to be the best action. Returns null if no 5954 * matching activity was found. If multiple matching activities are 5955 * found and there is no default set, returns a ResolveInfo object 5956 * containing something else, such as the activity resolver. 5957 * @hide 5958 */ 5959 @SuppressWarnings("HiddenAbstractMethod") 5960 @Nullable 5961 @UnsupportedAppUsage resolveActivityAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)5962 public abstract ResolveInfo resolveActivityAsUser(@NonNull Intent intent, 5963 @ResolveInfoFlags int flags, @UserIdInt int userId); 5964 5965 /** 5966 * Retrieve all activities that can be performed for the given intent. 5967 * 5968 * @param intent The desired intent as per resolveActivity(). 5969 * @param flags Additional option flags to modify the data returned. The 5970 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 5971 * resolution to only those activities that support the 5972 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 5973 * {@link #MATCH_ALL} to prevent any filtering of the results. 5974 * @return Returns a List of ResolveInfo objects containing one entry for 5975 * each matching activity, ordered from best to worst. In other 5976 * words, the first item is what would be returned by 5977 * {@link #resolveActivity}. If there are no matching activities, an 5978 * empty list is returned. 5979 */ 5980 @NonNull queryIntentActivities(@onNull Intent intent, @ResolveInfoFlags int flags)5981 public abstract List<ResolveInfo> queryIntentActivities(@NonNull Intent intent, 5982 @ResolveInfoFlags int flags); 5983 5984 /** 5985 * Retrieve all activities that can be performed for the given intent, for a 5986 * specific user. 5987 * 5988 * @param intent The desired intent as per resolveActivity(). 5989 * @param flags Additional option flags to modify the data returned. The 5990 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 5991 * resolution to only those activities that support the 5992 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 5993 * {@link #MATCH_ALL} to prevent any filtering of the results. 5994 * @return Returns a List of ResolveInfo objects containing one entry for 5995 * each matching activity, ordered from best to worst. In other 5996 * words, the first item is what would be returned by 5997 * {@link #resolveActivity}. If there are no matching activities, an 5998 * empty list is returned. 5999 * @hide 6000 */ 6001 @SuppressWarnings("HiddenAbstractMethod") 6002 @NonNull 6003 @UnsupportedAppUsage queryIntentActivitiesAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)6004 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 6005 @ResolveInfoFlags int flags, @UserIdInt int userId); 6006 6007 /** 6008 * Retrieve all activities that can be performed for the given intent, for a 6009 * specific user. 6010 * 6011 * @param intent The desired intent as per resolveActivity(). 6012 * @param flags Additional option flags to modify the data returned. The 6013 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 6014 * resolution to only those activities that support the 6015 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 6016 * {@link #MATCH_ALL} to prevent any filtering of the results. 6017 * @param user The user being queried. 6018 * @return Returns a List of ResolveInfo objects containing one entry for 6019 * each matching activity, ordered from best to worst. In other 6020 * words, the first item is what would be returned by 6021 * {@link #resolveActivity}. If there are no matching activities, an 6022 * empty list is returned. 6023 * @hide 6024 */ 6025 @SuppressWarnings("HiddenAbstractMethod") 6026 @NonNull 6027 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 6028 @SystemApi queryIntentActivitiesAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, @NonNull UserHandle user)6029 public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent, 6030 @ResolveInfoFlags int flags, @NonNull UserHandle user) { 6031 return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier()); 6032 } 6033 6034 /** 6035 * Retrieve a set of activities that should be presented to the user as 6036 * similar options. This is like {@link #queryIntentActivities}, except it 6037 * also allows you to supply a list of more explicit Intents that you would 6038 * like to resolve to particular options, and takes care of returning the 6039 * final ResolveInfo list in a reasonable order, with no duplicates, based 6040 * on those inputs. 6041 * 6042 * @param caller The class name of the activity that is making the request. 6043 * This activity will never appear in the output list. Can be 6044 * null. 6045 * @param specifics An array of Intents that should be resolved to the first 6046 * specific results. Can be null. 6047 * @param intent The desired intent as per resolveActivity(). 6048 * @param flags Additional option flags to modify the data returned. The 6049 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 6050 * resolution to only those activities that support the 6051 * {@link android.content.Intent#CATEGORY_DEFAULT}. 6052 * @return Returns a List of ResolveInfo objects containing one entry for 6053 * each matching activity. The list is ordered first by all of the 6054 * intents resolved in <var>specifics</var> and then any additional 6055 * activities that can handle <var>intent</var> but did not get 6056 * included by one of the <var>specifics</var> intents. If there are 6057 * no matching activities, an empty list is returned. 6058 */ 6059 @NonNull queryIntentActivityOptions(@ullable ComponentName caller, @Nullable Intent[] specifics, @NonNull Intent intent, @ResolveInfoFlags int flags)6060 public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller, 6061 @Nullable Intent[] specifics, @NonNull Intent intent, @ResolveInfoFlags int flags); 6062 6063 /** 6064 * Retrieve all receivers that can handle a broadcast of the given intent. 6065 * 6066 * @param intent The desired intent as per resolveActivity(). 6067 * @param flags Additional option flags to modify the data returned. 6068 * @return Returns a List of ResolveInfo objects containing one entry for 6069 * each matching receiver, ordered from best to worst. If there are 6070 * no matching receivers, an empty list or null is returned. 6071 */ 6072 @NonNull queryBroadcastReceivers(@onNull Intent intent, @ResolveInfoFlags int flags)6073 public abstract List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, 6074 @ResolveInfoFlags int flags); 6075 6076 /** 6077 * Retrieve all receivers that can handle a broadcast of the given intent, 6078 * for a specific user. 6079 * 6080 * @param intent The desired intent as per resolveActivity(). 6081 * @param flags Additional option flags to modify the data returned. 6082 * @param userHandle UserHandle of the user being queried. 6083 * @return Returns a List of ResolveInfo objects containing one entry for 6084 * each matching receiver, ordered from best to worst. If there are 6085 * no matching receivers, an empty list or null is returned. 6086 * @hide 6087 */ 6088 @SuppressWarnings("HiddenAbstractMethod") 6089 @NonNull 6090 @SystemApi 6091 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) queryBroadcastReceiversAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, UserHandle userHandle)6092 public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 6093 @ResolveInfoFlags int flags, UserHandle userHandle) { 6094 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 6095 } 6096 6097 /** 6098 * @hide 6099 */ 6100 @SuppressWarnings("HiddenAbstractMethod") 6101 @NonNull 6102 @UnsupportedAppUsage queryBroadcastReceiversAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)6103 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent, 6104 @ResolveInfoFlags int flags, @UserIdInt int userId); 6105 6106 6107 /** @deprecated @hide */ 6108 @NonNull 6109 @Deprecated 6110 @UnsupportedAppUsage queryBroadcastReceivers(@onNull Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)6111 public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, 6112 @ResolveInfoFlags int flags, @UserIdInt int userId) { 6113 final String msg = "Shame on you for calling the hidden API " 6114 + "queryBroadcastReceivers(). Shame!"; 6115 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) { 6116 throw new UnsupportedOperationException(msg); 6117 } else { 6118 Log.d(TAG, msg); 6119 return queryBroadcastReceiversAsUser(intent, flags, userId); 6120 } 6121 } 6122 6123 /** 6124 * Determine the best service to handle for a given Intent. 6125 * 6126 * @param intent An intent containing all of the desired specification 6127 * (action, data, type, category, and/or component). 6128 * @param flags Additional option flags to modify the data returned. 6129 * @return Returns a ResolveInfo object containing the final service intent 6130 * that was determined to be the best action. Returns null if no 6131 * matching service was found. 6132 */ 6133 @Nullable resolveService(@onNull Intent intent, @ResolveInfoFlags int flags)6134 public abstract ResolveInfo resolveService(@NonNull Intent intent, @ResolveInfoFlags int flags); 6135 6136 /** 6137 * @hide 6138 */ 6139 @SuppressWarnings("HiddenAbstractMethod") 6140 @Nullable resolveServiceAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)6141 public abstract ResolveInfo resolveServiceAsUser(@NonNull Intent intent, 6142 @ResolveInfoFlags int flags, @UserIdInt int userId); 6143 6144 /** 6145 * Retrieve all services that can match the given intent. 6146 * 6147 * @param intent The desired intent as per resolveService(). 6148 * @param flags Additional option flags to modify the data returned. 6149 * @return Returns a List of ResolveInfo objects containing one entry for 6150 * each matching service, ordered from best to worst. In other 6151 * words, the first item is what would be returned by 6152 * {@link #resolveService}. If there are no matching services, an 6153 * empty list or null is returned. 6154 */ 6155 @NonNull queryIntentServices(@onNull Intent intent, @ResolveInfoFlags int flags)6156 public abstract List<ResolveInfo> queryIntentServices(@NonNull Intent intent, 6157 @ResolveInfoFlags int flags); 6158 6159 /** 6160 * Retrieve all services that can match the given intent for a given user. 6161 * 6162 * @param intent The desired intent as per resolveService(). 6163 * @param flags Additional option flags to modify the data returned. 6164 * @param userId The user id. 6165 * @return Returns a List of ResolveInfo objects containing one entry for 6166 * each matching service, ordered from best to worst. In other 6167 * words, the first item is what would be returned by 6168 * {@link #resolveService}. If there are no matching services, an 6169 * empty list or null is returned. 6170 * @hide 6171 */ 6172 @SuppressWarnings("HiddenAbstractMethod") 6173 @NonNull 6174 @UnsupportedAppUsage queryIntentServicesAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)6175 public abstract List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 6176 @ResolveInfoFlags int flags, @UserIdInt int userId); 6177 6178 /** 6179 * Retrieve all services that can match the given intent for a given user. 6180 * 6181 * @param intent The desired intent as per resolveService(). 6182 * @param flags Additional option flags to modify the data returned. 6183 * @param user The user being queried. 6184 * @return Returns a List of ResolveInfo objects containing one entry for 6185 * each matching service, ordered from best to worst. In other 6186 * words, the first item is what would be returned by 6187 * {@link #resolveService}. If there are no matching services, an 6188 * empty list or null is returned. 6189 * @hide 6190 */ 6191 @NonNull 6192 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 6193 @SystemApi queryIntentServicesAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, @NonNull UserHandle user)6194 public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent, 6195 @ResolveInfoFlags int flags, @NonNull UserHandle user) { 6196 return queryIntentServicesAsUser(intent, flags, user.getIdentifier()); 6197 } 6198 6199 /** 6200 * Retrieve all providers that can match the given intent. 6201 * 6202 * @param intent An intent containing all of the desired specification 6203 * (action, data, type, category, and/or component). 6204 * @param flags Additional option flags to modify the data returned. 6205 * @param userId The user id. 6206 * @return Returns a List of ResolveInfo objects containing one entry for 6207 * each matching provider, ordered from best to worst. If there are 6208 * no matching services, an empty list or null is returned. 6209 * @hide 6210 */ 6211 @SuppressWarnings("HiddenAbstractMethod") 6212 @NonNull 6213 @UnsupportedAppUsage queryIntentContentProvidersAsUser( @onNull Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)6214 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 6215 @NonNull Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId); 6216 6217 /** 6218 * Retrieve all providers that can match the given intent. 6219 * 6220 * @param intent An intent containing all of the desired specification 6221 * (action, data, type, category, and/or component). 6222 * @param flags Additional option flags to modify the data returned. 6223 * @param user The user being queried. 6224 * @return Returns a List of ResolveInfo objects containing one entry for 6225 * each matching provider, ordered from best to worst. If there are 6226 * no matching services, an empty list or null is returned. 6227 * @hide 6228 */ 6229 @NonNull 6230 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 6231 @SystemApi queryIntentContentProvidersAsUser(@onNull Intent intent, @ResolveInfoFlags int flags, @NonNull UserHandle user)6232 public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent, 6233 @ResolveInfoFlags int flags, @NonNull UserHandle user) { 6234 return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier()); 6235 } 6236 6237 /** 6238 * Retrieve all providers that can match the given intent. 6239 * 6240 * @param intent An intent containing all of the desired specification 6241 * (action, data, type, category, and/or component). 6242 * @param flags Additional option flags to modify the data returned. 6243 * @return Returns a List of ResolveInfo objects containing one entry for 6244 * each matching provider, ordered from best to worst. If there are 6245 * no matching services, an empty list or null is returned. 6246 */ 6247 @NonNull queryIntentContentProviders(@onNull Intent intent, @ResolveInfoFlags int flags)6248 public abstract List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent, 6249 @ResolveInfoFlags int flags); 6250 6251 /** 6252 * Find a single content provider by its authority. 6253 * <p> 6254 * Example:<p> 6255 * <pre> 6256 * Uri uri = Uri.parse("content://com.example.app.provider/table1"); 6257 * ProviderInfo info = packageManager.resolveContentProvider(uri.getAuthority(), flags); 6258 * </pre> 6259 * 6260 * @param authority The authority of the provider to find. 6261 * @param flags Additional option flags to modify the data returned. 6262 * @return A {@link ProviderInfo} object containing information about the 6263 * provider. If a provider was not found, returns null. 6264 */ 6265 @Nullable resolveContentProvider(@onNull String authority, @ComponentInfoFlags int flags)6266 public abstract ProviderInfo resolveContentProvider(@NonNull String authority, 6267 @ComponentInfoFlags int flags); 6268 6269 /** 6270 * Find a single content provider by its base path name. 6271 * 6272 * @param providerName The name of the provider to find. 6273 * @param flags Additional option flags to modify the data returned. 6274 * @param userId The user id. 6275 * @return A {@link ProviderInfo} object containing information about the 6276 * provider. If a provider was not found, returns null. 6277 * @hide 6278 */ 6279 @SuppressWarnings("HiddenAbstractMethod") 6280 @Nullable 6281 @UnsupportedAppUsage resolveContentProviderAsUser(@onNull String providerName, @ComponentInfoFlags int flags, @UserIdInt int userId)6282 public abstract ProviderInfo resolveContentProviderAsUser(@NonNull String providerName, 6283 @ComponentInfoFlags int flags, @UserIdInt int userId); 6284 6285 /** 6286 * Retrieve content provider information. 6287 * <p> 6288 * <em>Note: unlike most other methods, an empty result set is indicated 6289 * by a null return instead of an empty list.</em> 6290 * 6291 * @param processName If non-null, limits the returned providers to only 6292 * those that are hosted by the given process. If null, all 6293 * content providers are returned. 6294 * @param uid If <var>processName</var> is non-null, this is the required 6295 * uid owning the requested content providers. 6296 * @param flags Additional option flags to modify the data returned. 6297 * @return A list of {@link ProviderInfo} objects containing one entry for 6298 * each provider either matching <var>processName</var> or, if 6299 * <var>processName</var> is null, all known content providers. 6300 * <em>If there are no matching providers, null is returned.</em> 6301 */ 6302 @NonNull queryContentProviders( @ullable String processName, int uid, @ComponentInfoFlags int flags)6303 public abstract List<ProviderInfo> queryContentProviders( 6304 @Nullable String processName, int uid, @ComponentInfoFlags int flags); 6305 6306 /** 6307 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null, 6308 * it only returns providers which have metadata with the {@code metaDataKey} key. 6309 * 6310 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider. 6311 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders} 6312 * instead. 6313 * 6314 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly 6315 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata 6316 * to mark GAL providers, rather than intent filters, so we can't use 6317 * {@link #queryIntentContentProviders} for that. 6318 * 6319 * @hide 6320 */ 6321 @NonNull queryContentProviders(@ullable String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey)6322 public List<ProviderInfo> queryContentProviders(@Nullable String processName, 6323 int uid, @ComponentInfoFlags int flags, String metaDataKey) { 6324 // Provide the default implementation for mocks. 6325 return queryContentProviders(processName, uid, flags); 6326 } 6327 6328 /** 6329 * Retrieve all of the information we know about a particular 6330 * instrumentation class. 6331 * 6332 * @param className The full name (i.e. 6333 * com.google.apps.contacts.InstrumentList) of an Instrumentation 6334 * class. 6335 * @param flags Additional option flags to modify the data returned. 6336 * @return An {@link InstrumentationInfo} object containing information 6337 * about the instrumentation. 6338 * @throws NameNotFoundException if a package with the given name cannot be 6339 * found on the system. 6340 */ 6341 @NonNull getInstrumentationInfo(@onNull ComponentName className, @InstrumentationInfoFlags int flags)6342 public abstract InstrumentationInfo getInstrumentationInfo(@NonNull ComponentName className, 6343 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 6344 6345 /** 6346 * Retrieve information about available instrumentation code. May be used to 6347 * retrieve either all instrumentation code, or only the code targeting a 6348 * particular package. 6349 * 6350 * @param targetPackage If null, all instrumentation is returned; only the 6351 * instrumentation targeting this package name is returned. 6352 * @param flags Additional option flags to modify the data returned. 6353 * @return A list of {@link InstrumentationInfo} objects containing one 6354 * entry for each matching instrumentation. If there are no 6355 * instrumentation available, returns an empty list. 6356 */ 6357 @NonNull queryInstrumentation(@onNull String targetPackage, @InstrumentationInfoFlags int flags)6358 public abstract List<InstrumentationInfo> queryInstrumentation(@NonNull String targetPackage, 6359 @InstrumentationInfoFlags int flags); 6360 6361 /** 6362 * Retrieve an image from a package. This is a low-level API used by 6363 * the various package manager info structures (such as 6364 * {@link ComponentInfo} to implement retrieval of their associated 6365 * icon. 6366 * 6367 * @param packageName The name of the package that this icon is coming from. 6368 * Cannot be null. 6369 * @param resid The resource identifier of the desired image. Cannot be 0. 6370 * @param appInfo Overall information about <var>packageName</var>. This 6371 * may be null, in which case the application information will be retrieved 6372 * for you if needed; if you already have this information around, it can 6373 * be much more efficient to supply it here. 6374 * 6375 * @return Returns a Drawable holding the requested image. Returns null if 6376 * an image could not be found for any reason. 6377 */ 6378 @Nullable getDrawable(@onNull String packageName, @DrawableRes int resid, @Nullable ApplicationInfo appInfo)6379 public abstract Drawable getDrawable(@NonNull String packageName, @DrawableRes int resid, 6380 @Nullable ApplicationInfo appInfo); 6381 6382 /** 6383 * Retrieve the icon associated with an activity. Given the full name of 6384 * an activity, retrieves the information about it and calls 6385 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 6386 * If the activity cannot be found, NameNotFoundException is thrown. 6387 * 6388 * @param activityName Name of the activity whose icon is to be retrieved. 6389 * 6390 * @return Returns the image of the icon, or the default activity icon if 6391 * it could not be found. Does not return null. 6392 * @throws NameNotFoundException Thrown if the resources for the given 6393 * activity could not be loaded. 6394 * 6395 * @see #getActivityIcon(Intent) 6396 */ 6397 @NonNull getActivityIcon(@onNull ComponentName activityName)6398 public abstract Drawable getActivityIcon(@NonNull ComponentName activityName) 6399 throws NameNotFoundException; 6400 6401 /** 6402 * Retrieve the icon associated with an Intent. If intent.getClassName() is 6403 * set, this simply returns the result of 6404 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 6405 * component and returns the icon associated with the resolved component. 6406 * If intent.getClassName() cannot be found or the Intent cannot be resolved 6407 * to a component, NameNotFoundException is thrown. 6408 * 6409 * @param intent The intent for which you would like to retrieve an icon. 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 application 6414 * matching the given intent could not be loaded. 6415 * 6416 * @see #getActivityIcon(ComponentName) 6417 */ 6418 @NonNull getActivityIcon(@onNull Intent intent)6419 public abstract Drawable getActivityIcon(@NonNull Intent intent) 6420 throws NameNotFoundException; 6421 6422 /** 6423 * Retrieve the banner associated with an activity. Given the full name of 6424 * an activity, retrieves the information about it and calls 6425 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 6426 * banner. If the activity cannot be found, NameNotFoundException is thrown. 6427 * 6428 * @param activityName Name of the activity whose banner is to be retrieved. 6429 * @return Returns the image of the banner, or null if the activity has no 6430 * banner specified. 6431 * @throws NameNotFoundException Thrown if the resources for the given 6432 * activity could not be loaded. 6433 * @see #getActivityBanner(Intent) 6434 */ 6435 @Nullable getActivityBanner(@onNull ComponentName activityName)6436 public abstract Drawable getActivityBanner(@NonNull ComponentName activityName) 6437 throws NameNotFoundException; 6438 6439 /** 6440 * Retrieve the banner associated with an Intent. If intent.getClassName() 6441 * is set, this simply returns the result of 6442 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 6443 * intent's component and returns the banner associated with the resolved 6444 * component. If intent.getClassName() cannot be found or the Intent cannot 6445 * be resolved to a component, NameNotFoundException is thrown. 6446 * 6447 * @param intent The intent for which you would like to retrieve a banner. 6448 * @return Returns the image of the banner, or null if the activity has no 6449 * banner specified. 6450 * @throws NameNotFoundException Thrown if the resources for application 6451 * matching the given intent could not be loaded. 6452 * @see #getActivityBanner(ComponentName) 6453 */ 6454 @Nullable getActivityBanner(@onNull Intent intent)6455 public abstract Drawable getActivityBanner(@NonNull Intent intent) 6456 throws NameNotFoundException; 6457 6458 /** 6459 * Return the generic icon for an activity that is used when no specific 6460 * icon is defined. 6461 * 6462 * @return Drawable Image of the icon. 6463 */ 6464 @NonNull getDefaultActivityIcon()6465 public abstract Drawable getDefaultActivityIcon(); 6466 6467 /** 6468 * Retrieve the icon associated with an application. If it has not defined 6469 * an icon, the default app icon is returned. Does not return null. 6470 * 6471 * @param info Information about application being queried. 6472 * 6473 * @return Returns the image of the icon, or the default application icon 6474 * if it could not be found. 6475 * 6476 * @see #getApplicationIcon(String) 6477 */ 6478 @NonNull getApplicationIcon(@onNull ApplicationInfo info)6479 public abstract Drawable getApplicationIcon(@NonNull ApplicationInfo info); 6480 6481 /** 6482 * Retrieve the icon associated with an application. Given the name of the 6483 * application's package, retrieves the information about it and calls 6484 * getApplicationIcon() to return its icon. If the application cannot be 6485 * found, NameNotFoundException is thrown. 6486 * 6487 * @param packageName Name of the package whose application icon is to be 6488 * retrieved. 6489 * 6490 * @return Returns the image of the icon, or the default application icon 6491 * if it could not be found. Does not return null. 6492 * @throws NameNotFoundException Thrown if the resources for the given 6493 * application could not be loaded. 6494 * 6495 * @see #getApplicationIcon(ApplicationInfo) 6496 */ 6497 @NonNull getApplicationIcon(@onNull String packageName)6498 public abstract Drawable getApplicationIcon(@NonNull String packageName) 6499 throws NameNotFoundException; 6500 6501 /** 6502 * Retrieve the banner associated with an application. 6503 * 6504 * @param info Information about application being queried. 6505 * @return Returns the image of the banner or null if the application has no 6506 * banner specified. 6507 * @see #getApplicationBanner(String) 6508 */ 6509 @Nullable getApplicationBanner(@onNull ApplicationInfo info)6510 public abstract Drawable getApplicationBanner(@NonNull ApplicationInfo info); 6511 6512 /** 6513 * Retrieve the banner associated with an application. Given the name of the 6514 * application's package, retrieves the information about it and calls 6515 * getApplicationIcon() to return its banner. If the application cannot be 6516 * found, NameNotFoundException is thrown. 6517 * 6518 * @param packageName Name of the package whose application banner is to be 6519 * retrieved. 6520 * @return Returns the image of the banner or null if the application has no 6521 * banner specified. 6522 * @throws NameNotFoundException Thrown if the resources for the given 6523 * application could not be loaded. 6524 * @see #getApplicationBanner(ApplicationInfo) 6525 */ 6526 @Nullable getApplicationBanner(@onNull String packageName)6527 public abstract Drawable getApplicationBanner(@NonNull String packageName) 6528 throws NameNotFoundException; 6529 6530 /** 6531 * Retrieve the logo associated with an activity. Given the full name of an 6532 * activity, retrieves the information about it and calls 6533 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 6534 * logo. If the activity cannot be found, NameNotFoundException is thrown. 6535 * 6536 * @param activityName Name of the activity whose logo is to be retrieved. 6537 * @return Returns the image of the logo or null if the activity has no logo 6538 * specified. 6539 * @throws NameNotFoundException Thrown if the resources for the given 6540 * activity could not be loaded. 6541 * @see #getActivityLogo(Intent) 6542 */ 6543 @Nullable getActivityLogo(@onNull ComponentName activityName)6544 public abstract Drawable getActivityLogo(@NonNull ComponentName activityName) 6545 throws NameNotFoundException; 6546 6547 /** 6548 * Retrieve the logo associated with an Intent. If intent.getClassName() is 6549 * set, this simply returns the result of 6550 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 6551 * component and returns the logo associated with the resolved component. 6552 * If intent.getClassName() cannot be found or the Intent cannot be resolved 6553 * to a component, NameNotFoundException is thrown. 6554 * 6555 * @param intent The intent for which you would like to retrieve a logo. 6556 * 6557 * @return Returns the image of the logo, or null if the activity has no 6558 * logo specified. 6559 * 6560 * @throws NameNotFoundException Thrown if the resources for application 6561 * matching the given intent could not be loaded. 6562 * 6563 * @see #getActivityLogo(ComponentName) 6564 */ 6565 @Nullable getActivityLogo(@onNull Intent intent)6566 public abstract Drawable getActivityLogo(@NonNull Intent intent) 6567 throws NameNotFoundException; 6568 6569 /** 6570 * Retrieve the logo associated with an application. If it has not specified 6571 * a logo, this method returns null. 6572 * 6573 * @param info Information about application being queried. 6574 * 6575 * @return Returns the image of the logo, or null if no logo is specified 6576 * by the application. 6577 * 6578 * @see #getApplicationLogo(String) 6579 */ 6580 @Nullable getApplicationLogo(@onNull ApplicationInfo info)6581 public abstract Drawable getApplicationLogo(@NonNull ApplicationInfo info); 6582 6583 /** 6584 * Retrieve the logo associated with an application. Given the name of the 6585 * application's package, retrieves the information about it and calls 6586 * getApplicationLogo() to return its logo. If the application cannot be 6587 * found, NameNotFoundException is thrown. 6588 * 6589 * @param packageName Name of the package whose application logo is to be 6590 * retrieved. 6591 * 6592 * @return Returns the image of the logo, or null if no application logo 6593 * has been specified. 6594 * 6595 * @throws NameNotFoundException Thrown if the resources for the given 6596 * application could not be loaded. 6597 * 6598 * @see #getApplicationLogo(ApplicationInfo) 6599 */ 6600 @Nullable getApplicationLogo(@onNull String packageName)6601 public abstract Drawable getApplicationLogo(@NonNull String packageName) 6602 throws NameNotFoundException; 6603 6604 /** 6605 * If the target user is a managed profile, then this returns a badged copy of the given icon 6606 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use 6607 * {@link #getUserBadgedDrawableForDensity( 6608 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 6609 * <p> 6610 * If the original drawable is a BitmapDrawable and the backing bitmap is 6611 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 6612 * is performed in place and the original drawable is returned. 6613 * </p> 6614 * 6615 * @param drawable The drawable to badge. 6616 * @param user The target user. 6617 * @return A drawable that combines the original icon and a badge as 6618 * determined by the system. 6619 */ 6620 @NonNull getUserBadgedIcon(@onNull Drawable drawable, @NonNull UserHandle user)6621 public abstract Drawable getUserBadgedIcon(@NonNull Drawable drawable, 6622 @NonNull UserHandle user); 6623 6624 /** 6625 * If the target user is a managed profile of the calling user or the caller 6626 * is itself a managed profile, then this returns a badged copy of the given 6627 * drawable allowing the user to distinguish it from the original drawable. 6628 * The caller can specify the location in the bounds of the drawable to be 6629 * badged where the badge should be applied as well as the density of the 6630 * badge to be used. 6631 * <p> 6632 * If the original drawable is a BitmapDrawable and the backing bitmap is 6633 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 6634 * is performed in place and the original drawable is returned. 6635 * </p> 6636 * 6637 * @param drawable The drawable to badge. 6638 * @param user The target user. 6639 * @param badgeLocation Where in the bounds of the badged drawable to place 6640 * the badge. If it's {@code null}, the badge is applied on top of the entire 6641 * drawable being badged. 6642 * @param badgeDensity The optional desired density for the badge as per 6643 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 6644 * the density of the display is used. 6645 * @return A drawable that combines the original drawable and a badge as 6646 * determined by the system. 6647 */ 6648 @NonNull getUserBadgedDrawableForDensity(@onNull Drawable drawable, @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity)6649 public abstract Drawable getUserBadgedDrawableForDensity(@NonNull Drawable drawable, 6650 @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity); 6651 6652 /** 6653 * If the target user is a managed profile of the calling user or the caller 6654 * is itself a managed profile, then this returns a drawable to use as a small 6655 * icon to include in a view to distinguish it from the original icon. 6656 * 6657 * @param user The target user. 6658 * @param density The optional desired density for the badge as per 6659 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 6660 * the density of the current display is used. 6661 * @return the drawable or null if no drawable is required. 6662 * @hide 6663 */ 6664 @SuppressWarnings("HiddenAbstractMethod") 6665 @Nullable 6666 @UnsupportedAppUsage getUserBadgeForDensity(@onNull UserHandle user, int density)6667 public abstract Drawable getUserBadgeForDensity(@NonNull UserHandle user, int density); 6668 6669 /** 6670 * If the target user is a managed profile of the calling user or the caller 6671 * is itself a managed profile, then this returns a drawable to use as a small 6672 * icon to include in a view to distinguish it from the original icon. This version 6673 * doesn't have background protection and should be used over a light background instead of 6674 * a badge. 6675 * 6676 * @param user The target user. 6677 * @param density The optional desired density for the badge as per 6678 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 6679 * the density of the current display is used. 6680 * @return the drawable or null if no drawable is required. 6681 * @hide 6682 */ 6683 @SuppressWarnings("HiddenAbstractMethod") 6684 @Nullable 6685 @UnsupportedAppUsage getUserBadgeForDensityNoBackground(@onNull UserHandle user, int density)6686 public abstract Drawable getUserBadgeForDensityNoBackground(@NonNull UserHandle user, 6687 int density); 6688 6689 /** 6690 * If the target user is a managed profile of the calling user or the caller 6691 * is itself a managed profile, then this returns a copy of the label with 6692 * badging for accessibility services like talkback. E.g. passing in "Email" 6693 * and it might return "Work Email" for Email in the work profile. 6694 * 6695 * @param label The label to change. 6696 * @param user The target user. 6697 * @return A label that combines the original label and a badge as 6698 * determined by the system. 6699 */ 6700 @NonNull getUserBadgedLabel(@onNull CharSequence label, @NonNull UserHandle user)6701 public abstract CharSequence getUserBadgedLabel(@NonNull CharSequence label, 6702 @NonNull UserHandle user); 6703 6704 /** 6705 * Retrieve text from a package. This is a low-level API used by 6706 * the various package manager info structures (such as 6707 * {@link ComponentInfo} to implement retrieval of their associated 6708 * labels and other text. 6709 * 6710 * @param packageName The name of the package that this text is coming from. 6711 * Cannot be null. 6712 * @param resid The resource identifier of the desired text. Cannot be 0. 6713 * @param appInfo Overall information about <var>packageName</var>. This 6714 * may be null, in which case the application information will be retrieved 6715 * for you if needed; if you already have this information around, it can 6716 * be much more efficient to supply it here. 6717 * 6718 * @return Returns a CharSequence holding the requested text. Returns null 6719 * if the text could not be found for any reason. 6720 */ 6721 @Nullable getText(@onNull String packageName, @StringRes int resid, @Nullable ApplicationInfo appInfo)6722 public abstract CharSequence getText(@NonNull String packageName, @StringRes int resid, 6723 @Nullable ApplicationInfo appInfo); 6724 6725 /** 6726 * Retrieve an XML file from a package. This is a low-level API used to 6727 * retrieve XML meta data. 6728 * 6729 * @param packageName The name of the package that this xml is coming from. 6730 * Cannot be null. 6731 * @param resid The resource identifier of the desired xml. Cannot be 0. 6732 * @param appInfo Overall information about <var>packageName</var>. This 6733 * may be null, in which case the application information will be retrieved 6734 * for you if needed; if you already have this information around, it can 6735 * be much more efficient to supply it here. 6736 * 6737 * @return Returns an XmlPullParser allowing you to parse out the XML 6738 * data. Returns null if the xml resource could not be found for any 6739 * reason. 6740 */ 6741 @Nullable getXml(@onNull String packageName, @XmlRes int resid, @Nullable ApplicationInfo appInfo)6742 public abstract XmlResourceParser getXml(@NonNull String packageName, @XmlRes int resid, 6743 @Nullable ApplicationInfo appInfo); 6744 6745 /** 6746 * Return the label to use for this application. 6747 * 6748 * @return Returns a {@link CharSequence} containing the label associated with 6749 * this application, or its name the item does not have a label. 6750 * @param info The {@link ApplicationInfo} of the application to get the label of. 6751 */ 6752 @NonNull getApplicationLabel(@onNull ApplicationInfo info)6753 public abstract CharSequence getApplicationLabel(@NonNull ApplicationInfo info); 6754 6755 /** 6756 * Retrieve the resources associated with an activity. Given the full 6757 * name of an activity, retrieves the information about it and calls 6758 * getResources() to return its application's resources. If the activity 6759 * cannot be found, NameNotFoundException is thrown. 6760 * 6761 * @param activityName Name of the activity whose resources are to be 6762 * retrieved. 6763 * 6764 * @return Returns the application's Resources. 6765 * @throws NameNotFoundException Thrown if the resources for the given 6766 * application could not be loaded. 6767 * 6768 * @see #getResourcesForApplication(ApplicationInfo) 6769 */ 6770 @NonNull getResourcesForActivity(@onNull ComponentName activityName)6771 public abstract Resources getResourcesForActivity(@NonNull ComponentName activityName) 6772 throws NameNotFoundException; 6773 6774 /** 6775 * Retrieve the resources for an application. Throws NameNotFoundException 6776 * if the package is no longer installed. 6777 * 6778 * @param app Information about the desired application. 6779 * 6780 * @return Returns the application's Resources. 6781 * @throws NameNotFoundException Thrown if the resources for the given 6782 * application could not be loaded (most likely because it was uninstalled). 6783 */ 6784 @NonNull getResourcesForApplication(@onNull ApplicationInfo app)6785 public abstract Resources getResourcesForApplication(@NonNull ApplicationInfo app) 6786 throws NameNotFoundException; 6787 6788 /** 6789 * Retrieve the resources for an application for the provided configuration. 6790 * 6791 * @param app Information about the desired application. 6792 * @param configuration Overridden configuration when loading the Resources 6793 * 6794 * @return Returns the application's Resources. 6795 * @throws NameNotFoundException Thrown if the resources for the given 6796 * application could not be loaded (most likely because it was uninstalled). 6797 */ 6798 @NonNull getResourcesForApplication(@onNull ApplicationInfo app, @Nullable Configuration configuration)6799 public Resources getResourcesForApplication(@NonNull ApplicationInfo app, @Nullable 6800 Configuration configuration) throws NameNotFoundException { 6801 throw new UnsupportedOperationException(); 6802 } 6803 6804 /** 6805 * Retrieve the resources associated with an application. Given the full 6806 * package name of an application, retrieves the information about it and 6807 * calls getResources() to return its application's resources. If the 6808 * appPackageName cannot be found, NameNotFoundException is thrown. 6809 * 6810 * @param packageName Package name of the application whose resources 6811 * are to be retrieved. 6812 * 6813 * @return Returns the application's Resources. 6814 * @throws NameNotFoundException Thrown if the resources for the given 6815 * application could not be loaded. 6816 * 6817 * @see #getResourcesForApplication(ApplicationInfo) 6818 */ 6819 @NonNull getResourcesForApplication(@onNull String packageName)6820 public abstract Resources getResourcesForApplication(@NonNull String packageName) 6821 throws NameNotFoundException; 6822 6823 /** 6824 * Please don't use this function because it is no longer supported. 6825 * 6826 * @deprecated Instead of using this function, please use 6827 * {@link Context#createContextAsUser(UserHandle, int)} to create the specified user 6828 * context, {@link Context#getPackageManager()} to get PackageManager instance for 6829 * the specified user, and then 6830 * {@link PackageManager#getResourcesForApplication(String)} to get the same 6831 * Resources instance. 6832 * @see {@link Context#createContextAsUser(android.os.UserHandle, int)} 6833 * @see {@link Context#getPackageManager()} 6834 * @see {@link android.content.pm.PackageManager#getResourcesForApplication(java.lang.String)} 6835 * TODO(b/170852794): mark maxTargetSdk as {@code Build.VERSION_CODES.S} 6836 * @hide 6837 */ 6838 @SuppressWarnings("HiddenAbstractMethod") 6839 @NonNull 6840 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170928809, 6841 publicAlternatives = "Use {@code Context#createContextAsUser(UserHandle, int)}" 6842 + " to create the relevant user context," 6843 + " {@link android.content.Context#getPackageManager()} and" 6844 + " {@link android.content.pm.PackageManager#getResourcesForApplication(" 6845 + "java.lang.String)}" 6846 + " instead.") 6847 @Deprecated getResourcesForApplicationAsUser(@onNull String packageName, @UserIdInt int userId)6848 public abstract Resources getResourcesForApplicationAsUser(@NonNull String packageName, 6849 @UserIdInt int userId) throws NameNotFoundException; 6850 6851 /** 6852 * Retrieve overall information about an application package defined in a 6853 * package archive file 6854 * 6855 * @param archiveFilePath The path to the archive file 6856 * @param flags Additional option flags to modify the data returned. 6857 * @return A PackageInfo object containing information about the package 6858 * archive. If the package could not be parsed, returns null. 6859 */ 6860 @Nullable getPackageArchiveInfo(@onNull String archiveFilePath, @PackageInfoFlags int flags)6861 public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath, 6862 @PackageInfoFlags int flags) { 6863 throw new UnsupportedOperationException( 6864 "getPackageArchiveInfo() not implemented in subclass"); 6865 } 6866 6867 /** 6868 * If there is already an application with the given package name installed 6869 * on the system for other users, also install it for the calling user. 6870 * @hide 6871 * 6872 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 6873 */ 6874 @SuppressWarnings("HiddenAbstractMethod") 6875 @Deprecated 6876 @SystemApi installExistingPackage(@onNull String packageName)6877 public abstract int installExistingPackage(@NonNull String packageName) 6878 throws NameNotFoundException; 6879 6880 /** 6881 * If there is already an application with the given package name installed 6882 * on the system for other users, also install it for the calling user. 6883 * @hide 6884 * 6885 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 6886 */ 6887 @SuppressWarnings("HiddenAbstractMethod") 6888 @Deprecated 6889 @SystemApi installExistingPackage(@onNull String packageName, @InstallReason int installReason)6890 public abstract int installExistingPackage(@NonNull String packageName, 6891 @InstallReason int installReason) throws NameNotFoundException; 6892 6893 /** 6894 * If there is already an application with the given package name installed 6895 * on the system for other users, also install it for the specified user. 6896 * @hide 6897 * 6898 * @deprecated use {@link PackageInstaller#installExistingPackage()} instead. 6899 */ 6900 @SuppressWarnings("HiddenAbstractMethod") 6901 @Deprecated 6902 @RequiresPermission(anyOf = { 6903 Manifest.permission.INSTALL_EXISTING_PACKAGES, 6904 Manifest.permission.INSTALL_PACKAGES, 6905 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 6906 @UnsupportedAppUsage installExistingPackageAsUser(@onNull String packageName, @UserIdInt int userId)6907 public abstract int installExistingPackageAsUser(@NonNull String packageName, 6908 @UserIdInt int userId) throws NameNotFoundException; 6909 6910 /** 6911 * Allows a package listening to the 6912 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 6913 * broadcast} to respond to the package manager. The response must include 6914 * the {@code verificationCode} which is one of 6915 * {@link PackageManager#VERIFICATION_ALLOW} or 6916 * {@link PackageManager#VERIFICATION_REJECT}. 6917 * 6918 * @param id pending package identifier as passed via the 6919 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 6920 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 6921 * or {@link PackageManager#VERIFICATION_REJECT}. 6922 * @throws SecurityException if the caller does not have the 6923 * PACKAGE_VERIFICATION_AGENT permission. 6924 */ verifyPendingInstall(int id, int verificationCode)6925 public abstract void verifyPendingInstall(int id, int verificationCode); 6926 6927 /** 6928 * Allows a package listening to the 6929 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 6930 * broadcast} to extend the default timeout for a response and declare what 6931 * action to perform after the timeout occurs. The response must include 6932 * the {@code verificationCodeAtTimeout} which is one of 6933 * {@link PackageManager#VERIFICATION_ALLOW} or 6934 * {@link PackageManager#VERIFICATION_REJECT}. 6935 * 6936 * This method may only be called once per package id. Additional calls 6937 * will have no effect. 6938 * 6939 * @param id pending package identifier as passed via the 6940 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 6941 * @param verificationCodeAtTimeout either 6942 * {@link PackageManager#VERIFICATION_ALLOW} or 6943 * {@link PackageManager#VERIFICATION_REJECT}. If 6944 * {@code verificationCodeAtTimeout} is neither 6945 * {@link PackageManager#VERIFICATION_ALLOW} or 6946 * {@link PackageManager#VERIFICATION_REJECT}, then 6947 * {@code verificationCodeAtTimeout} will default to 6948 * {@link PackageManager#VERIFICATION_REJECT}. 6949 * @param millisecondsToDelay the amount of time requested for the timeout. 6950 * Must be positive and less than 6951 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 6952 * {@code millisecondsToDelay} is out of bounds, 6953 * {@code millisecondsToDelay} will be set to the closest in 6954 * bounds value; namely, 0 or 6955 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 6956 * @throws SecurityException if the caller does not have the 6957 * PACKAGE_VERIFICATION_AGENT permission. 6958 */ extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay)6959 public abstract void extendVerificationTimeout(int id, 6960 int verificationCodeAtTimeout, long millisecondsToDelay); 6961 6962 /** 6963 * Allows a package listening to the 6964 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification 6965 * broadcast to respond to the package manager. The response must include 6966 * the {@code verificationCode} which is one of 6967 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 6968 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 6969 * 6970 * @param verificationId pending package identifier as passed via the 6971 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 6972 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 6973 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 6974 * @param failedDomains a list of failed domains if the verificationCode is 6975 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 6976 * @throws SecurityException if the caller does not have the 6977 * INTENT_FILTER_VERIFICATION_AGENT permission. 6978 * 6979 * @deprecated Use {@link DomainVerificationManager} APIs. 6980 * @hide 6981 */ 6982 @Deprecated 6983 @SuppressWarnings("HiddenAbstractMethod") 6984 @SystemApi 6985 @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT) verifyIntentFilter(int verificationId, int verificationCode, @NonNull List<String> failedDomains)6986 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 6987 @NonNull List<String> failedDomains); 6988 6989 /** 6990 * Get the status of a Domain Verification Result for an IntentFilter. This is 6991 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 6992 * {@link android.content.IntentFilter#getAutoVerify()} 6993 * 6994 * This is used by the ResolverActivity to change the status depending on what the User select 6995 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 6996 * for a domain. 6997 * 6998 * @param packageName The package name of the Activity associated with the IntentFilter. 6999 * @param userId The user id. 7000 * 7001 * @return The status to set to. This can be 7002 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 7003 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 7004 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 7005 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 7006 * 7007 * @deprecated Use {@link DomainVerificationManager} APIs. 7008 * @hide 7009 */ 7010 @Deprecated 7011 @SuppressWarnings("HiddenAbstractMethod") 7012 @SystemApi 7013 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) getIntentVerificationStatusAsUser(@onNull String packageName, @UserIdInt int userId)7014 public abstract int getIntentVerificationStatusAsUser(@NonNull String packageName, 7015 @UserIdInt int userId); 7016 7017 /** 7018 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 7019 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 7020 * {@link android.content.IntentFilter#getAutoVerify()} 7021 * 7022 * This is used by the ResolverActivity to change the status depending on what the User select 7023 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 7024 * for a domain. 7025 * 7026 * @param packageName The package name of the Activity associated with the IntentFilter. 7027 * @param status The status to set to. This can be 7028 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 7029 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 7030 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 7031 * @param userId The user id. 7032 * 7033 * @return true if the status has been set. False otherwise. 7034 * 7035 * @deprecated This API represents a very dangerous behavior where Settings or a system app with 7036 * the right permissions can force an application to be verified for all of its declared 7037 * domains. This has been removed to prevent unintended usage, and no longer does anything, 7038 * always returning false. If a caller truly wishes to grant <i></i>every</i> declared web 7039 * domain to an application, use 7040 * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, Set, boolean)}, 7041 * passing in all of the domains returned inside 7042 * {@link DomainVerificationManager#getDomainVerificationUserState(String)}. 7043 * 7044 * @hide 7045 */ 7046 @Deprecated 7047 @SuppressWarnings("HiddenAbstractMethod") 7048 @SystemApi 7049 @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS) updateIntentVerificationStatusAsUser(@onNull String packageName, int status, @UserIdInt int userId)7050 public abstract boolean updateIntentVerificationStatusAsUser(@NonNull String packageName, 7051 int status, @UserIdInt int userId); 7052 7053 /** 7054 * Get the list of IntentFilterVerificationInfo for a specific package and User. 7055 * 7056 * @param packageName the package name. When this parameter is set to a non null value, 7057 * the results will be filtered by the package name provided. 7058 * Otherwise, there will be no filtering and it will return a list 7059 * corresponding for all packages 7060 * 7061 * @return a list of IntentFilterVerificationInfo for a specific package. 7062 * 7063 * @deprecated Use {@link DomainVerificationManager} instead. 7064 * @hide 7065 */ 7066 @Deprecated 7067 @SuppressWarnings("HiddenAbstractMethod") 7068 @NonNull 7069 @SystemApi getIntentFilterVerifications( @onNull String packageName)7070 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 7071 @NonNull String packageName); 7072 7073 /** 7074 * Get the list of IntentFilter for a specific package. 7075 * 7076 * @param packageName the package name. This parameter is set to a non null value, 7077 * the list will contain all the IntentFilter for that package. 7078 * Otherwise, the list will be empty. 7079 * 7080 * @return a list of IntentFilter for a specific package. 7081 * 7082 * @hide 7083 */ 7084 @SuppressWarnings("HiddenAbstractMethod") 7085 @NonNull 7086 @SystemApi getAllIntentFilters(@onNull String packageName)7087 public abstract List<IntentFilter> getAllIntentFilters(@NonNull String packageName); 7088 7089 /** 7090 * Get the default Browser package name for a specific user. 7091 * 7092 * @param userId The user id. 7093 * 7094 * @return the package name of the default Browser for the specified user. If the user id passed 7095 * is -1 (all users) it will return a null value. 7096 * 7097 * @hide 7098 */ 7099 @SuppressWarnings("HiddenAbstractMethod") 7100 @Nullable 7101 @SystemApi 7102 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) getDefaultBrowserPackageNameAsUser(@serIdInt int userId)7103 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId); 7104 7105 /** 7106 * Set the default Browser package name for a specific user. 7107 * 7108 * @param packageName The package name of the default Browser. 7109 * @param userId The user id. 7110 * 7111 * @return true if the default Browser for the specified user has been set, 7112 * otherwise return false. If the user id passed is -1 (all users) this call will not 7113 * do anything and just return false. 7114 * 7115 * @hide 7116 */ 7117 @SuppressWarnings("HiddenAbstractMethod") 7118 @SystemApi 7119 @RequiresPermission(allOf = { 7120 Manifest.permission.SET_PREFERRED_APPLICATIONS, 7121 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) setDefaultBrowserPackageNameAsUser(@ullable String packageName, @UserIdInt int userId)7122 public abstract boolean setDefaultBrowserPackageNameAsUser(@Nullable String packageName, 7123 @UserIdInt int userId); 7124 7125 /** 7126 * Change the installer associated with a given package. There are limitations 7127 * on how the installer package can be changed; in particular: 7128 * <ul> 7129 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 7130 * is not signed with the same certificate as the calling application. 7131 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 7132 * has an installer package, and that installer package is not signed with 7133 * the same certificate as the calling application. 7134 * </ul> 7135 * 7136 * @param targetPackage The installed package whose installer will be changed. 7137 * @param installerPackageName The package name of the new installer. May be 7138 * null to clear the association. 7139 */ setInstallerPackageName(@onNull String targetPackage, @Nullable String installerPackageName)7140 public abstract void setInstallerPackageName(@NonNull String targetPackage, 7141 @Nullable String installerPackageName); 7142 7143 /** @hide */ 7144 @SuppressWarnings("HiddenAbstractMethod") 7145 @SystemApi 7146 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES) setUpdateAvailable(@onNull String packageName, boolean updateAvaialble)7147 public abstract void setUpdateAvailable(@NonNull String packageName, boolean updateAvaialble); 7148 7149 /** 7150 * Attempts to delete a package. Since this may take a little while, the 7151 * result will be posted back to the given observer. A deletion will fail if 7152 * the calling context lacks the 7153 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 7154 * named package cannot be found, or if the named package is a system 7155 * package. 7156 * 7157 * @param packageName The name of the package to delete 7158 * @param observer An observer callback to get notified when the package 7159 * deletion is complete. 7160 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 7161 * will be called when that happens. observer may be null to 7162 * indicate that no callback is desired. 7163 * @hide 7164 */ 7165 @SuppressWarnings("HiddenAbstractMethod") 7166 @RequiresPermission(Manifest.permission.DELETE_PACKAGES) 7167 @UnsupportedAppUsage deletePackage(@onNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags)7168 public abstract void deletePackage(@NonNull String packageName, 7169 @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags); 7170 7171 /** 7172 * Attempts to delete a package. Since this may take a little while, the 7173 * result will be posted back to the given observer. A deletion will fail if 7174 * the named package cannot be found, or if the named package is a system 7175 * package. 7176 * 7177 * @param packageName The name of the package to delete 7178 * @param observer An observer callback to get notified when the package 7179 * deletion is complete. 7180 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 7181 * will be called when that happens. observer may be null to 7182 * indicate that no callback is desired. 7183 * @param userId The user Id 7184 * @hide 7185 */ 7186 @SuppressWarnings("HiddenAbstractMethod") 7187 @RequiresPermission(anyOf = { 7188 Manifest.permission.DELETE_PACKAGES, 7189 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 7190 @UnsupportedAppUsage deletePackageAsUser(@onNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId)7191 public abstract void deletePackageAsUser(@NonNull String packageName, 7192 @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags, 7193 @UserIdInt int userId); 7194 7195 /** 7196 * Retrieve the package name of the application that installed a package. This identifies 7197 * which market the package came from. 7198 * 7199 * @param packageName The name of the package to query 7200 * @throws IllegalArgumentException if the given package name is not installed 7201 * 7202 * @deprecated use {@link #getInstallSourceInfo(String)} instead 7203 */ 7204 @SuppressWarnings("HiddenAbstractMethod") 7205 @Deprecated 7206 @Nullable getInstallerPackageName(@onNull String packageName)7207 public abstract String getInstallerPackageName(@NonNull String packageName); 7208 7209 /** 7210 * Retrieves information about how a package was installed or updated. 7211 * <p> 7212 * If the calling application does not hold the INSTALL_PACKAGES permission then 7213 * the result will always return {@code null} from 7214 * {@link InstallSourceInfo#getOriginatingPackageName()}. 7215 * <p> 7216 * If the package that requested the install has been uninstalled, then information about it 7217 * will only be returned from {@link InstallSourceInfo#getInitiatingPackageName()} and 7218 * {@link InstallSourceInfo#getInitiatingPackageSigningInfo()} if the calling package is 7219 * requesting its own install information and is not an instant app. 7220 * 7221 * @param packageName The name of the package to query 7222 * @throws NameNotFoundException if the given package name is not installed 7223 */ 7224 @NonNull getInstallSourceInfo(@onNull String packageName)7225 public InstallSourceInfo getInstallSourceInfo(@NonNull String packageName) 7226 throws NameNotFoundException { 7227 throw new UnsupportedOperationException("getInstallSourceInfo not implemented"); 7228 } 7229 7230 /** 7231 * Attempts to clear the user data directory of an application. 7232 * Since this may take a little while, the result will 7233 * be posted back to the given observer. A deletion will fail if the 7234 * named package cannot be found, or if the named package is a "system package". 7235 * 7236 * @param packageName The name of the package 7237 * @param observer An observer callback to get notified when the operation is finished 7238 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 7239 * will be called when that happens. observer may be null to indicate that 7240 * no callback is desired. 7241 * 7242 * @hide 7243 */ 7244 @SuppressWarnings("HiddenAbstractMethod") 7245 @UnsupportedAppUsage clearApplicationUserData(@onNull String packageName, @Nullable IPackageDataObserver observer)7246 public abstract void clearApplicationUserData(@NonNull String packageName, 7247 @Nullable IPackageDataObserver observer); 7248 /** 7249 * Attempts to delete the cache files associated with an application. 7250 * Since this may take a little while, the result will 7251 * be posted back to the given observer. A deletion will fail if the calling context 7252 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 7253 * named package cannot be found, or if the named package is a "system package". 7254 * 7255 * @param packageName The name of the package to delete 7256 * @param observer An observer callback to get notified when the cache file deletion 7257 * is complete. 7258 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 7259 * will be called when that happens. observer may be null to indicate that 7260 * no callback is desired. 7261 * 7262 * @hide 7263 */ 7264 @SuppressWarnings("HiddenAbstractMethod") 7265 @UnsupportedAppUsage deleteApplicationCacheFiles(@onNull String packageName, @Nullable IPackageDataObserver observer)7266 public abstract void deleteApplicationCacheFiles(@NonNull String packageName, 7267 @Nullable IPackageDataObserver observer); 7268 7269 /** 7270 * Attempts to delete the cache files associated with an application for a given user. Since 7271 * this may take a little while, the result will be posted back to the given observer. A 7272 * deletion will fail if the calling context lacks the 7273 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package 7274 * cannot be found, or if the named package is a "system package". If {@code userId} does not 7275 * belong to the calling user, the caller must have 7276 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. 7277 * 7278 * @param packageName The name of the package to delete 7279 * @param userId the user for which the cache files needs to be deleted 7280 * @param observer An observer callback to get notified when the cache file deletion is 7281 * complete. 7282 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 7283 * will be called when that happens. observer may be null to indicate that no 7284 * callback is desired. 7285 * @hide 7286 */ 7287 @SuppressWarnings("HiddenAbstractMethod") 7288 @UnsupportedAppUsage deleteApplicationCacheFilesAsUser(@onNull String packageName, @UserIdInt int userId, @Nullable IPackageDataObserver observer)7289 public abstract void deleteApplicationCacheFilesAsUser(@NonNull String packageName, 7290 @UserIdInt int userId, @Nullable IPackageDataObserver observer); 7291 7292 /** 7293 * Free storage by deleting LRU sorted list of cache files across 7294 * all applications. If the currently available free storage 7295 * on the device is greater than or equal to the requested 7296 * free storage, no cache files are cleared. If the currently 7297 * available storage on the device is less than the requested 7298 * free storage, some or all of the cache files across 7299 * all applications are deleted (based on last accessed time) 7300 * to increase the free storage space on the device to 7301 * the requested value. There is no guarantee that clearing all 7302 * the cache files from all applications will clear up 7303 * enough storage to achieve the desired value. 7304 * @param freeStorageSize The number of bytes of storage to be 7305 * freed by the system. Say if freeStorageSize is XX, 7306 * and the current free storage is YY, 7307 * if XX is less than YY, just return. if not free XX-YY number 7308 * of bytes if possible. 7309 * @param observer call back used to notify when 7310 * the operation is completed 7311 * 7312 * @hide 7313 */ 7314 @UnsupportedAppUsage freeStorageAndNotify(long freeStorageSize, @Nullable IPackageDataObserver observer)7315 public void freeStorageAndNotify(long freeStorageSize, 7316 @Nullable IPackageDataObserver observer) { 7317 freeStorageAndNotify(null, freeStorageSize, observer); 7318 } 7319 7320 /** {@hide} */ 7321 @SuppressWarnings("HiddenAbstractMethod") 7322 @UnsupportedAppUsage freeStorageAndNotify(@ullable String volumeUuid, long freeStorageSize, @Nullable IPackageDataObserver observer)7323 public abstract void freeStorageAndNotify(@Nullable String volumeUuid, long freeStorageSize, 7324 @Nullable IPackageDataObserver observer); 7325 7326 /** 7327 * Free storage by deleting LRU sorted list of cache files across 7328 * all applications. If the currently available free storage 7329 * on the device is greater than or equal to the requested 7330 * free storage, no cache files are cleared. If the currently 7331 * available storage on the device is less than the requested 7332 * free storage, some or all of the cache files across 7333 * all applications are deleted (based on last accessed time) 7334 * to increase the free storage space on the device to 7335 * the requested value. There is no guarantee that clearing all 7336 * the cache files from all applications will clear up 7337 * enough storage to achieve the desired value. 7338 * @param freeStorageSize The number of bytes of storage to be 7339 * freed by the system. Say if freeStorageSize is XX, 7340 * and the current free storage is YY, 7341 * if XX is less than YY, just return. if not free XX-YY number 7342 * of bytes if possible. 7343 * @param pi IntentSender call back used to 7344 * notify when the operation is completed.May be null 7345 * to indicate that no call back is desired. 7346 * 7347 * @hide 7348 */ 7349 @UnsupportedAppUsage freeStorage(long freeStorageSize, @Nullable IntentSender pi)7350 public void freeStorage(long freeStorageSize, @Nullable IntentSender pi) { 7351 freeStorage(null, freeStorageSize, pi); 7352 } 7353 7354 /** {@hide} */ 7355 @SuppressWarnings("HiddenAbstractMethod") 7356 @UnsupportedAppUsage freeStorage(@ullable String volumeUuid, long freeStorageSize, @Nullable IntentSender pi)7357 public abstract void freeStorage(@Nullable String volumeUuid, long freeStorageSize, 7358 @Nullable IntentSender pi); 7359 7360 /** 7361 * Retrieve the size information for a package. 7362 * Since this may take a little while, the result will 7363 * be posted back to the given observer. The calling context 7364 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 7365 * 7366 * @param packageName The name of the package whose size information is to be retrieved 7367 * @param userId The user whose size information should be retrieved. 7368 * @param observer An observer callback to get notified when the operation 7369 * is complete. 7370 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 7371 * The observer's callback is invoked with a PackageStats object(containing the 7372 * code, data and cache sizes of the package) and a boolean value representing 7373 * the status of the operation. observer may be null to indicate that 7374 * no callback is desired. 7375 * 7376 * @deprecated use {@link StorageStatsManager} instead. 7377 * @hide 7378 */ 7379 @SuppressWarnings("HiddenAbstractMethod") 7380 @Deprecated 7381 @UnsupportedAppUsage getPackageSizeInfoAsUser(@onNull String packageName, @UserIdInt int userId, @Nullable IPackageStatsObserver observer)7382 public abstract void getPackageSizeInfoAsUser(@NonNull String packageName, 7383 @UserIdInt int userId, @Nullable IPackageStatsObserver observer); 7384 7385 /** 7386 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 7387 * returns the size for the calling user. 7388 * 7389 * @deprecated use {@link StorageStatsManager} instead. 7390 * @hide 7391 */ 7392 @Deprecated 7393 @UnsupportedAppUsage getPackageSizeInfo(@onNull String packageName, IPackageStatsObserver observer)7394 public void getPackageSizeInfo(@NonNull String packageName, IPackageStatsObserver observer) { 7395 getPackageSizeInfoAsUser(packageName, getUserId(), observer); 7396 } 7397 7398 /** 7399 * @deprecated This function no longer does anything. It is the platform's 7400 * responsibility to assign preferred activities and this cannot be modified 7401 * directly. To determine the activities resolved by the platform, use 7402 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7403 * an app to be responsible for a particular role and to check current role 7404 * holders, see {@link android.app.role.RoleManager}. 7405 */ 7406 @Deprecated addPackageToPreferred(@onNull String packageName)7407 public abstract void addPackageToPreferred(@NonNull String packageName); 7408 7409 /** 7410 * @deprecated This function no longer does anything. It is the platform's 7411 * responsibility to assign preferred activities and this cannot be modified 7412 * directly. To determine the activities resolved by the platform, use 7413 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7414 * an app to be responsible for a particular role and to check current role 7415 * holders, see {@link android.app.role.RoleManager}. 7416 */ 7417 @Deprecated removePackageFromPreferred(@onNull String packageName)7418 public abstract void removePackageFromPreferred(@NonNull String packageName); 7419 7420 /** 7421 * Retrieve the list of all currently configured preferred packages. The 7422 * first package on the list is the most preferred, the last is the least 7423 * preferred. 7424 * 7425 * @param flags Additional option flags to modify the data returned. 7426 * @return A List of PackageInfo objects, one for each preferred 7427 * application, in order of preference. 7428 * 7429 * @deprecated This function no longer does anything. It is the platform's 7430 * responsibility to assign preferred activities and this cannot be modified 7431 * directly. To determine the activities resolved by the platform, use 7432 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7433 * an app to be responsible for a particular role and to check current role 7434 * holders, see {@link android.app.role.RoleManager}. 7435 */ 7436 @NonNull 7437 @Deprecated getPreferredPackages(@ackageInfoFlags int flags)7438 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 7439 7440 /** 7441 * Add a new preferred activity mapping to the system. This will be used 7442 * to automatically select the given activity component when 7443 * {@link Context#startActivity(Intent) Context.startActivity()} finds 7444 * multiple matching activities and also matches the given filter. 7445 * 7446 * @param filter The set of intents under which this activity will be 7447 * made preferred. 7448 * @param match The IntentFilter match category that this preference 7449 * applies to. 7450 * @param set The set of activities that the user was picking from when 7451 * this preference was made. 7452 * @param activity The component name of the activity that is to be 7453 * preferred. 7454 * 7455 * @deprecated This function no longer does anything. It is the platform's 7456 * responsibility to assign preferred activities and this cannot be modified 7457 * directly. To determine the activities resolved by the platform, use 7458 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7459 * an app to be responsible for a particular role and to check current role 7460 * holders, see {@link android.app.role.RoleManager}. 7461 */ 7462 @Deprecated addPreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)7463 public abstract void addPreferredActivity(@NonNull IntentFilter filter, int match, 7464 @Nullable ComponentName[] set, @NonNull ComponentName activity); 7465 7466 /** 7467 * Same as {@link #addPreferredActivity(IntentFilter, int, 7468 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 7469 to. 7470 * @hide 7471 * 7472 * @deprecated This function no longer does anything. It is the platform's 7473 * responsibility to assign preferred activities and this cannot be modified 7474 * directly. To determine the activities resolved by the platform, use 7475 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7476 * an app to be responsible for a particular role and to check current role 7477 * holders, see {@link android.app.role.RoleManager}. 7478 */ 7479 @Deprecated 7480 @UnsupportedAppUsage addPreferredActivityAsUser(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId)7481 public void addPreferredActivityAsUser(@NonNull IntentFilter filter, int match, 7482 @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) { 7483 throw new RuntimeException("Not implemented. Must override in a subclass."); 7484 } 7485 7486 /** 7487 * Replaces an existing preferred activity mapping to the system, and if that were not present 7488 * adds a new preferred activity. This will be used 7489 * to automatically select the given activity component when 7490 * {@link Context#startActivity(Intent) Context.startActivity()} finds 7491 * multiple matching activities and also matches the given filter. 7492 * 7493 * @param filter The set of intents under which this activity will be 7494 * made preferred. 7495 * @param match The IntentFilter match category that this preference 7496 * applies to. 7497 * @param set The set of activities that the user was picking from when 7498 * this preference was made. 7499 * @param activity The component name of the activity that is to be 7500 * preferred. 7501 * 7502 * @hide 7503 * 7504 * @deprecated This function no longer does anything. It is the platform's 7505 * responsibility to assign preferred activities and this cannot be modified 7506 * directly. To determine the activities resolved by the platform, use 7507 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7508 * an app to be responsible for a particular role and to check current role 7509 * holders, see {@link android.app.role.RoleManager}. 7510 */ 7511 @SuppressWarnings("HiddenAbstractMethod") 7512 @Deprecated 7513 @UnsupportedAppUsage replacePreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)7514 public abstract void replacePreferredActivity(@NonNull IntentFilter filter, int match, 7515 @Nullable ComponentName[] set, @NonNull ComponentName activity); 7516 7517 /** 7518 * Replaces an existing preferred activity mapping to the system, and if that were not present 7519 * adds a new preferred activity. This will be used to automatically select the given activity 7520 * component when {@link Context#startActivity(Intent) Context.startActivity()} finds multiple 7521 * matching activities and also matches the given filter. 7522 * 7523 * @param filter The set of intents under which this activity will be made preferred. 7524 * @param match The IntentFilter match category that this preference applies to. Should be a 7525 * combination of {@link IntentFilter#MATCH_CATEGORY_MASK} and 7526 * {@link IntentFilter#MATCH_ADJUSTMENT_MASK}). 7527 * @param set The set of activities that the user was picking from when this preference was 7528 * made. 7529 * @param activity The component name of the activity that is to be preferred. 7530 * 7531 * @hide 7532 */ 7533 @SystemApi replacePreferredActivity(@onNull IntentFilter filter, int match, @NonNull List<ComponentName> set, @NonNull ComponentName activity)7534 public void replacePreferredActivity(@NonNull IntentFilter filter, int match, 7535 @NonNull List<ComponentName> set, @NonNull ComponentName activity) { 7536 replacePreferredActivity(filter, match, set.toArray(new ComponentName[0]), activity); 7537 } 7538 7539 /** 7540 * @hide 7541 * 7542 * @deprecated This function no longer does anything. It is the platform's 7543 * responsibility to assign preferred activities and this cannot be modified 7544 * directly. To determine the activities resolved by the platform, use 7545 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7546 * an app to be responsible for a particular role and to check current role 7547 * holders, see {@link android.app.role.RoleManager}. 7548 */ 7549 @Deprecated 7550 @UnsupportedAppUsage replacePreferredActivityAsUser(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId)7551 public void replacePreferredActivityAsUser(@NonNull IntentFilter filter, int match, 7552 @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) { 7553 throw new RuntimeException("Not implemented. Must override in a subclass."); 7554 } 7555 7556 /** 7557 * Remove all preferred activity mappings, previously added with 7558 * {@link #addPreferredActivity}, from the 7559 * system whose activities are implemented in the given package name. 7560 * An application can only clear its own package(s). 7561 * 7562 * @param packageName The name of the package whose preferred activity 7563 * mappings are to be removed. 7564 * 7565 * @deprecated This function no longer does anything. It is the platform's 7566 * responsibility to assign preferred activities and this cannot be modified 7567 * directly. To determine the activities resolved by the platform, use 7568 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7569 * an app to be responsible for a particular role and to check current role 7570 * holders, see {@link android.app.role.RoleManager}. 7571 */ 7572 @Deprecated clearPackagePreferredActivities(@onNull String packageName)7573 public abstract void clearPackagePreferredActivities(@NonNull String packageName); 7574 7575 /** 7576 * Same as {@link #addPreferredActivity(IntentFilter, int, ComponentName[], ComponentName)}, 7577 * but removes all existing entries that match this filter. 7578 * @hide 7579 */ addUniquePreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)7580 public void addUniquePreferredActivity(@NonNull IntentFilter filter, int match, 7581 @Nullable ComponentName[] set, @NonNull ComponentName activity) { 7582 throw new UnsupportedOperationException( 7583 "addUniquePreferredActivity not implemented in subclass"); 7584 } 7585 7586 /** 7587 * Retrieve all preferred activities, previously added with 7588 * {@link #addPreferredActivity}, that are 7589 * currently registered with the system. 7590 * 7591 * @param outFilters A required list in which to place the filters of all of the 7592 * preferred activities. 7593 * @param outActivities A required list in which to place the component names of 7594 * all of the preferred activities. 7595 * @param packageName An optional package in which you would like to limit 7596 * the list. If null, all activities will be returned; if non-null, only 7597 * those activities in the given package are returned. 7598 * 7599 * @return Returns the total number of registered preferred activities 7600 * (the number of distinct IntentFilter records, not the number of unique 7601 * activity components) that were found. 7602 * 7603 * @deprecated This function no longer does anything. It is the platform's 7604 * responsibility to assign preferred activities and this cannot be modified 7605 * directly. To determine the activities resolved by the platform, use 7606 * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure 7607 * an app to be responsible for a particular role and to check current role 7608 * holders, see {@link android.app.role.RoleManager}. 7609 */ 7610 @Deprecated getPreferredActivities(@onNull List<IntentFilter> outFilters, @NonNull List<ComponentName> outActivities, @Nullable String packageName)7611 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 7612 @NonNull List<ComponentName> outActivities, @Nullable String packageName); 7613 7614 /** 7615 * Ask for the set of available 'home' activities and the current explicit 7616 * default, if any. 7617 * @hide 7618 */ 7619 @SuppressWarnings("HiddenAbstractMethod") 7620 @Nullable 7621 @UnsupportedAppUsage getHomeActivities(@onNull List<ResolveInfo> outActivities)7622 public abstract ComponentName getHomeActivities(@NonNull List<ResolveInfo> outActivities); 7623 7624 /** 7625 * Set the enabled setting for a package component (activity, receiver, service, provider). 7626 * This setting will override any enabled state which may have been set by the component in its 7627 * manifest. 7628 * 7629 * @param componentName The component to enable 7630 * @param newState The new enabled state for the component. 7631 * @param flags Optional behavior flags. 7632 */ 7633 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 7634 conditional = true) setComponentEnabledSetting(@onNull ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags)7635 public abstract void setComponentEnabledSetting(@NonNull ComponentName componentName, 7636 @EnabledState int newState, @EnabledFlags int flags); 7637 7638 /** 7639 * Return the enabled setting for a package component (activity, 7640 * receiver, service, provider). This returns the last value set by 7641 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 7642 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 7643 * the value originally specified in the manifest has not been modified. 7644 * 7645 * @param componentName The component to retrieve. 7646 * @return Returns the current enabled state for the component. 7647 */ getComponentEnabledSetting( @onNull ComponentName componentName)7648 public abstract @EnabledState int getComponentEnabledSetting( 7649 @NonNull ComponentName componentName); 7650 7651 /** 7652 * Set whether a synthetic app details activity will be generated if the app has no enabled 7653 * launcher activity. Disabling this allows the app to have no launcher icon. 7654 * 7655 * @param packageName The package name of the app 7656 * @param enabled The new enabled state for the synthetic app details activity. 7657 * 7658 * @hide 7659 */ 7660 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 7661 conditional = true) 7662 @SystemApi setSyntheticAppDetailsActivityEnabled(@onNull String packageName, boolean enabled)7663 public void setSyntheticAppDetailsActivityEnabled(@NonNull String packageName, 7664 boolean enabled) { 7665 throw new UnsupportedOperationException( 7666 "setSyntheticAppDetailsActivityEnabled not implemented"); 7667 } 7668 7669 7670 /** 7671 * Return whether a synthetic app details activity will be generated if the app has no enabled 7672 * launcher activity. 7673 * 7674 * @param packageName The package name of the app 7675 * @return Returns the enabled state for the synthetic app details activity. 7676 * 7677 * 7678 */ getSyntheticAppDetailsActivityEnabled(@onNull String packageName)7679 public boolean getSyntheticAppDetailsActivityEnabled(@NonNull String packageName) { 7680 throw new UnsupportedOperationException( 7681 "getSyntheticAppDetailsActivityEnabled not implemented"); 7682 } 7683 7684 /** 7685 * Set the enabled setting for an application 7686 * This setting will override any enabled state which may have been set by the application in 7687 * its manifest. It also overrides the enabled state set in the manifest for any of the 7688 * application's components. It does not override any enabled state set by 7689 * {@link #setComponentEnabledSetting} for any of the application's components. 7690 * 7691 * @param packageName The package name of the application to enable 7692 * @param newState The new enabled state for the application. 7693 * @param flags Optional behavior flags. 7694 */ 7695 @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE, 7696 conditional = true) setApplicationEnabledSetting(@onNull String packageName, @EnabledState int newState, @EnabledFlags int flags)7697 public abstract void setApplicationEnabledSetting(@NonNull String packageName, 7698 @EnabledState int newState, @EnabledFlags int flags); 7699 7700 /** 7701 * Return the enabled setting for an application. This returns 7702 * the last value set by 7703 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 7704 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 7705 * the value originally specified in the manifest has not been modified. 7706 * 7707 * @param packageName The package name of the application to retrieve. 7708 * @return Returns the current enabled state for the application. 7709 * @throws IllegalArgumentException if the named package does not exist. 7710 */ getApplicationEnabledSetting(@onNull String packageName)7711 public abstract @EnabledState int getApplicationEnabledSetting(@NonNull String packageName); 7712 7713 /** 7714 * Flush the package restrictions for a given user to disk. This forces the package restrictions 7715 * like component and package enabled settings to be written to disk and avoids the delay that 7716 * is otherwise present when changing those settings. 7717 * 7718 * @param userId Ther userId of the user whose restrictions are to be flushed. 7719 * @hide 7720 */ 7721 @SuppressWarnings("HiddenAbstractMethod") 7722 @UnsupportedAppUsage flushPackageRestrictionsAsUser(@serIdInt int userId)7723 public abstract void flushPackageRestrictionsAsUser(@UserIdInt int userId); 7724 7725 /** 7726 * Puts the package in a hidden state, which is almost like an uninstalled state, 7727 * making the package unavailable, but it doesn't remove the data or the actual 7728 * package file. Application can be unhidden by either resetting the hidden state 7729 * or by installing it, such as with {@link #installExistingPackage(String)} 7730 * @hide 7731 */ 7732 @SuppressWarnings("HiddenAbstractMethod") 7733 @UnsupportedAppUsage setApplicationHiddenSettingAsUser(@onNull String packageName, boolean hidden, @NonNull UserHandle userHandle)7734 public abstract boolean setApplicationHiddenSettingAsUser(@NonNull String packageName, 7735 boolean hidden, @NonNull UserHandle userHandle); 7736 7737 /** 7738 * Returns the hidden state of a package. 7739 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 7740 * @hide 7741 */ 7742 @SuppressWarnings("HiddenAbstractMethod") 7743 @UnsupportedAppUsage getApplicationHiddenSettingAsUser(@onNull String packageName, @NonNull UserHandle userHandle)7744 public abstract boolean getApplicationHiddenSettingAsUser(@NonNull String packageName, 7745 @NonNull UserHandle userHandle); 7746 7747 /** 7748 * Sets the state of a system app. 7749 * 7750 * This method can be used to change a system app's hidden-until-installed state (via 7751 * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN} and 7752 * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE} or its installation state (via 7753 * {@link #SYSTEM_APP_STATE_INSTALLED} and {@link #SYSTEM_APP_STATE_UNINSTALLED}. 7754 * 7755 * This API may only be called from {@link android.os.Process#SYSTEM_UID} or 7756 * {@link android.os.Process#PHONE_UID}. 7757 * 7758 * @param packageName Package name of the app. 7759 * @param state State of the app. 7760 * @hide 7761 */ 7762 @SystemApi setSystemAppState(@onNull String packageName, @SystemAppState int state)7763 public void setSystemAppState(@NonNull String packageName, @SystemAppState int state) { 7764 throw new RuntimeException("Not implemented. Must override in a subclass"); 7765 } 7766 7767 /** 7768 * Return whether the device has been booted into safe mode. 7769 */ isSafeMode()7770 public abstract boolean isSafeMode(); 7771 7772 /** 7773 * Adds a listener for permission changes for installed packages. 7774 * 7775 * @param listener The listener to add. 7776 * 7777 * @hide 7778 */ 7779 //@Deprecated 7780 @SuppressWarnings("HiddenAbstractMethod") 7781 @SystemApi 7782 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) addOnPermissionsChangeListener( @onNull OnPermissionsChangedListener listener)7783 public abstract void addOnPermissionsChangeListener( 7784 @NonNull OnPermissionsChangedListener listener); 7785 7786 /** 7787 * Remvoes a listener for permission changes for installed packages. 7788 * 7789 * @param listener The listener to remove. 7790 * 7791 * @hide 7792 */ 7793 //@Deprecated 7794 @SuppressWarnings("HiddenAbstractMethod") 7795 @SystemApi 7796 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) removeOnPermissionsChangeListener( @onNull OnPermissionsChangedListener listener)7797 public abstract void removeOnPermissionsChangeListener( 7798 @NonNull OnPermissionsChangedListener listener); 7799 7800 /** 7801 * Return the {@link KeySet} associated with the String alias for this 7802 * application. 7803 * 7804 * @param alias The alias for a given {@link KeySet} as defined in the 7805 * application's AndroidManifest.xml. 7806 * @hide 7807 */ 7808 @SuppressWarnings("HiddenAbstractMethod") 7809 @NonNull 7810 @UnsupportedAppUsage getKeySetByAlias(@onNull String packageName, @NonNull String alias)7811 public abstract KeySet getKeySetByAlias(@NonNull String packageName, @NonNull String alias); 7812 7813 /** Return the signing {@link KeySet} for this application. 7814 * @hide 7815 */ 7816 @SuppressWarnings("HiddenAbstractMethod") 7817 @NonNull 7818 @UnsupportedAppUsage getSigningKeySet(@onNull String packageName)7819 public abstract KeySet getSigningKeySet(@NonNull String packageName); 7820 7821 /** 7822 * Return whether the package denoted by packageName has been signed by all 7823 * of the keys specified by the {@link KeySet} ks. This will return true if 7824 * the package has been signed by additional keys (a superset) as well. 7825 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 7826 * @hide 7827 */ 7828 @SuppressWarnings("HiddenAbstractMethod") 7829 @UnsupportedAppUsage isSignedBy(@onNull String packageName, @NonNull KeySet ks)7830 public abstract boolean isSignedBy(@NonNull String packageName, @NonNull KeySet ks); 7831 7832 /** 7833 * Return whether the package denoted by packageName has been signed by all 7834 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 7835 * {@link #isSignedBy(String packageName, KeySet ks)}. 7836 * @hide 7837 */ 7838 @SuppressWarnings("HiddenAbstractMethod") 7839 @UnsupportedAppUsage isSignedByExactly(@onNull String packageName, @NonNull KeySet ks)7840 public abstract boolean isSignedByExactly(@NonNull String packageName, @NonNull KeySet ks); 7841 7842 /** 7843 * Flag to denote no restrictions. This should be used to clear any restrictions that may have 7844 * been previously set for the package. 7845 * @hide 7846 * @see #setDistractingPackageRestrictions(String[], int) 7847 */ 7848 @SystemApi 7849 public static final int RESTRICTION_NONE = 0x0; 7850 7851 /** 7852 * Flag to denote that a package should be hidden from any suggestions to the user. 7853 * @hide 7854 * @see #setDistractingPackageRestrictions(String[], int) 7855 */ 7856 @SystemApi 7857 public static final int RESTRICTION_HIDE_FROM_SUGGESTIONS = 0x00000001; 7858 7859 /** 7860 * Flag to denote that a package's notifications should be hidden. 7861 * @hide 7862 * @see #setDistractingPackageRestrictions(String[], int) 7863 */ 7864 @SystemApi 7865 public static final int RESTRICTION_HIDE_NOTIFICATIONS = 0x00000002; 7866 7867 /** 7868 * Restriction flags to set on a package that is considered as distracting to the user. 7869 * These should help the user to restrict their usage of these apps. 7870 * 7871 * @see #setDistractingPackageRestrictions(String[], int) 7872 * @hide 7873 */ 7874 @IntDef(flag = true, prefix = {"RESTRICTION_"}, value = { 7875 RESTRICTION_NONE, 7876 RESTRICTION_HIDE_FROM_SUGGESTIONS, 7877 RESTRICTION_HIDE_NOTIFICATIONS 7878 }) 7879 @Retention(RetentionPolicy.SOURCE) 7880 public @interface DistractionRestriction {} 7881 7882 /** 7883 * Mark or unmark the given packages as distracting to the user. 7884 * These packages can have certain restrictions set that should discourage the user to launch 7885 * them often. For example, notifications from such an app can be hidden, or the app can be 7886 * removed from launcher suggestions, so the user is able to restrict their use of these apps. 7887 * 7888 * <p>The caller must hold {@link android.Manifest.permission#SUSPEND_APPS} to use this API. 7889 * 7890 * @param packages Packages to mark as distracting. 7891 * @param restrictionFlags Any combination of restrictions to impose on the given packages. 7892 * {@link #RESTRICTION_NONE} can be used to clear any existing 7893 * restrictions. 7894 * @return A list of packages that could not have the {@code restrictionFlags} set. The system 7895 * may prevent restricting critical packages to preserve normal device function. 7896 * 7897 * @hide 7898 * @see #RESTRICTION_NONE 7899 * @see #RESTRICTION_HIDE_FROM_SUGGESTIONS 7900 * @see #RESTRICTION_HIDE_NOTIFICATIONS 7901 */ 7902 @SystemApi 7903 @RequiresPermission(android.Manifest.permission.SUSPEND_APPS) 7904 @NonNull setDistractingPackageRestrictions(@onNull String[] packages, @DistractionRestriction int restrictionFlags)7905 public String[] setDistractingPackageRestrictions(@NonNull String[] packages, 7906 @DistractionRestriction int restrictionFlags) { 7907 throw new UnsupportedOperationException( 7908 "setDistractingPackageRestrictions not implemented"); 7909 } 7910 7911 /** 7912 * Puts the package in a suspended state, where attempts at starting activities are denied. 7913 * 7914 * <p>It doesn't remove the data or the actual package file. The application's notifications 7915 * will be hidden, any of its started activities will be stopped and it will not be able to 7916 * show toasts or system alert windows or ring the device. 7917 * 7918 * <p>When the user tries to launch a suspended app, a system dialog with the given 7919 * {@code dialogMessage} will be shown instead. Since the message is supplied to the system as 7920 * a {@link String}, the caller needs to take care of localization as needed. 7921 * The dialog message can optionally contain a placeholder for the name of the suspended app. 7922 * The system uses {@link String#format(Locale, String, Object...) String.format} to insert the 7923 * app name into the message, so an example format string could be {@code "The app %1$s is 7924 * currently suspended"}. This makes it easier for callers to provide a single message which 7925 * works for all the packages being suspended in a single call. 7926 * 7927 * <p>The package must already be installed. If the package is uninstalled while suspended 7928 * the package will no longer be suspended. </p> 7929 * 7930 * <p>Optionally, the suspending app can provide extra information in the form of 7931 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 7932 * launcher to support customization that they might need to handle the suspended state. 7933 * 7934 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API. 7935 * 7936 * @param packageNames The names of the packages to set the suspended status. 7937 * @param suspended If set to {@code true}, the packages will be suspended, if set to 7938 * {@code false}, the packages will be unsuspended. 7939 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 7940 * which will be shared with the apps being suspended. Ignored if 7941 * {@code suspended} is false. 7942 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 7943 * provide which will be shared with the launcher. Ignored if 7944 * {@code suspended} is false. 7945 * @param dialogMessage The message to be displayed to the user, when they try to launch a 7946 * suspended app. 7947 * 7948 * @return an array of package names for which the suspended status could not be set as 7949 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}. 7950 * 7951 * @deprecated use {@link #setPackagesSuspended(String[], boolean, PersistableBundle, 7952 * PersistableBundle, android.content.pm.SuspendDialogInfo)} instead. 7953 * 7954 * @hide 7955 */ 7956 @SystemApi 7957 @Deprecated 7958 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 7959 @Nullable setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable String dialogMessage)7960 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended, 7961 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 7962 @Nullable String dialogMessage) { 7963 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 7964 } 7965 7966 /** 7967 * Puts the given packages in a suspended state, where attempts at starting activities are 7968 * denied. 7969 * 7970 * <p>The suspended application's notifications and all of its windows will be hidden, any 7971 * of its started activities will be stopped and it won't be able to ring the device. 7972 * It doesn't remove the data or the actual package file. 7973 * 7974 * <p>When the user tries to launch a suspended app, a system dialog alerting them that the app 7975 * is suspended will be shown instead. 7976 * The caller can optionally customize the dialog by passing a {@link SuspendDialogInfo} object 7977 * to this API. This dialog will have a button that starts the 7978 * {@link Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS} intent if the suspending app declares an 7979 * activity which handles this action. 7980 * 7981 * <p>The packages being suspended must already be installed. If a package is uninstalled, it 7982 * will no longer be suspended. 7983 * 7984 * <p>Optionally, the suspending app can provide extra information in the form of 7985 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 7986 * launcher to support customization that they might need to handle the suspended state. 7987 * 7988 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API. 7989 * 7990 * @param packageNames The names of the packages to set the suspended status. 7991 * @param suspended If set to {@code true}, the packages will be suspended, if set to 7992 * {@code false}, the packages will be unsuspended. 7993 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 7994 * which will be shared with the apps being suspended. Ignored if 7995 * {@code suspended} is false. 7996 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 7997 * provide which will be shared with the launcher. Ignored if 7998 * {@code suspended} is false. 7999 * @param dialogInfo An optional {@link SuspendDialogInfo} object describing the dialog that 8000 * should be shown to the user when they try to launch a suspended app. 8001 * Ignored if {@code suspended} is false. 8002 * 8003 * @return an array of package names for which the suspended status could not be set as 8004 * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}. 8005 * 8006 * @see #isPackageSuspended 8007 * @see SuspendDialogInfo 8008 * @see SuspendDialogInfo.Builder 8009 * @see Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS 8010 * 8011 * @hide 8012 */ 8013 @SystemApi 8014 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 8015 @Nullable setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable SuspendDialogInfo dialogInfo)8016 public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended, 8017 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 8018 @Nullable SuspendDialogInfo dialogInfo) { 8019 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 8020 } 8021 8022 /** 8023 * Returns any packages in a given set of packages that cannot be suspended via a call to {@link 8024 * #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, 8025 * SuspendDialogInfo) setPackagesSuspended}. The platform prevents suspending certain critical 8026 * packages to keep the device in a functioning state, e.g. the default dialer and launcher. 8027 * Apps need to hold {@link Manifest.permission#SUSPEND_APPS SUSPEND_APPS} to call this API. 8028 * 8029 * <p> 8030 * Note that this set of critical packages can change with time, so even though a package name 8031 * was not returned by this call, it does not guarantee that a subsequent call to 8032 * {@link #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, 8033 * SuspendDialogInfo) setPackagesSuspended} for that package will succeed, especially if 8034 * significant time elapsed between the two calls. 8035 * 8036 * @param packageNames The packages to check. 8037 * @return A list of packages that can not be currently suspended by the system. 8038 * @hide 8039 */ 8040 @SystemApi 8041 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 8042 @NonNull getUnsuspendablePackages(@onNull String[] packageNames)8043 public String[] getUnsuspendablePackages(@NonNull String[] packageNames) { 8044 throw new UnsupportedOperationException("getUnsuspendablePackages not implemented"); 8045 } 8046 8047 /** 8048 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 8049 * @param packageName The name of the package to get the suspended status of. 8050 * @param userId The user id. 8051 * @return {@code true} if the package is suspended or {@code false} if the package is not 8052 * suspended. 8053 * @throws IllegalArgumentException if the package was not found. 8054 * @hide 8055 */ 8056 @SuppressWarnings("HiddenAbstractMethod") 8057 @UnsupportedAppUsage isPackageSuspendedForUser(@onNull String packageName, int userId)8058 public abstract boolean isPackageSuspendedForUser(@NonNull String packageName, int userId); 8059 8060 /** 8061 * Query if an app is currently suspended. 8062 * 8063 * @return {@code true} if the given package is suspended, {@code false} otherwise 8064 * @throws NameNotFoundException if the package could not be found. 8065 * 8066 * @see #isPackageSuspended() 8067 */ isPackageSuspended(@onNull String packageName)8068 public boolean isPackageSuspended(@NonNull String packageName) throws NameNotFoundException { 8069 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 8070 } 8071 8072 /** 8073 * Apps can query this to know if they have been suspended. A system app with the permission 8074 * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state. 8075 * 8076 * <p>While in this state, the application's notifications will be hidden, any of its started 8077 * activities will be stopped and it will not be able to show toasts or dialogs or play audio. 8078 * When the user tries to launch a suspended app, the system will, instead, show a 8079 * dialog to the user informing them that they cannot use this app while it is suspended. 8080 * 8081 * <p>When an app is put into this state, the broadcast action 8082 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast 8083 * receivers that included this action in their intent-filters, <em>including manifest 8084 * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED} 8085 * is delivered when a previously suspended app is taken out of this state. Apps are expected to 8086 * use these to gracefully deal with transitions to and from this state. 8087 * 8088 * @return {@code true} if the calling package has been suspended, {@code false} otherwise. 8089 * 8090 * @see #getSuspendedPackageAppExtras() 8091 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 8092 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 8093 */ isPackageSuspended()8094 public boolean isPackageSuspended() { 8095 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 8096 } 8097 8098 /** 8099 * Returns a {@link Bundle} of extras that was meant to be sent to the calling app when it was 8100 * suspended. An app with the permission {@code android.permission.SUSPEND_APPS} can supply this 8101 * to the system at the time of suspending an app. 8102 * 8103 * <p>This is the same {@link Bundle} that is sent along with the broadcast 8104 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED}, whenever the app is suspended. The contents of 8105 * this {@link Bundle} are a contract between the suspended app and the suspending app. 8106 * 8107 * <p>Note: These extras are optional, so if no extras were supplied to the system, this method 8108 * will return {@code null}, even when the calling app has been suspended. 8109 * 8110 * @return A {@link Bundle} containing the extras for the app, or {@code null} if the 8111 * package is not currently suspended. 8112 * 8113 * @see #isPackageSuspended() 8114 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 8115 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 8116 * @see Intent#EXTRA_SUSPENDED_PACKAGE_EXTRAS 8117 */ getSuspendedPackageAppExtras()8118 public @Nullable Bundle getSuspendedPackageAppExtras() { 8119 throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented"); 8120 } 8121 8122 /** 8123 * Provide a hint of what the {@link ApplicationInfo#category} value should 8124 * be for the given package. 8125 * <p> 8126 * This hint can only be set by the app which installed this package, as 8127 * determined by {@link #getInstallerPackageName(String)}. 8128 * 8129 * @param packageName the package to change the category hint for. 8130 * @param categoryHint the category hint to set. 8131 */ 8132 @SuppressWarnings("HiddenAbstractMethod") setApplicationCategoryHint(@onNull String packageName, @ApplicationInfo.Category int categoryHint)8133 public abstract void setApplicationCategoryHint(@NonNull String packageName, 8134 @ApplicationInfo.Category int categoryHint); 8135 8136 /** {@hide} */ isMoveStatusFinished(int status)8137 public static boolean isMoveStatusFinished(int status) { 8138 return (status < 0 || status > 100); 8139 } 8140 8141 /** {@hide} */ 8142 public static abstract class MoveCallback { onCreated(int moveId, Bundle extras)8143 public void onCreated(int moveId, Bundle extras) {} onStatusChanged(int moveId, int status, long estMillis)8144 public abstract void onStatusChanged(int moveId, int status, long estMillis); 8145 } 8146 8147 /** {@hide} */ 8148 @SuppressWarnings("HiddenAbstractMethod") 8149 @UnsupportedAppUsage getMoveStatus(int moveId)8150 public abstract int getMoveStatus(int moveId); 8151 8152 /** {@hide} */ 8153 @SuppressWarnings("HiddenAbstractMethod") 8154 @UnsupportedAppUsage registerMoveCallback(@onNull MoveCallback callback, @NonNull Handler handler)8155 public abstract void registerMoveCallback(@NonNull MoveCallback callback, 8156 @NonNull Handler handler); 8157 /** {@hide} */ 8158 @SuppressWarnings("HiddenAbstractMethod") 8159 @UnsupportedAppUsage unregisterMoveCallback(@onNull MoveCallback callback)8160 public abstract void unregisterMoveCallback(@NonNull MoveCallback callback); 8161 8162 /** {@hide} */ 8163 @SuppressWarnings("HiddenAbstractMethod") 8164 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) movePackage(@onNull String packageName, @NonNull VolumeInfo vol)8165 public abstract int movePackage(@NonNull String packageName, @NonNull VolumeInfo vol); 8166 /** {@hide} */ 8167 @SuppressWarnings("HiddenAbstractMethod") 8168 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getPackageCurrentVolume(@onNull ApplicationInfo app)8169 public abstract @Nullable VolumeInfo getPackageCurrentVolume(@NonNull ApplicationInfo app); 8170 /** {@hide} */ 8171 @SuppressWarnings("HiddenAbstractMethod") 8172 @NonNull 8173 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getPackageCandidateVolumes( @onNull ApplicationInfo app)8174 public abstract List<VolumeInfo> getPackageCandidateVolumes( 8175 @NonNull ApplicationInfo app); 8176 8177 /** {@hide} */ 8178 @SuppressWarnings("HiddenAbstractMethod") movePrimaryStorage(@onNull VolumeInfo vol)8179 public abstract int movePrimaryStorage(@NonNull VolumeInfo vol); 8180 /** {@hide} */ 8181 @SuppressWarnings("HiddenAbstractMethod") getPrimaryStorageCurrentVolume()8182 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 8183 /** {@hide} */ 8184 @SuppressWarnings("HiddenAbstractMethod") getPrimaryStorageCandidateVolumes()8185 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 8186 8187 /** 8188 * Returns the device identity that verifiers can use to associate their scheme to a particular 8189 * device. This should not be used by anything other than a package verifier. 8190 * 8191 * @return identity that uniquely identifies current device 8192 * @hide 8193 */ 8194 @SuppressWarnings("HiddenAbstractMethod") 8195 @NonNull getVerifierDeviceIdentity()8196 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 8197 8198 /** 8199 * Returns true if the device is upgrading, such as first boot after OTA. 8200 * 8201 * @hide 8202 */ 8203 @SuppressWarnings("HiddenAbstractMethod") 8204 @UnsupportedAppUsage isUpgrade()8205 public abstract boolean isUpgrade(); 8206 8207 /** 8208 * Returns true if the device is upgrading, such as first boot after OTA. 8209 */ isDeviceUpgrading()8210 public boolean isDeviceUpgrading() { 8211 return false; 8212 } 8213 8214 /** 8215 * Return interface that offers the ability to install, upgrade, and remove 8216 * applications on the device. 8217 */ getPackageInstaller()8218 public abstract @NonNull PackageInstaller getPackageInstaller(); 8219 8220 /** 8221 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 8222 * intents sent from the user with id sourceUserId can also be be resolved 8223 * by activities in the user with id targetUserId if they match the 8224 * specified intent filter. 8225 * 8226 * @param filter The {@link IntentFilter} the intent has to match 8227 * @param sourceUserId The source user id. 8228 * @param targetUserId The target user id. 8229 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 8230 * {@link #ONLY_IF_NO_MATCH_FOUND}. 8231 * @hide 8232 */ 8233 @SuppressWarnings("HiddenAbstractMethod") 8234 @UnsupportedAppUsage addCrossProfileIntentFilter(@onNull IntentFilter filter, @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags)8235 public abstract void addCrossProfileIntentFilter(@NonNull IntentFilter filter, 8236 @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags); 8237 8238 /** 8239 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 8240 * as their source, and have been set by the app calling this method. 8241 * 8242 * @param sourceUserId The source user id. 8243 * @hide 8244 */ 8245 @SuppressWarnings("HiddenAbstractMethod") 8246 @UnsupportedAppUsage clearCrossProfileIntentFilters(@serIdInt int sourceUserId)8247 public abstract void clearCrossProfileIntentFilters(@UserIdInt int sourceUserId); 8248 8249 /** 8250 * @hide 8251 */ 8252 @SuppressWarnings("HiddenAbstractMethod") 8253 @NonNull 8254 @UnsupportedAppUsage loadItemIcon(@onNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo)8255 public abstract Drawable loadItemIcon(@NonNull PackageItemInfo itemInfo, 8256 @Nullable ApplicationInfo appInfo); 8257 8258 /** 8259 * @hide 8260 */ 8261 @SuppressWarnings("HiddenAbstractMethod") 8262 @NonNull 8263 @UnsupportedAppUsage loadUnbadgedItemIcon(@onNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo)8264 public abstract Drawable loadUnbadgedItemIcon(@NonNull PackageItemInfo itemInfo, 8265 @Nullable ApplicationInfo appInfo); 8266 8267 /** {@hide} */ 8268 @SuppressWarnings("HiddenAbstractMethod") 8269 @UnsupportedAppUsage isPackageAvailable(@onNull String packageName)8270 public abstract boolean isPackageAvailable(@NonNull String packageName); 8271 8272 /** {@hide} */ 8273 @NonNull 8274 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) installStatusToString(int status, @Nullable String msg)8275 public static String installStatusToString(int status, @Nullable String msg) { 8276 final String str = installStatusToString(status); 8277 if (msg != null) { 8278 return str + ": " + msg; 8279 } else { 8280 return str; 8281 } 8282 } 8283 8284 /** {@hide} */ 8285 @NonNull 8286 @UnsupportedAppUsage installStatusToString(int status)8287 public static String installStatusToString(int status) { 8288 switch (status) { 8289 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 8290 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 8291 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 8292 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 8293 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 8294 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 8295 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 8296 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 8297 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 8298 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 8299 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 8300 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 8301 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 8302 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 8303 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 8304 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 8305 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 8306 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 8307 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 8308 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 8309 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 8310 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 8311 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 8312 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 8313 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 8314 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 8315 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 8316 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 8317 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 8318 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 8319 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 8320 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 8321 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 8322 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 8323 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 8324 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 8325 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 8326 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 8327 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 8328 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 8329 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 8330 case INSTALL_FAILED_BAD_DEX_METADATA: return "INSTALL_FAILED_BAD_DEX_METADATA"; 8331 case INSTALL_FAILED_MISSING_SPLIT: return "INSTALL_FAILED_MISSING_SPLIT"; 8332 case INSTALL_FAILED_BAD_SIGNATURE: return "INSTALL_FAILED_BAD_SIGNATURE"; 8333 case INSTALL_FAILED_WRONG_INSTALLED_VERSION: return "INSTALL_FAILED_WRONG_INSTALLED_VERSION"; 8334 case INSTALL_FAILED_PROCESS_NOT_DEFINED: return "INSTALL_FAILED_PROCESS_NOT_DEFINED"; 8335 case INSTALL_FAILED_SESSION_INVALID: return "INSTALL_FAILED_SESSION_INVALID"; 8336 default: return Integer.toString(status); 8337 } 8338 } 8339 8340 /** {@hide} */ installStatusToPublicStatus(int status)8341 public static int installStatusToPublicStatus(int status) { 8342 switch (status) { 8343 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 8344 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8345 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 8346 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 8347 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 8348 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8349 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8350 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8351 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8352 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 8353 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8354 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 8355 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 8356 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8357 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 8358 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 8359 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 8360 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 8361 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 8362 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 8363 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 8364 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 8365 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 8366 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 8367 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 8368 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 8369 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 8370 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 8371 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 8372 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 8373 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 8374 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 8375 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 8376 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 8377 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 8378 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 8379 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 8380 case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID; 8381 case INSTALL_FAILED_BAD_SIGNATURE: return PackageInstaller.STATUS_FAILURE_INVALID; 8382 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 8383 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 8384 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8385 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 8386 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 8387 case INSTALL_FAILED_MISSING_SPLIT: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 8388 default: return PackageInstaller.STATUS_FAILURE; 8389 } 8390 } 8391 8392 /** {@hide} */ 8393 @NonNull deleteStatusToString(int status, @Nullable String msg)8394 public static String deleteStatusToString(int status, @Nullable String msg) { 8395 final String str = deleteStatusToString(status); 8396 if (msg != null) { 8397 return str + ": " + msg; 8398 } else { 8399 return str; 8400 } 8401 } 8402 8403 /** {@hide} */ 8404 @NonNull 8405 @UnsupportedAppUsage deleteStatusToString(int status)8406 public static String deleteStatusToString(int status) { 8407 switch (status) { 8408 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 8409 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 8410 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 8411 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 8412 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 8413 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 8414 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY"; 8415 case DELETE_FAILED_APP_PINNED: return "DELETE_FAILED_APP_PINNED"; 8416 default: return Integer.toString(status); 8417 } 8418 } 8419 8420 /** {@hide} */ deleteStatusToPublicStatus(int status)8421 public static int deleteStatusToPublicStatus(int status) { 8422 switch (status) { 8423 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 8424 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 8425 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 8426 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 8427 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 8428 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 8429 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT; 8430 case DELETE_FAILED_APP_PINNED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 8431 default: return PackageInstaller.STATUS_FAILURE; 8432 } 8433 } 8434 8435 /** {@hide} */ 8436 @NonNull permissionFlagToString(int flag)8437 public static String permissionFlagToString(int flag) { 8438 switch (flag) { 8439 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 8440 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 8441 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 8442 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 8443 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 8444 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 8445 case FLAG_PERMISSION_REVOKE_WHEN_REQUESTED: return "REVOKE_WHEN_REQUESTED"; 8446 case FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED: return "USER_SENSITIVE_WHEN_GRANTED"; 8447 case FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED: return "USER_SENSITIVE_WHEN_DENIED"; 8448 case FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT: return "RESTRICTION_INSTALLER_EXEMPT"; 8449 case FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT: return "RESTRICTION_SYSTEM_EXEMPT"; 8450 case FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT: return "RESTRICTION_UPGRADE_EXEMPT"; 8451 case FLAG_PERMISSION_APPLY_RESTRICTION: return "APPLY_RESTRICTION"; 8452 case FLAG_PERMISSION_GRANTED_BY_ROLE: return "GRANTED_BY_ROLE"; 8453 case FLAG_PERMISSION_REVOKED_COMPAT: return "REVOKED_COMPAT"; 8454 case FLAG_PERMISSION_ONE_TIME: return "ONE_TIME"; 8455 case FLAG_PERMISSION_AUTO_REVOKED: return "AUTO_REVOKED"; 8456 default: return Integer.toString(flag); 8457 } 8458 } 8459 8460 /** {@hide} */ 8461 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 8462 private final IPackageDeleteObserver mLegacy; 8463 LegacyPackageDeleteObserver(IPackageDeleteObserver legacy)8464 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 8465 mLegacy = legacy; 8466 } 8467 8468 @Override onPackageDeleted(String basePackageName, int returnCode, String msg)8469 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 8470 if (mLegacy == null) return; 8471 try { 8472 mLegacy.packageDeleted(basePackageName, returnCode); 8473 } catch (RemoteException ignored) { 8474 } 8475 } 8476 } 8477 8478 /** 8479 * Return the install reason that was recorded when a package was first 8480 * installed for a specific user. Requesting the install reason for another 8481 * user will require the permission INTERACT_ACROSS_USERS_FULL. 8482 * 8483 * @param packageName The package for which to retrieve the install reason 8484 * @param user The user for whom to retrieve the install reason 8485 * @return The install reason. If the package is not installed for the given 8486 * user, {@code INSTALL_REASON_UNKNOWN} is returned. 8487 * @hide 8488 */ 8489 @SuppressWarnings("HiddenAbstractMethod") 8490 @TestApi 8491 @InstallReason getInstallReason(@onNull String packageName, @NonNull UserHandle user)8492 public abstract int getInstallReason(@NonNull String packageName, @NonNull UserHandle user); 8493 8494 /** 8495 * Checks whether the calling package is allowed to request package installs through package 8496 * installer. Apps are encouraged to call this API before launching the package installer via 8497 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the 8498 * user can explicitly choose what external sources they trust to install apps on the device. 8499 * If this API returns false, the install request will be blocked by the package installer and 8500 * a dialog will be shown to the user with an option to launch settings to change their 8501 * preference. An application must target Android O or higher and declare permission 8502 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API. 8503 * 8504 * @return true if the calling package is trusted by the user to request install packages on 8505 * the device, false otherwise. 8506 * @see android.content.Intent#ACTION_INSTALL_PACKAGE 8507 * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES 8508 */ canRequestPackageInstalls()8509 public abstract boolean canRequestPackageInstalls(); 8510 8511 /** 8512 * Return the {@link ComponentName} of the activity providing Settings for the Instant App 8513 * resolver. 8514 * 8515 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS} 8516 * @hide 8517 */ 8518 @SuppressWarnings("HiddenAbstractMethod") 8519 @Nullable 8520 @SystemApi getInstantAppResolverSettingsComponent()8521 public abstract ComponentName getInstantAppResolverSettingsComponent(); 8522 8523 /** 8524 * Return the {@link ComponentName} of the activity responsible for installing instant 8525 * applications. 8526 * 8527 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE} 8528 * @hide 8529 */ 8530 @SuppressWarnings("HiddenAbstractMethod") 8531 @Nullable 8532 @SystemApi getInstantAppInstallerComponent()8533 public abstract ComponentName getInstantAppInstallerComponent(); 8534 8535 /** 8536 * Return the Android Id for a given Instant App. 8537 * 8538 * @see {@link android.provider.Settings.Secure#ANDROID_ID} 8539 * @hide 8540 */ 8541 @SuppressWarnings("HiddenAbstractMethod") 8542 @Nullable getInstantAppAndroidId(@onNull String packageName, @NonNull UserHandle user)8543 public abstract String getInstantAppAndroidId(@NonNull String packageName, 8544 @NonNull UserHandle user); 8545 8546 /** 8547 * Callback use to notify the callers of module registration that the operation 8548 * has finished. 8549 * 8550 * @hide 8551 */ 8552 @SystemApi 8553 public static abstract class DexModuleRegisterCallback { onDexModuleRegistered(String dexModulePath, boolean success, String message)8554 public abstract void onDexModuleRegistered(String dexModulePath, boolean success, 8555 String message); 8556 } 8557 8558 /** 8559 * Register an application dex module with the package manager. 8560 * The package manager will keep track of the given module for future optimizations. 8561 * 8562 * Dex module optimizations will disable the classpath checking at runtime. The client bares 8563 * the responsibility to ensure that the static assumptions on classes in the optimized code 8564 * hold at runtime (e.g. there's no duplicate classes in the classpath). 8565 * 8566 * Note that the package manager already keeps track of dex modules loaded with 8567 * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}. 8568 * This can be called for an eager registration. 8569 * 8570 * The call might take a while and the results will be posted on the main thread, using 8571 * the given callback. 8572 * 8573 * If the module is intended to be shared with other apps, make sure that the file 8574 * permissions allow for it. 8575 * If at registration time the permissions allow for others to read it, the module would 8576 * be marked as a shared module which might undergo a different optimization strategy. 8577 * (usually shared modules will generated larger optimizations artifacts, 8578 * taking more disk space). 8579 * 8580 * @param dexModulePath the absolute path of the dex module. 8581 * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will 8582 * be called once the registration finishes. 8583 * 8584 * @hide 8585 */ 8586 @SuppressWarnings("HiddenAbstractMethod") 8587 @SystemApi registerDexModule(@onNull String dexModulePath, @Nullable DexModuleRegisterCallback callback)8588 public abstract void registerDexModule(@NonNull String dexModulePath, 8589 @Nullable DexModuleRegisterCallback callback); 8590 8591 /** 8592 * Returns the {@link ArtManager} associated with this package manager. 8593 * 8594 * @hide 8595 */ 8596 @SystemApi getArtManager()8597 public @NonNull ArtManager getArtManager() { 8598 throw new UnsupportedOperationException("getArtManager not implemented in subclass"); 8599 } 8600 8601 /** 8602 * Sets or clears the harmful app warning details for the given app. 8603 * 8604 * When set, any attempt to launch an activity in this package will be intercepted and a 8605 * warning dialog will be shown to the user instead, with the given warning. The user 8606 * will have the option to proceed with the activity launch, or to uninstall the application. 8607 * 8608 * @param packageName The full name of the package to warn on. 8609 * @param warning A warning string to display to the user describing the threat posed by the 8610 * application, or null to clear the warning. 8611 * 8612 * @hide 8613 */ 8614 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 8615 @SystemApi setHarmfulAppWarning(@onNull String packageName, @Nullable CharSequence warning)8616 public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) { 8617 throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass"); 8618 } 8619 8620 /** 8621 * Returns the harmful app warning string for the given app, or null if there is none set. 8622 * 8623 * @param packageName The full name of the desired package. 8624 * 8625 * @hide 8626 */ 8627 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 8628 @Nullable 8629 @SystemApi getHarmfulAppWarning(@onNull String packageName)8630 public CharSequence getHarmfulAppWarning(@NonNull String packageName) { 8631 throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass"); 8632 } 8633 8634 /** @hide */ 8635 @IntDef(prefix = { "CERT_INPUT_" }, value = { 8636 CERT_INPUT_RAW_X509, 8637 CERT_INPUT_SHA256 8638 }) 8639 @Retention(RetentionPolicy.SOURCE) 8640 public @interface CertificateInputType {} 8641 8642 /** 8643 * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could 8644 * be generated using an {@code CertificateFactory} 8645 */ 8646 public static final int CERT_INPUT_RAW_X509 = 0; 8647 8648 /** 8649 * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509 8650 * Certificate. 8651 */ 8652 public static final int CERT_INPUT_SHA256 = 1; 8653 8654 /** 8655 * Searches the set of signing certificates by which the given package has proven to have been 8656 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 8657 * since it takes into account the possibility of signing certificate rotation, except in the 8658 * case of packages that are signed by multiple certificates, for which signing certificate 8659 * rotation is not supported. This method is analogous to using {@code getPackageInfo} with 8660 * {@code GET_SIGNING_CERTIFICATES} and then searching through the resulting {@code 8661 * signingInfo} field to see if the desired certificate is present. 8662 * 8663 * @param packageName package whose signing certificates to check 8664 * @param certificate signing certificate for which to search 8665 * @param type representation of the {@code certificate} 8666 * @return true if this package was or is signed by exactly the certificate {@code certificate} 8667 */ hasSigningCertificate(@onNull String packageName, @NonNull byte[] certificate, @CertificateInputType int type)8668 public boolean hasSigningCertificate(@NonNull String packageName, @NonNull byte[] certificate, 8669 @CertificateInputType int type) { 8670 throw new UnsupportedOperationException( 8671 "hasSigningCertificate not implemented in subclass"); 8672 } 8673 8674 /** 8675 * Searches the set of signing certificates by which the package(s) for the given uid has proven 8676 * to have been signed. For multiple packages sharing the same uid, this will return the 8677 * signing certificates found in the signing history of the "newest" package, where "newest" 8678 * indicates the package with the newest signing certificate in the shared uid group. This 8679 * method should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 8680 * since it takes into account the possibility of signing certificate rotation, except in the 8681 * case of packages that are signed by multiple certificates, for which signing certificate 8682 * rotation is not supported. This method is analogous to using {@code getPackagesForUid} 8683 * followed by {@code getPackageInfo} with {@code GET_SIGNING_CERTIFICATES}, selecting the 8684 * {@code PackageInfo} of the newest-signed bpackage , and finally searching through the 8685 * resulting {@code signingInfo} field to see if the desired certificate is there. 8686 * 8687 * @param uid uid whose signing certificates to check 8688 * @param certificate signing certificate for which to search 8689 * @param type representation of the {@code certificate} 8690 * @return true if this package was or is signed by exactly the certificate {@code certificate} 8691 */ hasSigningCertificate( int uid, @NonNull byte[] certificate, @CertificateInputType int type)8692 public boolean hasSigningCertificate( 8693 int uid, @NonNull byte[] certificate, @CertificateInputType int type) { 8694 throw new UnsupportedOperationException( 8695 "hasSigningCertificate not implemented in subclass"); 8696 } 8697 8698 /** 8699 * Trust any Installer to provide checksums for the package. 8700 * @see #requestChecksums 8701 */ 8702 public static final @NonNull List<Certificate> TRUST_ALL = Collections.singletonList(null); 8703 8704 /** 8705 * Don't trust any Installer to provide checksums for the package. 8706 * This effectively disables optimized Installer-enforced checksums. 8707 * @see #requestChecksums 8708 */ 8709 public static final @NonNull List<Certificate> TRUST_NONE = Collections.singletonList(null); 8710 8711 /** Listener that gets notified when checksums are available. */ 8712 @FunctionalInterface 8713 public interface OnChecksumsReadyListener { 8714 /** 8715 * Called when the checksums are available. 8716 * 8717 * @param checksums array of checksums. 8718 */ onChecksumsReady(@onNull List<ApkChecksum> checksums)8719 void onChecksumsReady(@NonNull List<ApkChecksum> checksums); 8720 } 8721 8722 /** 8723 * Requesting the checksums for APKs within a package. 8724 * The checksums will be returned asynchronously via onChecksumsReadyListener. 8725 * 8726 * By default returns all readily available checksums: 8727 * - enforced by platform, 8728 * - enforced by installer. 8729 * If caller needs a specific checksum kind, they can specify it as required. 8730 * 8731 * <b>Caution: Android can not verify installer-provided checksums. Make sure you specify 8732 * trusted installers.</b> 8733 * 8734 * @param packageName whose checksums to return. 8735 * @param includeSplits whether to include checksums for non-base splits. 8736 * @param required explicitly request the checksum types. May incur significant 8737 * CPU/memory/disk usage. 8738 * @param trustedInstallers for checksums enforced by installer, which installers are to be 8739 * trusted. 8740 * {@link #TRUST_ALL} will return checksums from any installer, 8741 * {@link #TRUST_NONE} disables optimized installer-enforced checksums, 8742 * otherwise the list has to be non-empty list of certificates. 8743 * @param onChecksumsReadyListener called once when the results are available. 8744 * @throws CertificateEncodingException if an encoding error occurs for trustedInstallers. 8745 * @throws IllegalArgumentException if the list of trusted installer certificates is empty. 8746 * @throws NameNotFoundException if a package with the given name cannot be found on the system. 8747 */ requestChecksums(@onNull String packageName, boolean includeSplits, @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers, @NonNull OnChecksumsReadyListener onChecksumsReadyListener)8748 public void requestChecksums(@NonNull String packageName, boolean includeSplits, 8749 @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers, 8750 @NonNull OnChecksumsReadyListener onChecksumsReadyListener) 8751 throws CertificateEncodingException, NameNotFoundException { 8752 throw new UnsupportedOperationException("requestChecksums not implemented in subclass"); 8753 } 8754 8755 /** 8756 * @return the default text classifier package name, or null if there's none. 8757 * 8758 * @hide 8759 */ 8760 @Nullable 8761 @TestApi getDefaultTextClassifierPackageName()8762 public String getDefaultTextClassifierPackageName() { 8763 throw new UnsupportedOperationException( 8764 "getDefaultTextClassifierPackageName not implemented in subclass"); 8765 } 8766 8767 /** 8768 * @return the system defined text classifier package names, or null if there's none. 8769 * 8770 * @hide 8771 */ 8772 @Nullable 8773 @TestApi getSystemTextClassifierPackageName()8774 public String getSystemTextClassifierPackageName() { 8775 throw new UnsupportedOperationException( 8776 "getSystemTextClassifierPackageName not implemented in subclass"); 8777 } 8778 8779 /** 8780 * @return attention service package name, or null if there's none. 8781 * 8782 * @hide 8783 */ getAttentionServicePackageName()8784 public String getAttentionServicePackageName() { 8785 throw new UnsupportedOperationException( 8786 "getAttentionServicePackageName not implemented in subclass"); 8787 } 8788 8789 /** 8790 * @return rotation resolver service's package name, or null if there's none. 8791 * 8792 * @hide 8793 */ getRotationResolverPackageName()8794 public String getRotationResolverPackageName() { 8795 throw new UnsupportedOperationException( 8796 "getRotationResolverPackageName not implemented in subclass"); 8797 } 8798 8799 /** 8800 * @return the wellbeing app package name, or null if it's not defined by the OEM. 8801 * 8802 * @hide 8803 */ 8804 @Nullable 8805 @TestApi getWellbeingPackageName()8806 public String getWellbeingPackageName() { 8807 throw new UnsupportedOperationException( 8808 "getWellbeingPackageName not implemented in subclass"); 8809 } 8810 8811 /** 8812 * @return the system defined app predictor package name, or null if there's none. 8813 * 8814 * @hide 8815 */ 8816 @Nullable getAppPredictionServicePackageName()8817 public String getAppPredictionServicePackageName() { 8818 throw new UnsupportedOperationException( 8819 "getAppPredictionServicePackageName not implemented in subclass"); 8820 } 8821 8822 /** 8823 * @return the system defined content capture service package name, or null if there's none. 8824 * 8825 * @hide 8826 */ 8827 @Nullable getSystemCaptionsServicePackageName()8828 public String getSystemCaptionsServicePackageName() { 8829 throw new UnsupportedOperationException( 8830 "getSystemCaptionsServicePackageName not implemented in subclass"); 8831 } 8832 8833 /** 8834 * @return the system defined setup wizard package name, or null if there's none. 8835 * 8836 * @hide 8837 */ 8838 @Nullable getSetupWizardPackageName()8839 public String getSetupWizardPackageName() { 8840 throw new UnsupportedOperationException( 8841 "getSetupWizardPackageName not implemented in subclass"); 8842 } 8843 8844 /** 8845 * @return the system defined content capture package name, or null if there's none. 8846 * 8847 * @hide 8848 */ 8849 @TestApi 8850 @Nullable getContentCaptureServicePackageName()8851 public String getContentCaptureServicePackageName() { 8852 throw new UnsupportedOperationException( 8853 "getContentCaptureServicePackageName not implemented in subclass"); 8854 } 8855 8856 /** 8857 * @return the incident report approver app package name, or null if it's not defined 8858 * by the OEM. 8859 * 8860 * @hide 8861 */ 8862 @SystemApi 8863 @Nullable getIncidentReportApproverPackageName()8864 public String getIncidentReportApproverPackageName() { 8865 throw new UnsupportedOperationException( 8866 "getIncidentReportApproverPackageName not implemented in subclass"); 8867 } 8868 8869 /** 8870 * @return whether a given package's state is protected, e.g. package cannot be disabled, 8871 * suspended, hidden or force stopped. 8872 * 8873 * @hide 8874 */ isPackageStateProtected(@onNull String packageName, @UserIdInt int userId)8875 public boolean isPackageStateProtected(@NonNull String packageName, @UserIdInt int userId) { 8876 throw new UnsupportedOperationException( 8877 "isPackageStateProtected not implemented in subclass"); 8878 } 8879 8880 /** 8881 * Notify to the rest of the system that a new device configuration has 8882 * been prepared and that it is time to refresh caches. 8883 * 8884 * @see android.content.Intent#ACTION_DEVICE_CUSTOMIZATION_READY 8885 * 8886 * @hide 8887 */ 8888 @SystemApi sendDeviceCustomizationReadyBroadcast()8889 public void sendDeviceCustomizationReadyBroadcast() { 8890 throw new UnsupportedOperationException( 8891 "sendDeviceCustomizationReadyBroadcast not implemented in subclass"); 8892 } 8893 8894 /** 8895 * <p> 8896 * <strong>Note: </strong>In retrospect it would have been preferred to use 8897 * more inclusive terminology when naming this API. Similar APIs added will 8898 * refrain from using the term "whitelist". 8899 * </p> 8900 * 8901 * @return whether this package is whitelisted from having its runtime permission be 8902 * auto-revoked if unused for an extended period of time. 8903 */ isAutoRevokeWhitelisted()8904 public boolean isAutoRevokeWhitelisted() { 8905 throw new UnsupportedOperationException( 8906 "isAutoRevokeWhitelisted not implemented in subclass"); 8907 } 8908 8909 /** 8910 * Returns if the provided drawable represents the default activity icon provided by the system. 8911 * 8912 * PackageManager silently returns a default application icon for any package/activity if the 8913 * app itself does not define one or if the system encountered any error when loading the icon. 8914 * 8915 * Developers can use this to check implement app specific logic around retrying or caching. 8916 * 8917 * @return true if the drawable represents the default activity icon, false otherwise 8918 * @see #getDefaultActivityIcon() 8919 * @see #getActivityIcon 8920 * @see LauncherActivityInfo#getIcon(int) 8921 */ isDefaultApplicationIcon(@onNull Drawable drawable)8922 public boolean isDefaultApplicationIcon(@NonNull Drawable drawable) { 8923 int resId = drawable instanceof AdaptiveIconDrawable 8924 ? ((AdaptiveIconDrawable) drawable).getSourceDrawableResId() : Resources.ID_NULL; 8925 return resId == com.android.internal.R.drawable.sym_def_app_icon 8926 || resId == com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon; 8927 } 8928 8929 /** 8930 * Sets MIME group's MIME types. 8931 * 8932 * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific 8933 * group name to avoid namespace collisions, e.g. "com.example:myFeature". 8934 * 8935 * @param mimeGroup MIME group to modify. 8936 * @param mimeTypes new MIME types contained by MIME group. 8937 * @throws IllegalArgumentException if the MIME group was not declared in the manifest. 8938 */ setMimeGroup(@onNull String mimeGroup, @NonNull Set<String> mimeTypes)8939 public void setMimeGroup(@NonNull String mimeGroup, @NonNull Set<String> mimeTypes) { 8940 throw new UnsupportedOperationException( 8941 "setMimeGroup not implemented in subclass"); 8942 } 8943 8944 /** 8945 * Gets all MIME types contained by MIME group. 8946 * 8947 * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific 8948 * group name to avoid namespace collisions, e.g. "com.example:myFeature". 8949 * 8950 * @param mimeGroup MIME group to retrieve. 8951 * @return MIME types contained by the MIME group. 8952 * @throws IllegalArgumentException if the MIME group was not declared in the manifest. 8953 */ 8954 @NonNull getMimeGroup(@onNull String mimeGroup)8955 public Set<String> getMimeGroup(@NonNull String mimeGroup) { 8956 throw new UnsupportedOperationException( 8957 "getMimeGroup not implemented in subclass"); 8958 } 8959 8960 /** 8961 * Returns the property defined in the given package's <appliction> tag. 8962 * 8963 * @throws NameNotFoundException if either the given package is not installed or if the 8964 * given property is not defined within the <application> tag. 8965 */ 8966 @NonNull getProperty(@onNull String propertyName, @NonNull String packageName)8967 public Property getProperty(@NonNull String propertyName, @NonNull String packageName) 8968 throws NameNotFoundException { 8969 throw new UnsupportedOperationException( 8970 "getProperty not implemented in subclass"); 8971 } 8972 8973 /** 8974 * Returns the property defined in the given component declaration. 8975 * 8976 * @throws NameNotFoundException if either the given component does not exist or if the 8977 * given property is not defined within the component declaration. 8978 */ 8979 @NonNull getProperty(@onNull String propertyName, @NonNull ComponentName component)8980 public Property getProperty(@NonNull String propertyName, @NonNull ComponentName component) 8981 throws NameNotFoundException { 8982 throw new UnsupportedOperationException( 8983 "getProperty not implemented in subclass"); 8984 } 8985 8986 /** 8987 * Returns the property definition for all <application> tags. 8988 * <p>If the property is not defined with any <application> tag, 8989 * returns and empty list. 8990 */ 8991 @NonNull queryApplicationProperty(@onNull String propertyName)8992 public List<Property> queryApplicationProperty(@NonNull String propertyName) { 8993 throw new UnsupportedOperationException( 8994 "qeuryApplicationProperty not implemented in subclass"); 8995 } 8996 8997 /** 8998 * Returns the property definition for all <activity> and <activity-alias> tags. 8999 * <p>If the property is not defined with any <activity> and <activity-alias> tag, 9000 * returns and empty list. 9001 */ 9002 @NonNull queryActivityProperty(@onNull String propertyName)9003 public List<Property> queryActivityProperty(@NonNull String propertyName) { 9004 throw new UnsupportedOperationException( 9005 "qeuryActivityProperty not implemented in subclass"); 9006 } 9007 9008 /** 9009 * Returns the property definition for all <provider> tags. 9010 * <p>If the property is not defined with any <provider> tag, 9011 * returns and empty list. 9012 */ 9013 @NonNull queryProviderProperty(@onNull String propertyName)9014 public List<Property> queryProviderProperty(@NonNull String propertyName) { 9015 throw new UnsupportedOperationException( 9016 "qeuryProviderProperty not implemented in subclass"); 9017 } 9018 9019 /** 9020 * Returns the property definition for all <receiver> tags. 9021 * <p>If the property is not defined with any <receiver> tag, 9022 * returns and empty list. 9023 */ 9024 @NonNull queryReceiverProperty(@onNull String propertyName)9025 public List<Property> queryReceiverProperty(@NonNull String propertyName) { 9026 throw new UnsupportedOperationException( 9027 "qeuryReceiverProperty not implemented in subclass"); 9028 } 9029 9030 /** 9031 * Returns the property definition for all <service> tags. 9032 * <p>If the property is not defined with any <service> tag, 9033 * returns and empty list. 9034 */ 9035 @NonNull queryServiceProperty(@onNull String propertyName)9036 public List<Property> queryServiceProperty(@NonNull String propertyName) { 9037 throw new UnsupportedOperationException( 9038 "qeuryServiceProperty not implemented in subclass"); 9039 } 9040 9041 /** 9042 * Grants implicit visibility of the package that provides an authority to a querying UID. 9043 * 9044 * @throws SecurityException when called by a package other than the contacts provider 9045 * @hide 9046 */ grantImplicitAccess(int queryingUid, String visibleAuthority)9047 public void grantImplicitAccess(int queryingUid, String visibleAuthority) { 9048 try { 9049 ActivityThread.getPackageManager().grantImplicitAccess(queryingUid, visibleAuthority); 9050 } catch (RemoteException e) { 9051 throw e.rethrowFromSystemServer(); 9052 } 9053 } 9054 9055 // Some of the flags don't affect the query result, but let's be conservative and cache 9056 // each combination of flags separately. 9057 9058 private static final class ApplicationInfoQuery { 9059 final String packageName; 9060 final int flags; 9061 final int userId; 9062 ApplicationInfoQuery(@ullable String packageName, int flags, int userId)9063 ApplicationInfoQuery(@Nullable String packageName, int flags, int userId) { 9064 this.packageName = packageName; 9065 this.flags = flags; 9066 this.userId = userId; 9067 } 9068 9069 @Override toString()9070 public String toString() { 9071 return String.format( 9072 "ApplicationInfoQuery(packageName=\"%s\", flags=%s, userId=%s)", 9073 packageName, flags, userId); 9074 } 9075 9076 @Override hashCode()9077 public int hashCode() { 9078 int hash = Objects.hashCode(packageName); 9079 hash = hash * 13 + Objects.hashCode(flags); 9080 hash = hash * 13 + Objects.hashCode(userId); 9081 return hash; 9082 } 9083 9084 @Override equals(@ullable Object rval)9085 public boolean equals(@Nullable Object rval) { 9086 if (rval == null) { 9087 return false; 9088 } 9089 ApplicationInfoQuery other; 9090 try { 9091 other = (ApplicationInfoQuery) rval; 9092 } catch (ClassCastException ex) { 9093 return false; 9094 } 9095 return Objects.equals(packageName, other.packageName) 9096 && flags == other.flags 9097 && userId == other.userId; 9098 } 9099 } 9100 getApplicationInfoAsUserUncached( String packageName, int flags, int userId)9101 private static ApplicationInfo getApplicationInfoAsUserUncached( 9102 String packageName, int flags, int userId) { 9103 try { 9104 return ActivityThread.getPackageManager() 9105 .getApplicationInfo(packageName, flags, userId); 9106 } catch (RemoteException e) { 9107 throw e.rethrowFromSystemServer(); 9108 } 9109 } 9110 9111 private static final PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo> 9112 sApplicationInfoCache = 9113 new PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo>( 9114 16, PermissionManager.CACHE_KEY_PACKAGE_INFO, 9115 "getApplicationInfo") { 9116 @Override 9117 protected ApplicationInfo recompute(ApplicationInfoQuery query) { 9118 return getApplicationInfoAsUserUncached( 9119 query.packageName, query.flags, query.userId); 9120 } 9121 @Override 9122 protected ApplicationInfo maybeCheckConsistency( 9123 ApplicationInfoQuery query, ApplicationInfo proposedResult) { 9124 // Implementing this debug check for ApplicationInfo would require a 9125 // complicated deep comparison, so just bypass it for now. 9126 return proposedResult; 9127 } 9128 }; 9129 9130 /** @hide */ getApplicationInfoAsUserCached( String packageName, int flags, int userId)9131 public static ApplicationInfo getApplicationInfoAsUserCached( 9132 String packageName, int flags, int userId) { 9133 return sApplicationInfoCache.query( 9134 new ApplicationInfoQuery(packageName, flags, userId)); 9135 } 9136 9137 /** 9138 * Make getApplicationInfoAsUser() bypass the cache in this process. 9139 * 9140 * @hide 9141 */ disableApplicationInfoCache()9142 public static void disableApplicationInfoCache() { 9143 sApplicationInfoCache.disableLocal(); 9144 } 9145 9146 private static final PropertyInvalidatedCache.AutoCorker sCacheAutoCorker = 9147 new PropertyInvalidatedCache.AutoCorker(PermissionManager.CACHE_KEY_PACKAGE_INFO); 9148 9149 /** 9150 * Invalidate caches of package and permission information system-wide. 9151 * 9152 * @hide 9153 */ invalidatePackageInfoCache()9154 public static void invalidatePackageInfoCache() { 9155 sCacheAutoCorker.autoCork(); 9156 } 9157 9158 // Some of the flags don't affect the query result, but let's be conservative and cache 9159 // each combination of flags separately. 9160 9161 private static final class PackageInfoQuery { 9162 final String packageName; 9163 final int flags; 9164 final int userId; 9165 PackageInfoQuery(@ullable String packageName, int flags, int userId)9166 PackageInfoQuery(@Nullable String packageName, int flags, int userId) { 9167 this.packageName = packageName; 9168 this.flags = flags; 9169 this.userId = userId; 9170 } 9171 9172 @Override toString()9173 public String toString() { 9174 return String.format( 9175 "PackageInfoQuery(packageName=\"%s\", flags=%s, userId=%s)", 9176 packageName, flags, userId); 9177 } 9178 9179 @Override hashCode()9180 public int hashCode() { 9181 int hash = Objects.hashCode(packageName); 9182 hash = hash * 13 + Objects.hashCode(flags); 9183 hash = hash * 13 + Objects.hashCode(userId); 9184 return hash; 9185 } 9186 9187 @Override equals(@ullable Object rval)9188 public boolean equals(@Nullable Object rval) { 9189 if (rval == null) { 9190 return false; 9191 } 9192 PackageInfoQuery other; 9193 try { 9194 other = (PackageInfoQuery) rval; 9195 } catch (ClassCastException ex) { 9196 return false; 9197 } 9198 return Objects.equals(packageName, other.packageName) 9199 && flags == other.flags 9200 && userId == other.userId; 9201 } 9202 } 9203 getPackageInfoAsUserUncached( String packageName, int flags, int userId)9204 private static PackageInfo getPackageInfoAsUserUncached( 9205 String packageName, int flags, int userId) { 9206 try { 9207 return ActivityThread.getPackageManager().getPackageInfo(packageName, flags, userId); 9208 } catch (RemoteException e) { 9209 throw e.rethrowFromSystemServer(); 9210 } 9211 } 9212 9213 private static final PropertyInvalidatedCache<PackageInfoQuery, PackageInfo> 9214 sPackageInfoCache = 9215 new PropertyInvalidatedCache<PackageInfoQuery, PackageInfo>( 9216 32, PermissionManager.CACHE_KEY_PACKAGE_INFO, 9217 "getPackageInfo") { 9218 @Override 9219 protected PackageInfo recompute(PackageInfoQuery query) { 9220 return getPackageInfoAsUserUncached( 9221 query.packageName, query.flags, query.userId); 9222 } 9223 @Override 9224 protected PackageInfo maybeCheckConsistency( 9225 PackageInfoQuery query, PackageInfo proposedResult) { 9226 // Implementing this debug check for PackageInfo would require a 9227 // complicated deep comparison, so just bypass it for now. 9228 return proposedResult; 9229 } 9230 }; 9231 9232 /** @hide */ getPackageInfoAsUserCached( String packageName, int flags, int userId)9233 public static PackageInfo getPackageInfoAsUserCached( 9234 String packageName, int flags, int userId) { 9235 return sPackageInfoCache.query(new PackageInfoQuery(packageName, flags, userId)); 9236 } 9237 9238 /** 9239 * Make getPackageInfoAsUser() bypass the cache in this process. 9240 * @hide 9241 */ disablePackageInfoCache()9242 public static void disablePackageInfoCache() { 9243 sPackageInfoCache.disableLocal(); 9244 } 9245 9246 /** 9247 * Inhibit package info cache invalidations when correct. 9248 * 9249 * @hide */ corkPackageInfoCache()9250 public static void corkPackageInfoCache() { 9251 PropertyInvalidatedCache.corkInvalidations(PermissionManager.CACHE_KEY_PACKAGE_INFO); 9252 } 9253 9254 /** 9255 * Enable package info cache invalidations. 9256 * 9257 * @hide */ uncorkPackageInfoCache()9258 public static void uncorkPackageInfoCache() { 9259 PropertyInvalidatedCache.uncorkInvalidations(PermissionManager.CACHE_KEY_PACKAGE_INFO); 9260 } 9261 9262 /** 9263 * Returns the token to be used by the subsequent calls to holdLock(). 9264 * @hide 9265 */ 9266 @RequiresPermission(android.Manifest.permission.INJECT_EVENTS) 9267 @TestApi getHoldLockToken()9268 public IBinder getHoldLockToken() { 9269 try { 9270 return ActivityThread.getPackageManager().getHoldLockToken(); 9271 } catch (RemoteException e) { 9272 throw e.rethrowFromSystemServer(); 9273 } 9274 } 9275 9276 /** 9277 * Holds the PM lock for the specified amount of milliseconds. 9278 * Intended for use by the tests that need to imitate lock contention. 9279 * The token should be obtained by 9280 * {@link android.content.pm.PackageManager#getHoldLockToken()}. 9281 * @hide 9282 */ 9283 @TestApi holdLock(IBinder token, int durationMs)9284 public void holdLock(IBinder token, int durationMs) { 9285 try { 9286 ActivityThread.getPackageManager().holdLock(token, durationMs); 9287 } catch (RemoteException e) { 9288 throw e.rethrowFromSystemServer(); 9289 } 9290 } 9291 9292 /** 9293 * Set a list of apps to keep around as APKs even if no user has currently installed it. 9294 * @param packageList List of package names to keep cached. 9295 * 9296 * @hide 9297 */ 9298 @RequiresPermission(android.Manifest.permission.KEEP_UNINSTALLED_PACKAGES) 9299 @TestApi setKeepUninstalledPackages(@onNull List<String> packageList)9300 public void setKeepUninstalledPackages(@NonNull List<String> packageList) { 9301 try { 9302 ActivityThread.getPackageManager().setKeepUninstalledPackages(packageList); 9303 } catch (RemoteException e) { 9304 throw e.rethrowFromSystemServer(); 9305 } 9306 } 9307 } 9308