1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.content.pm;
18 
19 import android.Manifest;
20 import android.annotation.CheckResult;
21 import android.annotation.DrawableRes;
22 import android.annotation.IntDef;
23 import android.annotation.IntRange;
24 import android.annotation.NonNull;
25 import android.annotation.Nullable;
26 import android.annotation.RequiresPermission;
27 import android.annotation.SdkConstant;
28 import android.annotation.SdkConstant.SdkConstantType;
29 import android.annotation.StringRes;
30 import android.annotation.SystemApi;
31 import android.annotation.TestApi;
32 import android.annotation.UserIdInt;
33 import android.annotation.XmlRes;
34 import android.app.ActivityManager;
35 import android.app.PackageDeleteObserver;
36 import android.app.PackageInstallObserver;
37 import android.app.admin.DevicePolicyManager;
38 import android.app.usage.StorageStatsManager;
39 import android.content.ComponentName;
40 import android.content.Context;
41 import android.content.Intent;
42 import android.content.IntentFilter;
43 import android.content.IntentSender;
44 import android.content.pm.PackageParser.PackageParserException;
45 import android.content.pm.dex.ArtManager;
46 import android.content.res.Resources;
47 import android.content.res.XmlResourceParser;
48 import android.graphics.Rect;
49 import android.graphics.drawable.Drawable;
50 import android.net.wifi.WifiManager;
51 import android.os.Build;
52 import android.os.Bundle;
53 import android.os.Handler;
54 import android.os.PersistableBundle;
55 import android.os.RemoteException;
56 import android.os.UserHandle;
57 import android.os.UserManager;
58 import android.os.storage.StorageManager;
59 import android.os.storage.VolumeInfo;
60 import android.util.AndroidException;
61 import android.util.Log;
62 
63 import com.android.internal.util.ArrayUtils;
64 
65 import dalvik.system.VMRuntime;
66 
67 import java.io.File;
68 import java.lang.annotation.Retention;
69 import java.lang.annotation.RetentionPolicy;
70 import java.util.List;
71 import java.util.Locale;
72 
73 /**
74  * Class for retrieving various kinds of information related to the application
75  * packages that are currently installed on the device.
76  *
77  * You can find this class through {@link Context#getPackageManager}.
78  */
79 public abstract class PackageManager {
80     private static final String TAG = "PackageManager";
81 
82     /** {@hide} */
83     public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true;
84 
85     /**
86      * This exception is thrown when a given package, application, or component
87      * name cannot be found.
88      */
89     public static class NameNotFoundException extends AndroidException {
NameNotFoundException()90         public NameNotFoundException() {
91         }
92 
NameNotFoundException(String name)93         public NameNotFoundException(String name) {
94             super(name);
95         }
96     }
97 
98     /**
99      * Listener for changes in permissions granted to a UID.
100      *
101      * @hide
102      */
103     @SystemApi
104     public interface OnPermissionsChangedListener {
105 
106         /**
107          * Called when the permissions for a UID change.
108          * @param uid The UID with a change.
109          */
onPermissionsChanged(int uid)110         public void onPermissionsChanged(int uid);
111     }
112 
113     /**
114      * As a guiding principle:
115      * <p>
116      * {@code GET_} flags are used to request additional data that may have been
117      * elided to save wire space.
118      * <p>
119      * {@code MATCH_} flags are used to include components or packages that
120      * would have otherwise been omitted from a result set by current system
121      * state.
122      */
123 
124     /** @hide */
125     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
126             GET_ACTIVITIES,
127             GET_CONFIGURATIONS,
128             GET_GIDS,
129             GET_INSTRUMENTATION,
130             GET_INTENT_FILTERS,
131             GET_META_DATA,
132             GET_PERMISSIONS,
133             GET_PROVIDERS,
134             GET_RECEIVERS,
135             GET_SERVICES,
136             GET_SHARED_LIBRARY_FILES,
137             GET_SIGNATURES,
138             GET_SIGNING_CERTIFICATES,
139             GET_URI_PERMISSION_PATTERNS,
140             MATCH_UNINSTALLED_PACKAGES,
141             MATCH_DISABLED_COMPONENTS,
142             MATCH_DISABLED_UNTIL_USED_COMPONENTS,
143             MATCH_SYSTEM_ONLY,
144             MATCH_FACTORY_ONLY,
145             MATCH_DEBUG_TRIAGED_MISSING,
146             MATCH_INSTANT,
147             GET_DISABLED_COMPONENTS,
148             GET_DISABLED_UNTIL_USED_COMPONENTS,
149             GET_UNINSTALLED_PACKAGES,
150     })
151     @Retention(RetentionPolicy.SOURCE)
152     public @interface PackageInfoFlags {}
153 
154     /** @hide */
155     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
156             GET_META_DATA,
157             GET_SHARED_LIBRARY_FILES,
158             MATCH_UNINSTALLED_PACKAGES,
159             MATCH_SYSTEM_ONLY,
160             MATCH_DEBUG_TRIAGED_MISSING,
161             MATCH_DISABLED_COMPONENTS,
162             MATCH_DISABLED_UNTIL_USED_COMPONENTS,
163             MATCH_INSTANT,
164             MATCH_STATIC_SHARED_LIBRARIES,
165             GET_DISABLED_UNTIL_USED_COMPONENTS,
166             GET_UNINSTALLED_PACKAGES,
167     })
168     @Retention(RetentionPolicy.SOURCE)
169     public @interface ApplicationInfoFlags {}
170 
171     /** @hide */
172     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
173             GET_META_DATA,
174             GET_SHARED_LIBRARY_FILES,
175             MATCH_ALL,
176             MATCH_DEBUG_TRIAGED_MISSING,
177             MATCH_DEFAULT_ONLY,
178             MATCH_DISABLED_COMPONENTS,
179             MATCH_DISABLED_UNTIL_USED_COMPONENTS,
180             MATCH_DIRECT_BOOT_AWARE,
181             MATCH_DIRECT_BOOT_UNAWARE,
182             MATCH_SYSTEM_ONLY,
183             MATCH_UNINSTALLED_PACKAGES,
184             MATCH_INSTANT,
185             MATCH_STATIC_SHARED_LIBRARIES,
186             GET_DISABLED_COMPONENTS,
187             GET_DISABLED_UNTIL_USED_COMPONENTS,
188             GET_UNINSTALLED_PACKAGES,
189     })
190     @Retention(RetentionPolicy.SOURCE)
191     public @interface ComponentInfoFlags {}
192 
193     /** @hide */
194     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
195             GET_META_DATA,
196             GET_RESOLVED_FILTER,
197             GET_SHARED_LIBRARY_FILES,
198             MATCH_ALL,
199             MATCH_DEBUG_TRIAGED_MISSING,
200             MATCH_DISABLED_COMPONENTS,
201             MATCH_DISABLED_UNTIL_USED_COMPONENTS,
202             MATCH_DEFAULT_ONLY,
203             MATCH_DIRECT_BOOT_AWARE,
204             MATCH_DIRECT_BOOT_UNAWARE,
205             MATCH_SYSTEM_ONLY,
206             MATCH_UNINSTALLED_PACKAGES,
207             MATCH_INSTANT,
208             GET_DISABLED_COMPONENTS,
209             GET_DISABLED_UNTIL_USED_COMPONENTS,
210             GET_UNINSTALLED_PACKAGES,
211     })
212     @Retention(RetentionPolicy.SOURCE)
213     public @interface ResolveInfoFlags {}
214 
215     /** @hide */
216     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
217             GET_META_DATA,
218     })
219     @Retention(RetentionPolicy.SOURCE)
220     public @interface PermissionInfoFlags {}
221 
222     /** @hide */
223     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
224             GET_META_DATA,
225     })
226     @Retention(RetentionPolicy.SOURCE)
227     public @interface PermissionGroupInfoFlags {}
228 
229     /** @hide */
230     @IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
231             GET_META_DATA,
232     })
233     @Retention(RetentionPolicy.SOURCE)
234     public @interface InstrumentationInfoFlags {}
235 
236     /**
237      * {@link PackageInfo} flag: return information about
238      * activities in the package in {@link PackageInfo#activities}.
239      */
240     public static final int GET_ACTIVITIES              = 0x00000001;
241 
242     /**
243      * {@link PackageInfo} flag: return information about
244      * intent receivers in the package in
245      * {@link PackageInfo#receivers}.
246      */
247     public static final int GET_RECEIVERS               = 0x00000002;
248 
249     /**
250      * {@link PackageInfo} flag: return information about
251      * services in the package in {@link PackageInfo#services}.
252      */
253     public static final int GET_SERVICES                = 0x00000004;
254 
255     /**
256      * {@link PackageInfo} flag: return information about
257      * content providers in the package in
258      * {@link PackageInfo#providers}.
259      */
260     public static final int GET_PROVIDERS               = 0x00000008;
261 
262     /**
263      * {@link PackageInfo} flag: return information about
264      * instrumentation in the package in
265      * {@link PackageInfo#instrumentation}.
266      */
267     public static final int GET_INSTRUMENTATION         = 0x00000010;
268 
269     /**
270      * {@link PackageInfo} flag: return information about the
271      * intent filters supported by the activity.
272      */
273     public static final int GET_INTENT_FILTERS          = 0x00000020;
274 
275     /**
276      * {@link PackageInfo} flag: return information about the
277      * signatures included in the package.
278      *
279      * @deprecated use {@code GET_SIGNING_CERTIFICATES} instead
280      */
281     @Deprecated
282     public static final int GET_SIGNATURES          = 0x00000040;
283 
284     /**
285      * {@link ResolveInfo} flag: return the IntentFilter that
286      * was matched for a particular ResolveInfo in
287      * {@link ResolveInfo#filter}.
288      */
289     public static final int GET_RESOLVED_FILTER         = 0x00000040;
290 
291     /**
292      * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
293      * data {@link android.os.Bundle}s that are associated with a component.
294      * This applies for any API returning a ComponentInfo subclass.
295      */
296     public static final int GET_META_DATA               = 0x00000080;
297 
298     /**
299      * {@link PackageInfo} flag: return the
300      * {@link PackageInfo#gids group ids} that are associated with an
301      * application.
302      * This applies for any API returning a PackageInfo class, either
303      * directly or nested inside of another.
304      */
305     public static final int GET_GIDS                    = 0x00000100;
306 
307     /**
308      * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS}
309      */
310     @Deprecated
311     public static final int GET_DISABLED_COMPONENTS = 0x00000200;
312 
313     /**
314      * {@link PackageInfo} flag: include disabled components in the returned info.
315      */
316     public static final int MATCH_DISABLED_COMPONENTS = 0x00000200;
317 
318     /**
319      * {@link ApplicationInfo} flag: return the
320      * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
321      * that are associated with an application.
322      * This applies for any API returning an ApplicationInfo class, either
323      * directly or nested inside of another.
324      */
325     public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
326 
327     /**
328      * {@link ProviderInfo} flag: return the
329      * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
330      * that are associated with a content provider.
331      * This applies for any API returning a ProviderInfo class, either
332      * directly or nested inside of another.
333      */
334     public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
335     /**
336      * {@link PackageInfo} flag: return information about
337      * permissions in the package in
338      * {@link PackageInfo#permissions}.
339      */
340     public static final int GET_PERMISSIONS               = 0x00001000;
341 
342     /**
343      * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES}
344      */
345     @Deprecated
346     public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
347 
348     /**
349      * Flag parameter to retrieve some information about all applications (even
350      * uninstalled ones) which have data directories. This state could have
351      * resulted if applications have been deleted with flag
352      * {@code DONT_DELETE_DATA} with a possibility of being replaced or
353      * reinstalled in future.
354      * <p>
355      * Note: this flag may cause less information about currently installed
356      * applications to be returned.
357      */
358     public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000;
359 
360     /**
361      * {@link PackageInfo} flag: return information about
362      * hardware preferences in
363      * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
364      * and requested features in {@link PackageInfo#reqFeatures} and
365      * {@link PackageInfo#featureGroups}.
366      */
367     public static final int GET_CONFIGURATIONS = 0x00004000;
368 
369     /**
370      * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}.
371      */
372     @Deprecated
373     public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
374 
375     /**
376      * {@link PackageInfo} flag: include disabled components which are in
377      * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
378      * in the returned info.  Note that if you set this flag, applications
379      * that are in this disabled state will be reported as enabled.
380      */
381     public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
382 
383     /**
384      * Resolution and querying flag: if set, only filters that support the
385      * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
386      * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
387      * supplied Intent.
388      */
389     public static final int MATCH_DEFAULT_ONLY  = 0x00010000;
390 
391     /**
392      * Querying flag: if set and if the platform is doing any filtering of the
393      * results, then the filtering will not happen. This is a synonym for saying
394      * that all results should be returned.
395      * <p>
396      * <em>This flag should be used with extreme care.</em>
397      */
398     public static final int MATCH_ALL = 0x00020000;
399 
400     /**
401      * Querying flag: match components which are direct boot <em>unaware</em> in
402      * the returned info, regardless of the current user state.
403      * <p>
404      * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
405      * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
406      * to match only runnable components based on the user state. For example,
407      * when a user is started but credentials have not been presented yet, the
408      * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
409      * components are returned. Once the user credentials have been presented,
410      * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
411      * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
412      *
413      * @see UserManager#isUserUnlocked()
414      */
415     public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000;
416 
417     /**
418      * Querying flag: match components which are direct boot <em>aware</em> in
419      * the returned info, regardless of the current user state.
420      * <p>
421      * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
422      * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
423      * to match only runnable components based on the user state. For example,
424      * when a user is started but credentials have not been presented yet, the
425      * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
426      * components are returned. Once the user credentials have been presented,
427      * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
428      * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
429      *
430      * @see UserManager#isUserUnlocked()
431      */
432     public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000;
433 
434     /**
435      * Querying flag: include only components from applications that are marked
436      * with {@link ApplicationInfo#FLAG_SYSTEM}.
437      */
438     public static final int MATCH_SYSTEM_ONLY = 0x00100000;
439 
440     /**
441      * Internal {@link PackageInfo} flag: include only components on the system image.
442      * This will not return information on any unbundled update to system components.
443      * @hide
444      */
445     @SystemApi
446     @TestApi
447     public static final int MATCH_FACTORY_ONLY = 0x00200000;
448 
449     /**
450      * Allows querying of packages installed for any user, not just the specific one. This flag
451      * is only meant for use by apps that have INTERACT_ACROSS_USERS permission.
452      * @hide
453      */
454     @SystemApi
455     public static final int MATCH_ANY_USER = 0x00400000;
456 
457     /**
458      * Combination of MATCH_ANY_USER and MATCH_UNINSTALLED_PACKAGES to mean any known
459      * package.
460      * @hide
461      */
462     @TestApi
463     public static final int MATCH_KNOWN_PACKAGES = MATCH_UNINSTALLED_PACKAGES | MATCH_ANY_USER;
464 
465     /**
466      * Internal {@link PackageInfo} flag: include components that are part of an
467      * instant app. By default, instant app components are not matched.
468      * @hide
469      */
470     @SystemApi
471     public static final int MATCH_INSTANT = 0x00800000;
472 
473     /**
474      * Internal {@link PackageInfo} flag: include only components that are exposed to
475      * instant apps. Matched components may have been either explicitly or implicitly
476      * exposed.
477      * @hide
478      */
479     public static final int MATCH_VISIBLE_TO_INSTANT_APP_ONLY = 0x01000000;
480 
481     /**
482      * Internal {@link PackageInfo} flag: include only components that have been
483      * explicitly exposed to instant apps.
484      * @hide
485      */
486     public static final int MATCH_EXPLICITLY_VISIBLE_ONLY = 0x02000000;
487 
488     /**
489      * Internal {@link PackageInfo} flag: include static shared libraries.
490      * Apps that depend on static shared libs can always access the version
491      * of the lib they depend on. System/shell/root can access all shared
492      * libs regardless of dependency but need to explicitly ask for them
493      * via this flag.
494      * @hide
495      */
496     public static final int MATCH_STATIC_SHARED_LIBRARIES = 0x04000000;
497 
498     /**
499      * {@link PackageInfo} flag: return the signing certificates associated with
500      * this package.  Each entry is a signing certificate that the package
501      * has proven it is authorized to use, usually a past signing certificate from
502      * which it has rotated.
503      */
504     public static final int GET_SIGNING_CERTIFICATES = 0x08000000;
505 
506     /**
507      * Internal flag used to indicate that a system component has done their
508      * homework and verified that they correctly handle packages and components
509      * that come and go over time. In particular:
510      * <ul>
511      * <li>Apps installed on external storage, which will appear to be
512      * uninstalled while the the device is ejected.
513      * <li>Apps with encryption unaware components, which will appear to not
514      * exist while the device is locked.
515      * </ul>
516      *
517      * @see #MATCH_UNINSTALLED_PACKAGES
518      * @see #MATCH_DIRECT_BOOT_AWARE
519      * @see #MATCH_DIRECT_BOOT_UNAWARE
520      * @hide
521      */
522     public static final int MATCH_DEBUG_TRIAGED_MISSING = 0x10000000;
523 
524     /**
525      * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when
526      * resolving an intent that matches the {@code CrossProfileIntentFilter},
527      * the current profile will be skipped. Only activities in the target user
528      * can respond to the intent.
529      *
530      * @hide
531      */
532     public static final int SKIP_CURRENT_PROFILE = 0x00000002;
533 
534     /**
535      * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set:
536      * activities in the other profiles can respond to the intent only if no activity with
537      * non-negative priority in current profile can respond to the intent.
538      * @hide
539      */
540     public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
541 
542     /** @hide */
543     @IntDef(prefix = { "PERMISSION_" }, value = {
544             PERMISSION_GRANTED,
545             PERMISSION_DENIED
546     })
547     @Retention(RetentionPolicy.SOURCE)
548     public @interface PermissionResult {}
549 
550     /**
551      * Permission check result: this is returned by {@link #checkPermission}
552      * if the permission has been granted to the given package.
553      */
554     public static final int PERMISSION_GRANTED = 0;
555 
556     /**
557      * Permission check result: this is returned by {@link #checkPermission}
558      * if the permission has not been granted to the given package.
559      */
560     public static final int PERMISSION_DENIED = -1;
561 
562     /** @hide */
563     @IntDef(prefix = { "SIGNATURE_" }, value = {
564             SIGNATURE_MATCH,
565             SIGNATURE_NEITHER_SIGNED,
566             SIGNATURE_FIRST_NOT_SIGNED,
567             SIGNATURE_SECOND_NOT_SIGNED,
568             SIGNATURE_NO_MATCH,
569             SIGNATURE_UNKNOWN_PACKAGE,
570     })
571     @Retention(RetentionPolicy.SOURCE)
572     public @interface SignatureResult {}
573 
574     /**
575      * Signature check result: this is returned by {@link #checkSignatures}
576      * if all signatures on the two packages match.
577      */
578     public static final int SIGNATURE_MATCH = 0;
579 
580     /**
581      * Signature check result: this is returned by {@link #checkSignatures}
582      * if neither of the two packages is signed.
583      */
584     public static final int SIGNATURE_NEITHER_SIGNED = 1;
585 
586     /**
587      * Signature check result: this is returned by {@link #checkSignatures}
588      * if the first package is not signed but the second is.
589      */
590     public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
591 
592     /**
593      * Signature check result: this is returned by {@link #checkSignatures}
594      * if the second package is not signed but the first is.
595      */
596     public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
597 
598     /**
599      * Signature check result: this is returned by {@link #checkSignatures}
600      * if not all signatures on both packages match.
601      */
602     public static final int SIGNATURE_NO_MATCH = -3;
603 
604     /**
605      * Signature check result: this is returned by {@link #checkSignatures}
606      * if either of the packages are not valid.
607      */
608     public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
609 
610     /** @hide */
611     @IntDef(prefix = { "COMPONENT_ENABLED_STATE_" }, value = {
612             COMPONENT_ENABLED_STATE_DEFAULT,
613             COMPONENT_ENABLED_STATE_ENABLED,
614             COMPONENT_ENABLED_STATE_DISABLED,
615             COMPONENT_ENABLED_STATE_DISABLED_USER,
616             COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED,
617     })
618     @Retention(RetentionPolicy.SOURCE)
619     public @interface EnabledState {}
620 
621     /**
622      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} and
623      * {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
624      * component or application is in its default enabled state (as specified in
625      * its manifest).
626      * <p>
627      * Explicitly setting the component state to this value restores it's
628      * enabled state to whatever is set in the manifest.
629      */
630     public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
631 
632     /**
633      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
634      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
635      * component or application has been explictily enabled, regardless of
636      * what it has specified in its manifest.
637      */
638     public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
639 
640     /**
641      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
642      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
643      * component or application has been explicitly disabled, regardless of
644      * what it has specified in its manifest.
645      */
646     public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
647 
648     /**
649      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
650      * user has explicitly disabled the application, regardless of what it has
651      * specified in its manifest.  Because this is due to the user's request,
652      * they may re-enable it if desired through the appropriate system UI.  This
653      * option currently <strong>cannot</strong> be used with
654      * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
655      */
656     public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
657 
658     /**
659      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
660      * application should be considered, until the point where the user actually
661      * wants to use it.  This means that it will not normally show up to the user
662      * (such as in the launcher), but various parts of the user interface can
663      * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
664      * the user to select it (as for example an IME, device admin, etc).  Such code,
665      * once the user has selected the app, should at that point also make it enabled.
666      * This option currently <strong>can not</strong> be used with
667      * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
668      */
669     public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
670 
671     /** @hide */
672     @IntDef(flag = true, prefix = { "INSTALL_" }, value = {
673             INSTALL_FORWARD_LOCK,
674             INSTALL_REPLACE_EXISTING,
675             INSTALL_ALLOW_TEST,
676             INSTALL_EXTERNAL,
677             INSTALL_INTERNAL,
678             INSTALL_FROM_ADB,
679             INSTALL_ALL_USERS,
680             INSTALL_ALLOW_DOWNGRADE,
681             INSTALL_GRANT_RUNTIME_PERMISSIONS,
682             INSTALL_FORCE_VOLUME_UUID,
683             INSTALL_FORCE_PERMISSION_PROMPT,
684             INSTALL_INSTANT_APP,
685             INSTALL_DONT_KILL_APP,
686             INSTALL_FORCE_SDK,
687             INSTALL_FULL_APP,
688             INSTALL_ALLOCATE_AGGRESSIVE,
689     })
690     @Retention(RetentionPolicy.SOURCE)
691     public @interface InstallFlags {}
692 
693     /**
694      * Flag parameter for {@link #installPackage} to indicate that this package
695      * should be installed as forward locked, i.e. only the app itself should
696      * have access to its code and non-resource assets.
697      *
698      * @deprecated new installs into ASEC containers are no longer supported.
699      * @hide
700      */
701     @Deprecated
702     public static final int INSTALL_FORWARD_LOCK = 0x00000001;
703 
704     /**
705      * Flag parameter for {@link #installPackage} to indicate that you want to
706      * replace an already installed package, if one exists.
707      *
708      * @hide
709      */
710     public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
711 
712     /**
713      * Flag parameter for {@link #installPackage} to indicate that you want to
714      * allow test packages (those that have set android:testOnly in their
715      * manifest) to be installed.
716      * @hide
717      */
718     public static final int INSTALL_ALLOW_TEST = 0x00000004;
719 
720     /**
721      * Flag parameter for {@link #installPackage} to indicate that this package
722      * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}.
723      *
724      * @deprecated new installs into ASEC containers are no longer supported;
725      *             use adoptable storage instead.
726      * @hide
727      */
728     @Deprecated
729     public static final int INSTALL_EXTERNAL = 0x00000008;
730 
731     /**
732      * Flag parameter for {@link #installPackage} to indicate that this package
733      * must be installed to internal storage.
734      *
735      * @hide
736      */
737     public static final int INSTALL_INTERNAL = 0x00000010;
738 
739     /**
740      * Flag parameter for {@link #installPackage} to indicate that this install
741      * was initiated via ADB.
742      *
743      * @hide
744      */
745     public static final int INSTALL_FROM_ADB = 0x00000020;
746 
747     /**
748      * Flag parameter for {@link #installPackage} to indicate that this install
749      * should immediately be visible to all users.
750      *
751      * @hide
752      */
753     public static final int INSTALL_ALL_USERS = 0x00000040;
754 
755     /**
756      * Flag parameter for {@link #installPackage} to indicate that it is okay
757      * to install an update to an app where the newly installed app has a lower
758      * version code than the currently installed app. This is permitted only if
759      * the currently installed app is marked debuggable.
760      *
761      * @hide
762      */
763     public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
764 
765     /**
766      * Flag parameter for {@link #installPackage} to indicate that all runtime
767      * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS}
768      * is set the runtime permissions will be granted to all users, otherwise
769      * only to the owner.
770      *
771      * @hide
772      */
773     public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100;
774 
775     /** {@hide} */
776     public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
777 
778     /**
779      * Flag parameter for {@link #installPackage} to indicate that we always want to force
780      * the prompt for permission approval. This overrides any special behaviour for internal
781      * components.
782      *
783      * @hide
784      */
785     public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400;
786 
787     /**
788      * Flag parameter for {@link #installPackage} to indicate that this package is
789      * to be installed as a lightweight "ephemeral" app.
790      *
791      * @hide
792      */
793     public static final int INSTALL_INSTANT_APP = 0x00000800;
794 
795     /**
796      * Flag parameter for {@link #installPackage} to indicate that this package contains
797      * a feature split to an existing application and the existing application should not
798      * be killed during the installation process.
799      *
800      * @hide
801      */
802     public static final int INSTALL_DONT_KILL_APP = 0x00001000;
803 
804     /**
805      * Flag parameter for {@link #installPackage} to indicate that this package is an
806      * upgrade to a package that refers to the SDK via release letter or is targeting an SDK via
807      * release letter that the current build does not support.
808      *
809      * @hide
810      */
811     public static final int INSTALL_FORCE_SDK = 0x00002000;
812 
813     /**
814      * Flag parameter for {@link #installPackage} to indicate that this package is
815      * to be installed as a heavy weight app. This is fundamentally the opposite of
816      * {@link #INSTALL_INSTANT_APP}.
817      *
818      * @hide
819      */
820     public static final int INSTALL_FULL_APP = 0x00004000;
821 
822     /**
823      * Flag parameter for {@link #installPackage} to indicate that this package
824      * is critical to system health or security, meaning the system should use
825      * {@link StorageManager#FLAG_ALLOCATE_AGGRESSIVE} internally.
826      *
827      * @hide
828      */
829     public static final int INSTALL_ALLOCATE_AGGRESSIVE = 0x00008000;
830 
831     /**
832      * Flag parameter for {@link #installPackage} to indicate that this package
833      * is a virtual preload.
834      *
835      * @hide
836      */
837     public static final int INSTALL_VIRTUAL_PRELOAD = 0x00010000;
838 
839     /** @hide */
840     @IntDef(flag = true, prefix = { "DONT_KILL_APP" }, value = {
841             DONT_KILL_APP
842     })
843     @Retention(RetentionPolicy.SOURCE)
844     public @interface EnabledFlags {}
845 
846     /**
847      * Flag parameter for
848      * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
849      * that you don't want to kill the app containing the component.  Be careful when you set this
850      * since changing component states can make the containing application's behavior unpredictable.
851      */
852     public static final int DONT_KILL_APP = 0x00000001;
853 
854     /** @hide */
855     @IntDef(prefix = { "INSTALL_REASON_" }, value = {
856             INSTALL_REASON_UNKNOWN,
857             INSTALL_REASON_POLICY,
858             INSTALL_REASON_DEVICE_RESTORE,
859             INSTALL_REASON_DEVICE_SETUP,
860             INSTALL_REASON_USER
861     })
862     @Retention(RetentionPolicy.SOURCE)
863     public @interface InstallReason {}
864 
865     /**
866      * Code indicating that the reason for installing this package is unknown.
867      */
868     public static final int INSTALL_REASON_UNKNOWN = 0;
869 
870     /**
871      * Code indicating that this package was installed due to enterprise policy.
872      */
873     public static final int INSTALL_REASON_POLICY = 1;
874 
875     /**
876      * Code indicating that this package was installed as part of restoring from another device.
877      */
878     public static final int INSTALL_REASON_DEVICE_RESTORE = 2;
879 
880     /**
881      * Code indicating that this package was installed as part of device setup.
882      */
883     public static final int INSTALL_REASON_DEVICE_SETUP = 3;
884 
885     /**
886      * Code indicating that the package installation was initiated by the user.
887      */
888     public static final int INSTALL_REASON_USER = 4;
889 
890     /**
891      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
892      * on success.
893      *
894      * @hide
895      */
896     @SystemApi
897     public static final int INSTALL_SUCCEEDED = 1;
898 
899     /**
900      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
901      * if the package is already installed.
902      *
903      * @hide
904      */
905     @SystemApi
906     public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
907 
908     /**
909      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
910      * if the package archive file is invalid.
911      *
912      * @hide
913      */
914     @SystemApi
915     public static final int INSTALL_FAILED_INVALID_APK = -2;
916 
917     /**
918      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
919      * if the URI passed in is invalid.
920      *
921      * @hide
922      */
923     @SystemApi
924     public static final int INSTALL_FAILED_INVALID_URI = -3;
925 
926     /**
927      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
928      * if the package manager service found that the device didn't have enough storage space to
929      * install the app.
930      *
931      * @hide
932      */
933     @SystemApi
934     public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
935 
936     /**
937      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
938      * if a package is already installed with the same name.
939      *
940      * @hide
941      */
942     @SystemApi
943     public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
944 
945     /**
946      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
947      * if the requested shared user does not exist.
948      *
949      * @hide
950      */
951     @SystemApi
952     public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
953 
954     /**
955      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
956      * if a previously installed package of the same name has a different signature than the new
957      * package (and the old package's data was not removed).
958      *
959      * @hide
960      */
961     @SystemApi
962     public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
963 
964     /**
965      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
966      * if the new package is requested a shared user which is already installed on the device and
967      * does not have matching signature.
968      *
969      * @hide
970      */
971     @SystemApi
972     public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
973 
974     /**
975      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
976      * if the new package uses a shared library that is not available.
977      *
978      * @hide
979      */
980     @SystemApi
981     public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
982 
983     /**
984      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
985      * if the new package uses a shared library that is not available.
986      *
987      * @hide
988      */
989     @SystemApi
990     public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
991 
992     /**
993      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
994      * if the new package failed while optimizing and validating its dex files, either because there
995      * was not enough storage or the validation failed.
996      *
997      * @hide
998      */
999     @SystemApi
1000     public static final int INSTALL_FAILED_DEXOPT = -11;
1001 
1002     /**
1003      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1004      * if the new package failed because the current SDK version is older than that required by the
1005      * package.
1006      *
1007      * @hide
1008      */
1009     @SystemApi
1010     public static final int INSTALL_FAILED_OLDER_SDK = -12;
1011 
1012     /**
1013      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1014      * if the new package failed because it contains a content provider with the same authority as a
1015      * provider already installed in the system.
1016      *
1017      * @hide
1018      */
1019     @SystemApi
1020     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
1021 
1022     /**
1023      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1024      * if the new package failed because the current SDK version is newer than that required by the
1025      * package.
1026      *
1027      * @hide
1028      */
1029     @SystemApi
1030     public static final int INSTALL_FAILED_NEWER_SDK = -14;
1031 
1032     /**
1033      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1034      * if the new package failed because it has specified that it is a test-only package and the
1035      * caller has not supplied the {@link #INSTALL_ALLOW_TEST} flag.
1036      *
1037      * @hide
1038      */
1039     @SystemApi
1040     public static final int INSTALL_FAILED_TEST_ONLY = -15;
1041 
1042     /**
1043      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1044      * if the package being installed contains native code, but none that is compatible with the
1045      * device's CPU_ABI.
1046      *
1047      * @hide
1048      */
1049     @SystemApi
1050     public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
1051 
1052     /**
1053      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1054      * if the new package uses a feature that is not available.
1055      *
1056      * @hide
1057      */
1058     @SystemApi
1059     public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
1060 
1061     // ------ Errors related to sdcard
1062     /**
1063      * Installation return code: this is passed in the
1064      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if a secure container mount point couldn't be
1065      * accessed on external media.
1066      *
1067      * @hide
1068      */
1069     @SystemApi
1070     public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
1071 
1072     /**
1073      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1074      * if the new package couldn't be installed in the specified install location.
1075      *
1076      * @hide
1077      */
1078     @SystemApi
1079     public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
1080 
1081     /**
1082      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1083      * if the new package couldn't be installed in the specified install location because the media
1084      * is not available.
1085      *
1086      * @hide
1087      */
1088     @SystemApi
1089     public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
1090 
1091     /**
1092      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1093      * if the new package couldn't be installed because the verification timed out.
1094      *
1095      * @hide
1096      */
1097     @SystemApi
1098     public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
1099 
1100     /**
1101      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1102      * if the new package couldn't be installed because the verification did not succeed.
1103      *
1104      * @hide
1105      */
1106     @SystemApi
1107     public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
1108 
1109     /**
1110      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1111      * if the package changed from what the calling program expected.
1112      *
1113      * @hide
1114      */
1115     @SystemApi
1116     public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
1117 
1118     /**
1119      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1120      * if the new package is assigned a different UID than it previously held.
1121      *
1122      * @hide
1123      */
1124     public static final int INSTALL_FAILED_UID_CHANGED = -24;
1125 
1126     /**
1127      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1128      * if the new package has an older version code than the currently installed package.
1129      *
1130      * @hide
1131      */
1132     public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
1133 
1134     /**
1135      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1136      * if the old package has target SDK high enough to support runtime permission and the new
1137      * package has target SDK low enough to not support runtime permissions.
1138      *
1139      * @hide
1140      */
1141     @SystemApi
1142     public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
1143 
1144     /**
1145      * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS}
1146      * if the new package attempts to downgrade the target sandbox version of the app.
1147      *
1148      * @hide
1149      */
1150     @SystemApi
1151     public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27;
1152 
1153     /**
1154      * Installation parse return code: this is passed in the
1155      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was given a path that is not a
1156      * file, or does not end with the expected '.apk' extension.
1157      *
1158      * @hide
1159      */
1160     @SystemApi
1161     public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
1162 
1163     /**
1164      * Installation parse return code: this is passed in the
1165      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was unable to retrieve the
1166      * AndroidManifest.xml file.
1167      *
1168      * @hide
1169      */
1170     @SystemApi
1171     public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
1172 
1173     /**
1174      * Installation parse return code: this is passed in the
1175      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered an unexpected
1176      * exception.
1177      *
1178      * @hide
1179      */
1180     @SystemApi
1181     public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
1182 
1183     /**
1184      * Installation parse return code: this is passed in the
1185      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any certificates in
1186      * the .apk.
1187      *
1188      * @hide
1189      */
1190     @SystemApi
1191     public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
1192 
1193     /**
1194      * Installation parse return code: this is passed in the
1195      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser found inconsistent certificates on
1196      * the files in the .apk.
1197      *
1198      * @hide
1199      */
1200     @SystemApi
1201     public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
1202 
1203     /**
1204      * Installation parse return code: this is passed in the
1205      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a
1206      * CertificateEncodingException in one of the files in the .apk.
1207      *
1208      * @hide
1209      */
1210     @SystemApi
1211     public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
1212 
1213     /**
1214      * Installation parse return code: this is passed in the
1215      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad or missing
1216      * package name in the manifest.
1217      *
1218      * @hide
1219      */
1220     @SystemApi
1221     public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
1222 
1223     /**
1224      * Installation parse return code: tthis is passed in the
1225      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad shared user id
1226      * name in the manifest.
1227      *
1228      * @hide
1229      */
1230     @SystemApi
1231     public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
1232 
1233     /**
1234      * Installation parse return code: this is passed in the
1235      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered some structural
1236      * problem in the manifest.
1237      *
1238      * @hide
1239      */
1240     @SystemApi
1241     public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
1242 
1243     /**
1244      * Installation parse return code: this is passed in the
1245      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any actionable tags
1246      * (instrumentation or application) in the manifest.
1247      *
1248      * @hide
1249      */
1250     @SystemApi
1251     public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
1252 
1253     /**
1254      * Installation failed return code: this is passed in the
1255      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1256      * because of system issues.
1257      *
1258      * @hide
1259      */
1260     @SystemApi
1261     public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
1262 
1263     /**
1264      * Installation failed return code: this is passed in the
1265      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1266      * because the user is restricted from installing apps.
1267      *
1268      * @hide
1269      */
1270     public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
1271 
1272     /**
1273      * Installation failed return code: this is passed in the
1274      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1275      * because it is attempting to define a permission that is already defined by some existing
1276      * package.
1277      * <p>
1278      * The package name of the app which has already defined the permission is passed to a
1279      * {@link PackageInstallObserver}, if any, as the {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string
1280      * extra; and the name of the permission being redefined is passed in the
1281      * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra.
1282      *
1283      * @hide
1284      */
1285     public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
1286 
1287     /**
1288      * Installation failed return code: this is passed in the
1289      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package
1290      * because its packaged native code did not match any of the ABIs supported by the system.
1291      *
1292      * @hide
1293      */
1294     public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
1295 
1296     /**
1297      * Internal return code for NativeLibraryHelper methods to indicate that the package
1298      * being processed did not contain any native code. This is placed here only so that
1299      * it can belong to the same value space as the other install failure codes.
1300      *
1301      * @hide
1302      */
1303     public static final int NO_NATIVE_LIBRARIES = -114;
1304 
1305     /** {@hide} */
1306     public static final int INSTALL_FAILED_ABORTED = -115;
1307 
1308     /**
1309      * Installation failed return code: instant app installs are incompatible with some
1310      * other installation flags supplied for the operation; or other circumstances such
1311      * as trying to upgrade a system app via an instant app install.
1312      * @hide
1313      */
1314     public static final int INSTALL_FAILED_INSTANT_APP_INVALID = -116;
1315 
1316     /**
1317      * Installation parse return code: this is passed in the
1318      * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the dex metadata file is invalid or
1319      * if there was no matching apk file for a dex metadata file.
1320      *
1321      * @hide
1322      */
1323     public static final int INSTALL_FAILED_BAD_DEX_METADATA = -117;
1324 
1325     /** @hide */
1326     @IntDef(flag = true, prefix = { "DELETE_" }, value = {
1327             DELETE_KEEP_DATA,
1328             DELETE_ALL_USERS,
1329             DELETE_SYSTEM_APP,
1330             DELETE_DONT_KILL_APP,
1331             DELETE_CHATTY,
1332     })
1333     @Retention(RetentionPolicy.SOURCE)
1334     public @interface DeleteFlags {}
1335 
1336     /**
1337      * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
1338      * package's data directory.
1339      *
1340      * @hide
1341      */
1342     public static final int DELETE_KEEP_DATA = 0x00000001;
1343 
1344     /**
1345      * Flag parameter for {@link #deletePackage} to indicate that you want the
1346      * package deleted for all users.
1347      *
1348      * @hide
1349      */
1350     public static final int DELETE_ALL_USERS = 0x00000002;
1351 
1352     /**
1353      * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1354      * uninstall on a system that has been updated, then don't do the normal process
1355      * of uninstalling the update and rolling back to the older system version (which
1356      * needs to happen for all users); instead, just mark the app as uninstalled for
1357      * the current user.
1358      *
1359      * @hide
1360      */
1361     public static final int DELETE_SYSTEM_APP = 0x00000004;
1362 
1363     /**
1364      * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1365      * uninstall on a package that is replaced to provide new feature splits, the
1366      * existing application should not be killed during the removal process.
1367      *
1368      * @hide
1369      */
1370     public static final int DELETE_DONT_KILL_APP = 0x00000008;
1371 
1372     /**
1373      * Flag parameter for {@link #deletePackage} to indicate that package deletion
1374      * should be chatty.
1375      *
1376      * @hide
1377      */
1378     public static final int DELETE_CHATTY = 0x80000000;
1379 
1380     /**
1381      * Return code for when package deletion succeeds. This is passed to the
1382      * {@link IPackageDeleteObserver} if the system succeeded in deleting the
1383      * package.
1384      *
1385      * @hide
1386      */
1387     public static final int DELETE_SUCCEEDED = 1;
1388 
1389     /**
1390      * Deletion failed return code: this is passed to the
1391      * {@link IPackageDeleteObserver} if the system failed to delete the package
1392      * for an unspecified reason.
1393      *
1394      * @hide
1395      */
1396     public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
1397 
1398     /**
1399      * Deletion failed return code: this is passed to the
1400      * {@link IPackageDeleteObserver} if the system failed to delete the package
1401      * because it is the active DevicePolicy manager.
1402      *
1403      * @hide
1404      */
1405     public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
1406 
1407     /**
1408      * Deletion failed return code: this is passed to the
1409      * {@link IPackageDeleteObserver} if the system failed to delete the package
1410      * since the user is restricted.
1411      *
1412      * @hide
1413      */
1414     public static final int DELETE_FAILED_USER_RESTRICTED = -3;
1415 
1416     /**
1417      * Deletion failed return code: this is passed to the
1418      * {@link IPackageDeleteObserver} if the system failed to delete the package
1419      * because a profile or device owner has marked the package as
1420      * uninstallable.
1421      *
1422      * @hide
1423      */
1424     public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
1425 
1426     /** {@hide} */
1427     public static final int DELETE_FAILED_ABORTED = -5;
1428 
1429     /**
1430      * Deletion failed return code: this is passed to the
1431      * {@link IPackageDeleteObserver} if the system failed to delete the package
1432      * because the packge is a shared library used by other installed packages.
1433      * {@hide} */
1434     public static final int DELETE_FAILED_USED_SHARED_LIBRARY = -6;
1435 
1436     /**
1437      * Return code that is passed to the {@link IPackageMoveObserver} when the
1438      * package has been successfully moved by the system.
1439      *
1440      * @hide
1441      */
1442     public static final int MOVE_SUCCEEDED = -100;
1443 
1444     /**
1445      * Error code that is passed to the {@link IPackageMoveObserver} when the
1446      * package hasn't been successfully moved by the system because of
1447      * insufficient memory on specified media.
1448      *
1449      * @hide
1450      */
1451     public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
1452 
1453     /**
1454      * Error code that is passed to the {@link IPackageMoveObserver} if the
1455      * specified package doesn't exist.
1456      *
1457      * @hide
1458      */
1459     public static final int MOVE_FAILED_DOESNT_EXIST = -2;
1460 
1461     /**
1462      * Error code that is passed to the {@link IPackageMoveObserver} if the
1463      * specified package cannot be moved since its a system package.
1464      *
1465      * @hide
1466      */
1467     public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
1468 
1469     /**
1470      * Error code that is passed to the {@link IPackageMoveObserver} if the
1471      * specified package cannot be moved since its forward locked.
1472      *
1473      * @hide
1474      */
1475     public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
1476 
1477     /**
1478      * Error code that is passed to the {@link IPackageMoveObserver} if the
1479      * specified package cannot be moved to the specified location.
1480      *
1481      * @hide
1482      */
1483     public static final int MOVE_FAILED_INVALID_LOCATION = -5;
1484 
1485     /**
1486      * Error code that is passed to the {@link IPackageMoveObserver} if the
1487      * specified package cannot be moved to the specified location.
1488      *
1489      * @hide
1490      */
1491     public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
1492 
1493     /**
1494      * Error code that is passed to the {@link IPackageMoveObserver} if the
1495      * specified package already has an operation pending in the queue.
1496      *
1497      * @hide
1498      */
1499     public static final int MOVE_FAILED_OPERATION_PENDING = -7;
1500 
1501     /**
1502      * Error code that is passed to the {@link IPackageMoveObserver} if the
1503      * specified package cannot be moved since it contains a device admin.
1504      *
1505      * @hide
1506      */
1507     public static final int MOVE_FAILED_DEVICE_ADMIN = -8;
1508 
1509     /**
1510      * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow
1511      * non-system apps to be moved to internal storage.
1512      *
1513      * @hide
1514      */
1515     public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9;
1516 
1517     /** @hide */
1518     public static final int MOVE_FAILED_LOCKED_USER = -10;
1519 
1520     /**
1521      * Flag parameter for {@link #movePackage} to indicate that
1522      * the package should be moved to internal storage if its
1523      * been installed on external media.
1524      * @hide
1525      */
1526     @Deprecated
1527     public static final int MOVE_INTERNAL = 0x00000001;
1528 
1529     /**
1530      * Flag parameter for {@link #movePackage} to indicate that
1531      * the package should be moved to external media.
1532      * @hide
1533      */
1534     @Deprecated
1535     public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
1536 
1537     /** {@hide} */
1538     public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
1539 
1540     /**
1541      * Usable by the required verifier as the {@code verificationCode} argument
1542      * for {@link PackageManager#verifyPendingInstall} to indicate that it will
1543      * allow the installation to proceed without any of the optional verifiers
1544      * needing to vote.
1545      *
1546      * @hide
1547      */
1548     public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
1549 
1550     /**
1551      * Used as the {@code verificationCode} argument for
1552      * {@link PackageManager#verifyPendingInstall} to indicate that the calling
1553      * package verifier allows the installation to proceed.
1554      */
1555     public static final int VERIFICATION_ALLOW = 1;
1556 
1557     /**
1558      * Used as the {@code verificationCode} argument for
1559      * {@link PackageManager#verifyPendingInstall} to indicate the calling
1560      * package verifier does not vote to allow the installation to proceed.
1561      */
1562     public static final int VERIFICATION_REJECT = -1;
1563 
1564     /**
1565      * Used as the {@code verificationCode} argument for
1566      * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1567      * IntentFilter Verifier confirms that the IntentFilter is verified.
1568      *
1569      * @hide
1570      */
1571     @SystemApi
1572     public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
1573 
1574     /**
1575      * Used as the {@code verificationCode} argument for
1576      * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1577      * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
1578      *
1579      * @hide
1580      */
1581     @SystemApi
1582     public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
1583 
1584     /**
1585      * Internal status code to indicate that an IntentFilter verification result is not specified.
1586      *
1587      * @hide
1588      */
1589     @SystemApi
1590     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
1591 
1592     /**
1593      * Used as the {@code status} argument for
1594      * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1595      * will always be prompted the Intent Disambiguation Dialog if there are two
1596      * or more Intent resolved for the IntentFilter's domain(s).
1597      *
1598      * @hide
1599      */
1600     @SystemApi
1601     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
1602 
1603     /**
1604      * Used as the {@code status} argument for
1605      * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1606      * will never be prompted the Intent Disambiguation Dialog if there are two
1607      * or more resolution of the Intent. The default App for the domain(s)
1608      * specified in the IntentFilter will also ALWAYS be used.
1609      *
1610      * @hide
1611      */
1612     @SystemApi
1613     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
1614 
1615     /**
1616      * Used as the {@code status} argument for
1617      * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1618      * may be prompted the Intent Disambiguation Dialog if there are two or more
1619      * Intent resolved. The default App for the domain(s) specified in the
1620      * IntentFilter will also NEVER be presented to the User.
1621      *
1622      * @hide
1623      */
1624     @SystemApi
1625     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
1626 
1627     /**
1628      * Used as the {@code status} argument for
1629      * {@link #updateIntentVerificationStatusAsUser} to indicate that this app
1630      * should always be considered as an ambiguous candidate for handling the
1631      * matching Intent even if there are other candidate apps in the "always"
1632      * state. Put another way: if there are any 'always ask' apps in a set of
1633      * more than one candidate app, then a disambiguation is *always* presented
1634      * even if there is another candidate app with the 'always' state.
1635      *
1636      * @hide
1637      */
1638     @SystemApi
1639     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
1640 
1641     /**
1642      * Can be used as the {@code millisecondsToDelay} argument for
1643      * {@link PackageManager#extendVerificationTimeout}. This is the
1644      * maximum time {@code PackageManager} waits for the verification
1645      * agent to return (in milliseconds).
1646      */
1647     public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
1648 
1649     /**
1650      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
1651      * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
1652      * lag in sound input or output.
1653      */
1654     @SdkConstant(SdkConstantType.FEATURE)
1655     public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
1656 
1657     /**
1658      * Feature for {@link #getSystemAvailableFeatures} and
1659      * {@link #hasSystemFeature}: The device includes at least one form of audio
1660      * output, as defined in the Android Compatibility Definition Document (CDD)
1661      * <a href="https://source.android.com/compatibility/android-cdd#7_8_audio">section 7.8 Audio</a>.
1662      */
1663     @SdkConstant(SdkConstantType.FEATURE)
1664     public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
1665 
1666     /**
1667      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1668      * The device has professional audio level of functionality and performance.
1669      */
1670     @SdkConstant(SdkConstantType.FEATURE)
1671     public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
1672 
1673     /**
1674      * Feature for {@link #getSystemAvailableFeatures} and
1675      * {@link #hasSystemFeature}: The device is capable of communicating with
1676      * other devices via Bluetooth.
1677      */
1678     @SdkConstant(SdkConstantType.FEATURE)
1679     public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
1680 
1681     /**
1682      * Feature for {@link #getSystemAvailableFeatures} and
1683      * {@link #hasSystemFeature}: The device is capable of communicating with
1684      * other devices via Bluetooth Low Energy radio.
1685      */
1686     @SdkConstant(SdkConstantType.FEATURE)
1687     public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
1688 
1689     /**
1690      * Feature for {@link #getSystemAvailableFeatures} and
1691      * {@link #hasSystemFeature}: The device has a camera facing away
1692      * from the screen.
1693      */
1694     @SdkConstant(SdkConstantType.FEATURE)
1695     public static final String FEATURE_CAMERA = "android.hardware.camera";
1696 
1697     /**
1698      * Feature for {@link #getSystemAvailableFeatures} and
1699      * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1700      */
1701     @SdkConstant(SdkConstantType.FEATURE)
1702     public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
1703 
1704     /**
1705      * Feature for {@link #getSystemAvailableFeatures} and
1706      * {@link #hasSystemFeature}: The device has at least one camera pointing in
1707      * some direction, or can support an external camera being connected to it.
1708      */
1709     @SdkConstant(SdkConstantType.FEATURE)
1710     public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1711 
1712     /**
1713      * Feature for {@link #getSystemAvailableFeatures} and
1714      * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1715      * The external camera may not always be connected or available to applications to use.
1716      */
1717     @SdkConstant(SdkConstantType.FEATURE)
1718     public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1719 
1720     /**
1721      * Feature for {@link #getSystemAvailableFeatures} and
1722      * {@link #hasSystemFeature}: The device's camera supports flash.
1723      */
1724     @SdkConstant(SdkConstantType.FEATURE)
1725     public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
1726 
1727     /**
1728      * Feature for {@link #getSystemAvailableFeatures} and
1729      * {@link #hasSystemFeature}: The device has a front facing camera.
1730      */
1731     @SdkConstant(SdkConstantType.FEATURE)
1732     public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1733 
1734     /**
1735      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1736      * of the cameras on the device supports the
1737      * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1738      * capability level.
1739      */
1740     @SdkConstant(SdkConstantType.FEATURE)
1741     public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1742 
1743     /**
1744      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1745      * of the cameras on the device supports the
1746      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1747      * capability level.
1748      */
1749     @SdkConstant(SdkConstantType.FEATURE)
1750     public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1751             "android.hardware.camera.capability.manual_sensor";
1752 
1753     /**
1754      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1755      * of the cameras on the device supports the
1756      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1757      * capability level.
1758      */
1759     @SdkConstant(SdkConstantType.FEATURE)
1760     public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1761             "android.hardware.camera.capability.manual_post_processing";
1762 
1763     /**
1764      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1765      * of the cameras on the device supports the
1766      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1767      * capability level.
1768      */
1769     @SdkConstant(SdkConstantType.FEATURE)
1770     public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1771             "android.hardware.camera.capability.raw";
1772 
1773     /**
1774      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1775      * of the cameras on the device supports the
1776      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING
1777      * MOTION_TRACKING} capability level.
1778      */
1779     @SdkConstant(SdkConstantType.FEATURE)
1780     public static final String FEATURE_CAMERA_AR =
1781             "android.hardware.camera.ar";
1782 
1783     /**
1784      * Feature for {@link #getSystemAvailableFeatures} and
1785      * {@link #hasSystemFeature}: The device is capable of communicating with
1786      * consumer IR devices.
1787      */
1788     @SdkConstant(SdkConstantType.FEATURE)
1789     public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1790 
1791     /** {@hide} */
1792     @SdkConstant(SdkConstantType.FEATURE)
1793     public static final String FEATURE_CTS = "android.software.cts";
1794 
1795     /**
1796      * Feature for {@link #getSystemAvailableFeatures} and
1797      * {@link #hasSystemFeature}: The device supports one or more methods of
1798      * reporting current location.
1799      */
1800     @SdkConstant(SdkConstantType.FEATURE)
1801     public static final String FEATURE_LOCATION = "android.hardware.location";
1802 
1803     /**
1804      * Feature for {@link #getSystemAvailableFeatures} and
1805      * {@link #hasSystemFeature}: The device has a Global Positioning System
1806      * receiver and can report precise location.
1807      */
1808     @SdkConstant(SdkConstantType.FEATURE)
1809     public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1810 
1811     /**
1812      * Feature for {@link #getSystemAvailableFeatures} and
1813      * {@link #hasSystemFeature}: The device can report location with coarse
1814      * accuracy using a network-based geolocation system.
1815      */
1816     @SdkConstant(SdkConstantType.FEATURE)
1817     public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1818 
1819     /**
1820      * Feature for {@link #getSystemAvailableFeatures} and
1821      * {@link #hasSystemFeature}: The device's
1822      * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
1823      * true.
1824      */
1825     @SdkConstant(SdkConstantType.FEATURE)
1826     public static final String FEATURE_RAM_LOW = "android.hardware.ram.low";
1827 
1828     /**
1829      * Feature for {@link #getSystemAvailableFeatures} and
1830      * {@link #hasSystemFeature}: The device's
1831      * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns
1832      * false.
1833      */
1834     @SdkConstant(SdkConstantType.FEATURE)
1835     public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal";
1836 
1837     /**
1838      * Feature for {@link #getSystemAvailableFeatures} and
1839      * {@link #hasSystemFeature}: The device can record audio via a
1840      * microphone.
1841      */
1842     @SdkConstant(SdkConstantType.FEATURE)
1843     public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1844 
1845     /**
1846      * Feature for {@link #getSystemAvailableFeatures} and
1847      * {@link #hasSystemFeature}: The device can communicate using Near-Field
1848      * Communications (NFC).
1849      */
1850     @SdkConstant(SdkConstantType.FEATURE)
1851     public static final String FEATURE_NFC = "android.hardware.nfc";
1852 
1853     /**
1854      * Feature for {@link #getSystemAvailableFeatures} and
1855      * {@link #hasSystemFeature}: The device supports host-
1856      * based NFC card emulation.
1857      *
1858      * TODO remove when depending apps have moved to new constant.
1859      * @hide
1860      * @deprecated
1861      */
1862     @Deprecated
1863     @SdkConstant(SdkConstantType.FEATURE)
1864     public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1865 
1866     /**
1867      * Feature for {@link #getSystemAvailableFeatures} and
1868      * {@link #hasSystemFeature}: The device supports host-
1869      * based NFC card emulation.
1870      */
1871     @SdkConstant(SdkConstantType.FEATURE)
1872     public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1873 
1874     /**
1875      * Feature for {@link #getSystemAvailableFeatures} and
1876      * {@link #hasSystemFeature}: The device supports host-
1877      * based NFC-F card emulation.
1878      */
1879     @SdkConstant(SdkConstantType.FEATURE)
1880     public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef";
1881 
1882     /**
1883      * Feature for {@link #getSystemAvailableFeatures} and
1884      * {@link #hasSystemFeature}: The device supports any
1885      * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION},
1886      * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features.
1887      *
1888      * @hide
1889      */
1890     @SdkConstant(SdkConstantType.FEATURE)
1891     public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any";
1892 
1893     /**
1894      * Feature for {@link #getSystemAvailableFeatures} and
1895      * {@link #hasSystemFeature}: The device supports the OpenGL ES
1896      * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1897      * Android Extension Pack</a>.
1898      */
1899     @SdkConstant(SdkConstantType.FEATURE)
1900     public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1901 
1902     /**
1903      * Feature for {@link #getSystemAvailableFeatures} and
1904      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1905      * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
1906      * what level of optional hardware features limits it supports.
1907      * <p>
1908      * Level 0 includes the base Vulkan requirements as well as:
1909      * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul>
1910      * <p>
1911      * Level 1 additionally includes:
1912      * <ul>
1913      * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li>
1914      * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li>
1915      * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li>
1916      * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li>
1917      * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li>
1918      * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li>
1919      * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li>
1920      * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li>
1921      * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li>
1922      * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li>
1923      * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li>
1924      * </ul>
1925      */
1926     @SdkConstant(SdkConstantType.FEATURE)
1927     public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level";
1928 
1929     /**
1930      * Feature for {@link #getSystemAvailableFeatures} and
1931      * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1932      * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
1933      * what level of optional compute features that device supports beyond the Vulkan 1.0
1934      * requirements.
1935      * <p>
1936      * Compute level 0 indicates:
1937      * <ul>
1938      * <li>The {@code VK_KHR_variable_pointers} extension and
1939      *     {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are
1940            supported.</li>
1941      * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li>
1942      * </ul>
1943      */
1944     @SdkConstant(SdkConstantType.FEATURE)
1945     public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute";
1946 
1947     /**
1948      * Feature for {@link #getSystemAvailableFeatures} and
1949      * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest
1950      * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support
1951      * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version
1952      * uses the same encoding as Vulkan version numbers:
1953      * <ul>
1954      * <li>Major version number in bits 31-22</li>
1955      * <li>Minor version number in bits 21-12</li>
1956      * <li>Patch version number in bits 11-0</li>
1957      * </ul>
1958      * A version of 1.1.0 or higher also indicates:
1959      * <ul>
1960      * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li>
1961      * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is
1962      *     supported.</li>
1963      * </ul>
1964      */
1965     @SdkConstant(SdkConstantType.FEATURE)
1966     public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version";
1967 
1968     /**
1969      * Feature for {@link #getSystemAvailableFeatures} and
1970      * {@link #hasSystemFeature}: The device includes broadcast radio tuner.
1971      * @hide
1972      */
1973     @SystemApi
1974     @SdkConstant(SdkConstantType.FEATURE)
1975     public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio";
1976 
1977     /**
1978      * Feature for {@link #getSystemAvailableFeatures} and
1979      * {@link #hasSystemFeature}: The device includes an accelerometer.
1980      */
1981     @SdkConstant(SdkConstantType.FEATURE)
1982     public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1983 
1984     /**
1985      * Feature for {@link #getSystemAvailableFeatures} and
1986      * {@link #hasSystemFeature}: The device includes a barometer (air
1987      * pressure sensor.)
1988      */
1989     @SdkConstant(SdkConstantType.FEATURE)
1990     public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1991 
1992     /**
1993      * Feature for {@link #getSystemAvailableFeatures} and
1994      * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1995      */
1996     @SdkConstant(SdkConstantType.FEATURE)
1997     public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1998 
1999     /**
2000      * Feature for {@link #getSystemAvailableFeatures} and
2001      * {@link #hasSystemFeature}: The device includes a gyroscope.
2002      */
2003     @SdkConstant(SdkConstantType.FEATURE)
2004     public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
2005 
2006     /**
2007      * Feature for {@link #getSystemAvailableFeatures} and
2008      * {@link #hasSystemFeature}: The device includes a light sensor.
2009      */
2010     @SdkConstant(SdkConstantType.FEATURE)
2011     public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
2012 
2013     /**
2014      * Feature for {@link #getSystemAvailableFeatures} and
2015      * {@link #hasSystemFeature}: The device includes a proximity sensor.
2016      */
2017     @SdkConstant(SdkConstantType.FEATURE)
2018     public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
2019 
2020     /**
2021      * Feature for {@link #getSystemAvailableFeatures} and
2022      * {@link #hasSystemFeature}: The device includes a hardware step counter.
2023      */
2024     @SdkConstant(SdkConstantType.FEATURE)
2025     public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
2026 
2027     /**
2028      * Feature for {@link #getSystemAvailableFeatures} and
2029      * {@link #hasSystemFeature}: The device includes a hardware step detector.
2030      */
2031     @SdkConstant(SdkConstantType.FEATURE)
2032     public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
2033 
2034     /**
2035      * Feature for {@link #getSystemAvailableFeatures} and
2036      * {@link #hasSystemFeature}: The device includes a heart rate monitor.
2037      */
2038     @SdkConstant(SdkConstantType.FEATURE)
2039     public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
2040 
2041     /**
2042      * Feature for {@link #getSystemAvailableFeatures} and
2043      * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram.
2044      */
2045     @SdkConstant(SdkConstantType.FEATURE)
2046     public static final String FEATURE_SENSOR_HEART_RATE_ECG =
2047             "android.hardware.sensor.heartrate.ecg";
2048 
2049     /**
2050      * Feature for {@link #getSystemAvailableFeatures} and
2051      * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
2052      */
2053     @SdkConstant(SdkConstantType.FEATURE)
2054     public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
2055             "android.hardware.sensor.relative_humidity";
2056 
2057     /**
2058      * Feature for {@link #getSystemAvailableFeatures} and
2059      * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
2060      */
2061     @SdkConstant(SdkConstantType.FEATURE)
2062     public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
2063             "android.hardware.sensor.ambient_temperature";
2064 
2065     /**
2066      * Feature for {@link #getSystemAvailableFeatures} and
2067      * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
2068      * capabilities.
2069      */
2070     @SdkConstant(SdkConstantType.FEATURE)
2071     public static final String FEATURE_HIFI_SENSORS =
2072             "android.hardware.sensor.hifi_sensors";
2073 
2074     /**
2075      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2076      * The device supports a hardware mechanism for invoking an assist gesture.
2077      * @see android.provider.Settings.Secure#ASSIST_GESTURE_ENABLED
2078      * @hide
2079      */
2080     @SdkConstant(SdkConstantType.FEATURE)
2081     public static final String FEATURE_ASSIST_GESTURE = "android.hardware.sensor.assist";
2082 
2083     /**
2084      * Feature for {@link #getSystemAvailableFeatures} and
2085      * {@link #hasSystemFeature}: The device has a telephony radio with data
2086      * communication support.
2087      */
2088     @SdkConstant(SdkConstantType.FEATURE)
2089     public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
2090 
2091     /**
2092      * Feature for {@link #getSystemAvailableFeatures} and
2093      * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
2094      */
2095     @SdkConstant(SdkConstantType.FEATURE)
2096     public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
2097 
2098     /**
2099      * Feature for {@link #getSystemAvailableFeatures} and
2100      * {@link #hasSystemFeature}: The device has a GSM telephony stack.
2101      */
2102     @SdkConstant(SdkConstantType.FEATURE)
2103     public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
2104 
2105     /**
2106      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2107      * The device supports telephony carrier restriction mechanism.
2108      *
2109      * <p>Devices declaring this feature must have an implementation of the
2110      * {@link android.telephony.TelephonyManager#getAllowedCarriers} and
2111      * {@link android.telephony.TelephonyManager#setAllowedCarriers}.
2112      * @hide
2113      */
2114     @SystemApi
2115     @SdkConstant(SdkConstantType.FEATURE)
2116     public static final String FEATURE_TELEPHONY_CARRIERLOCK =
2117             "android.hardware.telephony.carrierlock";
2118 
2119     /**
2120      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
2121      * supports embedded subscriptions on eUICCs.
2122      */
2123     @SdkConstant(SdkConstantType.FEATURE)
2124     public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc";
2125 
2126     /**
2127      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device
2128      * supports cell-broadcast reception using the MBMS APIs.
2129      */
2130     @SdkConstant(SdkConstantType.FEATURE)
2131     public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms";
2132 
2133     /**
2134      * Feature for {@link #getSystemAvailableFeatures} and
2135      * {@link #hasSystemFeature}: The device supports connecting to USB devices
2136      * as the USB host.
2137      */
2138     @SdkConstant(SdkConstantType.FEATURE)
2139     public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
2140 
2141     /**
2142      * Feature for {@link #getSystemAvailableFeatures} and
2143      * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
2144      */
2145     @SdkConstant(SdkConstantType.FEATURE)
2146     public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
2147 
2148     /**
2149      * Feature for {@link #getSystemAvailableFeatures} and
2150      * {@link #hasSystemFeature}: The SIP API is enabled on the device.
2151      */
2152     @SdkConstant(SdkConstantType.FEATURE)
2153     public static final String FEATURE_SIP = "android.software.sip";
2154 
2155     /**
2156      * Feature for {@link #getSystemAvailableFeatures} and
2157      * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
2158      */
2159     @SdkConstant(SdkConstantType.FEATURE)
2160     public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
2161 
2162     /**
2163      * Feature for {@link #getSystemAvailableFeatures} and
2164      * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
2165      */
2166     @SdkConstant(SdkConstantType.FEATURE)
2167     public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
2168 
2169     /**
2170      * Feature for {@link #getSystemAvailableFeatures} and
2171      * {@link #hasSystemFeature}: The device's display has a touch screen.
2172      */
2173     @SdkConstant(SdkConstantType.FEATURE)
2174     public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
2175 
2176     /**
2177      * Feature for {@link #getSystemAvailableFeatures} and
2178      * {@link #hasSystemFeature}: The device's touch screen supports
2179      * multitouch sufficient for basic two-finger gesture detection.
2180      */
2181     @SdkConstant(SdkConstantType.FEATURE)
2182     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
2183 
2184     /**
2185      * Feature for {@link #getSystemAvailableFeatures} and
2186      * {@link #hasSystemFeature}: The device's touch screen is capable of
2187      * tracking two or more fingers fully independently.
2188      */
2189     @SdkConstant(SdkConstantType.FEATURE)
2190     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
2191 
2192     /**
2193      * Feature for {@link #getSystemAvailableFeatures} and
2194      * {@link #hasSystemFeature}: The device's touch screen is capable of
2195      * tracking a full hand of fingers fully independently -- that is, 5 or
2196      * more simultaneous independent pointers.
2197      */
2198     @SdkConstant(SdkConstantType.FEATURE)
2199     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
2200 
2201     /**
2202      * Feature for {@link #getSystemAvailableFeatures} and
2203      * {@link #hasSystemFeature}: The device does not have a touch screen, but
2204      * does support touch emulation for basic events. For instance, the
2205      * device might use a mouse or remote control to drive a cursor, and
2206      * emulate basic touch pointer events like down, up, drag, etc. All
2207      * devices that support android.hardware.touchscreen or a sub-feature are
2208      * presumed to also support faketouch.
2209      */
2210     @SdkConstant(SdkConstantType.FEATURE)
2211     public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
2212 
2213     /**
2214      * Feature for {@link #getSystemAvailableFeatures} and
2215      * {@link #hasSystemFeature}: The device does not have a touch screen, but
2216      * does support touch emulation for basic events that supports distinct
2217      * tracking of two or more fingers.  This is an extension of
2218      * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
2219      * that unlike a distinct multitouch screen as defined by
2220      * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
2221      * devices will not actually provide full two-finger gestures since the
2222      * input is being transformed to cursor movement on the screen.  That is,
2223      * single finger gestures will move a cursor; two-finger swipes will
2224      * result in single-finger touch events; other two-finger gestures will
2225      * result in the corresponding two-finger touch event.
2226      */
2227     @SdkConstant(SdkConstantType.FEATURE)
2228     public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
2229 
2230     /**
2231      * Feature for {@link #getSystemAvailableFeatures} and
2232      * {@link #hasSystemFeature}: The device does not have a touch screen, but
2233      * does support touch emulation for basic events that supports tracking
2234      * a hand of fingers (5 or more fingers) fully independently.
2235      * This is an extension of
2236      * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
2237      * that unlike a multitouch screen as defined by
2238      * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
2239      * gestures can be detected due to the limitations described for
2240      * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
2241      */
2242     @SdkConstant(SdkConstantType.FEATURE)
2243     public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
2244 
2245     /**
2246      * Feature for {@link #getSystemAvailableFeatures} and
2247      * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
2248       */
2249     @SdkConstant(SdkConstantType.FEATURE)
2250     public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
2251 
2252     /**
2253      * Feature for {@link #getSystemAvailableFeatures} and
2254      * {@link #hasSystemFeature}: The device supports portrait orientation
2255      * screens.  For backwards compatibility, you can assume that if neither
2256      * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
2257      * both portrait and landscape.
2258      */
2259     @SdkConstant(SdkConstantType.FEATURE)
2260     public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
2261 
2262     /**
2263      * Feature for {@link #getSystemAvailableFeatures} and
2264      * {@link #hasSystemFeature}: The device supports landscape orientation
2265      * screens.  For backwards compatibility, you can assume that if neither
2266      * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
2267      * both portrait and landscape.
2268      */
2269     @SdkConstant(SdkConstantType.FEATURE)
2270     public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
2271 
2272     /**
2273      * Feature for {@link #getSystemAvailableFeatures} and
2274      * {@link #hasSystemFeature}: The device supports live wallpapers.
2275      */
2276     @SdkConstant(SdkConstantType.FEATURE)
2277     public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
2278     /**
2279      * Feature for {@link #getSystemAvailableFeatures} and
2280      * {@link #hasSystemFeature}: The device supports app widgets.
2281      */
2282     @SdkConstant(SdkConstantType.FEATURE)
2283     public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
2284     /**
2285      * Feature for {@link #getSystemAvailableFeatures} and
2286      * {@link #hasSystemFeature}: The device supports the
2287      * {@link android.R.attr#cantSaveState} API.
2288      */
2289     @SdkConstant(SdkConstantType.FEATURE)
2290     public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state";
2291 
2292     /**
2293      * @hide
2294      * Feature for {@link #getSystemAvailableFeatures} and
2295      * {@link #hasSystemFeature}: The device supports
2296      * {@link android.service.voice.VoiceInteractionService} and
2297      * {@link android.app.VoiceInteractor}.
2298      */
2299     @SdkConstant(SdkConstantType.FEATURE)
2300     public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
2301 
2302 
2303     /**
2304      * Feature for {@link #getSystemAvailableFeatures} and
2305      * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
2306      * by third party applications.
2307      */
2308     @SdkConstant(SdkConstantType.FEATURE)
2309     public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
2310 
2311     /**
2312      * Feature for {@link #getSystemAvailableFeatures} and
2313      * {@link #hasSystemFeature}: The device supports adding new input methods implemented
2314      * with the {@link android.inputmethodservice.InputMethodService} API.
2315      */
2316     @SdkConstant(SdkConstantType.FEATURE)
2317     public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
2318 
2319     /**
2320      * Feature for {@link #getSystemAvailableFeatures} and
2321      * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
2322      */
2323     @SdkConstant(SdkConstantType.FEATURE)
2324     public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
2325 
2326     /**
2327      * Feature for {@link #getSystemAvailableFeatures} and
2328      * {@link #hasSystemFeature}: The device supports leanback UI. This is
2329      * typically used in a living room television experience, but is a software
2330      * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
2331      * feature will use resources associated with the "television" UI mode.
2332      */
2333     @SdkConstant(SdkConstantType.FEATURE)
2334     public static final String FEATURE_LEANBACK = "android.software.leanback";
2335 
2336     /**
2337      * Feature for {@link #getSystemAvailableFeatures} and
2338      * {@link #hasSystemFeature}: The device supports only leanback UI. Only
2339      * applications designed for this experience should be run, though this is
2340      * not enforced by the system.
2341      */
2342     @SdkConstant(SdkConstantType.FEATURE)
2343     public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
2344 
2345     /**
2346      * Feature for {@link #getSystemAvailableFeatures} and
2347      * {@link #hasSystemFeature}: The device supports live TV and can display
2348      * contents from TV inputs implemented with the
2349      * {@link android.media.tv.TvInputService} API.
2350      */
2351     @SdkConstant(SdkConstantType.FEATURE)
2352     public static final String FEATURE_LIVE_TV = "android.software.live_tv";
2353 
2354     /**
2355      * Feature for {@link #getSystemAvailableFeatures} and
2356      * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
2357      */
2358     @SdkConstant(SdkConstantType.FEATURE)
2359     public static final String FEATURE_WIFI = "android.hardware.wifi";
2360 
2361     /**
2362      * Feature for {@link #getSystemAvailableFeatures} and
2363      * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
2364      */
2365     @SdkConstant(SdkConstantType.FEATURE)
2366     public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
2367 
2368     /**
2369      * Feature for {@link #getSystemAvailableFeatures} and
2370      * {@link #hasSystemFeature}: The device supports Wi-Fi Aware.
2371      */
2372     @SdkConstant(SdkConstantType.FEATURE)
2373     public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware";
2374 
2375     /**
2376      * Feature for {@link #getSystemAvailableFeatures} and
2377      * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all
2378      * Passpoint related APIs in {@link WifiManager} are supported. Refer to
2379      * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info.
2380      */
2381     @SdkConstant(SdkConstantType.FEATURE)
2382     public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint";
2383 
2384     /**
2385      * Feature for {@link #getSystemAvailableFeatures} and
2386      * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc).
2387      */
2388     @SdkConstant(SdkConstantType.FEATURE)
2389     public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt";
2390 
2391 
2392     /**
2393      * Feature for {@link #getSystemAvailableFeatures} and
2394      * {@link #hasSystemFeature}: The device supports LoWPAN networking.
2395      * @hide
2396      */
2397     @SdkConstant(SdkConstantType.FEATURE)
2398     public static final String FEATURE_LOWPAN = "android.hardware.lowpan";
2399 
2400     /**
2401      * Feature for {@link #getSystemAvailableFeatures} and
2402      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2403      * on a vehicle headunit. A headunit here is defined to be inside a
2404      * vehicle that may or may not be moving. A headunit uses either a
2405      * primary display in the center console and/or additional displays in
2406      * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
2407      * have limited size and resolution. The user will likely be focused on
2408      * driving so limiting driver distraction is a primary concern. User input
2409      * can be a variety of hard buttons, touch, rotary controllers and even mouse-
2410      * like interfaces.
2411      */
2412     @SdkConstant(SdkConstantType.FEATURE)
2413     public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
2414 
2415     /**
2416      * Feature for {@link #getSystemAvailableFeatures} and
2417      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2418      * on a television.  Television here is defined to be a typical living
2419      * room television experience: displayed on a big screen, where the user
2420      * is sitting far away from it, and the dominant form of input will be
2421      * something like a DPAD, not through touch or mouse.
2422      * @deprecated use {@link #FEATURE_LEANBACK} instead.
2423      */
2424     @Deprecated
2425     @SdkConstant(SdkConstantType.FEATURE)
2426     public static final String FEATURE_TELEVISION = "android.hardware.type.television";
2427 
2428     /**
2429      * Feature for {@link #getSystemAvailableFeatures} and
2430      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2431      * on a watch. A watch here is defined to be a device worn on the body, perhaps on
2432      * the wrist. The user is very close when interacting with the device.
2433      */
2434     @SdkConstant(SdkConstantType.FEATURE)
2435     public static final String FEATURE_WATCH = "android.hardware.type.watch";
2436 
2437     /**
2438      * Feature for {@link #getSystemAvailableFeatures} and
2439      * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded
2440      * device is defined as a full stack Android device with or without a display and no
2441      * user-installable apps.
2442      */
2443     @SdkConstant(SdkConstantType.FEATURE)
2444     public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded";
2445 
2446     /**
2447      * Feature for {@link #getSystemAvailableFeatures} and
2448      * {@link #hasSystemFeature}: This is a device dedicated to be primarily used
2449      * with keyboard, mouse or touchpad. This includes traditional desktop
2450      * computers, laptops and variants such as convertibles or detachables.
2451      * Due to the larger screen, the device will most likely use the
2452      * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well.
2453      */
2454     @SdkConstant(SdkConstantType.FEATURE)
2455     public static final String FEATURE_PC = "android.hardware.type.pc";
2456 
2457     /**
2458      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2459      * The device supports printing.
2460      */
2461     @SdkConstant(SdkConstantType.FEATURE)
2462     public static final String FEATURE_PRINTING = "android.software.print";
2463 
2464     /**
2465      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2466      * The device supports {@link android.companion.CompanionDeviceManager#associate associating}
2467      * with devices via {@link android.companion.CompanionDeviceManager}.
2468      */
2469     @SdkConstant(SdkConstantType.FEATURE)
2470     public static final String FEATURE_COMPANION_DEVICE_SETUP
2471             = "android.software.companion_device_setup";
2472 
2473     /**
2474      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2475      * The device can perform backup and restore operations on installed applications.
2476      */
2477     @SdkConstant(SdkConstantType.FEATURE)
2478     public static final String FEATURE_BACKUP = "android.software.backup";
2479 
2480     /**
2481      * Feature for {@link #getSystemAvailableFeatures} and
2482      * {@link #hasSystemFeature}: The device supports freeform window management.
2483      * Windows have title bars and can be moved and resized.
2484      */
2485     // If this feature is present, you also need to set
2486     // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay.
2487     @SdkConstant(SdkConstantType.FEATURE)
2488     public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
2489             = "android.software.freeform_window_management";
2490 
2491     /**
2492      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2493      * The device supports picture-in-picture multi-window mode.
2494      */
2495     @SdkConstant(SdkConstantType.FEATURE)
2496     public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
2497 
2498     /**
2499      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2500      * The device supports running activities on secondary displays.
2501      */
2502     @SdkConstant(SdkConstantType.FEATURE)
2503     public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS
2504             = "android.software.activities_on_secondary_displays";
2505 
2506     /**
2507      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2508      * The device supports creating secondary users and managed profiles via
2509      * {@link DevicePolicyManager}.
2510      */
2511     @SdkConstant(SdkConstantType.FEATURE)
2512     public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
2513 
2514     /**
2515      * @hide
2516      * TODO: Remove after dependencies updated b/17392243
2517      */
2518     public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
2519 
2520     /**
2521      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2522      * The device supports verified boot.
2523      */
2524     @SdkConstant(SdkConstantType.FEATURE)
2525     public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
2526 
2527     /**
2528      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2529      * The device supports secure removal of users. When a user is deleted the data associated
2530      * with that user is securely deleted and no longer available.
2531      */
2532     @SdkConstant(SdkConstantType.FEATURE)
2533     public static final String FEATURE_SECURELY_REMOVES_USERS
2534             = "android.software.securely_removes_users";
2535 
2536     /** {@hide} */
2537     @TestApi
2538     @SdkConstant(SdkConstantType.FEATURE)
2539     public static final String FEATURE_FILE_BASED_ENCRYPTION
2540             = "android.software.file_based_encryption";
2541 
2542     /** {@hide} */
2543     @TestApi
2544     @SdkConstant(SdkConstantType.FEATURE)
2545     public static final String FEATURE_ADOPTABLE_STORAGE
2546             = "android.software.adoptable_storage";
2547 
2548     /**
2549      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2550      * The device has a full implementation of the android.webkit.* APIs. Devices
2551      * lacking this feature will not have a functioning WebView implementation.
2552      */
2553     @SdkConstant(SdkConstantType.FEATURE)
2554     public static final String FEATURE_WEBVIEW = "android.software.webview";
2555 
2556     /**
2557      * Feature for {@link #getSystemAvailableFeatures} and
2558      * {@link #hasSystemFeature}: This device supports ethernet.
2559      */
2560     @SdkConstant(SdkConstantType.FEATURE)
2561     public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
2562 
2563     /**
2564      * Feature for {@link #getSystemAvailableFeatures} and
2565      * {@link #hasSystemFeature}: This device supports HDMI-CEC.
2566      * @hide
2567      */
2568     @SdkConstant(SdkConstantType.FEATURE)
2569     public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
2570 
2571     /**
2572      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2573      * The device has all of the inputs necessary to be considered a compatible game controller, or
2574      * includes a compatible game controller in the box.
2575      */
2576     @SdkConstant(SdkConstantType.FEATURE)
2577     public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
2578 
2579     /**
2580      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2581      * The device has a full implementation of the android.media.midi.* APIs.
2582      */
2583     @SdkConstant(SdkConstantType.FEATURE)
2584     public static final String FEATURE_MIDI = "android.software.midi";
2585 
2586     /**
2587      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2588      * The device implements an optimized mode for virtual reality (VR) applications that handles
2589      * stereoscopic rendering of notifications, and disables most monocular system UI components
2590      * while a VR application has user focus.
2591      * Devices declaring this feature must include an application implementing a
2592      * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2593      * {@link android.app.Activity#setVrModeEnabled}.
2594      * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead.
2595      */
2596     @Deprecated
2597     @SdkConstant(SdkConstantType.FEATURE)
2598     public static final String FEATURE_VR_MODE = "android.software.vr.mode";
2599 
2600     /**
2601      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2602      * The device implements an optimized mode for virtual reality (VR) applications that handles
2603      * stereoscopic rendering of notifications, disables most monocular system UI components
2604      * while a VR application has user focus and meets extra CDD requirements to provide a
2605      * high-quality VR experience.
2606      * Devices declaring this feature must include an application implementing a
2607      * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2608      * {@link android.app.Activity#setVrModeEnabled}.
2609      * and must meet CDD requirements to provide a high-quality VR experience.
2610      */
2611     @SdkConstant(SdkConstantType.FEATURE)
2612     public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
2613             = "android.hardware.vr.high_performance";
2614 
2615     /**
2616      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2617      * The device supports autofill of user credentials, addresses, credit cards, etc
2618      * via integration with {@link android.service.autofill.AutofillService autofill
2619      * providers}.
2620      */
2621     @SdkConstant(SdkConstantType.FEATURE)
2622     public static final String FEATURE_AUTOFILL = "android.software.autofill";
2623 
2624     /**
2625      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2626      * The device implements headtracking suitable for a VR device.
2627      */
2628     @SdkConstant(SdkConstantType.FEATURE)
2629     public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking";
2630 
2631     /**
2632      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2633      * The device has a StrongBox hardware-backed Keystore.
2634      */
2635     @SdkConstant(SdkConstantType.FEATURE)
2636     public static final String FEATURE_STRONGBOX_KEYSTORE =
2637             "android.hardware.strongbox_keystore";
2638 
2639     /**
2640      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2641      * The device has a Keymaster implementation that supports Device ID attestation.
2642      *
2643      * @see DevicePolicyManager#isDeviceIdAttestationSupported
2644      * @hide
2645      */
2646     @SdkConstant(SdkConstantType.FEATURE)
2647     public static final String FEATURE_DEVICE_ID_ATTESTATION =
2648             "android.software.device_id_attestation";
2649 
2650     /**
2651      * Action to external storage service to clean out removed apps.
2652      * @hide
2653      */
2654     public static final String ACTION_CLEAN_EXTERNAL_STORAGE
2655             = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
2656 
2657     /**
2658      * Extra field name for the URI to a verification file. Passed to a package
2659      * verifier.
2660      *
2661      * @hide
2662      */
2663     public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
2664 
2665     /**
2666      * Extra field name for the ID of a package pending verification. Passed to
2667      * a package verifier and is used to call back to
2668      * {@link PackageManager#verifyPendingInstall(int, int)}
2669      */
2670     public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
2671 
2672     /**
2673      * Extra field name for the package identifier which is trying to install
2674      * the package.
2675      *
2676      * @hide
2677      */
2678     public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
2679             = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
2680 
2681     /**
2682      * Extra field name for the requested install flags for a package pending
2683      * verification. Passed to a package verifier.
2684      *
2685      * @hide
2686      */
2687     public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
2688             = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
2689 
2690     /**
2691      * Extra field name for the uid of who is requesting to install
2692      * the package.
2693      *
2694      * @hide
2695      */
2696     public static final String EXTRA_VERIFICATION_INSTALLER_UID
2697             = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
2698 
2699     /**
2700      * Extra field name for the package name of a package pending verification.
2701      *
2702      * @hide
2703      */
2704     public static final String EXTRA_VERIFICATION_PACKAGE_NAME
2705             = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
2706     /**
2707      * Extra field name for the result of a verification, either
2708      * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
2709      * Passed to package verifiers after a package is verified.
2710      */
2711     public static final String EXTRA_VERIFICATION_RESULT
2712             = "android.content.pm.extra.VERIFICATION_RESULT";
2713 
2714     /**
2715      * Extra field name for the version code of a package pending verification.
2716      * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead.
2717      * @hide
2718      */
2719     @Deprecated
2720     public static final String EXTRA_VERIFICATION_VERSION_CODE
2721             = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
2722 
2723     /**
2724      * Extra field name for the long version code of a package pending verification.
2725      *
2726      * @hide
2727      */
2728     public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE =
2729             "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE";
2730 
2731     /**
2732      * Extra field name for the ID of a intent filter pending verification.
2733      * Passed to an intent filter verifier and is used to call back to
2734      * {@link #verifyIntentFilter}
2735      *
2736      * @hide
2737      */
2738     public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
2739             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
2740 
2741     /**
2742      * Extra field name for the scheme used for an intent filter pending verification. Passed to
2743      * an intent filter verifier and is used to construct the URI to verify against.
2744      *
2745      * Usually this is "https"
2746      *
2747      * @hide
2748      */
2749     public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
2750             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
2751 
2752     /**
2753      * Extra field name for the host names to be used for an intent filter pending verification.
2754      * Passed to an intent filter verifier and is used to construct the URI to verify the
2755      * intent filter.
2756      *
2757      * This is a space delimited list of hosts.
2758      *
2759      * @hide
2760      */
2761     public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
2762             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
2763 
2764     /**
2765      * Extra field name for the package name to be used for an intent filter pending verification.
2766      * Passed to an intent filter verifier and is used to check the verification responses coming
2767      * from the hosts. Each host response will need to include the package name of APK containing
2768      * the intent filter.
2769      *
2770      * @hide
2771      */
2772     public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
2773             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
2774 
2775     /**
2776      * The action used to request that the user approve a permission request
2777      * from the application.
2778      *
2779      * @hide
2780      */
2781     @SystemApi
2782     public static final String ACTION_REQUEST_PERMISSIONS =
2783             "android.content.pm.action.REQUEST_PERMISSIONS";
2784 
2785     /**
2786      * The names of the requested permissions.
2787      * <p>
2788      * <strong>Type:</strong> String[]
2789      * </p>
2790      *
2791      * @hide
2792      */
2793     @SystemApi
2794     public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
2795             "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
2796 
2797     /**
2798      * The results from the permissions request.
2799      * <p>
2800      * <strong>Type:</strong> int[] of #PermissionResult
2801      * </p>
2802      *
2803      * @hide
2804      */
2805     @SystemApi
2806     public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
2807             = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
2808 
2809     /**
2810      * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2811      * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
2812      * the existing definition for the permission.
2813      * @hide
2814      */
2815     public static final String EXTRA_FAILURE_EXISTING_PACKAGE
2816             = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
2817 
2818     /**
2819      * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2820      * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
2821      * being redundantly defined by the package being installed.
2822      * @hide
2823      */
2824     public static final String EXTRA_FAILURE_EXISTING_PERMISSION
2825             = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
2826 
2827    /**
2828     * Permission flag: The permission is set in its current state
2829     * by the user and apps can still request it at runtime.
2830     *
2831     * @hide
2832     */
2833     @SystemApi
2834     public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
2835 
2836     /**
2837      * Permission flag: The permission is set in its current state
2838      * by the user and it is fixed, i.e. apps can no longer request
2839      * this permission.
2840      *
2841      * @hide
2842      */
2843     @SystemApi
2844     public static final int FLAG_PERMISSION_USER_FIXED =  1 << 1;
2845 
2846     /**
2847      * Permission flag: The permission is set in its current state
2848      * by device policy and neither apps nor the user can change
2849      * its state.
2850      *
2851      * @hide
2852      */
2853     @SystemApi
2854     public static final int FLAG_PERMISSION_POLICY_FIXED =  1 << 2;
2855 
2856     /**
2857      * Permission flag: The permission is set in a granted state but
2858      * access to resources it guards is restricted by other means to
2859      * enable revoking a permission on legacy apps that do not support
2860      * runtime permissions. If this permission is upgraded to runtime
2861      * because the app was updated to support runtime permissions, the
2862      * the permission will be revoked in the upgrade process.
2863      *
2864      * @hide
2865      */
2866     @SystemApi
2867     public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE =  1 << 3;
2868 
2869     /**
2870      * Permission flag: The permission is set in its current state
2871      * because the app is a component that is a part of the system.
2872      *
2873      * @hide
2874      */
2875     @SystemApi
2876     public static final int FLAG_PERMISSION_SYSTEM_FIXED =  1 << 4;
2877 
2878     /**
2879      * Permission flag: The permission is granted by default because it
2880      * enables app functionality that is expected to work out-of-the-box
2881      * for providing a smooth user experience. For example, the phone app
2882      * is expected to have the phone permission.
2883      *
2884      * @hide
2885      */
2886     @SystemApi
2887     public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
2888 
2889     /**
2890      * Permission flag: The permission has to be reviewed before any of
2891      * the app components can run.
2892      *
2893      * @hide
2894      */
2895     @SystemApi
2896     public static final int FLAG_PERMISSION_REVIEW_REQUIRED =  1 << 6;
2897 
2898     /**
2899      * Mask for all permission flags.
2900      *
2901      * @hide
2902      */
2903     @SystemApi
2904     public static final int MASK_PERMISSION_FLAGS = 0xFF;
2905 
2906     /**
2907      * This is a library that contains components apps can invoke. For
2908      * example, a services for apps to bind to, or standard chooser UI,
2909      * etc. This library is versioned and backwards compatible. Clients
2910      * should check its version via {@link android.ext.services.Version
2911      * #getVersionCode()} and avoid calling APIs added in later versions.
2912      *
2913      * @hide
2914      */
2915     public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
2916 
2917     /**
2918      * This is a library that contains components apps can dynamically
2919      * load. For example, new widgets, helper classes, etc. This library
2920      * is versioned and backwards compatible. Clients should check its
2921      * version via {@link android.ext.shared.Version#getVersionCode()}
2922      * and avoid calling APIs added in later versions.
2923      *
2924      * @hide
2925      */
2926     public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
2927 
2928     /**
2929      * Used when starting a process for an Activity.
2930      *
2931      * @hide
2932      */
2933     public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
2934 
2935     /**
2936      * Used when starting a process for a Service.
2937      *
2938      * @hide
2939      */
2940     public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
2941 
2942     /**
2943      * Used when moving a Service to the foreground.
2944      *
2945      * @hide
2946      */
2947     public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
2948 
2949     /**
2950      * Used when starting a process for a BroadcastReceiver.
2951      *
2952      * @hide
2953      */
2954     public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
2955 
2956     /**
2957      * Used when starting a process for a ContentProvider.
2958      *
2959      * @hide
2960      */
2961     public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
2962 
2963     /**
2964      * Used when starting a process for a BroadcastReceiver.
2965      *
2966      * @hide
2967      */
2968     public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
2969 
2970     /**
2971      * Used with Context.getClassLoader() across Android packages.
2972      *
2973      * @hide
2974      */
2975     public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
2976 
2977     /**
2978      * Used when starting a package within a process for Instrumentation.
2979      *
2980      * @hide
2981      */
2982     public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
2983 
2984     /**
2985      * Total number of usage reasons.
2986      *
2987      * @hide
2988      */
2989     public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
2990 
2991     /**
2992      * Constant for specifying the highest installed package version code.
2993      */
2994     public static final int VERSION_CODE_HIGHEST = -1;
2995 
2996     /** {@hide} */
getUserId()2997     public int getUserId() {
2998         return UserHandle.myUserId();
2999     }
3000 
3001     /**
3002      * Retrieve overall information about an application package that is
3003      * installed on the system.
3004      *
3005      * @param packageName The full name (i.e. com.google.apps.contacts) of the
3006      *            desired package.
3007      * @param flags Additional option flags to modify the data returned.
3008      * @return A PackageInfo object containing information about the package. If
3009      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
3010      *         is not found in the list of installed applications, the package
3011      *         information is retrieved from the list of uninstalled
3012      *         applications (which includes installed applications as well as
3013      *         applications with data directory i.e. applications which had been
3014      *         deleted with {@code DONT_DELETE_DATA} flag set).
3015      * @throws NameNotFoundException if a package with the given name cannot be
3016      *             found on the system.
3017      */
getPackageInfo(String packageName, @PackageInfoFlags int flags)3018     public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags)
3019             throws NameNotFoundException;
3020 
3021     /**
3022      * Retrieve overall information about an application package that is
3023      * installed on the system. This method can be used for retrieving
3024      * information about packages for which multiple versions can be installed
3025      * at the time. Currently only packages hosting static shared libraries can
3026      * have multiple installed versions. The method can also be used to get info
3027      * for a package that has a single version installed by passing
3028      * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage}
3029      * constructor.
3030      *
3031      * @param versionedPackage The versioned package for which to query.
3032      * @param flags Additional option flags to modify the data returned.
3033      * @return A PackageInfo object containing information about the package. If
3034      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
3035      *         is not found in the list of installed applications, the package
3036      *         information is retrieved from the list of uninstalled
3037      *         applications (which includes installed applications as well as
3038      *         applications with data directory i.e. applications which had been
3039      *         deleted with {@code DONT_DELETE_DATA} flag set).
3040      * @throws NameNotFoundException if a package with the given name cannot be
3041      *             found on the system.
3042      */
getPackageInfo(VersionedPackage versionedPackage, @PackageInfoFlags int flags)3043     public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage,
3044             @PackageInfoFlags int flags) throws NameNotFoundException;
3045 
3046     /**
3047      * Retrieve overall information about an application package that is
3048      * installed on the system.
3049      *
3050      * @param packageName The full name (i.e. com.google.apps.contacts) of the
3051      *            desired package.
3052      * @param flags Additional option flags to modify the data returned.
3053      * @param userId The user id.
3054      * @return A PackageInfo object containing information about the package. If
3055      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
3056      *         is not found in the list of installed applications, the package
3057      *         information is retrieved from the list of uninstalled
3058      *         applications (which includes installed applications as well as
3059      *         applications with data directory i.e. applications which had been
3060      *         deleted with {@code DONT_DELETE_DATA} flag set).
3061      * @throws NameNotFoundException if a package with the given name cannot be
3062      *             found on the system.
3063      * @hide
3064      */
3065     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
getPackageInfoAsUser(String packageName, @PackageInfoFlags int flags, @UserIdInt int userId)3066     public abstract PackageInfo getPackageInfoAsUser(String packageName,
3067             @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
3068 
3069     /**
3070      * Map from the current package names in use on the device to whatever
3071      * the current canonical name of that package is.
3072      * @param names Array of current names to be mapped.
3073      * @return Returns an array of the same size as the original, containing
3074      * the canonical name for each package.
3075      */
currentToCanonicalPackageNames(String[] names)3076     public abstract String[] currentToCanonicalPackageNames(String[] names);
3077 
3078     /**
3079      * Map from a packages canonical name to the current name in use on the device.
3080      * @param names Array of new names to be mapped.
3081      * @return Returns an array of the same size as the original, containing
3082      * the current name for each package.
3083      */
canonicalToCurrentPackageNames(String[] names)3084     public abstract String[] canonicalToCurrentPackageNames(String[] names);
3085 
3086     /**
3087      * Returns a "good" intent to launch a front-door activity in a package.
3088      * This is used, for example, to implement an "open" button when browsing
3089      * through packages.  The current implementation looks first for a main
3090      * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
3091      * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
3092      * <code>null</code> if neither are found.
3093      *
3094      * @param packageName The name of the package to inspect.
3095      *
3096      * @return A fully-qualified {@link Intent} that can be used to launch the
3097      * main activity in the package. Returns <code>null</code> if the package
3098      * does not contain such an activity, or if <em>packageName</em> is not
3099      * recognized.
3100      */
getLaunchIntentForPackage(@onNull String packageName)3101     public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName);
3102 
3103     /**
3104      * Return a "good" intent to launch a front-door Leanback activity in a
3105      * package, for use for example to implement an "open" button when browsing
3106      * through packages. The current implementation will look for a main
3107      * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
3108      * return null if no main leanback activities are found.
3109      *
3110      * @param packageName The name of the package to inspect.
3111      * @return Returns either a fully-qualified Intent that can be used to launch
3112      *         the main Leanback activity in the package, or null if the package
3113      *         does not contain such an activity.
3114      */
getLeanbackLaunchIntentForPackage(@onNull String packageName)3115     public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName);
3116 
3117     /**
3118      * Return a "good" intent to launch a front-door Car activity in a
3119      * package, for use for example to implement an "open" button when browsing
3120      * through packages. The current implementation will look for a main
3121      * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or
3122      * return null if no main car activities are found.
3123      *
3124      * @param packageName The name of the package to inspect.
3125      * @return Returns either a fully-qualified Intent that can be used to launch
3126      *         the main Car activity in the package, or null if the package
3127      *         does not contain such an activity.
3128      * @hide
3129      */
getCarLaunchIntentForPackage(@onNull String packageName)3130     public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName);
3131 
3132     /**
3133      * Return an array of all of the POSIX secondary group IDs that have been
3134      * assigned to the given package.
3135      * <p>
3136      * Note that the same package may have different GIDs under different
3137      * {@link UserHandle} on the same device.
3138      *
3139      * @param packageName The full name (i.e. com.google.apps.contacts) of the
3140      *            desired package.
3141      * @return Returns an int array of the assigned GIDs, or null if there are
3142      *         none.
3143      * @throws NameNotFoundException if a package with the given name cannot be
3144      *             found on the system.
3145      */
getPackageGids(@onNull String packageName)3146     public abstract int[] getPackageGids(@NonNull String packageName)
3147             throws NameNotFoundException;
3148 
3149     /**
3150      * Return an array of all of the POSIX secondary group IDs that have been
3151      * assigned to the given package.
3152      * <p>
3153      * Note that the same package may have different GIDs under different
3154      * {@link UserHandle} on the same device.
3155      *
3156      * @param packageName The full name (i.e. com.google.apps.contacts) of the
3157      *            desired package.
3158      * @return Returns an int array of the assigned gids, or null if there are
3159      *         none.
3160      * @throws NameNotFoundException if a package with the given name cannot be
3161      *             found on the system.
3162      */
getPackageGids(String packageName, @PackageInfoFlags int flags)3163     public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
3164             throws NameNotFoundException;
3165 
3166     /**
3167      * Return the UID associated with the given package name.
3168      * <p>
3169      * Note that the same package will have different UIDs under different
3170      * {@link UserHandle} on the same device.
3171      *
3172      * @param packageName The full name (i.e. com.google.apps.contacts) of the
3173      *            desired package.
3174      * @return Returns an integer UID who owns the given package name.
3175      * @throws NameNotFoundException if a package with the given name can not be
3176      *             found on the system.
3177      */
getPackageUid(String packageName, @PackageInfoFlags int flags)3178     public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
3179             throws NameNotFoundException;
3180 
3181     /**
3182      * Return the UID associated with the given package name.
3183      * <p>
3184      * Note that the same package will have different UIDs under different
3185      * {@link UserHandle} on the same device.
3186      *
3187      * @param packageName The full name (i.e. com.google.apps.contacts) of the
3188      *            desired package.
3189      * @param userId The user handle identifier to look up the package under.
3190      * @return Returns an integer UID who owns the given package name.
3191      * @throws NameNotFoundException if a package with the given name can not be
3192      *             found on the system.
3193      * @hide
3194      */
getPackageUidAsUser(String packageName, @UserIdInt int userId)3195     public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
3196             throws NameNotFoundException;
3197 
3198     /**
3199      * Return the UID associated with the given package name.
3200      * <p>
3201      * Note that the same package will have different UIDs under different
3202      * {@link UserHandle} on the same device.
3203      *
3204      * @param packageName The full name (i.e. com.google.apps.contacts) of the
3205      *            desired package.
3206      * @param userId The user handle identifier to look up the package under.
3207      * @return Returns an integer UID who owns the given package name.
3208      * @throws NameNotFoundException if a package with the given name can not be
3209      *             found on the system.
3210      * @hide
3211      */
getPackageUidAsUser(String packageName, @PackageInfoFlags int flags, @UserIdInt int userId)3212     public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
3213             @UserIdInt int userId) throws NameNotFoundException;
3214 
3215     /**
3216      * Retrieve all of the information we know about a particular permission.
3217      *
3218      * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
3219      *            of the permission you are interested in.
3220      * @param flags Additional option flags to modify the data returned.
3221      * @return Returns a {@link PermissionInfo} containing information about the
3222      *         permission.
3223      * @throws NameNotFoundException if a package with the given name cannot be
3224      *             found on the system.
3225      */
getPermissionInfo(String name, @PermissionInfoFlags int flags)3226     public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
3227             throws NameNotFoundException;
3228 
3229     /**
3230      * Query for all of the permissions associated with a particular group.
3231      *
3232      * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
3233      *            of the permission group you are interested in. Use null to
3234      *            find all of the permissions not associated with a group.
3235      * @param flags Additional option flags to modify the data returned.
3236      * @return Returns a list of {@link PermissionInfo} containing information
3237      *         about all of the permissions in the given group.
3238      * @throws NameNotFoundException if a package with the given name cannot be
3239      *             found on the system.
3240      */
queryPermissionsByGroup(String group, @PermissionInfoFlags int flags)3241     public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
3242             @PermissionInfoFlags int flags) throws NameNotFoundException;
3243 
3244     /**
3245      * Returns true if Permission Review Mode is enabled, false otherwise.
3246      *
3247      * @hide
3248      */
3249     @TestApi
isPermissionReviewModeEnabled()3250     public abstract boolean isPermissionReviewModeEnabled();
3251 
3252     /**
3253      * Retrieve all of the information we know about a particular group of
3254      * permissions.
3255      *
3256      * @param name The fully qualified name (i.e.
3257      *            com.google.permission_group.APPS) of the permission you are
3258      *            interested in.
3259      * @param flags Additional option flags to modify the data returned.
3260      * @return Returns a {@link PermissionGroupInfo} containing information
3261      *         about the permission.
3262      * @throws NameNotFoundException if a package with the given name cannot be
3263      *             found on the system.
3264      */
getPermissionGroupInfo(String name, @PermissionGroupInfoFlags int flags)3265     public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
3266             @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
3267 
3268     /**
3269      * Retrieve all of the known permission groups in the system.
3270      *
3271      * @param flags Additional option flags to modify the data returned.
3272      * @return Returns a list of {@link PermissionGroupInfo} containing
3273      *         information about all of the known permission groups.
3274      */
getAllPermissionGroups( @ermissionGroupInfoFlags int flags)3275     public abstract List<PermissionGroupInfo> getAllPermissionGroups(
3276             @PermissionGroupInfoFlags int flags);
3277 
3278     /**
3279      * Retrieve all of the information we know about a particular
3280      * package/application.
3281      *
3282      * @param packageName The full name (i.e. com.google.apps.contacts) of an
3283      *            application.
3284      * @param flags Additional option flags to modify the data returned.
3285      * @return An {@link ApplicationInfo} containing information about the
3286      *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if
3287      *         the package is not found in the list of installed applications,
3288      *         the application information is retrieved from the list of
3289      *         uninstalled applications (which includes installed applications
3290      *         as well as applications with data directory i.e. applications
3291      *         which had been deleted with {@code DONT_DELETE_DATA} flag set).
3292      * @throws NameNotFoundException if a package with the given name cannot be
3293      *             found on the system.
3294      */
getApplicationInfo(String packageName, @ApplicationInfoFlags int flags)3295     public abstract ApplicationInfo getApplicationInfo(String packageName,
3296             @ApplicationInfoFlags int flags) throws NameNotFoundException;
3297 
3298     /** {@hide} */
getApplicationInfoAsUser(String packageName, @ApplicationInfoFlags int flags, @UserIdInt int userId)3299     public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
3300             @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
3301 
3302     /**
3303      * Retrieve all of the information we know about a particular activity
3304      * class.
3305      *
3306      * @param component The full component name (i.e.
3307      *            com.google.apps.contacts/com.google.apps.contacts.
3308      *            ContactsList) of an Activity class.
3309      * @param flags Additional option flags to modify the data returned.
3310      * @return An {@link ActivityInfo} containing information about the
3311      *         activity.
3312      * @throws NameNotFoundException if a package with the given name cannot be
3313      *             found on the system.
3314      */
getActivityInfo(ComponentName component, @ComponentInfoFlags int flags)3315     public abstract ActivityInfo getActivityInfo(ComponentName component,
3316             @ComponentInfoFlags int flags) throws NameNotFoundException;
3317 
3318     /**
3319      * Retrieve all of the information we know about a particular receiver
3320      * class.
3321      *
3322      * @param component The full component name (i.e.
3323      *            com.google.apps.calendar/com.google.apps.calendar.
3324      *            CalendarAlarm) of a Receiver class.
3325      * @param flags Additional option flags to modify the data returned.
3326      * @return An {@link ActivityInfo} containing information about the
3327      *         receiver.
3328      * @throws NameNotFoundException if a package with the given name cannot be
3329      *             found on the system.
3330      */
getReceiverInfo(ComponentName component, @ComponentInfoFlags int flags)3331     public abstract ActivityInfo getReceiverInfo(ComponentName component,
3332             @ComponentInfoFlags int flags) throws NameNotFoundException;
3333 
3334     /**
3335      * Retrieve all of the information we know about a particular service class.
3336      *
3337      * @param component The full component name (i.e.
3338      *            com.google.apps.media/com.google.apps.media.
3339      *            BackgroundPlayback) of a Service class.
3340      * @param flags Additional option flags to modify the data returned.
3341      * @return A {@link ServiceInfo} object containing information about the
3342      *         service.
3343      * @throws NameNotFoundException if a package with the given name cannot be
3344      *             found on the system.
3345      */
getServiceInfo(ComponentName component, @ComponentInfoFlags int flags)3346     public abstract ServiceInfo getServiceInfo(ComponentName component,
3347             @ComponentInfoFlags int flags) throws NameNotFoundException;
3348 
3349     /**
3350      * Retrieve all of the information we know about a particular content
3351      * provider class.
3352      *
3353      * @param component The full component name (i.e.
3354      *            com.google.providers.media/com.google.providers.media.
3355      *            MediaProvider) of a ContentProvider class.
3356      * @param flags Additional option flags to modify the data returned.
3357      * @return A {@link ProviderInfo} object containing information about the
3358      *         provider.
3359      * @throws NameNotFoundException if a package with the given name cannot be
3360      *             found on the system.
3361      */
getProviderInfo(ComponentName component, @ComponentInfoFlags int flags)3362     public abstract ProviderInfo getProviderInfo(ComponentName component,
3363             @ComponentInfoFlags int flags) throws NameNotFoundException;
3364 
3365     /**
3366      * Return a List of all packages that are installed for the current user.
3367      *
3368      * @param flags Additional option flags to modify the data returned.
3369      * @return A List of PackageInfo objects, one for each installed package,
3370      *         containing information about the package. In the unlikely case
3371      *         there are no installed packages, an empty list is returned. If
3372      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3373      *         information is retrieved from the list of uninstalled
3374      *         applications (which includes installed applications as well as
3375      *         applications with data directory i.e. applications which had been
3376      *         deleted with {@code DONT_DELETE_DATA} flag set).
3377      */
getInstalledPackages(@ackageInfoFlags int flags)3378     public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
3379 
3380     /**
3381      * Return a List of all installed packages that are currently holding any of
3382      * the given permissions.
3383      *
3384      * @param flags Additional option flags to modify the data returned.
3385      * @return A List of PackageInfo objects, one for each installed package
3386      *         that holds any of the permissions that were provided, containing
3387      *         information about the package. If no installed packages hold any
3388      *         of the permissions, an empty list is returned. If flag
3389      *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3390      *         information is retrieved from the list of uninstalled
3391      *         applications (which includes installed applications as well as
3392      *         applications with data directory i.e. applications which had been
3393      *         deleted with {@code DONT_DELETE_DATA} flag set).
3394      */
getPackagesHoldingPermissions( String[] permissions, @PackageInfoFlags int flags)3395     public abstract List<PackageInfo> getPackagesHoldingPermissions(
3396             String[] permissions, @PackageInfoFlags int flags);
3397 
3398     /**
3399      * Return a List of all packages that are installed on the device, for a
3400      * specific user.
3401      *
3402      * @param flags Additional option flags to modify the data returned.
3403      * @param userId The user for whom the installed packages are to be listed
3404      * @return A List of PackageInfo objects, one for each installed package,
3405      *         containing information about the package. In the unlikely case
3406      *         there are no installed packages, an empty list is returned. If
3407      *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3408      *         information is retrieved from the list of uninstalled
3409      *         applications (which includes installed applications as well as
3410      *         applications with data directory i.e. applications which had been
3411      *         deleted with {@code DONT_DELETE_DATA} flag set).
3412      * @hide
3413      */
3414     @TestApi
3415     @SystemApi
3416     @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
getInstalledPackagesAsUser(@ackageInfoFlags int flags, @UserIdInt int userId)3417     public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
3418             @UserIdInt int userId);
3419 
3420     /**
3421      * Check whether a particular package has been granted a particular
3422      * permission.
3423      *
3424      * @param permName The name of the permission you are checking for.
3425      * @param pkgName The name of the package you are checking against.
3426      *
3427      * @return If the package has the permission, PERMISSION_GRANTED is
3428      * returned.  If it does not have the permission, PERMISSION_DENIED
3429      * is returned.
3430      *
3431      * @see #PERMISSION_GRANTED
3432      * @see #PERMISSION_DENIED
3433      */
3434     @CheckResult
checkPermission(String permName, String pkgName)3435     public abstract @PermissionResult int checkPermission(String permName, String pkgName);
3436 
3437     /**
3438      * Checks whether a particular permissions has been revoked for a
3439      * package by policy. Typically the device owner or the profile owner
3440      * may apply such a policy. The user cannot grant policy revoked
3441      * permissions, hence the only way for an app to get such a permission
3442      * is by a policy change.
3443      *
3444      * @param permName The name of the permission you are checking for.
3445      * @param pkgName The name of the package you are checking against.
3446      *
3447      * @return Whether the permission is restricted by policy.
3448      */
3449     @CheckResult
isPermissionRevokedByPolicy(@onNull String permName, @NonNull String pkgName)3450     public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
3451             @NonNull String pkgName);
3452 
3453     /**
3454      * Gets the package name of the component controlling runtime permissions.
3455      *
3456      * @return The package name.
3457      *
3458      * @hide
3459      */
3460     @TestApi
getPermissionControllerPackageName()3461     public abstract String getPermissionControllerPackageName();
3462 
3463     /**
3464      * Add a new dynamic permission to the system.  For this to work, your
3465      * package must have defined a permission tree through the
3466      * {@link android.R.styleable#AndroidManifestPermissionTree
3467      * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
3468      * permissions to trees that were defined by either its own package or
3469      * another with the same user id; a permission is in a tree if it
3470      * matches the name of the permission tree + ".": for example,
3471      * "com.foo.bar" is a member of the permission tree "com.foo".
3472      *
3473      * <p>It is good to make your permission tree name descriptive, because you
3474      * are taking possession of that entire set of permission names.  Thus, it
3475      * must be under a domain you control, with a suffix that will not match
3476      * any normal permissions that may be declared in any applications that
3477      * are part of that domain.
3478      *
3479      * <p>New permissions must be added before
3480      * any .apks are installed that use those permissions.  Permissions you
3481      * add through this method are remembered across reboots of the device.
3482      * If the given permission already exists, the info you supply here
3483      * will be used to update it.
3484      *
3485      * @param info Description of the permission to be added.
3486      *
3487      * @return Returns true if a new permission was created, false if an
3488      * existing one was updated.
3489      *
3490      * @throws SecurityException if you are not allowed to add the
3491      * given permission name.
3492      *
3493      * @see #removePermission(String)
3494      */
addPermission(PermissionInfo info)3495     public abstract boolean addPermission(PermissionInfo info);
3496 
3497     /**
3498      * Like {@link #addPermission(PermissionInfo)} but asynchronously
3499      * persists the package manager state after returning from the call,
3500      * allowing it to return quicker and batch a series of adds at the
3501      * expense of no guarantee the added permission will be retained if
3502      * the device is rebooted before it is written.
3503      */
addPermissionAsync(PermissionInfo info)3504     public abstract boolean addPermissionAsync(PermissionInfo info);
3505 
3506     /**
3507      * Removes a permission that was previously added with
3508      * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
3509      * -- you are only allowed to remove permissions that you are allowed
3510      * to add.
3511      *
3512      * @param name The name of the permission to remove.
3513      *
3514      * @throws SecurityException if you are not allowed to remove the
3515      * given permission name.
3516      *
3517      * @see #addPermission(PermissionInfo)
3518      */
removePermission(String name)3519     public abstract void removePermission(String name);
3520 
3521     /**
3522      * Permission flags set when granting or revoking a permission.
3523      *
3524      * @hide
3525      */
3526     @SystemApi
3527     @IntDef(prefix = { "FLAG_PERMISSION_" }, value = {
3528             FLAG_PERMISSION_USER_SET,
3529             FLAG_PERMISSION_USER_FIXED,
3530             FLAG_PERMISSION_POLICY_FIXED,
3531             FLAG_PERMISSION_REVOKE_ON_UPGRADE,
3532             FLAG_PERMISSION_SYSTEM_FIXED,
3533             FLAG_PERMISSION_GRANTED_BY_DEFAULT
3534     })
3535     @Retention(RetentionPolicy.SOURCE)
3536     public @interface PermissionFlags {}
3537 
3538     /**
3539      * Grant a runtime permission to an application which the application does not
3540      * already have. The permission must have been requested by the application.
3541      * If the application is not allowed to hold the permission, a {@link
3542      * java.lang.SecurityException} is thrown. If the package or permission is
3543      * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
3544      * <p>
3545      * <strong>Note: </strong>Using this API requires holding
3546      * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is
3547      * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3548      * </p>
3549      *
3550      * @param packageName The package to which to grant the permission.
3551      * @param permissionName The permission name to grant.
3552      * @param user The user for which to grant the permission.
3553      *
3554      * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
3555      *
3556      * @hide
3557      */
3558     @SystemApi
3559     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
grantRuntimePermission(@onNull String packageName, @NonNull String permissionName, @NonNull UserHandle user)3560     public abstract void grantRuntimePermission(@NonNull String packageName,
3561             @NonNull String permissionName, @NonNull UserHandle user);
3562 
3563     /**
3564      * Revoke a runtime permission that was previously granted by {@link
3565      * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
3566      * permission must have been requested by and granted to the application.
3567      * If the application is not allowed to hold the permission, a {@link
3568      * java.lang.SecurityException} is thrown. If the package or permission is
3569      * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
3570      * <p>
3571      * <strong>Note: </strong>Using this API requires holding
3572      * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
3573      * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3574      * </p>
3575      *
3576      * @param packageName The package from which to revoke the permission.
3577      * @param permissionName The permission name to revoke.
3578      * @param user The user for which to revoke the permission.
3579      *
3580      * @see #grantRuntimePermission(String, String, android.os.UserHandle)
3581      *
3582      * @hide
3583      */
3584     @SystemApi
3585     @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
revokeRuntimePermission(@onNull String packageName, @NonNull String permissionName, @NonNull UserHandle user)3586     public abstract void revokeRuntimePermission(@NonNull String packageName,
3587             @NonNull String permissionName, @NonNull UserHandle user);
3588 
3589     /**
3590      * Gets the state flags associated with a permission.
3591      *
3592      * @param permissionName The permission for which to get the flags.
3593      * @param packageName The package name for which to get the flags.
3594      * @param user The user for which to get permission flags.
3595      * @return The permission flags.
3596      *
3597      * @hide
3598      */
3599     @SystemApi
3600     @RequiresPermission(anyOf = {
3601             android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
3602             android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
3603     })
getPermissionFlags(String permissionName, String packageName, @NonNull UserHandle user)3604     public abstract @PermissionFlags int getPermissionFlags(String permissionName,
3605             String packageName, @NonNull UserHandle user);
3606 
3607     /**
3608      * Updates the flags associated with a permission by replacing the flags in
3609      * the specified mask with the provided flag values.
3610      *
3611      * @param permissionName The permission for which to update the flags.
3612      * @param packageName The package name for which to update the flags.
3613      * @param flagMask The flags which to replace.
3614      * @param flagValues The flags with which to replace.
3615      * @param user The user for which to update the permission flags.
3616      *
3617      * @hide
3618      */
3619     @SystemApi
3620     @RequiresPermission(anyOf = {
3621             android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
3622             android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
3623     })
updatePermissionFlags(String permissionName, String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues, @NonNull UserHandle user)3624     public abstract void updatePermissionFlags(String permissionName,
3625             String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues,
3626             @NonNull UserHandle user);
3627 
3628     /**
3629      * Gets whether you should show UI with rationale for requesting a permission.
3630      * You should do this only if you do not have the permission and the context in
3631      * which the permission is requested does not clearly communicate to the user
3632      * what would be the benefit from grating this permission.
3633      *
3634      * @param permission A permission your app wants to request.
3635      * @return Whether you can show permission rationale UI.
3636      *
3637      * @hide
3638      */
shouldShowRequestPermissionRationale(String permission)3639     public abstract boolean shouldShowRequestPermissionRationale(String permission);
3640 
3641     /**
3642      * Returns an {@link android.content.Intent} suitable for passing to
3643      * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
3644      * which prompts the user to grant permissions to this application.
3645      *
3646      * @throws NullPointerException if {@code permissions} is {@code null} or empty.
3647      *
3648      * @hide
3649      */
buildRequestPermissionsIntent(@onNull String[] permissions)3650     public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
3651         if (ArrayUtils.isEmpty(permissions)) {
3652            throw new IllegalArgumentException("permission cannot be null or empty");
3653         }
3654         Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
3655         intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
3656         intent.setPackage(getPermissionControllerPackageName());
3657         return intent;
3658     }
3659 
3660     /**
3661      * Compare the signatures of two packages to determine if the same
3662      * signature appears in both of them.  If they do contain the same
3663      * signature, then they are allowed special privileges when working
3664      * with each other: they can share the same user-id, run instrumentation
3665      * against each other, etc.
3666      *
3667      * @param pkg1 First package name whose signature will be compared.
3668      * @param pkg2 Second package name whose signature will be compared.
3669      *
3670      * @return Returns an integer indicating whether all signatures on the
3671      * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3672      * all signatures match or < 0 if there is not a match ({@link
3673      * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3674      *
3675      * @see #checkSignatures(int, int)
3676      */
3677     @CheckResult
checkSignatures(String pkg1, String pkg2)3678     public abstract @SignatureResult int checkSignatures(String pkg1, String pkg2);
3679 
3680     /**
3681      * Like {@link #checkSignatures(String, String)}, but takes UIDs of
3682      * the two packages to be checked.  This can be useful, for example,
3683      * when doing the check in an IPC, where the UID is the only identity
3684      * available.  It is functionally identical to determining the package
3685      * associated with the UIDs and checking their signatures.
3686      *
3687      * @param uid1 First UID whose signature will be compared.
3688      * @param uid2 Second UID whose signature will be compared.
3689      *
3690      * @return Returns an integer indicating whether all signatures on the
3691      * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3692      * all signatures match or < 0 if there is not a match ({@link
3693      * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3694      *
3695      * @see #checkSignatures(String, String)
3696      */
3697     @CheckResult
checkSignatures(int uid1, int uid2)3698     public abstract @SignatureResult int checkSignatures(int uid1, int uid2);
3699 
3700     /**
3701      * Retrieve the names of all packages that are associated with a particular
3702      * user id.  In most cases, this will be a single package name, the package
3703      * that has been assigned that user id.  Where there are multiple packages
3704      * sharing the same user id through the "sharedUserId" mechanism, all
3705      * packages with that id will be returned.
3706      *
3707      * @param uid The user id for which you would like to retrieve the
3708      * associated packages.
3709      *
3710      * @return Returns an array of one or more packages assigned to the user
3711      * id, or null if there are no known packages with the given id.
3712      */
getPackagesForUid(int uid)3713     public abstract @Nullable String[] getPackagesForUid(int uid);
3714 
3715     /**
3716      * Retrieve the official name associated with a uid. This name is
3717      * guaranteed to never change, though it is possible for the underlying
3718      * uid to be changed.  That is, if you are storing information about
3719      * uids in persistent storage, you should use the string returned
3720      * by this function instead of the raw uid.
3721      *
3722      * @param uid The uid for which you would like to retrieve a name.
3723      * @return Returns a unique name for the given uid, or null if the
3724      * uid is not currently assigned.
3725      */
getNameForUid(int uid)3726     public abstract @Nullable String getNameForUid(int uid);
3727 
3728     /**
3729      * Retrieves the official names associated with each given uid.
3730      * @see #getNameForUid(int)
3731      *
3732      * @hide
3733      */
3734     @TestApi
getNamesForUids(int[] uids)3735     public abstract @Nullable String[] getNamesForUids(int[] uids);
3736 
3737     /**
3738      * Return the user id associated with a shared user name. Multiple
3739      * applications can specify a shared user name in their manifest and thus
3740      * end up using a common uid. This might be used for new applications
3741      * that use an existing shared user name and need to know the uid of the
3742      * shared user.
3743      *
3744      * @param sharedUserName The shared user name whose uid is to be retrieved.
3745      * @return Returns the UID associated with the shared user.
3746      * @throws NameNotFoundException if a package with the given name cannot be
3747      *             found on the system.
3748      * @hide
3749      */
getUidForSharedUser(String sharedUserName)3750     public abstract int getUidForSharedUser(String sharedUserName)
3751             throws NameNotFoundException;
3752 
3753     /**
3754      * Return a List of all application packages that are installed for the
3755      * current user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
3756      * applications including those deleted with {@code DONT_DELETE_DATA}
3757      * (partially installed apps with data directory) will be returned.
3758      *
3759      * @param flags Additional option flags to modify the data returned.
3760      * @return A List of ApplicationInfo objects, one for each installed
3761      *         application. In the unlikely case there are no installed
3762      *         packages, an empty list is returned. If flag
3763      *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
3764      *         information is retrieved from the list of uninstalled
3765      *         applications (which includes installed applications as well as
3766      *         applications with data directory i.e. applications which had been
3767      *         deleted with {@code DONT_DELETE_DATA} flag set).
3768      */
getInstalledApplications(@pplicationInfoFlags int flags)3769     public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
3770 
3771     /**
3772      * Return a List of all application packages that are installed on the
3773      * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been
3774      * set, a list of all applications including those deleted with
3775      * {@code DONT_DELETE_DATA} (partially installed apps with data directory)
3776      * will be returned.
3777      *
3778      * @param flags Additional option flags to modify the data returned.
3779      * @param userId The user for whom the installed applications are to be
3780      *            listed
3781      * @return A List of ApplicationInfo objects, one for each installed
3782      *         application. In the unlikely case there are no installed
3783      *         packages, an empty list is returned. If flag
3784      *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
3785      *         information is retrieved from the list of uninstalled
3786      *         applications (which includes installed applications as well as
3787      *         applications with data directory i.e. applications which had been
3788      *         deleted with {@code DONT_DELETE_DATA} flag set).
3789      * @hide
3790      */
3791     @TestApi
getInstalledApplicationsAsUser( @pplicationInfoFlags int flags, @UserIdInt int userId)3792     public abstract List<ApplicationInfo> getInstalledApplicationsAsUser(
3793             @ApplicationInfoFlags int flags, @UserIdInt int userId);
3794 
3795     /**
3796      * Gets the instant applications the user recently used.
3797      *
3798      * @return The instant app list.
3799      *
3800      * @hide
3801      */
3802     @SystemApi
3803     @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
getInstantApps()3804     public abstract @NonNull List<InstantAppInfo> getInstantApps();
3805 
3806     /**
3807      * Gets the icon for an instant application.
3808      *
3809      * @param packageName The app package name.
3810      *
3811      * @hide
3812      */
3813     @SystemApi
3814     @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
getInstantAppIcon(String packageName)3815     public abstract @Nullable Drawable getInstantAppIcon(String packageName);
3816 
3817     /**
3818      * Gets whether this application is an instant app.
3819      *
3820      * @return Whether caller is an instant app.
3821      *
3822      * @see #isInstantApp(String)
3823      * @see #updateInstantAppCookie(byte[])
3824      * @see #getInstantAppCookie()
3825      * @see #getInstantAppCookieMaxBytes()
3826      */
isInstantApp()3827     public abstract boolean isInstantApp();
3828 
3829     /**
3830      * Gets whether the given package is an instant app.
3831      *
3832      * @param packageName The package to check
3833      * @return Whether the given package is an instant app.
3834      *
3835      * @see #isInstantApp()
3836      * @see #updateInstantAppCookie(byte[])
3837      * @see #getInstantAppCookie()
3838      * @see #getInstantAppCookieMaxBytes()
3839      * @see #clearInstantAppCookie()
3840      */
isInstantApp(String packageName)3841     public abstract boolean isInstantApp(String packageName);
3842 
3843     /**
3844      * Gets the maximum size in bytes of the cookie data an instant app
3845      * can store on the device.
3846      *
3847      * @return The max cookie size in bytes.
3848      *
3849      * @see #isInstantApp()
3850      * @see #isInstantApp(String)
3851      * @see #updateInstantAppCookie(byte[])
3852      * @see #getInstantAppCookie()
3853      * @see #clearInstantAppCookie()
3854      */
getInstantAppCookieMaxBytes()3855     public abstract int getInstantAppCookieMaxBytes();
3856 
3857     /**
3858      * deprecated
3859      * @hide
3860      */
getInstantAppCookieMaxSize()3861     public abstract int getInstantAppCookieMaxSize();
3862 
3863     /**
3864      * Gets the instant application cookie for this app. Non
3865      * instant apps and apps that were instant but were upgraded
3866      * to normal apps can still access this API. For instant apps
3867      * this cookie is cached for some time after uninstall while for
3868      * normal apps the cookie is deleted after the app is uninstalled.
3869      * The cookie is always present while the app is installed.
3870      *
3871      * @return The cookie.
3872      *
3873      * @see #isInstantApp()
3874      * @see #isInstantApp(String)
3875      * @see #updateInstantAppCookie(byte[])
3876      * @see #getInstantAppCookieMaxBytes()
3877      * @see #clearInstantAppCookie()
3878      */
getInstantAppCookie()3879     public abstract @NonNull byte[] getInstantAppCookie();
3880 
3881     /**
3882      * Clears the instant application cookie for the calling app.
3883      *
3884      * @see #isInstantApp()
3885      * @see #isInstantApp(String)
3886      * @see #getInstantAppCookieMaxBytes()
3887      * @see #getInstantAppCookie()
3888      * @see #clearInstantAppCookie()
3889      */
clearInstantAppCookie()3890     public abstract void clearInstantAppCookie();
3891 
3892     /**
3893      * Updates the instant application cookie for the calling app. Non
3894      * instant apps and apps that were instant but were upgraded
3895      * to normal apps can still access this API. For instant apps
3896      * this cookie is cached for some time after uninstall while for
3897      * normal apps the cookie is deleted after the app is uninstalled.
3898      * The cookie is always present while the app is installed. The
3899      * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}.
3900      * Passing <code>null</code> or an empty array clears the cookie.
3901      * </p>
3902      *
3903      * @param cookie The cookie data.
3904      *
3905      * @see #isInstantApp()
3906      * @see #isInstantApp(String)
3907      * @see #getInstantAppCookieMaxBytes()
3908      * @see #getInstantAppCookie()
3909      * @see #clearInstantAppCookie()
3910      *
3911      * @throws IllegalArgumentException if the array exceeds max cookie size.
3912      */
updateInstantAppCookie(@ullable byte[] cookie)3913     public abstract void updateInstantAppCookie(@Nullable byte[] cookie);
3914 
3915     /**
3916      * @removed
3917      */
setInstantAppCookie(@ullable byte[] cookie)3918     public abstract boolean setInstantAppCookie(@Nullable byte[] cookie);
3919 
3920     /**
3921      * Get a list of shared libraries that are available on the
3922      * system.
3923      *
3924      * @return An array of shared library names that are
3925      * available on the system, or null if none are installed.
3926      *
3927      */
getSystemSharedLibraryNames()3928     public abstract String[] getSystemSharedLibraryNames();
3929 
3930     /**
3931      * Get a list of shared libraries on the device.
3932      *
3933      * @param flags To filter the libraries to return.
3934      * @return The shared library list.
3935      *
3936      * @see #MATCH_UNINSTALLED_PACKAGES
3937      */
getSharedLibraries( @nstallFlags int flags)3938     public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(
3939             @InstallFlags int flags);
3940 
3941     /**
3942      * Get a list of shared libraries on the device.
3943      *
3944      * @param flags To filter the libraries to return.
3945      * @param userId The user to query for.
3946      * @return The shared library list.
3947      *
3948      * @see #MATCH_FACTORY_ONLY
3949      * @see #MATCH_KNOWN_PACKAGES
3950      * @see #MATCH_ANY_USER
3951      * @see #MATCH_UNINSTALLED_PACKAGES
3952      *
3953      * @hide
3954      */
getSharedLibrariesAsUser( @nstallFlags int flags, @UserIdInt int userId)3955     public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(
3956             @InstallFlags int flags, @UserIdInt int userId);
3957 
3958     /**
3959      * Get the name of the package hosting the services shared library.
3960      *
3961      * @return The library host package.
3962      *
3963      * @hide
3964      */
3965     @TestApi
getServicesSystemSharedLibraryPackageName()3966     public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
3967 
3968     /**
3969      * Get the name of the package hosting the shared components shared library.
3970      *
3971      * @return The library host package.
3972      *
3973      * @hide
3974      */
3975     @TestApi
getSharedSystemSharedLibraryPackageName()3976     public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
3977 
3978     /**
3979      * Returns the names of the packages that have been changed
3980      * [eg. added, removed or updated] since the given sequence
3981      * number.
3982      * <p>If no packages have been changed, returns <code>null</code>.
3983      * <p>The sequence number starts at <code>0</code> and is
3984      * reset every boot.
3985      * @param sequenceNumber The first sequence number for which to retrieve package changes.
3986      * @see Settings.Global#BOOT_COUNT
3987      */
getChangedPackages( @ntRangefrom=0) int sequenceNumber)3988     public abstract @Nullable ChangedPackages getChangedPackages(
3989             @IntRange(from=0) int sequenceNumber);
3990 
3991     /**
3992      * Get a list of features that are available on the
3993      * system.
3994      *
3995      * @return An array of FeatureInfo classes describing the features
3996      * that are available on the system, or null if there are none(!!).
3997      */
getSystemAvailableFeatures()3998     public abstract FeatureInfo[] getSystemAvailableFeatures();
3999 
4000     /**
4001      * Check whether the given feature name is one of the available features as
4002      * returned by {@link #getSystemAvailableFeatures()}. This tests for the
4003      * presence of <em>any</em> version of the given feature name; use
4004      * {@link #hasSystemFeature(String, int)} to check for a minimum version.
4005      *
4006      * @return Returns true if the devices supports the feature, else false.
4007      */
hasSystemFeature(String name)4008     public abstract boolean hasSystemFeature(String name);
4009 
4010     /**
4011      * Check whether the given feature name and version is one of the available
4012      * features as returned by {@link #getSystemAvailableFeatures()}. Since
4013      * features are defined to always be backwards compatible, this returns true
4014      * if the available feature version is greater than or equal to the
4015      * requested version.
4016      *
4017      * @return Returns true if the devices supports the feature, else false.
4018      */
hasSystemFeature(String name, int version)4019     public abstract boolean hasSystemFeature(String name, int version);
4020 
4021     /**
4022      * Determine the best action to perform for a given Intent. This is how
4023      * {@link Intent#resolveActivity} finds an activity if a class has not been
4024      * explicitly specified.
4025      * <p>
4026      * <em>Note:</em> if using an implicit Intent (without an explicit
4027      * ComponentName specified), be sure to consider whether to set the
4028      * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
4029      * activity in the same way that
4030      * {@link android.content.Context#startActivity(Intent)} and
4031      * {@link android.content.Intent#resolveActivity(PackageManager)
4032      * Intent.resolveActivity(PackageManager)} do.
4033      * </p>
4034      *
4035      * @param intent An intent containing all of the desired specification
4036      *            (action, data, type, category, and/or component).
4037      * @param flags Additional option flags to modify the data returned. The
4038      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4039      *            resolution to only those activities that support the
4040      *            {@link android.content.Intent#CATEGORY_DEFAULT}.
4041      * @return Returns a ResolveInfo object containing the final activity intent
4042      *         that was determined to be the best action. Returns null if no
4043      *         matching activity was found. If multiple matching activities are
4044      *         found and there is no default set, returns a ResolveInfo object
4045      *         containing something else, such as the activity resolver.
4046      */
resolveActivity(Intent intent, @ResolveInfoFlags int flags)4047     public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
4048 
4049     /**
4050      * Determine the best action to perform for a given Intent for a given user.
4051      * This is how {@link Intent#resolveActivity} finds an activity if a class
4052      * has not been explicitly specified.
4053      * <p>
4054      * <em>Note:</em> if using an implicit Intent (without an explicit
4055      * ComponentName specified), be sure to consider whether to set the
4056      * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
4057      * activity in the same way that
4058      * {@link android.content.Context#startActivity(Intent)} and
4059      * {@link android.content.Intent#resolveActivity(PackageManager)
4060      * Intent.resolveActivity(PackageManager)} do.
4061      * </p>
4062      *
4063      * @param intent An intent containing all of the desired specification
4064      *            (action, data, type, category, and/or component).
4065      * @param flags Additional option flags to modify the data returned. The
4066      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4067      *            resolution to only those activities that support the
4068      *            {@link android.content.Intent#CATEGORY_DEFAULT}.
4069      * @param userId The user id.
4070      * @return Returns a ResolveInfo object containing the final activity intent
4071      *         that was determined to be the best action. Returns null if no
4072      *         matching activity was found. If multiple matching activities are
4073      *         found and there is no default set, returns a ResolveInfo object
4074      *         containing something else, such as the activity resolver.
4075      * @hide
4076      */
resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)4077     public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
4078             @UserIdInt int userId);
4079 
4080     /**
4081      * Retrieve all activities that can be performed for the given intent.
4082      *
4083      * @param intent The desired intent as per resolveActivity().
4084      * @param flags Additional option flags to modify the data returned. The
4085      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4086      *            resolution to only those activities that support the
4087      *            {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
4088      *            {@link #MATCH_ALL} to prevent any filtering of the results.
4089      * @return Returns a List of ResolveInfo objects containing one entry for
4090      *         each matching activity, ordered from best to worst. In other
4091      *         words, the first item is what would be returned by
4092      *         {@link #resolveActivity}. If there are no matching activities, an
4093      *         empty list is returned.
4094      */
queryIntentActivities(Intent intent, @ResolveInfoFlags int flags)4095     public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
4096             @ResolveInfoFlags int flags);
4097 
4098     /**
4099      * Retrieve all activities that can be performed for the given intent, for a
4100      * specific user.
4101      *
4102      * @param intent The desired intent as per resolveActivity().
4103      * @param flags Additional option flags to modify the data returned. The
4104      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4105      *            resolution to only those activities that support the
4106      *            {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
4107      *            {@link #MATCH_ALL} to prevent any filtering of the results.
4108      * @return Returns a List of ResolveInfo objects containing one entry for
4109      *         each matching activity, ordered from best to worst. In other
4110      *         words, the first item is what would be returned by
4111      *         {@link #resolveActivity}. If there are no matching activities, an
4112      *         empty list is returned.
4113      * @hide
4114      */
queryIntentActivitiesAsUser(Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)4115     public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
4116             @ResolveInfoFlags int flags, @UserIdInt int userId);
4117 
4118     /**
4119      * Retrieve a set of activities that should be presented to the user as
4120      * similar options. This is like {@link #queryIntentActivities}, except it
4121      * also allows you to supply a list of more explicit Intents that you would
4122      * like to resolve to particular options, and takes care of returning the
4123      * final ResolveInfo list in a reasonable order, with no duplicates, based
4124      * on those inputs.
4125      *
4126      * @param caller The class name of the activity that is making the request.
4127      *            This activity will never appear in the output list. Can be
4128      *            null.
4129      * @param specifics An array of Intents that should be resolved to the first
4130      *            specific results. Can be null.
4131      * @param intent The desired intent as per resolveActivity().
4132      * @param flags Additional option flags to modify the data returned. The
4133      *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4134      *            resolution to only those activities that support the
4135      *            {@link android.content.Intent#CATEGORY_DEFAULT}.
4136      * @return Returns a List of ResolveInfo objects containing one entry for
4137      *         each matching activity. The list is ordered first by all of the
4138      *         intents resolved in <var>specifics</var> and then any additional
4139      *         activities that can handle <var>intent</var> but did not get
4140      *         included by one of the <var>specifics</var> intents. If there are
4141      *         no matching activities, an empty list is returned.
4142      */
queryIntentActivityOptions(@ullable ComponentName caller, @Nullable Intent[] specifics, Intent intent, @ResolveInfoFlags int flags)4143     public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
4144             @Nullable Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
4145 
4146     /**
4147      * Retrieve all receivers that can handle a broadcast of the given intent.
4148      *
4149      * @param intent The desired intent as per resolveActivity().
4150      * @param flags Additional option flags to modify the data returned.
4151      * @return Returns a List of ResolveInfo objects containing one entry for
4152      *         each matching receiver, ordered from best to worst. If there are
4153      *         no matching receivers, an empty list or null is returned.
4154      */
queryBroadcastReceivers(Intent intent, @ResolveInfoFlags int flags)4155     public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
4156             @ResolveInfoFlags int flags);
4157 
4158     /**
4159      * Retrieve all receivers that can handle a broadcast of the given intent,
4160      * for a specific user.
4161      *
4162      * @param intent The desired intent as per resolveActivity().
4163      * @param flags Additional option flags to modify the data returned.
4164      * @param userHandle UserHandle of the user being queried.
4165      * @return Returns a List of ResolveInfo objects containing one entry for
4166      *         each matching receiver, ordered from best to worst. If there are
4167      *         no matching receivers, an empty list or null is returned.
4168      * @hide
4169      */
4170     @SystemApi
4171     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
queryBroadcastReceiversAsUser(Intent intent, @ResolveInfoFlags int flags, UserHandle userHandle)4172     public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
4173             @ResolveInfoFlags int flags, UserHandle userHandle) {
4174         return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
4175     }
4176 
4177     /**
4178      * @hide
4179      */
queryBroadcastReceiversAsUser(Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)4180     public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
4181             @ResolveInfoFlags int flags, @UserIdInt int userId);
4182 
4183 
4184     /** {@hide} */
4185     @Deprecated
queryBroadcastReceivers(Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)4186     public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
4187             @ResolveInfoFlags int flags, @UserIdInt int userId) {
4188         final String msg = "Shame on you for calling the hidden API "
4189                 + "queryBroadcastReceivers(). Shame!";
4190         if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) {
4191             throw new UnsupportedOperationException(msg);
4192         } else {
4193             Log.d(TAG, msg);
4194             return queryBroadcastReceiversAsUser(intent, flags, userId);
4195         }
4196     }
4197 
4198     /**
4199      * Determine the best service to handle for a given Intent.
4200      *
4201      * @param intent An intent containing all of the desired specification
4202      *            (action, data, type, category, and/or component).
4203      * @param flags Additional option flags to modify the data returned.
4204      * @return Returns a ResolveInfo object containing the final service intent
4205      *         that was determined to be the best action. Returns null if no
4206      *         matching service was found.
4207      */
resolveService(Intent intent, @ResolveInfoFlags int flags)4208     public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
4209 
4210     /**
4211      * @hide
4212      */
resolveServiceAsUser(Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)4213     public abstract ResolveInfo resolveServiceAsUser(Intent intent, @ResolveInfoFlags int flags,
4214             @UserIdInt int userId);
4215 
4216     /**
4217      * Retrieve all services that can match the given intent.
4218      *
4219      * @param intent The desired intent as per resolveService().
4220      * @param flags Additional option flags to modify the data returned.
4221      * @return Returns a List of ResolveInfo objects containing one entry for
4222      *         each matching service, ordered from best to worst. In other
4223      *         words, the first item is what would be returned by
4224      *         {@link #resolveService}. If there are no matching services, an
4225      *         empty list or null is returned.
4226      */
queryIntentServices(Intent intent, @ResolveInfoFlags int flags)4227     public abstract List<ResolveInfo> queryIntentServices(Intent intent,
4228             @ResolveInfoFlags int flags);
4229 
4230     /**
4231      * Retrieve all services that can match the given intent for a given user.
4232      *
4233      * @param intent The desired intent as per resolveService().
4234      * @param flags Additional option flags to modify the data returned.
4235      * @param userId The user id.
4236      * @return Returns a List of ResolveInfo objects containing one entry for
4237      *         each matching service, ordered from best to worst. In other
4238      *         words, the first item is what would be returned by
4239      *         {@link #resolveService}. If there are no matching services, an
4240      *         empty list or null is returned.
4241      * @hide
4242      */
queryIntentServicesAsUser(Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)4243     public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
4244             @ResolveInfoFlags int flags, @UserIdInt int userId);
4245 
4246     /**
4247      * Retrieve all providers that can match the given intent.
4248      *
4249      * @param intent An intent containing all of the desired specification
4250      *            (action, data, type, category, and/or component).
4251      * @param flags Additional option flags to modify the data returned.
4252      * @param userId The user id.
4253      * @return Returns a List of ResolveInfo objects containing one entry for
4254      *         each matching provider, ordered from best to worst. If there are
4255      *         no matching services, an empty list or null is returned.
4256      * @hide
4257      */
queryIntentContentProvidersAsUser( Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId)4258     public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
4259             Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
4260 
4261     /**
4262      * Retrieve all providers that can match the given intent.
4263      *
4264      * @param intent An intent containing all of the desired specification
4265      *            (action, data, type, category, and/or component).
4266      * @param flags Additional option flags to modify the data returned.
4267      * @return Returns a List of ResolveInfo objects containing one entry for
4268      *         each matching provider, ordered from best to worst. If there are
4269      *         no matching services, an empty list or null is returned.
4270      */
queryIntentContentProviders(Intent intent, @ResolveInfoFlags int flags)4271     public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
4272             @ResolveInfoFlags int flags);
4273 
4274     /**
4275      * Find a single content provider by its base path name.
4276      *
4277      * @param name The name of the provider to find.
4278      * @param flags Additional option flags to modify the data returned.
4279      * @return A {@link ProviderInfo} object containing information about the
4280      *         provider. If a provider was not found, returns null.
4281      */
resolveContentProvider(String name, @ComponentInfoFlags int flags)4282     public abstract ProviderInfo resolveContentProvider(String name,
4283             @ComponentInfoFlags int flags);
4284 
4285     /**
4286      * Find a single content provider by its base path name.
4287      *
4288      * @param name The name of the provider to find.
4289      * @param flags Additional option flags to modify the data returned.
4290      * @param userId The user id.
4291      * @return A {@link ProviderInfo} object containing information about the
4292      *         provider. If a provider was not found, returns null.
4293      * @hide
4294      */
resolveContentProviderAsUser(String name, @ComponentInfoFlags int flags, @UserIdInt int userId)4295     public abstract ProviderInfo resolveContentProviderAsUser(String name,
4296             @ComponentInfoFlags int flags, @UserIdInt int userId);
4297 
4298     /**
4299      * Retrieve content provider information.
4300      * <p>
4301      * <em>Note: unlike most other methods, an empty result set is indicated
4302      * by a null return instead of an empty list.</em>
4303      *
4304      * @param processName If non-null, limits the returned providers to only
4305      *            those that are hosted by the given process. If null, all
4306      *            content providers are returned.
4307      * @param uid If <var>processName</var> is non-null, this is the required
4308      *            uid owning the requested content providers.
4309      * @param flags Additional option flags to modify the data returned.
4310      * @return A list of {@link ProviderInfo} objects containing one entry for
4311      *         each provider either matching <var>processName</var> or, if
4312      *         <var>processName</var> is null, all known content providers.
4313      *         <em>If there are no matching providers, null is returned.</em>
4314      */
queryContentProviders( String processName, int uid, @ComponentInfoFlags int flags)4315     public abstract List<ProviderInfo> queryContentProviders(
4316             String processName, int uid, @ComponentInfoFlags int flags);
4317 
4318     /**
4319      * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null,
4320      * it only returns providers which have metadata with the {@code metaDataKey} key.
4321      *
4322      * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider.
4323      * You really shouldn't need it.  Other apps should use {@link #queryIntentContentProviders}
4324      * instead.
4325      *
4326      * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly
4327      * scan the GAL providers on the device.  Unfortunately the discovery protocol used metadata
4328      * to mark GAL providers, rather than intent filters, so we can't use
4329      * {@link #queryIntentContentProviders} for that.
4330      *
4331      * @hide
4332      */
queryContentProviders( String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey)4333     public List<ProviderInfo> queryContentProviders(
4334             String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) {
4335         // Provide the default implementation for mocks.
4336         return queryContentProviders(processName, uid, flags);
4337     }
4338 
4339     /**
4340      * Retrieve all of the information we know about a particular
4341      * instrumentation class.
4342      *
4343      * @param className The full name (i.e.
4344      *            com.google.apps.contacts.InstrumentList) of an Instrumentation
4345      *            class.
4346      * @param flags Additional option flags to modify the data returned.
4347      * @return An {@link InstrumentationInfo} object containing information
4348      *         about the instrumentation.
4349      * @throws NameNotFoundException if a package with the given name cannot be
4350      *             found on the system.
4351      */
getInstrumentationInfo(ComponentName className, @InstrumentationInfoFlags int flags)4352     public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
4353             @InstrumentationInfoFlags int flags) throws NameNotFoundException;
4354 
4355     /**
4356      * Retrieve information about available instrumentation code. May be used to
4357      * retrieve either all instrumentation code, or only the code targeting a
4358      * particular package.
4359      *
4360      * @param targetPackage If null, all instrumentation is returned; only the
4361      *            instrumentation targeting this package name is returned.
4362      * @param flags Additional option flags to modify the data returned.
4363      * @return A list of {@link InstrumentationInfo} objects containing one
4364      *         entry for each matching instrumentation. If there are no
4365      *         instrumentation available, returns an empty list.
4366      */
queryInstrumentation(String targetPackage, @InstrumentationInfoFlags int flags)4367     public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
4368             @InstrumentationInfoFlags int flags);
4369 
4370     /**
4371      * Retrieve an image from a package.  This is a low-level API used by
4372      * the various package manager info structures (such as
4373      * {@link ComponentInfo} to implement retrieval of their associated
4374      * icon.
4375      *
4376      * @param packageName The name of the package that this icon is coming from.
4377      * Cannot be null.
4378      * @param resid The resource identifier of the desired image.  Cannot be 0.
4379      * @param appInfo Overall information about <var>packageName</var>.  This
4380      * may be null, in which case the application information will be retrieved
4381      * for you if needed; if you already have this information around, it can
4382      * be much more efficient to supply it here.
4383      *
4384      * @return Returns a Drawable holding the requested image.  Returns null if
4385      * an image could not be found for any reason.
4386      */
getDrawable(String packageName, @DrawableRes int resid, ApplicationInfo appInfo)4387     public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
4388             ApplicationInfo appInfo);
4389 
4390     /**
4391      * Retrieve the icon associated with an activity.  Given the full name of
4392      * an activity, retrieves the information about it and calls
4393      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
4394      * If the activity cannot be found, NameNotFoundException is thrown.
4395      *
4396      * @param activityName Name of the activity whose icon is to be retrieved.
4397      *
4398      * @return Returns the image of the icon, or the default activity icon if
4399      * it could not be found.  Does not return null.
4400      * @throws NameNotFoundException Thrown if the resources for the given
4401      * activity could not be loaded.
4402      *
4403      * @see #getActivityIcon(Intent)
4404      */
getActivityIcon(ComponentName activityName)4405     public abstract Drawable getActivityIcon(ComponentName activityName)
4406             throws NameNotFoundException;
4407 
4408     /**
4409      * Retrieve the icon associated with an Intent.  If intent.getClassName() is
4410      * set, this simply returns the result of
4411      * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
4412      * component and returns the icon associated with the resolved component.
4413      * If intent.getClassName() cannot be found or the Intent cannot be resolved
4414      * to a component, NameNotFoundException is thrown.
4415      *
4416      * @param intent The intent for which you would like to retrieve an icon.
4417      *
4418      * @return Returns the image of the icon, or the default activity icon if
4419      * it could not be found.  Does not return null.
4420      * @throws NameNotFoundException Thrown if the resources for application
4421      * matching the given intent could not be loaded.
4422      *
4423      * @see #getActivityIcon(ComponentName)
4424      */
getActivityIcon(Intent intent)4425     public abstract Drawable getActivityIcon(Intent intent)
4426             throws NameNotFoundException;
4427 
4428     /**
4429      * Retrieve the banner associated with an activity. Given the full name of
4430      * an activity, retrieves the information about it and calls
4431      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4432      * banner. If the activity cannot be found, NameNotFoundException is thrown.
4433      *
4434      * @param activityName Name of the activity whose banner is to be retrieved.
4435      * @return Returns the image of the banner, or null if the activity has no
4436      *         banner specified.
4437      * @throws NameNotFoundException Thrown if the resources for the given
4438      *             activity could not be loaded.
4439      * @see #getActivityBanner(Intent)
4440      */
getActivityBanner(ComponentName activityName)4441     public abstract Drawable getActivityBanner(ComponentName activityName)
4442             throws NameNotFoundException;
4443 
4444     /**
4445      * Retrieve the banner associated with an Intent. If intent.getClassName()
4446      * is set, this simply returns the result of
4447      * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4448      * intent's component and returns the banner associated with the resolved
4449      * component. If intent.getClassName() cannot be found or the Intent cannot
4450      * be resolved to a component, NameNotFoundException is thrown.
4451      *
4452      * @param intent The intent for which you would like to retrieve a banner.
4453      * @return Returns the image of the banner, or null if the activity has no
4454      *         banner specified.
4455      * @throws NameNotFoundException Thrown if the resources for application
4456      *             matching the given intent could not be loaded.
4457      * @see #getActivityBanner(ComponentName)
4458      */
getActivityBanner(Intent intent)4459     public abstract Drawable getActivityBanner(Intent intent)
4460             throws NameNotFoundException;
4461 
4462     /**
4463      * Return the generic icon for an activity that is used when no specific
4464      * icon is defined.
4465      *
4466      * @return Drawable Image of the icon.
4467      */
getDefaultActivityIcon()4468     public abstract Drawable getDefaultActivityIcon();
4469 
4470     /**
4471      * Retrieve the icon associated with an application.  If it has not defined
4472      * an icon, the default app icon is returned.  Does not return null.
4473      *
4474      * @param info Information about application being queried.
4475      *
4476      * @return Returns the image of the icon, or the default application icon
4477      * if it could not be found.
4478      *
4479      * @see #getApplicationIcon(String)
4480      */
getApplicationIcon(ApplicationInfo info)4481     public abstract Drawable getApplicationIcon(ApplicationInfo info);
4482 
4483     /**
4484      * Retrieve the icon associated with an application.  Given the name of the
4485      * application's package, retrieves the information about it and calls
4486      * getApplicationIcon() to return its icon. If the application cannot be
4487      * found, NameNotFoundException is thrown.
4488      *
4489      * @param packageName Name of the package whose application icon is to be
4490      *                    retrieved.
4491      *
4492      * @return Returns the image of the icon, or the default application icon
4493      * if it could not be found.  Does not return null.
4494      * @throws NameNotFoundException Thrown if the resources for the given
4495      * application could not be loaded.
4496      *
4497      * @see #getApplicationIcon(ApplicationInfo)
4498      */
getApplicationIcon(String packageName)4499     public abstract Drawable getApplicationIcon(String packageName)
4500             throws NameNotFoundException;
4501 
4502     /**
4503      * Retrieve the banner associated with an application.
4504      *
4505      * @param info Information about application being queried.
4506      * @return Returns the image of the banner or null if the application has no
4507      *         banner specified.
4508      * @see #getApplicationBanner(String)
4509      */
getApplicationBanner(ApplicationInfo info)4510     public abstract Drawable getApplicationBanner(ApplicationInfo info);
4511 
4512     /**
4513      * Retrieve the banner associated with an application. Given the name of the
4514      * application's package, retrieves the information about it and calls
4515      * getApplicationIcon() to return its banner. If the application cannot be
4516      * found, NameNotFoundException is thrown.
4517      *
4518      * @param packageName Name of the package whose application banner is to be
4519      *            retrieved.
4520      * @return Returns the image of the banner or null if the application has no
4521      *         banner specified.
4522      * @throws NameNotFoundException Thrown if the resources for the given
4523      *             application could not be loaded.
4524      * @see #getApplicationBanner(ApplicationInfo)
4525      */
getApplicationBanner(String packageName)4526     public abstract Drawable getApplicationBanner(String packageName)
4527             throws NameNotFoundException;
4528 
4529     /**
4530      * Retrieve the logo associated with an activity. Given the full name of an
4531      * activity, retrieves the information about it and calls
4532      * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4533      * logo. If the activity cannot be found, NameNotFoundException is thrown.
4534      *
4535      * @param activityName Name of the activity whose logo is to be retrieved.
4536      * @return Returns the image of the logo or null if the activity has no logo
4537      *         specified.
4538      * @throws NameNotFoundException Thrown if the resources for the given
4539      *             activity could not be loaded.
4540      * @see #getActivityLogo(Intent)
4541      */
getActivityLogo(ComponentName activityName)4542     public abstract Drawable getActivityLogo(ComponentName activityName)
4543             throws NameNotFoundException;
4544 
4545     /**
4546      * Retrieve the logo associated with an Intent.  If intent.getClassName() is
4547      * set, this simply returns the result of
4548      * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
4549      * component and returns the logo associated with the resolved component.
4550      * If intent.getClassName() cannot be found or the Intent cannot be resolved
4551      * to a component, NameNotFoundException is thrown.
4552      *
4553      * @param intent The intent for which you would like to retrieve a logo.
4554      *
4555      * @return Returns the image of the logo, or null if the activity has no
4556      * logo specified.
4557      *
4558      * @throws NameNotFoundException Thrown if the resources for application
4559      * matching the given intent could not be loaded.
4560      *
4561      * @see #getActivityLogo(ComponentName)
4562      */
getActivityLogo(Intent intent)4563     public abstract Drawable getActivityLogo(Intent intent)
4564             throws NameNotFoundException;
4565 
4566     /**
4567      * Retrieve the logo associated with an application.  If it has not specified
4568      * a logo, this method returns null.
4569      *
4570      * @param info Information about application being queried.
4571      *
4572      * @return Returns the image of the logo, or null if no logo is specified
4573      * by the application.
4574      *
4575      * @see #getApplicationLogo(String)
4576      */
getApplicationLogo(ApplicationInfo info)4577     public abstract Drawable getApplicationLogo(ApplicationInfo info);
4578 
4579     /**
4580      * Retrieve the logo associated with an application.  Given the name of the
4581      * application's package, retrieves the information about it and calls
4582      * getApplicationLogo() to return its logo. If the application cannot be
4583      * found, NameNotFoundException is thrown.
4584      *
4585      * @param packageName Name of the package whose application logo is to be
4586      *                    retrieved.
4587      *
4588      * @return Returns the image of the logo, or null if no application logo
4589      * has been specified.
4590      *
4591      * @throws NameNotFoundException Thrown if the resources for the given
4592      * application could not be loaded.
4593      *
4594      * @see #getApplicationLogo(ApplicationInfo)
4595      */
getApplicationLogo(String packageName)4596     public abstract Drawable getApplicationLogo(String packageName)
4597             throws NameNotFoundException;
4598 
4599     /**
4600      * If the target user is a managed profile, then this returns a badged copy of the given icon
4601      * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
4602      * {@link #getUserBadgedDrawableForDensity(
4603      * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4604      * <p>
4605      * If the original drawable is a BitmapDrawable and the backing bitmap is
4606      * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4607      * is performed in place and the original drawable is returned.
4608      * </p>
4609      *
4610      * @param icon The icon to badge.
4611      * @param user The target user.
4612      * @return A drawable that combines the original icon and a badge as
4613      *         determined by the system.
4614      */
getUserBadgedIcon(Drawable icon, UserHandle user)4615     public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4616 
4617     /**
4618      * If the target user is a managed profile of the calling user or the caller
4619      * is itself a managed profile, then this returns a badged copy of the given
4620      * drawable allowing the user to distinguish it from the original drawable.
4621      * The caller can specify the location in the bounds of the drawable to be
4622      * badged where the badge should be applied as well as the density of the
4623      * badge to be used.
4624      * <p>
4625      * If the original drawable is a BitmapDrawable and the backing bitmap is
4626      * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4627      * is performed in place and the original drawable is returned.
4628      * </p>
4629      *
4630      * @param drawable The drawable to badge.
4631      * @param user The target user.
4632      * @param badgeLocation Where in the bounds of the badged drawable to place
4633      *         the badge. If it's {@code null}, the badge is applied on top of the entire
4634      *         drawable being badged.
4635      * @param badgeDensity The optional desired density for the badge as per
4636      *         {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4637      *         the density of the display is used.
4638      * @return A drawable that combines the original drawable and a badge as
4639      *         determined by the system.
4640      */
getUserBadgedDrawableForDensity(Drawable drawable, UserHandle user, Rect badgeLocation, int badgeDensity)4641     public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4642             UserHandle user, Rect badgeLocation, int badgeDensity);
4643 
4644     /**
4645      * If the target user is a managed profile of the calling user or the caller
4646      * is itself a managed profile, then this returns a drawable to use as a small
4647      * icon to include in a view to distinguish it from the original icon.
4648      *
4649      * @param user The target user.
4650      * @param density The optional desired density for the badge as per
4651      *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4652      *         the density of the current display is used.
4653      * @return the drawable or null if no drawable is required.
4654      * @hide
4655      */
getUserBadgeForDensity(UserHandle user, int density)4656     public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4657 
4658     /**
4659      * If the target user is a managed profile of the calling user or the caller
4660      * is itself a managed profile, then this returns a drawable to use as a small
4661      * icon to include in a view to distinguish it from the original icon. This version
4662      * doesn't have background protection and should be used over a light background instead of
4663      * a badge.
4664      *
4665      * @param user The target user.
4666      * @param density The optional desired density for the badge as per
4667      *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4668      *         the density of the current display is used.
4669      * @return the drawable or null if no drawable is required.
4670      * @hide
4671      */
getUserBadgeForDensityNoBackground(UserHandle user, int density)4672     public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4673 
4674     /**
4675      * If the target user is a managed profile of the calling user or the caller
4676      * is itself a managed profile, then this returns a copy of the label with
4677      * badging for accessibility services like talkback. E.g. passing in "Email"
4678      * and it might return "Work Email" for Email in the work profile.
4679      *
4680      * @param label The label to change.
4681      * @param user The target user.
4682      * @return A label that combines the original label and a badge as
4683      *         determined by the system.
4684      */
getUserBadgedLabel(CharSequence label, UserHandle user)4685     public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4686 
4687     /**
4688      * Retrieve text from a package.  This is a low-level API used by
4689      * the various package manager info structures (such as
4690      * {@link ComponentInfo} to implement retrieval of their associated
4691      * labels and other text.
4692      *
4693      * @param packageName The name of the package that this text is coming from.
4694      * Cannot be null.
4695      * @param resid The resource identifier of the desired text.  Cannot be 0.
4696      * @param appInfo Overall information about <var>packageName</var>.  This
4697      * may be null, in which case the application information will be retrieved
4698      * for you if needed; if you already have this information around, it can
4699      * be much more efficient to supply it here.
4700      *
4701      * @return Returns a CharSequence holding the requested text.  Returns null
4702      * if the text could not be found for any reason.
4703      */
getText(String packageName, @StringRes int resid, ApplicationInfo appInfo)4704     public abstract CharSequence getText(String packageName, @StringRes int resid,
4705             ApplicationInfo appInfo);
4706 
4707     /**
4708      * Retrieve an XML file from a package.  This is a low-level API used to
4709      * retrieve XML meta data.
4710      *
4711      * @param packageName The name of the package that this xml is coming from.
4712      * Cannot be null.
4713      * @param resid The resource identifier of the desired xml.  Cannot be 0.
4714      * @param appInfo Overall information about <var>packageName</var>.  This
4715      * may be null, in which case the application information will be retrieved
4716      * for you if needed; if you already have this information around, it can
4717      * be much more efficient to supply it here.
4718      *
4719      * @return Returns an XmlPullParser allowing you to parse out the XML
4720      * data.  Returns null if the xml resource could not be found for any
4721      * reason.
4722      */
getXml(String packageName, @XmlRes int resid, ApplicationInfo appInfo)4723     public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
4724             ApplicationInfo appInfo);
4725 
4726     /**
4727      * Return the label to use for this application.
4728      *
4729      * @return Returns the label associated with this application, or null if
4730      * it could not be found for any reason.
4731      * @param info The application to get the label of.
4732      */
getApplicationLabel(ApplicationInfo info)4733     public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4734 
4735     /**
4736      * Retrieve the resources associated with an activity.  Given the full
4737      * name of an activity, retrieves the information about it and calls
4738      * getResources() to return its application's resources.  If the activity
4739      * cannot be found, NameNotFoundException is thrown.
4740      *
4741      * @param activityName Name of the activity whose resources are to be
4742      *                     retrieved.
4743      *
4744      * @return Returns the application's Resources.
4745      * @throws NameNotFoundException Thrown if the resources for the given
4746      * application could not be loaded.
4747      *
4748      * @see #getResourcesForApplication(ApplicationInfo)
4749      */
getResourcesForActivity(ComponentName activityName)4750     public abstract Resources getResourcesForActivity(ComponentName activityName)
4751             throws NameNotFoundException;
4752 
4753     /**
4754      * Retrieve the resources for an application.  Throws NameNotFoundException
4755      * if the package is no longer installed.
4756      *
4757      * @param app Information about the desired application.
4758      *
4759      * @return Returns the application's Resources.
4760      * @throws NameNotFoundException Thrown if the resources for the given
4761      * application could not be loaded (most likely because it was uninstalled).
4762      */
getResourcesForApplication(ApplicationInfo app)4763     public abstract Resources getResourcesForApplication(ApplicationInfo app)
4764             throws NameNotFoundException;
4765 
4766     /**
4767      * Retrieve the resources associated with an application.  Given the full
4768      * package name of an application, retrieves the information about it and
4769      * calls getResources() to return its application's resources.  If the
4770      * appPackageName cannot be found, NameNotFoundException is thrown.
4771      *
4772      * @param appPackageName Package name of the application whose resources
4773      *                       are to be retrieved.
4774      *
4775      * @return Returns the application's Resources.
4776      * @throws NameNotFoundException Thrown if the resources for the given
4777      * application could not be loaded.
4778      *
4779      * @see #getResourcesForApplication(ApplicationInfo)
4780      */
getResourcesForApplication(String appPackageName)4781     public abstract Resources getResourcesForApplication(String appPackageName)
4782             throws NameNotFoundException;
4783 
4784     /** @hide */
getResourcesForApplicationAsUser(String appPackageName, @UserIdInt int userId)4785     public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4786             @UserIdInt int userId) throws NameNotFoundException;
4787 
4788     /**
4789      * Retrieve overall information about an application package defined in a
4790      * package archive file
4791      *
4792      * @param archiveFilePath The path to the archive file
4793      * @param flags Additional option flags to modify the data returned.
4794      * @return A PackageInfo object containing information about the package
4795      *         archive. If the package could not be parsed, returns null.
4796      */
getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags)4797     public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
4798         final PackageParser parser = new PackageParser();
4799         parser.setCallback(new PackageParser.CallbackImpl(this));
4800         final File apkFile = new File(archiveFilePath);
4801         try {
4802             if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
4803                 // Caller expressed an explicit opinion about what encryption
4804                 // aware/unaware components they want to see, so fall through and
4805                 // give them what they want
4806             } else {
4807                 // Caller expressed no opinion, so match everything
4808                 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
4809             }
4810 
4811             PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
4812             if ((flags & GET_SIGNATURES) != 0) {
4813                 PackageParser.collectCertificates(pkg, false /* skipVerify */);
4814             }
4815             PackageUserState state = new PackageUserState();
4816             return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4817         } catch (PackageParserException e) {
4818             return null;
4819         }
4820     }
4821 
4822     /**
4823      * If there is already an application with the given package name installed
4824      * on the system for other users, also install it for the calling user.
4825      * @hide
4826      */
4827     @SystemApi
installExistingPackage(String packageName)4828     public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
4829 
4830     /**
4831      * If there is already an application with the given package name installed
4832      * on the system for other users, also install it for the calling user.
4833      * @hide
4834      */
4835     @SystemApi
installExistingPackage(String packageName, @InstallReason int installReason)4836     public abstract int installExistingPackage(String packageName, @InstallReason int installReason)
4837             throws NameNotFoundException;
4838 
4839     /**
4840      * If there is already an application with the given package name installed
4841      * on the system for other users, also install it for the specified user.
4842      * @hide
4843      */
4844      @RequiresPermission(anyOf = {
4845             Manifest.permission.INSTALL_PACKAGES,
4846             Manifest.permission.INTERACT_ACROSS_USERS_FULL})
installExistingPackageAsUser(String packageName, @UserIdInt int userId)4847     public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
4848             throws NameNotFoundException;
4849 
4850     /**
4851      * Allows a package listening to the
4852      * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4853      * broadcast} to respond to the package manager. The response must include
4854      * the {@code verificationCode} which is one of
4855      * {@link PackageManager#VERIFICATION_ALLOW} or
4856      * {@link PackageManager#VERIFICATION_REJECT}.
4857      *
4858      * @param id pending package identifier as passed via the
4859      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4860      * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
4861      *            or {@link PackageManager#VERIFICATION_REJECT}.
4862      * @throws SecurityException if the caller does not have the
4863      *            PACKAGE_VERIFICATION_AGENT permission.
4864      */
verifyPendingInstall(int id, int verificationCode)4865     public abstract void verifyPendingInstall(int id, int verificationCode);
4866 
4867     /**
4868      * Allows a package listening to the
4869      * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4870      * broadcast} to extend the default timeout for a response and declare what
4871      * action to perform after the timeout occurs. The response must include
4872      * the {@code verificationCodeAtTimeout} which is one of
4873      * {@link PackageManager#VERIFICATION_ALLOW} or
4874      * {@link PackageManager#VERIFICATION_REJECT}.
4875      *
4876      * This method may only be called once per package id. Additional calls
4877      * will have no effect.
4878      *
4879      * @param id pending package identifier as passed via the
4880      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4881      * @param verificationCodeAtTimeout either
4882      *            {@link PackageManager#VERIFICATION_ALLOW} or
4883      *            {@link PackageManager#VERIFICATION_REJECT}. If
4884      *            {@code verificationCodeAtTimeout} is neither
4885      *            {@link PackageManager#VERIFICATION_ALLOW} or
4886      *            {@link PackageManager#VERIFICATION_REJECT}, then
4887      *            {@code verificationCodeAtTimeout} will default to
4888      *            {@link PackageManager#VERIFICATION_REJECT}.
4889      * @param millisecondsToDelay the amount of time requested for the timeout.
4890      *            Must be positive and less than
4891      *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4892      *            {@code millisecondsToDelay} is out of bounds,
4893      *            {@code millisecondsToDelay} will be set to the closest in
4894      *            bounds value; namely, 0 or
4895      *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
4896      * @throws SecurityException if the caller does not have the
4897      *            PACKAGE_VERIFICATION_AGENT permission.
4898      */
extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay)4899     public abstract void extendVerificationTimeout(int id,
4900             int verificationCodeAtTimeout, long millisecondsToDelay);
4901 
4902     /**
4903      * Allows a package listening to the
4904      * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
4905      * broadcast to respond to the package manager. The response must include
4906      * the {@code verificationCode} which is one of
4907      * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4908      * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4909      *
4910      * @param verificationId pending package identifier as passed via the
4911      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4912      * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4913      *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4914      * @param failedDomains a list of failed domains if the verificationCode is
4915      *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4916      * @throws SecurityException if the caller does not have the
4917      *            INTENT_FILTER_VERIFICATION_AGENT permission.
4918      *
4919      * @hide
4920      */
4921     @SystemApi
4922     @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT)
verifyIntentFilter(int verificationId, int verificationCode, List<String> failedDomains)4923     public abstract void verifyIntentFilter(int verificationId, int verificationCode,
4924             List<String> failedDomains);
4925 
4926     /**
4927      * Get the status of a Domain Verification Result for an IntentFilter. This is
4928      * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4929      * {@link android.content.IntentFilter#getAutoVerify()}
4930      *
4931      * This is used by the ResolverActivity to change the status depending on what the User select
4932      * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4933      * for a domain.
4934      *
4935      * @param packageName The package name of the Activity associated with the IntentFilter.
4936      * @param userId The user id.
4937      *
4938      * @return The status to set to. This can be
4939      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4940      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4941      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4942      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4943      *
4944      * @hide
4945      */
4946     @SystemApi
4947     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId)4948     public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
4949 
4950     /**
4951      * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4952      * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4953      * {@link android.content.IntentFilter#getAutoVerify()}
4954      *
4955      * This is used by the ResolverActivity to change the status depending on what the User select
4956      * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4957      * for a domain.
4958      *
4959      * @param packageName The package name of the Activity associated with the IntentFilter.
4960      * @param status The status to set to. This can be
4961      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4962      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4963      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4964      * @param userId The user id.
4965      *
4966      * @return true if the status has been set. False otherwise.
4967      *
4968      * @hide
4969      */
4970     @SystemApi
4971     @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
updateIntentVerificationStatusAsUser(String packageName, int status, @UserIdInt int userId)4972     public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
4973             @UserIdInt int userId);
4974 
4975     /**
4976      * Get the list of IntentFilterVerificationInfo for a specific package and User.
4977      *
4978      * @param packageName the package name. When this parameter is set to a non null value,
4979      *                    the results will be filtered by the package name provided.
4980      *                    Otherwise, there will be no filtering and it will return a list
4981      *                    corresponding for all packages
4982      *
4983      * @return a list of IntentFilterVerificationInfo for a specific package.
4984      *
4985      * @hide
4986      */
4987     @SystemApi
getIntentFilterVerifications( String packageName)4988     public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4989             String packageName);
4990 
4991     /**
4992      * Get the list of IntentFilter for a specific package.
4993      *
4994      * @param packageName the package name. This parameter is set to a non null value,
4995      *                    the list will contain all the IntentFilter for that package.
4996      *                    Otherwise, the list will be empty.
4997      *
4998      * @return a list of IntentFilter for a specific package.
4999      *
5000      * @hide
5001      */
5002     @SystemApi
getAllIntentFilters(String packageName)5003     public abstract List<IntentFilter> getAllIntentFilters(String packageName);
5004 
5005     /**
5006      * Get the default Browser package name for a specific user.
5007      *
5008      * @param userId The user id.
5009      *
5010      * @return the package name of the default Browser for the specified user. If the user id passed
5011      *         is -1 (all users) it will return a null value.
5012      *
5013      * @hide
5014      */
5015     @TestApi
5016     @SystemApi
5017     @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
getDefaultBrowserPackageNameAsUser(@serIdInt int userId)5018     public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
5019 
5020     /**
5021      * Set the default Browser package name for a specific user.
5022      *
5023      * @param packageName The package name of the default Browser.
5024      * @param userId The user id.
5025      *
5026      * @return true if the default Browser for the specified user has been set,
5027      *         otherwise return false. If the user id passed is -1 (all users) this call will not
5028      *         do anything and just return false.
5029      *
5030      * @hide
5031      */
5032     @SystemApi
5033     @RequiresPermission(allOf = {
5034             Manifest.permission.SET_PREFERRED_APPLICATIONS,
5035             Manifest.permission.INTERACT_ACROSS_USERS_FULL})
setDefaultBrowserPackageNameAsUser(String packageName, @UserIdInt int userId)5036     public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
5037             @UserIdInt int userId);
5038 
5039     /**
5040      * Change the installer associated with a given package.  There are limitations
5041      * on how the installer package can be changed; in particular:
5042      * <ul>
5043      * <li> A SecurityException will be thrown if <var>installerPackageName</var>
5044      * is not signed with the same certificate as the calling application.
5045      * <li> A SecurityException will be thrown if <var>targetPackage</var> already
5046      * has an installer package, and that installer package is not signed with
5047      * the same certificate as the calling application.
5048      * </ul>
5049      *
5050      * @param targetPackage The installed package whose installer will be changed.
5051      * @param installerPackageName The package name of the new installer.  May be
5052      * null to clear the association.
5053      */
setInstallerPackageName(String targetPackage, String installerPackageName)5054     public abstract void setInstallerPackageName(String targetPackage,
5055             String installerPackageName);
5056 
5057     /** @hide */
5058     @SystemApi
5059     @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
setUpdateAvailable(String packageName, boolean updateAvaialble)5060     public abstract void setUpdateAvailable(String packageName, boolean updateAvaialble);
5061 
5062     /**
5063      * Attempts to delete a package. Since this may take a little while, the
5064      * result will be posted back to the given observer. A deletion will fail if
5065      * the calling context lacks the
5066      * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
5067      * named package cannot be found, or if the named package is a system
5068      * package.
5069      *
5070      * @param packageName The name of the package to delete
5071      * @param observer An observer callback to get notified when the package
5072      *            deletion is complete.
5073      *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5074      *            will be called when that happens. observer may be null to
5075      *            indicate that no callback is desired.
5076      * @hide
5077      */
5078     @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
deletePackage(String packageName, IPackageDeleteObserver observer, @DeleteFlags int flags)5079     public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
5080             @DeleteFlags int flags);
5081 
5082     /**
5083      * Attempts to delete a package. Since this may take a little while, the
5084      * result will be posted back to the given observer. A deletion will fail if
5085      * the named package cannot be found, or if the named package is a system
5086      * package.
5087      *
5088      * @param packageName The name of the package to delete
5089      * @param observer An observer callback to get notified when the package
5090      *            deletion is complete.
5091      *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5092      *            will be called when that happens. observer may be null to
5093      *            indicate that no callback is desired.
5094      * @param userId The user Id
5095      * @hide
5096      */
5097     @RequiresPermission(anyOf = {
5098             Manifest.permission.DELETE_PACKAGES,
5099             Manifest.permission.INTERACT_ACROSS_USERS_FULL})
deletePackageAsUser(@onNull String packageName, IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId)5100     public abstract void deletePackageAsUser(@NonNull String packageName,
5101             IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId);
5102 
5103     /**
5104      * Retrieve the package name of the application that installed a package. This identifies
5105      * which market the package came from.
5106      *
5107      * @param packageName The name of the package to query
5108      * @throws IllegalArgumentException if the given package name is not installed
5109      */
getInstallerPackageName(String packageName)5110     public abstract String getInstallerPackageName(String packageName);
5111 
5112     /**
5113      * Attempts to clear the user data directory of an application.
5114      * Since this may take a little while, the result will
5115      * be posted back to the given observer.  A deletion will fail if the
5116      * named package cannot be found, or if the named package is a "system package".
5117      *
5118      * @param packageName The name of the package
5119      * @param observer An observer callback to get notified when the operation is finished
5120      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5121      * will be called when that happens.  observer may be null to indicate that
5122      * no callback is desired.
5123      *
5124      * @hide
5125      */
clearApplicationUserData(String packageName, IPackageDataObserver observer)5126     public abstract void clearApplicationUserData(String packageName,
5127             IPackageDataObserver observer);
5128     /**
5129      * Attempts to delete the cache files associated with an application.
5130      * Since this may take a little while, the result will
5131      * be posted back to the given observer.  A deletion will fail if the calling context
5132      * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
5133      * named package cannot be found, or if the named package is a "system package".
5134      *
5135      * @param packageName The name of the package to delete
5136      * @param observer An observer callback to get notified when the cache file deletion
5137      * is complete.
5138      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5139      * will be called when that happens.  observer may be null to indicate that
5140      * no callback is desired.
5141      *
5142      * @hide
5143      */
deleteApplicationCacheFiles(String packageName, IPackageDataObserver observer)5144     public abstract void deleteApplicationCacheFiles(String packageName,
5145             IPackageDataObserver observer);
5146 
5147     /**
5148      * Attempts to delete the cache files associated with an application for a given user. Since
5149      * this may take a little while, the result will be posted back to the given observer. A
5150      * deletion will fail if the calling context lacks the
5151      * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
5152      * cannot be found, or if the named package is a "system package". If {@code userId} does not
5153      * belong to the calling user, the caller must have
5154      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
5155      *
5156      * @param packageName The name of the package to delete
5157      * @param userId the user for which the cache files needs to be deleted
5158      * @param observer An observer callback to get notified when the cache file deletion is
5159      *            complete.
5160      *            {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5161      *            will be called when that happens. observer may be null to indicate that no
5162      *            callback is desired.
5163      * @hide
5164      */
deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer)5165     public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId,
5166             IPackageDataObserver observer);
5167 
5168     /**
5169      * Free storage by deleting LRU sorted list of cache files across
5170      * all applications. If the currently available free storage
5171      * on the device is greater than or equal to the requested
5172      * free storage, no cache files are cleared. If the currently
5173      * available storage on the device is less than the requested
5174      * free storage, some or all of the cache files across
5175      * all applications are deleted (based on last accessed time)
5176      * to increase the free storage space on the device to
5177      * the requested value. There is no guarantee that clearing all
5178      * the cache files from all applications will clear up
5179      * enough storage to achieve the desired value.
5180      * @param freeStorageSize The number of bytes of storage to be
5181      * freed by the system. Say if freeStorageSize is XX,
5182      * and the current free storage is YY,
5183      * if XX is less than YY, just return. if not free XX-YY number
5184      * of bytes if possible.
5185      * @param observer call back used to notify when
5186      * the operation is completed
5187      *
5188      * @hide
5189      */
freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer)5190     public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
5191         freeStorageAndNotify(null, freeStorageSize, observer);
5192     }
5193 
5194     /** {@hide} */
freeStorageAndNotify(String volumeUuid, long freeStorageSize, IPackageDataObserver observer)5195     public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
5196             IPackageDataObserver observer);
5197 
5198     /**
5199      * Free storage by deleting LRU sorted list of cache files across
5200      * all applications. If the currently available free storage
5201      * on the device is greater than or equal to the requested
5202      * free storage, no cache files are cleared. If the currently
5203      * available storage on the device is less than the requested
5204      * free storage, some or all of the cache files across
5205      * all applications are deleted (based on last accessed time)
5206      * to increase the free storage space on the device to
5207      * the requested value. There is no guarantee that clearing all
5208      * the cache files from all applications will clear up
5209      * enough storage to achieve the desired value.
5210      * @param freeStorageSize The number of bytes of storage to be
5211      * freed by the system. Say if freeStorageSize is XX,
5212      * and the current free storage is YY,
5213      * if XX is less than YY, just return. if not free XX-YY number
5214      * of bytes if possible.
5215      * @param pi IntentSender call back used to
5216      * notify when the operation is completed.May be null
5217      * to indicate that no call back is desired.
5218      *
5219      * @hide
5220      */
freeStorage(long freeStorageSize, IntentSender pi)5221     public void freeStorage(long freeStorageSize, IntentSender pi) {
5222         freeStorage(null, freeStorageSize, pi);
5223     }
5224 
5225     /** {@hide} */
freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi)5226     public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
5227 
5228     /**
5229      * Retrieve the size information for a package.
5230      * Since this may take a little while, the result will
5231      * be posted back to the given observer.  The calling context
5232      * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
5233      *
5234      * @param packageName The name of the package whose size information is to be retrieved
5235      * @param userId The user whose size information should be retrieved.
5236      * @param observer An observer callback to get notified when the operation
5237      * is complete.
5238      * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
5239      * The observer's callback is invoked with a PackageStats object(containing the
5240      * code, data and cache sizes of the package) and a boolean value representing
5241      * the status of the operation. observer may be null to indicate that
5242      * no callback is desired.
5243      *
5244      * @deprecated use {@link StorageStatsManager} instead.
5245      * @hide
5246      */
5247     @Deprecated
getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId, IPackageStatsObserver observer)5248     public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
5249             IPackageStatsObserver observer);
5250 
5251     /**
5252      * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
5253      * returns the size for the calling user.
5254      *
5255      * @deprecated use {@link StorageStatsManager} instead.
5256      * @hide
5257      */
5258     @Deprecated
getPackageSizeInfo(String packageName, IPackageStatsObserver observer)5259     public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
5260         getPackageSizeInfoAsUser(packageName, getUserId(), observer);
5261     }
5262 
5263     /**
5264      * @deprecated This function no longer does anything; it was an old
5265      * approach to managing preferred activities, which has been superseded
5266      * by (and conflicts with) the modern activity-based preferences.
5267      */
5268     @Deprecated
addPackageToPreferred(String packageName)5269     public abstract void addPackageToPreferred(String packageName);
5270 
5271     /**
5272      * @deprecated This function no longer does anything; it was an old
5273      * approach to managing preferred activities, which has been superseded
5274      * by (and conflicts with) the modern activity-based preferences.
5275      */
5276     @Deprecated
removePackageFromPreferred(String packageName)5277     public abstract void removePackageFromPreferred(String packageName);
5278 
5279     /**
5280      * Retrieve the list of all currently configured preferred packages. The
5281      * first package on the list is the most preferred, the last is the least
5282      * preferred.
5283      *
5284      * @param flags Additional option flags to modify the data returned.
5285      * @return A List of PackageInfo objects, one for each preferred
5286      *         application, in order of preference.
5287      */
getPreferredPackages(@ackageInfoFlags int flags)5288     public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
5289 
5290     /**
5291      * @deprecated This is a protected API that should not have been available
5292      * to third party applications.  It is the platform's responsibility for
5293      * assigning preferred activities and this cannot be directly modified.
5294      *
5295      * Add a new preferred activity mapping to the system.  This will be used
5296      * to automatically select the given activity component when
5297      * {@link Context#startActivity(Intent) Context.startActivity()} finds
5298      * multiple matching activities and also matches the given filter.
5299      *
5300      * @param filter The set of intents under which this activity will be
5301      * made preferred.
5302      * @param match The IntentFilter match category that this preference
5303      * applies to.
5304      * @param set The set of activities that the user was picking from when
5305      * this preference was made.
5306      * @param activity The component name of the activity that is to be
5307      * preferred.
5308      */
5309     @Deprecated
addPreferredActivity(IntentFilter filter, int match, ComponentName[] set, ComponentName activity)5310     public abstract void addPreferredActivity(IntentFilter filter, int match,
5311             ComponentName[] set, ComponentName activity);
5312 
5313     /**
5314      * Same as {@link #addPreferredActivity(IntentFilter, int,
5315             ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5316             to.
5317      * @hide
5318      */
addPreferredActivityAsUser(IntentFilter filter, int match, ComponentName[] set, ComponentName activity, @UserIdInt int userId)5319     public void addPreferredActivityAsUser(IntentFilter filter, int match,
5320             ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5321         throw new RuntimeException("Not implemented. Must override in a subclass.");
5322     }
5323 
5324     /**
5325      * @deprecated This is a protected API that should not have been available
5326      * to third party applications.  It is the platform's responsibility for
5327      * assigning preferred activities and this cannot be directly modified.
5328      *
5329      * Replaces an existing preferred activity mapping to the system, and if that were not present
5330      * adds a new preferred activity.  This will be used
5331      * to automatically select the given activity component when
5332      * {@link Context#startActivity(Intent) Context.startActivity()} finds
5333      * multiple matching activities and also matches the given filter.
5334      *
5335      * @param filter The set of intents under which this activity will be
5336      * made preferred.
5337      * @param match The IntentFilter match category that this preference
5338      * applies to.
5339      * @param set The set of activities that the user was picking from when
5340      * this preference was made.
5341      * @param activity The component name of the activity that is to be
5342      * preferred.
5343      * @hide
5344      */
5345     @Deprecated
replacePreferredActivity(IntentFilter filter, int match, ComponentName[] set, ComponentName activity)5346     public abstract void replacePreferredActivity(IntentFilter filter, int match,
5347             ComponentName[] set, ComponentName activity);
5348 
5349     /**
5350      * @hide
5351      */
5352     @Deprecated
replacePreferredActivityAsUser(IntentFilter filter, int match, ComponentName[] set, ComponentName activity, @UserIdInt int userId)5353     public void replacePreferredActivityAsUser(IntentFilter filter, int match,
5354            ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5355         throw new RuntimeException("Not implemented. Must override in a subclass.");
5356     }
5357 
5358     /**
5359      * Remove all preferred activity mappings, previously added with
5360      * {@link #addPreferredActivity}, from the
5361      * system whose activities are implemented in the given package name.
5362      * An application can only clear its own package(s).
5363      *
5364      * @param packageName The name of the package whose preferred activity
5365      * mappings are to be removed.
5366      */
clearPackagePreferredActivities(String packageName)5367     public abstract void clearPackagePreferredActivities(String packageName);
5368 
5369     /**
5370      * Retrieve all preferred activities, previously added with
5371      * {@link #addPreferredActivity}, that are
5372      * currently registered with the system.
5373      *
5374      * @param outFilters A required list in which to place the filters of all of the
5375      * preferred activities.
5376      * @param outActivities A required list in which to place the component names of
5377      * all of the preferred activities.
5378      * @param packageName An optional package in which you would like to limit
5379      * the list.  If null, all activities will be returned; if non-null, only
5380      * those activities in the given package are returned.
5381      *
5382      * @return Returns the total number of registered preferred activities
5383      * (the number of distinct IntentFilter records, not the number of unique
5384      * activity components) that were found.
5385      */
getPreferredActivities(@onNull List<IntentFilter> outFilters, @NonNull List<ComponentName> outActivities, String packageName)5386     public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5387             @NonNull List<ComponentName> outActivities, String packageName);
5388 
5389     /**
5390      * Ask for the set of available 'home' activities and the current explicit
5391      * default, if any.
5392      * @hide
5393      */
getHomeActivities(List<ResolveInfo> outActivities)5394     public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5395 
5396     /**
5397      * Set the enabled setting for a package component (activity, receiver, service, provider).
5398      * This setting will override any enabled state which may have been set by the component in its
5399      * manifest.
5400      *
5401      * @param componentName The component to enable
5402      * @param newState The new enabled state for the component.
5403      * @param flags Optional behavior flags.
5404      */
setComponentEnabledSetting(ComponentName componentName, @EnabledState int newState, @EnabledFlags int flags)5405     public abstract void setComponentEnabledSetting(ComponentName componentName,
5406             @EnabledState int newState, @EnabledFlags int flags);
5407 
5408     /**
5409      * Return the enabled setting for a package component (activity,
5410      * receiver, service, provider).  This returns the last value set by
5411      * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5412      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5413      * the value originally specified in the manifest has not been modified.
5414      *
5415      * @param componentName The component to retrieve.
5416      * @return Returns the current enabled state for the component.
5417      */
getComponentEnabledSetting( ComponentName componentName)5418     public abstract @EnabledState int getComponentEnabledSetting(
5419             ComponentName componentName);
5420 
5421     /**
5422      * Set the enabled setting for an application
5423      * This setting will override any enabled state which may have been set by the application in
5424      * its manifest.  It also overrides the enabled state set in the manifest for any of the
5425      * application's components.  It does not override any enabled state set by
5426      * {@link #setComponentEnabledSetting} for any of the application's components.
5427      *
5428      * @param packageName The package name of the application to enable
5429      * @param newState The new enabled state for the application.
5430      * @param flags Optional behavior flags.
5431      */
setApplicationEnabledSetting(String packageName, @EnabledState int newState, @EnabledFlags int flags)5432     public abstract void setApplicationEnabledSetting(String packageName,
5433             @EnabledState int newState, @EnabledFlags int flags);
5434 
5435     /**
5436      * Return the enabled setting for an application. This returns
5437      * the last value set by
5438      * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5439      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5440      * the value originally specified in the manifest has not been modified.
5441      *
5442      * @param packageName The package name of the application to retrieve.
5443      * @return Returns the current enabled state for the application.
5444      * @throws IllegalArgumentException if the named package does not exist.
5445      */
getApplicationEnabledSetting(String packageName)5446     public abstract @EnabledState int getApplicationEnabledSetting(String packageName);
5447 
5448     /**
5449      * Flush the package restrictions for a given user to disk. This forces the package restrictions
5450      * like component and package enabled settings to be written to disk and avoids the delay that
5451      * is otherwise present when changing those settings.
5452      *
5453      * @param userId Ther userId of the user whose restrictions are to be flushed.
5454      * @hide
5455      */
flushPackageRestrictionsAsUser(int userId)5456     public abstract void flushPackageRestrictionsAsUser(int userId);
5457 
5458     /**
5459      * Puts the package in a hidden state, which is almost like an uninstalled state,
5460      * making the package unavailable, but it doesn't remove the data or the actual
5461      * package file. Application can be unhidden by either resetting the hidden state
5462      * or by installing it, such as with {@link #installExistingPackage(String)}
5463      * @hide
5464      */
setApplicationHiddenSettingAsUser(String packageName, boolean hidden, UserHandle userHandle)5465     public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
5466             UserHandle userHandle);
5467 
5468     /**
5469      * Returns the hidden state of a package.
5470      * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
5471      * @hide
5472      */
getApplicationHiddenSettingAsUser(String packageName, UserHandle userHandle)5473     public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
5474             UserHandle userHandle);
5475 
5476     /**
5477      * Return whether the device has been booted into safe mode.
5478      */
isSafeMode()5479     public abstract boolean isSafeMode();
5480 
5481     /**
5482      * Adds a listener for permission changes for installed packages.
5483      *
5484      * @param listener The listener to add.
5485      *
5486      * @hide
5487      */
5488     @SystemApi
5489     @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
addOnPermissionsChangeListener(OnPermissionsChangedListener listener)5490     public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5491 
5492     /**
5493      * Remvoes a listener for permission changes for installed packages.
5494      *
5495      * @param listener The listener to remove.
5496      *
5497      * @hide
5498      */
5499     @SystemApi
5500     @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
removeOnPermissionsChangeListener(OnPermissionsChangedListener listener)5501     public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5502 
5503     /**
5504      * Return the {@link KeySet} associated with the String alias for this
5505      * application.
5506      *
5507      * @param alias The alias for a given {@link KeySet} as defined in the
5508      *        application's AndroidManifest.xml.
5509      * @hide
5510      */
getKeySetByAlias(String packageName, String alias)5511     public abstract KeySet getKeySetByAlias(String packageName, String alias);
5512 
5513     /** Return the signing {@link KeySet} for this application.
5514      * @hide
5515      */
getSigningKeySet(String packageName)5516     public abstract KeySet getSigningKeySet(String packageName);
5517 
5518     /**
5519      * Return whether the package denoted by packageName has been signed by all
5520      * of the keys specified by the {@link KeySet} ks.  This will return true if
5521      * the package has been signed by additional keys (a superset) as well.
5522      * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
5523      * @hide
5524      */
isSignedBy(String packageName, KeySet ks)5525     public abstract boolean isSignedBy(String packageName, KeySet ks);
5526 
5527     /**
5528      * Return whether the package denoted by packageName has been signed by all
5529      * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5530      * {@link #isSignedBy(String packageName, KeySet ks)}.
5531      * @hide
5532      */
isSignedByExactly(String packageName, KeySet ks)5533     public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5534 
5535     /**
5536      * Puts the package in a suspended state, where attempts at starting activities are denied.
5537      *
5538      * <p>It doesn't remove the data or the actual package file. The application's notifications
5539      * will be hidden, any of its started activities will be stopped and it will not be able to
5540      * show toasts or system alert windows or ring the device.
5541      *
5542      * <p>When the user tries to launch a suspended app, a system dialog with the given
5543      * {@code dialogMessage} will be shown instead. Since the message is supplied to the system as
5544      * a {@link String}, the caller needs to take care of localization as needed.
5545      * The dialog message can optionally contain a placeholder for the name of the suspended app.
5546      * The system uses {@link String#format(Locale, String, Object...) String.format} to insert the
5547      * app name into the message, so an example format string could be {@code "The app %1$s is
5548      * currently suspended"}. This makes it easier for callers to provide a single message which
5549      * works for all the packages being suspended in a single call.
5550      *
5551      * <p>The package must already be installed. If the package is uninstalled while suspended
5552      * the package will no longer be suspended. </p>
5553      *
5554      * <p>Optionally, the suspending app can provide extra information in the form of
5555      * {@link PersistableBundle} objects to be shared with the apps being suspended and the
5556      * launcher to support customization that they might need to handle the suspended state.
5557      *
5558      * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} or
5559      * {@link Manifest.permission#MANAGE_USERS} to use this api.</p>
5560      *
5561      * @param packageNames The names of the packages to set the suspended status.
5562      * @param suspended If set to {@code true} than the packages will be suspended, if set to
5563      * {@code false}, the packages will be unsuspended.
5564      * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide
5565      *                  which will be shared with the apps being suspended. Ignored if
5566      *                  {@code suspended} is false.
5567      * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can
5568      *                       provide which will be shared with the launcher. Ignored if
5569      *                       {@code suspended} is false.
5570      * @param dialogMessage The message to be displayed to the user, when they try to launch a
5571      *                      suspended app.
5572      *
5573      * @return an array of package names for which the suspended status could not be set as
5574      * requested in this method.
5575      *
5576      * @hide
5577      */
5578     @SystemApi
5579     @RequiresPermission(Manifest.permission.SUSPEND_APPS)
setPackagesSuspended(String[] packageNames, boolean suspended, @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, String dialogMessage)5580     public String[] setPackagesSuspended(String[] packageNames, boolean suspended,
5581             @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras,
5582             String dialogMessage) {
5583         throw new UnsupportedOperationException("setPackagesSuspended not implemented");
5584     }
5585 
5586     /**
5587      * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String)
5588      * @param packageName The name of the package to get the suspended status of.
5589      * @param userId The user id.
5590      * @return {@code true} if the package is suspended or {@code false} if the package is not
5591      * suspended.
5592      * @throws IllegalArgumentException if the package was not found.
5593      * @hide
5594      */
isPackageSuspendedForUser(String packageName, int userId)5595     public abstract boolean isPackageSuspendedForUser(String packageName, int userId);
5596 
5597     /**
5598      * Query if an app is currently suspended.
5599      *
5600      * @return {@code true} if the given package is suspended, {@code false} otherwise
5601      * @throws NameNotFoundException if the package could not be found.
5602      *
5603      * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String)
5604      * @hide
5605      */
5606     @SystemApi
isPackageSuspended(String packageName)5607     public boolean isPackageSuspended(String packageName) throws NameNotFoundException {
5608         throw new UnsupportedOperationException("isPackageSuspended not implemented");
5609     }
5610 
5611     /**
5612      * Apps can query this to know if they have been suspended. A system app with the permission
5613      * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state.
5614      *
5615      * <p>While in this state, the application's notifications will be hidden, any of its started
5616      * activities will be stopped and it will not be able to show toasts or dialogs or ring the
5617      * device. When the user tries to launch a suspended app, the system will, instead, show a
5618      * dialog to the user informing them that they cannot use this app while it is suspended.
5619      *
5620      * <p>When an app is put into this state, the broadcast action
5621      * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast
5622      * receivers that included this action in their intent-filters, <em>including manifest
5623      * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED}
5624      * is delivered when a previously suspended app is taken out of this state.
5625      * </p>
5626      *
5627      * @return {@code true} if the calling package has been suspended, {@code false} otherwise.
5628      *
5629      * @see #getSuspendedPackageAppExtras()
5630      * @see Intent#ACTION_MY_PACKAGE_SUSPENDED
5631      * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED
5632      */
isPackageSuspended()5633     public boolean isPackageSuspended() {
5634         throw new UnsupportedOperationException("isPackageSuspended not implemented");
5635     }
5636 
5637     /**
5638      * Returns a {@link Bundle} of extras that was meant to be sent to the calling app when it was
5639      * suspended. An app with the permission {@code android.permission.SUSPEND_APPS} can supply this
5640      * to the system at the time of suspending an app.
5641      *
5642      * <p>This is the same {@link Bundle} that is sent along with the broadcast
5643      * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED}, whenever the app is suspended. The contents of
5644      * this {@link Bundle} are a contract between the suspended app and the suspending app.
5645      *
5646      * <p>Note: These extras are optional, so if no extras were supplied to the system, this method
5647      * will return {@code null}, even when the calling app has been suspended.
5648      *
5649      * @return A {@link Bundle} containing the extras for the app, or {@code null} if the
5650      * package is not currently suspended.
5651      *
5652      * @see #isPackageSuspended()
5653      * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED
5654      * @see Intent#ACTION_MY_PACKAGE_SUSPENDED
5655      * @see Intent#EXTRA_SUSPENDED_PACKAGE_EXTRAS
5656      */
getSuspendedPackageAppExtras()5657     public @Nullable Bundle getSuspendedPackageAppExtras() {
5658         throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented");
5659     }
5660 
5661     /**
5662      * Provide a hint of what the {@link ApplicationInfo#category} value should
5663      * be for the given package.
5664      * <p>
5665      * This hint can only be set by the app which installed this package, as
5666      * determined by {@link #getInstallerPackageName(String)}.
5667      *
5668      * @param packageName the package to change the category hint for.
5669      * @param categoryHint the category hint to set.
5670      */
setApplicationCategoryHint(@onNull String packageName, @ApplicationInfo.Category int categoryHint)5671     public abstract void setApplicationCategoryHint(@NonNull String packageName,
5672             @ApplicationInfo.Category int categoryHint);
5673 
5674     /** {@hide} */
isMoveStatusFinished(int status)5675     public static boolean isMoveStatusFinished(int status) {
5676         return (status < 0 || status > 100);
5677     }
5678 
5679     /** {@hide} */
5680     public static abstract class MoveCallback {
onCreated(int moveId, Bundle extras)5681         public void onCreated(int moveId, Bundle extras) {}
onStatusChanged(int moveId, int status, long estMillis)5682         public abstract void onStatusChanged(int moveId, int status, long estMillis);
5683     }
5684 
5685     /** {@hide} */
getMoveStatus(int moveId)5686     public abstract int getMoveStatus(int moveId);
5687 
5688     /** {@hide} */
registerMoveCallback(MoveCallback callback, Handler handler)5689     public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5690     /** {@hide} */
unregisterMoveCallback(MoveCallback callback)5691     public abstract void unregisterMoveCallback(MoveCallback callback);
5692 
5693     /** {@hide} */
movePackage(String packageName, VolumeInfo vol)5694     public abstract int movePackage(String packageName, VolumeInfo vol);
5695     /** {@hide} */
getPackageCurrentVolume(ApplicationInfo app)5696     public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5697     /** {@hide} */
getPackageCandidateVolumes(ApplicationInfo app)5698     public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5699 
5700     /** {@hide} */
movePrimaryStorage(VolumeInfo vol)5701     public abstract int movePrimaryStorage(VolumeInfo vol);
5702     /** {@hide} */
getPrimaryStorageCurrentVolume()5703     public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5704     /** {@hide} */
getPrimaryStorageCandidateVolumes()5705     public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
5706 
5707     /**
5708      * Returns the device identity that verifiers can use to associate their scheme to a particular
5709      * device. This should not be used by anything other than a package verifier.
5710      *
5711      * @return identity that uniquely identifies current device
5712      * @hide
5713      */
getVerifierDeviceIdentity()5714     public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
5715 
5716     /**
5717      * Returns true if the device is upgrading, such as first boot after OTA.
5718      *
5719      * @hide
5720      */
isUpgrade()5721     public abstract boolean isUpgrade();
5722 
5723     /**
5724      * Return interface that offers the ability to install, upgrade, and remove
5725      * applications on the device.
5726      */
getPackageInstaller()5727     public abstract @NonNull PackageInstaller getPackageInstaller();
5728 
5729     /**
5730      * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5731      * intents sent from the user with id sourceUserId can also be be resolved
5732      * by activities in the user with id targetUserId if they match the
5733      * specified intent filter.
5734      *
5735      * @param filter The {@link IntentFilter} the intent has to match
5736      * @param sourceUserId The source user id.
5737      * @param targetUserId The target user id.
5738      * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5739      *            {@link #ONLY_IF_NO_MATCH_FOUND}.
5740      * @hide
5741      */
addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, int targetUserId, int flags)5742     public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5743             int targetUserId, int flags);
5744 
5745     /**
5746      * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5747      * as their source, and have been set by the app calling this method.
5748      *
5749      * @param sourceUserId The source user id.
5750      * @hide
5751      */
clearCrossProfileIntentFilters(int sourceUserId)5752     public abstract void clearCrossProfileIntentFilters(int sourceUserId);
5753 
5754     /**
5755      * @hide
5756      */
loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo)5757     public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5758 
5759     /**
5760      * @hide
5761      */
loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo)5762     public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5763 
5764     /** {@hide} */
isPackageAvailable(String packageName)5765     public abstract boolean isPackageAvailable(String packageName);
5766 
5767     /** {@hide} */
installStatusToString(int status, String msg)5768     public static String installStatusToString(int status, String msg) {
5769         final String str = installStatusToString(status);
5770         if (msg != null) {
5771             return str + ": " + msg;
5772         } else {
5773             return str;
5774         }
5775     }
5776 
5777     /** {@hide} */
installStatusToString(int status)5778     public static String installStatusToString(int status) {
5779         switch (status) {
5780             case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5781             case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5782             case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5783             case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5784             case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5785             case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5786             case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5787             case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5788             case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5789             case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5790             case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5791             case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5792             case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5793             case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5794             case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5795             case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5796             case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5797             case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5798             case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5799             case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5800             case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5801             case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5802             case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5803             case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5804             case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5805             case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5806             case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5807             case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5808             case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5809             case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5810             case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5811             case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5812             case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5813             case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5814             case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5815             case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5816             case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5817             case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5818             case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5819             case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
5820             case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
5821             case INSTALL_FAILED_BAD_DEX_METADATA:
5822                 return "INSTALL_FAILED_BAD_DEX_METADATA";
5823             default: return Integer.toString(status);
5824         }
5825     }
5826 
5827     /** {@hide} */
installStatusToPublicStatus(int status)5828     public static int installStatusToPublicStatus(int status) {
5829         switch (status) {
5830             case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5831             case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5832             case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5833             case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5834             case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5835             case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5836             case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5837             case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5838             case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5839             case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5840             case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5841             case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5842             case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5843             case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5844             case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5845             case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5846             case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5847             case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5848             case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5849             case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5850             case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5851             case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5852             case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5853             case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5854             case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5855             case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5856             case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5857             case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5858             case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5859             case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5860             case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5861             case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5862             case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5863             case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5864             case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5865             case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5866             case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
5867             case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID;
5868             case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5869             case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5870             case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5871             case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5872             case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5873             default: return PackageInstaller.STATUS_FAILURE;
5874         }
5875     }
5876 
5877     /** {@hide} */
deleteStatusToString(int status, String msg)5878     public static String deleteStatusToString(int status, String msg) {
5879         final String str = deleteStatusToString(status);
5880         if (msg != null) {
5881             return str + ": " + msg;
5882         } else {
5883             return str;
5884         }
5885     }
5886 
5887     /** {@hide} */
deleteStatusToString(int status)5888     public static String deleteStatusToString(int status) {
5889         switch (status) {
5890             case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5891             case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5892             case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5893             case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5894             case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
5895             case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
5896             case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY";
5897             default: return Integer.toString(status);
5898         }
5899     }
5900 
5901     /** {@hide} */
deleteStatusToPublicStatus(int status)5902     public static int deleteStatusToPublicStatus(int status) {
5903         switch (status) {
5904             case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5905             case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5906             case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5907             case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5908             case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5909             case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5910             case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5911             default: return PackageInstaller.STATUS_FAILURE;
5912         }
5913     }
5914 
5915     /** {@hide} */
permissionFlagToString(int flag)5916     public static String permissionFlagToString(int flag) {
5917         switch (flag) {
5918             case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
5919             case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
5920             case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
5921             case FLAG_PERMISSION_USER_SET: return "USER_SET";
5922             case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
5923             case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
5924             case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
5925             default: return Integer.toString(flag);
5926         }
5927     }
5928 
5929     /** {@hide} */
5930     public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
5931         private final IPackageDeleteObserver mLegacy;
5932 
LegacyPackageDeleteObserver(IPackageDeleteObserver legacy)5933         public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
5934             mLegacy = legacy;
5935         }
5936 
5937         @Override
onPackageDeleted(String basePackageName, int returnCode, String msg)5938         public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
5939             if (mLegacy == null) return;
5940             try {
5941                 mLegacy.packageDeleted(basePackageName, returnCode);
5942             } catch (RemoteException ignored) {
5943             }
5944         }
5945     }
5946 
5947     /**
5948      * Return the install reason that was recorded when a package was first
5949      * installed for a specific user. Requesting the install reason for another
5950      * user will require the permission INTERACT_ACROSS_USERS_FULL.
5951      *
5952      * @param packageName The package for which to retrieve the install reason
5953      * @param user The user for whom to retrieve the install reason
5954      * @return The install reason. If the package is not installed for the given
5955      *         user, {@code INSTALL_REASON_UNKNOWN} is returned.
5956      * @hide
5957      */
5958     @TestApi
getInstallReason(String packageName, @NonNull UserHandle user)5959     public abstract @InstallReason int getInstallReason(String packageName,
5960             @NonNull UserHandle user);
5961 
5962     /**
5963      * Checks whether the calling package is allowed to request package installs through package
5964      * installer. Apps are encouraged to call this API before launching the package installer via
5965      * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the
5966      * user can explicitly choose what external sources they trust to install apps on the device.
5967      * If this API returns false, the install request will be blocked by the package installer and
5968      * a dialog will be shown to the user with an option to launch settings to change their
5969      * preference. An application must target Android O or higher and declare permission
5970      * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API.
5971      *
5972      * @return true if the calling package is trusted by the user to request install packages on
5973      * the device, false otherwise.
5974      * @see android.content.Intent#ACTION_INSTALL_PACKAGE
5975      * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES
5976      */
canRequestPackageInstalls()5977     public abstract boolean canRequestPackageInstalls();
5978 
5979     /**
5980      * Return the {@link ComponentName} of the activity providing Settings for the Instant App
5981      * resolver.
5982      *
5983      * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS}
5984      * @hide
5985      */
5986     @SystemApi
getInstantAppResolverSettingsComponent()5987     public abstract ComponentName getInstantAppResolverSettingsComponent();
5988 
5989     /**
5990      * Return the {@link ComponentName} of the activity responsible for installing instant
5991      * applications.
5992      *
5993      * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE}
5994      * @hide
5995      */
5996     @SystemApi
getInstantAppInstallerComponent()5997     public abstract ComponentName getInstantAppInstallerComponent();
5998 
5999     /**
6000      * Return the Android Id for a given Instant App.
6001      *
6002      * @see {@link android.provider.Settings.Secure#ANDROID_ID}
6003      * @hide
6004      */
getInstantAppAndroidId(String packageName, @NonNull UserHandle user)6005     public abstract String getInstantAppAndroidId(String packageName, @NonNull UserHandle user);
6006 
6007     /**
6008      * Callback use to notify the callers of module registration that the operation
6009      * has finished.
6010      *
6011      * @hide
6012      */
6013     @SystemApi
6014     public static abstract class DexModuleRegisterCallback {
onDexModuleRegistered(String dexModulePath, boolean success, String message)6015         public abstract void onDexModuleRegistered(String dexModulePath, boolean success,
6016                 String message);
6017     }
6018 
6019     /**
6020      * Register an application dex module with the package manager.
6021      * The package manager will keep track of the given module for future optimizations.
6022      *
6023      * Dex module optimizations will disable the classpath checking at runtime. The client bares
6024      * the responsibility to ensure that the static assumptions on classes in the optimized code
6025      * hold at runtime (e.g. there's no duplicate classes in the classpath).
6026      *
6027      * Note that the package manager already keeps track of dex modules loaded with
6028      * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}.
6029      * This can be called for an eager registration.
6030      *
6031      * The call might take a while and the results will be posted on the main thread, using
6032      * the given callback.
6033      *
6034      * If the module is intended to be shared with other apps, make sure that the file
6035      * permissions allow for it.
6036      * If at registration time the permissions allow for others to read it, the module would
6037      * be marked as a shared module which might undergo a different optimization strategy.
6038      * (usually shared modules will generated larger optimizations artifacts,
6039      * taking more disk space).
6040      *
6041      * @param dexModulePath the absolute path of the dex module.
6042      * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will
6043      *                 be called once the registration finishes.
6044      *
6045      * @hide
6046      */
6047     @SystemApi
registerDexModule(String dexModulePath, @Nullable DexModuleRegisterCallback callback)6048     public abstract void registerDexModule(String dexModulePath,
6049             @Nullable DexModuleRegisterCallback callback);
6050 
6051     /**
6052      * Returns the {@link ArtManager} associated with this package manager.
6053      *
6054      * @hide
6055      */
6056     @SystemApi
getArtManager()6057     public @NonNull ArtManager getArtManager() {
6058         throw new UnsupportedOperationException("getArtManager not implemented in subclass");
6059     }
6060 
6061     /**
6062      * Sets or clears the harmful app warning details for the given app.
6063      *
6064      * When set, any attempt to launch an activity in this package will be intercepted and a
6065      * warning dialog will be shown to the user instead, with the given warning. The user
6066      * will have the option to proceed with the activity launch, or to uninstall the application.
6067      *
6068      * @param packageName The full name of the package to warn on.
6069      * @param warning A warning string to display to the user describing the threat posed by the
6070      *                application, or null to clear the warning.
6071      *
6072      * @hide
6073      */
6074     @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
6075     @SystemApi
setHarmfulAppWarning(@onNull String packageName, @Nullable CharSequence warning)6076     public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) {
6077         throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass");
6078     }
6079 
6080     /**
6081      * Returns the harmful app warning string for the given app, or null if there is none set.
6082      *
6083      * @param packageName The full name of the desired package.
6084      *
6085      * @hide
6086      */
6087     @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS)
6088     @Nullable
6089     @SystemApi
getHarmfulAppWarning(@onNull String packageName)6090     public CharSequence getHarmfulAppWarning(@NonNull String packageName) {
6091         throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass");
6092     }
6093 
6094     /** @hide */
6095     @IntDef(prefix = { "CERT_INPUT_" }, value = {
6096             CERT_INPUT_RAW_X509,
6097             CERT_INPUT_SHA256
6098     })
6099     @Retention(RetentionPolicy.SOURCE)
6100     public @interface CertificateInputType {}
6101 
6102     /**
6103      * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could
6104      * be generated using an {@code CertificateFactory}
6105      */
6106     public static final int CERT_INPUT_RAW_X509 = 0;
6107 
6108     /**
6109      * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509
6110      * Certificate.
6111      */
6112     public static final int CERT_INPUT_SHA256 = 1;
6113 
6114     /**
6115      * Searches the set of signing certificates by which the given package has proven to have been
6116      * signed.  This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
6117      * since it takes into account the possibility of signing certificate rotation, except in the
6118      * case of packages that are signed by multiple certificates, for which signing certificate
6119      * rotation is not supported.  This method is analogous to using {@code getPackageInfo} with
6120      * {@code GET_SIGNING_CERTIFICATES} and then searching through the resulting {@code
6121      * signingInfo} field to see if the desired certificate is present.
6122      *
6123      * @param packageName package whose signing certificates to check
6124      * @param certificate signing certificate for which to search
6125      * @param type representation of the {@code certificate}
6126      * @return true if this package was or is signed by exactly the certificate {@code certificate}
6127      */
hasSigningCertificate( String packageName, byte[] certificate, @CertificateInputType int type)6128     public boolean hasSigningCertificate(
6129             String packageName, byte[] certificate, @CertificateInputType int type) {
6130         throw new UnsupportedOperationException(
6131                 "hasSigningCertificate not implemented in subclass");
6132     }
6133 
6134     /**
6135      * Searches the set of signing certificates by which the package(s) for the given uid has proven
6136      * to have been signed.  For multiple packages sharing the same uid, this will return the
6137      * signing certificates found in the signing history of the "newest" package, where "newest"
6138      * indicates the package with the newest signing certificate in the shared uid group.  This
6139      * method should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES}
6140      * since it takes into account the possibility of signing certificate rotation, except in the
6141      * case of packages that are signed by multiple certificates, for which signing certificate
6142      * rotation is not supported. This method is analogous to using {@code getPackagesForUid}
6143      * followed by {@code getPackageInfo} with {@code GET_SIGNING_CERTIFICATES}, selecting the
6144      * {@code PackageInfo} of the newest-signed bpackage , and finally searching through the
6145      * resulting {@code signingInfo} field to see if the desired certificate is there.
6146      *
6147      * @param uid uid whose signing certificates to check
6148      * @param certificate signing certificate for which to search
6149      * @param type representation of the {@code certificate}
6150      * @return true if this package was or is signed by exactly the certificate {@code certificate}
6151      */
hasSigningCertificate( int uid, byte[] certificate, @CertificateInputType int type)6152     public boolean hasSigningCertificate(
6153             int uid, byte[] certificate, @CertificateInputType int type) {
6154         throw new UnsupportedOperationException(
6155                 "hasSigningCertificate not implemented in subclass");
6156     }
6157 
6158     /**
6159      * @return the system defined text classifier package name, or null if there's none.
6160      *
6161      * @hide
6162      */
getSystemTextClassifierPackageName()6163     public String getSystemTextClassifierPackageName() {
6164         throw new UnsupportedOperationException(
6165                 "getSystemTextClassifierPackageName not implemented in subclass");
6166     }
6167 
6168     /**
6169      * @return whether a given package's state is protected, e.g. package cannot be disabled,
6170      *         suspended, hidden or force stopped.
6171      *
6172      * @hide
6173      */
isPackageStateProtected(String packageName, int userId)6174     public boolean isPackageStateProtected(String packageName, int userId) {
6175         throw new UnsupportedOperationException(
6176             "isPackageStateProtected not implemented in subclass");
6177     }
6178 
6179 }
6180