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