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