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