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