1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.content.pm;
18 
19 import static android.media.audio.Flags.FLAG_FEATURE_SPATIAL_AUDIO_HEADTRACKING_LOW_LATENCY;
20 
21 import static com.android.internal.pm.pkg.parsing.ParsingPackageUtils.PARSE_COLLECT_CERTIFICATES;
22 
23 import android.Manifest;
24 import android.annotation.CallbackExecutor;
25 import android.annotation.CheckResult;
26 import android.annotation.DrawableRes;
27 import android.annotation.FlaggedApi;
28 import android.annotation.IntDef;
29 import android.annotation.IntRange;
30 import android.annotation.LongDef;
31 import android.annotation.NonNull;
32 import android.annotation.Nullable;
33 import android.annotation.RequiresPermission;
34 import android.annotation.SdkConstant;
35 import android.annotation.SdkConstant.SdkConstantType;
36 import android.annotation.StringRes;
37 import android.annotation.SuppressLint;
38 import android.annotation.SystemApi;
39 import android.annotation.TestApi;
40 import android.annotation.UserIdInt;
41 import android.annotation.WorkerThread;
42 import android.annotation.XmlRes;
43 import android.app.ActivityManager;
44 import android.app.ActivityThread;
45 import android.app.AppDetailsActivity;
46 import android.app.PackageDeleteObserver;
47 import android.app.PackageInstallObserver;
48 import android.app.PropertyInvalidatedCache;
49 import android.app.admin.DevicePolicyManager;
50 import android.app.usage.StorageStatsManager;
51 import android.companion.virtual.VirtualDeviceManager;
52 import android.compat.annotation.ChangeId;
53 import android.compat.annotation.EnabledSince;
54 import android.compat.annotation.UnsupportedAppUsage;
55 import android.content.ComponentName;
56 import android.content.Context;
57 import android.content.Intent;
58 import android.content.IntentFilter;
59 import android.content.IntentSender;
60 import android.content.pm.PackageInstaller.SessionParams;
61 import android.content.pm.dex.ArtManager;
62 import android.content.pm.verify.domain.DomainVerificationManager;
63 import android.content.res.Configuration;
64 import android.content.res.Resources;
65 import android.content.res.TypedArray;
66 import android.content.res.XmlResourceParser;
67 import android.graphics.Rect;
68 import android.graphics.drawable.AdaptiveIconDrawable;
69 import android.graphics.drawable.Drawable;
70 import android.net.ConnectivityManager;
71 import android.net.wifi.WifiManager;
72 import android.os.Build;
73 import android.os.Bundle;
74 import android.os.Handler;
75 import android.os.IBinder;
76 import android.os.IRemoteCallback;
77 import android.os.Parcel;
78 import android.os.ParcelFileDescriptor;
79 import android.os.Parcelable;
80 import android.os.PersistableBundle;
81 import android.os.RemoteException;
82 import android.os.UserHandle;
83 import android.os.UserManager;
84 import android.os.incremental.IncrementalManager;
85 import android.os.storage.StorageManager;
86 import android.os.storage.VolumeInfo;
87 import android.permission.PermissionManager;
88 import android.telephony.TelephonyManager;
89 import android.telephony.UiccCardInfo;
90 import android.telephony.gba.GbaService;
91 import android.telephony.ims.ImsService;
92 import android.telephony.ims.ProvisioningManager;
93 import android.telephony.ims.RcsUceAdapter;
94 import android.telephony.ims.SipDelegateManager;
95 import android.util.AndroidException;
96 import android.util.Log;
97 
98 import com.android.internal.annotations.VisibleForTesting;
99 import com.android.internal.pm.parsing.PackageInfoCommonUtils;
100 import com.android.internal.pm.parsing.PackageParser2;
101 import com.android.internal.pm.parsing.PackageParserException;
102 import com.android.internal.pm.parsing.pkg.ParsedPackage;
103 import com.android.internal.util.ArrayUtils;
104 import com.android.internal.util.DataClass;
105 
106 import dalvik.system.VMRuntime;
107 
108 import java.io.File;
109 import java.io.IOException;
110 import java.lang.annotation.Retention;
111 import java.lang.annotation.RetentionPolicy;
112 import java.security.cert.Certificate;
113 import java.security.cert.CertificateEncodingException;
114 import java.util.Collections;
115 import java.util.List;
116 import java.util.Locale;
117 import java.util.Objects;
118 import java.util.Set;
119 import java.util.UUID;
120 import java.util.concurrent.Executor;
121 import java.util.function.Consumer;
122 import java.util.function.Function;
123 
124 /**
125  * Class for retrieving various kinds of information related to the application
126  * packages that are currently installed on the device.
127  *
128  * You can find this class through {@link Context#getPackageManager}.
129  *
130  * <p class="note"><strong>Note: </strong>If your app targets Android 11 (API level 30) or
131  * higher, the methods in this class each return a filtered list of apps. Learn more about how to
132  * <a href="/training/basics/intents/package-visibility">manage package visibility</a>.
133  * </p>
134  */
135 @android.ravenwood.annotation.RavenwoodKeepPartialClass
136 public abstract class PackageManager {
137     private static final String TAG = "PackageManager";
138 
139     /** {@hide} */
140     public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true;
141 
142     /** {@hide} */
143     public static final boolean ENABLE_SHARED_UID_MIGRATION = true;
144 
145     /**
146      * This exception is thrown when a given package, application, or component
147      * name cannot be found.
148      */
149     public static class NameNotFoundException extends AndroidException {
NameNotFoundException()150         public NameNotFoundException() {
151         }
152 
NameNotFoundException(String name)153         public NameNotFoundException(String name) {
154             super(name);
155         }
156     }
157 
158     /**
159      * &lt;application&gt; level {@link android.content.pm.PackageManager.Property} tag specifying
160      * the XML resource ID containing an application's media capabilities XML file
161      *
162      * For example:
163      * &lt;application&gt;
164      *   &lt;property android:name="android.media.PROPERTY_MEDIA_CAPABILITIES"
165      *     android:resource="@xml/media_capabilities"&gt;
166      * &lt;application&gt;
167      */
168     public static final String PROPERTY_MEDIA_CAPABILITIES =
169             "android.media.PROPERTY_MEDIA_CAPABILITIES";
170 
171     /**
172      * &lt;application&gt; level {@link android.content.pm.PackageManager.Property} tag
173      * specifying the XML resource ID containing the declaration of the self-certified network
174      * capabilities used by the application.
175      *
176      * <p> Starting from Android 14, usage of some network capabilities in
177      * {@link android.net.ConnectivityManager#requestNetwork} require the application to
178      * declare its usage of that particular capability in this resource. Only some capabilities
179      * require a declaration. Please look up the specific capability you want to use in
180      * {@link android.net.NetworkCapabilities} to see if it needs declaration in this property.
181      *
182      * For example:
183      * &lt;application&gt;
184      *   &lt;property android:name="android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES"
185      *     android:resource="@xml/self_certified_network_capabilities"&gt;
186      * &lt;application&gt;
187      *
188      * <p> The detail format of self_certified_network_capabilities.xml is described in
189      * {@link android.net.NetworkRequest}
190      */
191     public static final String PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES =
192             "android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES";
193 
194     /**
195      * Application level property that an app can specify to opt-out from having private data
196      * directories both on the internal and external storages.
197      *
198      * <p>Changing the value of this property during app update is not supported, and such updates
199      * will be rejected.
200      *
201      * <p>This should only be set by platform apps that know what they are doing.
202      *
203      * @hide
204      */
205     public static final String PROPERTY_NO_APP_DATA_STORAGE =
206             "android.internal.PROPERTY_NO_APP_DATA_STORAGE";
207 
208     /**
209      * &lt;service&gt; level {@link android.content.pm.PackageManager.Property} tag specifying
210      * the actual use case of the service if it's foreground service with the type
211      * {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SPECIAL_USE}.
212      *
213      * <p>
214      * For example:
215      * &lt;service&gt;
216      *   &lt;property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
217      *     android:value="foo"/&gt;
218      * &lt;/service&gt;
219      */
220     public static final String PROPERTY_SPECIAL_USE_FGS_SUBTYPE =
221             "android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE";
222 
223     /**
224      * Application level {@link android.content.pm.PackageManager.Property PackageManager
225      * .Property} for an app to inform the system that the app can be opted-in or opted-out
226      * from the compatibility treatment that rotates camera output by 90 degrees on landscape
227      * sensors on devices known to have compatibility issues.
228      *
229      * <p>The treatment is disabled by default but device manufacturers can enable the treatment
230      * using their discretion to improve camera compatibility. With this property set to
231      * {@code false}, the rotation will not be applied. A value of {@code true}
232      * will ensure that rotation is applied, provided it is enabled for the device. In most cases,
233      * if rotation is the desired behavior this property need not be set. However, if your app
234      * experiences stretching or incorrect rotation on these devices, explicitly setting this to
235      * {@code true} may resolve that behavior. Apps should set this to {@code false} if there
236      * is confidence that the app handles
237      * {@link android.hardware.camera2.CameraCharacteristics#SENSOR_ORIENTATION} correctly.
238      * See <a href="https://developer.android.com/training/camera2/camera-preview"> the
239      * documentation for best practice.</a>
240      *
241      * <p><b>Syntax:</b>
242      * <pre>
243      * &lt;application&gt;
244      *   &lt;property
245      *     android:name="android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT"
246      *     android:value="true|false"/&gt;
247      * &lt;/application&gt;
248      * </pre>
249      */
250     public static final String PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT =
251             "android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT";
252 
253     /**
254      * Application level {@link android.content.pm.PackageManager.Property PackageManager
255      * .Property} for a privileged system installer to define a list of up to 500 packages that
256      * should not have their updates owned by any installer. The list must be provided via a default
257      * XML resource with the following format:
258      *
259      * <pre>
260      * &lt;deny-ownership&gt;PACKAGE_NAME&lt;/deny-ownership&gt;
261      * &lt;deny-ownership&gt;PACKAGE_NAME&lt;/deny-ownership&gt;
262      * </pre>
263      *
264      * <b>NOTE:</b> Installers that provide this property will not granted update ownership for any
265      * packages that they request update ownership of.
266      * @hide
267      */
268     public static final String PROPERTY_LEGACY_UPDATE_OWNERSHIP_DENYLIST =
269             "android.app.PROPERTY_LEGACY_UPDATE_OWNERSHIP_DENYLIST";
270 
271     /**
272      * Application level {@link android.content.pm.PackageManager.Property PackageManager
273      * .Property} for a app to inform the installer that a file containing the app's android
274      * safety label data is bundled into the APK as a raw resource.
275      *
276      * <p>For example:
277      * <pre>
278      * &lt;application&gt;
279      *   &lt;property
280      *     android:name="android.content.PROPERTY_ANDROID_SAFETY_LABEL"
281      *     android:resource="@raw/app-metadata"/&gt;
282      * &lt;/application&gt;
283      * </pre>
284      * @hide
285      */
286     public static final String PROPERTY_ANDROID_SAFETY_LABEL =
287             "android.content.PROPERTY_ANDROID_SAFETY_LABEL";
288 
289     /**
290      * A property value set within the manifest.
291      * <p>
292      * The value of a property will only have a single type, as defined by
293      * the property itself.
294      */
295     public static final class Property implements Parcelable {
296         private static final int TYPE_BOOLEAN = 1;
297         private static final int TYPE_FLOAT = 2;
298         private static final int TYPE_INTEGER = 3;
299         private static final int TYPE_RESOURCE = 4;
300         private static final int TYPE_STRING = 5;
301         private final String mName;
302         private final int mType;
303         private final String mClassName;
304         private final String mPackageName;
305         private boolean mBooleanValue;
306         private float mFloatValue;
307         private int mIntegerValue;
308         private String mStringValue;
309 
310         /** @hide */
311         @VisibleForTesting
Property(@onNull String name, int type, @NonNull String packageName, @Nullable String className)312         public Property(@NonNull String name, int type,
313                 @NonNull String packageName, @Nullable String className) {
314             if (type < TYPE_BOOLEAN || type > TYPE_STRING) {
315                 throw new IllegalArgumentException("Invalid type");
316             }
317             this.mName = Objects.requireNonNull(name);
318             this.mType = type;
319             this.mPackageName = Objects.requireNonNull(packageName);
320             this.mClassName = className;
321         }
322         /** @hide */
Property(@onNull String name, boolean value, String packageName, String className)323         public Property(@NonNull String name, boolean value,
324                 String packageName, String className) {
325             this(name, TYPE_BOOLEAN, packageName, className);
326             mBooleanValue = value;
327         }
328         /** @hide */
Property(@onNull String name, float value, String packageName, String className)329         public Property(@NonNull String name, float value,
330                 String packageName, String className) {
331             this(name, TYPE_FLOAT, packageName, className);
332             mFloatValue = value;
333         }
334         /** @hide */
Property(@onNull String name, int value, boolean isResource, String packageName, String className)335         public Property(@NonNull String name, int value, boolean isResource,
336                 String packageName, String className) {
337             this(name, isResource ? TYPE_RESOURCE : TYPE_INTEGER, packageName, className);
338             mIntegerValue = value;
339         }
340         /** @hide */
Property(@onNull String name, String value, String packageName, String className)341         public Property(@NonNull String name, String value,
342                 String packageName, String className) {
343             this(name, TYPE_STRING, packageName, className);
344             mStringValue = value;
345         }
346 
347         /** @hide */
348         @VisibleForTesting
getType()349         public int getType() {
350             return mType;
351         }
352 
353         /**
354          * Returns the name of the property.
355          */
getName()356         @NonNull public String getName() {
357             return mName;
358         }
359 
360         /**
361          * Returns the name of the package where this this property was defined.
362          */
getPackageName()363         @NonNull public String getPackageName() {
364             return mPackageName;
365         }
366 
367         /**
368          * Returns the classname of the component where this property was defined.
369          * <p>If the property was defined within and &lt;application&gt; tag, returns
370          * {@code null}
371          */
getClassName()372         @Nullable public String getClassName() {
373             return mClassName;
374         }
375 
376         /**
377          * Returns the boolean value set for the property.
378          * <p>If the property is not of a boolean type, returns {@code false}.
379          */
getBoolean()380         public boolean getBoolean() {
381             return mBooleanValue;
382         }
383 
384         /**
385          * Returns {@code true} if the property is a boolean type. Otherwise {@code false}.
386          */
isBoolean()387         public boolean isBoolean() {
388             return mType == TYPE_BOOLEAN;
389         }
390 
391         /**
392          * Returns the float value set for the property.
393          * <p>If the property is not of a float type, returns {@code 0.0}.
394          */
getFloat()395         public float getFloat() {
396             return mFloatValue;
397         }
398 
399         /**
400          * Returns {@code true} if the property is a float type. Otherwise {@code false}.
401          */
isFloat()402         public boolean isFloat() {
403             return mType == TYPE_FLOAT;
404         }
405 
406         /**
407          * Returns the integer value set for the property.
408          * <p>If the property is not of an integer type, returns {@code 0}.
409          */
getInteger()410         public int getInteger() {
411             return mType == TYPE_INTEGER ? mIntegerValue : 0;
412         }
413 
414         /**
415          * Returns {@code true} if the property is an integer type. Otherwise {@code false}.
416          */
isInteger()417         public boolean isInteger() {
418             return mType == TYPE_INTEGER;
419         }
420 
421         /**
422          * Returns the a resource id set for the property.
423          * <p>If the property is not of a resource id type, returns {@code 0}.
424          */
getResourceId()425         public int getResourceId() {
426             return mType == TYPE_RESOURCE ? mIntegerValue : 0;
427         }
428 
429         /**
430          * Returns {@code true} if the property is a resource id type. Otherwise {@code false}.
431          */
isResourceId()432         public boolean isResourceId() {
433             return mType == TYPE_RESOURCE;
434         }
435 
436         /**
437          * Returns the a String value set for the property.
438          * <p>If the property is not a String type, returns {@code null}.
439          */
getString()440         @Nullable public String getString() {
441             return mStringValue;
442         }
443 
444         /**
445          * Returns {@code true} if the property is a String type. Otherwise {@code false}.
446          */
isString()447         public boolean isString() {
448             return mType == TYPE_STRING;
449         }
450 
451         /**
452          * Adds a mapping from the given key to this property's value in the provided
453          * {@link android.os.Bundle}. If the provided {@link android.os.Bundle} is
454          * {@code null}, creates a new {@link android.os.Bundle}.
455          * @hide
456          */
toBundle(Bundle outBundle)457         public Bundle toBundle(Bundle outBundle) {
458             final Bundle b = outBundle == null || outBundle == Bundle.EMPTY
459                     ? new Bundle() : outBundle;
460             if (mType == TYPE_BOOLEAN) {
461                 b.putBoolean(mName, mBooleanValue);
462             } else if (mType == TYPE_FLOAT) {
463                 b.putFloat(mName, mFloatValue);
464             } else if (mType == TYPE_INTEGER) {
465                 b.putInt(mName, mIntegerValue);
466             } else if (mType == TYPE_RESOURCE) {
467                 b.putInt(mName, mIntegerValue);
468             } else if (mType == TYPE_STRING) {
469                 b.putString(mName, mStringValue);
470             }
471             return b;
472         }
473 
474         @Override
describeContents()475         public int describeContents() {
476             return 0;
477         }
478 
479         @Override
writeToParcel(@onNull Parcel dest, int flags)480         public void writeToParcel(@NonNull Parcel dest, int flags) {
481             dest.writeString(mName);
482             dest.writeInt(mType);
483             dest.writeString(mPackageName);
484             dest.writeString(mClassName);
485             if (mType == TYPE_BOOLEAN) {
486                 dest.writeBoolean(mBooleanValue);
487             } else if (mType == TYPE_FLOAT) {
488                 dest.writeFloat(mFloatValue);
489             } else if (mType == TYPE_INTEGER) {
490                 dest.writeInt(mIntegerValue);
491             } else if (mType == TYPE_RESOURCE) {
492                 dest.writeInt(mIntegerValue);
493             } else if (mType == TYPE_STRING) {
494                 dest.writeString(mStringValue);
495             }
496         }
497 
498         @NonNull
499         public static final Creator<Property> CREATOR = new Creator<Property>() {
500             @Override
501             public Property createFromParcel(@NonNull Parcel source) {
502                 final String name = source.readString();
503                 final int type = source.readInt();
504                 final String packageName = source.readString();
505                 final String className = source.readString();
506                 if (type == TYPE_BOOLEAN) {
507                     return new Property(name, source.readBoolean(), packageName, className);
508                 } else if (type == TYPE_FLOAT) {
509                     return new Property(name, source.readFloat(), packageName, className);
510                 } else if (type == TYPE_INTEGER) {
511                     return new Property(name, source.readInt(), false, packageName, className);
512                 } else if (type == TYPE_RESOURCE) {
513                     return new Property(name, source.readInt(), true, packageName, className);
514                 } else if (type == TYPE_STRING) {
515                     return new Property(name, source.readString(), packageName, className);
516                 }
517                 return null;
518             }
519 
520             @Override
521             public Property[] newArray(int size) {
522                 return new Property[size];
523             }
524         };
525     }
526 
527     /**
528      * The class containing the enabled setting of a package component.
529      * <p>
530      * This is used by the {@link #setComponentEnabledSettings(List)} to support the batch updates
531      * of the enabled settings of components.
532      *
533      * @see #setComponentEnabledSettings(List)
534      */
535     @DataClass(genConstructor = false)
536     public static final class ComponentEnabledSetting implements Parcelable {
537         /**
538          * The package name of the application to enable the setting.
539          */
540         private final @Nullable String mPackageName;
541 
542         /**
543          * The component name of the application to enable the setting.
544          */
545         private final @Nullable ComponentName mComponentName;
546 
547         /**
548          * The new enabled state
549          */
550         private final @EnabledState int mEnabledState;
551 
552         /**
553          * The optional behavior flag
554          */
555         private final @EnabledFlags int mEnabledFlags;
556 
557         /**
558          * Create an instance of the ComponentEnabledSetting for the component level's enabled
559          * setting update.
560          *
561          * @param componentName The component name to update the enabled setting.
562          * @param newState The new enabled state.
563          * @param flags The optional behavior flags.
564          */
ComponentEnabledSetting(@onNull ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags)565         public ComponentEnabledSetting(@NonNull ComponentName componentName,
566                 @EnabledState int newState, @EnabledFlags int flags) {
567             mPackageName = null;
568             mComponentName = Objects.requireNonNull(componentName);
569             mEnabledState = newState;
570             mEnabledFlags = flags;
571         }
572 
573         /**
574          * Create an instance of the ComponentEnabledSetting for the application level's enabled
575          * setting update.
576          *
577          * @param packageName The package name to update the enabled setting.
578          * @param newState The new enabled state.
579          * @param flags The optional behavior flags.
580          * @hide
581          */
ComponentEnabledSetting(@onNull String packageName, @EnabledState int newState, @EnabledFlags int flags)582         public ComponentEnabledSetting(@NonNull String packageName,
583                 @EnabledState int newState, @EnabledFlags int flags) {
584             mPackageName = Objects.requireNonNull(packageName);
585             mComponentName = null;
586             mEnabledState = newState;
587             mEnabledFlags = flags;
588         }
589 
590         /**
591          * Returns the package name of the setting.
592          *
593          * @return the package name.
594          * @hide
595          */
getPackageName()596         public @NonNull String getPackageName() {
597             if (isComponent()) {
598                 return mComponentName.getPackageName();
599             }
600             return mPackageName;
601         }
602 
603         /**
604          * Returns the component class name of the setting.
605          *
606          * @return the class name.
607          * @hide
608          */
getClassName()609         public @Nullable String getClassName() {
610             if (isComponent()) {
611                 return mComponentName.getClassName();
612             }
613             return null;
614         }
615 
616         /**
617          * Whether or not this is for the component level's enabled setting update.
618          *
619          * @return {@code true} if it's the component level enabled setting update.
620          * @hide
621          */
isComponent()622         public boolean isComponent() {
623             return mComponentName != null;
624         }
625 
626 
627 
628         // Code below generated by codegen v1.0.23.
629         //
630         // DO NOT MODIFY!
631         // CHECKSTYLE:OFF Generated code
632         //
633         // To regenerate run:
634         // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/PackageManager.java
635         //
636         // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
637         //   Settings > Editor > Code Style > Formatter Control
638         //@formatter:off
639 
640 
641         /**
642          * The component name of the application to enable the setting.
643          */
644         @DataClass.Generated.Member
getComponentName()645         public @Nullable ComponentName getComponentName() {
646             return mComponentName;
647         }
648 
649         /**
650          * The new enabled state
651          */
652         @DataClass.Generated.Member
getEnabledState()653         public @EnabledState int getEnabledState() {
654             return mEnabledState;
655         }
656 
657         /**
658          * The optional behavior flag
659          */
660         @DataClass.Generated.Member
getEnabledFlags()661         public @EnabledFlags int getEnabledFlags() {
662             return mEnabledFlags;
663         }
664 
665         @Override
666         @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)667         public void writeToParcel(@NonNull Parcel dest, int flags) {
668             // You can override field parcelling by defining methods like:
669             // void parcelFieldName(Parcel dest, int flags) { ... }
670 
671             byte flg = 0;
672             if (mPackageName != null) flg |= 0x1;
673             if (mComponentName != null) flg |= 0x2;
674             dest.writeByte(flg);
675             if (mPackageName != null) dest.writeString(mPackageName);
676             if (mComponentName != null) dest.writeTypedObject(mComponentName, flags);
677             dest.writeInt(mEnabledState);
678             dest.writeInt(mEnabledFlags);
679         }
680 
681         @Override
682         @DataClass.Generated.Member
describeContents()683         public int describeContents() { return 0; }
684 
685         /** @hide */
686         @SuppressWarnings({"unchecked", "RedundantCast"})
687         @DataClass.Generated.Member
ComponentEnabledSetting(@onNull Parcel in)688         /* package-private */ ComponentEnabledSetting(@NonNull Parcel in) {
689             // You can override field unparcelling by defining methods like:
690             // static FieldType unparcelFieldName(Parcel in) { ... }
691 
692             byte flg = in.readByte();
693             String packageName = (flg & 0x1) == 0 ? null : in.readString();
694             ComponentName componentName = (flg & 0x2) == 0 ? null : (ComponentName) in.readTypedObject(ComponentName.CREATOR);
695             int enabledState = in.readInt();
696             int enabledFlags = in.readInt();
697 
698             this.mPackageName = packageName;
699             this.mComponentName = componentName;
700             this.mEnabledState = enabledState;
701             com.android.internal.util.AnnotationValidations.validate(
702                     EnabledState.class, null, mEnabledState);
703             this.mEnabledFlags = enabledFlags;
704             com.android.internal.util.AnnotationValidations.validate(
705                     EnabledFlags.class, null, mEnabledFlags);
706 
707             // onConstructed(); // You can define this method to get a callback
708         }
709 
710         @DataClass.Generated.Member
711         public static final @NonNull Parcelable.Creator<ComponentEnabledSetting> CREATOR
712                 = new Parcelable.Creator<ComponentEnabledSetting>() {
713             @Override
714             public ComponentEnabledSetting[] newArray(int size) {
715                 return new ComponentEnabledSetting[size];
716             }
717 
718             @Override
719             public ComponentEnabledSetting createFromParcel(@NonNull Parcel in) {
720                 return new ComponentEnabledSetting(in);
721             }
722         };
723 
724         @DataClass.Generated(
725                 time = 1628668290863L,
726                 codegenVersion = "1.0.23",
727                 sourceFile = "frameworks/base/core/java/android/content/pm/PackageManager.java",
728                 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)")
729         @Deprecated
__metadata()730         private void __metadata() {}
731 
732 
733         //@formatter:on
734         // End of generated code
735 
736     }
737 
738     /**
739      * Listener for changes in permissions granted to a UID.
740      *
741      * @hide
742      */
743     @SystemApi
744     public interface OnPermissionsChangedListener {
745         /**
746          * Called when the permissions for a UID change for the default device.
747          *
748          * @param uid The UID with a change.
749          * @see Context#DEVICE_ID_DEFAULT
750          */
onPermissionsChanged(int uid)751         void onPermissionsChanged(int uid);
752 
753         /**
754          * Called when the permissions for a UID change for a device, including virtual devices.
755          *
756          * @param uid The UID of permission change event.
757          * @param persistentDeviceId The persistent device ID of permission change event.
758          *
759          * @see VirtualDeviceManager.VirtualDevice#getPersistentDeviceId()
760          * @see VirtualDeviceManager#PERSISTENT_DEVICE_ID_DEFAULT
761          */
762         @FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED)
onPermissionsChanged(int uid, @NonNull String persistentDeviceId)763         default void onPermissionsChanged(int uid, @NonNull String persistentDeviceId) {
764             Objects.requireNonNull(persistentDeviceId);
765             if (Objects.equals(persistentDeviceId,
766                     VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)) {
767                 onPermissionsChanged(uid);
768             }
769         }
770     }
771 
772     /** @hide */
773     public static final int TYPE_UNKNOWN = 0;
774     /** @hide */
775     public static final int TYPE_ACTIVITY = 1;
776     /** @hide */
777     public static final int TYPE_RECEIVER = 2;
778     /** @hide */
779     public static final int TYPE_SERVICE = 3;
780     /** @hide */
781     public static final int TYPE_PROVIDER = 4;
782     /** @hide */
783     public static final int TYPE_APPLICATION = 5;
784     /** @hide */
785     @IntDef(prefix = { "TYPE_" }, value = {
786             TYPE_UNKNOWN,
787             TYPE_ACTIVITY,
788             TYPE_RECEIVER,
789             TYPE_SERVICE,
790             TYPE_PROVIDER,
791     })
792     @Retention(RetentionPolicy.SOURCE)
793     public @interface ComponentType {}
794 
795     /** @hide */
796     @IntDef(prefix = { "TYPE_" }, value = {
797             TYPE_UNKNOWN,
798             TYPE_ACTIVITY,
799             TYPE_RECEIVER,
800             TYPE_SERVICE,
801             TYPE_PROVIDER,
802             TYPE_APPLICATION,
803     })
804     @Retention(RetentionPolicy.SOURCE)
805     public @interface PropertyLocation {}
806 
807     /**
808      * As a guiding principle:
809      * <p>
810      * {@code GET_} flags are used to request additional data that may have been
811      * elided to save wire space.
812      * <p>
813      * {@code MATCH_} flags are used to include components or packages that
814      * would have otherwise been omitted from a result set by current system
815      * state.
816      */
817 
818     /** @hide */
819     @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
820             GET_ACTIVITIES,
821             GET_CONFIGURATIONS,
822             GET_GIDS,
823             GET_INSTRUMENTATION,
824             GET_INTENT_FILTERS,
825             GET_META_DATA,
826             GET_PERMISSIONS,
827             GET_PROVIDERS,
828             GET_RECEIVERS,
829             GET_SERVICES,
830             GET_SHARED_LIBRARY_FILES,
831             GET_SIGNATURES,
832             GET_SIGNING_CERTIFICATES,
833             GET_URI_PERMISSION_PATTERNS,
834             MATCH_UNINSTALLED_PACKAGES,
835             MATCH_DISABLED_COMPONENTS,
836             MATCH_DISABLED_UNTIL_USED_COMPONENTS,
837             MATCH_SYSTEM_ONLY,
838             MATCH_FACTORY_ONLY,
839             MATCH_ANY_USER,
840             MATCH_DEBUG_TRIAGED_MISSING,
841             MATCH_INSTANT,
842             MATCH_APEX,
843             MATCH_ARCHIVED_PACKAGES,
844             GET_DISABLED_COMPONENTS,
845             GET_DISABLED_UNTIL_USED_COMPONENTS,
846             GET_UNINSTALLED_PACKAGES,
847             MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
848             MATCH_DIRECT_BOOT_AWARE,
849             MATCH_DIRECT_BOOT_UNAWARE,
850             GET_ATTRIBUTIONS_LONG,
851     })
852     @Retention(RetentionPolicy.SOURCE)
853     public @interface PackageInfoFlagsBits {}
854 
855     /** @hide */
856     @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
857             GET_META_DATA,
858             GET_SHARED_LIBRARY_FILES,
859             MATCH_UNINSTALLED_PACKAGES,
860             MATCH_SYSTEM_ONLY,
861             MATCH_DEBUG_TRIAGED_MISSING,
862             MATCH_DISABLED_COMPONENTS,
863             MATCH_DISABLED_UNTIL_USED_COMPONENTS,
864             MATCH_INSTANT,
865             MATCH_STATIC_SHARED_AND_SDK_LIBRARIES,
866             GET_DISABLED_UNTIL_USED_COMPONENTS,
867             GET_UNINSTALLED_PACKAGES,
868             MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
869             MATCH_APEX,
870             MATCH_ARCHIVED_PACKAGES,
871     })
872     @Retention(RetentionPolicy.SOURCE)
873     public @interface ApplicationInfoFlagsBits {}
874 
875     /** @hide */
876     @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
877             GET_META_DATA,
878             GET_SHARED_LIBRARY_FILES,
879             MATCH_ALL,
880             MATCH_DEBUG_TRIAGED_MISSING,
881             MATCH_DEFAULT_ONLY,
882             MATCH_DISABLED_COMPONENTS,
883             MATCH_DISABLED_UNTIL_USED_COMPONENTS,
884             MATCH_DIRECT_BOOT_AUTO,
885             MATCH_DIRECT_BOOT_AWARE,
886             MATCH_DIRECT_BOOT_UNAWARE,
887             MATCH_SYSTEM_ONLY,
888             MATCH_UNINSTALLED_PACKAGES,
889             MATCH_INSTANT,
890             MATCH_STATIC_SHARED_AND_SDK_LIBRARIES,
891             GET_DISABLED_COMPONENTS,
892             GET_DISABLED_UNTIL_USED_COMPONENTS,
893             GET_UNINSTALLED_PACKAGES,
894             MATCH_QUARANTINED_COMPONENTS,
895     })
896     @Retention(RetentionPolicy.SOURCE)
897     public @interface ComponentInfoFlagsBits {}
898 
899     /** @hide */
900     @LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
901             GET_META_DATA,
902             GET_RESOLVED_FILTER,
903             GET_SHARED_LIBRARY_FILES,
904             MATCH_ALL,
905             MATCH_DEBUG_TRIAGED_MISSING,
906             MATCH_DISABLED_COMPONENTS,
907             MATCH_DISABLED_UNTIL_USED_COMPONENTS,
908             MATCH_DEFAULT_ONLY,
909             MATCH_DIRECT_BOOT_AUTO,
910             MATCH_DIRECT_BOOT_AWARE,
911             MATCH_DIRECT_BOOT_UNAWARE,
912             MATCH_SYSTEM_ONLY,
913             MATCH_UNINSTALLED_PACKAGES,
914             MATCH_INSTANT,
915             GET_DISABLED_COMPONENTS,
916             GET_DISABLED_UNTIL_USED_COMPONENTS,
917             GET_UNINSTALLED_PACKAGES,
918             MATCH_CLONE_PROFILE_LONG,
919             MATCH_QUARANTINED_COMPONENTS,
920     })
921     @Retention(RetentionPolicy.SOURCE)
922     public @interface ResolveInfoFlagsBits {}
923 
924     /** @hide */
925     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
926             MATCH_ALL,
927     })
928     @Retention(RetentionPolicy.SOURCE)
929     public @interface InstalledModulesFlags {}
930 
931     /** @hide */
932     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
933             GET_META_DATA,
934     })
935     @Retention(RetentionPolicy.SOURCE)
936     public @interface PermissionInfoFlags {}
937 
938     /** @hide */
939     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
940             GET_META_DATA,
941     })
942     @Retention(RetentionPolicy.SOURCE)
943     public @interface PermissionGroupInfoFlags {}
944 
945     /** @hide */
946     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
947             GET_META_DATA,
948     })
949     @Retention(RetentionPolicy.SOURCE)
950     public @interface InstrumentationInfoFlags {}
951 
952     //-------------------------------------------------------------------------
953     // Beginning of GET_ and MATCH_ flags
954     //-------------------------------------------------------------------------
955 
956     /**
957      * {@link PackageInfo} flag: return information about
958      * activities in the package in {@link PackageInfo#activities}.
959      */
960     public static final int GET_ACTIVITIES              = 0x00000001;
961 
962     /**
963      * {@link PackageInfo} flag: return information about
964      * intent receivers in the package in
965      * {@link PackageInfo#receivers}.
966      */
967     public static final int GET_RECEIVERS               = 0x00000002;
968 
969     /**
970      * {@link PackageInfo} flag: return information about
971      * services in the package in {@link PackageInfo#services}.
972      */
973     public static final int GET_SERVICES                = 0x00000004;
974 
975     /**
976      * {@link PackageInfo} flag: return information about
977      * content providers in the package in
978      * {@link PackageInfo#providers}.
979      */
980     public static final int GET_PROVIDERS               = 0x00000008;
981 
982     /**
983      * {@link PackageInfo} flag: return information about
984      * instrumentation in the package in
985      * {@link PackageInfo#instrumentation}.
986      */
987     public static final int GET_INSTRUMENTATION         = 0x00000010;
988 
989     /**
990      * {@link PackageInfo} flag: return information about the
991      * intent filters supported by the activity.
992      *
993      * @deprecated The platform does not support getting {@link IntentFilter}s for the package.
994      */
995     @Deprecated
996     public static final int GET_INTENT_FILTERS          = 0x00000020;
997 
998     /**
999      * {@link PackageInfo} flag: return information about the
1000      * signatures included in the package.
1001      *
1002      * @deprecated use {@code GET_SIGNING_CERTIFICATES} instead
1003      */
1004     @Deprecated
1005     public static final int GET_SIGNATURES          = 0x00000040;
1006 
1007     /**
1008      * {@link ResolveInfo} flag: return the IntentFilter that
1009      * was matched for a particular ResolveInfo in
1010      * {@link ResolveInfo#filter}.
1011      */
1012     public static final int GET_RESOLVED_FILTER         = 0x00000040;
1013 
1014     /**
1015      * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
1016      * data {@link android.os.Bundle}s that are associated with a component.
1017      * This applies for any API returning a ComponentInfo subclass.
1018      */
1019     public static final int GET_META_DATA               = 0x00000080;
1020 
1021     /**
1022      * {@link PackageInfo} flag: return the
1023      * {@link PackageInfo#gids group ids} that are associated with an
1024      * application.
1025      * This applies for any API returning a PackageInfo class, either
1026      * directly or nested inside of another.
1027      */
1028     public static final int GET_GIDS                    = 0x00000100;
1029 
1030     /**
1031      * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS}
1032      */
1033     @Deprecated
1034     public static final int GET_DISABLED_COMPONENTS = 0x00000200;
1035 
1036     /**
1037      * {@link PackageInfo} flag: include disabled components in the returned info.
1038      */
1039     public static final int MATCH_DISABLED_COMPONENTS = 0x00000200;
1040 
1041     /**
1042      * {@link ApplicationInfo} flag: return the
1043      * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
1044      * that are associated with an application.
1045      * This applies for any API returning an ApplicationInfo class, either
1046      * directly or nested inside of another.
1047      */
1048     public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
1049 
1050     /**
1051      * {@link ProviderInfo} flag: return the
1052      * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
1053      * that are associated with a content provider.
1054      * This applies for any API returning a ProviderInfo class, either
1055      * directly or nested inside of another.
1056      */
1057     public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
1058     /**
1059      * {@link PackageInfo} flag: return information about
1060      * permissions in the package in
1061      * {@link PackageInfo#permissions}.
1062      */
1063     public static final int GET_PERMISSIONS               = 0x00001000;
1064 
1065     /**
1066      * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES}
1067      */
1068     @Deprecated
1069     public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
1070 
1071     /**
1072      * Flag parameter to retrieve some information about all applications (even
1073      * uninstalled ones) which have data directories. This state could have
1074      * resulted if applications have been deleted with flag
1075      * {@code DELETE_KEEP_DATA} with a possibility of being replaced or
1076      * reinstalled in future.
1077      * <p>
1078      * Note: this flag may cause less information about currently installed
1079      * applications to be returned.
1080      * <p>
1081      * Note: use of this flag requires the android.permission.QUERY_ALL_PACKAGES
1082      * permission to see uninstalled packages.
1083      */
1084     public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000;
1085 
1086     /**
1087      * {@link PackageInfo} flag: return information about
1088      * hardware preferences in
1089      * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
1090      * and requested features in {@link PackageInfo#reqFeatures} and
1091      * {@link PackageInfo#featureGroups}.
1092      */
1093     public static final int GET_CONFIGURATIONS = 0x00004000;
1094 
1095     /**
1096      * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}.
1097      */
1098     @Deprecated
1099     public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
1100 
1101     /**
1102      * {@link PackageInfo} flag: include disabled components which are in
1103      * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
1104      * in the returned info.  Note that if you set this flag, applications
1105      * that are in this disabled state will be reported as enabled.
1106      */
1107     public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
1108 
1109     /**
1110      * Resolution and querying flag: if set, only filters that support the
1111      * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
1112      * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
1113      * supplied Intent.
1114      */
1115     public static final int MATCH_DEFAULT_ONLY  = 0x00010000;
1116 
1117     /**
1118      * Querying flag: if set and if the platform is doing any filtering of the
1119      * results, then the filtering will not happen. This is a synonym for saying
1120      * that all results should be returned.
1121      * <p>
1122      * <em>This flag should be used with extreme care.</em>
1123      */
1124     public static final int MATCH_ALL = 0x00020000;
1125 
1126     /**
1127      * Querying flag: match components which are direct boot <em>unaware</em> in
1128      * the returned info, regardless of the current user state.
1129      * <p>
1130      * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
1131      * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
1132      * to match only runnable components based on the user state. For example,
1133      * when a user is started but credentials have not been presented yet, the
1134      * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
1135      * components are returned. Once the user credentials have been presented,
1136      * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
1137      * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
1138      *
1139      * @see UserManager#isUserUnlocked()
1140      */
1141     public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000;
1142 
1143     /**
1144      * Querying flag: match components which are direct boot <em>aware</em> in
1145      * the returned info, regardless of the current user state.
1146      * <p>
1147      * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
1148      * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
1149      * to match only runnable components based on the user state. For example,
1150      * when a user is started but credentials have not been presented yet, the
1151      * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
1152      * components are returned. Once the user credentials have been presented,
1153      * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
1154      * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
1155      *
1156      * @see UserManager#isUserUnlocked()
1157      */
1158     public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000;
1159 
1160     /**
1161      * Querying flag: include only components from applications that are marked
1162      * with {@link ApplicationInfo#FLAG_SYSTEM}.
1163      */
1164     public static final int MATCH_SYSTEM_ONLY = 0x00100000;
1165 
1166     /**
1167      * Internal {@link PackageInfo} flag: include only components on the system image.
1168      * This will not return information on any unbundled update to system components.
1169      * @hide
1170      */
1171     @SystemApi
1172     public static final int MATCH_FACTORY_ONLY = 0x00200000;
1173 
1174     /**
1175      * Allows querying of packages installed for any user, not just the specific one. This flag
1176      * is only meant for use by apps that have INTERACT_ACROSS_USERS permission.
1177      * @hide
1178      */
1179     @SystemApi
1180     public static final int MATCH_ANY_USER = 0x00400000;
1181 
1182     /**
1183      * Combination of MATCH_ANY_USER and MATCH_UNINSTALLED_PACKAGES to mean any known
1184      * package.
1185      * @hide
1186      */
1187     @TestApi
1188     public static final int MATCH_KNOWN_PACKAGES = MATCH_UNINSTALLED_PACKAGES | MATCH_ANY_USER;
1189 
1190     /**
1191      * Internal {@link PackageInfo} flag: include components that are part of an
1192      * instant app. By default, instant app components are not matched.
1193      * @hide
1194      */
1195     @SystemApi
1196     public static final int MATCH_INSTANT = 0x00800000;
1197 
1198     /**
1199      * Internal {@link PackageInfo} flag: include only components that are exposed to
1200      * instant apps. Matched components may have been either explicitly or implicitly
1201      * exposed.
1202      * @hide
1203      */
1204     public static final int MATCH_VISIBLE_TO_INSTANT_APP_ONLY = 0x01000000;
1205 
1206     /**
1207      * Internal {@link PackageInfo} flag: include only components that have been
1208      * explicitly exposed to instant apps.
1209      * @hide
1210      */
1211     public static final int MATCH_EXPLICITLY_VISIBLE_ONLY = 0x02000000;
1212 
1213     /**
1214      * Internal {@link PackageInfo} flag: include static shared and SDK libraries.
1215      * Apps that depend on static shared/SDK libs can always access the version
1216      * of the lib they depend on. System/shell/root can access all shared
1217      * libs regardless of dependency but need to explicitly ask for them
1218      * via this flag.
1219      * @hide
1220      */
1221     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1222     public static final int MATCH_STATIC_SHARED_AND_SDK_LIBRARIES = 0x04000000;
1223 
1224     /**
1225      * {@link PackageInfo} flag: return the signing certificates associated with
1226      * this package.  Each entry is a signing certificate that the package
1227      * has proven it is authorized to use, usually a past signing certificate from
1228      * which it has rotated.
1229      */
1230     public static final int GET_SIGNING_CERTIFICATES = 0x08000000;
1231 
1232     /**
1233      * Querying flag: automatically match components based on their Direct Boot
1234      * awareness and the current user state.
1235      * <p>
1236      * Since the default behavior is to automatically apply the current user
1237      * state, this is effectively a sentinel value that doesn't change the
1238      * output of any queries based on its presence or absence.
1239      * <p>
1240      * Instead, this value can be useful in conjunction with
1241      * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
1242      * to detect when a caller is relying on implicit automatic matching,
1243      * instead of confirming the explicit behavior they want, using a
1244      * combination of these flags:
1245      * <ul>
1246      * <li>{@link #MATCH_DIRECT_BOOT_AWARE}
1247      * <li>{@link #MATCH_DIRECT_BOOT_UNAWARE}
1248      * <li>{@link #MATCH_DIRECT_BOOT_AUTO}
1249      * </ul>
1250      */
1251     public static final int MATCH_DIRECT_BOOT_AUTO = 0x10000000;
1252 
1253     /** @hide */
1254     @Deprecated
1255     public static final int MATCH_DEBUG_TRIAGED_MISSING = MATCH_DIRECT_BOOT_AUTO;
1256 
1257     /**
1258      * @deprecated Use {@link #MATCH_CLONE_PROFILE_LONG} instead.
1259      *
1260      * @hide
1261      */
1262     @Deprecated
1263     @SystemApi
1264     public static final int MATCH_CLONE_PROFILE = 0x20000000;
1265 
1266     /**
1267      * {@link PackageInfo} flag: include system apps that are in the uninstalled state and have
1268      * been set to be hidden until installed via {@link #setSystemAppState}.
1269      * @hide
1270      */
1271     @SystemApi
1272     public static final int MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS =  0x20000000;
1273 
1274     /**
1275      * {@link PackageInfo} flag: include APEX packages that are currently
1276      * installed. In APEX terminology, this corresponds to packages that are
1277      * currently active, i.e. mounted and available to other processes of the OS.
1278      * In particular, this flag alone will not match APEX files that are staged
1279      * for activation at next reboot.
1280      */
1281     public static final int MATCH_APEX = 0x40000000;
1282 
1283     /**
1284      * @deprecated Use {@link #GET_ATTRIBUTIONS_LONG} to avoid unintended sign extension.
1285      */
1286     @Deprecated
1287     public static final int GET_ATTRIBUTIONS = 0x80000000;
1288 
1289     /**
1290      * {@link PackageInfo} flag: return all attributions declared in the package manifest
1291      */
1292     public static final long GET_ATTRIBUTIONS_LONG = 0x80000000L;
1293 
1294     /**
1295      * Flag parameter to also retrieve some information about archived packages.
1296      * Packages can be archived through {@link PackageInstaller#requestArchive} and do not have any
1297      * APKs stored on the device, but do keep the data directory.
1298      * <p> Note: Archived apps are a subset of apps returned by {@link #MATCH_UNINSTALLED_PACKAGES}.
1299      * <p> Note: this flag may cause less information about currently installed
1300      * applications to be returned.
1301      * <p> Note: use of this flag requires the android.permission.QUERY_ALL_PACKAGES
1302      * permission to see uninstalled packages.
1303      */
1304     @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING)
1305     public static final long MATCH_ARCHIVED_PACKAGES = 1L << 32;
1306 
1307     /**
1308      * Querying flag: always match components of packages in quarantined state.
1309      * @see #isPackageQuarantined
1310      */
1311     @FlaggedApi(android.content.pm.Flags.FLAG_QUARANTINED_ENABLED)
1312     public static final long MATCH_QUARANTINED_COMPONENTS = 1L << 33;
1313 
1314     /**
1315      * {@link ResolveInfo} flag: allow matching components across clone profile
1316      * <p>
1317      * This flag is used only for query and not resolution, the default behaviour would be to
1318      * restrict querying across clone profile. This flag would be honored only if caller have
1319      * permission {@link Manifest.permission.QUERY_CLONED_APPS}.
1320      *
1321      * @hide
1322      */
1323     @FlaggedApi(android.content.pm.Flags.FLAG_FIX_DUPLICATED_FLAGS)
1324     @SystemApi
1325     public static final long MATCH_CLONE_PROFILE_LONG = 1L << 34;
1326 
1327     //-------------------------------------------------------------------------
1328     // End of GET_ and MATCH_ flags
1329     //-------------------------------------------------------------------------
1330 
1331     /**
1332      * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when
1333      * resolving an intent that matches the {@code CrossProfileIntentFilter},
1334      * the current profile will be skipped. Only activities in the target user
1335      * can respond to the intent.
1336      *
1337      * @hide
1338      */
1339     public static final int SKIP_CURRENT_PROFILE = 0x00000002;
1340 
1341     /**
1342      * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set:
1343      * activities in the other profiles can respond to the intent only if no activity with
1344      * non-negative priority in current profile can respond to the intent.
1345      * @hide
1346      */
1347     public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
1348 
1349     /** @hide */
1350     @IntDef(flag = true, prefix = { "MODULE_" }, value = {
1351             MODULE_APEX_NAME,
1352     })
1353     @Retention(RetentionPolicy.SOURCE)
1354     public @interface ModuleInfoFlags {}
1355 
1356     /**
1357      * Flag for {@link #getModuleInfo}: allow ModuleInfo to be retrieved using the apex module
1358      * name, rather than the package name.
1359      *
1360      * @hide
1361      */
1362     @SystemApi
1363     public static final int MODULE_APEX_NAME = 0x00000001;
1364 
1365     /** @hide */
1366     @IntDef(prefix = { "PERMISSION_" }, value = {
1367             PERMISSION_GRANTED,
1368             PERMISSION_DENIED
1369     })
1370     @Retention(RetentionPolicy.SOURCE)
1371     public @interface PermissionResult {}
1372 
1373     /**
1374      * Permission check result: this is returned by {@link #checkPermission}
1375      * if the permission has been granted to the given package.
1376      */
1377     public static final int PERMISSION_GRANTED = 0;
1378 
1379     /**
1380      * Permission check result: this is returned by {@link #checkPermission}
1381      * if the permission has not been granted to the given package.
1382      */
1383     public static final int PERMISSION_DENIED = -1;
1384 
1385     /** @hide */
1386     @IntDef(prefix = { "SIGNATURE_" }, value = {
1387             SIGNATURE_MATCH,
1388             SIGNATURE_NEITHER_SIGNED,
1389             SIGNATURE_FIRST_NOT_SIGNED,
1390             SIGNATURE_SECOND_NOT_SIGNED,
1391             SIGNATURE_NO_MATCH,
1392             SIGNATURE_UNKNOWN_PACKAGE,
1393     })
1394     @Retention(RetentionPolicy.SOURCE)
1395     public @interface SignatureResult {}
1396 
1397     /**
1398      * Signature check result: this is returned by {@link #checkSignatures}
1399      * if all signatures on the two packages match.
1400      */
1401     public static final int SIGNATURE_MATCH = 0;
1402 
1403     /**
1404      * Signature check result: this is returned by {@link #checkSignatures}
1405      * if neither of the two packages is signed.
1406      */
1407     public static final int SIGNATURE_NEITHER_SIGNED = 1;
1408 
1409     /**
1410      * Signature check result: this is returned by {@link #checkSignatures}
1411      * if the first package is not signed but the second is.
1412      */
1413     public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
1414 
1415     /**
1416      * Signature check result: this is returned by {@link #checkSignatures}
1417      * if the second package is not signed but the first is.
1418      */
1419     public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
1420 
1421     /**
1422      * Signature check result: this is returned by {@link #checkSignatures}
1423      * if not all signatures on both packages match.
1424      */
1425     public static final int SIGNATURE_NO_MATCH = -3;
1426 
1427     /**
1428      * Signature check result: this is returned by {@link #checkSignatures}
1429      * if either of the packages are not valid.
1430      */
1431     public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
1432 
1433     /** @hide */
1434     @IntDef(prefix = { "COMPONENT_ENABLED_STATE_" }, value = {
1435             COMPONENT_ENABLED_STATE_DEFAULT,
1436             COMPONENT_ENABLED_STATE_ENABLED,
1437             COMPONENT_ENABLED_STATE_DISABLED,
1438             COMPONENT_ENABLED_STATE_DISABLED_USER,
1439             COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED,
1440     })
1441     @Retention(RetentionPolicy.SOURCE)
1442     public @interface EnabledState {}
1443 
1444     /**
1445      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
1446      * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
1447      * component or application is in its default enabled state (as specified in
1448      * its manifest).
1449      * <p>
1450      * Explicitly setting the component state to this value restores it's
1451      * enabled state to whatever is set in the manifest.
1452      */
1453     public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
1454 
1455     /**
1456      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
1457      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
1458      * component or application has been explictily enabled, regardless of
1459      * what it has specified in its manifest.
1460      */
1461     public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
1462 
1463     /**
1464      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
1465      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
1466      * component or application has been explicitly disabled, regardless of
1467      * what it has specified in its manifest.
1468      */
1469     public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
1470 
1471     /**
1472      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
1473      * user has explicitly disabled the application, regardless of what it has
1474      * specified in its manifest.  Because this is due to the user's request,
1475      * they may re-enable it if desired through the appropriate system UI.  This
1476      * option currently <strong>cannot</strong> be used with
1477      * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
1478      */
1479     public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
1480 
1481     /**
1482      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
1483      * application should be considered, until the point where the user actually
1484      * wants to use it.  This means that it will not normally show up to the user
1485      * (such as in the launcher), but various parts of the user interface can
1486      * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
1487      * the user to select it (as for example an IME, device admin, etc).  Such code,
1488      * once the user has selected the app, should at that point also make it enabled.
1489      * This option currently <strong>can not</strong> be used with
1490      * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
1491      */
1492     public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
1493 
1494     /** @hide */
1495     @Retention(RetentionPolicy.SOURCE)
1496     @IntDef(prefix = { "ROLLBACK_DATA_POLICY_" }, value = {
1497             ROLLBACK_DATA_POLICY_RESTORE,
1498             ROLLBACK_DATA_POLICY_WIPE,
1499             ROLLBACK_DATA_POLICY_RETAIN
1500     })
1501     public @interface RollbackDataPolicy {}
1502 
1503     /**
1504      * User data will be backed up during install and restored during rollback.
1505      *
1506      * @hide
1507      */
1508     @SystemApi
1509     public static final int ROLLBACK_DATA_POLICY_RESTORE = 0;
1510 
1511     /**
1512      * User data won't be backed up during install but will be wiped out during rollback.
1513      *
1514      * @hide
1515      */
1516     @SystemApi
1517     public static final int ROLLBACK_DATA_POLICY_WIPE = 1;
1518 
1519     /**
1520      * User data won't be backed up during install and will remain unchanged during rollback.
1521      *
1522      * @hide
1523      */
1524     @SystemApi
1525     public static final int ROLLBACK_DATA_POLICY_RETAIN = 2;
1526 
1527     /** @hide */
1528     @IntDef(prefix = {"ROLLBACK_USER_IMPACT_"}, value = {
1529             ROLLBACK_USER_IMPACT_LOW,
1530             ROLLBACK_USER_IMPACT_HIGH,
1531             ROLLBACK_USER_IMPACT_ONLY_MANUAL,
1532     })
1533     @Retention(RetentionPolicy.SOURCE)
1534     public @interface RollbackImpactLevel {}
1535 
1536     /**
1537      * Rollback will be performed automatically in response to native crashes on startup or
1538      * persistent service crashes. More suitable for apps that do not store any user data.
1539      *
1540      * @hide
1541      */
1542     @SystemApi
1543     @FlaggedApi(android.content.pm.Flags.FLAG_RECOVERABILITY_DETECTION)
1544     public static final int ROLLBACK_USER_IMPACT_LOW = 0;
1545 
1546     /**
1547      * Rollback will be performed automatically only when the device is found to be unrecoverable.
1548      * More suitable for apps that store user data and have higher impact on user.
1549      *
1550      * @hide
1551      */
1552     @SystemApi
1553     @FlaggedApi(android.content.pm.Flags.FLAG_RECOVERABILITY_DETECTION)
1554     public static final int ROLLBACK_USER_IMPACT_HIGH = 1;
1555 
1556     /**
1557      * Rollback will not be performed automatically. It can be triggered externally.
1558      *
1559      * @hide
1560      */
1561     @SystemApi
1562     @FlaggedApi(android.content.pm.Flags.FLAG_RECOVERABILITY_DETECTION)
1563     public static final int ROLLBACK_USER_IMPACT_ONLY_MANUAL = 2;
1564 
1565     /** @hide */
1566     @IntDef(flag = true, prefix = { "INSTALL_" }, value = {
1567             INSTALL_REPLACE_EXISTING,
1568             INSTALL_ALLOW_TEST,
1569             INSTALL_INTERNAL,
1570             INSTALL_FROM_ADB,
1571             INSTALL_ALL_USERS,
1572             INSTALL_REQUEST_DOWNGRADE,
1573             INSTALL_GRANT_ALL_REQUESTED_PERMISSIONS,
1574             INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS,
1575             INSTALL_FORCE_VOLUME_UUID,
1576             INSTALL_FORCE_PERMISSION_PROMPT,
1577             INSTALL_INSTANT_APP,
1578             INSTALL_DONT_KILL_APP,
1579             INSTALL_FULL_APP,
1580             INSTALL_ALLOCATE_AGGRESSIVE,
1581             INSTALL_VIRTUAL_PRELOAD,
1582             INSTALL_APEX,
1583             INSTALL_ENABLE_ROLLBACK,
1584             INSTALL_ALLOW_DOWNGRADE,
1585             INSTALL_STAGED,
1586             INSTALL_REQUEST_UPDATE_OWNERSHIP,
1587             INSTALL_IGNORE_DEXOPT_PROFILE,
1588             INSTALL_UNARCHIVE_DRAFT,
1589             INSTALL_UNARCHIVE,
1590     })
1591     @Retention(RetentionPolicy.SOURCE)
1592     public @interface InstallFlags {}
1593 
1594     /**
1595      * Install flags that can only be used in development workflows (e.g. {@code adb install}).
1596      * @hide
1597      */
1598     @IntDef(flag = true, prefix = { "INSTALL_DEVELOPMENT_" }, value = {
1599             INSTALL_DEVELOPMENT_FORCE_NON_STAGED_APEX_UPDATE,
1600     })
1601     @Retention(RetentionPolicy.SOURCE)
1602     public @interface DevelopmentInstallFlags {}
1603 
1604     /**
1605      * Flag parameter for {@link #installPackage} to indicate that you want to
1606      * replace an already installed package, if one exists.
1607      *
1608      * @hide
1609      */
1610     @UnsupportedAppUsage
1611     public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
1612 
1613     /**
1614      * Flag parameter for {@link #installPackage} to indicate that you want to
1615      * allow test packages (those that have set android:testOnly in their
1616      * manifest) to be installed.
1617      * @hide
1618      */
1619     public static final int INSTALL_ALLOW_TEST = 0x00000004;
1620 
1621     /**
1622      * Flag parameter for {@link #installPackage} to indicate that this package
1623      * must be installed to internal storage.
1624      *
1625      * @hide
1626      */
1627     public static final int INSTALL_INTERNAL = 0x00000010;
1628 
1629     /**
1630      * Flag parameter for {@link #installPackage} to indicate that this install
1631      * was initiated via ADB.
1632      *
1633      * @hide
1634      */
1635     public static final int INSTALL_FROM_ADB = 0x00000020;
1636 
1637     /**
1638      * Flag parameter for {@link #installPackage} to indicate that this install
1639      * should immediately be visible to all users.
1640      *
1641      * @hide
1642      */
1643     public static final int INSTALL_ALL_USERS = 0x00000040;
1644 
1645     /**
1646      * Flag parameter for {@link #installPackage} to indicate that an upgrade to a lower version
1647      * of a package than currently installed has been requested.
1648      *
1649      * <p>Note that this flag doesn't guarantee that downgrade will be performed. That decision
1650      * depends
1651      * on whenever:
1652      * <ul>
1653      * <li>An app is debuggable.
1654      * <li>Or a build is debuggable.
1655      * <li>Or {@link #INSTALL_ALLOW_DOWNGRADE} is set.
1656      * </ul>
1657      *
1658      * @hide
1659      */
1660     public static final int INSTALL_REQUEST_DOWNGRADE = 0x00000080;
1661 
1662     /**
1663      * Flag parameter for package install to indicate that all requested permissions should be
1664      * granted to the package. If {@link #INSTALL_ALL_USERS} is set the runtime permissions will
1665      * be granted to all users, otherwise only to the owner.
1666      * <p/>
1667      * If this flag is set, {@link SessionParams#setPermissionState(String, int)} should not be
1668      * called.
1669      *
1670      * @hide
1671      */
1672     public static final int INSTALL_GRANT_ALL_REQUESTED_PERMISSIONS = 0x00000100;
1673 
1674     /** {@hide} */
1675     public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
1676 
1677     /**
1678      * Flag parameter for {@link #installPackage} to indicate that we always want to force
1679      * the prompt for permission approval. This overrides any special behaviour for internal
1680      * components.
1681      *
1682      * @hide
1683      */
1684     public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400;
1685 
1686     /**
1687      * Flag parameter for {@link #installPackage} to indicate that this package is
1688      * to be installed as a lightweight "ephemeral" app.
1689      *
1690      * @hide
1691      */
1692     public static final int INSTALL_INSTANT_APP = 0x00000800;
1693 
1694     /**
1695      * Flag parameter for {@link #installPackage} to indicate that this package contains
1696      * a feature split to an existing application and the existing application should not
1697      * be killed during the installation process.
1698      *
1699      * @hide
1700      */
1701     public static final int INSTALL_DONT_KILL_APP = 0x00001000;
1702 
1703     /**
1704      * Flag parameter for {@link #installPackage} to indicate that this package is
1705      * to be installed as a heavy weight app. This is fundamentally the opposite of
1706      * {@link #INSTALL_INSTANT_APP}.
1707      *
1708      * @hide
1709      */
1710     public static final int INSTALL_FULL_APP = 0x00004000;
1711 
1712     /**
1713      * Flag parameter for {@link #installPackage} to indicate that this package
1714      * is critical to system health or security, meaning the system should use
1715      * {@link StorageManager#FLAG_ALLOCATE_AGGRESSIVE} internally.
1716      *
1717      * @hide
1718      */
1719     public static final int INSTALL_ALLOCATE_AGGRESSIVE = 0x00008000;
1720 
1721     /**
1722      * Flag parameter for {@link #installPackage} to indicate that this package
1723      * is a virtual preload.
1724      *
1725      * @hide
1726      */
1727     public static final int INSTALL_VIRTUAL_PRELOAD = 0x00010000;
1728 
1729     /**
1730      * Flag parameter for {@link #installPackage} to indicate that this package
1731      * is an APEX package
1732      *
1733      * @hide
1734      */
1735     public static final int INSTALL_APEX = 0x00020000;
1736 
1737     /**
1738      * Flag parameter for {@link #installPackage} to indicate that rollback
1739      * should be enabled for this install.
1740      *
1741      * @hide
1742      */
1743     public static final int INSTALL_ENABLE_ROLLBACK = 0x00040000;
1744 
1745     /**
1746      * Flag parameter for {@link #installPackage} to indicate that package verification should be
1747      * disabled for this package.
1748      *
1749      * @hide
1750      */
1751     public static final int INSTALL_DISABLE_VERIFICATION = 0x00080000;
1752 
1753     /**
1754      * Flag parameter for {@link #installPackage} to indicate that
1755      * {@link #INSTALL_REQUEST_DOWNGRADE} should be allowed.
1756      *
1757      * @hide
1758      */
1759     public static final int INSTALL_ALLOW_DOWNGRADE = 0x00100000;
1760 
1761     /**
1762      * Flag parameter for {@link #installPackage} to indicate that this package
1763      * is being installed as part of a staged install.
1764      *
1765      * @hide
1766      */
1767     public static final int INSTALL_STAGED = 0x00200000;
1768 
1769     /**
1770      * Flag parameter for {@link #installPackage} to indicate that all restricted
1771      * permissions should be allowlisted. If {@link #INSTALL_ALL_USERS}
1772      * is set the restricted permissions will be allowlisted for all users, otherwise
1773      * only to the owner.
1774      *
1775      * <p>
1776      * <strong>Note: </strong>In retrospect it would have been preferred to use
1777      * more inclusive terminology when naming this API. Similar APIs added will
1778      * refrain from using the term "whitelist".
1779      * </p>
1780      *
1781      * @hide
1782      */
1783     public static final int INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS = 0x00400000;
1784 
1785     /**
1786      * Flag parameter for {@link #installPackage} to indicate that check whether given APEX can be
1787      * updated should be disabled for this install.
1788      * @hide
1789      */
1790     public static final int INSTALL_DISABLE_ALLOWED_APEX_UPDATE_CHECK = 0x00800000;
1791 
1792     /**
1793      * Flag parameter for {@link #installPackage} to bypass the low targer sdk version block
1794      * for this install.
1795      *
1796      * @hide
1797      */
1798     public static final int INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK = 0x01000000;
1799 
1800     /**
1801      * Flag parameter for {@link SessionParams} to indicate that the
1802      * update ownership enforcement is requested.
1803      * @hide
1804      */
1805     public static final int INSTALL_REQUEST_UPDATE_OWNERSHIP = 1 << 25;
1806 
1807     /**
1808      * Flag parameter for {@link PackageInstaller.SessionParams} to indicate that this
1809      * session is from a managed user or profile.
1810      * @hide
1811      */
1812     public static final int INSTALL_FROM_MANAGED_USER_OR_PROFILE = 1 << 26;
1813 
1814     /**
1815      * Flag parameter for {@link PackageInstaller.SessionParams} to indicate that this
1816      * session is for archived package installation.
1817      * @hide
1818      */
1819     public static final int INSTALL_ARCHIVED = 1 << 27;
1820 
1821     /**
1822      * If set, all dexopt profiles are ignored by dexopt during the installation, including the
1823      * profile in the DM file and the profile embedded in the APK file. If an invalid profile is
1824      * provided during installation, no warning will be reported by {@code adb install}.
1825      *
1826      * This option does not affect later dexopt operations (e.g., background dexopt and manual `pm
1827      * compile` invocations).
1828      *
1829      * @hide
1830      */
1831     public static final int INSTALL_IGNORE_DEXOPT_PROFILE = 1 << 28;
1832 
1833     /**
1834      * If set, then the session is a draft session created for an upcoming unarchival by its
1835      * installer.
1836      *
1837      * @see PackageInstaller#requestUnarchive
1838      *
1839      * @hide
1840      */
1841     public static final int INSTALL_UNARCHIVE_DRAFT = 1 << 29;
1842 
1843     /**
1844      * If set, then the {@link PackageInstaller.Session} is an unarchival.
1845      *
1846      * @see PackageInstaller#requestUnarchive
1847      *
1848      * @hide
1849      */
1850     public static final int INSTALL_UNARCHIVE = 1 << 30;
1851 
1852     /**
1853      * Flag parameter for {@link #installPackage} to force a non-staged update of an APEX. This is
1854      * a development-only feature and should not be used on end user devices.
1855      *
1856      * @hide
1857      */
1858     public static final int INSTALL_DEVELOPMENT_FORCE_NON_STAGED_APEX_UPDATE = 1;
1859 
1860     /** @hide */
1861     @IntDef(flag = true, value = {
1862             DONT_KILL_APP,
1863             SYNCHRONOUS,
1864     })
1865     @Retention(RetentionPolicy.SOURCE)
1866     public @interface EnabledFlags {}
1867 
1868     /**
1869      * Flag parameter for
1870      * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
1871      * that you don't want to kill the app containing the component.  Be careful when you set this
1872      * since changing component states can make the containing application's behavior unpredictable.
1873      */
1874     public static final int DONT_KILL_APP = 0x00000001;
1875 
1876     /**
1877      * Flag parameter for
1878      * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
1879      * that the given user's package restrictions state will be serialised to disk after the
1880      * component state has been updated. Note that this is synchronous disk access, so calls using
1881      * this flag should be run on a background thread.
1882      */
1883     public static final int SYNCHRONOUS = 0x00000002;
1884 
1885     /** @hide */
1886     @IntDef(flag = true, value = {
1887             FLAG_SUSPEND_QUARANTINED,
1888     })
1889     @Retention(RetentionPolicy.SOURCE)
1890     public @interface SuspendedFlags {}
1891 
1892     /**
1893      * Flag parameter {@link #setPackagesSuspended(String[], boolean, PersistableBundle,
1894      * PersistableBundle, android.content.pm.SuspendDialogInfo, int)}:
1895      * Apps in this state not only appear suspended for all user visible purposes (eg, Launcher,
1896      * ShareSheet), but also individual components of the app can behave as disabled depending on
1897      * the importance of the calling app.
1898      *
1899      * @hide
1900      */
1901     @SystemApi
1902     @FlaggedApi(android.content.pm.Flags.FLAG_QUARANTINED_ENABLED)
1903     public static final int FLAG_SUSPEND_QUARANTINED = 0x00000001;
1904 
1905     /** @hide */
1906     @IntDef(prefix = { "INSTALL_REASON_" }, value = {
1907             INSTALL_REASON_UNKNOWN,
1908             INSTALL_REASON_POLICY,
1909             INSTALL_REASON_DEVICE_RESTORE,
1910             INSTALL_REASON_DEVICE_SETUP,
1911             INSTALL_REASON_USER,
1912             INSTALL_REASON_ROLLBACK
1913     })
1914     @Retention(RetentionPolicy.SOURCE)
1915     public @interface InstallReason {}
1916 
1917     /**
1918      * Code indicating that the reason for installing this package is unknown.
1919      */
1920     public static final int INSTALL_REASON_UNKNOWN = 0;
1921 
1922     /**
1923      * Code indicating that this package was installed due to enterprise policy.
1924      */
1925     public static final int INSTALL_REASON_POLICY = 1;
1926 
1927     /**
1928      * Code indicating that this package was installed as part of restoring from another device.
1929      */
1930     public static final int INSTALL_REASON_DEVICE_RESTORE = 2;
1931 
1932     /**
1933      * Code indicating that this package was installed as part of device setup.
1934      */
1935     public static final int INSTALL_REASON_DEVICE_SETUP = 3;
1936 
1937     /**
1938      * Code indicating that the package installation was initiated by the user.
1939      */
1940     public static final int INSTALL_REASON_USER = 4;
1941 
1942     /**
1943      * Code indicating that the package installation was a rollback initiated by RollbackManager.
1944      *
1945      * @hide
1946      */
1947     public static final int INSTALL_REASON_ROLLBACK = 5;
1948 
1949     /** @hide */
1950     @IntDef(prefix = { "INSTALL_SCENARIO_" }, value = {
1951             INSTALL_SCENARIO_DEFAULT,
1952             INSTALL_SCENARIO_FAST,
1953             INSTALL_SCENARIO_BULK,
1954             INSTALL_SCENARIO_BULK_SECONDARY,
1955     })
1956     @Retention(RetentionPolicy.SOURCE)
1957     public @interface InstallScenario {}
1958 
1959     /**
1960      * A value to indicate the lack of CUJ information, disabling all installation scenario logic.
1961      */
1962     public static final int INSTALL_SCENARIO_DEFAULT = 0;
1963 
1964     /**
1965      * Installation scenario providing the fastest “install button to launch" experience possible.
1966      */
1967     public static final int INSTALL_SCENARIO_FAST = 1;
1968 
1969     /**
1970      * Installation scenario indicating a bulk operation with the desired result of a fully
1971      * optimized application.  If the system is busy or resources are scarce the system will
1972      * perform less work to avoid impacting system health.
1973      *
1974      * Examples of bulk installation scenarios might include device restore, background updates of
1975      * multiple applications, or user-triggered updates for all applications.
1976      *
1977      * The decision to use BULK or BULK_SECONDARY should be based on the desired user experience.
1978      * BULK_SECONDARY operations may take less time to complete but, when they do, will produce
1979      * less optimized applications.  The device state (e.g. memory usage or battery status) should
1980      * not be considered when making this decision as those factors are taken into account by the
1981      * Package Manager when acting on the installation scenario.
1982      */
1983     public static final int INSTALL_SCENARIO_BULK = 2;
1984 
1985     /**
1986      * Installation scenario indicating a bulk operation that prioritizes minimal system health
1987      * impact over application optimization.  The application may undergo additional optimization
1988      * if the system is idle and system resources are abundant.  The more elements of a bulk
1989      * operation that are marked BULK_SECONDARY, the faster the entire bulk operation will be.
1990      *
1991      * See the comments for INSTALL_SCENARIO_BULK for more information.
1992      */
1993     public static final int INSTALL_SCENARIO_BULK_SECONDARY = 3;
1994 
1995     /** @hide */
1996     @IntDef(prefix = { "UNINSTALL_REASON_" }, value = {
1997             UNINSTALL_REASON_UNKNOWN,
1998             UNINSTALL_REASON_USER_TYPE,
1999     })
2000     @Retention(RetentionPolicy.SOURCE)
2001     public @interface UninstallReason {}
2002 
2003     /**
2004      * Code indicating that the reason for uninstalling this package is unknown.
2005      * @hide
2006      */
2007     public static final int UNINSTALL_REASON_UNKNOWN = 0;
2008 
2009     /**
2010      * Code indicating that this package was uninstalled due to the type of user.
2011      * See UserSystemPackageInstaller
2012      * @hide
2013      */
2014     public static final int UNINSTALL_REASON_USER_TYPE = 1;
2015 
2016     /**
2017      * @hide
2018      */
2019     public static final int INSTALL_UNKNOWN = 0;
2020 
2021     /**
2022      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2023      * on success.
2024      *
2025      * @hide
2026      */
2027     @SystemApi
2028     public static final int INSTALL_SUCCEEDED = 1;
2029 
2030     /**
2031      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2032      * if the package is already installed.
2033      *
2034      * @hide
2035      */
2036     @SystemApi
2037     public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
2038 
2039     /**
2040      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2041      * if the package archive file is invalid.
2042      *
2043      * @hide
2044      */
2045     @SystemApi
2046     public static final int INSTALL_FAILED_INVALID_APK = -2;
2047 
2048     /**
2049      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2050      * if the URI passed in is invalid.
2051      *
2052      * @hide
2053      */
2054     @SystemApi
2055     public static final int INSTALL_FAILED_INVALID_URI = -3;
2056 
2057     /**
2058      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2059      * if the package manager service found that the device didn't have enough storage space to
2060      * install the app.
2061      *
2062      * @hide
2063      */
2064     @SystemApi
2065     public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
2066 
2067     /**
2068      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2069      * if a package is already installed with the same name.
2070      *
2071      * @hide
2072      */
2073     @SystemApi
2074     public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
2075 
2076     /**
2077      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2078      * if the requested shared user does not exist.
2079      *
2080      * @hide
2081      */
2082     @SystemApi
2083     public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
2084 
2085     /**
2086      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2087      * if a previously installed package of the same name has a different signature than the new
2088      * package (and the old package's data was not removed).
2089      *
2090      * @hide
2091      */
2092     @SystemApi
2093     public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
2094 
2095     /**
2096      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2097      * if the new package is requested a shared user which is already installed on the device and
2098      * does not have matching signature.
2099      *
2100      * @hide
2101      */
2102     @SystemApi
2103     public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
2104 
2105     /**
2106      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2107      * if the new package uses a shared library that is not available.
2108      *
2109      * @hide
2110      */
2111     @SystemApi
2112     public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
2113 
2114     /**
2115      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2116      * when the package being replaced is a system app and the caller didn't provide the
2117      * {@link #DELETE_SYSTEM_APP} flag.
2118      *
2119      * @hide
2120      */
2121     @SystemApi
2122     public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
2123 
2124     /**
2125      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2126      * if the new package failed while optimizing and validating its dex files, either because there
2127      * was not enough storage or the validation failed.
2128      *
2129      * @hide
2130      */
2131     @SystemApi
2132     public static final int INSTALL_FAILED_DEXOPT = -11;
2133 
2134     /**
2135      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2136      * if the new package failed because the current SDK version is older than that required by the
2137      * package.
2138      *
2139      * @hide
2140      */
2141     @SystemApi
2142     public static final int INSTALL_FAILED_OLDER_SDK = -12;
2143 
2144     /**
2145      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2146      * if the new package failed because it contains a content provider with the same authority as a
2147      * provider already installed in the system.
2148      *
2149      * @hide
2150      */
2151     @SystemApi
2152     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
2153 
2154     /**
2155      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2156      * if the new package failed because the current SDK version is newer than that required by the
2157      * package.
2158      *
2159      * @hide
2160      */
2161     @SystemApi
2162     public static final int INSTALL_FAILED_NEWER_SDK = -14;
2163 
2164     /**
2165      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2166      * if the new package failed because it has specified that it is a test-only package and the
2167      * caller has not supplied the {@link #INSTALL_ALLOW_TEST} flag.
2168      *
2169      * @hide
2170      */
2171     @SystemApi
2172     public static final int INSTALL_FAILED_TEST_ONLY = -15;
2173 
2174     /**
2175      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2176      * if the package being installed contains native code, but none that is compatible with the
2177      * device's CPU_ABI.
2178      *
2179      * @hide
2180      */
2181     @SystemApi
2182     public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
2183 
2184     /**
2185      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2186      * if the new package uses a feature that is not available.
2187      *
2188      * @hide
2189      */
2190     @SystemApi
2191     public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
2192 
2193     // ------ Errors related to sdcard
2194     /**
2195      * Installation return code: this is passed in the
2196      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if a secure container mount point couldn't be
2197      * accessed on external media.
2198      *
2199      * @hide
2200      */
2201     @SystemApi
2202     public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
2203 
2204     /**
2205      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2206      * if the new package couldn't be installed in the specified install location.
2207      *
2208      * @hide
2209      */
2210     @SystemApi
2211     public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
2212 
2213     /**
2214      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2215      * if the new package couldn't be installed in the specified install location because the media
2216      * is not available.
2217      *
2218      * @hide
2219      */
2220     @SystemApi
2221     public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
2222 
2223     /**
2224      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2225      * if the new package couldn't be installed because the verification timed out.
2226      *
2227      * @hide
2228      */
2229     @SystemApi
2230     public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
2231 
2232     /**
2233      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2234      * if the new package couldn't be installed because the verification did not succeed.
2235      *
2236      * @hide
2237      */
2238     @SystemApi
2239     public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
2240 
2241     /**
2242      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2243      * if the package changed from what the calling program expected.
2244      *
2245      * @hide
2246      */
2247     @SystemApi
2248     public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
2249 
2250     /**
2251      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2252      * if the new package is assigned a different UID than it previously held.
2253      *
2254      * @hide
2255      */
2256     public static final int INSTALL_FAILED_UID_CHANGED = -24;
2257 
2258     /**
2259      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2260      * if the new package has an older version code than the currently installed package.
2261      *
2262      * @hide
2263      */
2264     public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
2265 
2266     /**
2267      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2268      * if the old package has target SDK high enough to support runtime permission and the new
2269      * package has target SDK low enough to not support runtime permissions.
2270      *
2271      * @hide
2272      */
2273     @SystemApi
2274     public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
2275 
2276     /**
2277      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2278      * if the new package attempts to downgrade the target sandbox version of the app.
2279      *
2280      * @hide
2281      */
2282     @SystemApi
2283     public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27;
2284 
2285     /**
2286      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2287      * if the new package requires at least one split and it was not provided.
2288      *
2289      * @hide
2290      */
2291     public static final int INSTALL_FAILED_MISSING_SPLIT = -28;
2292 
2293     /**
2294      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2295      * if the new package targets a deprecated SDK version.
2296      *
2297      * @hide
2298      */
2299     public static final int INSTALL_FAILED_DEPRECATED_SDK_VERSION = -29;
2300 
2301     /**
2302      * Installation parse return code: this is passed in the
2303      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was given a path that is not a
2304      * file, or does not end with the expected '.apk' extension.
2305      *
2306      * @hide
2307      */
2308     @SystemApi
2309     public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
2310 
2311     /**
2312      * Installation parse return code: this is passed in the
2313      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was unable to retrieve the
2314      * AndroidManifest.xml file.
2315      *
2316      * @hide
2317      */
2318     @SystemApi
2319     public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
2320 
2321     /**
2322      * Installation parse return code: this is passed in the
2323      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered an unexpected
2324      * exception.
2325      *
2326      * @hide
2327      */
2328     @SystemApi
2329     public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
2330 
2331     /**
2332      * Installation parse return code: this is passed in the
2333      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any certificates in
2334      * the .apk.
2335      *
2336      * @hide
2337      */
2338     @SystemApi
2339     public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
2340 
2341     /**
2342      * Installation parse return code: this is passed in the
2343      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser found inconsistent certificates on
2344      * the files in the .apk.
2345      *
2346      * @hide
2347      */
2348     @SystemApi
2349     public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
2350 
2351     /**
2352      * Installation parse return code: this is passed in the
2353      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a
2354      * CertificateEncodingException in one of the files in the .apk.
2355      *
2356      * @hide
2357      */
2358     @SystemApi
2359     public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
2360 
2361     /**
2362      * Installation parse return code: this is passed in the
2363      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad or missing
2364      * package name in the manifest.
2365      *
2366      * @hide
2367      */
2368     @SystemApi
2369     public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
2370 
2371     /**
2372      * Installation parse return code: tthis is passed in the
2373      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad shared user id
2374      * name in the manifest.
2375      *
2376      * @hide
2377      */
2378     @SystemApi
2379     public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
2380 
2381     /**
2382      * Installation parse return code: this is passed in the
2383      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered some structural
2384      * problem in the manifest.
2385      *
2386      * @hide
2387      */
2388     @SystemApi
2389     public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
2390 
2391     /**
2392      * Installation parse return code: this is passed in the
2393      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any actionable tags
2394      * (instrumentation or application) in the manifest.
2395      *
2396      * @hide
2397      */
2398     @SystemApi
2399     public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
2400 
2401     /**
2402      * Installation failed return code: this is passed in the
2403      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2404      * because of system issues.
2405      *
2406      * @hide
2407      */
2408     @SystemApi
2409     public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
2410 
2411     /**
2412      * Installation failed return code: this is passed in the
2413      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2414      * because the user is restricted from installing apps.
2415      *
2416      * @hide
2417      */
2418     public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
2419 
2420     /**
2421      * Installation failed return code: this is passed in the
2422      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2423      * because it is attempting to define a permission that is already defined by some existing
2424      * package.
2425      * <p>
2426      * The package name of the app which has already defined the permission is passed to a
2427      * {@link PackageInstallObserver}, if any, as the {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string
2428      * extra; and the name of the permission being redefined is passed in the
2429      * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra.
2430      *
2431      * @hide
2432      */
2433     public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
2434 
2435     /**
2436      * Installation failed return code: this is passed in the
2437      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2438      * because its packaged native code did not match any of the ABIs supported by the system.
2439      *
2440      * @hide
2441      */
2442     public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
2443 
2444     /**
2445      * Internal return code for NativeLibraryHelper methods to indicate that the package
2446      * being processed did not contain any native code. This is placed here only so that
2447      * it can belong to the same value space as the other install failure codes.
2448      *
2449      * @hide
2450      */
2451     @UnsupportedAppUsage
2452     public static final int NO_NATIVE_LIBRARIES = -114;
2453 
2454     /** {@hide} */
2455     public static final int INSTALL_FAILED_ABORTED = -115;
2456 
2457     /**
2458      * Installation failed return code: install type is incompatible with some other
2459      * installation flags supplied for the operation; or other circumstances such as trying
2460      * to upgrade a system app via an Incremental or instant app install.
2461      * @hide
2462      */
2463     public static final int INSTALL_FAILED_SESSION_INVALID = -116;
2464 
2465     /**
2466      * Installation parse return code: this is passed in the
2467      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the dex metadata file is invalid or
2468      * if there was no matching apk file for a dex metadata file.
2469      *
2470      * @hide
2471      */
2472     public static final int INSTALL_FAILED_BAD_DEX_METADATA = -117;
2473 
2474     /**
2475      * Installation parse return code: this is passed in the
2476      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if there is any signature problem.
2477      *
2478      * @hide
2479      */
2480     public static final int INSTALL_FAILED_BAD_SIGNATURE = -118;
2481 
2482     /**
2483      * Installation failed return code: a new staged session was attempted to be committed while
2484      * there is already one in-progress or new session has package that is already staged.
2485      *
2486      * @hide
2487      */
2488     public static final int INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS = -119;
2489 
2490     /**
2491      * Installation failed return code: one of the child sessions does not match the parent session
2492      * in respect to staged or rollback enabled parameters.
2493      *
2494      * @hide
2495      */
2496     public static final int INSTALL_FAILED_MULTIPACKAGE_INCONSISTENCY = -120;
2497 
2498     /**
2499      * Installation failed return code: the required installed version code
2500      * does not match the currently installed package version code.
2501      *
2502      * @hide
2503      */
2504     public static final int INSTALL_FAILED_WRONG_INSTALLED_VERSION = -121;
2505 
2506     /**
2507      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2508      * if the new package failed because it contains a request to use a process that was not
2509      * explicitly defined as part of its &lt;processes&gt; tag.
2510      *
2511      * @hide
2512      */
2513     public static final int INSTALL_FAILED_PROCESS_NOT_DEFINED = -122;
2514 
2515     /**
2516      * Installation failed return code: the {@code resources.arsc} of one of the APKs being
2517      * installed is compressed or not aligned on a 4-byte boundary. Resource tables that cannot be
2518      * memory mapped exert excess memory pressure on the system and drastically slow down
2519      * construction of {@link Resources} objects.
2520      *
2521      * @hide
2522      */
2523     public static final int INSTALL_PARSE_FAILED_RESOURCES_ARSC_COMPRESSED = -124;
2524 
2525     /**
2526      * Installation failed return code: the package was skipped and should be ignored.
2527      *
2528      * The reason for the skip is undefined.
2529      * @hide
2530      */
2531     public static final int INSTALL_PARSE_FAILED_SKIPPED = -125;
2532 
2533     /**
2534      * Installation failed return code: this is passed in the
2535      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2536      * because it is attempting to define a permission group that is already defined by some
2537      * existing package.
2538      *
2539      * @hide
2540      */
2541     public static final int INSTALL_FAILED_DUPLICATE_PERMISSION_GROUP = -126;
2542 
2543     /**
2544      * Installation failed return code: this is passed in the
2545      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
2546      * because it is attempting to define a permission in a group that does not exists or that is
2547      * defined by an packages with an incompatible certificate.
2548      *
2549      * @hide
2550      */
2551     public static final int INSTALL_FAILED_BAD_PERMISSION_GROUP = -127;
2552 
2553     /**
2554      * Installation failed return code: an error occurred during the activation phase of this
2555      * session.
2556      *
2557      * @hide
2558      */
2559     public static final int INSTALL_ACTIVATION_FAILED = -128;
2560 
2561     /**
2562      * Installation failed return code: requesting user pre-approval is currently unavailable.
2563      *
2564      * @hide
2565      */
2566     public static final int INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE = -129;
2567 
2568     /**
2569      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
2570      * if the new package declares bad certificate digest for a shared library in the package
2571      * manifest.
2572      *
2573      * @hide
2574      */
2575     public static final int INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST = -130;
2576 
2577     /**
2578      * Installation failed return code: if the system failed to install the package that
2579      * {@link android.R.attr#multiArch} is true in its manifest because its packaged
2580      * native code did not match all of the natively ABIs supported by the system.
2581      *
2582      * @hide
2583      */
2584     public static final int INSTALL_FAILED_MULTI_ARCH_NOT_MATCH_ALL_NATIVE_ABIS = -131;
2585 
2586     /**
2587      * App minimum aspect ratio set by the user which will override app-defined aspect ratio.
2588      *
2589      * @hide
2590      */
2591     @IntDef(prefix = { "USER_MIN_ASPECT_RATIO_" }, value = {
2592             USER_MIN_ASPECT_RATIO_UNSET,
2593             USER_MIN_ASPECT_RATIO_SPLIT_SCREEN,
2594             USER_MIN_ASPECT_RATIO_DISPLAY_SIZE,
2595             USER_MIN_ASPECT_RATIO_4_3,
2596             USER_MIN_ASPECT_RATIO_16_9,
2597             USER_MIN_ASPECT_RATIO_3_2,
2598             USER_MIN_ASPECT_RATIO_FULLSCREEN,
2599             USER_MIN_ASPECT_RATIO_APP_DEFAULT,
2600     })
2601     @Retention(RetentionPolicy.SOURCE)
2602     public @interface UserMinAspectRatio {}
2603 
2604     /**
2605      * No aspect ratio override has been set by user.
2606      *
2607      * @hide
2608      */
2609     public static final int USER_MIN_ASPECT_RATIO_UNSET = 0;
2610 
2611     /**
2612      * Aspect ratio override code: user forces app to split screen aspect ratio. This is adjusted to
2613      * half of the screen without the split screen divider.
2614      *
2615      * @hide
2616      */
2617     public static final int USER_MIN_ASPECT_RATIO_SPLIT_SCREEN = 1;
2618 
2619     /**
2620      * Aspect ratio override code: user forces app to the aspect ratio of the device display size.
2621      * This will be the portrait aspect ratio of the device if the app has fixed portrait
2622      * orientation or the landscape aspect ratio of the device if the app has fixed landscape
2623      * orientation.
2624      *
2625      * @hide
2626      */
2627     public static final int USER_MIN_ASPECT_RATIO_DISPLAY_SIZE = 2;
2628 
2629     /**
2630      * Aspect ratio override code: user forces app to 4:3 min aspect ratio
2631      * @hide
2632      */
2633     public static final int USER_MIN_ASPECT_RATIO_4_3 = 3;
2634 
2635     /**
2636      * Aspect ratio override code: user forces app to 16:9 min aspect ratio
2637      * @hide
2638      */
2639     public static final int USER_MIN_ASPECT_RATIO_16_9 = 4;
2640 
2641     /**
2642      * Aspect ratio override code: user forces app to 3:2 min aspect ratio
2643      * @hide
2644      */
2645     public static final int USER_MIN_ASPECT_RATIO_3_2 = 5;
2646 
2647     /**
2648      * Aspect ratio override code: user forces app to fullscreen
2649      * @hide
2650      */
2651     public static final int USER_MIN_ASPECT_RATIO_FULLSCREEN = 6;
2652 
2653     /**
2654      * Aspect ratio override code: user sets to app's default aspect ratio.
2655      * This resets both the user-forced aspect ratio, and the device manufacturer
2656      * per-app override {@link ActivityInfo#OVERRIDE_ANY_ORIENTATION_TO_USER}.
2657      * It is different from {@link #USER_MIN_ASPECT_RATIO_UNSET} as the latter may
2658      * apply the device manufacturer per-app orientation override if any,
2659      * @hide
2660      */
2661     public static final int USER_MIN_ASPECT_RATIO_APP_DEFAULT = 7;
2662 
2663     /** @hide */
2664     @IntDef(flag = true, prefix = { "DELETE_" }, value = {
2665             DELETE_KEEP_DATA,
2666             DELETE_ALL_USERS,
2667             DELETE_SYSTEM_APP,
2668             DELETE_DONT_KILL_APP,
2669             DELETE_CHATTY,
2670     })
2671     @Retention(RetentionPolicy.SOURCE)
2672     public @interface DeleteFlags {}
2673 
2674     /**
2675      * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
2676      * package's data directory.
2677      *
2678      * @hide
2679      */
2680     @SystemApi
2681     public static final int DELETE_KEEP_DATA = 0x00000001;
2682 
2683     /**
2684      * Flag parameter for {@link #deletePackage} to indicate that you want the
2685      * package deleted for all users.
2686      *
2687      * @hide
2688      */
2689     @SystemApi
2690     public static final int DELETE_ALL_USERS = 0x00000002;
2691 
2692     /**
2693      * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
2694      * uninstall on a system that has been updated, then don't do the normal process
2695      * of uninstalling the update and rolling back to the older system version (which
2696      * needs to happen for all users); instead, just mark the app as uninstalled for
2697      * the current user.
2698      *
2699      * @hide
2700      */
2701     public static final int DELETE_SYSTEM_APP = 0x00000004;
2702 
2703     /**
2704      * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
2705      * uninstall on a package that is replaced to provide new feature splits, the
2706      * existing application should not be killed during the removal process.
2707      *
2708      * @hide
2709      */
2710     public static final int DELETE_DONT_KILL_APP = 0x00000008;
2711 
2712     /**
2713      * Flag parameter for {@link PackageInstaller#uninstall(VersionedPackage, int, IntentSender)} to
2714      * indicate that the deletion is an archival. This
2715      * flag is only for internal usage as part of
2716      * {@link PackageInstaller#requestArchive}.
2717      */
2718     @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING)
2719     public static final int DELETE_ARCHIVE = 0x00000010;
2720 
2721     /**
2722      * Flag parameter for {@link #deletePackage} to indicate that package deletion
2723      * should be chatty.
2724      *
2725      * @hide
2726      */
2727     public static final int DELETE_CHATTY = 0x80000000;
2728 
2729     /**
2730      * Return code for when package deletion succeeds. This is passed to the
2731      * {@link IPackageDeleteObserver} if the system succeeded in deleting the
2732      * package.
2733      *
2734      * @hide
2735      */
2736     @SystemApi
2737     public static final int DELETE_SUCCEEDED = 1;
2738 
2739     /**
2740      * Deletion failed return code: this is passed to the
2741      * {@link IPackageDeleteObserver} if the system failed to delete the package
2742      * for an unspecified reason.
2743      *
2744      * @hide
2745      */
2746     @SystemApi
2747     public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
2748 
2749     /**
2750      * Deletion failed return code: this is passed to the
2751      * {@link IPackageDeleteObserver} if the system failed to delete the package
2752      * because it is the active DevicePolicy manager.
2753      *
2754      * @hide
2755      */
2756     @SystemApi
2757     public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
2758 
2759     /**
2760      * Deletion failed return code: this is passed to the
2761      * {@link IPackageDeleteObserver} if the system failed to delete the package
2762      * since the user is restricted.
2763      *
2764      * @hide
2765      */
2766     public static final int DELETE_FAILED_USER_RESTRICTED = -3;
2767 
2768     /**
2769      * Deletion failed return code: this is passed to the
2770      * {@link IPackageDeleteObserver} if the system failed to delete the package
2771      * because a profile or device owner has marked the package as
2772      * uninstallable.
2773      *
2774      * @hide
2775      */
2776     @SystemApi
2777     public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
2778 
2779     /** {@hide} */
2780     @SystemApi
2781     public static final int DELETE_FAILED_ABORTED = -5;
2782 
2783     /**
2784      * Deletion failed return code: this is passed to the
2785      * {@link IPackageDeleteObserver} if the system failed to delete the package
2786      * because the packge is a shared library used by other installed packages.
2787      * {@hide} */
2788     public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6;
2789 
2790     /**
2791      * Deletion failed return code: this is passed to the
2792      * {@link IPackageDeleteObserver} if the system failed to delete the package
2793      * because there is an app pinned.
2794      *
2795      * @hide
2796      */
2797     public static final int DELETE_FAILED_APP_PINNED = -7;
2798 
2799     /**
2800      * Deletion failed return code: this is passed to the
2801      * {@link IPackageDeleteObserver} if the system failed to delete the package
2802      * for any child profile with {@link UserProperties#getDeleteAppWithParent()} as true.
2803      * @hide
2804      */
2805     public static final int DELETE_FAILED_FOR_CHILD_PROFILE = -8;
2806 
2807     /**
2808      * Return code that is passed to the {@link IPackageMoveObserver} when the
2809      * package has been successfully moved by the system.
2810      *
2811      * @hide
2812      */
2813     public static final int MOVE_SUCCEEDED = -100;
2814 
2815     /**
2816      * Error code that is passed to the {@link IPackageMoveObserver} when the
2817      * package hasn't been successfully moved by the system because of
2818      * insufficient memory on specified media.
2819      *
2820      * @hide
2821      */
2822     public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
2823 
2824     /**
2825      * Error code that is passed to the {@link IPackageMoveObserver} if the
2826      * specified package doesn't exist.
2827      *
2828      * @hide
2829      */
2830     public static final int MOVE_FAILED_DOESNT_EXIST = -2;
2831 
2832     /**
2833      * Error code that is passed to the {@link IPackageMoveObserver} if the
2834      * specified package cannot be moved since its a system package.
2835      *
2836      * @hide
2837      */
2838     public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
2839 
2840     /**
2841      * Error code that is passed to the {@link IPackageMoveObserver} if the
2842      * specified package cannot be moved to the specified location.
2843      *
2844      * @hide
2845      */
2846     public static final int MOVE_FAILED_INVALID_LOCATION = -5;
2847 
2848     /**
2849      * Error code that is passed to the {@link IPackageMoveObserver} if the
2850      * specified package cannot be moved to the specified location.
2851      *
2852      * @hide
2853      */
2854     public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
2855 
2856     /**
2857      * Error code that is passed to the {@link IPackageMoveObserver} if the
2858      * specified package already has an operation pending in the queue.
2859      *
2860      * @hide
2861      */
2862     public static final int MOVE_FAILED_OPERATION_PENDING = -7;
2863 
2864     /**
2865      * Error code that is passed to the {@link IPackageMoveObserver} if the
2866      * specified package cannot be moved since it contains a device admin.
2867      *
2868      * @hide
2869      */
2870     public static final int MOVE_FAILED_DEVICE_ADMIN = -8;
2871 
2872     /**
2873      * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow
2874      * non-system apps to be moved to internal storage.
2875      *
2876      * @hide
2877      */
2878     public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9;
2879 
2880     /** @hide */
2881     public static final int MOVE_FAILED_LOCKED_USER = -10;
2882 
2883     /**
2884      * Flag parameter for {@link #movePackage} to indicate that
2885      * the package should be moved to internal storage if its
2886      * been installed on external media.
2887      * @hide
2888      */
2889     @Deprecated
2890     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
2891     public static final int MOVE_INTERNAL = 0x00000001;
2892 
2893     /**
2894      * Flag parameter for {@link #movePackage} to indicate that
2895      * the package should be moved to external media.
2896      * @hide
2897      */
2898     @Deprecated
2899     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
2900     public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
2901 
2902     /** {@hide} */
2903     public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
2904 
2905     /**
2906      * Extra field name for notifying package change event. Currently, it is used by PackageMonitor.
2907      * @hide
2908      */
2909     public static final String EXTRA_PACKAGE_MONITOR_CALLBACK_RESULT =
2910             "android.content.pm.extra.EXTRA_PACKAGE_MONITOR_CALLBACK_RESULT";
2911 
2912     /**
2913      * Usable by the required verifier as the {@code verificationCode} argument
2914      * for {@link PackageManager#verifyPendingInstall} to indicate that it will
2915      * allow the installation to proceed without any of the optional verifiers
2916      * needing to vote.
2917      *
2918      * @hide
2919      */
2920     public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
2921 
2922     /**
2923      * Used as the {@code verificationCode} argument for
2924      * {@link PackageManager#verifyPendingInstall} to indicate that the calling
2925      * package verifier allows the installation to proceed.
2926      */
2927     public static final int VERIFICATION_ALLOW = 1;
2928 
2929     /**
2930      * Used as the {@code verificationCode} argument for
2931      * {@link PackageManager#verifyPendingInstall} to indicate the calling
2932      * package verifier does not vote to allow the installation to proceed.
2933      */
2934     public static final int VERIFICATION_REJECT = -1;
2935 
2936     /**
2937      * Used as the {@code verificationCode} argument for
2938      * {@link PackageManager#verifyIntentFilter} to indicate that the calling
2939      * IntentFilter Verifier confirms that the IntentFilter is verified.
2940      *
2941      * @deprecated Use {@link DomainVerificationManager} APIs.
2942      * @hide
2943      */
2944     @Deprecated
2945     @SystemApi
2946     public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
2947 
2948     /**
2949      * Used as the {@code verificationCode} argument for
2950      * {@link PackageManager#verifyIntentFilter} to indicate that the calling
2951      * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
2952      *
2953      * @deprecated Use {@link DomainVerificationManager} APIs.
2954      * @hide
2955      */
2956     @Deprecated
2957     @SystemApi
2958     public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
2959 
2960     /**
2961      * Internal status code to indicate that an IntentFilter verification result is not specified.
2962      *
2963      * @deprecated Use {@link DomainVerificationManager} APIs.
2964      * @hide
2965      */
2966     @Deprecated
2967     @SystemApi
2968     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
2969 
2970     /**
2971      * Used as the {@code status} argument for
2972      * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
2973      * will always be prompted the Intent Disambiguation Dialog if there are two
2974      * or more Intent resolved for the IntentFilter's domain(s).
2975      *
2976      * @deprecated Use {@link DomainVerificationManager} APIs.
2977      * @hide
2978      */
2979     @Deprecated
2980     @SystemApi
2981     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
2982 
2983     /**
2984      * Used as the {@code status} argument for
2985      * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
2986      * will never be prompted the Intent Disambiguation Dialog if there are two
2987      * or more resolution of the Intent. The default App for the domain(s)
2988      * specified in the IntentFilter will also ALWAYS be used.
2989      *
2990      * @deprecated Use {@link DomainVerificationManager} APIs.
2991      * @hide
2992      */
2993     @Deprecated
2994     @SystemApi
2995     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
2996 
2997     /**
2998      * Used as the {@code status} argument for
2999      * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
3000      * may be prompted the Intent Disambiguation Dialog if there are two or more
3001      * Intent resolved. The default App for the domain(s) specified in the
3002      * IntentFilter will also NEVER be presented to the User.
3003      *
3004      * @deprecated Use {@link DomainVerificationManager} APIs.
3005      * @hide
3006      */
3007     @Deprecated
3008     @SystemApi
3009     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
3010 
3011     /**
3012      * Used as the {@code status} argument for
3013      * {@link #updateIntentVerificationStatusAsUser} to indicate that this app
3014      * should always be considered as an ambiguous candidate for handling the
3015      * matching Intent even if there are other candidate apps in the "always"
3016      * state. Put another way: if there are any 'always ask' apps in a set of
3017      * more than one candidate app, then a disambiguation is *always* presented
3018      * even if there is another candidate app with the 'always' state.
3019      *
3020      * @deprecated Use {@link DomainVerificationManager} APIs.
3021      * @hide
3022      */
3023     @Deprecated
3024     @SystemApi
3025     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
3026 
3027 
3028     /**
3029      * Indicates that the app metadata does not exist or its source is unknown.
3030      * @hide
3031      */
3032     @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
3033     @SystemApi
3034     public static final int APP_METADATA_SOURCE_UNKNOWN = 0;
3035     /**
3036      * Indicates that the app metadata is provided by the APK itself.
3037      * @hide
3038      */
3039     @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
3040     @SystemApi
3041     public static final int APP_METADATA_SOURCE_APK = 1;
3042     /**
3043      * Indicates that the app metadata is provided by the installer that installed the app.
3044      * @hide
3045      */
3046     @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
3047     @SystemApi
3048     public static final int APP_METADATA_SOURCE_INSTALLER = 2;
3049     /**
3050      * Indicates that the app metadata is provided as part of the system image.
3051      * @hide
3052      */
3053     @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
3054     @SystemApi
3055     public static final int APP_METADATA_SOURCE_SYSTEM_IMAGE = 3;
3056 
3057     /** @hide */
3058     @IntDef(flag = true, prefix = { "APP_METADATA_SOURCE_" }, value = {
3059             APP_METADATA_SOURCE_UNKNOWN,
3060             APP_METADATA_SOURCE_APK,
3061             APP_METADATA_SOURCE_INSTALLER,
3062             APP_METADATA_SOURCE_SYSTEM_IMAGE,
3063     })
3064     @Retention(RetentionPolicy.SOURCE)
3065     public @interface AppMetadataSource {}
3066 
3067     /**
3068      * Can be used as the {@code millisecondsToDelay} argument for
3069      * {@link PackageManager#extendVerificationTimeout}. This is the
3070      * maximum time {@code PackageManager} waits for the verification
3071      * agent to return (in milliseconds).
3072      */
3073     public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
3074 
3075     /**
3076      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
3077      * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
3078      * lag in sound input or output.
3079      */
3080     @SdkConstant(SdkConstantType.FEATURE)
3081     public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
3082 
3083     /**
3084      * Feature for {@link #getSystemAvailableFeatures} and
3085      * {@link #hasSystemFeature}: The device includes at least one form of audio
3086      * output, as defined in the Android Compatibility Definition Document (CDD)
3087      * <a href="https://source.android.com/compatibility/android-cdd#7_8_audio">section 7.8 Audio</a>.
3088      */
3089     @SdkConstant(SdkConstantType.FEATURE)
3090     public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
3091 
3092     /**
3093      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3094      * The device has professional audio level of functionality and performance.
3095      */
3096     @SdkConstant(SdkConstantType.FEATURE)
3097     public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
3098 
3099     /**
3100      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}
3101      * which indicates whether head tracking for spatial audio operates with low-latency,
3102      * as defined by the CDD criteria for the feature.
3103      *
3104      */
3105     @SdkConstant(SdkConstantType.FEATURE)
3106     @FlaggedApi(FLAG_FEATURE_SPATIAL_AUDIO_HEADTRACKING_LOW_LATENCY)
3107     public static final String FEATURE_AUDIO_SPATIAL_HEADTRACKING_LOW_LATENCY =
3108             "android.hardware.audio.spatial.headtracking.low_latency";
3109 
3110     /**
3111      * Feature for {@link #getSystemAvailableFeatures} and
3112      * {@link #hasSystemFeature}: The device is capable of communicating with
3113      * other devices via Bluetooth.
3114      */
3115     @SdkConstant(SdkConstantType.FEATURE)
3116     public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
3117 
3118     /**
3119      * Feature for {@link #getSystemAvailableFeatures} and
3120      * {@link #hasSystemFeature}: The device is capable of communicating with
3121      * other devices via Bluetooth Low Energy radio.
3122      */
3123     @SdkConstant(SdkConstantType.FEATURE)
3124     public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
3125 
3126     /**
3127      * Feature for {@link #getSystemAvailableFeatures} and
3128      * {@link #hasSystemFeature}: The device has a camera facing away
3129      * from the screen.
3130      */
3131     @SdkConstant(SdkConstantType.FEATURE)
3132     public static final String FEATURE_CAMERA = "android.hardware.camera";
3133 
3134     /**
3135      * Feature for {@link #getSystemAvailableFeatures} and
3136      * {@link #hasSystemFeature}: The device's camera supports auto-focus.
3137      */
3138     @SdkConstant(SdkConstantType.FEATURE)
3139     public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
3140 
3141     /**
3142      * Feature for {@link #getSystemAvailableFeatures} and
3143      * {@link #hasSystemFeature}: The device has at least one camera pointing in
3144      * some direction, or can support an external camera being connected to it.
3145      */
3146     @SdkConstant(SdkConstantType.FEATURE)
3147     public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
3148 
3149     /**
3150      * Feature for {@link #getSystemAvailableFeatures} and
3151      * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
3152      * The external camera may not always be connected or available to applications to use.
3153      */
3154     @SdkConstant(SdkConstantType.FEATURE)
3155     public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
3156 
3157     /**
3158      * Feature for {@link #getSystemAvailableFeatures} and
3159      * {@link #hasSystemFeature}: The device's camera supports flash.
3160      */
3161     @SdkConstant(SdkConstantType.FEATURE)
3162     public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
3163 
3164     /**
3165      * Feature for {@link #getSystemAvailableFeatures} and
3166      * {@link #hasSystemFeature}: The device has a front facing camera.
3167      */
3168     @SdkConstant(SdkConstantType.FEATURE)
3169     public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
3170 
3171     /**
3172      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
3173      * of the cameras on the device supports the
3174      * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
3175      * capability level.
3176      */
3177     @SdkConstant(SdkConstantType.FEATURE)
3178     public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
3179 
3180     /**
3181      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
3182      * of the cameras on the device supports the
3183      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
3184      * capability level.
3185      */
3186     @SdkConstant(SdkConstantType.FEATURE)
3187     public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
3188             "android.hardware.camera.capability.manual_sensor";
3189 
3190     /**
3191      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
3192      * of the cameras on the device supports the
3193      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
3194      * capability level.
3195      */
3196     @SdkConstant(SdkConstantType.FEATURE)
3197     public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
3198             "android.hardware.camera.capability.manual_post_processing";
3199 
3200     /**
3201      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
3202      * of the cameras on the device supports the
3203      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
3204      * capability level.
3205      */
3206     @SdkConstant(SdkConstantType.FEATURE)
3207     public static final String FEATURE_CAMERA_CAPABILITY_RAW =
3208             "android.hardware.camera.capability.raw";
3209 
3210     /**
3211      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
3212      * of the cameras on the device supports the
3213      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING
3214      * MOTION_TRACKING} capability level.
3215      */
3216     @SdkConstant(SdkConstantType.FEATURE)
3217     public static final String FEATURE_CAMERA_AR =
3218             "android.hardware.camera.ar";
3219 
3220     /**
3221      * Feature for {@link #getSystemAvailableFeatures} and
3222      * {@link #hasSystemFeature}: The device's main front and back cameras can stream
3223      * concurrently as described in {@link
3224      * android.hardware.camera2.CameraManager#getConcurrentCameraIds()}.
3225      * </p>
3226      * <p>While {@link android.hardware.camera2.CameraManager#getConcurrentCameraIds()} and
3227      * associated APIs are only available on API level 30 or newer, this feature flag may be
3228      * advertised by devices on API levels below 30. If present on such a device, the same
3229      * guarantees hold: The main front and main back camera can be used at the same time, with
3230      * guaranteed stream configurations as defined in the table for concurrent streaming at
3231      * {@link android.hardware.camera2.CameraDevice#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)}.
3232      * </p>
3233      */
3234     @SdkConstant(SdkConstantType.FEATURE)
3235     public static final String FEATURE_CAMERA_CONCURRENT = "android.hardware.camera.concurrent";
3236 
3237     /**
3238      * Feature for {@link #getSystemAvailableFeatures} and
3239      * {@link #hasSystemFeature}: The device is capable of communicating with
3240      * consumer IR devices.
3241      */
3242     @SdkConstant(SdkConstantType.FEATURE)
3243     public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
3244 
3245     /**
3246      * Feature for {@link #getSystemAvailableFeatures} and
3247      * {@link #hasSystemFeature}: The device supports a Context Hub, used to expose the
3248      * functionalities in {@link android.hardware.location.ContextHubManager}.
3249      *
3250      * @hide
3251      */
3252     @SystemApi
3253     @SdkConstant(SdkConstantType.FEATURE)
3254     public static final String FEATURE_CONTEXT_HUB = "android.hardware.context_hub";
3255 
3256     /** {@hide} */
3257     @SdkConstant(SdkConstantType.FEATURE)
3258     public static final String FEATURE_CTS = "android.software.cts";
3259 
3260     /**
3261      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3262      * is opted-in to render the application using Automotive App Host
3263      *
3264      * @hide
3265      */
3266     @SdkConstant(SdkConstantType.FEATURE)
3267     public static final String FEATURE_CAR_TEMPLATES_HOST =
3268             "android.software.car.templates_host";
3269 
3270     /**
3271      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:If this
3272      * feature is supported, the device should also declare {@link #FEATURE_AUTOMOTIVE} and show
3273      * a UI that can display multiple tasks at the same time on a single display. The user can
3274      * perform multiple actions on different tasks simultaneously. Apps open in split screen mode
3275      * by default, instead of full screen. Unlike Android's multi-window mode, where users can
3276      * choose how to display apps, the device determines how apps are shown.
3277      *
3278      * @hide
3279      */
3280     @SdkConstant(SdkConstantType.FEATURE)
3281     public static final String FEATURE_CAR_SPLITSCREEN_MULTITASKING =
3282             "android.software.car.splitscreen_multitasking";
3283 
3284     /**
3285      * Feature for {@link #getSystemAvailableFeatures} and
3286      * {@link #hasSystemFeature}: This device is capable of launching apps in automotive display
3287      * compatibility mode.
3288      * @hide
3289      */
3290     @SdkConstant(SdkConstantType.FEATURE)
3291     public static final String FEATURE_CAR_DISPLAY_COMPATIBILITY =
3292             "android.software.car.display_compatibility";
3293 
3294     /**
3295      * Feature for {@link #getSystemAvailableFeatures} and
3296      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports
3297      * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware
3298      * at the given feature version.
3299      *
3300      * <p>Known feature versions include:
3301      * <ul>
3302      * <li><code>202009</code>: corresponds to the features included in the Identity Credential
3303      * API shipped in Android 11.
3304      * <li><code>202101</code>: corresponds to the features included in the Identity Credential
3305      * API shipped in Android 12.
3306      * <li><code>202201</code>: corresponds to the features included in the Identity Credential
3307      * API shipped in Android 13.
3308      * </ul>
3309      */
3310     @SdkConstant(SdkConstantType.FEATURE)
3311     public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE =
3312             "android.hardware.identity_credential";
3313 
3314     /**
3315      * Feature for {@link #getSystemAvailableFeatures} and
3316      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device supports
3317      * {@link android.security.identity.IdentityCredentialStore} implemented in secure hardware
3318      * with direct access at the given feature version.
3319      * See {@link #FEATURE_IDENTITY_CREDENTIAL_HARDWARE} for known feature versions.
3320      */
3321     @SdkConstant(SdkConstantType.FEATURE)
3322     public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE_DIRECT_ACCESS =
3323             "android.hardware.identity_credential_direct_access";
3324 
3325     /**
3326      * Feature for {@link #getSystemAvailableFeatures} and
3327      * {@link #hasSystemFeature}: The device supports one or more methods of
3328      * reporting current location.
3329      */
3330     @SdkConstant(SdkConstantType.FEATURE)
3331     public static final String FEATURE_LOCATION = "android.hardware.location";
3332 
3333     /**
3334      * Feature for {@link #getSystemAvailableFeatures} and
3335      * {@link #hasSystemFeature}: The device has a Global Positioning System
3336      * receiver and can report precise location.
3337      */
3338     @SdkConstant(SdkConstantType.FEATURE)
3339     public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
3340 
3341     /**
3342      * Feature for {@link #getSystemAvailableFeatures} and
3343      * {@link #hasSystemFeature}: The device can report location with coarse
3344      * accuracy using a network-based geolocation system.
3345      */
3346     @SdkConstant(SdkConstantType.FEATURE)
3347     public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
3348 
3349     /**
3350      * Feature for {@link #getSystemAvailableFeatures} and
3351      * {@link #hasSystemFeature}: The device supports FeliCa communication, which is based on
3352      * ISO/IEC 18092 and JIS X 6319-4.
3353      *
3354      * @hide
3355      */
3356     @SdkConstant(SdkConstantType.FEATURE)
3357     public static final String FEATURE_FELICA = "android.hardware.felica";
3358 
3359     /**
3360      * Feature for {@link #getSystemAvailableFeatures} and
3361      * {@link #hasSystemFeature}: The device's
3362      * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
3363      * true.
3364      */
3365     @SdkConstant(SdkConstantType.FEATURE)
3366     public static final String FEATURE_RAM_LOW = "android.hardware.ram.low";
3367 
3368     /**
3369      * Feature for {@link #getSystemAvailableFeatures} and
3370      * {@link #hasSystemFeature}: The device's
3371      * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
3372      * false.
3373      */
3374     @SdkConstant(SdkConstantType.FEATURE)
3375     public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal";
3376 
3377     /**
3378      * Feature for {@link #getSystemAvailableFeatures} and
3379      * {@link #hasSystemFeature}: The device can record audio via a
3380      * microphone.
3381      */
3382     @SdkConstant(SdkConstantType.FEATURE)
3383     public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
3384 
3385     /**
3386      * Feature for {@link #getSystemAvailableFeatures} and
3387      * {@link #hasSystemFeature}: The device can communicate using Near-Field
3388      * Communications (NFC).
3389      */
3390     @SdkConstant(SdkConstantType.FEATURE)
3391     public static final String FEATURE_NFC = "android.hardware.nfc";
3392 
3393     /**
3394      * Feature for {@link #getSystemAvailableFeatures} and
3395      * {@link #hasSystemFeature}: The device supports host-
3396      * based NFC card emulation.
3397      *
3398      * TODO remove when depending apps have moved to new constant.
3399      * @hide
3400      * @deprecated
3401      */
3402     @Deprecated
3403     @SdkConstant(SdkConstantType.FEATURE)
3404     public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
3405 
3406     /**
3407      * Feature for {@link #getSystemAvailableFeatures} and
3408      * {@link #hasSystemFeature}: The device supports host-
3409      * based NFC card emulation.
3410      */
3411     @SdkConstant(SdkConstantType.FEATURE)
3412     public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
3413 
3414     /**
3415      * Feature for {@link #getSystemAvailableFeatures} and
3416      * {@link #hasSystemFeature}: The device supports host-
3417      * based NFC-F card emulation.
3418      */
3419     @SdkConstant(SdkConstantType.FEATURE)
3420     public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef";
3421 
3422     /**
3423      * Feature for {@link #getSystemAvailableFeatures} and
3424      * {@link #hasSystemFeature}: The device supports uicc-
3425      * based NFC card emulation.
3426      */
3427     @SdkConstant(SdkConstantType.FEATURE)
3428     public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC =
3429                                                                        "android.hardware.nfc.uicc";
3430 
3431     /**
3432      * Feature for {@link #getSystemAvailableFeatures} and
3433      * {@link #hasSystemFeature}: The device supports eSE-
3434      * based NFC card emulation.
3435      */
3436     @SdkConstant(SdkConstantType.FEATURE)
3437     public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE = "android.hardware.nfc.ese";
3438 
3439     /**
3440      * Feature for {@link #getSystemAvailableFeatures} and
3441      * {@link #hasSystemFeature}: The device supports NFC charging.
3442      */
3443     @SdkConstant(SdkConstantType.FEATURE)
3444     @FlaggedApi(android.nfc.Flags.FLAG_ENABLE_NFC_CHARGING)
3445     public static final String FEATURE_NFC_CHARGING = "android.hardware.nfc.charging";
3446 
3447     /**
3448      * Feature for {@link #getSystemAvailableFeatures} and
3449      * {@link #hasSystemFeature}: The Beam API is enabled on the device.
3450      */
3451     @SdkConstant(SdkConstantType.FEATURE)
3452     public static final String FEATURE_NFC_BEAM = "android.sofware.nfc.beam";
3453 
3454     /**
3455      * Feature for {@link #getSystemAvailableFeatures} and
3456      * {@link #hasSystemFeature}: The device supports any
3457      * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION},
3458      * {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF}, or {@link #FEATURE_NFC_CHARGING} features.
3459      *
3460      * @hide
3461      */
3462     @SdkConstant(SdkConstantType.FEATURE)
3463     public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any";
3464 
3465     /**
3466      * Feature for {@link #getSystemAvailableFeatures} and
3467      * {@link #hasSystemFeature}: The device contains support for installing SDKs to a work
3468      * profile.
3469      *
3470      * @hide
3471      */
3472     @SdkConstant(SdkConstantType.FEATURE)
3473     public static final String FEATURE_SDK_SANDBOX_WORK_PROFILE_INSTALL =
3474             "android.software.sdksandbox.sdk_install_work_profile";
3475 
3476     /**
3477      * Feature for {@link #getSystemAvailableFeatures} and
3478      * {@link #hasSystemFeature}: The device supports Open Mobile API capable UICC-based secure
3479      * elements.
3480      */
3481     @SdkConstant(SdkConstantType.FEATURE)
3482     public static final String FEATURE_SE_OMAPI_UICC = "android.hardware.se.omapi.uicc";
3483 
3484     /**
3485      * Feature for {@link #getSystemAvailableFeatures} and
3486      * {@link #hasSystemFeature}: The device supports Open Mobile API capable eSE-based secure
3487      * elements.
3488      */
3489     @SdkConstant(SdkConstantType.FEATURE)
3490     public static final String FEATURE_SE_OMAPI_ESE = "android.hardware.se.omapi.ese";
3491 
3492     /**
3493      * Feature for {@link #getSystemAvailableFeatures} and
3494      * {@link #hasSystemFeature}: The device supports Open Mobile API capable SD-based secure
3495      * elements.
3496      */
3497     @SdkConstant(SdkConstantType.FEATURE)
3498     public static final String FEATURE_SE_OMAPI_SD = "android.hardware.se.omapi.sd";
3499 
3500     /**
3501      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device is
3502      * compatible with Android’s security model.
3503      *
3504      * <p>See sections 2 and 9 in the
3505      * <a href="https://source.android.com/compatibility/android-cdd">Android CDD</a> for more
3506      * details.
3507      */
3508     @SdkConstant(SdkConstantType.FEATURE)
3509     public static final String FEATURE_SECURITY_MODEL_COMPATIBLE =
3510             "android.hardware.security.model.compatible";
3511 
3512     /**
3513      * Feature for {@link #getSystemAvailableFeatures} and
3514      * {@link #hasSystemFeature}: The device supports the OpenGL ES
3515      * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
3516      * Android Extension Pack</a>.
3517      */
3518     @SdkConstant(SdkConstantType.FEATURE)
3519     public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
3520 
3521     /**
3522      * Feature for {@link #getSystemAvailableFeatures()} and {@link #hasSystemFeature(String)}.
3523      * This feature indicates whether device supports
3524      * <a href="https://source.android.com/docs/core/virtualization">Android Virtualization Framework</a>.
3525      *
3526      * @hide
3527      */
3528     @SystemApi
3529     @SdkConstant(SdkConstantType.FEATURE)
3530     public static final String FEATURE_VIRTUALIZATION_FRAMEWORK =
3531             "android.software.virtualization_framework";
3532 
3533     /**
3534      * Feature for {@link #getSystemAvailableFeatures} and
3535      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan
3536      * implementation on this device is hardware accelerated, and the Vulkan native API will
3537      * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what
3538      * level of optional hardware features limits it supports.
3539      * <p>
3540      * Level 0 includes the base Vulkan requirements as well as:
3541      * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul>
3542      * <p>
3543      * Level 1 additionally includes:
3544      * <ul>
3545      * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li>
3546      * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li>
3547      * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li>
3548      * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li>
3549      * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li>
3550      * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li>
3551      * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li>
3552      * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li>
3553      * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li>
3554      * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li>
3555      * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li>
3556      * </ul>
3557      */
3558     @SdkConstant(SdkConstantType.FEATURE)
3559     public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level";
3560 
3561     /**
3562      * Feature for {@link #getSystemAvailableFeatures} and
3563      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan
3564      * implementation on this device is hardware accelerated, and the Vulkan native API will
3565      * enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate what
3566      * level of optional compute features that device supports beyond the Vulkan 1.0 requirements.
3567      * <p>
3568      * Compute level 0 indicates:
3569      * <ul>
3570      * <li>The {@code VK_KHR_variable_pointers} extension and
3571      *     {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are
3572            supported.</li>
3573      * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li>
3574      * </ul>
3575      */
3576     @SdkConstant(SdkConstantType.FEATURE)
3577     public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute";
3578 
3579     /**
3580      * Feature for {@link #getSystemAvailableFeatures} and
3581      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan
3582      * implementation on this device is hardware accelerated, and the feature version will indicate
3583      * the highest {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices
3584      * that support the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The
3585      * feature version uses the same encoding as Vulkan version numbers:
3586      * <ul>
3587      * <li>Major version number in bits 31-22</li>
3588      * <li>Minor version number in bits 21-12</li>
3589      * <li>Patch version number in bits 11-0</li>
3590      * </ul>
3591      * A version of 1.1.0 or higher also indicates:
3592      * <ul>
3593      * <li>The {@code VK_ANDROID_external_memory_android_hardware_buffer} extension is
3594      *     supported.</li>
3595      * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li>
3596      * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is
3597      *     supported.</li>
3598      * </ul>
3599      * A subset of devices that support Vulkan 1.1 do so via software emulation. For more
3600      * information, see
3601      * <a href="{@docRoot}ndk/guides/graphics/design-notes">Vulkan Design Guidelines</a>.
3602      */
3603     @SdkConstant(SdkConstantType.FEATURE)
3604     public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version";
3605 
3606     /**
3607      * Feature for {@link #getSystemAvailableFeatures} and
3608      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version
3609      * specifies a date such that the device is known to pass the Vulkan dEQP test suite associated
3610      * with that date.  The date is encoded as follows:
3611      * <ul>
3612      * <li>Year in bits 31-16</li>
3613      * <li>Month in bits 15-8</li>
3614      * <li>Day in bits 7-0</li>
3615      * </ul>
3616      * <p>
3617      * Example: 2019-03-01 is encoded as 0x07E30301, and would indicate that the device passes the
3618      * Vulkan dEQP test suite version that was current on 2019-03-01.
3619      */
3620     @SdkConstant(SdkConstantType.FEATURE)
3621     public static final String FEATURE_VULKAN_DEQP_LEVEL = "android.software.vulkan.deqp.level";
3622 
3623     /**
3624      * Feature for {@link #getSystemAvailableFeatures} and
3625      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the feature version
3626      * specifies a date such that the device is known to pass the OpenGLES dEQP test suite
3627      * associated with that date.  The date is encoded as follows:
3628      * <ul>
3629      * <li>Year in bits 31-16</li>
3630      * <li>Month in bits 15-8</li>
3631      * <li>Day in bits 7-0</li>
3632      * </ul>
3633      * <p>
3634      * Example: 2021-03-01 is encoded as 0x07E50301, and would indicate that the device passes the
3635      * OpenGL ES dEQP test suite version that was current on 2021-03-01.
3636      */
3637     @SdkConstant(SdkConstantType.FEATURE)
3638     public static final String FEATURE_OPENGLES_DEQP_LEVEL = "android.software.opengles.deqp.level";
3639 
3640     /**
3641      * Feature for {@link #getSystemAvailableFeatures} and
3642      * {@link #hasSystemFeature}: The device includes broadcast radio tuner.
3643      * @hide
3644      */
3645     @SystemApi
3646     @SdkConstant(SdkConstantType.FEATURE)
3647     public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio";
3648 
3649     /**
3650      * Feature for {@link #getSystemAvailableFeatures} and
3651      * {@link #hasSystemFeature}: The device has a secure implementation of keyguard, meaning the
3652      * device supports PIN, pattern and password as defined in Android CDD
3653      */
3654     @SdkConstant(SdkConstantType.FEATURE)
3655     public static final String FEATURE_SECURE_LOCK_SCREEN = "android.software.secure_lock_screen";
3656 
3657     /**
3658      * Feature for {@link #getSystemAvailableFeatures} and
3659      * {@link #hasSystemFeature}: The device includes an accelerometer.
3660      */
3661     @SdkConstant(SdkConstantType.FEATURE)
3662     public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
3663 
3664     /**
3665      * Feature for {@link #getSystemAvailableFeatures} and
3666      * {@link #hasSystemFeature}: The device includes a barometer (air
3667      * pressure sensor.)
3668      */
3669     @SdkConstant(SdkConstantType.FEATURE)
3670     public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
3671 
3672     /**
3673      * Feature for {@link #getSystemAvailableFeatures} and
3674      * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
3675      */
3676     @SdkConstant(SdkConstantType.FEATURE)
3677     public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
3678 
3679     /**
3680      * Feature for {@link #getSystemAvailableFeatures} and
3681      * {@link #hasSystemFeature}: The device includes a gyroscope.
3682      */
3683     @SdkConstant(SdkConstantType.FEATURE)
3684     public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
3685 
3686     /**
3687      * Feature for {@link #getSystemAvailableFeatures} and
3688      * {@link #hasSystemFeature}: The device includes a limited axes accelerometer.
3689      */
3690     @SdkConstant(SdkConstantType.FEATURE)
3691     public static final String FEATURE_SENSOR_ACCELEROMETER_LIMITED_AXES =
3692                 "android.hardware.sensor.accelerometer_limited_axes";
3693 
3694     /**
3695      * Feature for {@link #getSystemAvailableFeatures} and
3696      * {@link #hasSystemFeature}: The device includes a limited axes gyroscope.
3697      */
3698     @SdkConstant(SdkConstantType.FEATURE)
3699     public static final String FEATURE_SENSOR_GYROSCOPE_LIMITED_AXES =
3700                 "android.hardware.sensor.gyroscope_limited_axes";
3701 
3702     /**
3703      * Feature for {@link #getSystemAvailableFeatures} and
3704      * {@link #hasSystemFeature}: The device includes an uncalibrated limited axes accelerometer.
3705      */
3706     @SdkConstant(SdkConstantType.FEATURE)
3707     public static final String FEATURE_SENSOR_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED =
3708                 "android.hardware.sensor.accelerometer_limited_axes_uncalibrated";
3709 
3710     /**
3711      * Feature for {@link #getSystemAvailableFeatures} and
3712      * {@link #hasSystemFeature}: The device includes an uncalibrated limited axes gyroscope.
3713      */
3714     @SdkConstant(SdkConstantType.FEATURE)
3715     public static final String FEATURE_SENSOR_GYROSCOPE_LIMITED_AXES_UNCALIBRATED =
3716                 "android.hardware.sensor.gyroscope_limited_axes_uncalibrated";
3717 
3718     /**
3719      * Feature for {@link #getSystemAvailableFeatures} and
3720      * {@link #hasSystemFeature}: The device includes a light sensor.
3721      */
3722     @SdkConstant(SdkConstantType.FEATURE)
3723     public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
3724 
3725     /**
3726      * Feature for {@link #getSystemAvailableFeatures} and
3727      * {@link #hasSystemFeature}: The device includes a proximity sensor.
3728      */
3729     @SdkConstant(SdkConstantType.FEATURE)
3730     public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
3731 
3732     /**
3733      * Feature for {@link #getSystemAvailableFeatures} and
3734      * {@link #hasSystemFeature}: The device includes a hardware step counter.
3735      */
3736     @SdkConstant(SdkConstantType.FEATURE)
3737     public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
3738 
3739     /**
3740      * Feature for {@link #getSystemAvailableFeatures} and
3741      * {@link #hasSystemFeature}: The device includes a hardware step detector.
3742      */
3743     @SdkConstant(SdkConstantType.FEATURE)
3744     public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
3745 
3746     /**
3747      * Feature for {@link #getSystemAvailableFeatures} and
3748      * {@link #hasSystemFeature}: The device includes a heart rate monitor.
3749      */
3750     @SdkConstant(SdkConstantType.FEATURE)
3751     public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
3752 
3753     /**
3754      * Feature for {@link #getSystemAvailableFeatures} and
3755      * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram.
3756      */
3757     @SdkConstant(SdkConstantType.FEATURE)
3758     public static final String FEATURE_SENSOR_HEART_RATE_ECG =
3759             "android.hardware.sensor.heartrate.ecg";
3760 
3761     /**
3762      * Feature for {@link #getSystemAvailableFeatures} and
3763      * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
3764      */
3765     @SdkConstant(SdkConstantType.FEATURE)
3766     public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
3767             "android.hardware.sensor.relative_humidity";
3768 
3769     /**
3770      * Feature for {@link #getSystemAvailableFeatures} and
3771      * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
3772      */
3773     @SdkConstant(SdkConstantType.FEATURE)
3774     public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
3775             "android.hardware.sensor.ambient_temperature";
3776 
3777     /**
3778      * Feature for {@link #getSystemAvailableFeatures} and
3779      * {@link #hasSystemFeature}: The device includes a hinge angle sensor.
3780      */
3781     @SdkConstant(SdkConstantType.FEATURE)
3782     public static final String FEATURE_SENSOR_HINGE_ANGLE = "android.hardware.sensor.hinge_angle";
3783 
3784      /**
3785      * Feature for {@link #getSystemAvailableFeatures} and
3786      * {@link #hasSystemFeature}: The device includes a heading sensor.
3787      */
3788     @SdkConstant(SdkConstantType.FEATURE)
3789     public static final String FEATURE_SENSOR_HEADING = "android.hardware.sensor.heading";
3790 
3791     /**
3792      * Feature for {@link #getSystemAvailableFeatures} and
3793      * {@link #hasSystemFeature}: The device supports exposing head tracker sensors from peripheral
3794      * devices via the dynamic sensors API.
3795      */
3796     @SdkConstant(SdkConstantType.FEATURE)
3797     public static final String FEATURE_SENSOR_DYNAMIC_HEAD_TRACKER = "android.hardware.sensor.dynamic.head_tracker";
3798 
3799     /**
3800      * Feature for {@link #getSystemAvailableFeatures} and
3801      * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
3802      * capabilities.
3803      */
3804     @SdkConstant(SdkConstantType.FEATURE)
3805     public static final String FEATURE_HIFI_SENSORS =
3806             "android.hardware.sensor.hifi_sensors";
3807 
3808     /**
3809      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3810      * The device supports a hardware mechanism for invoking an assist gesture.
3811      * @see android.provider.Settings.Secure#ASSIST_GESTURE_ENABLED
3812      * @hide
3813      */
3814     @SdkConstant(SdkConstantType.FEATURE)
3815     public static final String FEATURE_ASSIST_GESTURE = "android.hardware.sensor.assist";
3816 
3817     /**
3818      * Feature for {@link #getSystemAvailableFeatures} and
3819      * {@link #hasSystemFeature}: The device has a telephony radio with data
3820      * communication support.
3821      */
3822     @SdkConstant(SdkConstantType.FEATURE)
3823     public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
3824 
3825     /**
3826      * Feature for {@link #getSystemAvailableFeatures} and
3827      * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
3828      *
3829      * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined.
3830      */
3831     @SdkConstant(SdkConstantType.FEATURE)
3832     public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
3833 
3834     /**
3835      * Feature for {@link #getSystemAvailableFeatures} and
3836      * {@link #hasSystemFeature}: The device has a GSM telephony stack.
3837      *
3838      * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined.
3839      */
3840     @SdkConstant(SdkConstantType.FEATURE)
3841     public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
3842 
3843     /**
3844      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3845      * The device supports telephony carrier restriction mechanism.
3846      *
3847      * <p>Devices declaring this feature must have an implementation of the
3848      * {@link android.telephony.TelephonyManager#getAllowedCarriers} and
3849      * {@link android.telephony.TelephonyManager#setAllowedCarriers}.
3850      *
3851      * This feature should only be defined if {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3852      * has been defined.
3853      * @hide
3854      */
3855     @SystemApi
3856     @SdkConstant(SdkConstantType.FEATURE)
3857     public static final String FEATURE_TELEPHONY_CARRIERLOCK =
3858             "android.hardware.telephony.carrierlock";
3859 
3860     /**
3861      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3862      * supports embedded subscriptions on eUICCs.
3863      *
3864      * This feature should only be defined if {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3865      * has been defined.
3866      */
3867     @SdkConstant(SdkConstantType.FEATURE)
3868     public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc";
3869 
3870     /**
3871      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3872      * supports multiple enabled profiles on eUICCs.
3873      *
3874      * <p>Devices declaring this feature must have an implementation of the
3875      *  {@link UiccCardInfo#getPorts},
3876      *  {@link UiccCardInfo#isMultipleEnabledProfilesSupported} and
3877      *  {@link android.telephony.euicc.EuiccManager#switchToSubscription (with portIndex)}.
3878      *
3879      * This feature should only be defined if {@link #FEATURE_TELEPHONY_EUICC} have been defined.
3880      */
3881     @SdkConstant(SdkConstantType.FEATURE)
3882     public static final String FEATURE_TELEPHONY_EUICC_MEP = "android.hardware.telephony.euicc.mep";
3883 
3884     /**
3885      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3886      * supports cell-broadcast reception using the MBMS APIs.
3887      *
3888      * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3889      * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined.
3890      */
3891     @SdkConstant(SdkConstantType.FEATURE)
3892     public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms";
3893 
3894     /**
3895      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3896      * supports attaching to IMS implementations using the ImsService API in telephony.
3897      *
3898      * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_DATA} has been defined.
3899      */
3900     @SdkConstant(SdkConstantType.FEATURE)
3901     public static final String FEATURE_TELEPHONY_IMS = "android.hardware.telephony.ims";
3902 
3903     /**
3904      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
3905      * supports a single IMS registration as defined by carrier networks in the IMS service
3906      * implementation using the {@link ImsService} API, {@link GbaService} API, and IRadio 1.6 HAL.
3907      * <p>
3908      * When set, the device must fully support the following APIs for an application to implement
3909      * IMS single registration:
3910      * <ul>
3911      * <li> Updating RCS provisioning status using the {@link ProvisioningManager} API to supply an
3912      * RCC.14 defined XML and notify IMS applications of Auto Configuration Server (ACS) or
3913      * proprietary server provisioning updates.</li>
3914      * <li>Opening a delegate in the device IMS service to forward SIP traffic to the carrier's
3915      * network using the {@link SipDelegateManager} API</li>
3916      * <li>Listening to EPS dedicated bearer establishment via the
3917      * {@link ConnectivityManager#registerQosCallback}
3918      * API to indicate to the application when to start/stop media traffic.</li>
3919      * <li>Implementing Generic Bootstrapping Architecture (GBA) and providing the associated
3920      * authentication keys to applications
3921      * requesting this information via the {@link TelephonyManager#bootstrapAuthenticationRequest}
3922      * API</li>
3923      * <li>Implementing RCS User Capability Exchange using the {@link RcsUceAdapter} API</li>
3924      * </ul>
3925      * <p>
3926      * This feature should only be defined if {@link #FEATURE_TELEPHONY_IMS} is also defined.
3927      * @hide
3928      */
3929     @SystemApi
3930     @SdkConstant(SdkConstantType.FEATURE)
3931     public static final String FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION =
3932             "android.hardware.telephony.ims.singlereg";
3933 
3934     /**
3935      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3936      * The device supports Telecom Service APIs.
3937      */
3938     @SdkConstant(SdkConstantType.FEATURE)
3939     public static final String FEATURE_TELECOM = "android.software.telecom";
3940 
3941     /**
3942      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3943      * The device supports Telephony APIs for calling service.
3944      *
3945      * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_RADIO_ACCESS},
3946      * {@link #FEATURE_TELEPHONY_SUBSCRIPTION}, and {@link #FEATURE_TELECOM} have been defined.
3947      */
3948     @SdkConstant(SdkConstantType.FEATURE)
3949     public static final String FEATURE_TELEPHONY_CALLING = "android.hardware.telephony.calling";
3950 
3951     /**
3952      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3953      * The device supports Telephony APIs for data service.
3954      *
3955      * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3956      * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined.
3957      */
3958     @SdkConstant(SdkConstantType.FEATURE)
3959     public static final String FEATURE_TELEPHONY_DATA = "android.hardware.telephony.data";
3960 
3961     /**
3962      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3963      * The device supports Telephony APIs for SMS and MMS.
3964      *
3965      * <p>This feature should only be defined if both {@link #FEATURE_TELEPHONY_SUBSCRIPTION}
3966      * and {@link #FEATURE_TELEPHONY_RADIO_ACCESS} have been defined.
3967      */
3968     @SdkConstant(SdkConstantType.FEATURE)
3969     public static final String FEATURE_TELEPHONY_MESSAGING = "android.hardware.telephony.messaging";
3970 
3971     /**
3972      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3973      * The device supports Telephony APIs for the radio access.
3974      *
3975      * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined.
3976      */
3977     @SdkConstant(SdkConstantType.FEATURE)
3978     public static final String FEATURE_TELEPHONY_RADIO_ACCESS =
3979             "android.hardware.telephony.radio.access";
3980 
3981     /**
3982      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3983      * The device supports Telephony APIs for Satellite communication.
3984      *
3985      * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY_MESSAGING}
3986      * has been defined.
3987      *
3988      * @hide
3989      */
3990     @SdkConstant(SdkConstantType.FEATURE)
3991     public static final String FEATURE_TELEPHONY_SATELLITE = "android.hardware.telephony.satellite";
3992 
3993     /**
3994      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
3995      * The device supports Telephony APIs for the subscription.
3996      *
3997      * <p>This feature should only be defined if {@link #FEATURE_TELEPHONY} has been defined.
3998      */
3999     @SdkConstant(SdkConstantType.FEATURE)
4000     public static final String FEATURE_TELEPHONY_SUBSCRIPTION =
4001             "android.hardware.telephony.subscription";
4002 
4003     /**
4004      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4005      * The device is capable of communicating with other devices via
4006      * <a href="https://www.threadgroup.org">Thread</a> networking protocol.
4007      */
4008     @FlaggedApi(com.android.net.thread.platform.flags.Flags.FLAG_THREAD_ENABLED_PLATFORM)
4009     @SdkConstant(SdkConstantType.FEATURE)
4010     public static final String FEATURE_THREAD_NETWORK = "android.hardware.thread_network";
4011 
4012     /**
4013      * Feature for {@link #getSystemAvailableFeatures} and
4014      * {@link #hasSystemFeature}: The device is capable of communicating with
4015      * other devices via ultra wideband.
4016      */
4017     @SdkConstant(SdkConstantType.FEATURE)
4018     public static final String FEATURE_UWB = "android.hardware.uwb";
4019 
4020     /**
4021      * Feature for {@link #getSystemAvailableFeatures} and
4022      * {@link #hasSystemFeature}: The device supports connecting to USB devices
4023      * as the USB host.
4024      */
4025     @SdkConstant(SdkConstantType.FEATURE)
4026     public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
4027 
4028     /**
4029      * Feature for {@link #getSystemAvailableFeatures} and
4030      * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
4031      */
4032     @SdkConstant(SdkConstantType.FEATURE)
4033     public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
4034 
4035     /**
4036      * Feature for {@link #getSystemAvailableFeatures} and
4037      * {@link #hasSystemFeature}: The SIP API is enabled on the device.
4038      */
4039     @SdkConstant(SdkConstantType.FEATURE)
4040     public static final String FEATURE_SIP = "android.software.sip";
4041 
4042     /**
4043      * Feature for {@link #getSystemAvailableFeatures} and
4044      * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
4045      */
4046     @SdkConstant(SdkConstantType.FEATURE)
4047     public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
4048 
4049     /**
4050      * Feature for {@link #getSystemAvailableFeatures} and
4051      * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
4052      * @deprecated use {@link #FEATURE_TELECOM} instead.
4053      */
4054     @Deprecated
4055     @SdkConstant(SdkConstantType.FEATURE)
4056     public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
4057 
4058     /**
4059      * Feature for {@link #getSystemAvailableFeatures} and
4060      * {@link #hasSystemFeature}: The device's display has a touch screen.
4061      */
4062     @SdkConstant(SdkConstantType.FEATURE)
4063     public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
4064 
4065     /**
4066      * Feature for {@link #getSystemAvailableFeatures} and
4067      * {@link #hasSystemFeature}: The device's touch screen supports
4068      * multitouch sufficient for basic two-finger gesture detection.
4069      */
4070     @SdkConstant(SdkConstantType.FEATURE)
4071     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
4072 
4073     /**
4074      * Feature for {@link #getSystemAvailableFeatures} and
4075      * {@link #hasSystemFeature}: The device's touch screen is capable of
4076      * tracking two or more fingers fully independently.
4077      */
4078     @SdkConstant(SdkConstantType.FEATURE)
4079     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
4080 
4081     /**
4082      * Feature for {@link #getSystemAvailableFeatures} and
4083      * {@link #hasSystemFeature}: The device's touch screen is capable of
4084      * tracking a full hand of fingers fully independently -- that is, 5 or
4085      * more simultaneous independent pointers.
4086      */
4087     @SdkConstant(SdkConstantType.FEATURE)
4088     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
4089 
4090     /**
4091      * Feature for {@link #getSystemAvailableFeatures} and
4092      * {@link #hasSystemFeature}: The device does not have a touch screen, but
4093      * does support touch emulation for basic events. For instance, the
4094      * device might use a mouse or remote control to drive a cursor, and
4095      * emulate basic touch pointer events like down, up, drag, etc. All
4096      * devices that support android.hardware.touchscreen or a sub-feature are
4097      * presumed to also support faketouch.
4098      */
4099     @SdkConstant(SdkConstantType.FEATURE)
4100     public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
4101 
4102     /**
4103      * Feature for {@link #getSystemAvailableFeatures} and
4104      * {@link #hasSystemFeature}: The device does not have a touch screen, but
4105      * does support touch emulation for basic events that supports distinct
4106      * tracking of two or more fingers.  This is an extension of
4107      * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
4108      * that unlike a distinct multitouch screen as defined by
4109      * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
4110      * devices will not actually provide full two-finger gestures since the
4111      * input is being transformed to cursor movement on the screen.  That is,
4112      * single finger gestures will move a cursor; two-finger swipes will
4113      * result in single-finger touch events; other two-finger gestures will
4114      * result in the corresponding two-finger touch event.
4115      */
4116     @SdkConstant(SdkConstantType.FEATURE)
4117     public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
4118 
4119     /**
4120      * Feature for {@link #getSystemAvailableFeatures} and
4121      * {@link #hasSystemFeature}: The device does not have a touch screen, but
4122      * does support touch emulation for basic events that supports tracking
4123      * a hand of fingers (5 or more fingers) fully independently.
4124      * This is an extension of
4125      * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
4126      * that unlike a multitouch screen as defined by
4127      * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
4128      * gestures can be detected due to the limitations described for
4129      * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
4130      */
4131     @SdkConstant(SdkConstantType.FEATURE)
4132     public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
4133 
4134     /**
4135      * Feature for {@link #getSystemAvailableFeatures} and
4136      * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
4137      */
4138     @SdkConstant(SdkConstantType.FEATURE)
4139     public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
4140 
4141     /**
4142      * Feature for {@link #getSystemAvailableFeatures} and
4143      * {@link #hasSystemFeature}: The device has biometric hardware to perform face authentication.
4144      */
4145     @SdkConstant(SdkConstantType.FEATURE)
4146     public static final String FEATURE_FACE = "android.hardware.biometrics.face";
4147 
4148     /**
4149      * Feature for {@link #getSystemAvailableFeatures} and
4150      * {@link #hasSystemFeature}: The device has biometric hardware to perform iris authentication.
4151      */
4152     @SdkConstant(SdkConstantType.FEATURE)
4153     public static final String FEATURE_IRIS = "android.hardware.biometrics.iris";
4154 
4155     /**
4156      * Feature for {@link #getSystemAvailableFeatures} and
4157      * {@link #hasSystemFeature}: The device supports portrait orientation
4158      * screens.  For backwards compatibility, you can assume that if neither
4159      * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
4160      * both portrait and landscape.
4161      */
4162     @SdkConstant(SdkConstantType.FEATURE)
4163     public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
4164 
4165     /**
4166      * Feature for {@link #getSystemAvailableFeatures} and
4167      * {@link #hasSystemFeature}: The device supports landscape orientation
4168      * screens.  For backwards compatibility, you can assume that if neither
4169      * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
4170      * both portrait and landscape.
4171      */
4172     @SdkConstant(SdkConstantType.FEATURE)
4173     public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
4174 
4175     /**
4176      * Feature for {@link #getSystemAvailableFeatures} and
4177      * {@link #hasSystemFeature}: The device supports live wallpapers.
4178      */
4179     @SdkConstant(SdkConstantType.FEATURE)
4180     public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
4181     /**
4182      * Feature for {@link #getSystemAvailableFeatures} and
4183      * {@link #hasSystemFeature}: The device supports app widgets.
4184      */
4185     @SdkConstant(SdkConstantType.FEATURE)
4186     public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
4187     /**
4188      * Feature for {@link #getSystemAvailableFeatures} and
4189      * {@link #hasSystemFeature}: The device supports the
4190      * {@link android.R.attr#cantSaveState} API.
4191      */
4192     @SdkConstant(SdkConstantType.FEATURE)
4193     public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state";
4194 
4195     /**
4196      * @hide
4197      * Feature for {@link #getSystemAvailableFeatures} and
4198      * {@link #hasSystemFeature}: The device supports
4199      * {@link android.service.games.GameService}.
4200      *
4201      * @hide
4202      */
4203     @SdkConstant(SdkConstantType.FEATURE)
4204     @SystemApi
4205     public static final String FEATURE_GAME_SERVICE = "android.software.game_service";
4206 
4207     /**
4208      * @hide
4209      * Feature for {@link #getSystemAvailableFeatures} and
4210      * {@link #hasSystemFeature}: The device supports
4211      * {@link android.service.voice.VoiceInteractionService} and
4212      * {@link android.app.VoiceInteractor}.
4213      */
4214     @SdkConstant(SdkConstantType.FEATURE)
4215     public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
4216 
4217 
4218     /**
4219      * Feature for {@link #getSystemAvailableFeatures} and
4220      * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
4221      * by third party applications.
4222      */
4223     @SdkConstant(SdkConstantType.FEATURE)
4224     public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
4225 
4226     /**
4227      * Feature for {@link #getSystemAvailableFeatures} and
4228      * {@link #hasSystemFeature}: The device supports adding new input methods implemented
4229      * with the {@link android.inputmethodservice.InputMethodService} API.
4230      */
4231     @SdkConstant(SdkConstantType.FEATURE)
4232     public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
4233 
4234     /**
4235      * Feature for {@link #getSystemAvailableFeatures} and
4236      * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
4237      */
4238     @SdkConstant(SdkConstantType.FEATURE)
4239     public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
4240 
4241     /**
4242      * Feature for {@link #getSystemAvailableFeatures} and
4243      * {@link #hasSystemFeature}: The device supports leanback UI. This is
4244      * typically used in a living room television experience, but is a software
4245      * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
4246      * feature will use resources associated with the "television" UI mode.
4247      */
4248     @SdkConstant(SdkConstantType.FEATURE)
4249     public static final String FEATURE_LEANBACK = "android.software.leanback";
4250 
4251     /**
4252      * Feature for {@link #getSystemAvailableFeatures} and
4253      * {@link #hasSystemFeature}: The device supports only leanback UI. Only
4254      * applications designed for this experience should be run, though this is
4255      * not enforced by the system.
4256      */
4257     @SdkConstant(SdkConstantType.FEATURE)
4258     public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
4259 
4260     /**
4261      * Feature for {@link #getSystemAvailableFeatures} and
4262      * {@link #hasSystemFeature}: The device supports live TV and can display
4263      * contents from TV inputs implemented with the
4264      * {@link android.media.tv.TvInputService} API.
4265      */
4266     @SdkConstant(SdkConstantType.FEATURE)
4267     public static final String FEATURE_LIVE_TV = "android.software.live_tv";
4268 
4269     /**
4270      * Feature for {@link #getSystemAvailableFeatures} and
4271      * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
4272      */
4273     @SdkConstant(SdkConstantType.FEATURE)
4274     public static final String FEATURE_WIFI = "android.hardware.wifi";
4275 
4276     /**
4277      * Feature for {@link #getSystemAvailableFeatures} and
4278      * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
4279      */
4280     @SdkConstant(SdkConstantType.FEATURE)
4281     public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
4282 
4283     /**
4284      * Feature for {@link #getSystemAvailableFeatures} and
4285      * {@link #hasSystemFeature}: The device supports Wi-Fi Aware.
4286      */
4287     @SdkConstant(SdkConstantType.FEATURE)
4288     public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware";
4289 
4290     /**
4291      * Feature for {@link #getSystemAvailableFeatures} and
4292      * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all
4293      * Passpoint related APIs in {@link WifiManager} are supported. Refer to
4294      * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info.
4295      */
4296     @SdkConstant(SdkConstantType.FEATURE)
4297     public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint";
4298 
4299     /**
4300      * Feature for {@link #getSystemAvailableFeatures} and
4301      * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc).
4302      */
4303     @SdkConstant(SdkConstantType.FEATURE)
4304     public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt";
4305 
4306 
4307     /**
4308      * Feature for {@link #getSystemAvailableFeatures} and
4309      * {@link #hasSystemFeature}: The device supports LoWPAN networking.
4310      * @hide
4311      */
4312     @SdkConstant(SdkConstantType.FEATURE)
4313     public static final String FEATURE_LOWPAN = "android.hardware.lowpan";
4314 
4315     /**
4316      * Feature for {@link #getSystemAvailableFeatures} and
4317      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
4318      * on a vehicle headunit. A headunit here is defined to be inside a
4319      * vehicle that may or may not be moving. A headunit uses either a
4320      * primary display in the center console and/or additional displays in
4321      * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
4322      * have limited size and resolution. The user will likely be focused on
4323      * driving so limiting driver distraction is a primary concern. User input
4324      * can be a variety of hard buttons, touch, rotary controllers and even mouse-
4325      * like interfaces.
4326      */
4327     @SdkConstant(SdkConstantType.FEATURE)
4328     public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
4329 
4330     /**
4331      * Feature for {@link #getSystemAvailableFeatures} and
4332      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
4333      * on a television.  Television here is defined to be a typical living
4334      * room television experience: displayed on a big screen, where the user
4335      * is sitting far away from it, and the dominant form of input will be
4336      * something like a DPAD, not through touch or mouse.
4337      * @deprecated use {@link #FEATURE_LEANBACK} instead.
4338      */
4339     @Deprecated
4340     @SdkConstant(SdkConstantType.FEATURE)
4341     public static final String FEATURE_TELEVISION = "android.hardware.type.television";
4342 
4343     /**
4344      * Feature for {@link #getSystemAvailableFeatures} and
4345      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
4346      * on a watch. A watch here is defined to be a device worn on the body, perhaps on
4347      * the wrist. The user is very close when interacting with the device.
4348      */
4349     @SdkConstant(SdkConstantType.FEATURE)
4350     public static final String FEATURE_WATCH = "android.hardware.type.watch";
4351 
4352     /**
4353      * Feature for {@link #getSystemAvailableFeatures} and
4354      * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded
4355      * device is defined as a full stack Android device with or without a display and no
4356      * user-installable apps.
4357      */
4358     @SdkConstant(SdkConstantType.FEATURE)
4359     public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded";
4360 
4361     /**
4362      * Feature for {@link #getSystemAvailableFeatures} and
4363      * {@link #hasSystemFeature}: This is a device dedicated to be primarily used
4364      * with keyboard, mouse or touchpad. This includes traditional desktop
4365      * computers, laptops and variants such as convertibles or detachables.
4366      * Due to the larger screen, the device will most likely use the
4367      * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well.
4368      */
4369     @SdkConstant(SdkConstantType.FEATURE)
4370     public static final String FEATURE_PC = "android.hardware.type.pc";
4371 
4372     /**
4373      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4374      * The device supports printing.
4375      */
4376     @SdkConstant(SdkConstantType.FEATURE)
4377     public static final String FEATURE_PRINTING = "android.software.print";
4378 
4379     /**
4380      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4381      * The device supports {@link android.companion.CompanionDeviceManager#associate associating}
4382      * with devices via {@link android.companion.CompanionDeviceManager}.
4383      */
4384     @SdkConstant(SdkConstantType.FEATURE)
4385     public static final String FEATURE_COMPANION_DEVICE_SETUP
4386             = "android.software.companion_device_setup";
4387 
4388     /**
4389      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4390      * The device can perform backup and restore operations on installed applications.
4391      */
4392     @SdkConstant(SdkConstantType.FEATURE)
4393     public static final String FEATURE_BACKUP = "android.software.backup";
4394 
4395     /**
4396      * Feature for {@link #getSystemAvailableFeatures} and
4397      * {@link #hasSystemFeature}: The device supports freeform window management.
4398      * Windows have title bars and can be moved and resized.
4399      */
4400     @SdkConstant(SdkConstantType.FEATURE)
4401     public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
4402             = "android.software.freeform_window_management";
4403 
4404     /**
4405      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4406      * The device supports picture-in-picture multi-window mode.
4407      */
4408     @SdkConstant(SdkConstantType.FEATURE)
4409     public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
4410 
4411     /**
4412      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4413      * The device supports expanded picture-in-picture multi-window mode.
4414      *
4415      * @see android.app.PictureInPictureParams.Builder#setExpandedAspectRatio
4416      */
4417     @SdkConstant(SdkConstantType.FEATURE)
4418     public static final String FEATURE_EXPANDED_PICTURE_IN_PICTURE
4419             = "android.software.expanded_picture_in_picture";
4420 
4421     /**
4422      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4423      * The device supports running activities on secondary displays. Displays here
4424      * refers to both physical and virtual displays. Disabling this feature can impact
4425      * support for application projection use-cases and support for virtual devices
4426      * on the device.
4427      */
4428     @SdkConstant(SdkConstantType.FEATURE)
4429     public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS
4430             = "android.software.activities_on_secondary_displays";
4431 
4432     /**
4433      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4434      * The device supports creating secondary users and managed profiles via
4435      * {@link DevicePolicyManager}.
4436      */
4437     @SdkConstant(SdkConstantType.FEATURE)
4438     public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
4439 
4440     /**
4441      * @hide
4442      * TODO: Remove after dependencies updated b/17392243
4443      */
4444     public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
4445 
4446     /**
4447      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4448      * The device supports verified boot.
4449      */
4450     @SdkConstant(SdkConstantType.FEATURE)
4451     public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
4452 
4453     /**
4454      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4455      * The device supports secure removal of users. When a user is deleted the data associated
4456      * with that user is securely deleted and no longer available.
4457      */
4458     @SdkConstant(SdkConstantType.FEATURE)
4459     public static final String FEATURE_SECURELY_REMOVES_USERS
4460             = "android.software.securely_removes_users";
4461 
4462     /** {@hide} */
4463     @TestApi
4464     @SdkConstant(SdkConstantType.FEATURE)
4465     public static final String FEATURE_FILE_BASED_ENCRYPTION
4466             = "android.software.file_based_encryption";
4467 
4468     /** {@hide} */
4469     @TestApi
4470     @SdkConstant(SdkConstantType.FEATURE)
4471     public static final String FEATURE_ADOPTABLE_STORAGE
4472             = "android.software.adoptable_storage";
4473 
4474     /**
4475      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4476      * The device has a full implementation of the android.webkit.* APIs. Devices
4477      * lacking this feature will not have a functioning WebView implementation.
4478      */
4479     @SdkConstant(SdkConstantType.FEATURE)
4480     public static final String FEATURE_WEBVIEW = "android.software.webview";
4481 
4482     /**
4483      * Feature for {@link #getSystemAvailableFeatures} and
4484      * {@link #hasSystemFeature}: This device supports ethernet.
4485      */
4486     @SdkConstant(SdkConstantType.FEATURE)
4487     public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
4488 
4489     /**
4490      * Feature for {@link #getSystemAvailableFeatures} and
4491      * {@link #hasSystemFeature}: This device supports HDMI-CEC.
4492      * @hide
4493      */
4494     @TestApi
4495     @SdkConstant(SdkConstantType.FEATURE)
4496     public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
4497 
4498     /**
4499      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4500      * The device has all of the inputs necessary to be considered a compatible game controller, or
4501      * includes a compatible game controller in the box.
4502      */
4503     @SdkConstant(SdkConstantType.FEATURE)
4504     public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
4505 
4506     /**
4507      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4508      * The device has a full implementation of the android.media.midi.* APIs.
4509      */
4510     @SdkConstant(SdkConstantType.FEATURE)
4511     public static final String FEATURE_MIDI = "android.software.midi";
4512 
4513     /**
4514      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4515      * The device implements an optimized mode for virtual reality (VR) applications that handles
4516      * stereoscopic rendering of notifications, and disables most monocular system UI components
4517      * while a VR application has user focus.
4518      * Devices declaring this feature must include an application implementing a
4519      * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
4520      * {@link android.app.Activity#setVrModeEnabled}.
4521      * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead.
4522      */
4523     @Deprecated
4524     @SdkConstant(SdkConstantType.FEATURE)
4525     public static final String FEATURE_VR_MODE = "android.software.vr.mode";
4526 
4527     /**
4528      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4529      * The device implements an optimized mode for virtual reality (VR) applications that handles
4530      * stereoscopic rendering of notifications, disables most monocular system UI components
4531      * while a VR application has user focus and meets extra CDD requirements to provide a
4532      * high-quality VR experience.
4533      * Devices declaring this feature must include an application implementing a
4534      * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
4535      * {@link android.app.Activity#setVrModeEnabled}.
4536      * and must meet CDD requirements to provide a high-quality VR experience.
4537      */
4538     @SdkConstant(SdkConstantType.FEATURE)
4539     public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
4540             = "android.hardware.vr.high_performance";
4541 
4542     /**
4543      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4544      * The device supports autofill of user credentials, addresses, credit cards, etc
4545      * via integration with {@link android.service.autofill.AutofillService autofill
4546      * providers}.
4547      */
4548     @SdkConstant(SdkConstantType.FEATURE)
4549     public static final String FEATURE_AUTOFILL = "android.software.autofill";
4550 
4551     /**
4552      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4553      * The device implements headtracking suitable for a VR device.
4554      */
4555     @SdkConstant(SdkConstantType.FEATURE)
4556     public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking";
4557 
4558     /**
4559      * Feature for {@link #getSystemAvailableFeatures} and
4560      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements
4561      * the Android Keystore backed by an isolated execution environment. The version indicates
4562      * which features are implemented in the isolated execution environment:
4563      * <ul>
4564      * <li>300: Ability to include a second IMEI in the ID attestation record, see
4565      * {@link android.app.admin.DevicePolicyManager#ID_TYPE_IMEI}.
4566      * <li>200: Hardware support for Curve 25519 (including both Ed25519 signature generation and
4567      * X25519 key agreement).
4568      * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support
4569      * for app-generated attestation keys (see {@link
4570      * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}).
4571      * <li>41: Hardware enforcement of device-unlocked keys (see {@link
4572      * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}).
4573      * <li>40: Support for wrapped key import (see {@link
4574      * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link
4575      * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}),
4576      * attestation (see {@link
4577      * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}),
4578      * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure
4579      * hardware, and support for requiring user authentication before a key can be used.
4580      * </ul>
4581      * This feature version is guaranteed to be set for all devices launching with Android 12 and
4582      * may be set on devices launching with an earlier version. If the feature version is set, it
4583      * will at least have the value 40. If it's not set the device may have a version of
4584      * hardware-backed keystore but it may not support all features listed above.
4585      */
4586     @SdkConstant(SdkConstantType.FEATURE)
4587     public static final String FEATURE_HARDWARE_KEYSTORE = "android.hardware.hardware_keystore";
4588 
4589     /**
4590      * Feature for {@link #getSystemAvailableFeatures}, {@link #hasSystemFeature(String)}, and
4591      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements
4592      * the Android Keystore backed by a dedicated secure processor referred to as
4593      * <a href="https://source.android.com/security/best-practices/hardware#strongbox-keymaster">
4594      * StrongBox</a>. If this feature has a version, the version number indicates which features are
4595      * implemented in StrongBox:
4596      * <ul>
4597      * <li>300: Ability to include a second IMEI in the ID attestation record, see
4598      * {@link android.app.admin.DevicePolicyManager#ID_TYPE_IMEI}.
4599      * <li>200: No new features for StrongBox (the Android Keystore environment backed by an
4600      * isolated execution environment has gained support for Curve 25519 in this version, but
4601      * the implementation backed by a dedicated secure processor is not expected to implement it).
4602      * <li>100: Hardware support for ECDH (see {@link javax.crypto.KeyAgreement}) and support
4603      * for app-generated attestation keys (see {@link
4604      * android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias(String)}).
4605      * <li>41: Hardware enforcement of device-unlocked keys (see {@link
4606      * android.security.keystore.KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)}).
4607      * <li>40: Support for wrapped key import (see {@link
4608      * android.security.keystore.WrappedKeyEntry}), optional support for ID attestation (see {@link
4609      * android.security.keystore.KeyGenParameterSpec.Builder#setDevicePropertiesAttestationIncluded(boolean)}),
4610      * attestation (see {@link
4611      * android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])}),
4612      * AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure
4613      * hardware, and support for requiring user authentication before a key can be used.
4614      * </ul>
4615      * If a device has StrongBox, this feature version number is guaranteed to be set for all
4616      * devices launching with Android 12 and may be set on devices launching with an earlier
4617      * version. If the feature version is set, it will at least have the value 40. If it's not
4618      * set the device may have StrongBox but it may not support all features listed above.
4619      */
4620     @SdkConstant(SdkConstantType.FEATURE)
4621     public static final String FEATURE_STRONGBOX_KEYSTORE =
4622             "android.hardware.strongbox_keystore";
4623 
4624     /**
4625      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4626      * The device does not have slices implementation.
4627      * @hide
4628      */
4629     @SdkConstant(SdkConstantType.FEATURE)
4630     public static final String FEATURE_SLICES_DISABLED = "android.software.slices_disabled";
4631 
4632     /**
4633      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4634      * The device supports device-unique Keystore attestations.  Only available on devices that
4635      * also support {@link #FEATURE_STRONGBOX_KEYSTORE}, and can only be used by device owner
4636      * apps (see {@link android.app.admin.DevicePolicyManager#generateKeyPair}).
4637      * @hide
4638      */
4639     @SdkConstant(SdkConstantType.FEATURE)
4640     public static final String FEATURE_DEVICE_UNIQUE_ATTESTATION =
4641             "android.hardware.device_unique_attestation";
4642 
4643     /**
4644      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4645      * The device has a Keymaster implementation that supports Device ID attestation.
4646      *
4647      * @see DevicePolicyManager#isDeviceIdAttestationSupported
4648      * @hide
4649      */
4650     @SdkConstant(SdkConstantType.FEATURE)
4651     public static final String FEATURE_DEVICE_ID_ATTESTATION =
4652             "android.software.device_id_attestation";
4653 
4654     /**
4655      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4656      * the requisite kernel support for multinetworking-capable IPsec tunnels.
4657      *
4658      * <p>This feature implies that the device supports XFRM Interfaces (CONFIG_XFRM_INTERFACE), or
4659      * VTIs with kernel patches allowing updates of output/set mark via UPDSA.
4660      */
4661     @SdkConstant(SdkConstantType.FEATURE)
4662     public static final String FEATURE_IPSEC_TUNNELS = "android.software.ipsec_tunnels";
4663 
4664     /**
4665      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4666      * the requisite kernel support for migrating IPsec tunnels to new source/destination addresses.
4667      *
4668      * <p>This feature implies that the device supports XFRM Migration (CONFIG_XFRM_MIGRATE) and has
4669      * the kernel fixes to support cross-address-family IPsec tunnel migration
4670      */
4671     @SdkConstant(SdkConstantType.FEATURE)
4672     public static final String FEATURE_IPSEC_TUNNEL_MIGRATION =
4673             "android.software.ipsec_tunnel_migration";
4674 
4675     /**
4676      * Feature for {@link #getSystemAvailableFeatures} and
4677      * {@link #hasSystemFeature}: The device supports a system interface for the user to select
4678      * and bind device control services provided by applications.
4679      *
4680      * @see android.service.controls.ControlsProviderService
4681      */
4682     @SdkConstant(SdkConstantType.FEATURE)
4683     public static final String FEATURE_CONTROLS = "android.software.controls";
4684 
4685     /**
4686      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4687      * the requisite hardware support to support reboot escrow of synthetic password for updates.
4688      *
4689      * <p>This feature implies that the device has the RebootEscrow HAL implementation.
4690      *
4691      * @hide
4692      */
4693     @SystemApi
4694     @SdkConstant(SdkConstantType.FEATURE)
4695     public static final String FEATURE_REBOOT_ESCROW = "android.hardware.reboot_escrow";
4696 
4697     /**
4698      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4699      * the requisite kernel support to support incremental delivery aka Incremental FileSystem.
4700      *
4701      * feature not present - IncFs is not present on the device.
4702      * 1 - IncFs v1, core features, no PerUid support. Optional in R.
4703      * 2 - IncFs v2, PerUid support, fs-verity support. Required in S.
4704      *
4705      * @see IncrementalManager#isFeatureEnabled
4706      * @see IncrementalManager#getVersion()
4707      * @hide
4708      */
4709     @SystemApi
4710     @SdkConstant(SdkConstantType.FEATURE)
4711     public static final String FEATURE_INCREMENTAL_DELIVERY =
4712             "android.software.incremental_delivery";
4713 
4714     /**
4715      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4716      * has the requisite kernel support for the EROFS filesystem present in 4.19 kernels as a
4717      * staging driver, which lacks 0padding and big pcluster support.
4718      *
4719      * @hide
4720      */
4721     @SystemApi
4722     @SdkConstant(SdkConstantType.FEATURE)
4723     public static final String FEATURE_EROFS_LEGACY = "android.software.erofs_legacy";
4724 
4725     /**
4726      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4727      * has the requisite kernel support for the EROFS filesystem present in 5.10 kernels, which
4728      * has 0padding, big pcluster, and chunked index support.
4729      *
4730      * @hide
4731      */
4732     @SystemApi
4733     @SdkConstant(SdkConstantType.FEATURE)
4734     public static final String FEATURE_EROFS = "android.software.erofs";
4735 
4736     /**
4737      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
4738      * The device has tuner hardware to support tuner operations.
4739      *
4740      * <p>This feature implies that the device has the tuner HAL implementation.
4741      *
4742      * @hide
4743      */
4744     @SdkConstant(SdkConstantType.FEATURE)
4745     public static final String FEATURE_TUNER = "android.hardware.tv.tuner";
4746 
4747     /**
4748      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4749      * the necessary changes to support app enumeration.
4750      *
4751      * @hide
4752      */
4753     @SdkConstant(SdkConstantType.FEATURE)
4754     public static final String FEATURE_APP_ENUMERATION = "android.software.app_enumeration";
4755 
4756     /**
4757      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4758      * a Keystore implementation that can only enforce limited use key in hardware with max usage
4759      * count equals to 1.
4760      */
4761     @SdkConstant(SdkConstantType.FEATURE)
4762     public static final String FEATURE_KEYSTORE_SINGLE_USE_KEY =
4763             "android.hardware.keystore.single_use_key";
4764 
4765     /**
4766      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4767      * a Keystore implementation that can enforce limited use key in hardware with any max usage
4768      * count (including count equals to 1).
4769      */
4770     @SdkConstant(SdkConstantType.FEATURE)
4771     public static final String FEATURE_KEYSTORE_LIMITED_USE_KEY =
4772             "android.hardware.keystore.limited_use_key";
4773 
4774     /**
4775      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4776      * a Keystore implementation that can create application-specific attestation keys.
4777      * See {@link android.security.keystore.KeyGenParameterSpec.Builder#setAttestKeyAlias}.
4778      */
4779     @SdkConstant(SdkConstantType.FEATURE)
4780     public static final String FEATURE_KEYSTORE_APP_ATTEST_KEY =
4781             "android.hardware.keystore.app_attest_key";
4782 
4783     /**
4784      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4785      * is opted-in to receive per-app compatibility overrides that are applied in
4786      * {@link com.android.server.compat.overrides.AppCompatOverridesService}.
4787      *
4788      * @hide
4789      */
4790     @SdkConstant(SdkConstantType.FEATURE)
4791     public static final String FEATURE_APP_COMPAT_OVERRIDES =
4792             "android.software.app_compat_overrides";
4793 
4794     /**
4795      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4796      * supports communal mode,
4797      *
4798      * @hide
4799      */
4800     @SdkConstant(SdkConstantType.FEATURE)
4801     @TestApi
4802     public static final String FEATURE_COMMUNAL_MODE = "android.software.communal_mode";
4803 
4804     /**
4805      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4806      * supports dream overlay feature, which is an informational layer shown on top of dreams.
4807      *
4808      * @hide
4809      */
4810     @SdkConstant(SdkConstantType.FEATURE)
4811     public static final String FEATURE_DREAM_OVERLAY = "android.software.dream_overlay";
4812 
4813     /**
4814      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4815      * supports window magnification.
4816      *
4817      * @see android.accessibilityservice.MagnificationConfig#MAGNIFICATION_MODE_WINDOW
4818      */
4819     @SdkConstant(SdkConstantType.FEATURE)
4820     public static final String FEATURE_WINDOW_MAGNIFICATION =
4821             "android.software.window_magnification";
4822 
4823     /**
4824      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4825      * supports retrieval of user credentials, via integration with credential providers.
4826      */
4827     @SdkConstant(SdkConstantType.FEATURE)
4828     public static final String FEATURE_CREDENTIALS = "android.software.credentials";
4829 
4830     /**
4831      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4832      * supports locking (for example, by a financing provider in case of a missed payment).
4833      */
4834     @SdkConstant(SdkConstantType.FEATURE)
4835     public static final String FEATURE_DEVICE_LOCK = "android.software.device_lock";
4836 
4837     /**
4838      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
4839      * supports showing location-based suggestions for wallet cards provided by the default payment
4840      * app.
4841      */
4842     @SdkConstant(SdkConstantType.FEATURE)
4843     public static final String FEATURE_WALLET_LOCATION_BASED_SUGGESTIONS =
4844             "android.software.wallet_location_based_suggestions";
4845 
4846     /**
4847      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4848      * the rotary encoder hardware to support rotating bezel on watch.
4849      *
4850      * @hide
4851      */
4852     @SdkConstant(SdkConstantType.FEATURE)
4853     public static final String FEATURE_ROTARY_ENCODER_LOW_RES =
4854             "android.hardware.rotaryencoder.lowres";
4855 
4856   /**
4857    * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
4858    * support for contextual search helper.
4859    *
4860    * @hide
4861    */
4862   @SdkConstant(SdkConstantType.FEATURE)
4863   public static final String FEATURE_CONTEXTUAL_SEARCH_HELPER =
4864       "android.software.contextualsearch";
4865 
4866     /** @hide */
4867     public static final boolean APP_ENUMERATION_ENABLED_BY_DEFAULT = true;
4868 
4869     /**
4870      * Extra field name for the URI to a verification file. Passed to a package verifier.
4871      *
4872      * @hide
4873      */
4874     public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
4875 
4876     /**
4877      * Extra field name for the ID of a package pending verification. Passed to
4878      * a package verifier and is used to call back to
4879      * {@link PackageManager#verifyPendingInstall(int, int)}
4880      */
4881     public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
4882 
4883     /**
4884      * Extra field name for the package identifier which is trying to install
4885      * the package.
4886      *
4887      * @hide
4888      */
4889     public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
4890             = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
4891 
4892     /**
4893      * Extra field name for the requested install flags for a package pending
4894      * verification. Passed to a package verifier.
4895      *
4896      * @hide
4897      */
4898     public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
4899             = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
4900 
4901     /**
4902      * Extra field name for the uid of who is requesting to install
4903      * the package.
4904      *
4905      * @hide
4906      */
4907     public static final String EXTRA_VERIFICATION_INSTALLER_UID
4908             = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
4909 
4910     /**
4911      * Extra field name for the package name of a package pending verification.
4912      *
4913      * @hide
4914      */
4915     public static final String EXTRA_VERIFICATION_PACKAGE_NAME
4916             = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
4917 
4918     /**
4919      * Extra field name for the result of a verification, either
4920      * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
4921      * Passed to package verifiers after a package is verified.
4922      */
4923     public static final String EXTRA_VERIFICATION_RESULT
4924             = "android.content.pm.extra.VERIFICATION_RESULT";
4925 
4926     /**
4927      * Extra field name for tracking whether user action
4928      * was requested for a particular install, either {@code true} or {@code false}.
4929      * @hide
4930      */
4931     public static final String EXTRA_USER_ACTION_REQUIRED
4932             = "android.content.pm.extra.USER_ACTION_REQUIRED";
4933 
4934     /**
4935      * Extra field name for the version code of a package pending verification.
4936      * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead.
4937      * @hide
4938      */
4939     @Deprecated
4940     public static final String EXTRA_VERIFICATION_VERSION_CODE
4941             = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
4942 
4943     /**
4944      * Extra field name for the long version code of a package pending verification
4945      * @hide
4946      */
4947     public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE =
4948             "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE";
4949 
4950     /**
4951      * Extra field name for the Merkle tree root hash of a package.
4952      * <p>Passed to a package verifier both prior to verification and as a result
4953      * of verification.
4954      * <p>The value of the extra is a specially formatted list:
4955      * {@code filename1:HASH_1;filename2:HASH_2;...;filenameN:HASH_N}
4956      * <p>The extra must include an entry for every APK within an installation. If
4957      * a hash is not physically present, a hash value of {@code 0} will be used.
4958      * <p>The root hash is generated using SHA-256, no salt with a 4096 byte block
4959      * size. See the description of the
4960      * <a href="https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#merkle-tree">fs-verity merkle-tree</a>
4961      * for more details.
4962      * @hide
4963      */
4964     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4965     public static final String EXTRA_VERIFICATION_ROOT_HASH =
4966             "android.content.pm.extra.VERIFICATION_ROOT_HASH";
4967 
4968     /**
4969      * Extra field name for the ID of a intent filter pending verification.
4970      * Passed to an intent filter verifier and is used to call back to
4971      * {@link #verifyIntentFilter}
4972      *
4973      * @deprecated Use DomainVerificationManager APIs.
4974      * @hide
4975      */
4976     @Deprecated
4977     public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
4978             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
4979 
4980     /**
4981      * Extra field name for the scheme used for an intent filter pending verification. Passed to
4982      * an intent filter verifier and is used to construct the URI to verify against.
4983      *
4984      * Usually this is "https"
4985      *
4986      * @deprecated Use DomainVerificationManager APIs.
4987      * @hide
4988      */
4989     @Deprecated
4990     public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
4991             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
4992 
4993     /**
4994      * Extra field name for the host names to be used for an intent filter pending verification.
4995      * Passed to an intent filter verifier and is used to construct the URI to verify the
4996      * intent filter.
4997      *
4998      * This is a space delimited list of hosts.
4999      *
5000      * @deprecated Use DomainVerificationManager APIs.
5001      * @hide
5002      */
5003     @Deprecated
5004     public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
5005             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
5006 
5007     /**
5008      * Extra field name for the package name to be used for an intent filter pending verification.
5009      * Passed to an intent filter verifier and is used to check the verification responses coming
5010      * from the hosts. Each host response will need to include the package name of APK containing
5011      * the intent filter.
5012      *
5013      * @deprecated Use DomainVerificationManager APIs.
5014      * @hide
5015      */
5016     @Deprecated
5017     public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
5018             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
5019 
5020     /**
5021      * The action used to request that the user approve a permission request
5022      * from the application.
5023      *
5024      * @hide
5025      */
5026     @SystemApi
5027     public static final String ACTION_REQUEST_PERMISSIONS =
5028             "android.content.pm.action.REQUEST_PERMISSIONS";
5029 
5030     /**
5031      * The action used to request that the user approve a permission request
5032      * from the application. Sent from an application other than the one whose permissions
5033      * will be granted. Can only be used by the system server.
5034      *
5035      * @hide
5036      */
5037     @SystemApi
5038     public static final String ACTION_REQUEST_PERMISSIONS_FOR_OTHER =
5039             "android.content.pm.action.REQUEST_PERMISSIONS_FOR_OTHER";
5040 
5041     /**
5042      * The names of the requested permissions.
5043      * <p>
5044      * <strong>Type:</strong> String[]
5045      * </p>
5046      *
5047      * @hide
5048      */
5049     @SystemApi
5050     public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
5051             "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
5052 
5053     /**
5054      * The deviceId for which the permissions are requested, {@link Context#DEVICE_ID_DEFAULT}
5055      * is the default device ID.
5056      * <p>
5057      * <strong>Type:</strong> int
5058      * </p>
5059      *
5060      * @hide
5061      */
5062     @SystemApi
5063     @FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED)
5064     public static final String EXTRA_REQUEST_PERMISSIONS_DEVICE_ID =
5065             "android.content.pm.extra.REQUEST_PERMISSIONS_DEVICE_ID";
5066 
5067     /**
5068      * The results from the permissions request.
5069      * <p>
5070      * <strong>Type:</strong> int[] of #PermissionResult
5071      * </p>
5072      *
5073      * @hide
5074      */
5075     @SystemApi
5076     public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
5077             = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
5078 
5079     /**
5080      * Indicates that the package requesting permissions has legacy access for some permissions,
5081      * or had it, but it was recently revoked. These request dialogs may show different text,
5082      * indicating that the app is requesting continued access to a permission. Will be cleared
5083      * from any permission request intent, if set by a non-system server app.
5084      * <p>
5085      * <strong>Type:</strong> String[]
5086      * </p>
5087      *
5088      * @hide
5089      */
5090     @SystemApi
5091     public static final String EXTRA_REQUEST_PERMISSIONS_LEGACY_ACCESS_PERMISSION_NAMES
5092             = "android.content.pm.extra.REQUEST_PERMISSIONS_LEGACY_ACCESS_PERMISSION_NAMES";
5093 
5094     /**
5095      * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
5096      * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
5097      * the existing definition for the permission.
5098      * @hide
5099      */
5100     public static final String EXTRA_FAILURE_EXISTING_PACKAGE
5101             = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
5102 
5103     /**
5104      * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
5105      * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
5106      * being redundantly defined by the package being installed.
5107      * @hide
5108      */
5109     public static final String EXTRA_FAILURE_EXISTING_PERMISSION
5110             = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
5111 
5112    /**
5113     * Permission flag: The permission is set in its current state
5114     * by the user and apps can still request it at runtime.
5115     *
5116     * @hide
5117     */
5118     @SystemApi
5119     public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
5120 
5121     /**
5122      * Permission flag: The permission is set in its current state
5123      * by the user and it is fixed, i.e. apps can no longer request
5124      * this permission.
5125      *
5126      * @hide
5127      */
5128     @SystemApi
5129     public static final int FLAG_PERMISSION_USER_FIXED =  1 << 1;
5130 
5131     /**
5132      * Permission flag: The permission is set in its current state
5133      * by device policy and neither apps nor the user can change
5134      * its state.
5135      *
5136      * @hide
5137      */
5138     @SystemApi
5139     public static final int FLAG_PERMISSION_POLICY_FIXED =  1 << 2;
5140 
5141     /**
5142      * Permission flag: The permission is set in a granted state but
5143      * access to resources it guards is restricted by other means to
5144      * enable revoking a permission on legacy apps that do not support
5145      * runtime permissions. If this permission is upgraded to runtime
5146      * because the app was updated to support runtime permissions, the
5147      * the permission will be revoked in the upgrade process.
5148      *
5149      * @deprecated Renamed to {@link #FLAG_PERMISSION_REVOKED_COMPAT}.
5150      *
5151      * @hide
5152      */
5153     @Deprecated
5154     @SystemApi
5155     public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE =  1 << 3;
5156 
5157     /**
5158      * Permission flag: The permission is set in its current state
5159      * because the app is a component that is a part of the system.
5160      *
5161      * @hide
5162      */
5163     @SystemApi
5164     public static final int FLAG_PERMISSION_SYSTEM_FIXED =  1 << 4;
5165 
5166     /**
5167      * Permission flag: The permission is granted by default because it
5168      * enables app functionality that is expected to work out-of-the-box
5169      * for providing a smooth user experience. For example, the phone app
5170      * is expected to have the phone permission.
5171      *
5172      * @hide
5173      */
5174     @SystemApi
5175     public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
5176 
5177     /**
5178      * Permission flag: If app targetSDK < M, then the permission has to be reviewed before any of
5179      * the app components can run. If app targetSDK >= M, then the system might need to show a
5180      * request dialog for this permission on behalf of an app.
5181      *
5182      * @hide
5183      */
5184     @SystemApi
5185     public static final int FLAG_PERMISSION_REVIEW_REQUIRED =  1 << 6;
5186 
5187     /**
5188      * Permission flag: The permission has not been explicitly requested by
5189      * the app but has been added automatically by the system. Revoke once
5190      * the app does explicitly request it.
5191      *
5192      * @hide
5193      */
5194     @TestApi
5195     @SystemApi
5196     public static final int FLAG_PERMISSION_REVOKE_WHEN_REQUESTED =  1 << 7;
5197 
5198     /**
5199      * Permission flag: The permission's usage should be made highly visible to the user
5200      * when granted.
5201      *
5202      * @hide
5203      */
5204     @SystemApi
5205     public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED =  1 << 8;
5206 
5207     /**
5208      * Permission flag: The permission's usage should be made highly visible to the user
5209      * when denied.
5210      *
5211      * @hide
5212      */
5213     @SystemApi
5214     public static final int FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED =  1 << 9;
5215 
5216     /**
5217      * Permission flag: The permission is restricted but the app is exempt
5218      * from the restriction and is allowed to hold this permission in its
5219      * full form and the exemption is provided by the installer on record.
5220      *
5221      * @hide
5222      */
5223     @SystemApi
5224     public static final int FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT =  1 << 11;
5225 
5226     /**
5227      * Permission flag: The permission is restricted but the app is exempt
5228      * from the restriction and is allowed to hold this permission in its
5229      * full form and the exemption is provided by the system due to its
5230      * permission policy.
5231      *
5232      * @hide
5233      */
5234     @SystemApi
5235     public static final int FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT =  1 << 12;
5236 
5237     /**
5238      * Permission flag: The permission is restricted but the app is exempt
5239      * from the restriction and is allowed to hold this permission and the
5240      * exemption is provided by the system when upgrading from an OS version
5241      * where the permission was not restricted to an OS version where the
5242      * permission is restricted.
5243      *
5244      * @hide
5245      */
5246     @SystemApi
5247     public static final int FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT =  1 << 13;
5248 
5249 
5250     /**
5251      * Permission flag: The permission is disabled but may be granted. If
5252      * disabled the data protected by the permission should be protected
5253      * by a no-op (empty list, default error, etc) instead of crashing the
5254      * client.
5255      *
5256      * @hide
5257      */
5258     @SystemApi
5259     public static final int FLAG_PERMISSION_APPLY_RESTRICTION =  1 << 14;
5260 
5261     /**
5262      * Permission flag: The permission is granted because the application holds a role.
5263      *
5264      * @hide
5265      */
5266     @SystemApi
5267     public static final int FLAG_PERMISSION_GRANTED_BY_ROLE =  1 << 15;
5268 
5269     /**
5270      * Permission flag: The permission should have been revoked but is kept granted for
5271      * compatibility. The data protected by the permission should be protected by a no-op (empty
5272      * list, default error, etc) instead of crashing the client. The permission will be revoked if
5273      * the app is upgraded to supports it.
5274      *
5275      * @hide
5276      */
5277     @SystemApi
5278     public static final int FLAG_PERMISSION_REVOKED_COMPAT =  FLAG_PERMISSION_REVOKE_ON_UPGRADE;
5279 
5280     /**
5281      * Permission flag: The permission is one-time and should be revoked automatically on app
5282      * inactivity
5283      *
5284      * @hide
5285      */
5286     @SystemApi
5287     public static final int FLAG_PERMISSION_ONE_TIME = 1 << 16;
5288 
5289     /**
5290      * Permission flag: Whether permission was revoked by auto-revoke.
5291      *
5292      * @hide
5293      */
5294     @SystemApi
5295     public static final int FLAG_PERMISSION_AUTO_REVOKED = 1 << 17;
5296 
5297     /**
5298      * Permission flag: This location permission is selected as the level of granularity of
5299      * location accuracy.
5300      * Example: If this flag is set for ACCESS_FINE_LOCATION, FINE location is the selected location
5301      *          accuracy for location permissions.
5302      *
5303      * @hide
5304      */
5305     @SystemApi
5306     public static final int FLAG_PERMISSION_SELECTED_LOCATION_ACCURACY =  1 << 19;
5307 
5308     /**
5309      * Permission flags: Reserved for use by the permission controller. The platform and any
5310      * packages besides the permission controller should not assume any definition about these
5311      * flags.
5312      * @hide
5313      */
5314     @SystemApi
5315     public static final int FLAGS_PERMISSION_RESERVED_PERMISSION_CONTROLLER = 1 << 28 | 1 << 29
5316             | 1 << 30 | 1 << 31;
5317 
5318     /**
5319      * Permission flags: Bitwise or of all permission flags allowing an
5320      * exemption for a restricted permission.
5321      * @hide
5322      */
5323     public static final int FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT =
5324             FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT
5325                     | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT
5326                     | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT;
5327 
5328     /**
5329      * Mask for all permission flags.
5330      *
5331      * @hide
5332      *
5333      * @deprecated Don't use - does not capture all flags.
5334      */
5335     @Deprecated
5336     @SystemApi
5337     public static final int MASK_PERMISSION_FLAGS = 0xFF;
5338 
5339     /**
5340      * Mask for all permission flags.
5341      *
5342      * @hide
5343      */
5344     public static final int MASK_PERMISSION_FLAGS_ALL = FLAG_PERMISSION_USER_SET
5345             | FLAG_PERMISSION_USER_FIXED
5346             | FLAG_PERMISSION_POLICY_FIXED
5347             | FLAG_PERMISSION_REVOKE_ON_UPGRADE
5348             | FLAG_PERMISSION_SYSTEM_FIXED
5349             | FLAG_PERMISSION_GRANTED_BY_DEFAULT
5350             | FLAG_PERMISSION_REVIEW_REQUIRED
5351             | FLAG_PERMISSION_REVOKE_WHEN_REQUESTED
5352             | FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED
5353             | FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED
5354             | FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT
5355             | FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT
5356             | FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT
5357             | FLAG_PERMISSION_APPLY_RESTRICTION
5358             | FLAG_PERMISSION_GRANTED_BY_ROLE
5359             | FLAG_PERMISSION_REVOKED_COMPAT
5360             | FLAG_PERMISSION_ONE_TIME
5361             | FLAG_PERMISSION_AUTO_REVOKED;
5362 
5363     /**
5364      * Injected activity in app that forwards user to setting activity of that app.
5365      *
5366      * @hide
5367      */
5368     public static final String APP_DETAILS_ACTIVITY_CLASS_NAME = AppDetailsActivity.class.getName();
5369 
5370     /**
5371      * Permission whitelist flag: permissions whitelisted by the system.
5372      * Permissions can also be whitelisted by the installer, on upgrade, or on
5373      * role grant.
5374      *
5375      * <p>
5376      * <strong>Note: </strong>In retrospect it would have been preferred to use
5377      * more inclusive terminology when naming this API. Similar APIs added will
5378      * refrain from using the term "whitelist".
5379      * </p>
5380      */
5381     public static final int FLAG_PERMISSION_WHITELIST_SYSTEM = 1 << 0;
5382 
5383     /**
5384      * Permission whitelist flag: permissions whitelisted by the installer.
5385      * Permissions can also be whitelisted by the system, on upgrade, or on role
5386      * grant.
5387      *
5388      * <p>
5389      * <strong>Note: </strong>In retrospect it would have been preferred to use
5390      * more inclusive terminology when naming this API. Similar APIs added will
5391      * refrain from using the term "whitelist".
5392      * </p>
5393      */
5394     public static final int FLAG_PERMISSION_WHITELIST_INSTALLER = 1 << 1;
5395 
5396     /**
5397      * Permission whitelist flag: permissions whitelisted by the system
5398      * when upgrading from an OS version where the permission was not
5399      * restricted to an OS version where the permission is restricted.
5400      * Permissions can also be whitelisted by the installer, the system, or on
5401      * role grant.
5402      *
5403      * <p>
5404      * <strong>Note: </strong>In retrospect it would have been preferred to use
5405      * more inclusive terminology when naming this API. Similar APIs added will
5406      * refrain from using the term "whitelist".
5407      * </p>
5408      */
5409     public static final int FLAG_PERMISSION_WHITELIST_UPGRADE = 1 << 2;
5410 
5411     /** @hide */
5412     @IntDef(flag = true, prefix = {"FLAG_PERMISSION_WHITELIST_"}, value = {
5413             FLAG_PERMISSION_WHITELIST_SYSTEM,
5414             FLAG_PERMISSION_WHITELIST_INSTALLER,
5415             FLAG_PERMISSION_WHITELIST_UPGRADE
5416     })
5417     @Retention(RetentionPolicy.SOURCE)
5418     public @interface PermissionWhitelistFlags {}
5419 
5420     /**
5421      * This is a library that contains components apps can invoke. For
5422      * example, a services for apps to bind to, or standard chooser UI,
5423      * etc. This library is versioned and backwards compatible. Clients
5424      * should check its version via {@link android.ext.services.Version
5425      * #getVersionCode()} and avoid calling APIs added in later versions.
5426      * <p>
5427      * This shared library no longer exists since Android R.
5428      *
5429      * @see #getServicesSystemSharedLibraryPackageName()
5430      *
5431      * @hide
5432      */
5433     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
5434     @TestApi
5435     public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
5436 
5437     /**
5438      * This is a library that contains components apps can dynamically
5439      * load. For example, new widgets, helper classes, etc. This library
5440      * is versioned and backwards compatible. Clients should check its
5441      * version via {@link android.ext.shared.Version#getVersionCode()}
5442      * and avoid calling APIs added in later versions.
5443      *
5444      * @hide
5445      */
5446     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
5447     @TestApi
5448     public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
5449 
5450     /** @hide */
5451     @IntDef({
5452             NOTIFY_PACKAGE_USE_ACTIVITY,
5453             NOTIFY_PACKAGE_USE_SERVICE,
5454             NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE,
5455             NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER,
5456             NOTIFY_PACKAGE_USE_CONTENT_PROVIDER,
5457             NOTIFY_PACKAGE_USE_BACKUP,
5458             NOTIFY_PACKAGE_USE_CROSS_PACKAGE,
5459             NOTIFY_PACKAGE_USE_INSTRUMENTATION,
5460     })
5461     public @interface NotifyReason {
5462     }
5463 
5464     /**
5465      * Used when starting a process for an Activity.
5466      *
5467      * @hide
5468      */
5469     public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
5470 
5471     /**
5472      * Used when starting a process for a Service.
5473      *
5474      * @hide
5475      */
5476     public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
5477 
5478     /**
5479      * Used when moving a Service to the foreground.
5480      *
5481      * @hide
5482      */
5483     public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
5484 
5485     /**
5486      * Used when starting a process for a BroadcastReceiver.
5487      *
5488      * @hide
5489      */
5490     public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
5491 
5492     /**
5493      * Used when starting a process for a ContentProvider.
5494      *
5495      * @hide
5496      */
5497     public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
5498 
5499     /**
5500      * Used when starting a process for a BroadcastReceiver.
5501      *
5502      * @hide
5503      */
5504     public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
5505 
5506     /**
5507      * Used with Context.getClassLoader() across Android packages.
5508      *
5509      * @hide
5510      */
5511     public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
5512 
5513     /**
5514      * Used when starting a package within a process for Instrumentation.
5515      *
5516      * @hide
5517      */
5518     public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
5519 
5520     /**
5521      * Total number of usage reasons.
5522      *
5523      * @hide
5524      */
5525     public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
5526 
5527     /**
5528      * Constant for specifying the highest installed package version code.
5529      */
5530     public static final int VERSION_CODE_HIGHEST = -1;
5531 
5532     /**
5533      * Apps targeting Android R and above will need to declare the packages and intents they intend
5534      * to use to get details about other apps on a device. Such declarations must be made via the
5535      * {@code <queries>} tag in the manifest.
5536      *
5537      * @hide
5538      */
5539     @ChangeId
5540     @EnabledSince(targetSdkVersion = Build.VERSION_CODES.R)
5541     public static final long FILTER_APPLICATION_QUERY = 135549675L;
5542 
5543     /** {@hide} */
5544     @IntDef(prefix = {"SYSTEM_APP_STATE_"}, value = {
5545             SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN,
5546             SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE,
5547             SYSTEM_APP_STATE_INSTALLED,
5548             SYSTEM_APP_STATE_UNINSTALLED
5549     })
5550     @Retention(RetentionPolicy.SOURCE)
5551     public @interface SystemAppState {}
5552 
5553     /**
5554      * Constant for use with {@link #setSystemAppState} to mark a system app as hidden until
5555      * installation.
5556      * @hide
5557      */
5558     @SystemApi
5559     public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN = 0;
5560 
5561     /**
5562      * Constant for use with {@link #setSystemAppState} to mark a system app as not hidden until
5563      * installation.
5564      * @hide
5565      */
5566     @SystemApi
5567     public static final int SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE = 1;
5568 
5569     /**
5570      * Constant for use with {@link #setSystemAppState} to change a system app's state to installed.
5571      * @hide
5572      */
5573     @SystemApi
5574     public static final int SYSTEM_APP_STATE_INSTALLED = 2;
5575 
5576     /**
5577      * Constant for use with {@link #setSystemAppState} to change a system app's state to
5578      * uninstalled.
5579      * @hide
5580      */
5581     @SystemApi
5582     public static final int SYSTEM_APP_STATE_UNINSTALLED = 3;
5583 
5584     /**
5585      * A manifest property to control app's participation in {@code adb backup}. Should only
5586      * be used by system / privileged apps.
5587      *
5588      * @hide
5589      */
5590     public static final String PROPERTY_ALLOW_ADB_BACKUP = "android.backup.ALLOW_ADB_BACKUP";
5591 
5592     /**
5593      * Flags class that wraps around the bitmask flags used in methods that retrieve package or
5594      * application info.
5595      * @hide
5596      */
5597     @android.ravenwood.annotation.RavenwoodKeepWholeClass
5598     public static class Flags {
5599         final long mValue;
Flags(long value)5600         protected Flags(long value) {
5601             mValue = value;
5602         }
getValue()5603         public long getValue() {
5604             return mValue;
5605         }
5606     }
5607 
5608     /**
5609      * Specific flags used for retrieving package info. Example:
5610      * {@code PackageManager.getPackageInfo(packageName, PackageInfoFlags.of(0)}
5611      */
5612     @android.ravenwood.annotation.RavenwoodKeepWholeClass
5613     public final static class PackageInfoFlags extends Flags {
PackageInfoFlags(@ackageInfoFlagsBits long value)5614         private PackageInfoFlags(@PackageInfoFlagsBits long value) {
5615             super(value);
5616         }
5617         @NonNull
of(@ackageInfoFlagsBits long value)5618         public static PackageInfoFlags of(@PackageInfoFlagsBits long value) {
5619             return new PackageInfoFlags(value);
5620         }
5621     }
5622 
5623     /**
5624      * Specific flags used for retrieving application info.
5625      */
5626     @android.ravenwood.annotation.RavenwoodKeepWholeClass
5627     public final static class ApplicationInfoFlags extends Flags {
ApplicationInfoFlags(@pplicationInfoFlagsBits long value)5628         private ApplicationInfoFlags(@ApplicationInfoFlagsBits long value) {
5629             super(value);
5630         }
5631         @NonNull
of(@pplicationInfoFlagsBits long value)5632         public static ApplicationInfoFlags of(@ApplicationInfoFlagsBits long value) {
5633             return new ApplicationInfoFlags(value);
5634         }
5635     }
5636 
5637     /**
5638      * Specific flags used for retrieving component info.
5639      */
5640     @android.ravenwood.annotation.RavenwoodKeepWholeClass
5641     public final static class ComponentInfoFlags extends Flags {
ComponentInfoFlags(@omponentInfoFlagsBits long value)5642         private ComponentInfoFlags(@ComponentInfoFlagsBits long value) {
5643             super(value);
5644         }
5645         @NonNull
of(@omponentInfoFlagsBits long value)5646         public static ComponentInfoFlags of(@ComponentInfoFlagsBits long value) {
5647             return new ComponentInfoFlags(value);
5648         }
5649     }
5650 
5651     /**
5652      * Specific flags used for retrieving resolve info.
5653      */
5654     @android.ravenwood.annotation.RavenwoodKeepWholeClass
5655     public final static class ResolveInfoFlags extends Flags {
ResolveInfoFlags(@esolveInfoFlagsBits long value)5656         private ResolveInfoFlags(@ResolveInfoFlagsBits long value) {
5657             super(value);
5658         }
5659         @NonNull
of(@esolveInfoFlagsBits long value)5660         public static ResolveInfoFlags of(@ResolveInfoFlagsBits long value) {
5661             return new ResolveInfoFlags(value);
5662         }
5663     }
5664 
5665     /** {@hide} */
getUserId()5666     public int getUserId() {
5667         return UserHandle.myUserId();
5668     }
5669 
5670     /**
5671      * @deprecated Do not instantiate or subclass - obtain an instance from
5672      * {@link Context#getPackageManager}
5673      */
5674     @Deprecated
PackageManager()5675     public PackageManager() {}
5676 
5677     /**
5678      * Retrieve overall information about an application package that is
5679      * installed on the system.
5680      *
5681      * Use {@link #getPackageInfo(String, PackageInfoFlags)} when long flags are needed.
5682      *
5683      * @param packageName The full name (i.e. com.google.apps.contacts) of the
5684      *            desired package.
5685      * @param flags Additional option flags to modify the data returned.
5686      * @return A PackageInfo object containing information about the package. If
5687      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
5688      *         is not found in the list of installed applications, the package
5689      *         information is retrieved from the list of uninstalled
5690      *         applications (which includes installed applications as well as
5691      *         applications with data directory i.e. applications which had been
5692      *         deleted with {@code DELETE_KEEP_DATA} flag set).
5693      * @throws NameNotFoundException if no such package is available to the
5694      *             caller.
5695      */
getPackageInfo(@onNull String packageName, int flags)5696     public abstract PackageInfo getPackageInfo(@NonNull String packageName, int flags)
5697             throws NameNotFoundException;
5698 
5699     /**
5700      * See {@link #getPackageInfo(String, int)}
5701      */
5702     @NonNull
getPackageInfo(@onNull String packageName, @NonNull PackageInfoFlags flags)5703     public PackageInfo getPackageInfo(@NonNull String packageName, @NonNull PackageInfoFlags flags)
5704             throws NameNotFoundException {
5705         throw new UnsupportedOperationException(
5706                 "getPackageInfo not implemented in subclass");
5707     }
5708 
5709     /**
5710      * Retrieve overall information about an application package that is
5711      * installed on the system. This method can be used for retrieving
5712      * information about packages for which multiple versions can be installed
5713      * at the time. Currently only packages hosting static shared libraries can
5714      * have multiple installed versions. The method can also be used to get info
5715      * for a package that has a single version installed by passing
5716      * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage}
5717      * constructor.
5718      *
5719      * Use {@link #getPackageInfo(VersionedPackage, PackageInfoFlags)} when long flags are needed.
5720      *
5721      * @param versionedPackage The versioned package for which to query.
5722      * @param flags Additional option flags to modify the data returned.
5723      * @return A PackageInfo object containing information about the package. If
5724      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
5725      *         is not found in the list of installed applications, the package
5726      *         information is retrieved from the list of uninstalled
5727      *         applications (which includes installed applications as well as
5728      *         applications with data directory i.e. applications which had been
5729      *         deleted with {@code DELETE_KEEP_DATA} flag set).
5730      * @throws NameNotFoundException if no such package is available to the
5731      *             caller.
5732      */
getPackageInfo(@onNull VersionedPackage versionedPackage, int flags)5733     public abstract PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage,
5734             int flags) throws NameNotFoundException;
5735 
5736     /**
5737      * See {@link #getPackageInfo(VersionedPackage, int)}
5738      */
5739     @NonNull
getPackageInfo(@onNull VersionedPackage versionedPackage, @NonNull PackageInfoFlags flags)5740     public PackageInfo getPackageInfo(@NonNull VersionedPackage versionedPackage,
5741             @NonNull PackageInfoFlags flags) throws NameNotFoundException {
5742         throw new UnsupportedOperationException(
5743                 "getPackageInfo not implemented in subclass");
5744     }
5745 
5746     /**
5747      * Retrieve overall information about an application package that is
5748      * installed on the system.
5749      *
5750      * Use {@link #getPackageInfoAsUser(String, PackageInfoFlags, int)} when long flags are needed.
5751      *
5752      * @param packageName The full name (i.e. com.google.apps.contacts) of the
5753      *            desired package.
5754      * @param flags Additional option flags to modify the data returned.
5755      * @param userId The user id.
5756      * @return A PackageInfo object containing information about the package. If
5757      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
5758      *         is not found in the list of installed applications, the package
5759      *         information is retrieved from the list of uninstalled
5760      *         applications (which includes installed applications as well as
5761      *         applications with data directory i.e. applications which had been
5762      *         deleted with {@code DELETE_KEEP_DATA} flag set).
5763      * @throws NameNotFoundException if no such package is available to the
5764      *             caller.
5765      * @hide
5766      */
5767     @SuppressWarnings("HiddenAbstractMethod")
5768     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
5769     @UnsupportedAppUsage
getPackageInfoAsUser(@onNull String packageName, int flags, @UserIdInt int userId)5770     public abstract PackageInfo getPackageInfoAsUser(@NonNull String packageName,
5771             int flags, @UserIdInt int userId) throws NameNotFoundException;
5772 
5773     /**
5774      * See {@link #getPackageInfoAsUser(String, int, int)}
5775      * @hide
5776      */
5777     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
5778     @NonNull
getPackageInfoAsUser(@onNull String packageName, @NonNull PackageInfoFlags flags, @UserIdInt int userId)5779     public PackageInfo getPackageInfoAsUser(@NonNull String packageName,
5780             @NonNull PackageInfoFlags flags, @UserIdInt int userId) throws NameNotFoundException {
5781         throw new UnsupportedOperationException(
5782                 "getPackageInfoAsUser not implemented in subclass");
5783     }
5784 
5785     /**
5786      * Map from the current package names in use on the device to whatever
5787      * the current canonical name of that package is.
5788      * @param packageNames Array of current names to be mapped.
5789      * @return Returns an array of the same size as the original, containing
5790      * the canonical name for each package.
5791      */
currentToCanonicalPackageNames(@onNull String[] packageNames)5792     public abstract String[] currentToCanonicalPackageNames(@NonNull String[] packageNames);
5793 
5794     /**
5795      * Map from a packages canonical name to the current name in use on the device.
5796      * @param packageNames Array of new names to be mapped.
5797      * @return Returns an array of the same size as the original, containing
5798      * the current name for each package.
5799      */
canonicalToCurrentPackageNames(@onNull String[] packageNames)5800     public abstract String[] canonicalToCurrentPackageNames(@NonNull String[] packageNames);
5801 
5802     /**
5803      * Returns a "good" intent to launch a front-door activity in a package.
5804      * This is used, for example, to implement an "open" button when browsing
5805      * through packages.  The current implementation looks first for a main
5806      * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
5807      * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
5808      * <code>null</code> if neither are found.
5809      *
5810      * <p>Consider using {@link #getLaunchIntentSenderForPackage(String)} if
5811      * the caller is not allowed to query for the <code>packageName</code>.
5812      *
5813      * @param packageName The name of the package to inspect.
5814      *
5815      * @return A fully-qualified {@link Intent} that can be used to launch the
5816      * main activity in the package. Returns <code>null</code> if the package
5817      * does not contain such an activity, or if <em>packageName</em> is not
5818      * recognized.
5819      *
5820      * @see #getLaunchIntentSenderForPackage(String)
5821      */
getLaunchIntentForPackage(@onNull String packageName)5822     public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName);
5823 
5824     /**
5825      * Return a "good" intent to launch a front-door Leanback activity in a
5826      * package, for use for example to implement an "open" button when browsing
5827      * through packages. The current implementation will look for a main
5828      * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
5829      * return null if no main leanback activities are found.
5830      *
5831      * @param packageName The name of the package to inspect.
5832      * @return Returns either a fully-qualified Intent that can be used to launch
5833      *         the main Leanback activity in the package, or null if the package
5834      *         does not contain such an activity.
5835      */
getLeanbackLaunchIntentForPackage(@onNull String packageName)5836     public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName);
5837 
5838     /**
5839      * Return a "good" intent to launch a front-door Car activity in a
5840      * package, for use for example to implement an "open" button when browsing
5841      * through packages. The current implementation will look for a main
5842      * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or
5843      * return null if no main car activities are found.
5844      *
5845      * @param packageName The name of the package to inspect.
5846      * @return Returns either a fully-qualified Intent that can be used to launch
5847      *         the main Car activity in the package, or null if the package
5848      *         does not contain such an activity.
5849      * @hide
5850      */
5851     @SuppressWarnings("HiddenAbstractMethod")
getCarLaunchIntentForPackage(@onNull String packageName)5852     public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName);
5853 
5854     /**
5855      * Returns an {@link IntentSender} that can be used to launch a front-door activity in a
5856      * package. This is used, for example, to implement an "open" button when browsing through
5857      * packages. The current implementation is the same with
5858      * {@link #getLaunchIntentForPackage(String)}. Instead of returning the {@link Intent}, it
5859      * returns the {@link IntentSender} which is not restricted by the package visibility.
5860      *
5861      * <p>The caller can invoke
5862      * {@link IntentSender#sendIntent(Context, int, Intent, IntentSender.OnFinished, Handler)}
5863      * to launch the activity. An {@link IntentSender.SendIntentException} is thrown if the
5864      * package does not contain such an activity, or if <em>packageName</em> is not recognized.
5865      *
5866      * @param packageName The name of the package to inspect.
5867      * @return Returns a {@link IntentSender} to launch the activity.
5868      *
5869      * @see #getLaunchIntentForPackage(String)
5870      */
getLaunchIntentSenderForPackage(@onNull String packageName)5871     public @NonNull IntentSender getLaunchIntentSenderForPackage(@NonNull String packageName) {
5872         throw new UnsupportedOperationException("getLaunchIntentSenderForPackage not implemented"
5873                 + "in subclass");
5874     }
5875 
5876     /**
5877      * Return an array of all of the POSIX secondary group IDs that have been
5878      * assigned to the given package.
5879      * <p>
5880      * Note that the same package may have different GIDs under different
5881      * {@link UserHandle} on the same device.
5882      *
5883      * @param packageName The full name (i.e. com.google.apps.contacts) of the
5884      *            desired package.
5885      * @return Returns an int array of the assigned GIDs, or null if there are
5886      *         none.
5887      * @throws NameNotFoundException if no such package is available to the
5888      *             caller.
5889      */
getPackageGids(@onNull String packageName)5890     public abstract int[] getPackageGids(@NonNull String packageName)
5891             throws NameNotFoundException;
5892 
5893     /**
5894      * Return an array of all of the POSIX secondary group IDs that have been
5895      * assigned to the given package.
5896      * <p>
5897      * Note that the same package may have different GIDs under different
5898      * {@link UserHandle} on the same device.
5899      *
5900      * Use {@link #getPackageGids(String, PackageInfoFlags)} when long flags are needed.
5901      *
5902      * @param packageName The full name (i.e. com.google.apps.contacts) of the
5903      *            desired package.
5904      * @return Returns an int array of the assigned gids, or null if there are
5905      *         none.
5906      * @throws NameNotFoundException if no such package is available to the
5907      *             caller.
5908      */
5909 
getPackageGids(@onNull String packageName, int flags)5910     public abstract int[] getPackageGids(@NonNull String packageName, int flags)
5911             throws NameNotFoundException;
5912 
5913     /**
5914      * See {@link #getPackageGids(String, int)}.
5915      */
5916     @Nullable
getPackageGids(@onNull String packageName, @NonNull PackageInfoFlags flags)5917     public int[] getPackageGids(@NonNull String packageName, @NonNull PackageInfoFlags flags)
5918             throws NameNotFoundException {
5919         throw new UnsupportedOperationException(
5920                 "getPackageGids not implemented in subclass");
5921     }
5922 
5923     /**
5924      * Return the UID associated with the given package name.
5925      * <p>
5926      * Note that the same package will have different UIDs under different
5927      * {@link UserHandle} on the same device.
5928      *
5929      * Use {@link #getPackageUid(String, PackageInfoFlags)} when long flags are needed.
5930      *
5931      * @param packageName The full name (i.e. com.google.apps.contacts) of the
5932      *            desired package.
5933      * @return Returns an integer UID who owns the given package name.
5934      * @throws NameNotFoundException if no such package is available to the
5935      *             caller.
5936      */
getPackageUid(@onNull String packageName, int flags)5937     public abstract int getPackageUid(@NonNull String packageName, int flags)
5938             throws NameNotFoundException;
5939 
5940     /**
5941      * See {@link #getPackageUid(String, int)}.
5942      */
getPackageUid(@onNull String packageName, @NonNull PackageInfoFlags flags)5943     public int getPackageUid(@NonNull String packageName, @NonNull PackageInfoFlags flags)
5944             throws NameNotFoundException {
5945         throw new UnsupportedOperationException(
5946                 "getPackageUid not implemented in subclass");
5947     }
5948 
5949     /**
5950      * Return the UID associated with the given package name.
5951      * <p>
5952      * Note that the same package will have different UIDs under different
5953      * {@link UserHandle} on the same device.
5954      *
5955      * @param packageName The full name (i.e. com.google.apps.contacts) of the
5956      *            desired package.
5957      * @param userId The user handle identifier to look up the package under.
5958      * @return Returns an integer UID who owns the given package name.
5959      * @throws NameNotFoundException if no such package is available to the
5960      *             caller.
5961      * @hide
5962      */
5963     @SuppressWarnings("HiddenAbstractMethod")
5964     @UnsupportedAppUsage
getPackageUidAsUser(@onNull String packageName, @UserIdInt int userId)5965     public abstract int getPackageUidAsUser(@NonNull String packageName, @UserIdInt int userId)
5966             throws NameNotFoundException;
5967 
5968     /**
5969      * See {@link #getPackageUidAsUser(String, PackageInfoFlags, int)}.
5970      * Use {@link #getPackageUidAsUser(String, PackageInfoFlags, int)} when long flags are needed.
5971      * @hide
5972      */
5973     @SuppressWarnings("HiddenAbstractMethod")
5974     @UnsupportedAppUsage
getPackageUidAsUser(@onNull String packageName, int flags, @UserIdInt int userId)5975     public abstract int getPackageUidAsUser(@NonNull String packageName,
5976             int flags, @UserIdInt int userId) throws NameNotFoundException;
5977 
5978     /**
5979      * Return the UID associated with the given package name.
5980      * <p>
5981      * Note that the same package will have different UIDs under different
5982      * {@link UserHandle} on the same device.
5983      *
5984      * @param packageName The full name (i.e. com.google.apps.contacts) of the
5985      *            desired package.
5986      * @param flags Additional option flags to modify the data returned.
5987      * @param userId The user handle identifier to look up the package under.
5988      * @return Returns an integer UID who owns the given package name.
5989      * @throws NameNotFoundException if no such package is available to the
5990      *             caller.
5991      * @hide
5992      */
5993     @SystemApi
5994     @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
getPackageUidAsUser(@onNull String packageName, @NonNull PackageInfoFlags flags, @UserIdInt int userId)5995     public int getPackageUidAsUser(@NonNull String packageName, @NonNull PackageInfoFlags flags,
5996             @UserIdInt int userId) throws NameNotFoundException {
5997         throw new UnsupportedOperationException(
5998                 "getPackageUidAsUser not implemented in subclass");
5999     }
6000 
6001     /**
6002      * Retrieve all of the information we know about a particular permission.
6003      *
6004      * @param permName The fully qualified name (i.e. com.google.permission.LOGIN)
6005      *            of the permission you are interested in.
6006      * @param flags Additional option flags to modify the data returned.
6007      * @return Returns a {@link PermissionInfo} containing information about the
6008      *         permission.
6009      * @throws NameNotFoundException if a package with the given name cannot be
6010      *             found on the system.
6011      */
6012     //@Deprecated
getPermissionInfo(@onNull String permName, @PermissionInfoFlags int flags)6013     public abstract PermissionInfo getPermissionInfo(@NonNull String permName,
6014             @PermissionInfoFlags int flags) throws NameNotFoundException;
6015 
6016     /**
6017      * Query for all of the permissions associated with a particular group.
6018      *
6019      * @param permissionGroup The fully qualified name (i.e. com.google.permission.LOGIN)
6020      *            of the permission group you are interested in. Use {@code null} to
6021      *            find all of the permissions not associated with a group.
6022      * @param flags Additional option flags to modify the data returned.
6023      * @return Returns a list of {@link PermissionInfo} containing information
6024      *         about all of the permissions in the given group.
6025      * @throws NameNotFoundException if a group with the given name cannot be
6026      *             found on the system.
6027      */
6028     //@Deprecated
6029     @NonNull
queryPermissionsByGroup(@ullable String permissionGroup, @PermissionInfoFlags int flags)6030     public abstract List<PermissionInfo> queryPermissionsByGroup(@Nullable String permissionGroup,
6031             @PermissionInfoFlags int flags) throws NameNotFoundException;
6032 
6033     /**
6034      * Returns true if some permissions are individually controlled.
6035      *
6036      * <p>The user usually grants and revokes permission-groups. If this option is set some
6037      * dangerous system permissions can be revoked/granted by the user separately from their group.
6038      *
6039      * @hide
6040      */
6041     @SuppressWarnings("HiddenAbstractMethod")
6042     @SystemApi
arePermissionsIndividuallyControlled()6043     public abstract boolean arePermissionsIndividuallyControlled();
6044 
6045     /**
6046      * Returns true if wireless consent mode is enabled
6047      *
6048      * @hide
6049      */
6050     @SuppressWarnings("HiddenAbstractMethod")
isWirelessConsentModeEnabled()6051     public abstract boolean isWirelessConsentModeEnabled();
6052 
6053     /**
6054      * Retrieve all of the information we know about a particular group of
6055      * permissions.
6056      *
6057      * @param groupName The fully qualified name (i.e.
6058      *            com.google.permission_group.APPS) of the permission you are
6059      *            interested in.
6060      * @param flags Additional option flags to modify the data returned.
6061      * @return Returns a {@link PermissionGroupInfo} containing information
6062      *         about the permission.
6063      * @throws NameNotFoundException if a package with the given name cannot be
6064      *             found on the system.
6065      */
6066     //@Deprecated
6067     @NonNull
getPermissionGroupInfo(@onNull String groupName, @PermissionGroupInfoFlags int flags)6068     public abstract PermissionGroupInfo getPermissionGroupInfo(@NonNull String groupName,
6069             @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
6070 
6071     /**
6072      * Retrieve all of the known permission groups in the system.
6073      *
6074      * @param flags Additional option flags to modify the data returned.
6075      * @return Returns a list of {@link PermissionGroupInfo} containing
6076      *         information about all of the known permission groups.
6077      */
6078     //@Deprecated
6079     @NonNull
getAllPermissionGroups( @ermissionGroupInfoFlags int flags)6080     public abstract List<PermissionGroupInfo> getAllPermissionGroups(
6081             @PermissionGroupInfoFlags int flags);
6082 
6083     /**
6084      * Get the platform-defined permissions which belong to a particular permission group.
6085      *
6086      * @param permissionGroupName the permission group whose permissions are desired
6087      * @param executor the {@link Executor} on which to invoke the callback
6088      * @param callback the callback which will receive a list of the platform-defined permissions in
6089      *                 the group, or empty if the group is not a valid platform-defined permission
6090      *                 group, or there was an exception
6091      */
getPlatformPermissionsForGroup(@onNull String permissionGroupName, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<List<String>> callback)6092     public void getPlatformPermissionsForGroup(@NonNull String permissionGroupName,
6093             @NonNull @CallbackExecutor Executor executor,
6094             @NonNull Consumer<List<String>> callback) {}
6095 
6096     /**
6097      * Get the platform-defined permission group of a particular permission, if the permission is a
6098      * platform-defined permission.
6099      *
6100      * @param permissionName the permission whose group is desired
6101      * @param executor the {@link Executor} on which to invoke the callback
6102      * @param callback the callback which will receive the name of the permission group this
6103      *                 permission belongs to, or {@code null} if it has no group, is not a
6104      *                 platform-defined permission, or there was an exception
6105      */
getGroupOfPlatformPermission(@onNull String permissionName, @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback)6106     public void getGroupOfPlatformPermission(@NonNull String permissionName,
6107             @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback) {}
6108 
6109     /**
6110      * Retrieve all of the information we know about a particular
6111      * package/application.
6112      *
6113      * Use {@link #getApplicationInfo(String, ApplicationInfoFlags)} when long flags are needed.
6114      *
6115      * @param packageName The full name (i.e. com.google.apps.contacts) of an
6116      *            application.
6117      * @param flags Additional option flags to modify the data returned.
6118      * @return An {@link ApplicationInfo} containing information about the
6119      *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if
6120      *         the package is not found in the list of installed applications,
6121      *         the application information is retrieved from the list of
6122      *         uninstalled applications (which includes installed applications
6123      *         as well as applications with data directory i.e. applications
6124      *         which had been deleted with {@code DELETE_KEEP_DATA} flag set).
6125      * @throws NameNotFoundException if a package with the given name cannot be
6126      *             found on the system.
6127      */
6128     @NonNull
getApplicationInfo(@onNull String packageName, int flags)6129     public abstract ApplicationInfo getApplicationInfo(@NonNull String packageName,
6130             int flags) throws NameNotFoundException;
6131 
6132     /**
6133      * See {@link #getApplicationInfo(String, int)}.
6134      */
6135     @NonNull
getApplicationInfo(@onNull String packageName, @NonNull ApplicationInfoFlags flags)6136     public ApplicationInfo getApplicationInfo(@NonNull String packageName,
6137             @NonNull ApplicationInfoFlags flags) throws NameNotFoundException {
6138         throw new UnsupportedOperationException(
6139                 "getApplicationInfo not implemented in subclass");
6140     }
6141 
6142     /**
6143      * Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, int)} when long flags are
6144      * needed.
6145      * {@hide}
6146      */
6147     @SuppressWarnings("HiddenAbstractMethod")
6148     @NonNull
6149     @UnsupportedAppUsage
getApplicationInfoAsUser(@onNull String packageName, int flags, @UserIdInt int userId)6150     public abstract ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName,
6151             int flags, @UserIdInt int userId) throws NameNotFoundException;
6152 
6153     /** {@hide} */
6154     @NonNull
getApplicationInfoAsUser(@onNull String packageName, @NonNull ApplicationInfoFlags flags, @UserIdInt int userId)6155     public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName,
6156             @NonNull ApplicationInfoFlags flags, @UserIdInt int userId)
6157             throws NameNotFoundException {
6158         throw new UnsupportedOperationException(
6159                 "getApplicationInfoAsUser not implemented in subclass");
6160     }
6161 
6162     /**
6163      * Retrieve all of the information we know about a particular
6164      * package/application, for a specific user.
6165      *
6166      * Use {@link #getApplicationInfoAsUser(String, ApplicationInfoFlags, UserHandle)} when long
6167      * flags are needed.
6168      *
6169      * @param packageName The full name (i.e. com.google.apps.contacts) of an
6170      *            application.
6171      * @param flags Additional option flags to modify the data returned.
6172      * @return An {@link ApplicationInfo} containing information about the
6173      *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if
6174      *         the package is not found in the list of installed applications,
6175      *         the application information is retrieved from the list of
6176      *         uninstalled applications (which includes installed applications
6177      *         as well as applications with data directory i.e. applications
6178      *         which had been deleted with {@code DELETE_KEEP_DATA} flag set).
6179      * @throws NameNotFoundException if a package with the given name cannot be
6180      *             found on the system.
6181      * @hide
6182      */
6183     @NonNull
6184     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
6185     @SystemApi
getApplicationInfoAsUser(@onNull String packageName, int flags, @NonNull UserHandle user)6186     public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName,
6187             int flags, @NonNull UserHandle user)
6188             throws NameNotFoundException {
6189         return getApplicationInfoAsUser(packageName, flags, user.getIdentifier());
6190     }
6191 
6192     /**
6193      * See {@link #getApplicationInfoAsUser(String, int, UserHandle)}.
6194      * @hide
6195      */
6196     @NonNull
6197     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
6198     @SystemApi
getApplicationInfoAsUser(@onNull String packageName, @NonNull ApplicationInfoFlags flags, @NonNull UserHandle user)6199     public ApplicationInfo getApplicationInfoAsUser(@NonNull String packageName,
6200             @NonNull ApplicationInfoFlags flags, @NonNull UserHandle user)
6201             throws NameNotFoundException {
6202         return getApplicationInfoAsUser(packageName, flags, user.getIdentifier());
6203     }
6204 
6205     /**
6206      * @return The target SDK version for the given package name.
6207      * @throws NameNotFoundException if a package with the given name cannot be found on the system.
6208      */
6209     @IntRange(from = 0)
getTargetSdkVersion(@onNull String packageName)6210     public int getTargetSdkVersion(@NonNull String packageName) throws NameNotFoundException {
6211         throw new UnsupportedOperationException();
6212     }
6213 
6214     /**
6215      * Retrieve all of the information we know about a particular activity
6216      * class.
6217      *
6218      * Use {@link #getActivityInfo(ComponentName, ComponentInfoFlags)} when long flags are needed.
6219      *
6220      * @param component The full component name (i.e.
6221      *            com.google.apps.contacts/com.google.apps.contacts.
6222      *            ContactsList) of an Activity class.
6223      * @param flags Additional option flags to modify the data returned.
6224      * @return An {@link ActivityInfo} containing information about the
6225      *         activity.
6226      * @throws NameNotFoundException if a package with the given name cannot be
6227      *             found on the system.
6228      */
6229     @NonNull
getActivityInfo(@onNull ComponentName component, int flags)6230     public abstract ActivityInfo getActivityInfo(@NonNull ComponentName component,
6231             int flags) throws NameNotFoundException;
6232 
6233     /**
6234      * See {@link #getActivityInfo(ComponentName, int)}.
6235      */
6236     @NonNull
getActivityInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)6237     public ActivityInfo getActivityInfo(@NonNull ComponentName component,
6238             @NonNull ComponentInfoFlags flags) throws NameNotFoundException {
6239         throw new UnsupportedOperationException(
6240                 "getActivityInfo not implemented in subclass");
6241     }
6242 
6243     /**
6244      * Retrieve all of the information we know about a particular receiver
6245      * class.
6246      *
6247      * Use {@link #getReceiverInfo(ComponentName, ComponentInfoFlags)} when long flags are needed.
6248      *
6249      * @param component The full component name (i.e.
6250      *            com.google.apps.calendar/com.google.apps.calendar.
6251      *            CalendarAlarm) of a Receiver class.
6252      * @param flags Additional option flags to modify the data returned.
6253      * @return An {@link ActivityInfo} containing information about the
6254      *         receiver.
6255      * @throws NameNotFoundException if a package with the given name cannot be
6256      *             found on the system.
6257      */
6258     @NonNull
getReceiverInfo(@onNull ComponentName component, int flags)6259     public abstract ActivityInfo getReceiverInfo(@NonNull ComponentName component,
6260             int flags) throws NameNotFoundException;
6261 
6262     /**
6263      * See {@link #getReceiverInfo(ComponentName, int)}.
6264      */
6265     @NonNull
getReceiverInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)6266     public ActivityInfo getReceiverInfo(@NonNull ComponentName component,
6267             @NonNull ComponentInfoFlags flags) throws NameNotFoundException {
6268         throw new UnsupportedOperationException(
6269                 "getReceiverInfo not implemented in subclass");
6270     }
6271 
6272     /**
6273      * Retrieve all of the information we know about a particular service class.
6274      *
6275      * Use {@link #getServiceInfo(ComponentName, ComponentInfoFlags)} when long flags are needed.
6276      *
6277      * @param component The full component name (i.e.
6278      *            com.google.apps.media/com.google.apps.media.
6279      *            BackgroundPlayback) of a Service class.
6280      * @param flags Additional option flags to modify the data returned.
6281      * @return A {@link ServiceInfo} object containing information about the
6282      *         service.
6283      * @throws NameNotFoundException if the component cannot be found on the system.
6284      */
6285     @NonNull
getServiceInfo(@onNull ComponentName component, int flags)6286     public abstract ServiceInfo getServiceInfo(@NonNull ComponentName component,
6287             int flags) throws NameNotFoundException;
6288 
6289     /**
6290      * See {@link #getServiceInfo(ComponentName, int)}.
6291      */
6292     @NonNull
getServiceInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)6293     public ServiceInfo getServiceInfo(@NonNull ComponentName component,
6294             @NonNull ComponentInfoFlags flags) throws NameNotFoundException {
6295         throw new UnsupportedOperationException(
6296                 "getServiceInfo not implemented in subclass");
6297     }
6298 
6299     /**
6300      * Retrieve all of the information we know about a particular content
6301      * provider class.
6302      *
6303      * Use {@link #getProviderInfo(ComponentName, ComponentInfoFlags)} when long flags are needed.
6304      *
6305      * @param component The full component name (i.e.
6306      *            com.google.providers.media/com.google.providers.media.
6307      *            MediaProvider) of a ContentProvider class.
6308      * @param flags Additional option flags to modify the data returned.
6309      * @return A {@link ProviderInfo} object containing information about the
6310      *         provider.
6311      * @throws NameNotFoundException if a package with the given name cannot be
6312      *             found on the system.
6313      */
6314     @NonNull
getProviderInfo(@onNull ComponentName component, int flags)6315     public abstract ProviderInfo getProviderInfo(@NonNull ComponentName component,
6316             int flags) throws NameNotFoundException;
6317 
6318     /**
6319      * See {@link #getProviderInfo(ComponentName, int)}.
6320      */
6321     @NonNull
getProviderInfo(@onNull ComponentName component, @NonNull ComponentInfoFlags flags)6322     public ProviderInfo getProviderInfo(@NonNull ComponentName component,
6323             @NonNull ComponentInfoFlags flags) throws NameNotFoundException {
6324         throw new UnsupportedOperationException(
6325                 "getProviderInfo not implemented in subclass");
6326     }
6327 
6328     /**
6329      * Retrieve information for a particular module.
6330      *
6331      * @param packageName The name of the module.
6332      * @param flags Additional option flags to modify the data returned.
6333      * @return A {@link ModuleInfo} object containing information about the
6334      *         module.
6335      * @throws NameNotFoundException if a module with the given name cannot be
6336      *             found on the system.
6337      */
6338     @NonNull
getModuleInfo(@onNull String packageName, @ModuleInfoFlags int flags)6339     public ModuleInfo getModuleInfo(@NonNull String packageName, @ModuleInfoFlags int flags)
6340             throws NameNotFoundException {
6341         throw new UnsupportedOperationException(
6342                 "getModuleInfo not implemented in subclass");
6343     }
6344 
6345     /**
6346      * Return a List of all modules that are installed.
6347      *
6348      * @param flags Additional option flags to modify the data returned.
6349      * @return A {@link List} of {@link ModuleInfo} objects, one for each installed
6350      *         module, containing information about the module. In the unlikely case
6351      *         there are no installed modules, an empty list is returned.
6352      */
6353     @NonNull
getInstalledModules(@nstalledModulesFlags int flags)6354     public List<ModuleInfo> getInstalledModules(@InstalledModulesFlags int flags) {
6355         throw new UnsupportedOperationException(
6356                 "getInstalledModules not implemented in subclass");
6357     }
6358 
6359     /**
6360      * Return a List of all packages that are installed for the current user.
6361      *
6362      * Use {@link #getInstalledPackages(PackageInfoFlags)} when long flags are needed.
6363      *
6364      * @param flags Additional option flags to modify the data returned.
6365      * @return A List of PackageInfo objects, one for each installed package,
6366      *         containing information about the package. In the unlikely case
6367      *         there are no installed packages, an empty list is returned. If
6368      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
6369      *         information is retrieved from the list of uninstalled
6370      *         applications (which includes installed applications as well as
6371      *         applications with data directory i.e. applications which had been
6372      *         deleted with {@code DELETE_KEEP_DATA} flag set).
6373      */
6374     @NonNull
getInstalledPackages(int flags)6375     public abstract List<PackageInfo> getInstalledPackages(int flags);
6376 
6377     /**
6378      * See {@link #getInstalledPackages(int)}.
6379      */
6380     @NonNull
getInstalledPackages(@onNull PackageInfoFlags flags)6381     public List<PackageInfo> getInstalledPackages(@NonNull PackageInfoFlags flags) {
6382         throw new UnsupportedOperationException(
6383                 "getInstalledPackages not implemented in subclass");
6384     }
6385 
6386     /**
6387      * Returns the app metadata for a package.
6388      *
6389      * @param packageName The package name for which to get the app metadata.
6390      * @return A PersistableBundle containing the app metadata that was provided by the installer.
6391      *         In the case where a package does not have any metadata, an empty PersistableBundle is
6392      *         returned.
6393      * @throws NameNotFoundException if no such package is available to the caller.
6394      * @hide
6395      */
6396     @NonNull
6397     @SystemApi
6398     @RequiresPermission(Manifest.permission.GET_APP_METADATA)
getAppMetadata(@onNull String packageName)6399     public PersistableBundle getAppMetadata(@NonNull String packageName)
6400             throws NameNotFoundException {
6401         throw new UnsupportedOperationException("getAppMetadata not implemented in subclass");
6402     }
6403 
6404 
6405     /**
6406      * Returns the source of the app metadata that is currently associated with the given package.
6407      * The value can be {@link #APP_METADATA_SOURCE_UNKNOWN}, {@link #APP_METADATA_SOURCE_APK},
6408      * {@link #APP_METADATA_SOURCE_INSTALLER} or {@link #APP_METADATA_SOURCE_SYSTEM_IMAGE}.
6409      *
6410      * Note: an app can have the app metadata included in the APK, but if the installer also
6411      * provides an app metadata during the installation, the one provided by the installer will
6412      * take precedence.
6413      *
6414      * @param packageName The package name for which to get the app metadata source.
6415      * @throws NameNotFoundException if no such package is available to the caller.
6416      * @throws SecurityException if the caller doesn't have the required permission.
6417      * @hide
6418      */
6419     @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
6420     @SystemApi
6421     @RequiresPermission(Manifest.permission.GET_APP_METADATA)
getAppMetadataSource(@onNull String packageName)6422     public @AppMetadataSource int getAppMetadataSource(@NonNull String packageName)
6423             throws NameNotFoundException {
6424         throw new UnsupportedOperationException("getAppMetadataSource not implemented in subclass");
6425     }
6426 
6427     /**
6428      * Return a List of all installed packages that are currently holding any of
6429      * the given permissions.
6430      *
6431      * Use {@link #getPackagesHoldingPermissions(String[], PackageInfoFlags)} when long flags are
6432      * needed.
6433      *
6434      * @param flags Additional option flags to modify the data returned.
6435      * @return A List of PackageInfo objects, one for each installed package
6436      *         that holds any of the permissions that were provided, containing
6437      *         information about the package. If no installed packages hold any
6438      *         of the permissions, an empty list is returned. If flag
6439      *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
6440      *         information is retrieved from the list of uninstalled
6441      *         applications (which includes installed applications as well as
6442      *         applications with data directory i.e. applications which had been
6443      *         deleted with {@code DELETE_KEEP_DATA} flag set).
6444      */
6445     @NonNull
getPackagesHoldingPermissions( @onNull String[] permissions, int flags)6446     public abstract List<PackageInfo> getPackagesHoldingPermissions(
6447             @NonNull String[] permissions, int flags);
6448 
6449     /**
6450      * See {@link #getPackagesHoldingPermissions(String[], int)}.
6451      */
6452     @NonNull
getPackagesHoldingPermissions( @onNull String[] permissions, @NonNull PackageInfoFlags flags)6453     public List<PackageInfo> getPackagesHoldingPermissions(
6454             @NonNull String[] permissions, @NonNull PackageInfoFlags flags) {
6455         throw new UnsupportedOperationException(
6456                 "getPackagesHoldingPermissions not implemented in subclass");
6457     }
6458 
6459     /**
6460      * Return a List of all packages that are installed on the device, for a
6461      * specific user.
6462      *
6463      * Use {@link #getInstalledPackagesAsUser(PackageInfoFlags, int)} when long flags are needed.
6464      *
6465      * @param flags Additional option flags to modify the data returned.
6466      * @param userId The user for whom the installed packages are to be listed
6467      * @return A List of PackageInfo objects, one for each installed package,
6468      *         containing information about the package. In the unlikely case
6469      *         there are no installed packages, an empty list is returned. If
6470      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
6471      *         information is retrieved from the list of uninstalled
6472      *         applications (which includes installed applications as well as
6473      *         applications with data directory i.e. applications which had been
6474      *         deleted with {@code DELETE_KEEP_DATA} flag set).
6475      * @hide
6476      */
6477     @SuppressWarnings("HiddenAbstractMethod")
6478     @NonNull
6479     @SystemApi
6480     @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
getInstalledPackagesAsUser(int flags, @UserIdInt int userId)6481     public abstract List<PackageInfo> getInstalledPackagesAsUser(int flags,
6482             @UserIdInt int userId);
6483 
6484     /**
6485      * See {@link #getInstalledPackagesAsUser(int, int)}.
6486      * @hide
6487      */
6488     @NonNull
6489     @SystemApi
6490     @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
getInstalledPackagesAsUser(@onNull PackageInfoFlags flags, @UserIdInt int userId)6491     public List<PackageInfo> getInstalledPackagesAsUser(@NonNull PackageInfoFlags flags,
6492             @UserIdInt int userId) {
6493         throw new UnsupportedOperationException(
6494                 "getApplicationInfoAsUser not implemented in subclass");
6495     }
6496 
6497     /**
6498      * Check whether a particular package has been granted a particular
6499      * permission.
6500      * <p>
6501      * <strong>Note: </strong>This API returns the underlying permission state
6502      * as-is and is mostly intended for permission managing system apps. To
6503      * perform an access check for a certain app, please use the
6504      * {@link Context#checkPermission} APIs instead.
6505      *
6506      * @param permName The name of the permission you are checking for.
6507      * @param packageName The name of the package you are checking against.
6508      *
6509      * @return If the package has the permission, PERMISSION_GRANTED is
6510      * returned.  If it does not have the permission, PERMISSION_DENIED
6511      * is returned.
6512      *
6513      * @see #PERMISSION_GRANTED
6514      * @see #PERMISSION_DENIED
6515      */
6516     @CheckResult
6517     @PermissionResult
checkPermission(@onNull String permName, @NonNull String packageName)6518     public abstract int checkPermission(@NonNull String permName,
6519             @NonNull String packageName);
6520 
6521     /**
6522      * Checks whether a particular permissions has been revoked for a
6523      * package by policy. Typically the device owner or the profile owner
6524      * may apply such a policy. The user cannot grant policy revoked
6525      * permissions, hence the only way for an app to get such a permission
6526      * is by a policy change.
6527      *
6528      * @param permName The name of the permission you are checking for.
6529      * @param packageName The name of the package you are checking against.
6530      *
6531      * @return Whether the permission is restricted by policy.
6532      */
6533     @CheckResult
6534     //@Deprecated
isPermissionRevokedByPolicy(@onNull String permName, @NonNull String packageName)6535     public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
6536             @NonNull String packageName);
6537 
6538     /**
6539      * Gets the package name of the component controlling runtime permissions.
6540      *
6541      * @return the package name of the component controlling runtime permissions
6542      *
6543      * @hide
6544      */
6545     @NonNull
6546     @SystemApi
6547     @TestApi
6548     @SuppressLint("UnflaggedApi") // Promoting from @SystemApi(MODULE_LIBRARIES)
getPermissionControllerPackageName()6549     public String getPermissionControllerPackageName() {
6550         throw new RuntimeException("Not implemented. Must override in a subclass.");
6551     }
6552 
6553     /**
6554      * Returns the package name of the component implementing sdk sandbox service.
6555      *
6556      * @return the package name of the component implementing sdk sandbox service
6557      *
6558      * @hide
6559      */
6560     @NonNull
6561     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
6562     @TestApi
getSdkSandboxPackageName()6563     public String getSdkSandboxPackageName() {
6564         throw new RuntimeException("Not implemented. Must override in a subclass.");
6565     }
6566 
6567     /**
6568      * Add a new dynamic permission to the system.  For this to work, your
6569      * package must have defined a permission tree through the
6570      * {@link android.R.styleable#AndroidManifestPermissionTree
6571      * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
6572      * permissions to trees that were defined by either its own package or
6573      * another with the same user id; a permission is in a tree if it
6574      * matches the name of the permission tree + ".": for example,
6575      * "com.foo.bar" is a member of the permission tree "com.foo".
6576      *
6577      * <p>It is good to make your permission tree name descriptive, because you
6578      * are taking possession of that entire set of permission names.  Thus, it
6579      * must be under a domain you control, with a suffix that will not match
6580      * any normal permissions that may be declared in any applications that
6581      * are part of that domain.
6582      *
6583      * <p>New permissions must be added before
6584      * any .apks are installed that use those permissions.  Permissions you
6585      * add through this method are remembered across reboots of the device.
6586      * If the given permission already exists, the info you supply here
6587      * will be used to update it.
6588      *
6589      * @param info Description of the permission to be added.
6590      *
6591      * @return Returns true if a new permission was created, false if an
6592      * existing one was updated.
6593      *
6594      * @throws SecurityException if you are not allowed to add the
6595      * given permission name.
6596      *
6597      * @see #removePermission(String)
6598      */
6599     //@Deprecated
addPermission(@onNull PermissionInfo info)6600     public abstract boolean addPermission(@NonNull PermissionInfo info);
6601 
6602     /**
6603      * Like {@link #addPermission(PermissionInfo)} but asynchronously
6604      * persists the package manager state after returning from the call,
6605      * allowing it to return quicker and batch a series of adds at the
6606      * expense of no guarantee the added permission will be retained if
6607      * the device is rebooted before it is written.
6608      */
6609     //@Deprecated
addPermissionAsync(@onNull PermissionInfo info)6610     public abstract boolean addPermissionAsync(@NonNull PermissionInfo info);
6611 
6612     /**
6613      * Removes a permission that was previously added with
6614      * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
6615      * -- you are only allowed to remove permissions that you are allowed
6616      * to add.
6617      *
6618      * @param permName The name of the permission to remove.
6619      *
6620      * @throws SecurityException if you are not allowed to remove the
6621      * given permission name.
6622      *
6623      * @see #addPermission(PermissionInfo)
6624      */
6625     //@Deprecated
removePermission(@onNull String permName)6626     public abstract void removePermission(@NonNull String permName);
6627 
6628     /**
6629      * Permission flags set when granting or revoking a permission.
6630      *
6631      * @removed mistakenly exposed as system-api previously
6632      */
6633     @IntDef(prefix = { "FLAG_PERMISSION_" }, value = {
6634             FLAG_PERMISSION_USER_SET,
6635             FLAG_PERMISSION_USER_FIXED,
6636             FLAG_PERMISSION_POLICY_FIXED,
6637             FLAG_PERMISSION_REVOKE_ON_UPGRADE,
6638             FLAG_PERMISSION_SYSTEM_FIXED,
6639             FLAG_PERMISSION_GRANTED_BY_DEFAULT,
6640             FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED,
6641             FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED,
6642             /*
6643             FLAG_PERMISSION_REVOKE_WHEN_REQUESED
6644             */
6645             FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT,
6646             FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT,
6647             FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT,
6648             FLAG_PERMISSION_APPLY_RESTRICTION,
6649             FLAG_PERMISSION_GRANTED_BY_ROLE,
6650             FLAG_PERMISSION_REVOKED_COMPAT,
6651             FLAG_PERMISSION_ONE_TIME,
6652             FLAG_PERMISSION_AUTO_REVOKED
6653     })
6654     @Retention(RetentionPolicy.SOURCE)
6655     public @interface PermissionFlags {}
6656 
6657     /**
6658      * Grant a runtime permission to an application which the application does not
6659      * already have. The permission must have been requested by the application.
6660      * If the application is not allowed to hold the permission, a {@link
6661      * java.lang.SecurityException} is thrown. If the package or permission is
6662      * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
6663      * <p>
6664      * <strong>Note: </strong>Using this API requires holding
6665      * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is
6666      * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
6667      * </p>
6668      *
6669      * @param packageName The package to which to grant the permission.
6670      * @param permName The permission name to grant.
6671      * @param user The user for which to grant the permission.
6672      *
6673      * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
6674      *
6675      * @hide
6676      */
6677     //@Deprecated
6678     @SuppressWarnings("HiddenAbstractMethod")
6679     @SystemApi
6680     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
grantRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user)6681     public abstract void grantRuntimePermission(@NonNull String packageName,
6682             @NonNull String permName, @NonNull UserHandle user);
6683 
6684     /**
6685      * Revoke a runtime permission that was previously granted by {@link
6686      * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
6687      * permission must have been requested by and granted to the application.
6688      * If the application is not allowed to hold the permission, a {@link
6689      * java.lang.SecurityException} is thrown. If the package or permission is
6690      * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
6691      * <p>
6692      * <strong>Note: </strong>Using this API requires holding
6693      * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
6694      * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
6695      * </p>
6696      *
6697      * @param packageName The package from which to revoke the permission.
6698      * @param permName The permission name to revoke.
6699      * @param user The user for which to revoke the permission.
6700      *
6701      * @see #grantRuntimePermission(String, String, android.os.UserHandle)
6702      *
6703      * @hide
6704      */
6705     //@Deprecated
6706     @SuppressWarnings("HiddenAbstractMethod")
6707     @SystemApi
6708     @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
revokeRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user)6709     public abstract void revokeRuntimePermission(@NonNull String packageName,
6710             @NonNull String permName, @NonNull UserHandle user);
6711 
6712     /**
6713      * Revoke a runtime permission that was previously granted by {@link
6714      * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
6715      * permission must have been requested by and granted to the application.
6716      * If the application is not allowed to hold the permission, a {@link
6717      * java.lang.SecurityException} is thrown. If the package or permission is
6718      * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
6719      * <p>
6720      * <strong>Note: </strong>Using this API requires holding
6721      * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
6722      * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
6723      * </p>
6724      *
6725      * @param packageName The package from which to revoke the permission.
6726      * @param permName The permission name to revoke.
6727      * @param user The user for which to revoke the permission.
6728      * @param reason The reason for the revoke.
6729      *
6730      * @see #grantRuntimePermission(String, String, android.os.UserHandle)
6731      *
6732      * @hide
6733      */
6734     //@Deprecated
6735     @SystemApi
6736     @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
revokeRuntimePermission(@onNull String packageName, @NonNull String permName, @NonNull UserHandle user, @NonNull String reason)6737     public void revokeRuntimePermission(@NonNull String packageName,
6738             @NonNull String permName, @NonNull UserHandle user, @NonNull String reason) {
6739         revokeRuntimePermission(packageName, permName, user);
6740     }
6741 
6742     /**
6743      * Gets the state flags associated with a permission.
6744      *
6745      * @param permName The permission for which to get the flags.
6746      * @param packageName The package name for which to get the flags.
6747      * @param user The user for which to get permission flags.
6748      * @return The permission flags.
6749      *
6750      * @hide
6751      */
6752     //@Deprecated
6753     @SuppressWarnings("HiddenAbstractMethod")
6754     @SystemApi
6755     @RequiresPermission(anyOf = {
6756             android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
6757             android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS,
6758             android.Manifest.permission.GET_RUNTIME_PERMISSIONS
6759     })
6760     @PermissionFlags
getPermissionFlags(@onNull String permName, @NonNull String packageName, @NonNull UserHandle user)6761     public abstract int getPermissionFlags(@NonNull String permName,
6762             @NonNull String packageName, @NonNull UserHandle user);
6763 
6764     /**
6765      * Updates the flags associated with a permission by replacing the flags in
6766      * the specified mask with the provided flag values.
6767      *
6768      * @param permName The permission for which to update the flags.
6769      * @param packageName The package name for which to update the flags.
6770      * @param flagMask The flags which to replace.
6771      * @param flagValues The flags with which to replace.
6772      * @param user The user for which to update the permission flags.
6773      *
6774      * @hide
6775      */
6776     //@Deprecated
6777     @SuppressWarnings("HiddenAbstractMethod")
6778     @SystemApi
6779     @RequiresPermission(anyOf = {
6780             android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
6781             android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
6782     })
updatePermissionFlags(@onNull String permName, @NonNull String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues, @NonNull UserHandle user)6783     public abstract void updatePermissionFlags(@NonNull String permName,
6784             @NonNull String packageName, @PermissionFlags int flagMask,
6785             @PermissionFlags int flagValues, @NonNull UserHandle user);
6786 
6787     /**
6788      * Gets the restricted permissions that have been whitelisted and the app
6789      * is allowed to have them granted in their full form.
6790      *
6791      * <p> Permissions can be hard restricted which means that the app cannot hold
6792      * them or soft restricted where the app can hold the permission but in a weaker
6793      * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard
6794      * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted}
6795      * depends on the permission declaration. Whitelisting a hard restricted permission
6796      * allows for the to hold that permission and whitelisting a soft restricted
6797      * permission allows the app to hold the permission in its full, unrestricted form.
6798      *
6799      * <p><ol>There are four allowlists:
6800      *
6801      * <li>one for cases where the system permission policy whitelists a permission
6802      * This list corresponds to the{@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag.
6803      * Can only be accessed by pre-installed holders of a dedicated permission.
6804      *
6805      * <li>one for cases where the system whitelists the permission when upgrading
6806      * from an OS version in which the permission was not restricted to an OS version
6807      * in which the permission is restricted. This list corresponds to the {@link
6808      * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be accessed by pre-installed
6809      * holders of a dedicated permission or the installer on record.
6810      *
6811      * <li>one for cases where the installer of the package whitelists a permission.
6812      * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag.
6813      * Can be accessed by pre-installed holders of a dedicated permission or the
6814      * installer on record.
6815      * </ol>
6816      *
6817      * <p>
6818      * <strong>Note: </strong>In retrospect it would have been preferred to use
6819      * more inclusive terminology when naming this API. Similar APIs added will
6820      * refrain from using the term "whitelist".
6821      * </p>
6822      *
6823      * @param packageName The app for which to get whitelisted permissions.
6824      * @param whitelistFlag The flag to determine which whitelist to query. Only one flag
6825      * can be passed.s
6826      * @return The whitelisted permissions that are on any of the whitelists you query for.
6827      *
6828      * @see #addWhitelistedRestrictedPermission(String, String, int)
6829      * @see #removeWhitelistedRestrictedPermission(String, String, int)
6830      * @see #FLAG_PERMISSION_WHITELIST_SYSTEM
6831      * @see #FLAG_PERMISSION_WHITELIST_UPGRADE
6832      * @see #FLAG_PERMISSION_WHITELIST_INSTALLER
6833      *
6834      * @throws SecurityException if you try to access a whitelist that you have no access to.
6835      */
6836     //@Deprecated
6837     @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS,
6838             conditional = true)
getWhitelistedRestrictedPermissions( @onNull String packageName, @PermissionWhitelistFlags int whitelistFlag)6839     public @NonNull Set<String> getWhitelistedRestrictedPermissions(
6840             @NonNull String packageName, @PermissionWhitelistFlags int whitelistFlag) {
6841         return Collections.emptySet();
6842     }
6843 
6844     /**
6845      * Adds a whitelisted restricted permission for an app.
6846      *
6847      * <p> Permissions can be hard restricted which means that the app cannot hold
6848      * them or soft restricted where the app can hold the permission but in a weaker
6849      * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard
6850      * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted}
6851      * depends on the permission declaration. Whitelisting a hard restricted permission
6852      * allows for the to hold that permission and whitelisting a soft restricted
6853      * permission allows the app to hold the permission in its full, unrestricted form.
6854      *
6855      * <p><ol>There are four whitelists:
6856      *
6857      * <li>one for cases where the system permission policy whitelists a permission
6858      * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag.
6859      * Can only be modified by pre-installed holders of a dedicated permission.
6860      *
6861      * <li>one for cases where the system whitelists the permission when upgrading
6862      * from an OS version in which the permission was not restricted to an OS version
6863      * in which the permission is restricted. This list corresponds to the {@link
6864      * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed
6865      * holders of a dedicated permission. The installer on record can only remove
6866      * permissions from this whitelist.
6867      *
6868      * <li>one for cases where the installer of the package whitelists a permission.
6869      * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag.
6870      * Can be modified by pre-installed holders of a dedicated permission or the installer
6871      * on record.
6872      * </ol>
6873      *
6874      * <p>You need to specify the whitelists for which to set the whitelisted permissions
6875      * which will clear the previous whitelisted permissions and replace them with the
6876      * provided ones.
6877      *
6878      * <p>
6879      * <strong>Note: </strong>In retrospect it would have been preferred to use
6880      * more inclusive terminology when naming this API. Similar APIs added will
6881      * refrain from using the term "whitelist".
6882      * </p>
6883      *
6884      * @param packageName The app for which to get whitelisted permissions.
6885      * @param permName The whitelisted permission to add.
6886      * @param whitelistFlags The whitelists to which to add. Passing multiple flags
6887      * updates all specified whitelists.
6888      * @return Whether the permission was added to the whitelist.
6889      *
6890      * @see #getWhitelistedRestrictedPermissions(String, int)
6891      * @see #removeWhitelistedRestrictedPermission(String, String, int)
6892      * @see #FLAG_PERMISSION_WHITELIST_SYSTEM
6893      * @see #FLAG_PERMISSION_WHITELIST_UPGRADE
6894      * @see #FLAG_PERMISSION_WHITELIST_INSTALLER
6895      *
6896      * @throws SecurityException if you try to modify a whitelist that you have no access to.
6897      */
6898     //@Deprecated
6899     @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS,
6900             conditional = true)
addWhitelistedRestrictedPermission(@onNull String packageName, @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags)6901     public boolean addWhitelistedRestrictedPermission(@NonNull String packageName,
6902             @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) {
6903         return false;
6904     }
6905 
6906     /**
6907      * Removes a whitelisted restricted permission for an app.
6908      *
6909      * <p> Permissions can be hard restricted which means that the app cannot hold
6910      * them or soft restricted where the app can hold the permission but in a weaker
6911      * form. Whether a permission is {@link PermissionInfo#FLAG_HARD_RESTRICTED hard
6912      * restricted} or {@link PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted}
6913      * depends on the permission declaration. Whitelisting a hard restricted permission
6914      * allows for the to hold that permission and whitelisting a soft restricted
6915      * permission allows the app to hold the permission in its full, unrestricted form.
6916      *
6917      * <p><ol>There are four whitelists:
6918      *
6919      * <li>one for cases where the system permission policy whitelists a permission
6920      * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_SYSTEM} flag.
6921      * Can only be modified by pre-installed holders of a dedicated permission.
6922      *
6923      * <li>one for cases where the system whitelists the permission when upgrading
6924      * from an OS version in which the permission was not restricted to an OS version
6925      * in which the permission is restricted. This list corresponds to the {@link
6926      * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed
6927      * holders of a dedicated permission. The installer on record can only remove
6928      * permissions from this whitelist.
6929      *
6930      * <li>one for cases where the installer of the package whitelists a permission.
6931      * This list corresponds to the {@link #FLAG_PERMISSION_WHITELIST_INSTALLER} flag.
6932      * Can be modified by pre-installed holders of a dedicated permission or the installer
6933      * on record.
6934      *
6935      * <li>one for cases where the system exempts the permission when upgrading
6936      * from an OS version in which the permission was not restricted to an OS version
6937      * in which the permission is restricted. This list corresponds to the {@link
6938      * #FLAG_PERMISSION_WHITELIST_UPGRADE} flag. Can be modified by pre-installed
6939      * holders of a dedicated permission. The installer on record can only remove
6940      * permissions from this allowlist.
6941      * </ol>
6942      *
6943      * <p>You need to specify the whitelists for which to set the whitelisted permissions
6944      * which will clear the previous whitelisted permissions and replace them with the
6945      * provided ones.
6946      *
6947      * <p>
6948      * <strong>Note: </strong>In retrospect it would have been preferred to use
6949      * more inclusive terminology when naming this API. Similar APIs added will
6950      * refrain from using the term "whitelist".
6951      * </p>
6952      *
6953      * @param packageName The app for which to get whitelisted permissions.
6954      * @param permName The whitelisted permission to remove.
6955      * @param whitelistFlags The whitelists from which to remove. Passing multiple flags
6956      * updates all specified whitelists.
6957      * @return Whether the permission was removed from the whitelist.
6958      *
6959      * @see #getWhitelistedRestrictedPermissions(String, int)
6960      * @see #addWhitelistedRestrictedPermission(String, String, int)
6961      * @see #FLAG_PERMISSION_WHITELIST_SYSTEM
6962      * @see #FLAG_PERMISSION_WHITELIST_UPGRADE
6963      * @see #FLAG_PERMISSION_WHITELIST_INSTALLER
6964      *
6965      * @throws SecurityException if you try to modify a whitelist that you have no access to.
6966      */
6967     //@Deprecated
6968     @RequiresPermission(value = Manifest.permission.WHITELIST_RESTRICTED_PERMISSIONS,
6969         conditional = true)
removeWhitelistedRestrictedPermission(@onNull String packageName, @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags)6970     public boolean removeWhitelistedRestrictedPermission(@NonNull String packageName,
6971             @NonNull String permName, @PermissionWhitelistFlags int whitelistFlags) {
6972         return false;
6973     }
6974 
6975     /**
6976      * Marks an application exempt from having its permissions be automatically revoked when
6977      * the app is unused for an extended period of time.
6978      *
6979      * Only the installer on record that installed the given package is allowed to call this.
6980      *
6981      * Packages start in whitelisted state, and it is the installer's responsibility to
6982      * un-whitelist the packages it installs, unless auto-revoking permissions from that package
6983      * would cause breakages beyond having to re-request the permission(s).
6984      *
6985      * <p>
6986      * <strong>Note: </strong>In retrospect it would have been preferred to use
6987      * more inclusive terminology when naming this API. Similar APIs added will
6988      * refrain from using the term "whitelist".
6989      * </p>
6990      *
6991      * @param packageName The app for which to set exemption.
6992      * @param whitelisted Whether the app should be whitelisted.
6993      *
6994      * @return whether any change took effect.
6995      *
6996      * @see #isAutoRevokeWhitelisted
6997      *
6998      * @throws SecurityException if you you have no access to modify this.
6999      */
7000     //@Deprecated
7001     @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS,
7002             conditional = true)
setAutoRevokeWhitelisted(@onNull String packageName, boolean whitelisted)7003     public boolean setAutoRevokeWhitelisted(@NonNull String packageName, boolean whitelisted) {
7004         return false;
7005     }
7006 
7007     /**
7008      * Checks whether an application is exempt from having its permissions be automatically revoked
7009      * when the app is unused for an extended period of time.
7010      *
7011      * Only the installer on record that installed the given package, or a holder of
7012      * {@code WHITELIST_AUTO_REVOKE_PERMISSIONS} is allowed to call this.
7013      *
7014      * <p>
7015      * <strong>Note: </strong>In retrospect it would have been preferred to use
7016      * more inclusive terminology when naming this API. Similar APIs added will
7017      * refrain from using the term "whitelist".
7018      * </p>
7019      *
7020      * @param packageName The app for which to set exemption.
7021      *
7022      * @return Whether the app is whitelisted.
7023      *
7024      * @see #setAutoRevokeWhitelisted
7025      *
7026      * @throws SecurityException if you you have no access to this.
7027      */
7028     //@Deprecated
7029     @RequiresPermission(value = Manifest.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS,
7030             conditional = true)
isAutoRevokeWhitelisted(@onNull String packageName)7031     public boolean isAutoRevokeWhitelisted(@NonNull String packageName) {
7032         return false;
7033     }
7034 
7035 
7036     /**
7037      * Gets whether you should show UI with rationale for requesting a permission.
7038      * You should do this only if you do not have the permission and the context in
7039      * which the permission is requested does not clearly communicate to the user
7040      * what would be the benefit from grating this permission.
7041      *
7042      * @param permName A permission your app wants to request.
7043      * @return Whether you can show permission rationale UI.
7044      *
7045      * @hide
7046      */
7047     //@Deprecated
7048     @SuppressWarnings("HiddenAbstractMethod")
7049     @UnsupportedAppUsage
shouldShowRequestPermissionRationale(@onNull String permName)7050     public abstract boolean shouldShowRequestPermissionRationale(@NonNull String permName);
7051 
7052     /**
7053      * Gets the localized label that corresponds to the option in settings for granting
7054      * background access.
7055      *
7056      * <p>The intended use is for apps to reference this label in its instruction for users to grant
7057      * a background permission.
7058      *
7059      * @return the localized label that corresponds to the settings option for granting
7060      * background access
7061      */
7062     @NonNull
getBackgroundPermissionOptionLabel()7063     public CharSequence getBackgroundPermissionOptionLabel() {
7064         return "";
7065     }
7066 
7067     /**
7068      * Returns an {@link android.content.Intent} suitable for passing to
7069      * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
7070      * which prompts the user to grant permissions to this application.
7071      *
7072      * @throws NullPointerException if {@code permissions} is {@code null} or empty.
7073      *
7074      * @hide
7075      */
7076     @NonNull
7077     @UnsupportedAppUsage
buildRequestPermissionsIntent(@onNull String[] permissions)7078     public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
7079         if (ArrayUtils.isEmpty(permissions)) {
7080             throw new IllegalArgumentException("permission cannot be null or empty");
7081         }
7082         Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
7083         intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
7084         intent.setPackage(getPermissionControllerPackageName());
7085         return intent;
7086     }
7087 
7088     /**
7089      * Compare the signatures of two packages to determine if the same
7090      * signature appears in both of them.  If they do contain the same
7091      * signature, then they are allowed special privileges when working
7092      * with each other: they can share the same user-id, run instrumentation
7093      * against each other, etc.
7094      *
7095      * @param packageName1 First package name whose signature will be compared.
7096      * @param packageName2 Second package name whose signature will be compared.
7097      *
7098      * @return Returns an integer indicating whether all signatures on the
7099      * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
7100      * all signatures match or < 0 if there is not a match ({@link
7101      * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
7102      *
7103      * @see #checkSignatures(int, int)
7104      */
7105     @CheckResult
7106     @SignatureResult
checkSignatures(@onNull String packageName1, @NonNull String packageName2)7107     public abstract int checkSignatures(@NonNull String packageName1,
7108             @NonNull String packageName2);
7109 
7110     /**
7111      * Like {@link #checkSignatures(String, String)}, but takes UIDs of
7112      * the two packages to be checked.  This can be useful, for example,
7113      * when doing the check in an IPC, where the UID is the only identity
7114      * available.  It is functionally identical to determining the package
7115      * associated with the UIDs and checking their signatures.
7116      *
7117      * @param uid1 First UID whose signature will be compared.
7118      * @param uid2 Second UID whose signature will be compared.
7119      *
7120      * @return Returns an integer indicating whether all signatures on the
7121      * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
7122      * all signatures match or < 0 if there is not a match ({@link
7123      * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
7124      *
7125      * @see #checkSignatures(String, String)
7126      */
7127     @CheckResult
checkSignatures(int uid1, int uid2)7128     public abstract @SignatureResult int checkSignatures(int uid1, int uid2);
7129 
7130     /**
7131      * Retrieve the names of all packages that are associated with a particular
7132      * user id.  In most cases, this will be a single package name, the package
7133      * that has been assigned that user id.  Where there are multiple packages
7134      * sharing the same user id through the "sharedUserId" mechanism, all
7135      * packages with that id will be returned.
7136      *
7137      * @param uid The user id for which you would like to retrieve the
7138      * associated packages.
7139      *
7140      * @return Returns an array of one or more packages assigned to the user
7141      * id, or null if there are no known packages with the given id.
7142      */
getPackagesForUid(int uid)7143     public abstract @Nullable String[] getPackagesForUid(int uid);
7144 
7145     /**
7146      * Retrieve the official name associated with a uid. This name is
7147      * guaranteed to never change, though it is possible for the underlying
7148      * uid to be changed.  That is, if you are storing information about
7149      * uids in persistent storage, you should use the string returned
7150      * by this function instead of the raw uid.
7151      *
7152      * @param uid The uid for which you would like to retrieve a name.
7153      * @return Returns a unique name for the given uid, or null if the
7154      * uid is not currently assigned.
7155      */
getNameForUid(int uid)7156     public abstract @Nullable String getNameForUid(int uid);
7157 
7158     /**
7159      * Retrieves the official names associated with each given uid.
7160      * @see #getNameForUid(int)
7161      *
7162      * @hide
7163      */
7164     @SuppressWarnings({"HiddenAbstractMethod", "NullableCollection"})
7165     @TestApi
getNamesForUids(int[] uids)7166     public abstract @Nullable String[] getNamesForUids(int[] uids);
7167 
7168     /**
7169      * Return the user id associated with a shared user name. Multiple
7170      * applications can specify a shared user name in their manifest and thus
7171      * end up using a common uid. This might be used for new applications
7172      * that use an existing shared user name and need to know the uid of the
7173      * shared user.
7174      *
7175      * @param sharedUserName The shared user name whose uid is to be retrieved.
7176      * @return Returns the UID associated with the shared user.
7177      * @throws NameNotFoundException if a package with the given name cannot be
7178      *             found on the system.
7179      * @hide
7180      */
7181     @SuppressWarnings("HiddenAbstractMethod")
7182     @UnsupportedAppUsage
getUidForSharedUser(@onNull String sharedUserName)7183     public abstract int getUidForSharedUser(@NonNull String sharedUserName)
7184             throws NameNotFoundException;
7185 
7186     /**
7187      * Return a List of all application packages that are installed for the
7188      * current user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
7189      * applications including those deleted with {@code DELETE_KEEP_DATA}
7190      * (partially installed apps with data directory) will be returned.
7191      *
7192      * Use {@link #getInstalledApplications(ApplicationInfoFlags)} when long flags are needed.
7193      *
7194      * @param flags Additional option flags to modify the data returned.
7195      * @return A List of ApplicationInfo objects, one for each installed
7196      *         application. In the unlikely case there are no installed
7197      *         packages, an empty list is returned. If flag
7198      *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
7199      *         information is retrieved from the list of uninstalled
7200      *         applications (which includes installed applications as well as
7201      *         applications with data directory i.e. applications which had been
7202      *         deleted with {@code DELETE_KEEP_DATA} flag set).
7203      */
7204     @NonNull
getInstalledApplications(int flags)7205     public abstract List<ApplicationInfo> getInstalledApplications(int flags);
7206 
7207     /**
7208      * See {@link #getInstalledApplications(int)}
7209      * @param flags
7210      */
7211     @NonNull
getInstalledApplications(@onNull ApplicationInfoFlags flags)7212     public List<ApplicationInfo> getInstalledApplications(@NonNull ApplicationInfoFlags flags) {
7213         throw new UnsupportedOperationException(
7214                 "getInstalledApplications not implemented in subclass");
7215     }
7216     /**
7217      * Return a List of all application packages that are installed on the
7218      * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been
7219      * set, a list of all applications including those deleted with
7220      * {@code DELETE_KEEP_DATA} (partially installed apps with data directory)
7221      * will be returned.
7222      *
7223      * Use {@link #getInstalledApplicationsAsUser(ApplicationInfoFlags, int)} when long flags are
7224      * needed.
7225      *
7226      * @param flags Additional option flags to modify the data returned.
7227      * @param userId The user for whom the installed applications are to be
7228      *            listed
7229      * @return A List of ApplicationInfo objects, one for each installed
7230      *         application. In the unlikely case there are no installed
7231      *         packages, an empty list is returned. If flag
7232      *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
7233      *         information is retrieved from the list of uninstalled
7234      *         applications (which includes installed applications as well as
7235      *         applications with data directory i.e. applications which had been
7236      *         deleted with {@code DELETE_KEEP_DATA} flag set).
7237      * @hide
7238      */
7239     @SuppressWarnings("HiddenAbstractMethod")
7240     @NonNull
7241     @TestApi
getInstalledApplicationsAsUser( int flags, @UserIdInt int userId)7242     public abstract List<ApplicationInfo> getInstalledApplicationsAsUser(
7243             int flags, @UserIdInt int userId);
7244 
7245     /**
7246      * See {@link #getInstalledApplicationsAsUser(int, int}.
7247      * @hide
7248      */
7249     @NonNull
7250     @TestApi
getInstalledApplicationsAsUser( @onNull ApplicationInfoFlags flags, @UserIdInt int userId)7251     public List<ApplicationInfo> getInstalledApplicationsAsUser(
7252             @NonNull ApplicationInfoFlags flags, @UserIdInt int userId) {
7253         throw new UnsupportedOperationException(
7254                 "getInstalledApplicationsAsUser not implemented in subclass");
7255     }
7256 
7257     /**
7258      * Gets the instant applications the user recently used.
7259      *
7260      * @return The instant app list.
7261      *
7262      * @hide
7263      */
7264     @SuppressWarnings("HiddenAbstractMethod")
7265     @SystemApi
7266     @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
getInstantApps()7267     public abstract @NonNull List<InstantAppInfo> getInstantApps();
7268 
7269     /**
7270      * Gets the icon for an instant application.
7271      *
7272      * @param packageName The app package name.
7273      *
7274      * @hide
7275      */
7276     @SuppressWarnings("HiddenAbstractMethod")
7277     @SystemApi
7278     @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
getInstantAppIcon(String packageName)7279     public abstract @Nullable Drawable getInstantAppIcon(String packageName);
7280 
7281     /**
7282      * Gets whether this application is an instant app.
7283      *
7284      * @return Whether caller is an instant app.
7285      *
7286      * @see #isInstantApp(String)
7287      * @see #updateInstantAppCookie(byte[])
7288      * @see #getInstantAppCookie()
7289      * @see #getInstantAppCookieMaxBytes()
7290      */
isInstantApp()7291     public abstract boolean isInstantApp();
7292 
7293     /**
7294      * Gets whether the given package is an instant app.
7295      *
7296      * @param packageName The package to check
7297      * @return Whether the given package is an instant app.
7298      *
7299      * @see #isInstantApp()
7300      * @see #updateInstantAppCookie(byte[])
7301      * @see #getInstantAppCookie()
7302      * @see #getInstantAppCookieMaxBytes()
7303      * @see #clearInstantAppCookie()
7304      */
isInstantApp(@onNull String packageName)7305     public abstract boolean isInstantApp(@NonNull String packageName);
7306 
7307     /**
7308      * Gets the maximum size in bytes of the cookie data an instant app
7309      * can store on the device.
7310      *
7311      * @return The max cookie size in bytes.
7312      *
7313      * @see #isInstantApp()
7314      * @see #isInstantApp(String)
7315      * @see #updateInstantAppCookie(byte[])
7316      * @see #getInstantAppCookie()
7317      * @see #clearInstantAppCookie()
7318      */
getInstantAppCookieMaxBytes()7319     public abstract int getInstantAppCookieMaxBytes();
7320 
7321     /**
7322      * deprecated
7323      * @hide
7324      */
7325     @SuppressWarnings("HiddenAbstractMethod")
getInstantAppCookieMaxSize()7326     public abstract int getInstantAppCookieMaxSize();
7327 
7328     /**
7329      * Gets the instant application cookie for this app. Non
7330      * instant apps and apps that were instant but were upgraded
7331      * to normal apps can still access this API. For instant apps
7332      * this cookie is cached for some time after uninstall while for
7333      * normal apps the cookie is deleted after the app is uninstalled.
7334      * The cookie is always present while the app is installed.
7335      *
7336      * @return The cookie.
7337      *
7338      * @see #isInstantApp()
7339      * @see #isInstantApp(String)
7340      * @see #updateInstantAppCookie(byte[])
7341      * @see #getInstantAppCookieMaxBytes()
7342      * @see #clearInstantAppCookie()
7343      */
getInstantAppCookie()7344     public abstract @NonNull byte[] getInstantAppCookie();
7345 
7346     /**
7347      * Clears the instant application cookie for the calling app.
7348      *
7349      * @see #isInstantApp()
7350      * @see #isInstantApp(String)
7351      * @see #getInstantAppCookieMaxBytes()
7352      * @see #getInstantAppCookie()
7353      * @see #clearInstantAppCookie()
7354      */
clearInstantAppCookie()7355     public abstract void clearInstantAppCookie();
7356 
7357     /**
7358      * Updates the instant application cookie for the calling app. Non
7359      * instant apps and apps that were instant but were upgraded
7360      * to normal apps can still access this API. For instant apps
7361      * this cookie is cached for some time after uninstall while for
7362      * normal apps the cookie is deleted after the app is uninstalled.
7363      * The cookie is always present while the app is installed. The
7364      * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}.
7365      * Passing <code>null</code> or an empty array clears the cookie.
7366      * </p>
7367      *
7368      * @param cookie The cookie data.
7369      *
7370      * @see #isInstantApp()
7371      * @see #isInstantApp(String)
7372      * @see #getInstantAppCookieMaxBytes()
7373      * @see #getInstantAppCookie()
7374      * @see #clearInstantAppCookie()
7375      *
7376      * @throws IllegalArgumentException if the array exceeds max cookie size.
7377      */
updateInstantAppCookie(@ullable byte[] cookie)7378     public abstract void updateInstantAppCookie(@Nullable byte[] cookie);
7379 
7380     /**
7381      * @removed
7382      */
7383     @SuppressWarnings("HiddenAbstractMethod")
setInstantAppCookie(@ullable byte[] cookie)7384     public abstract boolean setInstantAppCookie(@Nullable byte[] cookie);
7385 
7386     /**
7387      * Get a list of shared libraries that are available on the
7388      * system.
7389      *
7390      * @return An array of shared library names that are
7391      * available on the system, or null if none are installed.
7392      *
7393      */
7394     @Nullable
getSystemSharedLibraryNames()7395     public abstract String[] getSystemSharedLibraryNames();
7396 
7397     /**
7398      * Get a list of shared libraries on the device.
7399      *
7400      * Use {@link #getSharedLibraries(PackageInfoFlags)} when long flags are needed.
7401      *
7402      * @param flags To filter the libraries to return.
7403      * @return The shared library list.
7404      *
7405      * @see #MATCH_UNINSTALLED_PACKAGES
7406      */
getSharedLibraries(int flags)7407     public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(int flags);
7408 
7409     /**
7410      * See {@link #getSharedLibraries(int)}.
7411      * @param flags
7412      */
getSharedLibraries(@onNull PackageInfoFlags flags)7413     public @NonNull List<SharedLibraryInfo> getSharedLibraries(@NonNull PackageInfoFlags flags) {
7414         throw new UnsupportedOperationException(
7415                 "getSharedLibraries() not implemented in subclass");
7416     }
7417 
7418     /**
7419      * Get a list of shared libraries on the device.
7420      *
7421      * Use {@link #getSharedLibrariesAsUser(PackageInfoFlags, int)} when long flags are needed.
7422      *
7423      * @param flags To filter the libraries to return.
7424      * @param userId The user to query for.
7425      * @return The shared library list.
7426      *
7427      * @see #MATCH_FACTORY_ONLY
7428      * @see #MATCH_KNOWN_PACKAGES
7429      * @see #MATCH_ANY_USER
7430      * @see #MATCH_UNINSTALLED_PACKAGES
7431      *
7432      * @hide
7433      */
7434     @SuppressWarnings("HiddenAbstractMethod")
getSharedLibrariesAsUser(int flags, @UserIdInt int userId)7435     public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(int flags,
7436             @UserIdInt int userId);
7437 
7438     /**
7439      * See {@link #getSharedLibrariesAsUser(int, int)}.
7440      * @hide
7441      */
getSharedLibrariesAsUser( @onNull PackageInfoFlags flags, @UserIdInt int userId)7442     public @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(
7443             @NonNull PackageInfoFlags flags, @UserIdInt int userId) {
7444         throw new UnsupportedOperationException(
7445                 "getSharedLibrariesAsUser() not implemented in subclass");
7446     }
7447 
7448     /**
7449      * Get the list of shared libraries declared by a package.
7450      *
7451      * Use {@link #getDeclaredSharedLibraries(String, PackageInfoFlags)} when long flags are needed.
7452      *
7453      * @param packageName the package name to query
7454      * @param flags the flags to filter packages
7455      * @return the shared library list
7456      *
7457      * @hide
7458      */
7459     @SuppressWarnings("HiddenAbstractMethod")
7460     @NonNull
7461     @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES)
7462     @SystemApi
getDeclaredSharedLibraries(@onNull String packageName, int flags)7463     public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName,
7464             int flags) {
7465         throw new UnsupportedOperationException(
7466                 "getDeclaredSharedLibraries() not implemented in subclass");
7467     }
7468 
7469     /**
7470      * See {@link #getDeclaredSharedLibraries(String, int)}.
7471      * @hide
7472      */
7473     @NonNull
7474     @RequiresPermission(Manifest.permission.ACCESS_SHARED_LIBRARIES)
7475     @SystemApi
getDeclaredSharedLibraries(@onNull String packageName, @NonNull PackageInfoFlags flags)7476     public List<SharedLibraryInfo> getDeclaredSharedLibraries(@NonNull String packageName,
7477             @NonNull PackageInfoFlags flags) {
7478         throw new UnsupportedOperationException(
7479                 "getDeclaredSharedLibraries() not implemented in subclass");
7480     }
7481 
7482     /**
7483      * Get the name of the package hosting the services shared library.
7484      * <p>
7485      * Note that this package is no longer a shared library since Android R. It is now a package
7486      * that hosts for a bunch of updatable services that the system binds to.
7487      *
7488      * @return The library host package.
7489      *
7490      * @hide
7491      */
7492     @SuppressWarnings("HiddenAbstractMethod")
7493     @UnsupportedAppUsage
7494     @TestApi
getServicesSystemSharedLibraryPackageName()7495     public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
7496 
7497     /**
7498      * Get the name of the package hosting the shared components shared library.
7499      *
7500      * @return The library host package.
7501      *
7502      * @hide
7503      */
7504     @SuppressWarnings("HiddenAbstractMethod")
7505     @UnsupportedAppUsage
7506     @TestApi
getSharedSystemSharedLibraryPackageName()7507     public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
7508 
7509     /**
7510      * Returns the names of the packages that have been changed
7511      * [eg. added, removed or updated] since the given sequence
7512      * number.
7513      * <p>If no packages have been changed, returns <code>null</code>.
7514      * <p>The sequence number starts at <code>0</code> and is
7515      * reset every boot.
7516      * @param sequenceNumber The first sequence number for which to retrieve package changes.
7517      * @see android.provider.Settings.Global#BOOT_COUNT
7518      */
getChangedPackages( @ntRangefrom=0) int sequenceNumber)7519     public abstract @Nullable ChangedPackages getChangedPackages(
7520             @IntRange(from=0) int sequenceNumber);
7521 
7522     /**
7523      * Get a list of features that are available on the
7524      * system.
7525      *
7526      * @return An array of FeatureInfo classes describing the features
7527      * that are available on the system, or null if there are none(!!).
7528      */
7529     @NonNull
getSystemAvailableFeatures()7530     public abstract FeatureInfo[] getSystemAvailableFeatures();
7531 
7532     /**
7533      * Check whether the given feature name is one of the available features as
7534      * returned by {@link #getSystemAvailableFeatures()}. This tests for the
7535      * presence of <em>any</em> version of the given feature name; use
7536      * {@link #hasSystemFeature(String, int)} to check for a minimum version.
7537      *
7538      * @return Returns true if the devices supports the feature, else false.
7539      */
hasSystemFeature(@onNull String featureName)7540     public abstract boolean hasSystemFeature(@NonNull String featureName);
7541 
7542     /**
7543      * Check whether the given feature name and version is one of the available
7544      * features as returned by {@link #getSystemAvailableFeatures()}. Since
7545      * features are defined to always be backwards compatible, this returns true
7546      * if the available feature version is greater than or equal to the
7547      * requested version.
7548      *
7549      * @return Returns true if the devices supports the feature, else false.
7550      */
hasSystemFeature(@onNull String featureName, int version)7551     public abstract boolean hasSystemFeature(@NonNull String featureName, int version);
7552 
7553     /**
7554      * Determine the best action to perform for a given Intent. This is how
7555      * {@link Intent#resolveActivity} finds an activity if a class has not been
7556      * explicitly specified.
7557      * <p>
7558      * <em>Note:</em> if using an implicit Intent (without an explicit
7559      * ComponentName specified), be sure to consider whether to set the
7560      * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
7561      * activity in the same way that
7562      * {@link android.content.Context#startActivity(Intent)} and
7563      * {@link android.content.Intent#resolveActivity(PackageManager)
7564      * Intent.resolveActivity(PackageManager)} do.
7565      * </p>
7566      *
7567      * Use {@link #resolveActivity(Intent, ResolveInfoFlags)} when long flags are needed.
7568      *
7569      * @param intent An intent containing all of the desired specification
7570      *            (action, data, type, category, and/or component).
7571      * @param flags Additional option flags to modify the data returned. The
7572      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
7573      *            resolution to only those activities that support the
7574      *            {@link android.content.Intent#CATEGORY_DEFAULT}.
7575      * @return Returns a ResolveInfo object containing the final activity intent
7576      *         that was determined to be the best action. Returns null if no
7577      *         matching activity was found. If multiple matching activities are
7578      *         found and there is no default set, returns a ResolveInfo object
7579      *         containing something else, such as the activity resolver.
7580      */
7581     @Nullable
resolveActivity(@onNull Intent intent, int flags)7582     public abstract ResolveInfo resolveActivity(@NonNull Intent intent, int flags);
7583 
7584     /**
7585      * See {@link #resolveActivity(Intent, int)}.
7586      */
7587     @Nullable
resolveActivity(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7588     public ResolveInfo resolveActivity(@NonNull Intent intent, @NonNull ResolveInfoFlags flags) {
7589         throw new UnsupportedOperationException(
7590                 "resolveActivity not implemented in subclass");
7591     }
7592 
7593     /**
7594      * Determine the best action to perform for a given Intent for a given user.
7595      * This is how {@link Intent#resolveActivity} finds an activity if a class
7596      * has not been explicitly specified.
7597      * <p>
7598      * <em>Note:</em> if using an implicit Intent (without an explicit
7599      * ComponentName specified), be sure to consider whether to set the
7600      * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
7601      * activity in the same way that
7602      * {@link android.content.Context#startActivity(Intent)} and
7603      * {@link android.content.Intent#resolveActivity(PackageManager)
7604      * Intent.resolveActivity(PackageManager)} do.
7605      * </p>
7606      *
7607      * Use {@link #resolveActivityAsUser(Intent, ResolveInfoFlags, int)} when long flags are needed.
7608      *
7609      * @param intent An intent containing all of the desired specification
7610      *            (action, data, type, category, and/or component).
7611      * @param flags Additional option flags to modify the data returned. The
7612      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
7613      *            resolution to only those activities that support the
7614      *            {@link android.content.Intent#CATEGORY_DEFAULT}.
7615      * @param userId The user id.
7616      * @return Returns a ResolveInfo object containing the final activity intent
7617      *         that was determined to be the best action. Returns null if no
7618      *         matching activity was found. If multiple matching activities are
7619      *         found and there is no default set, returns a ResolveInfo object
7620      *         containing something else, such as the activity resolver.
7621      * @hide
7622      */
7623     @SuppressWarnings("HiddenAbstractMethod")
7624     @Nullable
7625     @UnsupportedAppUsage
resolveActivityAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7626     public abstract ResolveInfo resolveActivityAsUser(@NonNull Intent intent,
7627             int flags, @UserIdInt int userId);
7628 
7629     /**
7630      * See {@link #resolveActivityAsUser(Intent, int, int)}.
7631      * @hide
7632      */
7633     @Nullable
resolveActivityAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7634     public ResolveInfo resolveActivityAsUser(@NonNull Intent intent,
7635             @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7636         throw new UnsupportedOperationException(
7637                 "resolveActivityAsUser not implemented in subclass");
7638     }
7639 
7640     /**
7641      * Retrieve all activities that can be performed for the given intent.
7642      *
7643      * Use {@link #queryIntentActivities(Intent, ResolveInfoFlags)} when long flags are needed.
7644      *
7645      * @param intent The desired intent as per resolveActivity().
7646      * @param flags Additional option flags to modify the data returned. The
7647      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
7648      *            resolution to only those activities that support the
7649      *            {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
7650      *            {@link #MATCH_ALL} to prevent any filtering of the results.
7651      * @return Returns a List of ResolveInfo objects containing one entry for
7652      *         each matching activity, ordered from best to worst. In other
7653      *         words, the first item is what would be returned by
7654      *         {@link #resolveActivity}. If there are no matching activities, an
7655      *         empty list is returned.
7656      */
7657     @NonNull
queryIntentActivities(@onNull Intent intent, int flags)7658     public abstract List<ResolveInfo> queryIntentActivities(@NonNull Intent intent, int flags);
7659 
7660     /**
7661      * See {@link #queryIntentActivities(Intent, int)}.
7662      */
7663     @NonNull
queryIntentActivities(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7664     public List<ResolveInfo> queryIntentActivities(@NonNull Intent intent,
7665             @NonNull ResolveInfoFlags flags) {
7666         throw new UnsupportedOperationException(
7667                 "queryIntentActivities not implemented in subclass");
7668     }
7669 
7670     /**
7671      * Retrieve all activities that can be performed for the given intent, for a
7672      * specific user.
7673      *
7674      * Use {@link #queryIntentActivitiesAsUser(Intent, ResolveInfoFlags, int)} when long flags are
7675      * needed.
7676      *
7677      * @param intent The desired intent as per resolveActivity().
7678      * @param flags Additional option flags to modify the data returned. The
7679      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
7680      *            resolution to only those activities that support the
7681      *            {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
7682      *            {@link #MATCH_ALL} to prevent any filtering of the results.
7683      * @return Returns a List of ResolveInfo objects containing one entry for
7684      *         each matching activity, ordered from best to worst. In other
7685      *         words, the first item is what would be returned by
7686      *         {@link #resolveActivity}. If there are no matching activities, an
7687      *         empty list is returned.
7688      * @hide
7689      */
7690     @SuppressWarnings("HiddenAbstractMethod")
7691     @NonNull
7692     @UnsupportedAppUsage
queryIntentActivitiesAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7693     public abstract List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent,
7694             int flags, @UserIdInt int userId);
7695 
7696     /**
7697      * See {@link #queryIntentActivitiesAsUser(Intent, int, int)}.
7698      * @hide
7699      */
7700     @NonNull
queryIntentActivitiesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7701     public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent,
7702             @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7703         throw new UnsupportedOperationException(
7704                 "queryIntentActivitiesAsUser not implemented in subclass");
7705     }
7706 
7707     /**
7708      * Retrieve all activities that can be performed for the given intent, for a
7709      * specific user.
7710      *
7711      * Use {@link #queryIntentActivitiesAsUser(Intent, ResolveInfoFlags, UserHandle)} when long
7712      * flags are needed.
7713      *
7714      * @param intent The desired intent as per resolveActivity().
7715      * @param flags Additional option flags to modify the data returned. The
7716      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
7717      *            resolution to only those activities that support the
7718      *            {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
7719      *            {@link #MATCH_ALL} to prevent any filtering of the results.
7720      * @param user The user being queried.
7721      * @return Returns a List of ResolveInfo objects containing one entry for
7722      *         each matching activity, ordered from best to worst. In other
7723      *         words, the first item is what would be returned by
7724      *         {@link #resolveActivity}. If there are no matching activities, an
7725      *         empty list is returned.
7726      * @hide
7727      */
7728     @SuppressWarnings("HiddenAbstractMethod")
7729     @NonNull
7730     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7731     @SystemApi
queryIntentActivitiesAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)7732     public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent,
7733             int flags, @NonNull UserHandle user) {
7734         return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier());
7735     }
7736 
7737     /**
7738      * See {@link #queryIntentActivitiesAsUser(Intent, int, UserHandle)}.
7739      * @hide
7740      */
7741     @NonNull
7742     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
7743     @SystemApi
queryIntentActivitiesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)7744     public List<ResolveInfo> queryIntentActivitiesAsUser(@NonNull Intent intent,
7745             @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) {
7746         return queryIntentActivitiesAsUser(intent, flags, user.getIdentifier());
7747     }
7748 
7749     /**
7750      * Retrieve a set of activities that should be presented to the user as
7751      * similar options. This is like {@link #queryIntentActivities}, except it
7752      * also allows you to supply a list of more explicit Intents that you would
7753      * like to resolve to particular options, and takes care of returning the
7754      * final ResolveInfo list in a reasonable order, with no duplicates, based
7755      * on those inputs.
7756      *
7757      * Use {@link #queryIntentActivityOptions(ComponentName, List, Intent, ResolveInfoFlags)} when
7758      * long flags are needed.
7759      *
7760      * @param caller The class name of the activity that is making the request.
7761      *            This activity will never appear in the output list. Can be
7762      *            null.
7763      * @param specifics An array of Intents that should be resolved to the first
7764      *            specific results. Can be null.
7765      * @param intent The desired intent as per resolveActivity().
7766      * @param flags Additional option flags to modify the data returned. The
7767      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
7768      *            resolution to only those activities that support the
7769      *            {@link android.content.Intent#CATEGORY_DEFAULT}.
7770      * @return Returns a List of ResolveInfo objects containing one entry for
7771      *         each matching activity. The list is ordered first by all of the
7772      *         intents resolved in <var>specifics</var> and then any additional
7773      *         activities that can handle <var>intent</var> but did not get
7774      *         included by one of the <var>specifics</var> intents. If there are
7775      *         no matching activities, an empty list is returned.
7776      */
7777     @NonNull
queryIntentActivityOptions(@ullable ComponentName caller, @Nullable Intent[] specifics, @NonNull Intent intent, int flags)7778     public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
7779             @Nullable Intent[] specifics, @NonNull Intent intent, int flags);
7780 
7781     /**
7782      * See {@link #queryIntentActivityOptions(ComponentName, Intent[], Intent, int)}.
7783      */
7784     @NonNull
queryIntentActivityOptions(@ullable ComponentName caller, @Nullable List<Intent> specifics, @NonNull Intent intent, @NonNull ResolveInfoFlags flags)7785     public List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
7786             @Nullable List<Intent> specifics, @NonNull Intent intent,
7787             @NonNull ResolveInfoFlags flags) {
7788         throw new UnsupportedOperationException(
7789                 "queryIntentActivityOptions not implemented in subclass");
7790     }
7791 
7792     /**
7793      * Retrieve all receivers that can handle a broadcast of the given intent.
7794      *
7795      * Use {@link #queryBroadcastReceivers(Intent, ResolveInfoFlags)} when long flags are needed.
7796      *
7797      * @param intent The desired intent as per resolveActivity().
7798      * @param flags Additional option flags to modify the data returned.
7799      * @return Returns a List of ResolveInfo objects containing one entry for
7800      *         each matching receiver, ordered from best to worst. If there are
7801      *         no matching receivers, an empty list or null is returned.
7802      */
7803     @NonNull
queryBroadcastReceivers(@onNull Intent intent, int flags)7804     public abstract List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent, int flags);
7805 
7806     /**
7807      * See {@link #queryBroadcastReceivers(Intent, int)}.
7808      */
7809     @NonNull
queryBroadcastReceivers(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7810     public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent,
7811             @NonNull ResolveInfoFlags flags) {
7812         throw new UnsupportedOperationException(
7813                 "queryBroadcastReceivers not implemented in subclass");
7814     }
7815 
7816     /**
7817      * Retrieve all receivers that can handle a broadcast of the given intent,
7818      * for a specific user.
7819      *
7820      * Use {@link #queryBroadcastReceiversAsUser(Intent, ResolveInfoFlags, UserHandle)} when long
7821      * flags are needed.
7822      *
7823      * @param intent The desired intent as per resolveActivity().
7824      * @param flags Additional option flags to modify the data returned.
7825      * @param userHandle UserHandle of the user being queried.
7826      * @return Returns a List of ResolveInfo objects containing one entry for
7827      *         each matching receiver, ordered from best to worst. If there are
7828      *         no matching receivers, an empty list or null is returned.
7829      * @hide
7830      */
7831     @SuppressWarnings("HiddenAbstractMethod")
7832     @NonNull
7833     @SystemApi
7834     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
queryBroadcastReceiversAsUser(@onNull Intent intent, int flags, UserHandle userHandle)7835     public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent,
7836             int flags, UserHandle userHandle) {
7837         return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
7838     }
7839 
7840     /**
7841      * See {@link #queryBroadcastReceiversAsUser(Intent, int, UserHandle)}.
7842      * @hide
7843      */
7844     @NonNull
7845     @SystemApi
7846     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
queryBroadcastReceiversAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle userHandle)7847     public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent,
7848             @NonNull ResolveInfoFlags flags, @NonNull UserHandle userHandle) {
7849         return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
7850     }
7851 
7852     /**
7853      * @hide
7854      * Use {@link #queryBroadcastReceiversAsUser(Intent, ResolveInfoFlags, int)} when long flags are
7855      * needed.
7856      */
7857     @SuppressWarnings("HiddenAbstractMethod")
7858     @NonNull
7859     @UnsupportedAppUsage
queryBroadcastReceiversAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7860     public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent,
7861             int flags, @UserIdInt int userId);
7862 
7863     /**
7864      * See {@link #queryBroadcastReceiversAsUser(Intent, int, int)}.
7865      * @hide
7866      */
7867     @NonNull
queryBroadcastReceiversAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7868     public List<ResolveInfo> queryBroadcastReceiversAsUser(@NonNull Intent intent,
7869             @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7870         throw new UnsupportedOperationException(
7871                 "queryBroadcastReceiversAsUser not implemented in subclass");
7872     }
7873 
7874 
7875     /** @deprecated @hide */
7876     @NonNull
7877     @Deprecated
7878     @UnsupportedAppUsage
queryBroadcastReceivers(@onNull Intent intent, int flags, @UserIdInt int userId)7879     public List<ResolveInfo> queryBroadcastReceivers(@NonNull Intent intent,
7880             int flags, @UserIdInt int userId) {
7881         final String msg = "Shame on you for calling the hidden API "
7882                 + "queryBroadcastReceivers(). Shame!";
7883         if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) {
7884             throw new UnsupportedOperationException(msg);
7885         } else {
7886             Log.d(TAG, msg);
7887             return queryBroadcastReceiversAsUser(intent, flags, userId);
7888         }
7889     }
7890 
7891     /**
7892      * Determine the best service to handle for a given Intent.
7893      *
7894      * Use {@link #resolveService(Intent, ResolveInfoFlags)} when long flags are needed.
7895      *
7896      * @param intent An intent containing all of the desired specification
7897      *            (action, data, type, category, and/or component).
7898      * @param flags Additional option flags to modify the data returned.
7899      * @return Returns a ResolveInfo object containing the final service intent
7900      *         that was determined to be the best action. Returns null if no
7901      *         matching service was found.
7902      */
7903     @Nullable
resolveService(@onNull Intent intent, int flags)7904     public abstract ResolveInfo resolveService(@NonNull Intent intent, int flags);
7905 
7906     /**
7907      * See {@link #resolveService(Intent, int)}.
7908      */
7909     @Nullable
resolveService(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7910     public ResolveInfo resolveService(@NonNull Intent intent, @NonNull ResolveInfoFlags flags) {
7911         throw new UnsupportedOperationException(
7912                 "resolveService not implemented in subclass");
7913     }
7914 
7915     /**
7916      * @hide
7917      * Use {@link #resolveServiceAsUser(Intent, ResolveInfoFlags, int)} when long flags are needed.
7918      */
7919     @SuppressWarnings("HiddenAbstractMethod")
7920     @Nullable
resolveServiceAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7921     public abstract ResolveInfo resolveServiceAsUser(@NonNull Intent intent,
7922             int flags, @UserIdInt int userId);
7923 
7924     /**
7925      * See {@link #resolveServiceAsUser(Intent, int, int)}.
7926      * @hide
7927      */
7928     @Nullable
resolveServiceAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7929     public ResolveInfo resolveServiceAsUser(@NonNull Intent intent,
7930             @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7931         throw new UnsupportedOperationException(
7932                 "resolveServiceAsUser not implemented in subclass");
7933     }
7934 
7935     /**
7936      * Retrieve all services that can match the given intent.
7937      *
7938      * Use {@link #queryIntentServices(Intent, ResolveInfoFlags)} when long flags are needed.
7939      *
7940      * @param intent The desired intent as per resolveService().
7941      * @param flags Additional option flags to modify the data returned.
7942      * @return Returns a List of ResolveInfo objects containing one entry for
7943      *         each matching service, ordered from best to worst. In other
7944      *         words, the first item is what would be returned by
7945      *         {@link #resolveService}. If there are no matching services, an
7946      *         empty list or null is returned.
7947      */
7948     @NonNull
queryIntentServices(@onNull Intent intent, int flags)7949     public abstract List<ResolveInfo> queryIntentServices(@NonNull Intent intent,
7950             int flags);
7951 
7952     /**
7953      * See {@link #queryIntentServices(Intent, int)}.
7954      */
7955     @NonNull
queryIntentServices(@onNull Intent intent, @NonNull ResolveInfoFlags flags)7956     public List<ResolveInfo> queryIntentServices(@NonNull Intent intent,
7957             @NonNull ResolveInfoFlags flags) {
7958         throw new UnsupportedOperationException(
7959                 "queryIntentServices not implemented in subclass");
7960     }
7961 
7962     /**
7963      * Retrieve all services that can match the given intent for a given user.
7964      *
7965      * Use {@link #queryIntentServicesAsUser(Intent, ResolveInfoFlags, int)} when long flags are
7966      * needed.
7967      *
7968      * @param intent The desired intent as per resolveService().
7969      * @param flags Additional option flags to modify the data returned.
7970      * @param userId The user id.
7971      * @return Returns a List of ResolveInfo objects containing one entry for
7972      *         each matching service, ordered from best to worst. In other
7973      *         words, the first item is what would be returned by
7974      *         {@link #resolveService}. If there are no matching services, an
7975      *         empty list or null is returned.
7976      * @hide
7977      */
7978     @SuppressWarnings("HiddenAbstractMethod")
7979     @NonNull
7980     @UnsupportedAppUsage
queryIntentServicesAsUser(@onNull Intent intent, int flags, @UserIdInt int userId)7981     public abstract List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent,
7982             int flags, @UserIdInt int userId);
7983 
7984     /**
7985      * See {@link #queryIntentServicesAsUser(Intent, int, int)}.
7986      * @hide
7987      */
7988     @NonNull
queryIntentServicesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)7989     public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent,
7990             @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
7991         throw new UnsupportedOperationException(
7992                 "queryIntentServicesAsUser not implemented in subclass");
7993     }
7994 
7995     /**
7996      * Retrieve all services that can match the given intent for a given user.
7997      *
7998      * Use {@link #queryIntentServicesAsUser(Intent, ResolveInfoFlags, UserHandle)} when long flags
7999      * are needed.
8000      *
8001      * @param intent The desired intent as per resolveService().
8002      * @param flags Additional option flags to modify the data returned.
8003      * @param user The user being queried.
8004      * @return Returns a List of ResolveInfo objects containing one entry for
8005      *         each matching service, ordered from best to worst. In other
8006      *         words, the first item is what would be returned by
8007      *         {@link #resolveService}. If there are no matching services, an
8008      *         empty list or null is returned.
8009      * @hide
8010      */
8011     @NonNull
8012     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
8013     @SystemApi
queryIntentServicesAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)8014     public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent,
8015             int flags, @NonNull UserHandle user) {
8016         return queryIntentServicesAsUser(intent, flags, user.getIdentifier());
8017     }
8018 
8019     /**
8020      * See {@link #queryIntentServicesAsUser(Intent, int, UserHandle)}.
8021      * @hide
8022      */
8023     @NonNull
8024     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
8025     @SystemApi
queryIntentServicesAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)8026     public List<ResolveInfo> queryIntentServicesAsUser(@NonNull Intent intent,
8027             @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) {
8028         return queryIntentServicesAsUser(intent, flags, user.getIdentifier());
8029     }
8030     /**
8031      * Retrieve all providers that can match the given intent.
8032      *
8033      * Use {@link #queryIntentContentProvidersAsUser(Intent, ResolveInfoFlags, int)} when long flags
8034      * are needed.
8035      *
8036      * @param intent An intent containing all of the desired specification
8037      *            (action, data, type, category, and/or component).
8038      * @param flags Additional option flags to modify the data returned.
8039      * @param userId The user id.
8040      * @return Returns a List of ResolveInfo objects containing one entry for
8041      *         each matching provider, ordered from best to worst. If there are
8042      *         no matching services, an empty list or null is returned.
8043      * @hide
8044      */
8045     @SuppressWarnings("HiddenAbstractMethod")
8046     @NonNull
8047     @UnsupportedAppUsage
queryIntentContentProvidersAsUser( @onNull Intent intent, int flags, @UserIdInt int userId)8048     public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
8049             @NonNull Intent intent, int flags, @UserIdInt int userId);
8050 
8051     /**
8052      * See {@link #queryIntentContentProvidersAsUser(Intent, int, int)}.
8053      * @hide
8054      */
8055     @NonNull
queryIntentContentProvidersAsUser( @onNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId)8056     protected List<ResolveInfo> queryIntentContentProvidersAsUser(
8057             @NonNull Intent intent, @NonNull ResolveInfoFlags flags, @UserIdInt int userId) {
8058         throw new UnsupportedOperationException(
8059                 "queryIntentContentProvidersAsUser not implemented in subclass");
8060     }
8061 
8062     /**
8063      * Retrieve all providers that can match the given intent.
8064      *
8065      * Use {@link #queryIntentContentProvidersAsUser(Intent, ResolveInfoFlags, UserHandle)} when
8066      * long flags are needed.
8067      *
8068      * @param intent An intent containing all of the desired specification
8069      *            (action, data, type, category, and/or component).
8070      * @param flags Additional option flags to modify the data returned.
8071      * @param user The user being queried.
8072      * @return Returns a List of ResolveInfo objects containing one entry for
8073      *         each matching provider, ordered from best to worst. If there are
8074      *         no matching services, an empty list or null is returned.
8075      * @hide
8076      */
8077     @NonNull
8078     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
8079     @SystemApi
queryIntentContentProvidersAsUser(@onNull Intent intent, int flags, @NonNull UserHandle user)8080     public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent,
8081             int flags, @NonNull UserHandle user) {
8082         return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier());
8083     }
8084 
8085     /**
8086      * See {@link #queryIntentContentProvidersAsUser(Intent, int, UserHandle)}.
8087      * @hide
8088      */
8089     @NonNull
8090     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
8091     @SystemApi
queryIntentContentProvidersAsUser(@onNull Intent intent, @NonNull ResolveInfoFlags flags, @NonNull UserHandle user)8092     public List<ResolveInfo> queryIntentContentProvidersAsUser(@NonNull Intent intent,
8093             @NonNull ResolveInfoFlags flags, @NonNull UserHandle user) {
8094         return queryIntentContentProvidersAsUser(intent, flags, user.getIdentifier());
8095     }
8096 
8097     /**
8098      * Retrieve all providers that can match the given intent.
8099      *
8100      * Use {@link #queryIntentContentProviders(Intent, ResolveInfoFlags)} when long flags are
8101      * needed.
8102      *
8103      * @param intent An intent containing all of the desired specification
8104      *            (action, data, type, category, and/or component).
8105      * @param flags Additional option flags to modify the data returned.
8106      * @return Returns a List of ResolveInfo objects containing one entry for
8107      *         each matching provider, ordered from best to worst. If there are
8108      *         no matching services, an empty list or null is returned.
8109      */
8110     @NonNull
queryIntentContentProviders(@onNull Intent intent, int flags)8111     public abstract List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent,
8112             int flags);
8113 
8114     /**
8115      * See {@link #queryIntentContentProviders(Intent, int)}.
8116      */
8117     @NonNull
queryIntentContentProviders(@onNull Intent intent, @NonNull ResolveInfoFlags flags)8118     public List<ResolveInfo> queryIntentContentProviders(@NonNull Intent intent,
8119             @NonNull ResolveInfoFlags flags) {
8120         throw new UnsupportedOperationException(
8121                 "queryIntentContentProviders not implemented in subclass");
8122     }
8123 
8124     /**
8125      * Find a single content provider by its authority.
8126      * <p>
8127      * Example:<p>
8128      * <pre>
8129      * Uri uri = Uri.parse("content://com.example.app.provider/table1");
8130      * ProviderInfo info = packageManager.resolveContentProvider(uri.getAuthority(), flags);
8131      * </pre>
8132      *
8133      * Use {@link #resolveContentProvider(String, ComponentInfoFlags)} when long flags are needed.
8134      *
8135      * @param authority The authority of the provider to find.
8136      * @param flags Additional option flags to modify the data returned.
8137      * @return A {@link ProviderInfo} object containing information about the
8138      *         provider. If a provider was not found, returns null.
8139      */
8140     @Nullable
resolveContentProvider(@onNull String authority, int flags)8141     public abstract ProviderInfo resolveContentProvider(@NonNull String authority,
8142             int flags);
8143 
8144     /**
8145      * See {@link #resolveContentProvider(String, int)}.
8146      */
8147     @Nullable
resolveContentProvider(@onNull String authority, @NonNull ComponentInfoFlags flags)8148     public ProviderInfo resolveContentProvider(@NonNull String authority,
8149             @NonNull ComponentInfoFlags flags) {
8150         throw new UnsupportedOperationException(
8151                 "resolveContentProvider not implemented in subclass");
8152     }
8153 
8154     /**
8155      * Find a single content provider by its base path name.
8156      *
8157      * Use {@link #resolveContentProviderAsUser(String, ComponentInfoFlags, int)} when long flags
8158      * are needed.
8159      *
8160      * @param providerName The name of the provider to find.
8161      * @param flags Additional option flags to modify the data returned.
8162      * @param userId The user id.
8163      * @return A {@link ProviderInfo} object containing information about the
8164      *         provider. If a provider was not found, returns null.
8165      * @hide
8166      */
8167     @SuppressWarnings("HiddenAbstractMethod")
8168     @Nullable
8169     @UnsupportedAppUsage
resolveContentProviderAsUser(@onNull String providerName, int flags, @UserIdInt int userId)8170     public abstract ProviderInfo resolveContentProviderAsUser(@NonNull String providerName,
8171             int flags, @UserIdInt int userId);
8172 
8173     /**
8174      * See {@link #resolveContentProviderAsUser(String, int, int)}.
8175      * @hide
8176      */
8177     @Nullable
resolveContentProviderAsUser(@onNull String providerName, @NonNull ComponentInfoFlags flags, @UserIdInt int userId)8178     public ProviderInfo resolveContentProviderAsUser(@NonNull String providerName,
8179             @NonNull ComponentInfoFlags flags, @UserIdInt int userId) {
8180         throw new UnsupportedOperationException(
8181                 "resolveContentProviderAsUser not implemented in subclass");
8182     }
8183 
8184     /**
8185      * Retrieve content provider information.
8186      * <p>
8187      * <em>Note: unlike most other methods, an empty result set is indicated
8188      * by a null return instead of an empty list.</em>
8189      *
8190      * Use {@link #queryContentProviders(String, int, ComponentInfoFlags)} when long flags are
8191      * needed.
8192      *
8193      * @param processName If non-null, limits the returned providers to only
8194      *            those that are hosted by the given process. If null, all
8195      *            content providers are returned.
8196      * @param uid If <var>processName</var> is non-null, this is the required
8197      *            uid owning the requested content providers.
8198      * @param flags Additional option flags to modify the data returned.
8199      * @return A list of {@link ProviderInfo} objects containing one entry for
8200      *         each provider either matching <var>processName</var> or, if
8201      *         <var>processName</var> is null, all known content providers.
8202      *         <em>If there are no matching providers, null is returned.</em>
8203      */
8204     @NonNull
queryContentProviders( @ullable String processName, int uid, int flags)8205     public abstract List<ProviderInfo> queryContentProviders(
8206             @Nullable String processName, int uid, int flags);
8207 
8208     /**
8209      * See {@link #queryContentProviders(String, int, int)}.
8210      */
8211     @NonNull
queryContentProviders( @ullable String processName, int uid, @NonNull ComponentInfoFlags flags)8212     public List<ProviderInfo> queryContentProviders(
8213             @Nullable String processName, int uid, @NonNull ComponentInfoFlags flags) {
8214         throw new UnsupportedOperationException(
8215                 "queryContentProviders not implemented in subclass");
8216     }
8217 
8218     /**
8219      * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null,
8220      * it only returns providers which have metadata with the {@code metaDataKey} key.
8221      *
8222      * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider.
8223      * You really shouldn't need it.  Other apps should use {@link #queryIntentContentProviders}
8224      * instead.
8225      *
8226      * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly
8227      * scan the GAL providers on the device.  Unfortunately the discovery protocol used metadata
8228      * to mark GAL providers, rather than intent filters, so we can't use
8229      * {@link #queryIntentContentProviders} for that.
8230      *
8231      * Use {@link #queryContentProviders(String, int, ComponentInfoFlags, String)} when long flags
8232      * are needed.
8233      *
8234      * @hide
8235      */
8236     @NonNull
queryContentProviders(@ullable String processName, int uid, int flags, String metaDataKey)8237     public List<ProviderInfo> queryContentProviders(@Nullable String processName,
8238             int uid, int flags, String metaDataKey) {
8239         // Provide the default implementation for mocks.
8240         return queryContentProviders(processName, uid, flags);
8241     }
8242 
8243     /**
8244      * See {@link #queryContentProviders(String, int, int, String)}.
8245      * @hide
8246      */
8247     @NonNull
queryContentProviders(@ullable String processName, int uid, @NonNull ComponentInfoFlags flags, @Nullable String metaDataKey)8248     public List<ProviderInfo> queryContentProviders(@Nullable String processName,
8249             int uid, @NonNull ComponentInfoFlags flags, @Nullable String metaDataKey) {
8250         // Provide the default implementation for mocks.
8251         return queryContentProviders(processName, uid, flags);
8252     }
8253 
8254     /**
8255      * Retrieve all of the information we know about a particular
8256      * instrumentation class.
8257      *
8258      * @param className The full name (i.e.
8259      *            com.google.apps.contacts.InstrumentList) of an Instrumentation
8260      *            class.
8261      * @param flags Additional option flags to modify the data returned.
8262      * @return An {@link InstrumentationInfo} object containing information
8263      *         about the instrumentation.
8264      * @throws NameNotFoundException if a package with the given name cannot be
8265      *             found on the system.
8266      */
8267     @NonNull
getInstrumentationInfo(@onNull ComponentName className, @InstrumentationInfoFlags int flags)8268     public abstract InstrumentationInfo getInstrumentationInfo(@NonNull ComponentName className,
8269             @InstrumentationInfoFlags int flags) throws NameNotFoundException;
8270 
8271     /**
8272      * Retrieve information about available instrumentation code. May be used to
8273      * retrieve either all instrumentation code, or only the code targeting a
8274      * particular package.
8275      *
8276      * @param targetPackage If null, all instrumentation is returned; only the
8277      *            instrumentation targeting this package name is returned.
8278      * @param flags Additional option flags to modify the data returned.
8279      * @return A list of {@link InstrumentationInfo} objects containing one
8280      *         entry for each matching instrumentation. If there are no
8281      *         instrumentation available, returns an empty list.
8282      */
8283     @NonNull
queryInstrumentation(@onNull String targetPackage, @InstrumentationInfoFlags int flags)8284     public abstract List<InstrumentationInfo> queryInstrumentation(@NonNull String targetPackage,
8285             @InstrumentationInfoFlags int flags);
8286 
8287     /**
8288      * Retrieve an image from a package.  This is a low-level API used by
8289      * the various package manager info structures (such as
8290      * {@link ComponentInfo} to implement retrieval of their associated
8291      * icon.
8292      *
8293      * @param packageName The name of the package that this icon is coming from.
8294      * Cannot be null.
8295      * @param resid The resource identifier of the desired image.  Cannot be 0.
8296      * @param appInfo Overall information about <var>packageName</var>.  This
8297      * may be null, in which case the application information will be retrieved
8298      * for you if needed; if you already have this information around, it can
8299      * be much more efficient to supply it here.
8300      *
8301      * @return Returns a Drawable holding the requested image.  Returns null if
8302      * an image could not be found for any reason.
8303      */
8304     @Nullable
getDrawable(@onNull String packageName, @DrawableRes int resid, @Nullable ApplicationInfo appInfo)8305     public abstract Drawable getDrawable(@NonNull String packageName, @DrawableRes int resid,
8306             @Nullable ApplicationInfo appInfo);
8307 
8308     /**
8309      * Retrieve the icon associated with an activity.  Given the full name of
8310      * an activity, retrieves the information about it and calls
8311      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
8312      * If the activity cannot be found, NameNotFoundException is thrown.
8313      *
8314      * @param activityName Name of the activity whose icon is to be retrieved.
8315      *
8316      * @return Returns the image of the icon, or the default activity icon if
8317      * it could not be found.  Does not return null.
8318      * @throws NameNotFoundException Thrown if the resources for the given
8319      * activity could not be loaded.
8320      *
8321      * @see #getActivityIcon(Intent)
8322      */
8323     @NonNull
getActivityIcon(@onNull ComponentName activityName)8324     public abstract Drawable getActivityIcon(@NonNull ComponentName activityName)
8325             throws NameNotFoundException;
8326 
8327     /**
8328      * Retrieve the icon associated with an Intent.  If intent.getClassName() is
8329      * set, this simply returns the result of
8330      * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
8331      * component and returns the icon associated with the resolved component.
8332      * If intent.getClassName() cannot be found or the Intent cannot be resolved
8333      * to a component, NameNotFoundException is thrown.
8334      *
8335      * @param intent The intent for which you would like to retrieve an icon.
8336      *
8337      * @return Returns the image of the icon, or the default activity icon if
8338      * it could not be found.  Does not return null.
8339      * @throws NameNotFoundException Thrown if the resources for application
8340      * matching the given intent could not be loaded.
8341      *
8342      * @see #getActivityIcon(ComponentName)
8343      */
8344     @NonNull
getActivityIcon(@onNull Intent intent)8345     public abstract Drawable getActivityIcon(@NonNull Intent intent)
8346             throws NameNotFoundException;
8347 
8348     /**
8349      * Retrieve the banner associated with an activity. Given the full name of
8350      * an activity, retrieves the information about it and calls
8351      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
8352      * banner. If the activity cannot be found, NameNotFoundException is thrown.
8353      *
8354      * @param activityName Name of the activity whose banner is to be retrieved.
8355      * @return Returns the image of the banner, or null if the activity has no
8356      *         banner specified.
8357      * @throws NameNotFoundException Thrown if the resources for the given
8358      *             activity could not be loaded.
8359      * @see #getActivityBanner(Intent)
8360      */
8361     @Nullable
getActivityBanner(@onNull ComponentName activityName)8362     public abstract Drawable getActivityBanner(@NonNull ComponentName activityName)
8363             throws NameNotFoundException;
8364 
8365     /**
8366      * Retrieve the banner associated with an Intent. If intent.getClassName()
8367      * is set, this simply returns the result of
8368      * getActivityBanner(intent.getClassName()). Otherwise it resolves the
8369      * intent's component and returns the banner associated with the resolved
8370      * component. If intent.getClassName() cannot be found or the Intent cannot
8371      * be resolved to a component, NameNotFoundException is thrown.
8372      *
8373      * @param intent The intent for which you would like to retrieve a banner.
8374      * @return Returns the image of the banner, or null if the activity has no
8375      *         banner specified.
8376      * @throws NameNotFoundException Thrown if the resources for application
8377      *             matching the given intent could not be loaded.
8378      * @see #getActivityBanner(ComponentName)
8379      */
8380     @Nullable
getActivityBanner(@onNull Intent intent)8381     public abstract Drawable getActivityBanner(@NonNull Intent intent)
8382             throws NameNotFoundException;
8383 
8384     /**
8385      * Return the generic icon for an activity that is used when no specific
8386      * icon is defined.
8387      *
8388      * @return Drawable Image of the icon.
8389      */
8390     @NonNull
getDefaultActivityIcon()8391     public abstract Drawable getDefaultActivityIcon();
8392 
8393     /**
8394      * Retrieve the icon associated with an application.  If it has not defined
8395      * an icon, the default app icon is returned.  Does not return null.
8396      *
8397      * @param info Information about application being queried.
8398      *
8399      * @return Returns the image of the icon, or the default application icon
8400      * if it could not be found.
8401      *
8402      * @see #getApplicationIcon(String)
8403      */
8404     @NonNull
getApplicationIcon(@onNull ApplicationInfo info)8405     public abstract Drawable getApplicationIcon(@NonNull ApplicationInfo info);
8406 
8407     /**
8408      * Retrieve the icon associated with an application.  Given the name of the
8409      * application's package, retrieves the information about it and calls
8410      * getApplicationIcon() to return its icon. If the application cannot be
8411      * found, NameNotFoundException is thrown.
8412      *
8413      * @param packageName Name of the package whose application icon is to be
8414      *                    retrieved.
8415      *
8416      * @return Returns the image of the icon, or the default application icon
8417      * if it could not be found.  Does not return null.
8418      * @throws NameNotFoundException Thrown if the resources for the given
8419      * application could not be loaded.
8420      *
8421      * @see #getApplicationIcon(ApplicationInfo)
8422      */
8423     @NonNull
getApplicationIcon(@onNull String packageName)8424     public abstract Drawable getApplicationIcon(@NonNull String packageName)
8425             throws NameNotFoundException;
8426 
8427     /**
8428      * Retrieve the banner associated with an application.
8429      *
8430      * @param info Information about application being queried.
8431      * @return Returns the image of the banner or null if the application has no
8432      *         banner specified.
8433      * @see #getApplicationBanner(String)
8434      */
8435     @Nullable
getApplicationBanner(@onNull ApplicationInfo info)8436     public abstract Drawable getApplicationBanner(@NonNull ApplicationInfo info);
8437 
8438     /**
8439      * Retrieve the banner associated with an application. Given the name of the
8440      * application's package, retrieves the information about it and calls
8441      * getApplicationIcon() to return its banner. If the application cannot be
8442      * found, NameNotFoundException is thrown.
8443      *
8444      * @param packageName Name of the package whose application banner is to be
8445      *            retrieved.
8446      * @return Returns the image of the banner or null if the application has no
8447      *         banner specified.
8448      * @throws NameNotFoundException Thrown if the resources for the given
8449      *             application could not be loaded.
8450      * @see #getApplicationBanner(ApplicationInfo)
8451      */
8452     @Nullable
getApplicationBanner(@onNull String packageName)8453     public abstract Drawable getApplicationBanner(@NonNull String packageName)
8454             throws NameNotFoundException;
8455 
8456     /**
8457      * Retrieve the logo associated with an activity. Given the full name of an
8458      * activity, retrieves the information about it and calls
8459      * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
8460      * logo. If the activity cannot be found, NameNotFoundException is thrown.
8461      *
8462      * @param activityName Name of the activity whose logo is to be retrieved.
8463      * @return Returns the image of the logo or null if the activity has no logo
8464      *         specified.
8465      * @throws NameNotFoundException Thrown if the resources for the given
8466      *             activity could not be loaded.
8467      * @see #getActivityLogo(Intent)
8468      */
8469     @Nullable
getActivityLogo(@onNull ComponentName activityName)8470     public abstract Drawable getActivityLogo(@NonNull ComponentName activityName)
8471             throws NameNotFoundException;
8472 
8473     /**
8474      * Retrieve the logo associated with an Intent.  If intent.getClassName() is
8475      * set, this simply returns the result of
8476      * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
8477      * component and returns the logo associated with the resolved component.
8478      * If intent.getClassName() cannot be found or the Intent cannot be resolved
8479      * to a component, NameNotFoundException is thrown.
8480      *
8481      * @param intent The intent for which you would like to retrieve a logo.
8482      *
8483      * @return Returns the image of the logo, or null if the activity has no
8484      * logo specified.
8485      *
8486      * @throws NameNotFoundException Thrown if the resources for application
8487      * matching the given intent could not be loaded.
8488      *
8489      * @see #getActivityLogo(ComponentName)
8490      */
8491     @Nullable
getActivityLogo(@onNull Intent intent)8492     public abstract Drawable getActivityLogo(@NonNull Intent intent)
8493             throws NameNotFoundException;
8494 
8495     /**
8496      * Retrieve the logo associated with an application.  If it has not specified
8497      * a logo, this method returns null.
8498      *
8499      * @param info Information about application being queried.
8500      *
8501      * @return Returns the image of the logo, or null if no logo is specified
8502      * by the application.
8503      *
8504      * @see #getApplicationLogo(String)
8505      */
8506     @Nullable
getApplicationLogo(@onNull ApplicationInfo info)8507     public abstract Drawable getApplicationLogo(@NonNull ApplicationInfo info);
8508 
8509     /**
8510      * Retrieve the logo associated with an application.  Given the name of the
8511      * application's package, retrieves the information about it and calls
8512      * getApplicationLogo() to return its logo. If the application cannot be
8513      * found, NameNotFoundException is thrown.
8514      *
8515      * @param packageName Name of the package whose application logo is to be
8516      *                    retrieved.
8517      *
8518      * @return Returns the image of the logo, or null if no application logo
8519      * has been specified.
8520      *
8521      * @throws NameNotFoundException Thrown if the resources for the given
8522      * application could not be loaded.
8523      *
8524      * @see #getApplicationLogo(ApplicationInfo)
8525      */
8526     @Nullable
getApplicationLogo(@onNull String packageName)8527     public abstract Drawable getApplicationLogo(@NonNull String packageName)
8528             throws NameNotFoundException;
8529 
8530     /**
8531      * If the target user is a managed profile, then this returns a badged copy of the given icon
8532      * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
8533      * {@link #getUserBadgedDrawableForDensity(
8534      * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
8535      * <p>
8536      * If the original drawable is a BitmapDrawable and the backing bitmap is
8537      * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
8538      * is performed in place and the original drawable is returned.
8539      * </p>
8540      *
8541      * @param drawable The drawable to badge.
8542      * @param user The target user.
8543      * @return A drawable that combines the original icon and a badge as
8544      *         determined by the system.
8545      */
8546     @NonNull
getUserBadgedIcon(@onNull Drawable drawable, @NonNull UserHandle user)8547     public abstract Drawable getUserBadgedIcon(@NonNull Drawable drawable,
8548             @NonNull UserHandle user);
8549 
8550     /**
8551      * If the target user is a managed profile of the calling user or the caller
8552      * is itself a managed profile, then this returns a badged copy of the given
8553      * drawable allowing the user to distinguish it from the original drawable.
8554      * The caller can specify the location in the bounds of the drawable to be
8555      * badged where the badge should be applied as well as the density of the
8556      * badge to be used.
8557      * <p>
8558      * If the original drawable is a BitmapDrawable and the backing bitmap is
8559      * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
8560      * is performed in place and the original drawable is returned.
8561      * </p>
8562      *
8563      * @param drawable The drawable to badge.
8564      * @param user The target user.
8565      * @param badgeLocation Where in the bounds of the badged drawable to place
8566      *         the badge. If it's {@code null}, the badge is applied on top of the entire
8567      *         drawable being badged.
8568      * @param badgeDensity The optional desired density for the badge as per
8569      *         {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
8570      *         the density of the display is used.
8571      * @return A drawable that combines the original drawable and a badge as
8572      *         determined by the system.
8573      */
8574     @NonNull
getUserBadgedDrawableForDensity(@onNull Drawable drawable, @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity)8575     public abstract Drawable getUserBadgedDrawableForDensity(@NonNull Drawable drawable,
8576             @NonNull UserHandle user, @Nullable Rect badgeLocation, int badgeDensity);
8577 
8578     /**
8579      * If the target user is a managed profile of the calling user or the caller
8580      * is itself a managed profile, then this returns a drawable to use as a small
8581      * icon to include in a view to distinguish it from the original icon.
8582      *
8583      * @param user The target user.
8584      * @param density The optional desired density for the badge as per
8585      *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
8586      *         the density of the current display is used.
8587      * @return the drawable or null if no drawable is required.
8588      * @hide
8589      */
8590     @SuppressWarnings("HiddenAbstractMethod")
8591     @Nullable
8592     @UnsupportedAppUsage
getUserBadgeForDensity(@onNull UserHandle user, int density)8593     public abstract Drawable getUserBadgeForDensity(@NonNull UserHandle user, int density);
8594 
8595     /**
8596      * If the target user is a managed profile of the calling user or the caller
8597      * is itself a managed profile, then this returns a drawable to use as a small
8598      * icon to include in a view to distinguish it from the original icon. This version
8599      * doesn't have background protection and should be used over a light background instead of
8600      * a badge.
8601      *
8602      * @param user The target user.
8603      * @param density The optional desired density for the badge as per
8604      *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
8605      *         the density of the current display is used.
8606      * @return the drawable or null if no drawable is required.
8607      * @hide
8608      */
8609     @SuppressWarnings("HiddenAbstractMethod")
8610     @Nullable
8611     @UnsupportedAppUsage
getUserBadgeForDensityNoBackground(@onNull UserHandle user, int density)8612     public abstract Drawable getUserBadgeForDensityNoBackground(@NonNull UserHandle user,
8613             int density);
8614 
8615     /**
8616      * If the target user is a managed profile of the calling user or the caller
8617      * is itself a managed profile, then this returns a copy of the label with
8618      * badging for accessibility services like talkback. E.g. passing in "Email"
8619      * and it might return "Work Email" for Email in the work profile.
8620      *
8621      * @param label The label to change.
8622      * @param user The target user.
8623      * @return A label that combines the original label and a badge as
8624      *         determined by the system.
8625      */
8626     @NonNull
getUserBadgedLabel(@onNull CharSequence label, @NonNull UserHandle user)8627     public abstract CharSequence getUserBadgedLabel(@NonNull CharSequence label,
8628             @NonNull UserHandle user);
8629 
8630     /**
8631      * Retrieve text from a package.  This is a low-level API used by
8632      * the various package manager info structures (such as
8633      * {@link ComponentInfo} to implement retrieval of their associated
8634      * labels and other text.
8635      *
8636      * @param packageName The name of the package that this text is coming from.
8637      * Cannot be null.
8638      * @param resid The resource identifier of the desired text.  Cannot be 0.
8639      * @param appInfo Overall information about <var>packageName</var>.  This
8640      * may be null, in which case the application information will be retrieved
8641      * for you if needed; if you already have this information around, it can
8642      * be much more efficient to supply it here.
8643      *
8644      * @return Returns a CharSequence holding the requested text.  Returns null
8645      * if the text could not be found for any reason.
8646      */
8647     @Nullable
getText(@onNull String packageName, @StringRes int resid, @Nullable ApplicationInfo appInfo)8648     public abstract CharSequence getText(@NonNull String packageName, @StringRes int resid,
8649             @Nullable ApplicationInfo appInfo);
8650 
8651     /**
8652      * Retrieve an XML file from a package.  This is a low-level API used to
8653      * retrieve XML meta data.
8654      *
8655      * @param packageName The name of the package that this xml is coming from.
8656      * Cannot be null.
8657      * @param resid The resource identifier of the desired xml.  Cannot be 0.
8658      * @param appInfo Overall information about <var>packageName</var>.  This
8659      * may be null, in which case the application information will be retrieved
8660      * for you if needed; if you already have this information around, it can
8661      * be much more efficient to supply it here.
8662      *
8663      * @return Returns an XmlPullParser allowing you to parse out the XML
8664      * data.  Returns null if the xml resource could not be found for any
8665      * reason.
8666      */
8667     @Nullable
getXml(@onNull String packageName, @XmlRes int resid, @Nullable ApplicationInfo appInfo)8668     public abstract XmlResourceParser getXml(@NonNull String packageName, @XmlRes int resid,
8669             @Nullable ApplicationInfo appInfo);
8670 
8671     /**
8672      * Return the label to use for this application.
8673      *
8674      * @return Returns a {@link CharSequence} containing the label associated with
8675      * this application, or its name the  item does not have a label.
8676      * @param info The {@link ApplicationInfo} of the application to get the label of.
8677      */
8678     @NonNull
getApplicationLabel(@onNull ApplicationInfo info)8679     public abstract CharSequence getApplicationLabel(@NonNull ApplicationInfo info);
8680 
8681     /**
8682      * Retrieve the resources associated with an activity.  Given the full
8683      * name of an activity, retrieves the information about it and calls
8684      * getResources() to return its application's resources.  If the activity
8685      * cannot be found, NameNotFoundException is thrown.
8686      *
8687      * @param activityName Name of the activity whose resources are to be
8688      *                     retrieved.
8689      *
8690      * @return Returns the application's Resources.
8691      * @throws NameNotFoundException Thrown if the resources for the given
8692      * application could not be loaded.
8693      *
8694      * @see #getResourcesForApplication(ApplicationInfo)
8695      */
8696     @NonNull
getResourcesForActivity(@onNull ComponentName activityName)8697     public abstract Resources getResourcesForActivity(@NonNull ComponentName activityName)
8698             throws NameNotFoundException;
8699 
8700     /**
8701      * Retrieve the resources for an application.  Throws NameNotFoundException
8702      * if the package is no longer installed.
8703      *
8704      * @param app Information about the desired application.
8705      *
8706      * @return Returns the application's Resources.
8707      * @throws NameNotFoundException Thrown if the resources for the given
8708      * application could not be loaded (most likely because it was uninstalled).
8709      */
8710     @NonNull
getResourcesForApplication(@onNull ApplicationInfo app)8711     public abstract Resources getResourcesForApplication(@NonNull ApplicationInfo app)
8712             throws NameNotFoundException;
8713 
8714     /**
8715      * Retrieve the resources for an application for the provided configuration.
8716      *
8717      * @param app Information about the desired application.
8718      * @param configuration Overridden configuration when loading the Resources
8719      *
8720      * @return Returns the application's Resources.
8721      * @throws NameNotFoundException Thrown if the resources for the given
8722      * application could not be loaded (most likely because it was uninstalled).
8723      */
8724     @NonNull
getResourcesForApplication(@onNull ApplicationInfo app, @Nullable Configuration configuration)8725     public Resources getResourcesForApplication(@NonNull ApplicationInfo app, @Nullable
8726             Configuration configuration) throws NameNotFoundException {
8727         return getResourcesForApplication(app);
8728     }
8729 
8730     /**
8731      * Retrieve the resources associated with an application.  Given the full
8732      * package name of an application, retrieves the information about it and
8733      * calls getResources() to return its application's resources.  If the
8734      * appPackageName cannot be found, NameNotFoundException is thrown.
8735      *
8736      * @param packageName Package name of the application whose resources
8737      *                       are to be retrieved.
8738      *
8739      * @return Returns the application's Resources.
8740      * @throws NameNotFoundException Thrown if the resources for the given
8741      * application could not be loaded.
8742      *
8743      * @see #getResourcesForApplication(ApplicationInfo)
8744      */
8745     @NonNull
getResourcesForApplication(@onNull String packageName)8746     public abstract Resources getResourcesForApplication(@NonNull String packageName)
8747             throws NameNotFoundException;
8748 
8749     /**
8750      * Please don't use this function because it is no longer supported.
8751      *
8752      * @deprecated Instead of using this function, please use
8753      *             {@link Context#createContextAsUser(UserHandle, int)} to create the specified user
8754      *             context, {@link Context#getPackageManager()} to get PackageManager instance for
8755      *             the specified user, and then
8756      *             {@link PackageManager#getResourcesForApplication(String)} to get the same
8757      *             Resources instance.
8758      * @see {@link Context#createContextAsUser(android.os.UserHandle, int)}
8759      * @see {@link Context#getPackageManager()}
8760      * @see {@link android.content.pm.PackageManager#getResourcesForApplication(java.lang.String)}
8761      * TODO(b/170852794): mark maxTargetSdk as {@code Build.VERSION_CODES.S}
8762      * @hide
8763      */
8764     @SuppressWarnings("HiddenAbstractMethod")
8765     @NonNull
8766     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170928809,
8767             publicAlternatives = "Use {@code Context#createContextAsUser(UserHandle, int)}"
8768                     + " to create the relevant user context,"
8769                     + " {@link android.content.Context#getPackageManager()} and"
8770                     + " {@link android.content.pm.PackageManager#getResourcesForApplication("
8771                     + "java.lang.String)}"
8772                     + " instead.")
8773     @Deprecated
getResourcesForApplicationAsUser(@onNull String packageName, @UserIdInt int userId)8774     public abstract Resources getResourcesForApplicationAsUser(@NonNull String packageName,
8775             @UserIdInt int userId) throws NameNotFoundException;
8776 
8777     /**
8778      * Retrieve overall information about an application package defined in a
8779      * package archive file
8780      *
8781      * Use {@link #getPackageArchiveInfo(String, PackageInfoFlags)} when long flags are needed.
8782      *
8783      * @param archiveFilePath The path to the archive file
8784      * @param flags Additional option flags to modify the data returned.
8785      * @return A PackageInfo object containing information about the package
8786      *         archive. If the package could not be parsed, returns null.
8787      */
8788     @Nullable
getPackageArchiveInfo(@onNull String archiveFilePath, int flags)8789     public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath, int flags) {
8790         return getPackageArchiveInfo(archiveFilePath, PackageInfoFlags.of(flags));
8791     }
8792 
8793     /**
8794      * See {@link #getPackageArchiveInfo(String, int)}.
8795      */
8796     @Nullable
getPackageArchiveInfo(@onNull String archiveFilePath, @NonNull PackageInfoFlags flags)8797     public PackageInfo getPackageArchiveInfo(@NonNull String archiveFilePath,
8798             @NonNull PackageInfoFlags flags) {
8799         final File apkFile = new File(archiveFilePath);
8800 
8801         @PackageInfoFlagsBits long flagsBits = flags.getValue();
8802         if ((flagsBits & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
8803             // Caller expressed an explicit opinion about what encryption
8804             // aware/unaware components they want to see, so fall through and
8805             // give them what they want
8806         } else {
8807             // Caller expressed no opinion, so match everything
8808             flagsBits |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
8809         }
8810 
8811         int parserFlags = 0;
8812         if ((flagsBits & (GET_SIGNATURES | GET_SIGNING_CERTIFICATES)) != 0) {
8813             parserFlags |= PARSE_COLLECT_CERTIFICATES;
8814         }
8815 
8816         final PackageParser2 parser2 = new PackageParser2(/*separateProcesses*/ null,
8817                 /*displayMetrics*/ null,/*cacher*/ null,
8818                 new PackageParser2.Callback() {
8819                     @Override
8820                     public boolean hasFeature(String feature) {
8821                         return PackageManager.this.hasSystemFeature(feature);
8822                     }
8823 
8824                     @NonNull
8825                     @Override
8826                     public Set<String> getHiddenApiWhitelistedApps() {
8827                         return Collections.emptySet();
8828                     }
8829 
8830                     @NonNull
8831                     @Override
8832                     public Set<String> getInstallConstraintsAllowlist() {
8833                         return Collections.emptySet();
8834                     }
8835 
8836                     @Override
8837                     public boolean isChangeEnabled(long changeId,
8838                             @androidx.annotation.NonNull ApplicationInfo appInfo) {
8839                         return false;
8840                     }
8841                 });
8842 
8843         try {
8844             ParsedPackage pp = parser2.parsePackage(apkFile, parserFlags, false);
8845 
8846             return PackageInfoCommonUtils.generate(pp, flagsBits, UserHandle.myUserId());
8847         } catch (PackageParserException e) {
8848             Log.w(TAG, "Failure to parse package archive apkFile= " +apkFile);
8849             return null;
8850         }
8851     }
8852 
8853     /**
8854      * If there is already an application with the given package name installed
8855      * on the system for other users, also install it for the calling user.
8856      * @hide
8857      *
8858      * @deprecated use {@link PackageInstaller#installExistingPackage()} instead.
8859      */
8860     @SuppressWarnings("HiddenAbstractMethod")
8861     @Deprecated
8862     @SystemApi
installExistingPackage(@onNull String packageName)8863     public abstract int installExistingPackage(@NonNull String packageName)
8864             throws NameNotFoundException;
8865 
8866     /**
8867      * If there is already an application with the given package name installed
8868      * on the system for other users, also install it for the calling user.
8869      * @hide
8870      *
8871      * @deprecated use {@link PackageInstaller#installExistingPackage()} instead.
8872      */
8873     @SuppressWarnings("HiddenAbstractMethod")
8874     @Deprecated
8875     @SystemApi
installExistingPackage(@onNull String packageName, @InstallReason int installReason)8876     public abstract int installExistingPackage(@NonNull String packageName,
8877             @InstallReason int installReason) throws NameNotFoundException;
8878 
8879     /**
8880      * If there is already an application with the given package name installed
8881      * on the system for other users, also install it for the specified user.
8882      * @hide
8883      *
8884      * @deprecated use {@link PackageInstaller#installExistingPackage()} instead.
8885      */
8886     @SuppressWarnings("HiddenAbstractMethod")
8887     @Deprecated
8888     @RequiresPermission(anyOf = {
8889             Manifest.permission.INSTALL_EXISTING_PACKAGES,
8890             Manifest.permission.INSTALL_PACKAGES,
8891             Manifest.permission.INTERACT_ACROSS_USERS_FULL})
8892     @UnsupportedAppUsage
installExistingPackageAsUser(@onNull String packageName, @UserIdInt int userId)8893     public abstract int installExistingPackageAsUser(@NonNull String packageName,
8894             @UserIdInt int userId) throws NameNotFoundException;
8895 
8896     /**
8897      * Allows a package listening to the
8898      * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
8899      * broadcast} to respond to the package manager. The response must include
8900      * the {@code verificationCode} which is one of
8901      * {@link PackageManager#VERIFICATION_ALLOW} or
8902      * {@link PackageManager#VERIFICATION_REJECT}.
8903      *
8904      * @param id pending package identifier as passed via the
8905      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
8906      * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
8907      *            or {@link PackageManager#VERIFICATION_REJECT}.
8908      * @throws SecurityException if the caller does not have the
8909      *            PACKAGE_VERIFICATION_AGENT permission.
8910      */
verifyPendingInstall(int id, int verificationCode)8911     public abstract void verifyPendingInstall(int id, int verificationCode);
8912 
8913     /**
8914      * Allows a package listening to the
8915      * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
8916      * broadcast} to extend the default timeout for a response and declare what
8917      * action to perform after the timeout occurs. The response must include
8918      * the {@code verificationCodeAtTimeout} which is one of
8919      * {@link PackageManager#VERIFICATION_ALLOW} or
8920      * {@link PackageManager#VERIFICATION_REJECT}.
8921      *
8922      * This method may only be called once per package id. Additional calls
8923      * will have no effect.
8924      *
8925      * @param id pending package identifier as passed via the
8926      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
8927      * @param verificationCodeAtTimeout either
8928      *            {@link PackageManager#VERIFICATION_ALLOW} or
8929      *            {@link PackageManager#VERIFICATION_REJECT}. If
8930      *            {@code verificationCodeAtTimeout} is neither
8931      *            {@link PackageManager#VERIFICATION_ALLOW} or
8932      *            {@link PackageManager#VERIFICATION_REJECT}, then
8933      *            {@code verificationCodeAtTimeout} will default to
8934      *            {@link PackageManager#VERIFICATION_REJECT}.
8935      * @param millisecondsToDelay the amount of time requested for the timeout.
8936      *            Must be positive and less than
8937      *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
8938      *            {@code millisecondsToDelay} is out of bounds,
8939      *            {@code millisecondsToDelay} will be set to the closest in
8940      *            bounds value; namely, 0 or
8941      *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
8942      * @throws SecurityException if the caller does not have the
8943      *            PACKAGE_VERIFICATION_AGENT permission.
8944      */
extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay)8945     public abstract void extendVerificationTimeout(int id,
8946             int verificationCodeAtTimeout, long millisecondsToDelay);
8947 
8948     /**
8949      * Allows a package listening to the
8950      * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
8951      * broadcast to respond to the package manager. The response must include
8952      * the {@code verificationCode} which is one of
8953      * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
8954      * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
8955      *
8956      * @param verificationId pending package identifier as passed via the
8957      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
8958      * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
8959      *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
8960      * @param failedDomains a list of failed domains if the verificationCode is
8961      *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
8962      * @throws SecurityException if the caller does not have the
8963      *            INTENT_FILTER_VERIFICATION_AGENT permission.
8964      *
8965      * @deprecated Use {@link DomainVerificationManager} APIs.
8966      * @hide
8967      */
8968     @Deprecated
8969     @SuppressWarnings("HiddenAbstractMethod")
8970     @SystemApi
8971     @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT)
verifyIntentFilter(int verificationId, int verificationCode, @NonNull List<String> failedDomains)8972     public abstract void verifyIntentFilter(int verificationId, int verificationCode,
8973             @NonNull List<String> failedDomains);
8974 
8975     /**
8976      * Get the status of a Domain Verification Result for an IntentFilter. This is
8977      * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
8978      * {@link android.content.IntentFilter#getAutoVerify()}
8979      *
8980      * This is used by the ResolverActivity to change the status depending on what the User select
8981      * in the Disambiguation Dialog and also used by the Settings App for changing the default App
8982      * for a domain.
8983      *
8984      * @param packageName The package name of the Activity associated with the IntentFilter.
8985      * @param userId The user id.
8986      *
8987      * @return The status to set to. This can be
8988      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
8989      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
8990      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
8991      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
8992      *
8993      * @deprecated Use {@link DomainVerificationManager} APIs.
8994      * @hide
8995      */
8996     @Deprecated
8997     @SuppressWarnings("HiddenAbstractMethod")
8998     @SystemApi
8999     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
getIntentVerificationStatusAsUser(@onNull String packageName, @UserIdInt int userId)9000     public abstract int getIntentVerificationStatusAsUser(@NonNull String packageName,
9001             @UserIdInt int userId);
9002 
9003     /**
9004      * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
9005      * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
9006      * {@link android.content.IntentFilter#getAutoVerify()}
9007      *
9008      * This is used by the ResolverActivity to change the status depending on what the User select
9009      * in the Disambiguation Dialog and also used by the Settings App for changing the default App
9010      * for a domain.
9011      *
9012      * @param packageName The package name of the Activity associated with the IntentFilter.
9013      * @param status The status to set to. This can be
9014      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
9015      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
9016      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
9017      * @param userId The user id.
9018      *
9019      * @return true if the status has been set. False otherwise.
9020      *
9021      * @deprecated This API represents a very dangerous behavior where Settings or a system app with
9022      * the right permissions can force an application to be verified for all of its declared
9023      * domains. This has been removed to prevent unintended usage, and no longer does anything,
9024      * always returning false. If a caller truly wishes to grant <i></i>every</i> declared web
9025      * domain to an application, use
9026      * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, Set, boolean)},
9027      * passing in all of the domains returned inside
9028      * {@link DomainVerificationManager#getDomainVerificationUserState(String)}.
9029      *
9030      * @hide
9031      */
9032     @Deprecated
9033     @SuppressWarnings("HiddenAbstractMethod")
9034     @SystemApi
9035     @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
updateIntentVerificationStatusAsUser(@onNull String packageName, int status, @UserIdInt int userId)9036     public abstract boolean updateIntentVerificationStatusAsUser(@NonNull String packageName,
9037             int status, @UserIdInt int userId);
9038 
9039     /**
9040      * Get the list of IntentFilterVerificationInfo for a specific package and User.
9041      *
9042      * @param packageName the package name. When this parameter is set to a non null value,
9043      *                    the results will be filtered by the package name provided.
9044      *                    Otherwise, there will be no filtering and it will return a list
9045      *                    corresponding for all packages
9046      *
9047      * @return a list of IntentFilterVerificationInfo for a specific package.
9048      *
9049      * @deprecated Use {@link DomainVerificationManager} instead.
9050      * @hide
9051      */
9052     @Deprecated
9053     @SuppressWarnings("HiddenAbstractMethod")
9054     @NonNull
9055     @SystemApi
getIntentFilterVerifications( @onNull String packageName)9056     public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
9057             @NonNull String packageName);
9058 
9059     /**
9060      * Get the list of IntentFilter for a specific package.
9061      *
9062      * @param packageName the package name. This parameter is set to a non null value,
9063      *                    the list will contain all the IntentFilter for that package.
9064      *                    Otherwise, the list will be empty.
9065      *
9066      * @return a list of IntentFilter for a specific package.
9067      *
9068      * @hide
9069      */
9070     @SuppressWarnings("HiddenAbstractMethod")
9071     @NonNull
9072     @SystemApi
getAllIntentFilters(@onNull String packageName)9073     public abstract List<IntentFilter> getAllIntentFilters(@NonNull String packageName);
9074 
9075     /**
9076      * Get the default Browser package name for a specific user.
9077      *
9078      * @param userId The user id.
9079      *
9080      * @return the package name of the default Browser for the specified user. If the user id passed
9081      *         is -1 (all users) it will return a null value.
9082      *
9083      * @hide
9084      */
9085     @SuppressWarnings("HiddenAbstractMethod")
9086     @Nullable
9087     @SystemApi
9088     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
getDefaultBrowserPackageNameAsUser(@serIdInt int userId)9089     public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
9090 
9091     /**
9092      * Set the default Browser package name for a specific user.
9093      *
9094      * @param packageName The package name of the default Browser.
9095      * @param userId The user id.
9096      *
9097      * @return true if the default Browser for the specified user has been set,
9098      *         otherwise return false. If the user id passed is -1 (all users) this call will not
9099      *         do anything and just return false.
9100      *
9101      * @hide
9102      */
9103     @SuppressWarnings("HiddenAbstractMethod")
9104     @SystemApi
9105     @RequiresPermission(allOf = {
9106             Manifest.permission.SET_PREFERRED_APPLICATIONS,
9107             Manifest.permission.INTERACT_ACROSS_USERS_FULL})
setDefaultBrowserPackageNameAsUser(@ullable String packageName, @UserIdInt int userId)9108     public abstract boolean setDefaultBrowserPackageNameAsUser(@Nullable String packageName,
9109             @UserIdInt int userId);
9110 
9111     /**
9112      * Change the installer associated with a given package.  There are limitations
9113      * on how the installer package can be changed; in particular:
9114      * <ul>
9115      * <li> A SecurityException will be thrown if <var>installerPackageName</var>
9116      * is not signed with the same certificate as the calling application.
9117      * <li> A SecurityException will be thrown if <var>targetPackage</var> already
9118      * has an installer package, and that installer package is not signed with
9119      * the same certificate as the calling application.
9120      * </ul>
9121      *
9122      * @param targetPackage The installed package whose installer will be changed.
9123      * @param installerPackageName The package name of the new installer.  May be
9124      * null to clear the association.
9125      */
setInstallerPackageName(@onNull String targetPackage, @Nullable String installerPackageName)9126     public abstract void setInstallerPackageName(@NonNull String targetPackage,
9127             @Nullable String installerPackageName);
9128 
9129     /** @hide */
9130     @SuppressWarnings("HiddenAbstractMethod")
9131     @SystemApi
9132     @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
setUpdateAvailable(@onNull String packageName, boolean updateAvaialble)9133     public abstract void setUpdateAvailable(@NonNull String packageName, boolean updateAvaialble);
9134 
9135     /**
9136      * Attempts to delete a package. Since this may take a little while, the
9137      * result will be posted back to the given observer. A deletion will fail if
9138      * the calling context lacks the
9139      * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
9140      * named package cannot be found, or if the named package is a system
9141      * package.
9142      *
9143      * @param packageName The name of the package to delete
9144      * @param observer An observer callback to get notified when the package
9145      *            deletion is complete.
9146      *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
9147      *            will be called when that happens. observer may be null to
9148      *            indicate that no callback is desired.
9149      * @hide
9150      */
9151     @SuppressWarnings("HiddenAbstractMethod")
9152     @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
9153     @UnsupportedAppUsage
deletePackage(@onNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags)9154     public abstract void deletePackage(@NonNull String packageName,
9155             @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags);
9156 
9157     /**
9158      * Attempts to delete a package. Since this may take a little while, the
9159      * result will be posted back to the given observer. A deletion will fail if
9160      * the named package cannot be found, or if the named package is a system
9161      * package.
9162      *
9163      * @param packageName The name of the package to delete
9164      * @param observer An observer callback to get notified when the package
9165      *            deletion is complete.
9166      *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
9167      *            will be called when that happens. observer may be null to
9168      *            indicate that no callback is desired.
9169      * @param userId The user Id
9170      * @hide
9171      */
9172     @SuppressWarnings("HiddenAbstractMethod")
9173     @RequiresPermission(anyOf = {
9174             Manifest.permission.DELETE_PACKAGES,
9175             Manifest.permission.INTERACT_ACROSS_USERS_FULL})
9176     @UnsupportedAppUsage
deletePackageAsUser(@onNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId)9177     public abstract void deletePackageAsUser(@NonNull String packageName,
9178             @Nullable IPackageDeleteObserver observer, @DeleteFlags int flags,
9179             @UserIdInt int userId);
9180 
9181     /**
9182      * Retrieve the package name of the application that installed a package. This identifies
9183      * which market the package came from.
9184      *
9185      * @param packageName The name of the package to query
9186      * @throws IllegalArgumentException if the given package name is not installed
9187      *
9188      * @deprecated use {@link #getInstallSourceInfo(String)} instead
9189      */
9190     @SuppressWarnings("HiddenAbstractMethod")
9191     @Deprecated
9192     @Nullable
getInstallerPackageName(@onNull String packageName)9193     public abstract String getInstallerPackageName(@NonNull String packageName);
9194 
9195     /**
9196      * Retrieves information about how a package was installed or updated.
9197      * <p>
9198      * If the calling application does not hold the INSTALL_PACKAGES permission then
9199      * the result will always return {@code null} from
9200      * {@link InstallSourceInfo#getOriginatingPackageName()}.
9201      * <p>
9202      * If the package that requested the install has been uninstalled, then information about it
9203      * will only be returned from {@link InstallSourceInfo#getInitiatingPackageName()} and
9204      * {@link InstallSourceInfo#getInitiatingPackageSigningInfo()} if the calling package is
9205      * requesting its own install information and is not an instant app.
9206      *
9207      * @param packageName The name of the package to query
9208      * @throws NameNotFoundException if the given package name is not available to the caller.
9209      */
9210     @NonNull
getInstallSourceInfo(@onNull String packageName)9211     public InstallSourceInfo getInstallSourceInfo(@NonNull String packageName)
9212             throws NameNotFoundException {
9213         throw new UnsupportedOperationException("getInstallSourceInfo not implemented");
9214     }
9215 
9216     /**
9217      * Returns true if an app is archivable.
9218      *
9219      * @throws NameNotFoundException if the given package name is not available to the caller.
9220      * @see PackageInstaller#requestArchive
9221      */
9222     @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING)
isAppArchivable(@onNull String packageName)9223     public boolean isAppArchivable(@NonNull String packageName) throws NameNotFoundException {
9224         throw new UnsupportedOperationException("isAppArchivable not implemented");
9225     }
9226 
9227     /**
9228      * Attempts to clear the user data directory of an application.
9229      * Since this may take a little while, the result will
9230      * be posted back to the given observer.  A deletion will fail if the
9231      * named package cannot be found, or if the named package is a "system package".
9232      *
9233      * @param packageName The name of the package
9234      * @param observer An observer callback to get notified when the operation is finished
9235      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
9236      * will be called when that happens.  observer may be null to indicate that
9237      * no callback is desired.
9238      *
9239      * @hide
9240      */
9241     @SuppressWarnings("HiddenAbstractMethod")
9242     @UnsupportedAppUsage
clearApplicationUserData(@onNull String packageName, @Nullable IPackageDataObserver observer)9243     public abstract void clearApplicationUserData(@NonNull String packageName,
9244             @Nullable IPackageDataObserver observer);
9245     /**
9246      * Attempts to delete the cache files associated with an application.
9247      * Since this may take a little while, the result will
9248      * be posted back to the given observer.  A deletion will fail if the calling context
9249      * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
9250      * named package cannot be found, or if the named package is a "system package".
9251      *
9252      * @param packageName The name of the package to delete
9253      * @param observer An observer callback to get notified when the cache file deletion
9254      * is complete.
9255      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
9256      * will be called when that happens.  observer may be null to indicate that
9257      * no callback is desired.
9258      *
9259      * @hide
9260      */
9261     @SuppressWarnings("HiddenAbstractMethod")
9262     @UnsupportedAppUsage
deleteApplicationCacheFiles(@onNull String packageName, @Nullable IPackageDataObserver observer)9263     public abstract void deleteApplicationCacheFiles(@NonNull String packageName,
9264             @Nullable IPackageDataObserver observer);
9265 
9266     /**
9267      * Attempts to delete the cache files associated with an application for a given user. Since
9268      * this may take a little while, the result will be posted back to the given observer. A
9269      * deletion will fail if the calling context lacks the
9270      * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
9271      * cannot be found, or if the named package is a "system package". If {@code userId} does not
9272      * belong to the calling user, the caller must have
9273      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
9274      *
9275      * @param packageName The name of the package to delete
9276      * @param userId the user for which the cache files needs to be deleted
9277      * @param observer An observer callback to get notified when the cache file deletion is
9278      *            complete.
9279      *            {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
9280      *            will be called when that happens. observer may be null to indicate that no
9281      *            callback is desired.
9282      * @hide
9283      */
9284     @SuppressWarnings("HiddenAbstractMethod")
9285     @UnsupportedAppUsage
deleteApplicationCacheFilesAsUser(@onNull String packageName, @UserIdInt int userId, @Nullable IPackageDataObserver observer)9286     public abstract void deleteApplicationCacheFilesAsUser(@NonNull String packageName,
9287             @UserIdInt int userId, @Nullable IPackageDataObserver observer);
9288 
9289     /**
9290      * Free storage by deleting LRU sorted list of cache files across
9291      * all applications. If the currently available free storage
9292      * on the device is greater than or equal to the requested
9293      * free storage, no cache files are cleared. If the currently
9294      * available storage on the device is less than the requested
9295      * free storage, some or all of the cache files across
9296      * all applications are deleted (based on last accessed time)
9297      * to increase the free storage space on the device to
9298      * the requested value. There is no guarantee that clearing all
9299      * the cache files from all applications will clear up
9300      * enough storage to achieve the desired value.
9301      * @param freeStorageSize The number of bytes of storage to be
9302      * freed by the system. Say if freeStorageSize is XX,
9303      * and the current free storage is YY,
9304      * if XX is less than YY, just return. if not free XX-YY number
9305      * of bytes if possible.
9306      * @param observer call back used to notify when
9307      * the operation is completed
9308      *
9309      * @hide
9310      */
9311     @UnsupportedAppUsage
freeStorageAndNotify(long freeStorageSize, @Nullable IPackageDataObserver observer)9312     public void freeStorageAndNotify(long freeStorageSize,
9313             @Nullable IPackageDataObserver observer) {
9314         freeStorageAndNotify(null, freeStorageSize, observer);
9315     }
9316 
9317     /** {@hide} */
9318     @SuppressWarnings("HiddenAbstractMethod")
9319     @UnsupportedAppUsage
freeStorageAndNotify(@ullable String volumeUuid, long freeStorageSize, @Nullable IPackageDataObserver observer)9320     public abstract void freeStorageAndNotify(@Nullable String volumeUuid, long freeStorageSize,
9321             @Nullable IPackageDataObserver observer);
9322 
9323     /**
9324      * Free storage by deleting LRU sorted list of cache files across
9325      * all applications. If the currently available free storage
9326      * on the device is greater than or equal to the requested
9327      * free storage, no cache files are cleared. If the currently
9328      * available storage on the device is less than the requested
9329      * free storage, some or all of the cache files across
9330      * all applications are deleted (based on last accessed time)
9331      * to increase the free storage space on the device to
9332      * the requested value. There is no guarantee that clearing all
9333      * the cache files from all applications will clear up
9334      * enough storage to achieve the desired value.
9335      * @param freeStorageSize The number of bytes of storage to be
9336      * freed by the system. Say if freeStorageSize is XX,
9337      * and the current free storage is YY,
9338      * if XX is less than YY, just return. if not free XX-YY number
9339      * of bytes if possible.
9340      * @param pi IntentSender call back used to
9341      * notify when the operation is completed.May be null
9342      * to indicate that no call back is desired.
9343      *
9344      * @hide
9345      */
9346     @UnsupportedAppUsage
freeStorage(long freeStorageSize, @Nullable IntentSender pi)9347     public void freeStorage(long freeStorageSize, @Nullable IntentSender pi) {
9348         freeStorage(null, freeStorageSize, pi);
9349     }
9350 
9351     /** {@hide} */
9352     @SuppressWarnings("HiddenAbstractMethod")
9353     @UnsupportedAppUsage
freeStorage(@ullable String volumeUuid, long freeStorageSize, @Nullable IntentSender pi)9354     public abstract void freeStorage(@Nullable String volumeUuid, long freeStorageSize,
9355             @Nullable IntentSender pi);
9356 
9357     /**
9358      * Retrieve the size information for a package.
9359      * Since this may take a little while, the result will
9360      * be posted back to the given observer.  The calling context
9361      * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
9362      *
9363      * @param packageName The name of the package whose size information is to be retrieved
9364      * @param userId The user whose size information should be retrieved.
9365      * @param observer An observer callback to get notified when the operation
9366      * is complete.
9367      * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
9368      * The observer's callback is invoked with a PackageStats object(containing the
9369      * code, data and cache sizes of the package) and a boolean value representing
9370      * the status of the operation. observer may be null to indicate that
9371      * no callback is desired.
9372      *
9373      * @deprecated use {@link StorageStatsManager} instead.
9374      * @hide
9375      */
9376     @SuppressWarnings("HiddenAbstractMethod")
9377     @Deprecated
9378     @UnsupportedAppUsage
getPackageSizeInfoAsUser(@onNull String packageName, @UserIdInt int userId, @Nullable IPackageStatsObserver observer)9379     public abstract void getPackageSizeInfoAsUser(@NonNull String packageName,
9380             @UserIdInt int userId, @Nullable IPackageStatsObserver observer);
9381 
9382     /**
9383      * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
9384      * returns the size for the calling user.
9385      *
9386      * @deprecated use {@link StorageStatsManager} instead.
9387      * @hide
9388      */
9389     @Deprecated
9390     @UnsupportedAppUsage
getPackageSizeInfo(@onNull String packageName, IPackageStatsObserver observer)9391     public void getPackageSizeInfo(@NonNull String packageName, IPackageStatsObserver observer) {
9392         getPackageSizeInfoAsUser(packageName, getUserId(), observer);
9393     }
9394 
9395     /**
9396      * @deprecated This function no longer does anything. It is the platform's
9397      * responsibility to assign preferred activities and this cannot be modified
9398      * directly. To determine the activities resolved by the platform, use
9399      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9400      * an app to be responsible for a particular role and to check current role
9401      * holders, see {@link android.app.role.RoleManager}.
9402      */
9403     @Deprecated
addPackageToPreferred(@onNull String packageName)9404     public abstract void addPackageToPreferred(@NonNull String packageName);
9405 
9406     /**
9407      * @deprecated This function no longer does anything. It is the platform's
9408      * responsibility to assign preferred activities and this cannot be modified
9409      * directly. To determine the activities resolved by the platform, use
9410      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9411      * an app to be responsible for a particular role and to check current role
9412      * holders, see {@link android.app.role.RoleManager}.
9413      */
9414     @Deprecated
removePackageFromPreferred(@onNull String packageName)9415     public abstract void removePackageFromPreferred(@NonNull String packageName);
9416 
9417     /**
9418      * Retrieve the list of all currently configured preferred packages. The
9419      * first package on the list is the most preferred, the last is the least
9420      * preferred.
9421      *
9422      * @param flags Additional option flags to modify the data returned.
9423      * @return A List of PackageInfo objects, one for each preferred
9424      *         application, in order of preference.
9425      *
9426      * @deprecated This function no longer does anything. It is the platform's
9427      * responsibility to assign preferred activities and this cannot be modified
9428      * directly. To determine the activities resolved by the platform, use
9429      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9430      * an app to be responsible for a particular role and to check current role
9431      * holders, see {@link android.app.role.RoleManager}.
9432      */
9433     @NonNull
9434     @Deprecated
getPreferredPackages(int flags)9435     public abstract List<PackageInfo> getPreferredPackages(int flags);
9436 
9437     /**
9438      * Add a new preferred activity mapping to the system.  This will be used
9439      * to automatically select the given activity component when
9440      * {@link Context#startActivity(Intent) Context.startActivity()} finds
9441      * multiple matching activities and also matches the given filter.
9442      *
9443      * @param filter The set of intents under which this activity will be
9444      * made preferred.
9445      * @param match The IntentFilter match category that this preference
9446      * applies to.
9447      * @param set The set of activities that the user was picking from when
9448      * this preference was made.
9449      * @param activity The component name of the activity that is to be
9450      * preferred.
9451      *
9452      * @deprecated This function no longer does anything. It is the platform's
9453      * responsibility to assign preferred activities and this cannot be modified
9454      * directly. To determine the activities resolved by the platform, use
9455      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9456      * an app to be responsible for a particular role and to check current role
9457      * holders, see {@link android.app.role.RoleManager}.
9458      */
9459     @Deprecated
addPreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9460     public abstract void addPreferredActivity(@NonNull IntentFilter filter, int match,
9461             @Nullable ComponentName[] set, @NonNull ComponentName activity);
9462 
9463     /**
9464      * Same as {@link #addPreferredActivity(IntentFilter, int,
9465             ComponentName[], ComponentName)}, but with a specific userId to apply the preference
9466             to.
9467      * @hide
9468      *
9469      * @deprecated This function no longer does anything. It is the platform's
9470      * responsibility to assign preferred activities and this cannot be modified
9471      * directly. To determine the activities resolved by the platform, use
9472      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9473      * an app to be responsible for a particular role and to check current role
9474      * holders, see {@link android.app.role.RoleManager}.
9475      */
9476     @Deprecated
9477     @UnsupportedAppUsage
addPreferredActivityAsUser(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId)9478     public void addPreferredActivityAsUser(@NonNull IntentFilter filter, int match,
9479             @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) {
9480         throw new RuntimeException("Not implemented. Must override in a subclass.");
9481     }
9482 
9483     /**
9484      * Replaces an existing preferred activity mapping to the system, and if that were not present
9485      * adds a new preferred activity.  This will be used
9486      * to automatically select the given activity component when
9487      * {@link Context#startActivity(Intent) Context.startActivity()} finds
9488      * multiple matching activities and also matches the given filter.
9489      *
9490      * @param filter The set of intents under which this activity will be
9491      * made preferred.
9492      * @param match The IntentFilter match category that this preference
9493      * applies to.
9494      * @param set The set of activities that the user was picking from when
9495      * this preference was made.
9496      * @param activity The component name of the activity that is to be
9497      * preferred.
9498      *
9499      * @hide
9500      *
9501      * @deprecated This function no longer does anything. It is the platform's
9502      * responsibility to assign preferred activities and this cannot be modified
9503      * directly. To determine the activities resolved by the platform, use
9504      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9505      * an app to be responsible for a particular role and to check current role
9506      * holders, see {@link android.app.role.RoleManager}.
9507      */
9508     @SuppressWarnings("HiddenAbstractMethod")
9509     @Deprecated
9510     @UnsupportedAppUsage
replacePreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9511     public abstract void replacePreferredActivity(@NonNull IntentFilter filter, int match,
9512             @Nullable ComponentName[] set, @NonNull ComponentName activity);
9513 
9514     /**
9515      * Replaces an existing preferred activity mapping to the system, and if that were not present
9516      * adds a new preferred activity.  This will be used to automatically select the given activity
9517      * component when {@link Context#startActivity(Intent) Context.startActivity()} finds multiple
9518      * matching activities and also matches the given filter.
9519      *
9520      * @param filter The set of intents under which this activity will be made preferred.
9521      * @param match The IntentFilter match category that this preference applies to. Should be a
9522      *              combination of {@link IntentFilter#MATCH_CATEGORY_MASK} and
9523      *              {@link IntentFilter#MATCH_ADJUSTMENT_MASK}).
9524      * @param set The set of activities that the user was picking from when this preference was
9525      *            made.
9526      * @param activity The component name of the activity that is to be preferred.
9527      *
9528      * @hide
9529      */
9530     @SystemApi
replacePreferredActivity(@onNull IntentFilter filter, int match, @NonNull List<ComponentName> set, @NonNull ComponentName activity)9531     public void replacePreferredActivity(@NonNull IntentFilter filter, int match,
9532             @NonNull List<ComponentName> set, @NonNull ComponentName activity) {
9533         replacePreferredActivity(filter, match, set.toArray(new ComponentName[0]), activity);
9534     }
9535 
9536     /**
9537      * @hide
9538      *
9539      * @deprecated This function no longer does anything. It is the platform's
9540      * responsibility to assign preferred activities and this cannot be modified
9541      * directly. To determine the activities resolved by the platform, use
9542      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9543      * an app to be responsible for a particular role and to check current role
9544      * holders, see {@link android.app.role.RoleManager}.
9545      */
9546     @Deprecated
9547     @UnsupportedAppUsage
replacePreferredActivityAsUser(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId)9548     public void replacePreferredActivityAsUser(@NonNull IntentFilter filter, int match,
9549             @Nullable ComponentName[] set, @NonNull ComponentName activity, @UserIdInt int userId) {
9550         throw new RuntimeException("Not implemented. Must override in a subclass.");
9551     }
9552 
9553     /**
9554      * Remove all preferred activity mappings, previously added with
9555      * {@link #addPreferredActivity}, from the
9556      * system whose activities are implemented in the given package name.
9557      * An application can only clear its own package(s).
9558      *
9559      * @param packageName The name of the package whose preferred activity
9560      * mappings are to be removed.
9561      *
9562      * @deprecated This function no longer does anything. It is the platform's
9563      * responsibility to assign preferred activities and this cannot be modified
9564      * directly. To determine the activities resolved by the platform, use
9565      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9566      * an app to be responsible for a particular role and to check current role
9567      * holders, see {@link android.app.role.RoleManager}.
9568      */
9569     @Deprecated
clearPackagePreferredActivities(@onNull String packageName)9570     public abstract void clearPackagePreferredActivities(@NonNull String packageName);
9571 
9572     /**
9573      * Same as {@link #addPreferredActivity(IntentFilter, int, ComponentName[], ComponentName)},
9574      * but removes all existing entries that match this filter.
9575      * @hide
9576      */
addUniquePreferredActivity(@onNull IntentFilter filter, int match, @Nullable ComponentName[] set, @NonNull ComponentName activity)9577     public void addUniquePreferredActivity(@NonNull IntentFilter filter, int match,
9578             @Nullable ComponentName[] set, @NonNull ComponentName activity) {
9579         throw new UnsupportedOperationException(
9580                 "addUniquePreferredActivity not implemented in subclass");
9581     }
9582 
9583     /**
9584      * Retrieve all preferred activities, previously added with
9585      * {@link #addPreferredActivity}, that are
9586      * currently registered with the system.
9587      *
9588      * @param outFilters A required list in which to place the filters of all of the
9589      * preferred activities.
9590      * @param outActivities A required list in which to place the component names of
9591      * all of the preferred activities.
9592      * @param packageName An optional package in which you would like to limit
9593      * the list.  If null, all activities will be returned; if non-null, only
9594      * those activities in the given package are returned.
9595      *
9596      * @return Returns the total number of registered preferred activities
9597      * (the number of distinct IntentFilter records, not the number of unique
9598      * activity components) that were found.
9599      *
9600      * @deprecated This function no longer does anything. It is the platform's
9601      * responsibility to assign preferred activities and this cannot be modified
9602      * directly. To determine the activities resolved by the platform, use
9603      * {@link #resolveActivity} or {@link #queryIntentActivities}. To configure
9604      * an app to be responsible for a particular role and to check current role
9605      * holders, see {@link android.app.role.RoleManager}.
9606      */
9607     @Deprecated
getPreferredActivities(@onNull List<IntentFilter> outFilters, @NonNull List<ComponentName> outActivities, @Nullable String packageName)9608     public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
9609             @NonNull List<ComponentName> outActivities, @Nullable String packageName);
9610 
9611     /**
9612      * Ask for the set of available 'home' activities and the current explicit
9613      * default, if any.
9614      * @hide
9615      */
9616     @SuppressWarnings("HiddenAbstractMethod")
9617     @Nullable
9618     @UnsupportedAppUsage
getHomeActivities(@onNull List<ResolveInfo> outActivities)9619     public abstract ComponentName getHomeActivities(@NonNull List<ResolveInfo> outActivities);
9620 
9621     /**
9622      * Set the enabled setting for a package component (activity, receiver, service, provider).
9623      * This setting will override any enabled state which may have been set by the component in its
9624      * manifest.
9625      *
9626      * <p>Consider using {@link #setComponentEnabledSettings(List)} if multiple components need to
9627      * be updated atomically.
9628      *
9629      * @param componentName The component to enable
9630      * @param newState The new enabled state for the component.
9631      * @param flags Optional behavior flags.
9632      */
9633     @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE,
9634             conditional = true)
setComponentEnabledSetting(@onNull ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags)9635     public abstract void setComponentEnabledSetting(@NonNull ComponentName componentName,
9636             @EnabledState int newState, @EnabledFlags int flags);
9637 
9638     /**
9639      * Set the enabled settings for package components such as activities, receivers, services and
9640      * providers. This setting will override any enabled state which may have been set by the
9641      * component in its manifest.
9642      *
9643      * <p>This api accepts a list of component changes, and applies them all atomically. The
9644      * application can use this api if components have dependencies and need to be updated
9645      * atomically.
9646      *
9647      * <p>The permission is not required if target components are running under the same uid with
9648      * the caller.
9649      *
9650      * @param settings The list of component enabled settings to update. Note that an
9651      *                 {@link IllegalArgumentException} is thrown if the duplicated component name
9652      *                 is in the list or there's a conflict {@link #DONT_KILL_APP} flag between
9653      *                 different components in the same package.
9654      *
9655      * @see #setComponentEnabledSetting(ComponentName, int, int)
9656      */
9657     @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE,
9658             conditional = true)
setComponentEnabledSettings(@onNull List<ComponentEnabledSetting> settings)9659     public void setComponentEnabledSettings(@NonNull List<ComponentEnabledSetting> settings) {
9660         throw new UnsupportedOperationException("setComponentEnabledSettings not implemented"
9661                 + "in subclass");
9662     }
9663 
9664     /**
9665      * Return the enabled setting for a package component (activity,
9666      * receiver, service, provider).  This returns the last value set by
9667      * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
9668      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
9669      * the value originally specified in the manifest has not been modified.
9670      *
9671      * @param componentName The component to retrieve.
9672      * @return Returns the current enabled state for the component.
9673      */
getComponentEnabledSetting( @onNull ComponentName componentName)9674     public abstract @EnabledState int getComponentEnabledSetting(
9675             @NonNull ComponentName componentName);
9676 
9677     /**
9678      * Set whether a synthetic app details activity will be generated if the app has no enabled
9679      * launcher activity. Disabling this allows the app to have no launcher icon.
9680      *
9681      * @param packageName The package name of the app
9682      * @param enabled The new enabled state for the synthetic app details activity.
9683      *
9684      * @hide
9685      */
9686     @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE,
9687             conditional = true)
9688     @SystemApi
setSyntheticAppDetailsActivityEnabled(@onNull String packageName, boolean enabled)9689     public void setSyntheticAppDetailsActivityEnabled(@NonNull String packageName,
9690             boolean enabled) {
9691         throw new UnsupportedOperationException(
9692                 "setSyntheticAppDetailsActivityEnabled not implemented");
9693     }
9694 
9695 
9696     /**
9697      * Return whether a synthetic app details activity will be generated if the app has no enabled
9698      * launcher activity.
9699      *
9700      * @param packageName The package name of the app
9701      * @return Returns the enabled state for the synthetic app details activity.
9702      *
9703      *
9704      */
getSyntheticAppDetailsActivityEnabled(@onNull String packageName)9705     public boolean getSyntheticAppDetailsActivityEnabled(@NonNull String packageName) {
9706         throw new UnsupportedOperationException(
9707                 "getSyntheticAppDetailsActivityEnabled not implemented");
9708     }
9709 
9710     /**
9711      * Set the enabled setting for an application
9712      * This setting will override any enabled state which may have been set by the application in
9713      * its manifest.  It also overrides the enabled state set in the manifest for any of the
9714      * application's components.  It does not override any enabled state set by
9715      * {@link #setComponentEnabledSetting} for any of the application's components.
9716      *
9717      * @param packageName The package name of the application to enable
9718      * @param newState The new enabled state for the application.
9719      * @param flags Optional behavior flags.
9720      */
9721     @RequiresPermission(value = android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE,
9722             conditional = true)
setApplicationEnabledSetting(@onNull String packageName, @EnabledState int newState, @EnabledFlags int flags)9723     public abstract void setApplicationEnabledSetting(@NonNull String packageName,
9724             @EnabledState int newState, @EnabledFlags int flags);
9725 
9726     /**
9727      * Return the enabled setting for an application. This returns
9728      * the last value set by
9729      * {@link #setApplicationEnabledSetting(String, int, int)}; in most
9730      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
9731      * the value originally specified in the manifest has not been modified.
9732      *
9733      * @param packageName The package name of the application to retrieve.
9734      * @return Returns the current enabled state for the application.
9735      * @throws IllegalArgumentException if the named package does not exist.
9736      */
getApplicationEnabledSetting(@onNull String packageName)9737     public abstract @EnabledState int getApplicationEnabledSetting(@NonNull String packageName);
9738 
9739     /**
9740      * Flush the package restrictions for a given user to disk. This forces the package restrictions
9741      * like component and package enabled settings to be written to disk and avoids the delay that
9742      * is otherwise present when changing those settings.
9743      *
9744      * @param userId Ther userId of the user whose restrictions are to be flushed.
9745      * @hide
9746      */
9747     @SuppressWarnings("HiddenAbstractMethod")
9748     @UnsupportedAppUsage
flushPackageRestrictionsAsUser(@serIdInt int userId)9749     public abstract void flushPackageRestrictionsAsUser(@UserIdInt int userId);
9750 
9751     /**
9752      * Puts the package in a hidden state, which is almost like an uninstalled state,
9753      * making the package unavailable, but it doesn't remove the data or the actual
9754      * package file. Application can be unhidden by either resetting the hidden state
9755      * or by installing it, such as with {@link #installExistingPackage(String)}
9756      * @hide
9757      */
9758     @SuppressWarnings("HiddenAbstractMethod")
9759     @UnsupportedAppUsage
setApplicationHiddenSettingAsUser(@onNull String packageName, boolean hidden, @NonNull UserHandle userHandle)9760     public abstract boolean setApplicationHiddenSettingAsUser(@NonNull String packageName,
9761             boolean hidden, @NonNull UserHandle userHandle);
9762 
9763     /**
9764      * Returns the hidden state of a package.
9765      * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
9766      * @hide
9767      */
9768     @SuppressWarnings("HiddenAbstractMethod")
9769     @UnsupportedAppUsage
getApplicationHiddenSettingAsUser(@onNull String packageName, @NonNull UserHandle userHandle)9770     public abstract boolean getApplicationHiddenSettingAsUser(@NonNull String packageName,
9771             @NonNull UserHandle userHandle);
9772 
9773     /**
9774      * Sets the state of a system app.
9775      *
9776      * This method can be used to change a system app's hidden-until-installed state (via
9777      * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN} and
9778      * {@link #SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_VISIBLE} or its installation state (via
9779      * {@link #SYSTEM_APP_STATE_INSTALLED} and {@link #SYSTEM_APP_STATE_UNINSTALLED}.
9780      *
9781      * This API may only be called from {@link android.os.Process#SYSTEM_UID} or
9782      * {@link android.os.Process#PHONE_UID}.
9783      *
9784      * @param packageName Package name of the app.
9785      * @param state State of the app.
9786      * @hide
9787      */
9788     @SystemApi
setSystemAppState(@onNull String packageName, @SystemAppState int state)9789     public void setSystemAppState(@NonNull String packageName, @SystemAppState int state) {
9790         throw new RuntimeException("Not implemented. Must override in a subclass");
9791     }
9792 
9793     /**
9794      * Return whether the device has been booted into safe mode.
9795      */
isSafeMode()9796     public abstract boolean isSafeMode();
9797 
9798     /**
9799      * Adds a listener for permission changes for installed packages.
9800      *
9801      * @param listener The listener to add.
9802      *
9803      * @hide
9804      */
9805     //@Deprecated
9806     @SuppressWarnings("HiddenAbstractMethod")
9807     @SystemApi
9808     @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
addOnPermissionsChangeListener( @onNull OnPermissionsChangedListener listener)9809     public abstract void addOnPermissionsChangeListener(
9810             @NonNull OnPermissionsChangedListener listener);
9811 
9812     /**
9813      * Remvoes a listener for permission changes for installed packages.
9814      *
9815      * @param listener The listener to remove.
9816      *
9817      * @hide
9818      */
9819     //@Deprecated
9820     @SuppressWarnings("HiddenAbstractMethod")
9821     @SystemApi
9822     @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
removeOnPermissionsChangeListener( @onNull OnPermissionsChangedListener listener)9823     public abstract void removeOnPermissionsChangeListener(
9824             @NonNull OnPermissionsChangedListener listener);
9825 
9826     /**
9827      * Return the {@link KeySet} associated with the String alias for this
9828      * application.
9829      *
9830      * @param alias The alias for a given {@link KeySet} as defined in the
9831      *        application's AndroidManifest.xml.
9832      * @hide
9833      */
9834     @SuppressWarnings("HiddenAbstractMethod")
9835     @NonNull
9836     @UnsupportedAppUsage
getKeySetByAlias(@onNull String packageName, @NonNull String alias)9837     public abstract KeySet getKeySetByAlias(@NonNull String packageName, @NonNull String alias);
9838 
9839     /** Return the signing {@link KeySet} for this application.
9840      * @hide
9841      */
9842     @SuppressWarnings("HiddenAbstractMethod")
9843     @NonNull
9844     @UnsupportedAppUsage
getSigningKeySet(@onNull String packageName)9845     public abstract KeySet getSigningKeySet(@NonNull String packageName);
9846 
9847     /**
9848      * Return whether the package denoted by packageName has been signed by all
9849      * of the keys specified by the {@link KeySet} ks.  This will return true if
9850      * the package has been signed by additional keys (a superset) as well.
9851      * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
9852      * @hide
9853      */
9854     @SuppressWarnings("HiddenAbstractMethod")
9855     @UnsupportedAppUsage
isSignedBy(@onNull String packageName, @NonNull KeySet ks)9856     public abstract boolean isSignedBy(@NonNull String packageName, @NonNull KeySet ks);
9857 
9858     /**
9859      * Return whether the package denoted by packageName has been signed by all
9860      * of, and only, the keys specified by the {@link KeySet} ks. Compare to
9861      * {@link #isSignedBy(String packageName, KeySet ks)}.
9862      * @hide
9863      */
9864     @SuppressWarnings("HiddenAbstractMethod")
9865     @UnsupportedAppUsage
isSignedByExactly(@onNull String packageName, @NonNull KeySet ks)9866     public abstract boolean isSignedByExactly(@NonNull String packageName, @NonNull KeySet ks);
9867 
9868     /**
9869      * Flag to denote no restrictions. This should be used to clear any restrictions that may have
9870      * been previously set for the package.
9871      * @hide
9872      * @see #setDistractingPackageRestrictions(String[], int)
9873      */
9874     @SystemApi
9875     public static final int RESTRICTION_NONE = 0x0;
9876 
9877     /**
9878      * Flag to denote that a package should be hidden from any suggestions to the user.
9879      * @hide
9880      * @see #setDistractingPackageRestrictions(String[], int)
9881      */
9882     @SystemApi
9883     public static final int RESTRICTION_HIDE_FROM_SUGGESTIONS = 0x00000001;
9884 
9885     /**
9886      * Flag to denote that a package's notifications should be hidden.
9887      * @hide
9888      * @see #setDistractingPackageRestrictions(String[], int)
9889      */
9890     @SystemApi
9891     public static final int RESTRICTION_HIDE_NOTIFICATIONS = 0x00000002;
9892 
9893     /**
9894      * Restriction flags to set on a package that is considered as distracting to the user.
9895      * These should help the user to restrict their usage of these apps.
9896      *
9897      * @see #setDistractingPackageRestrictions(String[], int)
9898      * @hide
9899      */
9900     @IntDef(flag = true, prefix = {"RESTRICTION_"}, value = {
9901             RESTRICTION_NONE,
9902             RESTRICTION_HIDE_FROM_SUGGESTIONS,
9903             RESTRICTION_HIDE_NOTIFICATIONS
9904     })
9905     @Retention(RetentionPolicy.SOURCE)
9906     public @interface DistractionRestriction {}
9907 
9908     /**
9909      * Mark or unmark the given packages as distracting to the user.
9910      * These packages can have certain restrictions set that should discourage the user to launch
9911      * them often. For example, notifications from such an app can be hidden, or the app can be
9912      * removed from launcher suggestions, so the user is able to restrict their use of these apps.
9913      *
9914      * <p>The caller must hold {@link android.Manifest.permission#SUSPEND_APPS} to use this API.
9915      *
9916      * @param packages Packages to mark as distracting.
9917      * @param restrictionFlags Any combination of restrictions to impose on the given packages.
9918      *                         {@link #RESTRICTION_NONE} can be used to clear any existing
9919      *                         restrictions.
9920      * @return A list of packages that could not have the {@code restrictionFlags} set. The system
9921      * may prevent restricting critical packages to preserve normal device function.
9922      *
9923      * @hide
9924      * @see #RESTRICTION_NONE
9925      * @see #RESTRICTION_HIDE_FROM_SUGGESTIONS
9926      * @see #RESTRICTION_HIDE_NOTIFICATIONS
9927      */
9928     @SystemApi
9929     @RequiresPermission(android.Manifest.permission.SUSPEND_APPS)
9930     @NonNull
setDistractingPackageRestrictions(@onNull String[] packages, @DistractionRestriction int restrictionFlags)9931     public String[] setDistractingPackageRestrictions(@NonNull String[] packages,
9932             @DistractionRestriction int restrictionFlags) {
9933         throw new UnsupportedOperationException(
9934                 "setDistractingPackageRestrictions not implemented");
9935     }
9936 
9937     /**
9938      * Puts the package in a suspended state, where attempts at starting activities are denied.
9939      *
9940      * <p>It doesn't remove the data or the actual package file. The application's notifications
9941      * will be hidden, any of its started activities will be stopped and it will not be able to
9942      * show toasts or system alert windows or ring the device.
9943      *
9944      * <p>When the user tries to launch a suspended app, a system dialog with the given
9945      * {@code dialogMessage} will be shown instead. Since the message is supplied to the system as
9946      * a {@link String}, the caller needs to take care of localization as needed.
9947      * The dialog message can optionally contain a placeholder for the name of the suspended app.
9948      * The system uses {@link String#format(Locale, String, Object...) String.format} to insert the
9949      * app name into the message, so an example format string could be {@code "The app %1$s is
9950      * currently suspended"}. This makes it easier for callers to provide a single message which
9951      * works for all the packages being suspended in a single call.
9952      *
9953      * <p>The package must already be installed. If the package is uninstalled while suspended
9954      * the package will no longer be suspended. </p>
9955      *
9956      * <p>Optionally, the suspending app can provide extra information in the form of
9957      * {@link PersistableBundle} objects to be shared with the apps being suspended and the
9958      * launcher to support customization that they might need to handle the suspended state.
9959      *
9960      * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API.
9961      *
9962      * @param packageNames The names of the packages to set the suspended status.
9963      * @param suspended If set to {@code true}, the packages will be suspended, if set to
9964      * {@code false}, the packages will be unsuspended.
9965      * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
9966      *                  which will be shared with the apps being suspended. Ignored if
9967      *                  {@code suspended} is false.
9968      * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can
9969      *                       provide which will be shared with the launcher. Ignored if
9970      *                       {@code suspended} is false.
9971      * @param dialogMessage The message to be displayed to the user, when they try to launch a
9972      *                      suspended app.
9973      *
9974      * @return an array of package names for which the suspended status could not be set as
9975      * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}.
9976      *
9977      * @deprecated use {@link #setPackagesSuspended(String[], boolean, PersistableBundle,
9978      * PersistableBundle, android.content.pm.SuspendDialogInfo)} instead.
9979      *
9980      * @hide
9981      */
9982     @SystemApi
9983     @Deprecated
9984     @RequiresPermission(Manifest.permission.SUSPEND_APPS)
9985     @Nullable
setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable String dialogMessage)9986     public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended,
9987             @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
9988             @Nullable String dialogMessage) {
9989         throw new UnsupportedOperationException("setPackagesSuspended not implemented");
9990     }
9991 
9992     /**
9993      * Puts the given packages in a suspended state, where attempts at starting activities are
9994      * denied.
9995      *
9996      * <p>The suspended application's notifications and all of its windows will be hidden, any
9997      * of its started activities will be stopped and it won't be able to ring the device.
9998      * It doesn't remove the data or the actual package file.
9999      *
10000      * <p>When the user tries to launch a suspended app, a system dialog alerting them that the app
10001      * is suspended will be shown instead.
10002      * The caller can optionally customize the dialog by passing a {@link SuspendDialogInfo} object
10003      * to this API. This dialog will have a button that starts the
10004      * {@link Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS} intent if the suspending app declares an
10005      * activity which handles this action.
10006      *
10007      * <p>The packages being suspended must already be installed. If a package is uninstalled, it
10008      * will no longer be suspended.
10009      *
10010      * <p>Optionally, the suspending app can provide extra information in the form of
10011      * {@link PersistableBundle} objects to be shared with the apps being suspended and the
10012      * launcher to support customization that they might need to handle the suspended state.
10013      *
10014      * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API except for
10015      * device owner and profile owner.
10016      *
10017      * @param packageNames The names of the packages to set the suspended status.
10018      * @param suspended If set to {@code true}, the packages will be suspended, if set to
10019      * {@code false}, the packages will be unsuspended.
10020      * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
10021      *                  which will be shared with the apps being suspended. Ignored if
10022      *                  {@code suspended} is false.
10023      * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can
10024      *                       provide which will be shared with the launcher. Ignored if
10025      *                       {@code suspended} is false.
10026      * @param dialogInfo An optional {@link SuspendDialogInfo} object describing the dialog that
10027      *                   should be shown to the user when they try to launch a suspended app.
10028      *                   Ignored if {@code suspended} is false.
10029      *
10030      * @return an array of package names for which the suspended status could not be set as
10031      * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}.
10032      *
10033      * @see #isPackageSuspended
10034      * @see SuspendDialogInfo
10035      * @see SuspendDialogInfo.Builder
10036      * @see Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS
10037      *
10038      * @hide
10039      */
10040     @SystemApi
10041     @RequiresPermission(value=Manifest.permission.SUSPEND_APPS, conditional=true)
10042     @Nullable
setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable SuspendDialogInfo dialogInfo)10043     public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended,
10044             @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
10045             @Nullable SuspendDialogInfo dialogInfo) {
10046         throw new UnsupportedOperationException("setPackagesSuspended not implemented");
10047     }
10048 
10049     /**
10050      * Puts the given packages in a suspended state, where attempts at starting activities are
10051      * denied.
10052      *
10053      * <p>The suspended application's notifications and all of its windows will be hidden, any
10054      * of its started activities will be stopped and it won't be able to ring the device.
10055      * It doesn't remove the data or the actual package file.
10056      *
10057      * <p>When the user tries to launch a suspended app, a system dialog alerting them that the app
10058      * is suspended will be shown instead.
10059      * The caller can optionally customize the dialog by passing a {@link SuspendDialogInfo} object
10060      * to this API. This dialog will have a button that starts the
10061      * {@link Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS} intent if the suspending app declares an
10062      * activity which handles this action.
10063      *
10064      * <p>The packages being suspended must already be installed. If a package is uninstalled, it
10065      * will no longer be suspended.
10066      *
10067      * <p>Optionally, the suspending app can provide extra information in the form of
10068      * {@link PersistableBundle} objects to be shared with the apps being suspended and the
10069      * launcher to support customization that they might need to handle the suspended state.
10070      *
10071      * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} to use this API except for
10072      * device owner and profile owner or the {@link Manifest.permission#QUARANTINE_APPS} if the
10073      * caller is using {@link #FLAG_SUSPEND_QUARANTINED}.
10074      *
10075      * @param packageNames The names of the packages to set the suspended status.
10076      * @param suspended If set to {@code true}, the packages will be suspended, if set to
10077      * {@code false}, the packages will be unsuspended.
10078      * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
10079      *                  which will be shared with the apps being suspended. Ignored if
10080      *                  {@code suspended} is false.
10081      * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can
10082      *                       provide which will be shared with the launcher. Ignored if
10083      *                       {@code suspended} is false.
10084      * @param dialogInfo An optional {@link SuspendDialogInfo} object describing the dialog that
10085      *                   should be shown to the user when they try to launch a suspended app.
10086      *                   Ignored if {@code suspended} is false.
10087      * @param flags Optional behavior flags.
10088      *
10089      * @return an array of package names for which the suspended status could not be set as
10090      * requested in this method. Returns {@code null} if {@code packageNames} was {@code null}.
10091      *
10092      * @see #isPackageSuspended
10093      * @see SuspendDialogInfo
10094      * @see SuspendDialogInfo.Builder
10095      * @see Intent#ACTION_SHOW_SUSPENDED_APP_DETAILS
10096      *
10097      * @hide
10098      */
10099     @SystemApi
10100     @FlaggedApi(android.content.pm.Flags.FLAG_QUARANTINED_ENABLED)
10101     @RequiresPermission(anyOf = {
10102             Manifest.permission.SUSPEND_APPS,
10103             Manifest.permission.QUARANTINE_APPS
10104     }, conditional = true)
10105     @SuppressLint("NullableCollection")
10106     @Nullable
setPackagesSuspended(@ullable String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, @Nullable SuspendDialogInfo dialogInfo, @SuspendedFlags int flags)10107     public String[] setPackagesSuspended(@Nullable String[] packageNames, boolean suspended,
10108             @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
10109             @Nullable SuspendDialogInfo dialogInfo, @SuspendedFlags int flags) {
10110         throw new UnsupportedOperationException("setPackagesSuspended not implemented");
10111     }
10112 
10113     /**
10114      * Returns any packages in a given set of packages that cannot be suspended via a call to {@link
10115      * #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle,
10116      * SuspendDialogInfo) setPackagesSuspended}. The platform prevents suspending certain critical
10117      * packages to keep the device in a functioning state, e.g. the default dialer and launcher.
10118      * Apps need to hold {@link Manifest.permission#SUSPEND_APPS SUSPEND_APPS} to call this API.
10119      *
10120      * <p>
10121      * Note that this set of critical packages can change with time, so even though a package name
10122      * was not returned by this call, it does not guarantee that a subsequent call to
10123      * {@link #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle,
10124      * SuspendDialogInfo) setPackagesSuspended} for that package will succeed, especially if
10125      * significant time elapsed between the two calls.
10126      *
10127      * @param packageNames The packages to check.
10128      * @return A list of packages that can not be currently suspended by the system.
10129      * @hide
10130      */
10131     @SystemApi
10132     @RequiresPermission(Manifest.permission.SUSPEND_APPS)
10133     @NonNull
getUnsuspendablePackages(@onNull String[] packageNames)10134     public String[] getUnsuspendablePackages(@NonNull String[] packageNames) {
10135         throw new UnsupportedOperationException("getUnsuspendablePackages not implemented");
10136     }
10137 
10138     /**
10139      * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String)
10140      * @param packageName The name of the package to get the suspended status of.
10141      * @param userId The user id.
10142      * @return {@code true} if the package is suspended or {@code false} if the package is not
10143      * suspended.
10144      * @throws IllegalArgumentException if the package was not found.
10145      * @hide
10146      */
10147     @SuppressWarnings("HiddenAbstractMethod")
10148     @UnsupportedAppUsage
isPackageSuspendedForUser(@onNull String packageName, int userId)10149     public abstract boolean isPackageSuspendedForUser(@NonNull String packageName, int userId);
10150 
10151     /**
10152      * Query if an app is currently suspended.
10153      *
10154      * @return {@code true} if the given package is suspended, {@code false} otherwise
10155      * @throws NameNotFoundException if the package could not be found.
10156      *
10157      * @see #isPackageSuspended()
10158      */
isPackageSuspended(@onNull String packageName)10159     public boolean isPackageSuspended(@NonNull String packageName) throws NameNotFoundException {
10160         throw new UnsupportedOperationException("isPackageSuspended not implemented");
10161     }
10162 
10163     /**
10164      * Apps can query this to know if they have been suspended. A system app with the permission
10165      * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state.
10166      *
10167      * <p>While in this state, the application's notifications will be hidden, any of its started
10168      * activities will be stopped and it will not be able to show toasts or dialogs or play audio.
10169      * When the user tries to launch a suspended app, the system will, instead, show a
10170      * dialog to the user informing them that they cannot use this app while it is suspended.
10171      *
10172      * <p>When an app is put into this state, the broadcast action
10173      * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast
10174      * receivers that included this action in their intent-filters, <em>including manifest
10175      * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED}
10176      * is delivered when a previously suspended app is taken out of this state. Apps are expected to
10177      * use these to gracefully deal with transitions to and from this state.
10178      *
10179      * @return {@code true} if the calling package has been suspended, {@code false} otherwise.
10180      *
10181      * @see #getSuspendedPackageAppExtras()
10182      * @see Intent#ACTION_MY_PACKAGE_SUSPENDED
10183      * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED
10184      */
isPackageSuspended()10185     public boolean isPackageSuspended() {
10186         throw new UnsupportedOperationException("isPackageSuspended not implemented");
10187     }
10188 
10189     /**
10190      * Returns a {@link Bundle} of extras that was meant to be sent to the calling app when it was
10191      * suspended. An app with the permission {@code android.permission.SUSPEND_APPS} can supply this
10192      * to the system at the time of suspending an app.
10193      *
10194      * <p>This is the same {@link Bundle} that is sent along with the broadcast
10195      * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED}, whenever the app is suspended. The contents of
10196      * this {@link Bundle} are a contract between the suspended app and the suspending app.
10197      *
10198      * <p>Note: These extras are optional, so if no extras were supplied to the system, this method
10199      * will return {@code null}, even when the calling app has been suspended.
10200      *
10201      * @return A {@link Bundle} containing the extras for the app, or {@code null} if the
10202      * package is not currently suspended.
10203      *
10204      * @see #isPackageSuspended()
10205      * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED
10206      * @see Intent#ACTION_MY_PACKAGE_SUSPENDED
10207      * @see Intent#EXTRA_SUSPENDED_PACKAGE_EXTRAS
10208      */
getSuspendedPackageAppExtras()10209     public @Nullable Bundle getSuspendedPackageAppExtras() {
10210         throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented");
10211     }
10212 
10213     /**
10214      * Get the name of the package that suspended the given package. Packages can be suspended by
10215      * device administrators or apps holding {@link android.Manifest.permission#MANAGE_USERS} or
10216      * {@link android.Manifest.permission#SUSPEND_APPS}.
10217      *
10218      * <p>
10219      * <strong>Note:</strong>This API doesn't support cross user suspension and should only be used
10220      * for testing.
10221      * @param suspendedPackage The package that has been suspended.
10222      * @return Name of the package that suspended the given package. Returns {@code null} if the
10223      * given package is not currently suspended and the platform package name - i.e.
10224      * {@code "android"} - if the package was suspended by a device admin.
10225      * @hide
10226      */
getSuspendingPackage(@onNull String suspendedPackage)10227     public @Nullable String getSuspendingPackage(@NonNull String suspendedPackage) {
10228         throw new UnsupportedOperationException("getSuspendingPackage not implemented");
10229     }
10230 
10231     /**
10232      * Query if an app is currently stopped.
10233      *
10234      * @return {@code true} if the given package is stopped, {@code false} otherwise
10235      * @throws NameNotFoundException if the package could not be found.
10236      * @see ApplicationInfo#FLAG_STOPPED
10237      */
10238     @FlaggedApi(android.content.pm.Flags.FLAG_STAY_STOPPED)
isPackageStopped(@onNull String packageName)10239     public boolean isPackageStopped(@NonNull String packageName) throws NameNotFoundException {
10240         throw new UnsupportedOperationException("isPackageStopped not implemented");
10241     }
10242 
10243     /**
10244      * Query if an app is currently quarantined.
10245      * A misbehaving app can be quarantined by e.g. a system of another privileged entity.
10246      * Quarantined apps are similar to disabled, but still visible in e.g. Launcher.
10247      * Only activities of such apps can still be queried, but not services etc.
10248      * Quarantined apps can't be bound to, and won't receive broadcasts.
10249      * They can't be resolved, unless {@link #MATCH_QUARANTINED_COMPONENTS} specified.
10250      *
10251      * @return {@code true} if the given package is quarantined, {@code false} otherwise
10252      * @throws NameNotFoundException if the package could not be found.
10253      */
10254     @FlaggedApi(android.content.pm.Flags.FLAG_QUARANTINED_ENABLED)
isPackageQuarantined(@onNull String packageName)10255     public boolean isPackageQuarantined(@NonNull String packageName) throws NameNotFoundException {
10256         throw new UnsupportedOperationException("isPackageQuarantined not implemented");
10257     }
10258     /**
10259      * Provide a hint of what the {@link ApplicationInfo#category} value should
10260      * be for the given package.
10261      * <p>
10262      * This hint can only be set by the app which installed this package, as
10263      * determined by {@link #getInstallerPackageName(String)}.
10264      *
10265      * @param packageName the package to change the category hint for.
10266      * @param categoryHint the category hint to set.
10267      */
10268     @SuppressWarnings("HiddenAbstractMethod")
setApplicationCategoryHint(@onNull String packageName, @ApplicationInfo.Category int categoryHint)10269     public abstract void setApplicationCategoryHint(@NonNull String packageName,
10270             @ApplicationInfo.Category int categoryHint);
10271 
10272     /** {@hide} */
isMoveStatusFinished(int status)10273     public static boolean isMoveStatusFinished(int status) {
10274         return (status < 0 || status > 100);
10275     }
10276 
10277     /** {@hide} */
10278     public static abstract class MoveCallback {
onCreated(int moveId, Bundle extras)10279         public void onCreated(int moveId, Bundle extras) {}
onStatusChanged(int moveId, int status, long estMillis)10280         public abstract void onStatusChanged(int moveId, int status, long estMillis);
10281     }
10282 
10283     /** {@hide} */
10284     @SuppressWarnings("HiddenAbstractMethod")
10285     @UnsupportedAppUsage
getMoveStatus(int moveId)10286     public abstract int getMoveStatus(int moveId);
10287 
10288     /** {@hide} */
10289     @SuppressWarnings("HiddenAbstractMethod")
10290     @UnsupportedAppUsage
registerMoveCallback(@onNull MoveCallback callback, @NonNull Handler handler)10291     public abstract void registerMoveCallback(@NonNull MoveCallback callback,
10292             @NonNull Handler handler);
10293     /** {@hide} */
10294     @SuppressWarnings("HiddenAbstractMethod")
10295     @UnsupportedAppUsage
unregisterMoveCallback(@onNull MoveCallback callback)10296     public abstract void unregisterMoveCallback(@NonNull MoveCallback callback);
10297 
10298     /** {@hide} */
10299     @SuppressWarnings("HiddenAbstractMethod")
10300     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
movePackage(@onNull String packageName, @NonNull VolumeInfo vol)10301     public abstract int movePackage(@NonNull String packageName, @NonNull VolumeInfo vol);
10302     /** {@hide} */
10303     @SuppressWarnings("HiddenAbstractMethod")
10304     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
getPackageCurrentVolume(@onNull ApplicationInfo app)10305     public abstract @Nullable VolumeInfo getPackageCurrentVolume(@NonNull ApplicationInfo app);
10306     /** {@hide} */
10307     @SuppressWarnings("HiddenAbstractMethod")
10308     @NonNull
10309     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
getPackageCandidateVolumes( @onNull ApplicationInfo app)10310     public abstract List<VolumeInfo> getPackageCandidateVolumes(
10311             @NonNull ApplicationInfo app);
10312 
10313     /** {@hide} */
10314     @SuppressWarnings("HiddenAbstractMethod")
movePrimaryStorage(@onNull VolumeInfo vol)10315     public abstract int movePrimaryStorage(@NonNull VolumeInfo vol);
10316     /** {@hide} */
10317     @SuppressWarnings("HiddenAbstractMethod")
getPrimaryStorageCurrentVolume()10318     public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
10319     /** {@hide} */
10320     @SuppressWarnings("HiddenAbstractMethod")
getPrimaryStorageCandidateVolumes()10321     public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
10322 
10323     /**
10324      * Returns the device identity that verifiers can use to associate their scheme to a particular
10325      * device. This should not be used by anything other than a package verifier.
10326      *
10327      * @return identity that uniquely identifies current device
10328      * @hide
10329      */
10330     @SuppressWarnings("HiddenAbstractMethod")
10331     @NonNull
getVerifierDeviceIdentity()10332     public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
10333 
10334     /**
10335      * Returns true if the device is upgrading, such as first boot after OTA.
10336      *
10337      * @hide
10338      */
10339     @SuppressWarnings("HiddenAbstractMethod")
10340     @UnsupportedAppUsage
isUpgrade()10341     public abstract boolean isUpgrade();
10342 
10343     /**
10344      * Returns true if the device is upgrading, such as first boot after OTA.
10345      */
isDeviceUpgrading()10346     public boolean isDeviceUpgrading() {
10347         return false;
10348     }
10349 
10350     /**
10351      * Return interface that offers the ability to install, upgrade, and remove
10352      * applications on the device.
10353      */
getPackageInstaller()10354     public abstract @NonNull PackageInstaller getPackageInstaller();
10355 
10356     /**
10357      * Adds a {@code CrossProfileIntentFilter}. After calling this method all
10358      * intents sent from the user with id sourceUserId can also be be resolved
10359      * by activities in the user with id targetUserId if they match the
10360      * specified intent filter.
10361      *
10362      * @param filter The {@link IntentFilter} the intent has to match
10363      * @param sourceUserId The source user id.
10364      * @param targetUserId The target user id.
10365      * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
10366      *            {@link #ONLY_IF_NO_MATCH_FOUND}.
10367      * @hide
10368      */
10369     @SuppressWarnings("HiddenAbstractMethod")
10370     @UnsupportedAppUsage
10371     @TestApi
addCrossProfileIntentFilter(@onNull IntentFilter filter, @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags)10372     public abstract void addCrossProfileIntentFilter(@NonNull IntentFilter filter,
10373             @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags);
10374 
10375     /**
10376      * Removes all {@code CrossProfileIntentFilter}s which matches the specified intent filer,
10377      * source, target and flag.
10378      *
10379      * @param filter       The {@link IntentFilter} the intent has to match
10380      * @param sourceUserId The source user id.
10381      * @param targetUserId The target user id.
10382      * @param flags        The possible values are {@link #SKIP_CURRENT_PROFILE} and
10383      *                     {@link #ONLY_IF_NO_MATCH_FOUND}.
10384      * @hide
10385      */
removeCrossProfileIntentFilter(@onNull IntentFilter filter, @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags)10386     public boolean removeCrossProfileIntentFilter(@NonNull IntentFilter filter,
10387             @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags) {
10388         throw new UnsupportedOperationException(
10389                 "removeCrossProfileIntentFilter not implemented in subclass");
10390     }
10391 
10392     /**
10393      * Clearing {@code CrossProfileIntentFilter}s which have the specified user
10394      * as their source, and have been set by the app calling this method.
10395      *
10396      * @param sourceUserId The source user id.
10397      * @hide
10398      */
10399     @SuppressWarnings("HiddenAbstractMethod")
10400     @UnsupportedAppUsage
10401     @TestApi
clearCrossProfileIntentFilters(@serIdInt int sourceUserId)10402     public abstract void clearCrossProfileIntentFilters(@UserIdInt int sourceUserId);
10403 
10404     /**
10405      * @hide
10406      */
10407     @SuppressWarnings("HiddenAbstractMethod")
10408     @NonNull
10409     @UnsupportedAppUsage
loadItemIcon(@onNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo)10410     public abstract Drawable loadItemIcon(@NonNull PackageItemInfo itemInfo,
10411             @Nullable ApplicationInfo appInfo);
10412 
10413     /**
10414      * @hide
10415      */
10416     @SuppressWarnings("HiddenAbstractMethod")
10417     @NonNull
10418     @UnsupportedAppUsage
loadUnbadgedItemIcon(@onNull PackageItemInfo itemInfo, @Nullable ApplicationInfo appInfo)10419     public abstract Drawable loadUnbadgedItemIcon(@NonNull PackageItemInfo itemInfo,
10420             @Nullable ApplicationInfo appInfo);
10421 
10422     /** {@hide} */
10423     @SuppressWarnings("HiddenAbstractMethod")
10424     @UnsupportedAppUsage
isPackageAvailable(@onNull String packageName)10425     public abstract boolean isPackageAvailable(@NonNull String packageName);
10426 
10427     /** {@hide} */
10428     @NonNull
10429     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
installStatusToString(int status, @Nullable String msg)10430     public static String installStatusToString(int status, @Nullable String msg) {
10431         final String str = installStatusToString(status);
10432         if (msg != null) {
10433             return str + ": " + msg;
10434         } else {
10435             return str;
10436         }
10437     }
10438 
10439     /** {@hide} */
10440     @NonNull
10441     @UnsupportedAppUsage
installStatusToString(int status)10442     public static String installStatusToString(int status) {
10443         switch (status) {
10444             case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
10445             case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
10446             case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
10447             case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
10448             case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
10449             case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
10450             case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
10451             case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
10452             case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
10453             case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
10454             case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
10455             case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
10456             case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
10457             case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
10458             case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
10459             case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
10460             case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
10461             case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
10462             case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
10463             case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
10464             case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
10465             case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
10466             case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
10467             case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
10468             case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
10469             case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
10470             case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
10471             case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
10472             case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
10473             case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
10474             case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
10475             case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
10476             case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
10477             case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
10478             case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
10479             case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
10480             case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
10481             case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
10482             case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
10483             case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
10484             case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
10485             case INSTALL_FAILED_BAD_DEX_METADATA: return "INSTALL_FAILED_BAD_DEX_METADATA";
10486             case INSTALL_FAILED_MISSING_SPLIT: return "INSTALL_FAILED_MISSING_SPLIT";
10487             case INSTALL_FAILED_DEPRECATED_SDK_VERSION: return "INSTALL_FAILED_DEPRECATED_SDK_VERSION";
10488             case INSTALL_FAILED_BAD_SIGNATURE: return "INSTALL_FAILED_BAD_SIGNATURE";
10489             case INSTALL_FAILED_WRONG_INSTALLED_VERSION: return "INSTALL_FAILED_WRONG_INSTALLED_VERSION";
10490             case INSTALL_FAILED_PROCESS_NOT_DEFINED: return "INSTALL_FAILED_PROCESS_NOT_DEFINED";
10491             case INSTALL_FAILED_SESSION_INVALID: return "INSTALL_FAILED_SESSION_INVALID";
10492             case INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST:
10493                 return "INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST";
10494             case INSTALL_FAILED_MULTI_ARCH_NOT_MATCH_ALL_NATIVE_ABIS:
10495                 return "INSTALL_FAILED_MULTI_ARCH_NOT_MATCH_ALL_NATIVE_ABIS";
10496             default: return Integer.toString(status);
10497         }
10498     }
10499 
10500     /** {@hide} */
installStatusToPublicStatus(int status)10501     public static int installStatusToPublicStatus(int status) {
10502         switch (status) {
10503             case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
10504             case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10505             case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
10506             case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
10507             case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
10508             case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10509             case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10510             case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10511             case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10512             case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10513             case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10514             case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
10515             case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10516             case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10517             case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10518             case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
10519             case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10520             case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10521             case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
10522             case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
10523             case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
10524             case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
10525             case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
10526             case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
10527             case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
10528             case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
10529             case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
10530             case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
10531             case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
10532             case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
10533             case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
10534             case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
10535             case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
10536             case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
10537             case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
10538             case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
10539             case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
10540             case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID;
10541             case INSTALL_FAILED_BAD_SIGNATURE: return PackageInstaller.STATUS_FAILURE_INVALID;
10542             case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
10543             case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10544             case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10545             case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10546             case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
10547             case INSTALL_FAILED_MISSING_SPLIT: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10548             case INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE: return PackageInstaller.STATUS_FAILURE_BLOCKED;
10549             case INSTALL_FAILED_DEPRECATED_SDK_VERSION: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
10550             default: return PackageInstaller.STATUS_FAILURE;
10551         }
10552     }
10553 
10554     /** {@hide} */
10555     @NonNull
deleteStatusToString(int status, @Nullable String msg)10556     public static String deleteStatusToString(int status, @Nullable String msg) {
10557         final String str = deleteStatusToString(status);
10558         if (msg != null) {
10559             return str + ": " + msg;
10560         } else {
10561             return str;
10562         }
10563     }
10564 
10565     /** {@hide} */
10566     @NonNull
10567     @UnsupportedAppUsage
deleteStatusToString(int status)10568     public static String deleteStatusToString(int status) {
10569         switch (status) {
10570             case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
10571             case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
10572             case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
10573             case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
10574             case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
10575             case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
10576             case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY";
10577             case DELETE_FAILED_APP_PINNED: return "DELETE_FAILED_APP_PINNED";
10578             default: return Integer.toString(status);
10579         }
10580     }
10581 
10582     /** {@hide} */
deleteStatusToPublicStatus(int status)10583     public static int deleteStatusToPublicStatus(int status) {
10584         switch (status) {
10585             case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
10586             case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
10587             case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
10588             case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
10589             case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
10590             case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
10591             case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT;
10592             case DELETE_FAILED_APP_PINNED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
10593             default: return PackageInstaller.STATUS_FAILURE;
10594         }
10595     }
10596 
10597     /** {@hide} */
10598     @NonNull
permissionFlagToString(int flag)10599     public static String permissionFlagToString(int flag) {
10600         switch (flag) {
10601             case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
10602             case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
10603             case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
10604             case FLAG_PERMISSION_USER_SET: return "USER_SET";
10605             case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
10606             case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
10607             case FLAG_PERMISSION_REVOKE_WHEN_REQUESTED: return "REVOKE_WHEN_REQUESTED";
10608             case FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED: return "USER_SENSITIVE_WHEN_GRANTED";
10609             case FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED: return "USER_SENSITIVE_WHEN_DENIED";
10610             case FLAG_PERMISSION_RESTRICTION_INSTALLER_EXEMPT: return "RESTRICTION_INSTALLER_EXEMPT";
10611             case FLAG_PERMISSION_RESTRICTION_SYSTEM_EXEMPT: return "RESTRICTION_SYSTEM_EXEMPT";
10612             case FLAG_PERMISSION_RESTRICTION_UPGRADE_EXEMPT: return "RESTRICTION_UPGRADE_EXEMPT";
10613             case FLAG_PERMISSION_APPLY_RESTRICTION: return "APPLY_RESTRICTION";
10614             case FLAG_PERMISSION_GRANTED_BY_ROLE: return "GRANTED_BY_ROLE";
10615             case FLAG_PERMISSION_REVOKED_COMPAT: return "REVOKED_COMPAT";
10616             case FLAG_PERMISSION_ONE_TIME: return "ONE_TIME";
10617             case FLAG_PERMISSION_AUTO_REVOKED: return "AUTO_REVOKED";
10618             default: return Integer.toString(flag);
10619         }
10620     }
10621 
10622     /** {@hide} */
10623     public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
10624         private final IPackageDeleteObserver mLegacy;
10625 
LegacyPackageDeleteObserver(IPackageDeleteObserver legacy)10626         public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
10627             mLegacy = legacy;
10628         }
10629 
10630         @Override
onPackageDeleted(String basePackageName, int returnCode, String msg)10631         public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
10632             if (mLegacy == null) return;
10633             try {
10634                 mLegacy.packageDeleted(basePackageName, returnCode);
10635             } catch (RemoteException ignored) {
10636             }
10637         }
10638     }
10639 
10640     /**
10641      * A parcelable class to pass as an intent extra to the PackageInstaller. When an uninstall is
10642      * completed (both successfully or unsuccessfully), the result is sent to the uninstall
10643      * initiators.
10644      *
10645      * @hide
10646      */
10647     @SystemApi
10648     public static final class UninstallCompleteCallback implements Parcelable {
10649         private IPackageDeleteObserver2 mBinder;
10650 
10651         /** @hide */
10652         @IntDef(prefix = { "DELETE_" }, value = {
10653                 DELETE_SUCCEEDED,
10654                 DELETE_FAILED_INTERNAL_ERROR,
10655                 DELETE_FAILED_DEVICE_POLICY_MANAGER,
10656                 DELETE_FAILED_USER_RESTRICTED,
10657                 DELETE_FAILED_OWNER_BLOCKED,
10658                 DELETE_FAILED_ABORTED,
10659                 DELETE_FAILED_USED_SHARED_LIBRARY,
10660                 DELETE_FAILED_APP_PINNED,
10661         })
10662         @Retention(RetentionPolicy.SOURCE)
10663         public @interface DeleteStatus{}
10664 
10665         /** @hide */
UninstallCompleteCallback(@onNull IBinder binder)10666         public UninstallCompleteCallback(@NonNull IBinder binder) {
10667             mBinder = IPackageDeleteObserver2.Stub.asInterface(binder);
10668         }
10669 
10670         /** @hide */
UninstallCompleteCallback(Parcel in)10671         private UninstallCompleteCallback(Parcel in) {
10672             mBinder = IPackageDeleteObserver2.Stub.asInterface(in.readStrongBinder());
10673         }
10674 
10675         public static final @NonNull Parcelable.Creator<UninstallCompleteCallback> CREATOR =
10676                 new Parcelable.Creator<>() {
10677                     public UninstallCompleteCallback createFromParcel(Parcel source) {
10678                         return new UninstallCompleteCallback(source);
10679                     }
10680 
10681                     public UninstallCompleteCallback[] newArray(int size) {
10682                         return new UninstallCompleteCallback[size];
10683                     }
10684                 };
10685 
10686         /**
10687          * Called when an uninstallation is completed successfully or unsuccessfully.
10688          *
10689          * @param packageName The name of the package being uninstalled.
10690          * @param resultCode Result code of the operation.
10691          * @param errorMessage Error message if any.
10692          *
10693          * @hide */
10694         @SystemApi
onUninstallComplete(@onNull String packageName, @DeleteStatus int resultCode, @Nullable String errorMessage)10695         public void onUninstallComplete(@NonNull String packageName, @DeleteStatus int resultCode,
10696                 @Nullable String errorMessage) {
10697             try {
10698                 mBinder.onPackageDeleted(packageName, resultCode, errorMessage);
10699             } catch (RemoteException e) {
10700                 // no-op
10701             }
10702         }
10703 
10704         /** @hide */
10705         @Override
describeContents()10706         public int describeContents() {
10707             return 0;
10708         }
10709 
10710         /** @hide */
10711         @Override
writeToParcel(@onNull Parcel dest, int flags)10712         public void writeToParcel(@NonNull Parcel dest, int flags) {
10713             dest.writeStrongBinder(mBinder.asBinder());
10714         }
10715     }
10716 
10717     /**
10718      * Return the install reason that was recorded when a package was first
10719      * installed for a specific user. Requesting the install reason for another
10720      * user will require the permission INTERACT_ACROSS_USERS_FULL.
10721      *
10722      * @param packageName The package for which to retrieve the install reason
10723      * @param user The user for whom to retrieve the install reason
10724      * @return The install reason. If the package is not installed for the given
10725      *         user, {@code INSTALL_REASON_UNKNOWN} is returned.
10726      * @hide
10727      */
10728     @SuppressWarnings("HiddenAbstractMethod")
10729     @TestApi
10730     @InstallReason
getInstallReason(@onNull String packageName, @NonNull UserHandle user)10731     public abstract int getInstallReason(@NonNull String packageName, @NonNull UserHandle user);
10732 
10733     /**
10734      * Checks whether the calling package is allowed to request package installs through package
10735      * installer. Apps are encouraged to call this API before launching the package installer via
10736      * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the
10737      * user can explicitly choose what external sources they trust to install apps on the device.
10738      * If this API returns false, the install request will be blocked by the package installer and
10739      * a dialog will be shown to the user with an option to launch settings to change their
10740      * preference. An application must target Android O or higher and declare permission
10741      * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API.
10742      *
10743      * @return true if the calling package is trusted by the user to request install packages on
10744      * the device, false otherwise.
10745      * @see android.content.Intent#ACTION_INSTALL_PACKAGE
10746      * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES
10747      */
canRequestPackageInstalls()10748     public abstract boolean canRequestPackageInstalls();
10749 
10750     /**
10751      * Return the {@link ComponentName} of the activity providing Settings for the Instant App
10752      * resolver.
10753      *
10754      * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS}
10755      * @hide
10756      */
10757     @SuppressWarnings("HiddenAbstractMethod")
10758     @Nullable
10759     @SystemApi
getInstantAppResolverSettingsComponent()10760     public abstract ComponentName getInstantAppResolverSettingsComponent();
10761 
10762     /**
10763      * Return the {@link ComponentName} of the activity responsible for installing instant
10764      * applications.
10765      *
10766      * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE}
10767      * @hide
10768      */
10769     @SuppressWarnings("HiddenAbstractMethod")
10770     @Nullable
10771     @SystemApi
getInstantAppInstallerComponent()10772     public abstract ComponentName getInstantAppInstallerComponent();
10773 
10774     /**
10775      * Return the Android Id for a given Instant App.
10776      *
10777      * @see {@link android.provider.Settings.Secure#ANDROID_ID}
10778      * @hide
10779      */
10780     @SuppressWarnings("HiddenAbstractMethod")
10781     @Nullable
getInstantAppAndroidId(@onNull String packageName, @NonNull UserHandle user)10782     public abstract String getInstantAppAndroidId(@NonNull String packageName,
10783             @NonNull UserHandle user);
10784 
10785     /**
10786      * Callback use to notify the callers of module registration that the operation
10787      * has finished.
10788      *
10789      * @hide
10790      */
10791     @SystemApi
10792     public static abstract class DexModuleRegisterCallback {
onDexModuleRegistered(String dexModulePath, boolean success, String message)10793         public abstract void onDexModuleRegistered(String dexModulePath, boolean success,
10794                 String message);
10795     }
10796 
10797     /**
10798      * Register an application dex module with the package manager.
10799      *
10800      * This call no longer does anything. If a callback is given it is called with a false success
10801      * value.
10802      *
10803      * @param dexModulePath the absolute path of the dex module.
10804      * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will
10805      *                 be called once the registration finishes.
10806      *
10807      * @hide
10808      */
10809     @SuppressWarnings("HiddenAbstractMethod")
10810     @SystemApi
registerDexModule(@onNull String dexModulePath, @Nullable DexModuleRegisterCallback callback)10811     public abstract void registerDexModule(@NonNull String dexModulePath,
10812             @Nullable DexModuleRegisterCallback callback);
10813 
10814     /**
10815      * Returns the {@link ArtManager} associated with this package manager.
10816      *
10817      * @hide
10818      */
10819     @SystemApi
getArtManager()10820     public @NonNull ArtManager getArtManager() {
10821         throw new UnsupportedOperationException("getArtManager not implemented in subclass");
10822     }
10823 
10824     /**
10825      * Sets or clears the harmful app warning details for the given app.
10826      *
10827      * When set, any attempt to launch an activity in this package will be intercepted and a
10828      * warning dialog will be shown to the user instead, with the given warning. The user
10829      * will have the option to proceed with the activity launch, or to uninstall the application.
10830      *
10831      * @param packageName The full name of the package to warn on.
10832      * @param warning A warning string to display to the user describing the threat posed by the
10833      *                application, or null to clear the warning.
10834      *
10835      * @hide
10836      */
10837     @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
10838     @SystemApi
setHarmfulAppWarning(@onNull String packageName, @Nullable CharSequence warning)10839     public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) {
10840         throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass");
10841     }
10842 
10843     /**
10844      * Returns the harmful app warning string for the given app, or null if there is none set.
10845      *
10846      * @param packageName The full name of the desired package.
10847      *
10848      * @hide
10849      */
10850     @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
10851     @Nullable
10852     @SystemApi
getHarmfulAppWarning(@onNull String packageName)10853     public CharSequence getHarmfulAppWarning(@NonNull String packageName) {
10854         throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass");
10855     }
10856 
10857     /** @hide */
10858     @IntDef(prefix = { "CERT_INPUT_" }, value = {
10859             CERT_INPUT_RAW_X509,
10860             CERT_INPUT_SHA256
10861     })
10862     @Retention(RetentionPolicy.SOURCE)
10863     public @interface CertificateInputType {}
10864 
10865     /**
10866      * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could
10867      * be generated using an {@code CertificateFactory}
10868      */
10869     public static final int CERT_INPUT_RAW_X509 = 0;
10870 
10871     /**
10872      * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509
10873      * Certificate.
10874      */
10875     public static final int CERT_INPUT_SHA256 = 1;
10876 
10877     /**
10878      * Searches the set of signing certificates by which the given package has proven to have been
10879      * signed.  This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
10880      * since it takes into account the possibility of signing certificate rotation, except in the
10881      * case of packages that are signed by multiple certificates, for which signing certificate
10882      * rotation is not supported.  This method is analogous to using {@code getPackageInfo} with
10883      * {@code GET_SIGNING_CERTIFICATES} and then searching through the resulting {@code
10884      * signingInfo} field to see if the desired certificate is present.
10885      *
10886      * @param packageName package whose signing certificates to check
10887      * @param certificate signing certificate for which to search
10888      * @param type representation of the {@code certificate}
10889      * @return true if this package was or is signed by exactly the certificate {@code certificate}
10890      */
hasSigningCertificate(@onNull String packageName, @NonNull byte[] certificate, @CertificateInputType int type)10891     public boolean hasSigningCertificate(@NonNull String packageName, @NonNull byte[] certificate,
10892             @CertificateInputType int type) {
10893         throw new UnsupportedOperationException(
10894                 "hasSigningCertificate not implemented in subclass");
10895     }
10896 
10897     /**
10898      * Searches the set of signing certificates by which the package(s) for the given uid has proven
10899      * to have been signed.  For multiple packages sharing the same uid, this will return the
10900      * signing certificates found in the signing history of the "newest" package, where "newest"
10901      * indicates the package with the newest signing certificate in the shared uid group.  This
10902      * method should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
10903      * since it takes into account the possibility of signing certificate rotation, except in the
10904      * case of packages that are signed by multiple certificates, for which signing certificate
10905      * rotation is not supported. This method is analogous to using {@code getPackagesForUid}
10906      * followed by {@code getPackageInfo} with {@code GET_SIGNING_CERTIFICATES}, selecting the
10907      * {@code PackageInfo} of the newest-signed bpackage , and finally searching through the
10908      * resulting {@code signingInfo} field to see if the desired certificate is there.
10909      *
10910      * @param uid uid whose signing certificates to check
10911      * @param certificate signing certificate for which to search
10912      * @param type representation of the {@code certificate}
10913      * @return true if this package was or is signed by exactly the certificate {@code certificate}
10914      */
hasSigningCertificate( int uid, @NonNull byte[] certificate, @CertificateInputType int type)10915     public boolean hasSigningCertificate(
10916             int uid, @NonNull byte[] certificate, @CertificateInputType int type) {
10917         throw new UnsupportedOperationException(
10918                 "hasSigningCertificate not implemented in subclass");
10919     }
10920 
10921     /**
10922      * Trust any Installer to provide checksums for the package.
10923      * @see #requestChecksums
10924      */
10925     public static final @NonNull List<Certificate> TRUST_ALL = Collections.singletonList(null);
10926 
10927     /**
10928      * Don't trust any Installer to provide checksums for the package.
10929      * This effectively disables optimized Installer-enforced checksums.
10930      * @see #requestChecksums
10931      */
10932     public static final @NonNull List<Certificate> TRUST_NONE = Collections.singletonList(null);
10933 
10934     /** Listener that gets notified when checksums are available. */
10935     @FunctionalInterface
10936     public interface OnChecksumsReadyListener {
10937         /**
10938          * Called when the checksums are available.
10939          *
10940          * @param checksums array of checksums.
10941          */
onChecksumsReady(@onNull List<ApkChecksum> checksums)10942         void onChecksumsReady(@NonNull List<ApkChecksum> checksums);
10943     }
10944 
10945     /**
10946      * Requests the checksums for APKs within a package.
10947      * The checksums will be returned asynchronously via onChecksumsReadyListener.
10948      *
10949      * By default returns all readily available checksums:
10950      * - enforced by platform,
10951      * - enforced by installer.
10952      * If caller needs a specific checksum kind, they can specify it as required.
10953      *
10954      * <b>Caution: Android can not verify installer-provided checksums. Make sure you specify
10955      * trusted installers.</b>
10956      *
10957      * @param packageName whose checksums to return.
10958      * @param includeSplits whether to include checksums for non-base splits.
10959      * @param required explicitly request the checksum types. May incur significant
10960      *                 CPU/memory/disk usage.
10961      * @param trustedInstallers for checksums enforced by installer, which installers are to be
10962      *                          trusted.
10963      *                          {@link #TRUST_ALL} will return checksums from any installer,
10964      *                          {@link #TRUST_NONE} disables optimized installer-enforced checksums,
10965      *                          otherwise the list has to be non-empty list of certificates.
10966      * @param onChecksumsReadyListener called once when the results are available.
10967      * @throws CertificateEncodingException if an encoding error occurs for trustedInstallers.
10968      * @throws IllegalArgumentException if the list of trusted installer certificates is empty.
10969      * @throws NameNotFoundException if a package with the given name cannot be found on the system.
10970      */
requestChecksums(@onNull String packageName, boolean includeSplits, @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers, @NonNull OnChecksumsReadyListener onChecksumsReadyListener)10971     public void requestChecksums(@NonNull String packageName, boolean includeSplits,
10972             @Checksum.TypeMask int required, @NonNull List<Certificate> trustedInstallers,
10973             @NonNull OnChecksumsReadyListener onChecksumsReadyListener)
10974             throws CertificateEncodingException, NameNotFoundException {
10975         throw new UnsupportedOperationException("requestChecksums not implemented in subclass");
10976     }
10977 
10978     /**
10979      * @return the default text classifier package name, or null if there's none.
10980      *
10981      * @hide
10982      */
10983     @Nullable
10984     @TestApi
getDefaultTextClassifierPackageName()10985     public String getDefaultTextClassifierPackageName() {
10986         throw new UnsupportedOperationException(
10987                 "getDefaultTextClassifierPackageName not implemented in subclass");
10988     }
10989 
10990     /**
10991      * @return the system defined text classifier package names, or null if there's none.
10992      *
10993      * @hide
10994      */
10995     @Nullable
10996     @TestApi
getSystemTextClassifierPackageName()10997     public String getSystemTextClassifierPackageName() {
10998         throw new UnsupportedOperationException(
10999                 "getSystemTextClassifierPackageName not implemented in subclass");
11000     }
11001 
11002     /**
11003      * @return  attention service package name, or null if there's none.
11004      *
11005      * @hide
11006      */
getAttentionServicePackageName()11007     public String getAttentionServicePackageName() {
11008         throw new UnsupportedOperationException(
11009                 "getAttentionServicePackageName not implemented in subclass");
11010     }
11011 
11012     /**
11013      * @return rotation resolver service's package name, or null if there's none.
11014      *
11015      * @hide
11016      */
getRotationResolverPackageName()11017     public String getRotationResolverPackageName() {
11018         throw new UnsupportedOperationException(
11019                 "getRotationResolverPackageName not implemented in subclass");
11020     }
11021 
11022     /**
11023      * @return the wellbeing app package name, or null if it's not defined by the OEM.
11024      *
11025      * @hide
11026      */
11027     @Nullable
11028     @TestApi
getWellbeingPackageName()11029     public String getWellbeingPackageName() {
11030         throw new UnsupportedOperationException(
11031                 "getWellbeingPackageName not implemented in subclass");
11032     }
11033 
11034     /**
11035      * @return the system defined app predictor package name, or null if there's none.
11036      *
11037      * @hide
11038      */
11039     @Nullable
getAppPredictionServicePackageName()11040     public String getAppPredictionServicePackageName() {
11041         throw new UnsupportedOperationException(
11042             "getAppPredictionServicePackageName not implemented in subclass");
11043     }
11044 
11045     /**
11046      * @return the system defined content capture service package name, or null if there's none.
11047      *
11048      * @hide
11049      */
11050     @Nullable
getSystemCaptionsServicePackageName()11051     public String getSystemCaptionsServicePackageName() {
11052         throw new UnsupportedOperationException(
11053                 "getSystemCaptionsServicePackageName not implemented in subclass");
11054     }
11055 
11056     /**
11057      * @return the system defined setup wizard package name, or null if there's none.
11058      *
11059      * @hide
11060      */
11061     @Nullable
getSetupWizardPackageName()11062     public String getSetupWizardPackageName() {
11063         throw new UnsupportedOperationException(
11064                 "getSetupWizardPackageName not implemented in subclass");
11065     }
11066 
11067     /**
11068      * @deprecated This function throws an {@link UnsupportedOperationException}. For pre-granting
11069      * permissions, instead of looking up the package that provides {@code ContentCaptureService},
11070      * use roles.
11071      *
11072      * @hide
11073      */
11074     // This function cannot yet be removed because it is referenced from GTS tests. The tests have
11075     // been updated to not rely on it when running on Android T and above, but in order to compile
11076     // the tests we must keep this method.
11077     @Deprecated
11078     @TestApi
11079     @Nullable
getContentCaptureServicePackageName()11080     public final String getContentCaptureServicePackageName() {
11081         throw new UnsupportedOperationException(
11082                 "getContentCaptureServicePackageName is deprecated");
11083     }
11084 
11085     /**
11086      * @return the incident report approver app package name, or null if it's not defined
11087      * by the OEM.
11088      *
11089      * @hide
11090      */
11091     @SystemApi
11092     @Nullable
getIncidentReportApproverPackageName()11093     public String getIncidentReportApproverPackageName() {
11094         throw new UnsupportedOperationException(
11095                 "getIncidentReportApproverPackageName not implemented in subclass");
11096     }
11097 
11098     /**
11099      * @return whether a given package's state is protected, e.g. package cannot be disabled,
11100      *         suspended, hidden or force stopped.
11101      *
11102      * @hide
11103      */
isPackageStateProtected(@onNull String packageName, @UserIdInt int userId)11104     public boolean isPackageStateProtected(@NonNull String packageName, @UserIdInt int userId) {
11105         throw new UnsupportedOperationException(
11106             "isPackageStateProtected not implemented in subclass");
11107     }
11108 
11109     /**
11110      * Notify to the rest of the system that a new device configuration has
11111      * been prepared and that it is time to refresh caches.
11112      *
11113      * @see android.content.Intent#ACTION_DEVICE_CUSTOMIZATION_READY
11114      *
11115      * @hide
11116      */
11117     @SystemApi
sendDeviceCustomizationReadyBroadcast()11118     public void sendDeviceCustomizationReadyBroadcast() {
11119         throw new UnsupportedOperationException(
11120             "sendDeviceCustomizationReadyBroadcast not implemented in subclass");
11121     }
11122 
11123     /**
11124      * <p>
11125      * <strong>Note: </strong>In retrospect it would have been preferred to use
11126      * more inclusive terminology when naming this API. Similar APIs added will
11127      * refrain from using the term "whitelist".
11128      * </p>
11129      *
11130      * @return whether this package is whitelisted from having its runtime permission be
11131      *         auto-revoked if unused for an extended period of time.
11132      */
isAutoRevokeWhitelisted()11133     public boolean isAutoRevokeWhitelisted() {
11134         throw new UnsupportedOperationException(
11135                 "isAutoRevokeWhitelisted not implemented in subclass");
11136     }
11137 
11138     /**
11139      * Returns if the provided drawable represents the default activity icon provided by the system.
11140      *
11141      * PackageManager silently returns a default application icon for any package/activity if the
11142      * app itself does not define one or if the system encountered any error when loading the icon.
11143      *
11144      * Developers can use this to check implement app specific logic around retrying or caching.
11145      *
11146      * @return true if the drawable represents the default activity icon, false otherwise
11147      * @see #getDefaultActivityIcon()
11148      * @see #getActivityIcon
11149      * @see LauncherActivityInfo#getIcon(int)
11150      */
isDefaultApplicationIcon(@onNull Drawable drawable)11151     public boolean isDefaultApplicationIcon(@NonNull Drawable drawable) {
11152         int resId = drawable instanceof AdaptiveIconDrawable
11153                 ? ((AdaptiveIconDrawable) drawable).getSourceDrawableResId() : Resources.ID_NULL;
11154         return resId == com.android.internal.R.drawable.sym_def_app_icon
11155                 || resId == com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon;
11156     }
11157 
11158     /**
11159      * Sets MIME group's MIME types.
11160      *
11161      * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific
11162      * group name to avoid namespace collisions, e.g. "com.example:myFeature".
11163      *
11164      * @param mimeGroup MIME group to modify.
11165      * @param mimeTypes new MIME types contained by MIME group.
11166      * @throws IllegalArgumentException if the MIME group was not declared in the manifest.
11167      */
setMimeGroup(@onNull String mimeGroup, @NonNull Set<String> mimeTypes)11168     public void setMimeGroup(@NonNull String mimeGroup, @NonNull Set<String> mimeTypes) {
11169         throw new UnsupportedOperationException(
11170                 "setMimeGroup not implemented in subclass");
11171     }
11172 
11173     /**
11174      * Gets all MIME types contained by MIME group.
11175      *
11176      * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific
11177      * group name to avoid namespace collisions, e.g. "com.example:myFeature".
11178      *
11179      * @param mimeGroup MIME group to retrieve.
11180      * @return MIME types contained by the MIME group.
11181      * @throws IllegalArgumentException if the MIME group was not declared in the manifest.
11182      */
11183     @NonNull
getMimeGroup(@onNull String mimeGroup)11184     public Set<String> getMimeGroup(@NonNull String mimeGroup) {
11185         throw new UnsupportedOperationException(
11186                 "getMimeGroup not implemented in subclass");
11187     }
11188 
11189     /**
11190      * Returns the property defined in the given package's &lt;application&gt; tag.
11191      *
11192      * @throws NameNotFoundException if either the given package is not installed or if the
11193      * given property is not defined within the &lt;application&gt; tag.
11194      */
11195     @NonNull
getProperty(@onNull String propertyName, @NonNull String packageName)11196     public Property getProperty(@NonNull String propertyName, @NonNull String packageName)
11197             throws NameNotFoundException {
11198         throw new UnsupportedOperationException(
11199                 "getProperty not implemented in subclass");
11200     }
11201 
11202     /**
11203      * Returns the property defined in the given component declaration.
11204      *
11205      * @throws NameNotFoundException if either the given component does not exist or if the
11206      * given property is not defined within the component declaration.
11207      */
11208     @NonNull
getProperty(@onNull String propertyName, @NonNull ComponentName component)11209     public Property getProperty(@NonNull String propertyName, @NonNull ComponentName component)
11210             throws NameNotFoundException {
11211         throw new UnsupportedOperationException(
11212                 "getProperty not implemented in subclass");
11213     }
11214 
11215     /**
11216      * If the provided className is {@code null}, returns the property defined on the application.
11217      * Otherwise, returns the property defined on the component.
11218      *
11219      * @throws NameNotFoundException if the given package is not installed on the calling user or
11220      * component does not exist or if the given property is not defined within the manifest.
11221      * @hide
11222      */
11223     @NonNull
getPropertyAsUser(@onNull String propertyName, @NonNull String packageName, @Nullable String className, int userId)11224     public Property getPropertyAsUser(@NonNull String propertyName, @NonNull String packageName,
11225             @Nullable String className, int userId) throws NameNotFoundException {
11226         throw new UnsupportedOperationException(
11227                 "getPropertyAsUser not implemented in subclass");
11228     }
11229 
11230     /**
11231      * Returns the property definition for all &lt;application&gt; tags.
11232      * <p>If the property is not defined with any &lt;application&gt; tag,
11233      * returns and empty list.
11234      */
11235     @NonNull
queryApplicationProperty(@onNull String propertyName)11236     public List<Property> queryApplicationProperty(@NonNull String propertyName) {
11237         throw new UnsupportedOperationException(
11238                 "qeuryApplicationProperty not implemented in subclass");
11239     }
11240 
11241     /**
11242      * Returns the property definition for all &lt;activity&gt; and &lt;activity-alias&gt; tags.
11243      * <p>If the property is not defined with any &lt;activity&gt; and &lt;activity-alias&gt; tag,
11244      * returns and empty list.
11245      */
11246     @NonNull
queryActivityProperty(@onNull String propertyName)11247     public List<Property> queryActivityProperty(@NonNull String propertyName) {
11248         throw new UnsupportedOperationException(
11249                 "qeuryActivityProperty not implemented in subclass");
11250     }
11251 
11252     /**
11253      * Returns the property definition for all &lt;provider&gt; tags.
11254      * <p>If the property is not defined with any &lt;provider&gt; tag,
11255      * returns and empty list.
11256      */
11257     @NonNull
queryProviderProperty(@onNull String propertyName)11258     public List<Property> queryProviderProperty(@NonNull String propertyName) {
11259         throw new UnsupportedOperationException(
11260                 "qeuryProviderProperty not implemented in subclass");
11261     }
11262 
11263     /**
11264      * Returns the property definition for all &lt;receiver&gt; tags.
11265      * <p>If the property is not defined with any &lt;receiver&gt; tag,
11266      * returns and empty list.
11267      */
11268     @NonNull
queryReceiverProperty(@onNull String propertyName)11269     public List<Property> queryReceiverProperty(@NonNull String propertyName) {
11270         throw new UnsupportedOperationException(
11271                 "qeuryReceiverProperty not implemented in subclass");
11272     }
11273 
11274     /**
11275      * Returns the property definition for all &lt;service&gt; tags.
11276      * <p>If the property is not defined with any &lt;service&gt; tag,
11277      * returns and empty list.
11278      */
11279     @NonNull
queryServiceProperty(@onNull String propertyName)11280     public List<Property> queryServiceProperty(@NonNull String propertyName) {
11281         throw new UnsupportedOperationException(
11282                 "qeuryServiceProperty not implemented in subclass");
11283     }
11284 
11285     /**
11286      * Returns {@code true} if the source package is able to query for details about the
11287      * target package. Applications that share details about other applications should
11288      * use this API to determine if those details should be withheld from callers that
11289      * do not otherwise have visibility of them.
11290      * <p>
11291      * Note: The caller must be able to query for details about the source and target
11292      * package. A {@link NameNotFoundException} is thrown if it isn't.
11293      *
11294      * @param sourcePackageName The source package that would receive details about the
11295      *                          target package.
11296      * @param targetPackageName The target package whose details would be shared with the
11297      *                          source package.
11298      * @return {@code true} if the source package is able to query for details about the
11299      * target package.
11300      * @throws NameNotFoundException if either a given package can not be found on the
11301      * system, or if the caller is not able to query for details about the source or
11302      * target package.
11303      */
canPackageQuery(@onNull String sourcePackageName, @NonNull String targetPackageName)11304     public boolean canPackageQuery(@NonNull String sourcePackageName,
11305             @NonNull String targetPackageName) throws NameNotFoundException {
11306         throw new UnsupportedOperationException(
11307                 "canPackageQuery not implemented in subclass");
11308     }
11309 
11310     /**
11311      * Same as {@link #canPackageQuery(String, String)} but accepts an array of target packages to
11312      * be queried.
11313      *
11314      * @param sourcePackageName The source package that would receive details about the
11315      *                          target package.
11316      * @param targetPackageNames An array of target packages whose details would be shared with the
11317      *                           source package.
11318      * @return An array of booleans where each member specifies whether the source package is able
11319      * to query for details about the target package given by the corresponding value at the same
11320      * index in the array of target packages.
11321      * @throws NameNotFoundException if either a given package can not be found on the
11322      * system, or if the caller is not able to query for details about the source or
11323      * target packages.
11324      */
11325     @NonNull
canPackageQuery(@onNull String sourcePackageName, @NonNull String[] targetPackageNames)11326     public boolean[] canPackageQuery(@NonNull String sourcePackageName,
11327             @NonNull String[] targetPackageNames) throws NameNotFoundException {
11328         throw new UnsupportedOperationException(
11329                 "canPackageQuery not implemented in subclass");
11330     }
11331 
11332     /**
11333      * Makes a package that provides an authority {@code visibleAuthority} become visible to the
11334      * application {@code recipientUid}.
11335      *
11336      * @throws SecurityException when called by a package other than the contacts provider
11337      * @hide
11338      */
makeProviderVisible(int recipientUid, String visibleAuthority)11339     public void makeProviderVisible(int recipientUid, String visibleAuthority) {
11340         try {
11341             ActivityThread.getPackageManager().makeProviderVisible(recipientUid, visibleAuthority);
11342         } catch (RemoteException e) {
11343             throw e.rethrowFromSystemServer();
11344         }
11345     }
11346 
11347     /**
11348      * Makes the package associated with the uid {@code visibleUid} become visible to the
11349      * recipient application. The recipient application can receive the details about the
11350      * visible package if successful.
11351      * <p>
11352      * Read <a href="/training/basics/intents/package-visibility">package visibility</a> for more
11353      * information.
11354      *
11355      * @param recipientUid The uid of the application that is being given access to {@code
11356      *                     visibleUid}
11357      * @param visibleUid The uid of the application that is becoming accessible to {@code
11358      *                   recipientAppId}
11359      * @hide
11360      */
11361     @RequiresPermission(android.Manifest.permission.MAKE_UID_VISIBLE)
11362     @TestApi
11363     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
makeUidVisible(int recipientUid, int visibleUid)11364     public void makeUidVisible(int recipientUid, int visibleUid) {
11365         throw new UnsupportedOperationException(
11366                 "makeUidVisible not implemented in subclass");
11367     }
11368 
11369     /**
11370      * Return archived package info for the package or null if the package is not installed.
11371      * @see PackageInstaller#installPackageArchived
11372      */
11373     @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING)
getArchivedPackage(@onNull String packageName)11374     public @Nullable ArchivedPackageInfo getArchivedPackage(@NonNull String packageName) {
11375         throw new UnsupportedOperationException(
11376                 "getArchivedPackage not implemented in subclass");
11377     }
11378 
11379     // Some of the flags don't affect the query result, but let's be conservative and cache
11380     // each combination of flags separately.
11381 
11382     private static final class ApplicationInfoQuery {
11383         final String packageName;
11384         final long flags;
11385         final int userId;
11386 
ApplicationInfoQuery(@ullable String packageName, @ApplicationInfoFlagsBits long flags, int userId)11387         ApplicationInfoQuery(@Nullable String packageName, @ApplicationInfoFlagsBits long flags,
11388                 int userId) {
11389             this.packageName = packageName;
11390             this.flags = flags;
11391             this.userId = userId;
11392         }
11393 
11394         @Override
toString()11395         public String toString() {
11396             return String.format(
11397                     "ApplicationInfoQuery(packageName=\"%s\", flags=%s, userId=%s)",
11398                     packageName, flags, userId);
11399         }
11400 
11401         @Override
hashCode()11402         public int hashCode() {
11403             int hash = Objects.hashCode(packageName);
11404             hash = hash * 13 + Objects.hashCode(flags);
11405             hash = hash * 13 + Objects.hashCode(userId);
11406             return hash;
11407         }
11408 
11409         @Override
equals(@ullable Object rval)11410         public boolean equals(@Nullable Object rval) {
11411             if (rval == null) {
11412                 return false;
11413             }
11414             ApplicationInfoQuery other;
11415             try {
11416                 other = (ApplicationInfoQuery) rval;
11417             } catch (ClassCastException ex) {
11418                 return false;
11419             }
11420             return Objects.equals(packageName, other.packageName)
11421                     && flags == other.flags
11422                     && userId == other.userId;
11423         }
11424     }
11425 
getApplicationInfoAsUserUncached( String packageName, @ApplicationInfoFlagsBits long flags, int userId)11426     private static ApplicationInfo getApplicationInfoAsUserUncached(
11427             String packageName, @ApplicationInfoFlagsBits long flags, int userId) {
11428         try {
11429             return ActivityThread.getPackageManager()
11430                     .getApplicationInfo(packageName, flags, userId);
11431         } catch (RemoteException e) {
11432             throw e.rethrowFromSystemServer();
11433         }
11434     }
11435 
11436     private static final PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo>
11437             sApplicationInfoCache =
11438             new PropertyInvalidatedCache<ApplicationInfoQuery, ApplicationInfo>(
11439                     32, PermissionManager.CACHE_KEY_PACKAGE_INFO,
11440                     "getApplicationInfo") {
11441                 @Override
11442                 public ApplicationInfo recompute(ApplicationInfoQuery query) {
11443                     return getApplicationInfoAsUserUncached(
11444                             query.packageName, query.flags, query.userId);
11445                 }
11446                 @Override
11447                 public boolean resultEquals(ApplicationInfo cached, ApplicationInfo fetched) {
11448                     // Implementing this debug check for ApplicationInfo would require a
11449                     // complicated deep comparison, so just bypass it for now.
11450                     return true;
11451                 }
11452             };
11453 
11454     /** @hide */
getApplicationInfoAsUserCached( String packageName, @ApplicationInfoFlagsBits long flags, int userId)11455     public static ApplicationInfo getApplicationInfoAsUserCached(
11456             String packageName, @ApplicationInfoFlagsBits long flags, int userId) {
11457         return sApplicationInfoCache.query(
11458                 new ApplicationInfoQuery(packageName, flags, userId));
11459     }
11460 
11461     /**
11462      * Make getApplicationInfoAsUser() bypass the cache in this process.
11463      *
11464      * @hide
11465      */
disableApplicationInfoCache()11466     public static void disableApplicationInfoCache() {
11467         sApplicationInfoCache.disableLocal();
11468     }
11469 
11470     private static final PropertyInvalidatedCache.AutoCorker sCacheAutoCorker =
11471             new PropertyInvalidatedCache.AutoCorker(PermissionManager.CACHE_KEY_PACKAGE_INFO);
11472 
11473     /**
11474      * Invalidate caches of package and permission information system-wide.
11475      *
11476      * @hide
11477      */
invalidatePackageInfoCache()11478     public static void invalidatePackageInfoCache() {
11479         sCacheAutoCorker.autoCork();
11480     }
11481 
11482     // Some of the flags don't affect the query result, but let's be conservative and cache
11483     // each combination of flags separately.
11484 
11485     private static final class PackageInfoQuery {
11486         final String packageName;
11487         final long flags;
11488         final int userId;
11489 
PackageInfoQuery(@ullable String packageName, @PackageInfoFlagsBits long flags, int userId)11490         PackageInfoQuery(@Nullable String packageName, @PackageInfoFlagsBits long flags, int userId) {
11491             this.packageName = packageName;
11492             this.flags = flags;
11493             this.userId = userId;
11494         }
11495 
11496         @Override
toString()11497         public String toString() {
11498             return String.format(
11499                     "PackageInfoQuery(packageName=\"%s\", flags=%s, userId=%s)",
11500                     packageName, flags, userId);
11501         }
11502 
11503         @Override
hashCode()11504         public int hashCode() {
11505             int hash = Objects.hashCode(packageName);
11506             hash = hash * 13 + Objects.hashCode(flags);
11507             hash = hash * 13 + Objects.hashCode(userId);
11508             return hash;
11509         }
11510 
11511         @Override
equals(@ullable Object rval)11512         public boolean equals(@Nullable Object rval) {
11513             if (rval == null) {
11514                 return false;
11515             }
11516             PackageInfoQuery other;
11517             try {
11518                 other = (PackageInfoQuery) rval;
11519             } catch (ClassCastException ex) {
11520                 return false;
11521             }
11522             return Objects.equals(packageName, other.packageName)
11523                     && flags == other.flags
11524                     && userId == other.userId;
11525         }
11526     }
11527 
getPackageInfoAsUserUncached( String packageName, @PackageInfoFlagsBits long flags, int userId)11528     private static PackageInfo getPackageInfoAsUserUncached(
11529             String packageName, @PackageInfoFlagsBits long flags, int userId) {
11530         try {
11531             return ActivityThread.getPackageManager().getPackageInfo(packageName, flags, userId);
11532         } catch (RemoteException e) {
11533             throw e.rethrowFromSystemServer();
11534         }
11535     }
11536 
11537     private static final PropertyInvalidatedCache<PackageInfoQuery, PackageInfo>
11538             sPackageInfoCache =
11539             new PropertyInvalidatedCache<PackageInfoQuery, PackageInfo>(
11540                     64, PermissionManager.CACHE_KEY_PACKAGE_INFO,
11541                     "getPackageInfo") {
11542                 @Override
11543                 public PackageInfo recompute(PackageInfoQuery query) {
11544                     return getPackageInfoAsUserUncached(
11545                             query.packageName, query.flags, query.userId);
11546                 }
11547                 @Override
11548                 public boolean resultEquals(PackageInfo cached, PackageInfo fetched) {
11549                     // Implementing this debug check for PackageInfo would require a
11550                     // complicated deep comparison, so just bypass it for now.
11551                     return true;
11552                 }
11553             };
11554 
11555     /** @hide */
getPackageInfoAsUserCached( String packageName, @PackageInfoFlagsBits long flags, int userId)11556     public static PackageInfo getPackageInfoAsUserCached(
11557             String packageName, @PackageInfoFlagsBits long flags, int userId) {
11558         return sPackageInfoCache.query(new PackageInfoQuery(packageName, flags, userId));
11559     }
11560 
11561     /**
11562      * Make getPackageInfoAsUser() bypass the cache in this process.
11563      * @hide
11564      */
disablePackageInfoCache()11565     public static void disablePackageInfoCache() {
11566         sPackageInfoCache.disableLocal();
11567     }
11568 
11569     /**
11570      * Inhibit package info cache invalidations when correct.
11571      *
11572      * @hide */
corkPackageInfoCache()11573     public static void corkPackageInfoCache() {
11574         PropertyInvalidatedCache.corkInvalidations(PermissionManager.CACHE_KEY_PACKAGE_INFO);
11575     }
11576 
11577     /**
11578      * Enable package info cache invalidations.
11579      *
11580      * @hide */
uncorkPackageInfoCache()11581     public static void uncorkPackageInfoCache() {
11582         PropertyInvalidatedCache.uncorkInvalidations(PermissionManager.CACHE_KEY_PACKAGE_INFO);
11583     }
11584 
11585     /**
11586      * Returns the token to be used by the subsequent calls to holdLock().
11587      * @hide
11588      */
11589     @RequiresPermission(android.Manifest.permission.INJECT_EVENTS)
11590     @TestApi
getHoldLockToken()11591     public IBinder getHoldLockToken() {
11592         try {
11593             return ActivityThread.getPackageManager().getHoldLockToken();
11594         } catch (RemoteException e) {
11595             throw e.rethrowFromSystemServer();
11596         }
11597     }
11598 
11599     /**
11600      * Holds the PM lock for the specified amount of milliseconds.
11601      * Intended for use by the tests that need to imitate lock contention.
11602      * The token should be obtained by
11603      * {@link android.content.pm.PackageManager#getHoldLockToken()}.
11604      * @hide
11605      */
11606     @TestApi
holdLock(IBinder token, int durationMs)11607     public void holdLock(IBinder token, int durationMs) {
11608         try {
11609             ActivityThread.getPackageManager().holdLock(token, durationMs);
11610         } catch (RemoteException e) {
11611             throw e.rethrowFromSystemServer();
11612         }
11613     }
11614 
11615     /**
11616      * Set a list of apps to keep around as APKs even if no user has currently installed it.
11617      * @param packageList List of package names to keep cached.
11618      *
11619      * @hide
11620      */
11621     @RequiresPermission(android.Manifest.permission.KEEP_UNINSTALLED_PACKAGES)
11622     @TestApi
setKeepUninstalledPackages(@onNull List<String> packageList)11623     public void setKeepUninstalledPackages(@NonNull List<String> packageList) {
11624         try {
11625             ActivityThread.getPackageManager().setKeepUninstalledPackages(packageList);
11626         } catch (RemoteException e) {
11627             throw e.rethrowFromSystemServer();
11628         }
11629     }
11630 
11631     /**
11632      * Checks if a package is blocked from uninstall for a particular user. A package can be
11633      * blocked from being uninstalled by a device owner or profile owner.
11634      * See {@link DevicePolicyManager#setUninstallBlocked(ComponentName, String, boolean)}.
11635      *
11636      * @param packageName Name of the package being uninstalled.
11637      * @param user UserHandle who's ability to uninstall a package is being checked.
11638      *
11639      * @hide
11640      */
11641     @SystemApi
11642     @NonNull
canUserUninstall(@onNull String packageName, @NonNull UserHandle user)11643     public boolean canUserUninstall(@NonNull String packageName, @NonNull UserHandle user){
11644         throw new UnsupportedOperationException(
11645                 "canUserUninstall not implemented in subclass");
11646     }
11647 
11648     /**
11649      * See {@link android.provider.Settings.Global#SHOW_NEW_APP_INSTALLED_NOTIFICATION_ENABLED}.
11650      *
11651      * @hide
11652      */
11653     @SystemApi
11654     @NonNull
shouldShowNewAppInstalledNotification()11655     public boolean shouldShowNewAppInstalledNotification() {
11656         throw new UnsupportedOperationException(
11657                 "isShowNewAppInstalledNotificationEnabled not implemented in subclass");
11658     }
11659 
11660     /**
11661      * Attempt to relinquish the update ownership of the given package. Only the current
11662      * update owner of the given package can use this API.
11663      *
11664      * @param targetPackage The installed package whose update owner will be changed.
11665      * @throws IllegalArgumentException if the given package is invalid.
11666      * @throws SecurityException if you are not the current update owner of the given package.
11667      *
11668      * @see PackageInstaller.SessionParams#setRequestUpdateOwnership
11669      */
relinquishUpdateOwnership(@onNull String targetPackage)11670     public void relinquishUpdateOwnership(@NonNull String targetPackage) {
11671         throw new UnsupportedOperationException(
11672                 "relinquishUpdateOwnership not implemented in subclass");
11673     }
11674 
11675     /**
11676      * Register for notifications of package changes such as install, removal and other events.
11677      *
11678      * @param callback the callback to register for receiving the change events
11679      * @param userId The id of registered user
11680      * @hide
11681      */
registerPackageMonitorCallback(@onNull IRemoteCallback callback, int userId)11682     public void registerPackageMonitorCallback(@NonNull IRemoteCallback callback, int userId) {
11683         throw new UnsupportedOperationException(
11684                 "registerPackageMonitorCallback not implemented in subclass");
11685     }
11686 
11687     /**
11688      * Unregister for notifications of package changes such as install, removal and other events.
11689      *
11690      * @param callback the callback to unregister for receiving the change events
11691      * @see #registerPackageMonitorCallback(IRemoteCallback, int)
11692      * @hide
11693      */
unregisterPackageMonitorCallback(@onNull IRemoteCallback callback)11694     public void unregisterPackageMonitorCallback(@NonNull IRemoteCallback callback) {
11695         throw new UnsupportedOperationException(
11696                 "unregisterPackageMonitorCallback not implemented in subclass");
11697     }
11698 
11699     /**
11700      * Retrieve AndroidManifest.xml information for the given application apk file.
11701      *
11702      * <p>Example:
11703      *
11704      * <pre><code>
11705      * Bundle result;
11706      * try {
11707      *     result = getContext().getPackageManager().parseAndroidManifest(apkFile,
11708      *             xmlResourceParser -> {
11709      *                 Bundle bundle = new Bundle();
11710      *                 // Search the start tag
11711      *                 int type;
11712      *                 while ((type = xmlResourceParser.next()) != XmlPullParser.START_TAG
11713      *                         &amp;&amp; type != XmlPullParser.END_DOCUMENT) {
11714      *                 }
11715      *                 if (type != XmlPullParser.START_TAG) {
11716      *                     return bundle;
11717      *                 }
11718      *
11719      *                 // Start to read the tags and attributes from the xmlResourceParser
11720      *                 if (!xmlResourceParser.getName().equals("manifest")) {
11721      *                     return bundle;
11722      *                 }
11723      *                 String packageName = xmlResourceParser.getAttributeValue(null, "package");
11724      *                 bundle.putString("package", packageName);
11725      *
11726      *                 // Continue to read the tags and attributes from the xmlResourceParser
11727      *
11728      *                 return bundle;
11729      *             });
11730      * } catch (IOException e) {
11731      * }
11732      * </code></pre>
11733      *
11734      * Note: When the parserFunction is invoked, the client can read the AndroidManifest.xml
11735      * information by the XmlResourceParser object. After leaving the parserFunction, the
11736      * XmlResourceParser object will be closed. The caller should also handle the exception for
11737      * calling this method.
11738      *
11739      * @param apkFile The file of an application apk.
11740      * @param parserFunction The parserFunction will be invoked with the XmlResourceParser object
11741      *        after getting the AndroidManifest.xml of an application package.
11742      *
11743      * @return Returns the result of the {@link Function#apply(Object)}.
11744      *
11745      * @throws IOException if the AndroidManifest.xml of an application package cannot be
11746      *             read or accessed.
11747      */
11748     @FlaggedApi(android.content.pm.Flags.FLAG_GET_PACKAGE_INFO)
11749     @WorkerThread
parseAndroidManifest(@onNull File apkFile, @NonNull Function<XmlResourceParser, T> parserFunction)11750     public <T> T parseAndroidManifest(@NonNull File apkFile,
11751             @NonNull Function<XmlResourceParser, T> parserFunction) throws IOException {
11752         throw new UnsupportedOperationException(
11753                 "parseAndroidManifest not implemented in subclass");
11754     }
11755 
11756     /**
11757      * Similar to {@link #parseAndroidManifest(File, Function)}, but accepting a file descriptor
11758      * instead of a File object.
11759      *
11760      * @param apkFileDescriptor The file descriptor of an application apk.
11761      * The parserFunction will be invoked with the XmlResourceParser object
11762      *        after getting the AndroidManifest.xml of an application package.
11763      *
11764      * @return Returns the result of the {@link Function#apply(Object)}.
11765      *
11766      * @throws IOException if the AndroidManifest.xml of an application package cannot be
11767      *             read or accessed.
11768      */
11769     @FlaggedApi(android.content.pm.Flags.FLAG_GET_PACKAGE_INFO_WITH_FD)
11770     @WorkerThread
parseAndroidManifest(@onNull ParcelFileDescriptor apkFileDescriptor, @NonNull Function<XmlResourceParser, T> parserFunction)11771     public <T> T parseAndroidManifest(@NonNull ParcelFileDescriptor apkFileDescriptor,
11772             @NonNull Function<XmlResourceParser, T> parserFunction) throws IOException {
11773         throw new UnsupportedOperationException(
11774                 "parseAndroidManifest not implemented in subclass");
11775     }
11776 
11777     /**
11778      * @param info    The {@link ServiceInfo} to pull the attributes from.
11779      * @param name    The name of the Xml metadata where the attributes are stored.
11780      * @param rootTag The root tag of the attributes.
11781      * @return A {@link TypedArray} of attributes if successful, {@code null} otherwise.
11782      * @hide
11783      */
extractPackageItemInfoAttributes(PackageItemInfo info, String name, String rootTag, int[] attributes)11784     public TypedArray extractPackageItemInfoAttributes(PackageItemInfo info, String name,
11785             String rootTag, int[] attributes) {
11786         throw new UnsupportedOperationException(
11787                 "parseServiceMetadata not implemented in subclass");
11788     }
11789 }
11790