PackageManager.java revision a0688e0321a3c911080d7a5a4ae7bf196198c319
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    @SdkConstant(SdkConstantType.FEATURE)
2333    public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt";
2334
2335
2336    /**
2337     * Feature for {@link #getSystemAvailableFeatures} and
2338     * {@link #hasSystemFeature}: The device supports LoWPAN networking.
2339     * @hide
2340     */
2341    @SdkConstant(SdkConstantType.FEATURE)
2342    public static final String FEATURE_LOWPAN = "android.hardware.lowpan";
2343
2344    /**
2345     * Feature for {@link #getSystemAvailableFeatures} and
2346     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2347     * on a vehicle headunit. A headunit here is defined to be inside a
2348     * vehicle that may or may not be moving. A headunit uses either a
2349     * primary display in the center console and/or additional displays in
2350     * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
2351     * have limited size and resolution. The user will likely be focused on
2352     * driving so limiting driver distraction is a primary concern. User input
2353     * can be a variety of hard buttons, touch, rotary controllers and even mouse-
2354     * like interfaces.
2355     */
2356    @SdkConstant(SdkConstantType.FEATURE)
2357    public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
2358
2359    /**
2360     * Feature for {@link #getSystemAvailableFeatures} and
2361     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2362     * on a television.  Television here is defined to be a typical living
2363     * room television experience: displayed on a big screen, where the user
2364     * is sitting far away from it, and the dominant form of input will be
2365     * something like a DPAD, not through touch or mouse.
2366     * @deprecated use {@link #FEATURE_LEANBACK} instead.
2367     */
2368    @Deprecated
2369    @SdkConstant(SdkConstantType.FEATURE)
2370    public static final String FEATURE_TELEVISION = "android.hardware.type.television";
2371
2372    /**
2373     * Feature for {@link #getSystemAvailableFeatures} and
2374     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2375     * on a watch. A watch here is defined to be a device worn on the body, perhaps on
2376     * the wrist. The user is very close when interacting with the device.
2377     */
2378    @SdkConstant(SdkConstantType.FEATURE)
2379    public static final String FEATURE_WATCH = "android.hardware.type.watch";
2380
2381    /**
2382     * Feature for {@link #getSystemAvailableFeatures} and
2383     * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded
2384     * device is defined as a full stack Android device with or without a display and no
2385     * user-installable apps.
2386     */
2387    @SdkConstant(SdkConstantType.FEATURE)
2388    public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded";
2389
2390    /**
2391     * Feature for {@link #getSystemAvailableFeatures} and
2392     * {@link #hasSystemFeature}: This is a device dedicated to be primarily used
2393     * with keyboard, mouse or touchpad. This includes traditional desktop
2394     * computers, laptops and variants such as convertibles or detachables.
2395     * Due to the larger screen, the device will most likely use the
2396     * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well.
2397     */
2398    @SdkConstant(SdkConstantType.FEATURE)
2399    public static final String FEATURE_PC = "android.hardware.type.pc";
2400
2401    /**
2402     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2403     * The device supports printing.
2404     */
2405    @SdkConstant(SdkConstantType.FEATURE)
2406    public static final String FEATURE_PRINTING = "android.software.print";
2407
2408    /**
2409     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2410     * The device supports {@link android.companion.CompanionDeviceManager#associate associating}
2411     * with devices via {@link android.companion.CompanionDeviceManager}.
2412     */
2413    @SdkConstant(SdkConstantType.FEATURE)
2414    public static final String FEATURE_COMPANION_DEVICE_SETUP
2415            = "android.software.companion_device_setup";
2416
2417    /**
2418     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2419     * The device can perform backup and restore operations on installed applications.
2420     */
2421    @SdkConstant(SdkConstantType.FEATURE)
2422    public static final String FEATURE_BACKUP = "android.software.backup";
2423
2424    /**
2425     * Feature for {@link #getSystemAvailableFeatures} and
2426     * {@link #hasSystemFeature}: The device supports freeform window management.
2427     * Windows have title bars and can be moved and resized.
2428     */
2429    // If this feature is present, you also need to set
2430    // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay.
2431    @SdkConstant(SdkConstantType.FEATURE)
2432    public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
2433            = "android.software.freeform_window_management";
2434
2435    /**
2436     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2437     * The device supports picture-in-picture multi-window mode.
2438     */
2439    @SdkConstant(SdkConstantType.FEATURE)
2440    public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
2441
2442    /**
2443     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2444     * The device supports running activities on secondary displays.
2445     */
2446    @SdkConstant(SdkConstantType.FEATURE)
2447    public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS
2448            = "android.software.activities_on_secondary_displays";
2449
2450    /**
2451     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2452     * The device supports creating secondary users and managed profiles via
2453     * {@link DevicePolicyManager}.
2454     */
2455    @SdkConstant(SdkConstantType.FEATURE)
2456    public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
2457
2458    /**
2459     * @hide
2460     * TODO: Remove after dependencies updated b/17392243
2461     */
2462    public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
2463
2464    /**
2465     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2466     * The device supports verified boot.
2467     */
2468    @SdkConstant(SdkConstantType.FEATURE)
2469    public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
2470
2471    /**
2472     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2473     * The device supports secure removal of users. When a user is deleted the data associated
2474     * with that user is securely deleted and no longer available.
2475     */
2476    @SdkConstant(SdkConstantType.FEATURE)
2477    public static final String FEATURE_SECURELY_REMOVES_USERS
2478            = "android.software.securely_removes_users";
2479
2480    /** {@hide} */
2481    @SdkConstant(SdkConstantType.FEATURE)
2482    public static final String FEATURE_FILE_BASED_ENCRYPTION
2483            = "android.software.file_based_encryption";
2484
2485    /**
2486     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2487     * The device has a full implementation of the android.webkit.* APIs. Devices
2488     * lacking this feature will not have a functioning WebView implementation.
2489     */
2490    @SdkConstant(SdkConstantType.FEATURE)
2491    public static final String FEATURE_WEBVIEW = "android.software.webview";
2492
2493    /**
2494     * Feature for {@link #getSystemAvailableFeatures} and
2495     * {@link #hasSystemFeature}: This device supports ethernet.
2496     */
2497    @SdkConstant(SdkConstantType.FEATURE)
2498    public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
2499
2500    /**
2501     * Feature for {@link #getSystemAvailableFeatures} and
2502     * {@link #hasSystemFeature}: This device supports HDMI-CEC.
2503     * @hide
2504     */
2505    @SdkConstant(SdkConstantType.FEATURE)
2506    public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
2507
2508    /**
2509     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2510     * The device has all of the inputs necessary to be considered a compatible game controller, or
2511     * includes a compatible game controller in the box.
2512     */
2513    @SdkConstant(SdkConstantType.FEATURE)
2514    public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
2515
2516    /**
2517     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2518     * The device has a full implementation of the android.media.midi.* APIs.
2519     */
2520    @SdkConstant(SdkConstantType.FEATURE)
2521    public static final String FEATURE_MIDI = "android.software.midi";
2522
2523    /**
2524     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2525     * The device implements an optimized mode for virtual reality (VR) applications that handles
2526     * stereoscopic rendering of notifications, and disables most monocular system UI components
2527     * while a VR application has user focus.
2528     * Devices declaring this feature must include an application implementing a
2529     * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2530     * {@link android.app.Activity#setVrModeEnabled}.
2531     */
2532    @SdkConstant(SdkConstantType.FEATURE)
2533    public static final String FEATURE_VR_MODE = "android.software.vr.mode";
2534
2535    /**
2536     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2537     * The device implements {@link #FEATURE_VR_MODE} but additionally meets extra CDD requirements
2538     * to provide a high-quality VR experience.  In general, devices declaring this feature will
2539     * additionally:
2540     * <ul>
2541     *   <li>Deliver consistent performance at a high framerate over an extended period of time
2542     *   for typical VR application CPU/GPU workloads with a minimal number of frame drops for VR
2543     *   applications that have called
2544     *   {@link android.view.Window#setSustainedPerformanceMode}.</li>
2545     *   <li>Implement {@link #FEATURE_HIFI_SENSORS} and have a low sensor latency.</li>
2546     *   <li>Include optimizations to lower display persistence while running VR applications.</li>
2547     *   <li>Implement an optimized render path to minimize latency to draw to the device's main
2548     *   display.</li>
2549     *   <li>Include the following EGL extensions: EGL_ANDROID_create_native_client_buffer,
2550     *   EGL_ANDROID_front_buffer_auto_refresh, EGL_EXT_protected_content,
2551     *   EGL_KHR_mutable_render_buffer, EGL_KHR_reusable_sync, and EGL_KHR_wait_sync.</li>
2552     *   <li>Provide at least one CPU core that is reserved for use solely by the top, foreground
2553     *   VR application process for critical render threads while such an application is
2554     *   running.</li>
2555     * </ul>
2556     */
2557    @SdkConstant(SdkConstantType.FEATURE)
2558    public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
2559            = "android.hardware.vr.high_performance";
2560
2561    /**
2562     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2563     * The device supports autofill of user credentials, addresses, credit cards, etc
2564     * via integration with {@link android.service.autofill.AutofillService autofill
2565     * providers}.
2566     */
2567    @SdkConstant(SdkConstantType.FEATURE)
2568    public static final String FEATURE_AUTOFILL = "android.software.autofill";
2569
2570    /**
2571     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2572     * The device implements headtracking suitable for a VR device.
2573     */
2574    @SdkConstant(SdkConstantType.FEATURE)
2575    public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking";
2576
2577    /**
2578     * Action to external storage service to clean out removed apps.
2579     * @hide
2580     */
2581    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
2582            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
2583
2584    /**
2585     * Extra field name for the URI to a verification file. Passed to a package
2586     * verifier.
2587     *
2588     * @hide
2589     */
2590    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
2591
2592    /**
2593     * Extra field name for the ID of a package pending verification. Passed to
2594     * a package verifier and is used to call back to
2595     * {@link PackageManager#verifyPendingInstall(int, int)}
2596     */
2597    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
2598
2599    /**
2600     * Extra field name for the package identifier which is trying to install
2601     * the package.
2602     *
2603     * @hide
2604     */
2605    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
2606            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
2607
2608    /**
2609     * Extra field name for the requested install flags for a package pending
2610     * verification. Passed to a package verifier.
2611     *
2612     * @hide
2613     */
2614    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
2615            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
2616
2617    /**
2618     * Extra field name for the uid of who is requesting to install
2619     * the package.
2620     *
2621     * @hide
2622     */
2623    public static final String EXTRA_VERIFICATION_INSTALLER_UID
2624            = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
2625
2626    /**
2627     * Extra field name for the package name of a package pending verification.
2628     *
2629     * @hide
2630     */
2631    public static final String EXTRA_VERIFICATION_PACKAGE_NAME
2632            = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
2633    /**
2634     * Extra field name for the result of a verification, either
2635     * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
2636     * Passed to package verifiers after a package is verified.
2637     */
2638    public static final String EXTRA_VERIFICATION_RESULT
2639            = "android.content.pm.extra.VERIFICATION_RESULT";
2640
2641    /**
2642     * Extra field name for the version code of a package pending verification.
2643     * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead.
2644     * @hide
2645     */
2646    @Deprecated
2647    public static final String EXTRA_VERIFICATION_VERSION_CODE
2648            = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
2649
2650    /**
2651     * Extra field name for the long version code of a package pending verification.
2652     *
2653     * @hide
2654     */
2655    public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE =
2656            "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE";
2657
2658    /**
2659     * Extra field name for the ID of a intent filter pending verification.
2660     * Passed to an intent filter verifier and is used to call back to
2661     * {@link #verifyIntentFilter}
2662     *
2663     * @hide
2664     */
2665    public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
2666            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
2667
2668    /**
2669     * Extra field name for the scheme used for an intent filter pending verification. Passed to
2670     * an intent filter verifier and is used to construct the URI to verify against.
2671     *
2672     * Usually this is "https"
2673     *
2674     * @hide
2675     */
2676    public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
2677            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
2678
2679    /**
2680     * Extra field name for the host names to be used for an intent filter pending verification.
2681     * Passed to an intent filter verifier and is used to construct the URI to verify the
2682     * intent filter.
2683     *
2684     * This is a space delimited list of hosts.
2685     *
2686     * @hide
2687     */
2688    public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
2689            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
2690
2691    /**
2692     * Extra field name for the package name to be used for an intent filter pending verification.
2693     * Passed to an intent filter verifier and is used to check the verification responses coming
2694     * from the hosts. Each host response will need to include the package name of APK containing
2695     * the intent filter.
2696     *
2697     * @hide
2698     */
2699    public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
2700            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
2701
2702    /**
2703     * The action used to request that the user approve a permission request
2704     * from the application.
2705     *
2706     * @hide
2707     */
2708    @SystemApi
2709    public static final String ACTION_REQUEST_PERMISSIONS =
2710            "android.content.pm.action.REQUEST_PERMISSIONS";
2711
2712    /**
2713     * The names of the requested permissions.
2714     * <p>
2715     * <strong>Type:</strong> String[]
2716     * </p>
2717     *
2718     * @hide
2719     */
2720    @SystemApi
2721    public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
2722            "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
2723
2724    /**
2725     * The results from the permissions request.
2726     * <p>
2727     * <strong>Type:</strong> int[] of #PermissionResult
2728     * </p>
2729     *
2730     * @hide
2731     */
2732    @SystemApi
2733    public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
2734            = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
2735
2736    /**
2737     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2738     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
2739     * the existing definition for the permission.
2740     * @hide
2741     */
2742    public static final String EXTRA_FAILURE_EXISTING_PACKAGE
2743            = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
2744
2745    /**
2746     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2747     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
2748     * being redundantly defined by the package being installed.
2749     * @hide
2750     */
2751    public static final String EXTRA_FAILURE_EXISTING_PERMISSION
2752            = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
2753
2754   /**
2755    * Permission flag: The permission is set in its current state
2756    * by the user and apps can still request it at runtime.
2757    *
2758    * @hide
2759    */
2760    @SystemApi
2761    public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
2762
2763    /**
2764     * Permission flag: The permission is set in its current state
2765     * by the user and it is fixed, i.e. apps can no longer request
2766     * this permission.
2767     *
2768     * @hide
2769     */
2770    @SystemApi
2771    public static final int FLAG_PERMISSION_USER_FIXED =  1 << 1;
2772
2773    /**
2774     * Permission flag: The permission is set in its current state
2775     * by device policy and neither apps nor the user can change
2776     * its state.
2777     *
2778     * @hide
2779     */
2780    @SystemApi
2781    public static final int FLAG_PERMISSION_POLICY_FIXED =  1 << 2;
2782
2783    /**
2784     * Permission flag: The permission is set in a granted state but
2785     * access to resources it guards is restricted by other means to
2786     * enable revoking a permission on legacy apps that do not support
2787     * runtime permissions. If this permission is upgraded to runtime
2788     * because the app was updated to support runtime permissions, the
2789     * the permission will be revoked in the upgrade process.
2790     *
2791     * @hide
2792     */
2793    @SystemApi
2794    public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE =  1 << 3;
2795
2796    /**
2797     * Permission flag: The permission is set in its current state
2798     * because the app is a component that is a part of the system.
2799     *
2800     * @hide
2801     */
2802    @SystemApi
2803    public static final int FLAG_PERMISSION_SYSTEM_FIXED =  1 << 4;
2804
2805    /**
2806     * Permission flag: The permission is granted by default because it
2807     * enables app functionality that is expected to work out-of-the-box
2808     * for providing a smooth user experience. For example, the phone app
2809     * is expected to have the phone permission.
2810     *
2811     * @hide
2812     */
2813    @SystemApi
2814    public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
2815
2816    /**
2817     * Permission flag: The permission has to be reviewed before any of
2818     * the app components can run.
2819     *
2820     * @hide
2821     */
2822    @SystemApi
2823    public static final int FLAG_PERMISSION_REVIEW_REQUIRED =  1 << 6;
2824
2825    /**
2826     * Mask for all permission flags.
2827     *
2828     * @hide
2829     */
2830    @SystemApi
2831    public static final int MASK_PERMISSION_FLAGS = 0xFF;
2832
2833    /**
2834     * This is a library that contains components apps can invoke. For
2835     * example, a services for apps to bind to, or standard chooser UI,
2836     * etc. This library is versioned and backwards compatible. Clients
2837     * should check its version via {@link android.ext.services.Version
2838     * #getVersionCode()} and avoid calling APIs added in later versions.
2839     *
2840     * @hide
2841     */
2842    public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
2843
2844    /**
2845     * This is a library that contains components apps can dynamically
2846     * load. For example, new widgets, helper classes, etc. This library
2847     * is versioned and backwards compatible. Clients should check its
2848     * version via {@link android.ext.shared.Version#getVersionCode()}
2849     * and avoid calling APIs added in later versions.
2850     *
2851     * @hide
2852     */
2853    public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
2854
2855    /**
2856     * Used when starting a process for an Activity.
2857     *
2858     * @hide
2859     */
2860    public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
2861
2862    /**
2863     * Used when starting a process for a Service.
2864     *
2865     * @hide
2866     */
2867    public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
2868
2869    /**
2870     * Used when moving a Service to the foreground.
2871     *
2872     * @hide
2873     */
2874    public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
2875
2876    /**
2877     * Used when starting a process for a BroadcastReceiver.
2878     *
2879     * @hide
2880     */
2881    public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
2882
2883    /**
2884     * Used when starting a process for a ContentProvider.
2885     *
2886     * @hide
2887     */
2888    public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
2889
2890    /**
2891     * Used when starting a process for a BroadcastReceiver.
2892     *
2893     * @hide
2894     */
2895    public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
2896
2897    /**
2898     * Used with Context.getClassLoader() across Android packages.
2899     *
2900     * @hide
2901     */
2902    public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
2903
2904    /**
2905     * Used when starting a package within a process for Instrumentation.
2906     *
2907     * @hide
2908     */
2909    public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
2910
2911    /**
2912     * Total number of usage reasons.
2913     *
2914     * @hide
2915     */
2916    public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
2917
2918    /**
2919     * Constant for specifying the highest installed package version code.
2920     */
2921    public static final int VERSION_CODE_HIGHEST = -1;
2922
2923    /**
2924     * Retrieve overall information about an application package that is
2925     * installed on the system.
2926     *
2927     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2928     *            desired package.
2929     * @param flags Additional option flags to modify the data returned.
2930     * @return A PackageInfo object containing information about the package. If
2931     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
2932     *         is not found in the list of installed applications, the package
2933     *         information is retrieved from the list of uninstalled
2934     *         applications (which includes installed applications as well as
2935     *         applications with data directory i.e. applications which had been
2936     *         deleted with {@code DONT_DELETE_DATA} flag set).
2937     * @throws NameNotFoundException if a package with the given name cannot be
2938     *             found on the system.
2939     */
2940    public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags)
2941            throws NameNotFoundException;
2942
2943    /**
2944     * Retrieve overall information about an application package that is
2945     * installed on the system. This method can be used for retrieving
2946     * information about packages for which multiple versions can be installed
2947     * at the time. Currently only packages hosting static shared libraries can
2948     * have multiple installed versions. The method can also be used to get info
2949     * for a package that has a single version installed by passing
2950     * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage}
2951     * constructor.
2952     *
2953     * @param versionedPackage The versioned package for which to query.
2954     * @param flags Additional option flags to modify the data returned.
2955     * @return A PackageInfo object containing information about the package. If
2956     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
2957     *         is not found in the list of installed applications, the package
2958     *         information is retrieved from the list of uninstalled
2959     *         applications (which includes installed applications as well as
2960     *         applications with data directory i.e. applications which had been
2961     *         deleted with {@code DONT_DELETE_DATA} flag set).
2962     * @throws NameNotFoundException if a package with the given name cannot be
2963     *             found on the system.
2964     */
2965    public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage,
2966            @PackageInfoFlags int flags) throws NameNotFoundException;
2967
2968    /**
2969     * Retrieve overall information about an application package that is
2970     * installed on the system.
2971     *
2972     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2973     *            desired package.
2974     * @param flags Additional option flags to modify the data returned.
2975     * @param userId The user id.
2976     * @return A PackageInfo object containing information about the package. If
2977     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package
2978     *         is not found in the list of installed applications, the package
2979     *         information is retrieved from the list of uninstalled
2980     *         applications (which includes installed applications as well as
2981     *         applications with data directory i.e. applications which had been
2982     *         deleted with {@code DONT_DELETE_DATA} flag set).
2983     * @throws NameNotFoundException if a package with the given name cannot be
2984     *             found on the system.
2985     * @hide
2986     */
2987    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
2988    public abstract PackageInfo getPackageInfoAsUser(String packageName,
2989            @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
2990
2991    /**
2992     * Map from the current package names in use on the device to whatever
2993     * the current canonical name of that package is.
2994     * @param names Array of current names to be mapped.
2995     * @return Returns an array of the same size as the original, containing
2996     * the canonical name for each package.
2997     */
2998    public abstract String[] currentToCanonicalPackageNames(String[] names);
2999
3000    /**
3001     * Map from a packages canonical name to the current name in use on the device.
3002     * @param names Array of new names to be mapped.
3003     * @return Returns an array of the same size as the original, containing
3004     * the current name for each package.
3005     */
3006    public abstract String[] canonicalToCurrentPackageNames(String[] names);
3007
3008    /**
3009     * Returns a "good" intent to launch a front-door activity in a package.
3010     * This is used, for example, to implement an "open" button when browsing
3011     * through packages.  The current implementation looks first for a main
3012     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
3013     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
3014     * <code>null</code> if neither are found.
3015     *
3016     * @param packageName The name of the package to inspect.
3017     *
3018     * @return A fully-qualified {@link Intent} that can be used to launch the
3019     * main activity in the package. Returns <code>null</code> if the package
3020     * does not contain such an activity, or if <em>packageName</em> is not
3021     * recognized.
3022     */
3023    public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName);
3024
3025    /**
3026     * Return a "good" intent to launch a front-door Leanback activity in a
3027     * package, for use for example to implement an "open" button when browsing
3028     * through packages. The current implementation will look for a main
3029     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
3030     * return null if no main leanback activities are found.
3031     *
3032     * @param packageName The name of the package to inspect.
3033     * @return Returns either a fully-qualified Intent that can be used to launch
3034     *         the main Leanback activity in the package, or null if the package
3035     *         does not contain such an activity.
3036     */
3037    public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName);
3038
3039    /**
3040     * Return an array of all of the POSIX secondary group IDs that have been
3041     * assigned to the given package.
3042     * <p>
3043     * Note that the same package may have different GIDs under different
3044     * {@link UserHandle} on the same device.
3045     *
3046     * @param packageName The full name (i.e. com.google.apps.contacts) of the
3047     *            desired package.
3048     * @return Returns an int array of the assigned GIDs, or null if there are
3049     *         none.
3050     * @throws NameNotFoundException if a package with the given name cannot be
3051     *             found on the system.
3052     */
3053    public abstract int[] getPackageGids(@NonNull String packageName)
3054            throws NameNotFoundException;
3055
3056    /**
3057     * Return an array of all of the POSIX secondary group IDs that have been
3058     * assigned to the given package.
3059     * <p>
3060     * Note that the same package may have different GIDs under different
3061     * {@link UserHandle} on the same device.
3062     *
3063     * @param packageName The full name (i.e. com.google.apps.contacts) of the
3064     *            desired package.
3065     * @return Returns an int array of the assigned gids, or null if there are
3066     *         none.
3067     * @throws NameNotFoundException if a package with the given name cannot be
3068     *             found on the system.
3069     */
3070    public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
3071            throws NameNotFoundException;
3072
3073    /**
3074     * Return the UID associated with the given package name.
3075     * <p>
3076     * Note that the same package will have different UIDs under different
3077     * {@link UserHandle} on the same device.
3078     *
3079     * @param packageName The full name (i.e. com.google.apps.contacts) of the
3080     *            desired package.
3081     * @return Returns an integer UID who owns the given package name.
3082     * @throws NameNotFoundException if a package with the given name can not be
3083     *             found on the system.
3084     */
3085    public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
3086            throws NameNotFoundException;
3087
3088    /**
3089     * Return the UID associated with the given package name.
3090     * <p>
3091     * Note that the same package will have different UIDs under different
3092     * {@link UserHandle} on the same device.
3093     *
3094     * @param packageName The full name (i.e. com.google.apps.contacts) of the
3095     *            desired package.
3096     * @param userId The user handle identifier to look up the package under.
3097     * @return Returns an integer UID who owns the given package name.
3098     * @throws NameNotFoundException if a package with the given name can not be
3099     *             found on the system.
3100     * @hide
3101     */
3102    public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
3103            throws NameNotFoundException;
3104
3105    /**
3106     * Return the UID associated with the given package name.
3107     * <p>
3108     * Note that the same package will have different UIDs under different
3109     * {@link UserHandle} on the same device.
3110     *
3111     * @param packageName The full name (i.e. com.google.apps.contacts) of the
3112     *            desired package.
3113     * @param userId The user handle identifier to look up the package under.
3114     * @return Returns an integer UID who owns the given package name.
3115     * @throws NameNotFoundException if a package with the given name can not be
3116     *             found on the system.
3117     * @hide
3118     */
3119    public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
3120            @UserIdInt int userId) throws NameNotFoundException;
3121
3122    /**
3123     * Retrieve all of the information we know about a particular permission.
3124     *
3125     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
3126     *            of the permission you are interested in.
3127     * @param flags Additional option flags to modify the data returned.
3128     * @return Returns a {@link PermissionInfo} containing information about the
3129     *         permission.
3130     * @throws NameNotFoundException if a package with the given name cannot be
3131     *             found on the system.
3132     */
3133    public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
3134            throws NameNotFoundException;
3135
3136    /**
3137     * Query for all of the permissions associated with a particular group.
3138     *
3139     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
3140     *            of the permission group you are interested in. Use null to
3141     *            find all of the permissions not associated with a group.
3142     * @param flags Additional option flags to modify the data returned.
3143     * @return Returns a list of {@link PermissionInfo} containing information
3144     *         about all of the permissions in the given group.
3145     * @throws NameNotFoundException if a package with the given name cannot be
3146     *             found on the system.
3147     */
3148    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
3149            @PermissionInfoFlags int flags) throws NameNotFoundException;
3150
3151    /**
3152     * Returns true if Permission Review Mode is enabled, false otherwise.
3153     *
3154     * @hide
3155     */
3156    @TestApi
3157    public abstract boolean isPermissionReviewModeEnabled();
3158
3159    /**
3160     * Retrieve all of the information we know about a particular group of
3161     * permissions.
3162     *
3163     * @param name The fully qualified name (i.e.
3164     *            com.google.permission_group.APPS) of the permission you are
3165     *            interested in.
3166     * @param flags Additional option flags to modify the data returned.
3167     * @return Returns a {@link PermissionGroupInfo} containing information
3168     *         about the permission.
3169     * @throws NameNotFoundException if a package with the given name cannot be
3170     *             found on the system.
3171     */
3172    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
3173            @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
3174
3175    /**
3176     * Retrieve all of the known permission groups in the system.
3177     *
3178     * @param flags Additional option flags to modify the data returned.
3179     * @return Returns a list of {@link PermissionGroupInfo} containing
3180     *         information about all of the known permission groups.
3181     */
3182    public abstract List<PermissionGroupInfo> getAllPermissionGroups(
3183            @PermissionGroupInfoFlags int flags);
3184
3185    /**
3186     * Retrieve all of the information we know about a particular
3187     * package/application.
3188     *
3189     * @param packageName The full name (i.e. com.google.apps.contacts) of an
3190     *            application.
3191     * @param flags Additional option flags to modify the data returned.
3192     * @return An {@link ApplicationInfo} containing information about the
3193     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if
3194     *         the package is not found in the list of installed applications,
3195     *         the application information is retrieved from the list of
3196     *         uninstalled applications (which includes installed applications
3197     *         as well as applications with data directory i.e. applications
3198     *         which had been deleted with {@code DONT_DELETE_DATA} flag set).
3199     * @throws NameNotFoundException if a package with the given name cannot be
3200     *             found on the system.
3201     */
3202    public abstract ApplicationInfo getApplicationInfo(String packageName,
3203            @ApplicationInfoFlags int flags) throws NameNotFoundException;
3204
3205    /** {@hide} */
3206    public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
3207            @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
3208
3209    /**
3210     * Retrieve all of the information we know about a particular activity
3211     * class.
3212     *
3213     * @param component The full component name (i.e.
3214     *            com.google.apps.contacts/com.google.apps.contacts.
3215     *            ContactsList) of an Activity class.
3216     * @param flags Additional option flags to modify the data returned.
3217     * @return An {@link ActivityInfo} containing information about the
3218     *         activity.
3219     * @throws NameNotFoundException if a package with the given name cannot be
3220     *             found on the system.
3221     */
3222    public abstract ActivityInfo getActivityInfo(ComponentName component,
3223            @ComponentInfoFlags int flags) throws NameNotFoundException;
3224
3225    /**
3226     * Retrieve all of the information we know about a particular receiver
3227     * class.
3228     *
3229     * @param component The full component name (i.e.
3230     *            com.google.apps.calendar/com.google.apps.calendar.
3231     *            CalendarAlarm) of a Receiver class.
3232     * @param flags Additional option flags to modify the data returned.
3233     * @return An {@link ActivityInfo} containing information about the
3234     *         receiver.
3235     * @throws NameNotFoundException if a package with the given name cannot be
3236     *             found on the system.
3237     */
3238    public abstract ActivityInfo getReceiverInfo(ComponentName component,
3239            @ComponentInfoFlags int flags) throws NameNotFoundException;
3240
3241    /**
3242     * Retrieve all of the information we know about a particular service class.
3243     *
3244     * @param component The full component name (i.e.
3245     *            com.google.apps.media/com.google.apps.media.
3246     *            BackgroundPlayback) of a Service class.
3247     * @param flags Additional option flags to modify the data returned.
3248     * @return A {@link ServiceInfo} object containing information about the
3249     *         service.
3250     * @throws NameNotFoundException if a package with the given name cannot be
3251     *             found on the system.
3252     */
3253    public abstract ServiceInfo getServiceInfo(ComponentName component,
3254            @ComponentInfoFlags int flags) throws NameNotFoundException;
3255
3256    /**
3257     * Retrieve all of the information we know about a particular content
3258     * provider class.
3259     *
3260     * @param component The full component name (i.e.
3261     *            com.google.providers.media/com.google.providers.media.
3262     *            MediaProvider) of a ContentProvider class.
3263     * @param flags Additional option flags to modify the data returned.
3264     * @return A {@link ProviderInfo} object containing information about the
3265     *         provider.
3266     * @throws NameNotFoundException if a package with the given name cannot be
3267     *             found on the system.
3268     */
3269    public abstract ProviderInfo getProviderInfo(ComponentName component,
3270            @ComponentInfoFlags int flags) throws NameNotFoundException;
3271
3272    /**
3273     * Return a List of all packages that are installed on the device.
3274     *
3275     * @param flags Additional option flags to modify the data returned.
3276     * @return A List of PackageInfo objects, one for each installed package,
3277     *         containing information about the package. In the unlikely case
3278     *         there are no installed packages, an empty list is returned. If
3279     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3280     *         information is retrieved from the list of uninstalled
3281     *         applications (which includes installed applications as well as
3282     *         applications with data directory i.e. applications which had been
3283     *         deleted with {@code DONT_DELETE_DATA} flag set).
3284     */
3285    public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
3286
3287    /**
3288     * Return a List of all installed packages that are currently holding any of
3289     * the given permissions.
3290     *
3291     * @param flags Additional option flags to modify the data returned.
3292     * @return A List of PackageInfo objects, one for each installed package
3293     *         that holds any of the permissions that were provided, containing
3294     *         information about the package. If no installed packages hold any
3295     *         of the permissions, an empty list is returned. If flag
3296     *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3297     *         information is retrieved from the list of uninstalled
3298     *         applications (which includes installed applications as well as
3299     *         applications with data directory i.e. applications which had been
3300     *         deleted with {@code DONT_DELETE_DATA} flag set).
3301     */
3302    public abstract List<PackageInfo> getPackagesHoldingPermissions(
3303            String[] permissions, @PackageInfoFlags int flags);
3304
3305    /**
3306     * Return a List of all packages that are installed on the device, for a
3307     * specific user.
3308     *
3309     * @param flags Additional option flags to modify the data returned.
3310     * @param userId The user for whom the installed packages are to be listed
3311     * @return A List of PackageInfo objects, one for each installed package,
3312     *         containing information about the package. In the unlikely case
3313     *         there are no installed packages, an empty list is returned. If
3314     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3315     *         information is retrieved from the list of uninstalled
3316     *         applications (which includes installed applications as well as
3317     *         applications with data directory i.e. applications which had been
3318     *         deleted with {@code DONT_DELETE_DATA} flag set).
3319     * @hide
3320     */
3321    @SystemApi
3322    @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
3323    public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
3324            @UserIdInt int userId);
3325
3326    /**
3327     * Check whether a particular package has been granted a particular
3328     * permission.
3329     *
3330     * @param permName The name of the permission you are checking for.
3331     * @param pkgName The name of the package you are checking against.
3332     *
3333     * @return If the package has the permission, PERMISSION_GRANTED is
3334     * returned.  If it does not have the permission, PERMISSION_DENIED
3335     * is returned.
3336     *
3337     * @see #PERMISSION_GRANTED
3338     * @see #PERMISSION_DENIED
3339     */
3340    @CheckResult
3341    public abstract @PermissionResult int checkPermission(String permName, String pkgName);
3342
3343    /**
3344     * Checks whether a particular permissions has been revoked for a
3345     * package by policy. Typically the device owner or the profile owner
3346     * may apply such a policy. The user cannot grant policy revoked
3347     * permissions, hence the only way for an app to get such a permission
3348     * is by a policy change.
3349     *
3350     * @param permName The name of the permission you are checking for.
3351     * @param pkgName The name of the package you are checking against.
3352     *
3353     * @return Whether the permission is restricted by policy.
3354     */
3355    @CheckResult
3356    public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
3357            @NonNull String pkgName);
3358
3359    /**
3360     * Gets the package name of the component controlling runtime permissions.
3361     *
3362     * @return The package name.
3363     *
3364     * @hide
3365     */
3366    @TestApi
3367    public abstract String getPermissionControllerPackageName();
3368
3369    /**
3370     * Add a new dynamic permission to the system.  For this to work, your
3371     * package must have defined a permission tree through the
3372     * {@link android.R.styleable#AndroidManifestPermissionTree
3373     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
3374     * permissions to trees that were defined by either its own package or
3375     * another with the same user id; a permission is in a tree if it
3376     * matches the name of the permission tree + ".": for example,
3377     * "com.foo.bar" is a member of the permission tree "com.foo".
3378     *
3379     * <p>It is good to make your permission tree name descriptive, because you
3380     * are taking possession of that entire set of permission names.  Thus, it
3381     * must be under a domain you control, with a suffix that will not match
3382     * any normal permissions that may be declared in any applications that
3383     * are part of that domain.
3384     *
3385     * <p>New permissions must be added before
3386     * any .apks are installed that use those permissions.  Permissions you
3387     * add through this method are remembered across reboots of the device.
3388     * If the given permission already exists, the info you supply here
3389     * will be used to update it.
3390     *
3391     * @param info Description of the permission to be added.
3392     *
3393     * @return Returns true if a new permission was created, false if an
3394     * existing one was updated.
3395     *
3396     * @throws SecurityException if you are not allowed to add the
3397     * given permission name.
3398     *
3399     * @see #removePermission(String)
3400     */
3401    public abstract boolean addPermission(PermissionInfo info);
3402
3403    /**
3404     * Like {@link #addPermission(PermissionInfo)} but asynchronously
3405     * persists the package manager state after returning from the call,
3406     * allowing it to return quicker and batch a series of adds at the
3407     * expense of no guarantee the added permission will be retained if
3408     * the device is rebooted before it is written.
3409     */
3410    public abstract boolean addPermissionAsync(PermissionInfo info);
3411
3412    /**
3413     * Removes a permission that was previously added with
3414     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
3415     * -- you are only allowed to remove permissions that you are allowed
3416     * to add.
3417     *
3418     * @param name The name of the permission to remove.
3419     *
3420     * @throws SecurityException if you are not allowed to remove the
3421     * given permission name.
3422     *
3423     * @see #addPermission(PermissionInfo)
3424     */
3425    public abstract void removePermission(String name);
3426
3427    /**
3428     * Permission flags set when granting or revoking a permission.
3429     *
3430     * @hide
3431     */
3432    @SystemApi
3433    @IntDef(prefix = { "FLAG_PERMISSION_" }, value = {
3434            FLAG_PERMISSION_USER_SET,
3435            FLAG_PERMISSION_USER_FIXED,
3436            FLAG_PERMISSION_POLICY_FIXED,
3437            FLAG_PERMISSION_REVOKE_ON_UPGRADE,
3438            FLAG_PERMISSION_SYSTEM_FIXED,
3439            FLAG_PERMISSION_GRANTED_BY_DEFAULT
3440    })
3441    @Retention(RetentionPolicy.SOURCE)
3442    public @interface PermissionFlags {}
3443
3444    /**
3445     * Grant a runtime permission to an application which the application does not
3446     * already have. The permission must have been requested by the application.
3447     * If the application is not allowed to hold the permission, a {@link
3448     * java.lang.SecurityException} is thrown. If the package or permission is
3449     * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
3450     * <p>
3451     * <strong>Note: </strong>Using this API requires holding
3452     * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is
3453     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3454     * </p>
3455     *
3456     * @param packageName The package to which to grant the permission.
3457     * @param permissionName The permission name to grant.
3458     * @param user The user for which to grant the permission.
3459     *
3460     * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
3461     *
3462     * @hide
3463     */
3464    @SystemApi
3465    @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
3466    public abstract void grantRuntimePermission(@NonNull String packageName,
3467            @NonNull String permissionName, @NonNull UserHandle user);
3468
3469    /**
3470     * Revoke a runtime permission that was previously granted by {@link
3471     * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
3472     * permission must have been requested by and granted to the application.
3473     * If the application is not allowed to hold the permission, a {@link
3474     * java.lang.SecurityException} is thrown. If the package or permission is
3475     * invalid, a {@link java.lang.IllegalArgumentException} is thrown.
3476     * <p>
3477     * <strong>Note: </strong>Using this API requires holding
3478     * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is
3479     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3480     * </p>
3481     *
3482     * @param packageName The package from which to revoke the permission.
3483     * @param permissionName The permission name to revoke.
3484     * @param user The user for which to revoke the permission.
3485     *
3486     * @see #grantRuntimePermission(String, String, android.os.UserHandle)
3487     *
3488     * @hide
3489     */
3490    @SystemApi
3491    @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
3492    public abstract void revokeRuntimePermission(@NonNull String packageName,
3493            @NonNull String permissionName, @NonNull UserHandle user);
3494
3495    /**
3496     * Gets the state flags associated with a permission.
3497     *
3498     * @param permissionName The permission for which to get the flags.
3499     * @param packageName The package name for which to get the flags.
3500     * @param user The user for which to get permission flags.
3501     * @return The permission flags.
3502     *
3503     * @hide
3504     */
3505    @SystemApi
3506    @RequiresPermission(anyOf = {
3507            android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
3508            android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
3509    })
3510    public abstract @PermissionFlags int getPermissionFlags(String permissionName,
3511            String packageName, @NonNull UserHandle user);
3512
3513    /**
3514     * Updates the flags associated with a permission by replacing the flags in
3515     * the specified mask with the provided flag values.
3516     *
3517     * @param permissionName The permission for which to update the flags.
3518     * @param packageName The package name for which to update the flags.
3519     * @param flagMask The flags which to replace.
3520     * @param flagValues The flags with which to replace.
3521     * @param user The user for which to update the permission flags.
3522     *
3523     * @hide
3524     */
3525    @SystemApi
3526    @RequiresPermission(anyOf = {
3527            android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
3528            android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
3529    })
3530    public abstract void updatePermissionFlags(String permissionName,
3531            String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues,
3532            @NonNull UserHandle user);
3533
3534    /**
3535     * Gets whether you should show UI with rationale for requesting a permission.
3536     * You should do this only if you do not have the permission and the context in
3537     * which the permission is requested does not clearly communicate to the user
3538     * what would be the benefit from grating this permission.
3539     *
3540     * @param permission A permission your app wants to request.
3541     * @return Whether you can show permission rationale UI.
3542     *
3543     * @hide
3544     */
3545    public abstract boolean shouldShowRequestPermissionRationale(String permission);
3546
3547    /**
3548     * Returns an {@link android.content.Intent} suitable for passing to
3549     * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
3550     * which prompts the user to grant permissions to this application.
3551     *
3552     * @throws NullPointerException if {@code permissions} is {@code null} or empty.
3553     *
3554     * @hide
3555     */
3556    public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
3557        if (ArrayUtils.isEmpty(permissions)) {
3558           throw new IllegalArgumentException("permission cannot be null or empty");
3559        }
3560        Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
3561        intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
3562        intent.setPackage(getPermissionControllerPackageName());
3563        return intent;
3564    }
3565
3566    /**
3567     * Compare the signatures of two packages to determine if the same
3568     * signature appears in both of them.  If they do contain the same
3569     * signature, then they are allowed special privileges when working
3570     * with each other: they can share the same user-id, run instrumentation
3571     * against each other, etc.
3572     *
3573     * @param pkg1 First package name whose signature will be compared.
3574     * @param pkg2 Second package name whose signature will be compared.
3575     *
3576     * @return Returns an integer indicating whether all signatures on the
3577     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3578     * all signatures match or < 0 if there is not a match ({@link
3579     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3580     *
3581     * @see #checkSignatures(int, int)
3582     */
3583    @CheckResult
3584    public abstract @SignatureResult int checkSignatures(String pkg1, String pkg2);
3585
3586    /**
3587     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
3588     * the two packages to be checked.  This can be useful, for example,
3589     * when doing the check in an IPC, where the UID is the only identity
3590     * available.  It is functionally identical to determining the package
3591     * associated with the UIDs and checking their signatures.
3592     *
3593     * @param uid1 First UID whose signature will be compared.
3594     * @param uid2 Second UID whose signature will be compared.
3595     *
3596     * @return Returns an integer indicating whether all signatures on the
3597     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3598     * all signatures match or < 0 if there is not a match ({@link
3599     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3600     *
3601     * @see #checkSignatures(String, String)
3602     */
3603    @CheckResult
3604    public abstract @SignatureResult int checkSignatures(int uid1, int uid2);
3605
3606    /**
3607     * Retrieve the names of all packages that are associated with a particular
3608     * user id.  In most cases, this will be a single package name, the package
3609     * that has been assigned that user id.  Where there are multiple packages
3610     * sharing the same user id through the "sharedUserId" mechanism, all
3611     * packages with that id will be returned.
3612     *
3613     * @param uid The user id for which you would like to retrieve the
3614     * associated packages.
3615     *
3616     * @return Returns an array of one or more packages assigned to the user
3617     * id, or null if there are no known packages with the given id.
3618     */
3619    public abstract @Nullable String[] getPackagesForUid(int uid);
3620
3621    /**
3622     * Retrieve the official name associated with a uid. This name is
3623     * guaranteed to never change, though it is possible for the underlying
3624     * uid to be changed.  That is, if you are storing information about
3625     * uids in persistent storage, you should use the string returned
3626     * by this function instead of the raw uid.
3627     *
3628     * @param uid The uid for which you would like to retrieve a name.
3629     * @return Returns a unique name for the given uid, or null if the
3630     * uid is not currently assigned.
3631     */
3632    public abstract @Nullable String getNameForUid(int uid);
3633
3634    /**
3635     * Retrieves the official names associated with each given uid.
3636     * @see #getNameForUid(int)
3637     *
3638     * @hide
3639     */
3640    public abstract @Nullable String[] getNamesForUids(int[] uids);
3641
3642    /**
3643     * Return the user id associated with a shared user name. Multiple
3644     * applications can specify a shared user name in their manifest and thus
3645     * end up using a common uid. This might be used for new applications
3646     * that use an existing shared user name and need to know the uid of the
3647     * shared user.
3648     *
3649     * @param sharedUserName The shared user name whose uid is to be retrieved.
3650     * @return Returns the UID associated with the shared user.
3651     * @throws NameNotFoundException if a package with the given name cannot be
3652     *             found on the system.
3653     * @hide
3654     */
3655    public abstract int getUidForSharedUser(String sharedUserName)
3656            throws NameNotFoundException;
3657
3658    /**
3659     * Return a List of all application packages that are installed on the
3660     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
3661     * applications including those deleted with {@code DONT_DELETE_DATA}
3662     * (partially installed apps with data directory) will be returned.
3663     *
3664     * @param flags Additional option flags to modify the data returned.
3665     * @return A List of ApplicationInfo objects, one for each installed
3666     *         application. In the unlikely case there are no installed
3667     *         packages, an empty list is returned. If flag
3668     *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
3669     *         information is retrieved from the list of uninstalled
3670     *         applications (which includes installed applications as well as
3671     *         applications with data directory i.e. applications which had been
3672     *         deleted with {@code DONT_DELETE_DATA} flag set).
3673     */
3674    public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
3675
3676    /**
3677     * Return a List of all application packages that are installed on the
3678     * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been
3679     * set, a list of all applications including those deleted with
3680     * {@code DONT_DELETE_DATA} (partially installed apps with data directory)
3681     * will be returned.
3682     *
3683     * @param flags Additional option flags to modify the data returned.
3684     * @param userId The user for whom the installed applications are to be
3685     *            listed
3686     * @return A List of ApplicationInfo objects, one for each installed
3687     *         application. In the unlikely case there are no installed
3688     *         packages, an empty list is returned. If flag
3689     *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the application
3690     *         information is retrieved from the list of uninstalled
3691     *         applications (which includes installed applications as well as
3692     *         applications with data directory i.e. applications which had been
3693     *         deleted with {@code DONT_DELETE_DATA} flag set).
3694     * @hide
3695     */
3696    public abstract List<ApplicationInfo> getInstalledApplicationsAsUser(
3697            @ApplicationInfoFlags int flags, @UserIdInt int userId);
3698
3699    /**
3700     * Gets the instant applications the user recently used.
3701     *
3702     * @return The instant app list.
3703     *
3704     * @hide
3705     */
3706    @SystemApi
3707    @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
3708    public abstract @NonNull List<InstantAppInfo> getInstantApps();
3709
3710    /**
3711     * Gets the icon for an instant application.
3712     *
3713     * @param packageName The app package name.
3714     *
3715     * @hide
3716     */
3717    @SystemApi
3718    @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS)
3719    public abstract @Nullable Drawable getInstantAppIcon(String packageName);
3720
3721    /**
3722     * Gets whether this application is an instant app.
3723     *
3724     * @return Whether caller is an instant app.
3725     *
3726     * @see #isInstantApp(String)
3727     * @see #updateInstantAppCookie(byte[])
3728     * @see #getInstantAppCookie()
3729     * @see #getInstantAppCookieMaxBytes()
3730     */
3731    public abstract boolean isInstantApp();
3732
3733    /**
3734     * Gets whether the given package is an instant app.
3735     *
3736     * @param packageName The package to check
3737     * @return Whether the given package is an instant app.
3738     *
3739     * @see #isInstantApp()
3740     * @see #updateInstantAppCookie(byte[])
3741     * @see #getInstantAppCookie()
3742     * @see #getInstantAppCookieMaxBytes()
3743     * @see #clearInstantAppCookie()
3744     */
3745    public abstract boolean isInstantApp(String packageName);
3746
3747    /**
3748     * Gets the maximum size in bytes of the cookie data an instant app
3749     * can store on the device.
3750     *
3751     * @return The max cookie size in bytes.
3752     *
3753     * @see #isInstantApp()
3754     * @see #isInstantApp(String)
3755     * @see #updateInstantAppCookie(byte[])
3756     * @see #getInstantAppCookie()
3757     * @see #clearInstantAppCookie()
3758     */
3759    public abstract int getInstantAppCookieMaxBytes();
3760
3761    /**
3762     * @deprecated
3763     * @hide
3764     */
3765    public abstract int getInstantAppCookieMaxSize();
3766
3767    /**
3768     * Gets the instant application cookie for this app. Non
3769     * instant apps and apps that were instant but were upgraded
3770     * to normal apps can still access this API. For instant apps
3771     * this cookie is cached for some time after uninstall while for
3772     * normal apps the cookie is deleted after the app is uninstalled.
3773     * The cookie is always present while the app is installed.
3774     *
3775     * @return The cookie.
3776     *
3777     * @see #isInstantApp()
3778     * @see #isInstantApp(String)
3779     * @see #updateInstantAppCookie(byte[])
3780     * @see #getInstantAppCookieMaxBytes()
3781     * @see #clearInstantAppCookie()
3782     */
3783    public abstract @NonNull byte[] getInstantAppCookie();
3784
3785    /**
3786     * Clears the instant application cookie for the calling app.
3787     *
3788     * @see #isInstantApp()
3789     * @see #isInstantApp(String)
3790     * @see #getInstantAppCookieMaxBytes()
3791     * @see #getInstantAppCookie()
3792     * @see #clearInstantAppCookie()
3793     */
3794    public abstract void clearInstantAppCookie();
3795
3796    /**
3797     * Updates the instant application cookie for the calling app. Non
3798     * instant apps and apps that were instant but were upgraded
3799     * to normal apps can still access this API. For instant apps
3800     * this cookie is cached for some time after uninstall while for
3801     * normal apps the cookie is deleted after the app is uninstalled.
3802     * The cookie is always present while the app is installed. The
3803     * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}.
3804     * Passing <code>null</code> or an empty array clears the cookie.
3805     * </p>
3806     *
3807     * @param cookie The cookie data.
3808     *
3809     * @see #isInstantApp()
3810     * @see #isInstantApp(String)
3811     * @see #getInstantAppCookieMaxBytes()
3812     * @see #getInstantAppCookie()
3813     * @see #clearInstantAppCookie()
3814     *
3815     * @throws IllegalArgumentException if the array exceeds max cookie size.
3816     */
3817    public abstract void updateInstantAppCookie(@Nullable byte[] cookie);
3818
3819    /**
3820     * @removed
3821     */
3822    public abstract boolean setInstantAppCookie(@Nullable byte[] cookie);
3823
3824    /**
3825     * Get a list of shared libraries that are available on the
3826     * system.
3827     *
3828     * @return An array of shared library names that are
3829     * available on the system, or null if none are installed.
3830     *
3831     */
3832    public abstract String[] getSystemSharedLibraryNames();
3833
3834    /**
3835     * Get a list of shared libraries on the device.
3836     *
3837     * @param flags To filter the libraries to return.
3838     * @return The shared library list.
3839     *
3840     * @see #MATCH_UNINSTALLED_PACKAGES
3841     */
3842    public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(
3843            @InstallFlags int flags);
3844
3845    /**
3846     * Get a list of shared libraries on the device.
3847     *
3848     * @param flags To filter the libraries to return.
3849     * @param userId The user to query for.
3850     * @return The shared library list.
3851     *
3852     * @see #MATCH_FACTORY_ONLY
3853     * @see #MATCH_KNOWN_PACKAGES
3854     * @see #MATCH_ANY_USER
3855     * @see #MATCH_UNINSTALLED_PACKAGES
3856     *
3857     * @hide
3858     */
3859    public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(
3860            @InstallFlags int flags, @UserIdInt int userId);
3861
3862    /**
3863     * Get the name of the package hosting the services shared library.
3864     *
3865     * @return The library host package.
3866     *
3867     * @hide
3868     */
3869    public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
3870
3871    /**
3872     * Get the name of the package hosting the shared components shared library.
3873     *
3874     * @return The library host package.
3875     *
3876     * @hide
3877     */
3878    public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
3879
3880    /**
3881     * Returns the names of the packages that have been changed
3882     * [eg. added, removed or updated] since the given sequence
3883     * number.
3884     * <p>If no packages have been changed, returns <code>null</code>.
3885     * <p>The sequence number starts at <code>0</code> and is
3886     * reset every boot.
3887     * @param sequenceNumber The first sequence number for which to retrieve package changes.
3888     * @see Settings.Global#BOOT_COUNT
3889     */
3890    public abstract @Nullable ChangedPackages getChangedPackages(
3891            @IntRange(from=0) int sequenceNumber);
3892
3893    /**
3894     * Get a list of features that are available on the
3895     * system.
3896     *
3897     * @return An array of FeatureInfo classes describing the features
3898     * that are available on the system, or null if there are none(!!).
3899     */
3900    public abstract FeatureInfo[] getSystemAvailableFeatures();
3901
3902    /**
3903     * Check whether the given feature name is one of the available features as
3904     * returned by {@link #getSystemAvailableFeatures()}. This tests for the
3905     * presence of <em>any</em> version of the given feature name; use
3906     * {@link #hasSystemFeature(String, int)} to check for a minimum version.
3907     *
3908     * @return Returns true if the devices supports the feature, else false.
3909     */
3910    public abstract boolean hasSystemFeature(String name);
3911
3912    /**
3913     * Check whether the given feature name and version is one of the available
3914     * features as returned by {@link #getSystemAvailableFeatures()}. Since
3915     * features are defined to always be backwards compatible, this returns true
3916     * if the available feature version is greater than or equal to the
3917     * requested version.
3918     *
3919     * @return Returns true if the devices supports the feature, else false.
3920     */
3921    public abstract boolean hasSystemFeature(String name, int version);
3922
3923    /**
3924     * Determine the best action to perform for a given Intent. This is how
3925     * {@link Intent#resolveActivity} finds an activity if a class has not been
3926     * explicitly specified.
3927     * <p>
3928     * <em>Note:</em> if using an implicit Intent (without an explicit
3929     * ComponentName specified), be sure to consider whether to set the
3930     * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3931     * activity in the same way that
3932     * {@link android.content.Context#startActivity(Intent)} and
3933     * {@link android.content.Intent#resolveActivity(PackageManager)
3934     * Intent.resolveActivity(PackageManager)} do.
3935     * </p>
3936     *
3937     * @param intent An intent containing all of the desired specification
3938     *            (action, data, type, category, and/or component).
3939     * @param flags Additional option flags to modify the data returned. The
3940     *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
3941     *            resolution to only those activities that support the
3942     *            {@link android.content.Intent#CATEGORY_DEFAULT}.
3943     * @return Returns a ResolveInfo object containing the final activity intent
3944     *         that was determined to be the best action. Returns null if no
3945     *         matching activity was found. If multiple matching activities are
3946     *         found and there is no default set, returns a ResolveInfo object
3947     *         containing something else, such as the activity resolver.
3948     */
3949    public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
3950
3951    /**
3952     * Determine the best action to perform for a given Intent for a given user.
3953     * This is how {@link Intent#resolveActivity} finds an activity if a class
3954     * has not been explicitly specified.
3955     * <p>
3956     * <em>Note:</em> if using an implicit Intent (without an explicit
3957     * ComponentName specified), be sure to consider whether to set the
3958     * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3959     * activity in the same way that
3960     * {@link android.content.Context#startActivity(Intent)} and
3961     * {@link android.content.Intent#resolveActivity(PackageManager)
3962     * Intent.resolveActivity(PackageManager)} do.
3963     * </p>
3964     *
3965     * @param intent An intent containing all of the desired specification
3966     *            (action, data, type, category, and/or component).
3967     * @param flags Additional option flags to modify the data returned. The
3968     *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
3969     *            resolution to only those activities that support the
3970     *            {@link android.content.Intent#CATEGORY_DEFAULT}.
3971     * @param userId The user id.
3972     * @return Returns a ResolveInfo object containing the final activity intent
3973     *         that was determined to be the best action. Returns null if no
3974     *         matching activity was found. If multiple matching activities are
3975     *         found and there is no default set, returns a ResolveInfo object
3976     *         containing something else, such as the activity resolver.
3977     * @hide
3978     */
3979    public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
3980            @UserIdInt int userId);
3981
3982    /**
3983     * Retrieve all activities that can be performed for the given intent.
3984     *
3985     * @param intent The desired intent as per resolveActivity().
3986     * @param flags Additional option flags to modify the data returned. The
3987     *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
3988     *            resolution to only those activities that support the
3989     *            {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
3990     *            {@link #MATCH_ALL} to prevent any filtering of the results.
3991     * @return Returns a List of ResolveInfo objects containing one entry for
3992     *         each matching activity, ordered from best to worst. In other
3993     *         words, the first item is what would be returned by
3994     *         {@link #resolveActivity}. If there are no matching activities, an
3995     *         empty list is returned.
3996     */
3997    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
3998            @ResolveInfoFlags int flags);
3999
4000    /**
4001     * Retrieve all activities that can be performed for the given intent, for a
4002     * specific user.
4003     *
4004     * @param intent The desired intent as per resolveActivity().
4005     * @param flags Additional option flags to modify the data returned. The
4006     *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4007     *            resolution to only those activities that support the
4008     *            {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
4009     *            {@link #MATCH_ALL} to prevent any filtering of the results.
4010     * @return Returns a List of ResolveInfo objects containing one entry for
4011     *         each matching activity, ordered from best to worst. In other
4012     *         words, the first item is what would be returned by
4013     *         {@link #resolveActivity}. If there are no matching activities, an
4014     *         empty list is returned.
4015     * @hide
4016     */
4017    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
4018            @ResolveInfoFlags int flags, @UserIdInt int userId);
4019
4020    /**
4021     * Retrieve a set of activities that should be presented to the user as
4022     * similar options. This is like {@link #queryIntentActivities}, except it
4023     * also allows you to supply a list of more explicit Intents that you would
4024     * like to resolve to particular options, and takes care of returning the
4025     * final ResolveInfo list in a reasonable order, with no duplicates, based
4026     * on those inputs.
4027     *
4028     * @param caller The class name of the activity that is making the request.
4029     *            This activity will never appear in the output list. Can be
4030     *            null.
4031     * @param specifics An array of Intents that should be resolved to the first
4032     *            specific results. Can be null.
4033     * @param intent The desired intent as per resolveActivity().
4034     * @param flags Additional option flags to modify the data returned. The
4035     *            most important is {@link #MATCH_DEFAULT_ONLY}, to limit the
4036     *            resolution to only those activities that support the
4037     *            {@link android.content.Intent#CATEGORY_DEFAULT}.
4038     * @return Returns a List of ResolveInfo objects containing one entry for
4039     *         each matching activity. The list is ordered first by all of the
4040     *         intents resolved in <var>specifics</var> and then any additional
4041     *         activities that can handle <var>intent</var> but did not get
4042     *         included by one of the <var>specifics</var> intents. If there are
4043     *         no matching activities, an empty list is returned.
4044     */
4045    public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller,
4046            @Nullable Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
4047
4048    /**
4049     * Retrieve all receivers that can handle a broadcast of the given intent.
4050     *
4051     * @param intent The desired intent as per resolveActivity().
4052     * @param flags Additional option flags to modify the data returned.
4053     * @return Returns a List of ResolveInfo objects containing one entry for
4054     *         each matching receiver, ordered from best to worst. If there are
4055     *         no matching receivers, an empty list or null is returned.
4056     */
4057    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
4058            @ResolveInfoFlags int flags);
4059
4060    /**
4061     * Retrieve all receivers that can handle a broadcast of the given intent,
4062     * for a specific user.
4063     *
4064     * @param intent The desired intent as per resolveActivity().
4065     * @param flags Additional option flags to modify the data returned.
4066     * @param userHandle UserHandle of the user being queried.
4067     * @return Returns a List of ResolveInfo objects containing one entry for
4068     *         each matching receiver, ordered from best to worst. If there are
4069     *         no matching receivers, an empty list or null is returned.
4070     * @hide
4071     */
4072    @SystemApi
4073    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
4074    public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
4075            @ResolveInfoFlags int flags, UserHandle userHandle) {
4076        return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
4077    }
4078
4079    /**
4080     * @hide
4081     */
4082    public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
4083            @ResolveInfoFlags int flags, @UserIdInt int userId);
4084
4085
4086    /** {@hide} */
4087    @Deprecated
4088    public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
4089            @ResolveInfoFlags int flags, @UserIdInt int userId) {
4090        final String msg = "Shame on you for calling the hidden API "
4091                + "queryBroadcastReceivers(). Shame!";
4092        if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) {
4093            throw new UnsupportedOperationException(msg);
4094        } else {
4095            Log.d(TAG, msg);
4096            return queryBroadcastReceiversAsUser(intent, flags, userId);
4097        }
4098    }
4099
4100    /**
4101     * Determine the best service to handle for a given Intent.
4102     *
4103     * @param intent An intent containing all of the desired specification
4104     *            (action, data, type, category, and/or component).
4105     * @param flags Additional option flags to modify the data returned.
4106     * @return Returns a ResolveInfo object containing the final service intent
4107     *         that was determined to be the best action. Returns null if no
4108     *         matching service was found.
4109     */
4110    public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
4111
4112    /**
4113     * Retrieve all services that can match the given intent.
4114     *
4115     * @param intent The desired intent as per resolveService().
4116     * @param flags Additional option flags to modify the data returned.
4117     * @return Returns a List of ResolveInfo objects containing one entry for
4118     *         each matching service, ordered from best to worst. In other
4119     *         words, the first item is what would be returned by
4120     *         {@link #resolveService}. If there are no matching services, an
4121     *         empty list or null is returned.
4122     */
4123    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
4124            @ResolveInfoFlags int flags);
4125
4126    /**
4127     * Retrieve all services that can match the given intent for a given user.
4128     *
4129     * @param intent The desired intent as per resolveService().
4130     * @param flags Additional option flags to modify the data returned.
4131     * @param userId The user id.
4132     * @return Returns a List of ResolveInfo objects containing one entry for
4133     *         each matching service, ordered from best to worst. In other
4134     *         words, the first item is what would be returned by
4135     *         {@link #resolveService}. If there are no matching services, an
4136     *         empty list or null is returned.
4137     * @hide
4138     */
4139    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
4140            @ResolveInfoFlags int flags, @UserIdInt int userId);
4141
4142    /**
4143     * Retrieve all providers that can match the given intent.
4144     *
4145     * @param intent An intent containing all of the desired specification
4146     *            (action, data, type, category, and/or component).
4147     * @param flags Additional option flags to modify the data returned.
4148     * @param userId The user id.
4149     * @return Returns a List of ResolveInfo objects containing one entry for
4150     *         each matching provider, ordered from best to worst. If there are
4151     *         no matching services, an empty list or null is returned.
4152     * @hide
4153     */
4154    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
4155            Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
4156
4157    /**
4158     * Retrieve all providers that can match the given intent.
4159     *
4160     * @param intent An intent containing all of the desired specification
4161     *            (action, data, type, category, and/or component).
4162     * @param flags Additional option flags to modify the data returned.
4163     * @return Returns a List of ResolveInfo objects containing one entry for
4164     *         each matching provider, ordered from best to worst. If there are
4165     *         no matching services, an empty list or null is returned.
4166     */
4167    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
4168            @ResolveInfoFlags int flags);
4169
4170    /**
4171     * Find a single content provider by its base path name.
4172     *
4173     * @param name The name of the provider to find.
4174     * @param flags Additional option flags to modify the data returned.
4175     * @return A {@link ProviderInfo} object containing information about the
4176     *         provider. If a provider was not found, returns null.
4177     */
4178    public abstract ProviderInfo resolveContentProvider(String name,
4179            @ComponentInfoFlags int flags);
4180
4181    /**
4182     * Find a single content provider by its base path name.
4183     *
4184     * @param name The name of the provider to find.
4185     * @param flags Additional option flags to modify the data returned.
4186     * @param userId The user id.
4187     * @return A {@link ProviderInfo} object containing information about the
4188     *         provider. If a provider was not found, returns null.
4189     * @hide
4190     */
4191    public abstract ProviderInfo resolveContentProviderAsUser(String name,
4192            @ComponentInfoFlags int flags, @UserIdInt int userId);
4193
4194    /**
4195     * Retrieve content provider information.
4196     * <p>
4197     * <em>Note: unlike most other methods, an empty result set is indicated
4198     * by a null return instead of an empty list.</em>
4199     *
4200     * @param processName If non-null, limits the returned providers to only
4201     *            those that are hosted by the given process. If null, all
4202     *            content providers are returned.
4203     * @param uid If <var>processName</var> is non-null, this is the required
4204     *            uid owning the requested content providers.
4205     * @param flags Additional option flags to modify the data returned.
4206     * @return A list of {@link ProviderInfo} objects containing one entry for
4207     *         each provider either matching <var>processName</var> or, if
4208     *         <var>processName</var> is null, all known content providers.
4209     *         <em>If there are no matching providers, null is returned.</em>
4210     */
4211    public abstract List<ProviderInfo> queryContentProviders(
4212            String processName, int uid, @ComponentInfoFlags int flags);
4213
4214    /**
4215     * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null,
4216     * it only returns providers which have metadata with the {@code metaDataKey} key.
4217     *
4218     * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider.
4219     * You really shouldn't need it.  Other apps should use {@link #queryIntentContentProviders}
4220     * instead.
4221     *
4222     * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly
4223     * scan the GAL providers on the device.  Unfortunately the discovery protocol used metadata
4224     * to mark GAL providers, rather than intent filters, so we can't use
4225     * {@link #queryIntentContentProviders} for that.
4226     *
4227     * @hide
4228     */
4229    public List<ProviderInfo> queryContentProviders(
4230            String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) {
4231        // Provide the default implementation for mocks.
4232        return queryContentProviders(processName, uid, flags);
4233    }
4234
4235    /**
4236     * Retrieve all of the information we know about a particular
4237     * instrumentation class.
4238     *
4239     * @param className The full name (i.e.
4240     *            com.google.apps.contacts.InstrumentList) of an Instrumentation
4241     *            class.
4242     * @param flags Additional option flags to modify the data returned.
4243     * @return An {@link InstrumentationInfo} object containing information
4244     *         about the instrumentation.
4245     * @throws NameNotFoundException if a package with the given name cannot be
4246     *             found on the system.
4247     */
4248    public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
4249            @InstrumentationInfoFlags int flags) throws NameNotFoundException;
4250
4251    /**
4252     * Retrieve information about available instrumentation code. May be used to
4253     * retrieve either all instrumentation code, or only the code targeting a
4254     * particular package.
4255     *
4256     * @param targetPackage If null, all instrumentation is returned; only the
4257     *            instrumentation targeting this package name is returned.
4258     * @param flags Additional option flags to modify the data returned.
4259     * @return A list of {@link InstrumentationInfo} objects containing one
4260     *         entry for each matching instrumentation. If there are no
4261     *         instrumentation available, returns an empty list.
4262     */
4263    public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
4264            @InstrumentationInfoFlags int flags);
4265
4266    /**
4267     * Retrieve an image from a package.  This is a low-level API used by
4268     * the various package manager info structures (such as
4269     * {@link ComponentInfo} to implement retrieval of their associated
4270     * icon.
4271     *
4272     * @param packageName The name of the package that this icon is coming from.
4273     * Cannot be null.
4274     * @param resid The resource identifier of the desired image.  Cannot be 0.
4275     * @param appInfo Overall information about <var>packageName</var>.  This
4276     * may be null, in which case the application information will be retrieved
4277     * for you if needed; if you already have this information around, it can
4278     * be much more efficient to supply it here.
4279     *
4280     * @return Returns a Drawable holding the requested image.  Returns null if
4281     * an image could not be found for any reason.
4282     */
4283    public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
4284            ApplicationInfo appInfo);
4285
4286    /**
4287     * Retrieve the icon associated with an activity.  Given the full name of
4288     * an activity, retrieves the information about it and calls
4289     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
4290     * If the activity cannot be found, NameNotFoundException is thrown.
4291     *
4292     * @param activityName Name of the activity whose icon is to be retrieved.
4293     *
4294     * @return Returns the image of the icon, or the default activity icon if
4295     * it could not be found.  Does not return null.
4296     * @throws NameNotFoundException Thrown if the resources for the given
4297     * activity could not be loaded.
4298     *
4299     * @see #getActivityIcon(Intent)
4300     */
4301    public abstract Drawable getActivityIcon(ComponentName activityName)
4302            throws NameNotFoundException;
4303
4304    /**
4305     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
4306     * set, this simply returns the result of
4307     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
4308     * component and returns the icon associated with the resolved component.
4309     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4310     * to a component, NameNotFoundException is thrown.
4311     *
4312     * @param intent The intent for which you would like to retrieve an icon.
4313     *
4314     * @return Returns the image of the icon, or the default activity icon if
4315     * it could not be found.  Does not return null.
4316     * @throws NameNotFoundException Thrown if the resources for application
4317     * matching the given intent could not be loaded.
4318     *
4319     * @see #getActivityIcon(ComponentName)
4320     */
4321    public abstract Drawable getActivityIcon(Intent intent)
4322            throws NameNotFoundException;
4323
4324    /**
4325     * Retrieve the banner associated with an activity. Given the full name of
4326     * an activity, retrieves the information about it and calls
4327     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4328     * banner. If the activity cannot be found, NameNotFoundException is thrown.
4329     *
4330     * @param activityName Name of the activity whose banner is to be retrieved.
4331     * @return Returns the image of the banner, or null if the activity has no
4332     *         banner specified.
4333     * @throws NameNotFoundException Thrown if the resources for the given
4334     *             activity could not be loaded.
4335     * @see #getActivityBanner(Intent)
4336     */
4337    public abstract Drawable getActivityBanner(ComponentName activityName)
4338            throws NameNotFoundException;
4339
4340    /**
4341     * Retrieve the banner associated with an Intent. If intent.getClassName()
4342     * is set, this simply returns the result of
4343     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4344     * intent's component and returns the banner associated with the resolved
4345     * component. If intent.getClassName() cannot be found or the Intent cannot
4346     * be resolved to a component, NameNotFoundException is thrown.
4347     *
4348     * @param intent The intent for which you would like to retrieve a banner.
4349     * @return Returns the image of the banner, or null if the activity has no
4350     *         banner specified.
4351     * @throws NameNotFoundException Thrown if the resources for application
4352     *             matching the given intent could not be loaded.
4353     * @see #getActivityBanner(ComponentName)
4354     */
4355    public abstract Drawable getActivityBanner(Intent intent)
4356            throws NameNotFoundException;
4357
4358    /**
4359     * Return the generic icon for an activity that is used when no specific
4360     * icon is defined.
4361     *
4362     * @return Drawable Image of the icon.
4363     */
4364    public abstract Drawable getDefaultActivityIcon();
4365
4366    /**
4367     * Retrieve the icon associated with an application.  If it has not defined
4368     * an icon, the default app icon is returned.  Does not return null.
4369     *
4370     * @param info Information about application being queried.
4371     *
4372     * @return Returns the image of the icon, or the default application icon
4373     * if it could not be found.
4374     *
4375     * @see #getApplicationIcon(String)
4376     */
4377    public abstract Drawable getApplicationIcon(ApplicationInfo info);
4378
4379    /**
4380     * Retrieve the icon associated with an application.  Given the name of the
4381     * application's package, retrieves the information about it and calls
4382     * getApplicationIcon() to return its icon. If the application cannot be
4383     * found, NameNotFoundException is thrown.
4384     *
4385     * @param packageName Name of the package whose application icon is to be
4386     *                    retrieved.
4387     *
4388     * @return Returns the image of the icon, or the default application icon
4389     * if it could not be found.  Does not return null.
4390     * @throws NameNotFoundException Thrown if the resources for the given
4391     * application could not be loaded.
4392     *
4393     * @see #getApplicationIcon(ApplicationInfo)
4394     */
4395    public abstract Drawable getApplicationIcon(String packageName)
4396            throws NameNotFoundException;
4397
4398    /**
4399     * Retrieve the banner associated with an application.
4400     *
4401     * @param info Information about application being queried.
4402     * @return Returns the image of the banner or null if the application has no
4403     *         banner specified.
4404     * @see #getApplicationBanner(String)
4405     */
4406    public abstract Drawable getApplicationBanner(ApplicationInfo info);
4407
4408    /**
4409     * Retrieve the banner associated with an application. Given the name of the
4410     * application's package, retrieves the information about it and calls
4411     * getApplicationIcon() to return its banner. If the application cannot be
4412     * found, NameNotFoundException is thrown.
4413     *
4414     * @param packageName Name of the package whose application banner is to be
4415     *            retrieved.
4416     * @return Returns the image of the banner or null if the application has no
4417     *         banner specified.
4418     * @throws NameNotFoundException Thrown if the resources for the given
4419     *             application could not be loaded.
4420     * @see #getApplicationBanner(ApplicationInfo)
4421     */
4422    public abstract Drawable getApplicationBanner(String packageName)
4423            throws NameNotFoundException;
4424
4425    /**
4426     * Retrieve the logo associated with an activity. Given the full name of an
4427     * activity, retrieves the information about it and calls
4428     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4429     * logo. If the activity cannot be found, NameNotFoundException is thrown.
4430     *
4431     * @param activityName Name of the activity whose logo is to be retrieved.
4432     * @return Returns the image of the logo or null if the activity has no logo
4433     *         specified.
4434     * @throws NameNotFoundException Thrown if the resources for the given
4435     *             activity could not be loaded.
4436     * @see #getActivityLogo(Intent)
4437     */
4438    public abstract Drawable getActivityLogo(ComponentName activityName)
4439            throws NameNotFoundException;
4440
4441    /**
4442     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
4443     * set, this simply returns the result of
4444     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
4445     * component and returns the logo associated with the resolved component.
4446     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4447     * to a component, NameNotFoundException is thrown.
4448     *
4449     * @param intent The intent for which you would like to retrieve a logo.
4450     *
4451     * @return Returns the image of the logo, or null if the activity has no
4452     * logo specified.
4453     *
4454     * @throws NameNotFoundException Thrown if the resources for application
4455     * matching the given intent could not be loaded.
4456     *
4457     * @see #getActivityLogo(ComponentName)
4458     */
4459    public abstract Drawable getActivityLogo(Intent intent)
4460            throws NameNotFoundException;
4461
4462    /**
4463     * Retrieve the logo associated with an application.  If it has not specified
4464     * a logo, this method returns null.
4465     *
4466     * @param info Information about application being queried.
4467     *
4468     * @return Returns the image of the logo, or null if no logo is specified
4469     * by the application.
4470     *
4471     * @see #getApplicationLogo(String)
4472     */
4473    public abstract Drawable getApplicationLogo(ApplicationInfo info);
4474
4475    /**
4476     * Retrieve the logo associated with an application.  Given the name of the
4477     * application's package, retrieves the information about it and calls
4478     * getApplicationLogo() to return its logo. If the application cannot be
4479     * found, NameNotFoundException is thrown.
4480     *
4481     * @param packageName Name of the package whose application logo is to be
4482     *                    retrieved.
4483     *
4484     * @return Returns the image of the logo, or null if no application logo
4485     * has been specified.
4486     *
4487     * @throws NameNotFoundException Thrown if the resources for the given
4488     * application could not be loaded.
4489     *
4490     * @see #getApplicationLogo(ApplicationInfo)
4491     */
4492    public abstract Drawable getApplicationLogo(String packageName)
4493            throws NameNotFoundException;
4494
4495    /**
4496     * If the target user is a managed profile, then this returns a badged copy of the given icon
4497     * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
4498     * {@link #getUserBadgedDrawableForDensity(
4499     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4500     * <p>
4501     * If the original drawable is a BitmapDrawable and the backing bitmap is
4502     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4503     * is performed in place and the original drawable is returned.
4504     * </p>
4505     *
4506     * @param icon The icon to badge.
4507     * @param user The target user.
4508     * @return A drawable that combines the original icon and a badge as
4509     *         determined by the system.
4510     */
4511    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4512
4513    /**
4514     * If the target user is a managed profile of the calling user or the caller
4515     * is itself a managed profile, then this returns a badged copy of the given
4516     * drawable allowing the user to distinguish it from the original drawable.
4517     * The caller can specify the location in the bounds of the drawable to be
4518     * badged where the badge should be applied as well as the density of the
4519     * badge to be used.
4520     * <p>
4521     * If the original drawable is a BitmapDrawable and the backing bitmap is
4522     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4523     * is performed in place and the original drawable is returned.
4524     * </p>
4525     *
4526     * @param drawable The drawable to badge.
4527     * @param user The target user.
4528     * @param badgeLocation Where in the bounds of the badged drawable to place
4529     *         the badge. If it's {@code null}, the badge is applied on top of the entire
4530     *         drawable being badged.
4531     * @param badgeDensity The optional desired density for the badge as per
4532     *         {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4533     *         the density of the display is used.
4534     * @return A drawable that combines the original drawable and a badge as
4535     *         determined by the system.
4536     */
4537    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4538            UserHandle user, Rect badgeLocation, int badgeDensity);
4539
4540    /**
4541     * If the target user is a managed profile of the calling user or the caller
4542     * is itself a managed profile, then this returns a drawable to use as a small
4543     * icon to include in a view to distinguish it from the original icon.
4544     *
4545     * @param user The target user.
4546     * @param density The optional desired density for the badge as per
4547     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4548     *         the density of the current display is used.
4549     * @return the drawable or null if no drawable is required.
4550     * @hide
4551     */
4552    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4553
4554    /**
4555     * If the target user is a managed profile of the calling user or the caller
4556     * is itself a managed profile, then this returns a drawable to use as a small
4557     * icon to include in a view to distinguish it from the original icon. This version
4558     * doesn't have background protection and should be used over a light background instead of
4559     * a badge.
4560     *
4561     * @param user The target user.
4562     * @param density The optional desired density for the badge as per
4563     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4564     *         the density of the current display is used.
4565     * @return the drawable or null if no drawable is required.
4566     * @hide
4567     */
4568    public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4569
4570    /**
4571     * If the target user is a managed profile of the calling user or the caller
4572     * is itself a managed profile, then this returns a copy of the label with
4573     * badging for accessibility services like talkback. E.g. passing in "Email"
4574     * and it might return "Work Email" for Email in the work profile.
4575     *
4576     * @param label The label to change.
4577     * @param user The target user.
4578     * @return A label that combines the original label and a badge as
4579     *         determined by the system.
4580     */
4581    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4582
4583    /**
4584     * Retrieve text from a package.  This is a low-level API used by
4585     * the various package manager info structures (such as
4586     * {@link ComponentInfo} to implement retrieval of their associated
4587     * labels and other text.
4588     *
4589     * @param packageName The name of the package that this text is coming from.
4590     * Cannot be null.
4591     * @param resid The resource identifier of the desired text.  Cannot be 0.
4592     * @param appInfo Overall information about <var>packageName</var>.  This
4593     * may be null, in which case the application information will be retrieved
4594     * for you if needed; if you already have this information around, it can
4595     * be much more efficient to supply it here.
4596     *
4597     * @return Returns a CharSequence holding the requested text.  Returns null
4598     * if the text could not be found for any reason.
4599     */
4600    public abstract CharSequence getText(String packageName, @StringRes int resid,
4601            ApplicationInfo appInfo);
4602
4603    /**
4604     * Retrieve an XML file from a package.  This is a low-level API used to
4605     * retrieve XML meta data.
4606     *
4607     * @param packageName The name of the package that this xml is coming from.
4608     * Cannot be null.
4609     * @param resid The resource identifier of the desired xml.  Cannot be 0.
4610     * @param appInfo Overall information about <var>packageName</var>.  This
4611     * may be null, in which case the application information will be retrieved
4612     * for you if needed; if you already have this information around, it can
4613     * be much more efficient to supply it here.
4614     *
4615     * @return Returns an XmlPullParser allowing you to parse out the XML
4616     * data.  Returns null if the xml resource could not be found for any
4617     * reason.
4618     */
4619    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
4620            ApplicationInfo appInfo);
4621
4622    /**
4623     * Return the label to use for this application.
4624     *
4625     * @return Returns the label associated with this application, or null if
4626     * it could not be found for any reason.
4627     * @param info The application to get the label of.
4628     */
4629    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4630
4631    /**
4632     * Retrieve the resources associated with an activity.  Given the full
4633     * name of an activity, retrieves the information about it and calls
4634     * getResources() to return its application's resources.  If the activity
4635     * cannot be found, NameNotFoundException is thrown.
4636     *
4637     * @param activityName Name of the activity whose resources are to be
4638     *                     retrieved.
4639     *
4640     * @return Returns the application's Resources.
4641     * @throws NameNotFoundException Thrown if the resources for the given
4642     * application could not be loaded.
4643     *
4644     * @see #getResourcesForApplication(ApplicationInfo)
4645     */
4646    public abstract Resources getResourcesForActivity(ComponentName activityName)
4647            throws NameNotFoundException;
4648
4649    /**
4650     * Retrieve the resources for an application.  Throws NameNotFoundException
4651     * if the package is no longer installed.
4652     *
4653     * @param app Information about the desired application.
4654     *
4655     * @return Returns the application's Resources.
4656     * @throws NameNotFoundException Thrown if the resources for the given
4657     * application could not be loaded (most likely because it was uninstalled).
4658     */
4659    public abstract Resources getResourcesForApplication(ApplicationInfo app)
4660            throws NameNotFoundException;
4661
4662    /**
4663     * Retrieve the resources associated with an application.  Given the full
4664     * package name of an application, retrieves the information about it and
4665     * calls getResources() to return its application's resources.  If the
4666     * appPackageName cannot be found, NameNotFoundException is thrown.
4667     *
4668     * @param appPackageName Package name of the application whose resources
4669     *                       are to be retrieved.
4670     *
4671     * @return Returns the application's Resources.
4672     * @throws NameNotFoundException Thrown if the resources for the given
4673     * application could not be loaded.
4674     *
4675     * @see #getResourcesForApplication(ApplicationInfo)
4676     */
4677    public abstract Resources getResourcesForApplication(String appPackageName)
4678            throws NameNotFoundException;
4679
4680    /** @hide */
4681    public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4682            @UserIdInt int userId) throws NameNotFoundException;
4683
4684    /**
4685     * Retrieve overall information about an application package defined in a
4686     * package archive file
4687     *
4688     * @param archiveFilePath The path to the archive file
4689     * @param flags Additional option flags to modify the data returned.
4690     * @return A PackageInfo object containing information about the package
4691     *         archive. If the package could not be parsed, returns null.
4692     */
4693    public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
4694        final PackageParser parser = new PackageParser();
4695        parser.setCallback(new PackageParser.CallbackImpl(this));
4696        final File apkFile = new File(archiveFilePath);
4697        try {
4698            if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
4699                // Caller expressed an explicit opinion about what encryption
4700                // aware/unaware components they want to see, so fall through and
4701                // give them what they want
4702            } else {
4703                // Caller expressed no opinion, so match everything
4704                flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
4705            }
4706
4707            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
4708            if ((flags & GET_SIGNATURES) != 0) {
4709                PackageParser.collectCertificates(pkg, 0);
4710            }
4711            PackageUserState state = new PackageUserState();
4712            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4713        } catch (PackageParserException e) {
4714            return null;
4715        }
4716    }
4717
4718    /**
4719     * @deprecated replaced by {@link PackageInstaller}
4720     * @hide
4721     */
4722    @Deprecated
4723    public abstract void installPackage(
4724            Uri packageURI,
4725            PackageInstallObserver observer,
4726            @InstallFlags int flags,
4727            String installerPackageName);
4728
4729    /**
4730     * If there is already an application with the given package name installed
4731     * on the system for other users, also install it for the calling user.
4732     * @hide
4733     */
4734    @SystemApi
4735    public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
4736
4737    /**
4738     * If there is already an application with the given package name installed
4739     * on the system for other users, also install it for the calling user.
4740     * @hide
4741     */
4742    @SystemApi
4743    public abstract int installExistingPackage(String packageName, @InstallReason int installReason)
4744            throws NameNotFoundException;
4745
4746    /**
4747     * If there is already an application with the given package name installed
4748     * on the system for other users, also install it for the specified user.
4749     * @hide
4750     */
4751     @RequiresPermission(anyOf = {
4752            Manifest.permission.INSTALL_PACKAGES,
4753            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4754    public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
4755            throws NameNotFoundException;
4756
4757    /**
4758     * Allows a package listening to the
4759     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4760     * broadcast} to respond to the package manager. The response must include
4761     * the {@code verificationCode} which is one of
4762     * {@link PackageManager#VERIFICATION_ALLOW} or
4763     * {@link PackageManager#VERIFICATION_REJECT}.
4764     *
4765     * @param id pending package identifier as passed via the
4766     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4767     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
4768     *            or {@link PackageManager#VERIFICATION_REJECT}.
4769     * @throws SecurityException if the caller does not have the
4770     *            PACKAGE_VERIFICATION_AGENT permission.
4771     */
4772    public abstract void verifyPendingInstall(int id, int verificationCode);
4773
4774    /**
4775     * Allows a package listening to the
4776     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4777     * broadcast} to extend the default timeout for a response and declare what
4778     * action to perform after the timeout occurs. The response must include
4779     * the {@code verificationCodeAtTimeout} which is one of
4780     * {@link PackageManager#VERIFICATION_ALLOW} or
4781     * {@link PackageManager#VERIFICATION_REJECT}.
4782     *
4783     * This method may only be called once per package id. Additional calls
4784     * will have no effect.
4785     *
4786     * @param id pending package identifier as passed via the
4787     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4788     * @param verificationCodeAtTimeout either
4789     *            {@link PackageManager#VERIFICATION_ALLOW} or
4790     *            {@link PackageManager#VERIFICATION_REJECT}. If
4791     *            {@code verificationCodeAtTimeout} is neither
4792     *            {@link PackageManager#VERIFICATION_ALLOW} or
4793     *            {@link PackageManager#VERIFICATION_REJECT}, then
4794     *            {@code verificationCodeAtTimeout} will default to
4795     *            {@link PackageManager#VERIFICATION_REJECT}.
4796     * @param millisecondsToDelay the amount of time requested for the timeout.
4797     *            Must be positive and less than
4798     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4799     *            {@code millisecondsToDelay} is out of bounds,
4800     *            {@code millisecondsToDelay} will be set to the closest in
4801     *            bounds value; namely, 0 or
4802     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
4803     * @throws SecurityException if the caller does not have the
4804     *            PACKAGE_VERIFICATION_AGENT permission.
4805     */
4806    public abstract void extendVerificationTimeout(int id,
4807            int verificationCodeAtTimeout, long millisecondsToDelay);
4808
4809    /**
4810     * Allows a package listening to the
4811     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
4812     * broadcast to respond to the package manager. The response must include
4813     * the {@code verificationCode} which is one of
4814     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4815     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4816     *
4817     * @param verificationId pending package identifier as passed via the
4818     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4819     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4820     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4821     * @param failedDomains a list of failed domains if the verificationCode is
4822     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4823     * @throws SecurityException if the caller does not have the
4824     *            INTENT_FILTER_VERIFICATION_AGENT permission.
4825     *
4826     * @hide
4827     */
4828    @SystemApi
4829    @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT)
4830    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
4831            List<String> failedDomains);
4832
4833    /**
4834     * Get the status of a Domain Verification Result for an IntentFilter. This is
4835     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4836     * {@link android.content.IntentFilter#getAutoVerify()}
4837     *
4838     * This is used by the ResolverActivity to change the status depending on what the User select
4839     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4840     * for a domain.
4841     *
4842     * @param packageName The package name of the Activity associated with the IntentFilter.
4843     * @param userId The user id.
4844     *
4845     * @return The status to set to. This can be
4846     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4847     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4848     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4849     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4850     *
4851     * @hide
4852     */
4853    @SystemApi
4854    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
4855    public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
4856
4857    /**
4858     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4859     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4860     * {@link android.content.IntentFilter#getAutoVerify()}
4861     *
4862     * This is used by the ResolverActivity to change the status depending on what the User select
4863     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4864     * for a domain.
4865     *
4866     * @param packageName The package name of the Activity associated with the IntentFilter.
4867     * @param status The status to set to. This can be
4868     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4869     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4870     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4871     * @param userId The user id.
4872     *
4873     * @return true if the status has been set. False otherwise.
4874     *
4875     * @hide
4876     */
4877    @SystemApi
4878    @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
4879    public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
4880            @UserIdInt int userId);
4881
4882    /**
4883     * Get the list of IntentFilterVerificationInfo for a specific package and User.
4884     *
4885     * @param packageName the package name. When this parameter is set to a non null value,
4886     *                    the results will be filtered by the package name provided.
4887     *                    Otherwise, there will be no filtering and it will return a list
4888     *                    corresponding for all packages
4889     *
4890     * @return a list of IntentFilterVerificationInfo for a specific package.
4891     *
4892     * @hide
4893     */
4894    @SystemApi
4895    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4896            String packageName);
4897
4898    /**
4899     * Get the list of IntentFilter for a specific package.
4900     *
4901     * @param packageName the package name. This parameter is set to a non null value,
4902     *                    the list will contain all the IntentFilter for that package.
4903     *                    Otherwise, the list will be empty.
4904     *
4905     * @return a list of IntentFilter for a specific package.
4906     *
4907     * @hide
4908     */
4909    @SystemApi
4910    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4911
4912    /**
4913     * Get the default Browser package name for a specific user.
4914     *
4915     * @param userId The user id.
4916     *
4917     * @return the package name of the default Browser for the specified user. If the user id passed
4918     *         is -1 (all users) it will return a null value.
4919     *
4920     * @hide
4921     */
4922    @TestApi
4923    @SystemApi
4924    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL)
4925    public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
4926
4927    /**
4928     * Set the default Browser package name for a specific user.
4929     *
4930     * @param packageName The package name of the default Browser.
4931     * @param userId The user id.
4932     *
4933     * @return true if the default Browser for the specified user has been set,
4934     *         otherwise return false. If the user id passed is -1 (all users) this call will not
4935     *         do anything and just return false.
4936     *
4937     * @hide
4938     */
4939    @SystemApi
4940    @RequiresPermission(allOf = {
4941            Manifest.permission.SET_PREFERRED_APPLICATIONS,
4942            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4943    public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
4944            @UserIdInt int userId);
4945
4946    /**
4947     * Change the installer associated with a given package.  There are limitations
4948     * on how the installer package can be changed; in particular:
4949     * <ul>
4950     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
4951     * is not signed with the same certificate as the calling application.
4952     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
4953     * has an installer package, and that installer package is not signed with
4954     * the same certificate as the calling application.
4955     * </ul>
4956     *
4957     * @param targetPackage The installed package whose installer will be changed.
4958     * @param installerPackageName The package name of the new installer.  May be
4959     * null to clear the association.
4960     */
4961    public abstract void setInstallerPackageName(String targetPackage,
4962            String installerPackageName);
4963
4964    /** @hide */
4965    @SystemApi
4966    @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
4967    public abstract void setUpdateAvailable(String packageName, boolean updateAvaialble);
4968
4969    /**
4970     * Attempts to delete a package. Since this may take a little while, the
4971     * result will be posted back to the given observer. A deletion will fail if
4972     * the calling context lacks the
4973     * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
4974     * named package cannot be found, or if the named package is a system
4975     * package.
4976     *
4977     * @param packageName The name of the package to delete
4978     * @param observer An observer callback to get notified when the package
4979     *            deletion is complete.
4980     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
4981     *            will be called when that happens. observer may be null to
4982     *            indicate that no callback is desired.
4983     * @hide
4984     */
4985    @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
4986    public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
4987            @DeleteFlags int flags);
4988
4989    /**
4990     * Attempts to delete a package. Since this may take a little while, the
4991     * result will be posted back to the given observer. A deletion will fail if
4992     * the named package cannot be found, or if the named package is a system
4993     * package.
4994     *
4995     * @param packageName The name of the package to delete
4996     * @param observer An observer callback to get notified when the package
4997     *            deletion is complete.
4998     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
4999     *            will be called when that happens. observer may be null to
5000     *            indicate that no callback is desired.
5001     * @param userId The user Id
5002     * @hide
5003     */
5004    @RequiresPermission(anyOf = {
5005            Manifest.permission.DELETE_PACKAGES,
5006            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
5007    public abstract void deletePackageAsUser(@NonNull String packageName,
5008            IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId);
5009
5010    /**
5011     * Retrieve the package name of the application that installed a package. This identifies
5012     * which market the package came from.
5013     *
5014     * @param packageName The name of the package to query
5015     */
5016    public abstract String getInstallerPackageName(String packageName);
5017
5018    /**
5019     * Attempts to clear the user data directory of an application.
5020     * Since this may take a little while, the result will
5021     * be posted back to the given observer.  A deletion will fail if the
5022     * named package cannot be found, or if the named package is a "system package".
5023     *
5024     * @param packageName The name of the package
5025     * @param observer An observer callback to get notified when the operation is finished
5026     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5027     * will be called when that happens.  observer may be null to indicate that
5028     * no callback is desired.
5029     *
5030     * @hide
5031     */
5032    public abstract void clearApplicationUserData(String packageName,
5033            IPackageDataObserver observer);
5034    /**
5035     * Attempts to delete the cache files associated with an application.
5036     * Since this may take a little while, the result will
5037     * be posted back to the given observer.  A deletion will fail if the calling context
5038     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
5039     * named package cannot be found, or if the named package is a "system package".
5040     *
5041     * @param packageName The name of the package to delete
5042     * @param observer An observer callback to get notified when the cache file deletion
5043     * is complete.
5044     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5045     * will be called when that happens.  observer may be null to indicate that
5046     * no callback is desired.
5047     *
5048     * @hide
5049     */
5050    public abstract void deleteApplicationCacheFiles(String packageName,
5051            IPackageDataObserver observer);
5052
5053    /**
5054     * Attempts to delete the cache files associated with an application for a given user. Since
5055     * this may take a little while, the result will be posted back to the given observer. A
5056     * deletion will fail if the calling context lacks the
5057     * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
5058     * cannot be found, or if the named package is a "system package". If {@code userId} does not
5059     * belong to the calling user, the caller must have
5060     * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
5061     *
5062     * @param packageName The name of the package to delete
5063     * @param userId the user for which the cache files needs to be deleted
5064     * @param observer An observer callback to get notified when the cache file deletion is
5065     *            complete.
5066     *            {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5067     *            will be called when that happens. observer may be null to indicate that no
5068     *            callback is desired.
5069     * @hide
5070     */
5071    public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId,
5072            IPackageDataObserver observer);
5073
5074    /**
5075     * Free storage by deleting LRU sorted list of cache files across
5076     * all applications. If the currently available free storage
5077     * on the device is greater than or equal to the requested
5078     * free storage, no cache files are cleared. If the currently
5079     * available storage on the device is less than the requested
5080     * free storage, some or all of the cache files across
5081     * all applications are deleted (based on last accessed time)
5082     * to increase the free storage space on the device to
5083     * the requested value. There is no guarantee that clearing all
5084     * the cache files from all applications will clear up
5085     * enough storage to achieve the desired value.
5086     * @param freeStorageSize The number of bytes of storage to be
5087     * freed by the system. Say if freeStorageSize is XX,
5088     * and the current free storage is YY,
5089     * if XX is less than YY, just return. if not free XX-YY number
5090     * of bytes if possible.
5091     * @param observer call back used to notify when
5092     * the operation is completed
5093     *
5094     * @hide
5095     */
5096    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
5097        freeStorageAndNotify(null, freeStorageSize, observer);
5098    }
5099
5100    /** {@hide} */
5101    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
5102            IPackageDataObserver observer);
5103
5104    /**
5105     * Free storage by deleting LRU sorted list of cache files across
5106     * all applications. If the currently available free storage
5107     * on the device is greater than or equal to the requested
5108     * free storage, no cache files are cleared. If the currently
5109     * available storage on the device is less than the requested
5110     * free storage, some or all of the cache files across
5111     * all applications are deleted (based on last accessed time)
5112     * to increase the free storage space on the device to
5113     * the requested value. There is no guarantee that clearing all
5114     * the cache files from all applications will clear up
5115     * enough storage to achieve the desired value.
5116     * @param freeStorageSize The number of bytes of storage to be
5117     * freed by the system. Say if freeStorageSize is XX,
5118     * and the current free storage is YY,
5119     * if XX is less than YY, just return. if not free XX-YY number
5120     * of bytes if possible.
5121     * @param pi IntentSender call back used to
5122     * notify when the operation is completed.May be null
5123     * to indicate that no call back is desired.
5124     *
5125     * @hide
5126     */
5127    public void freeStorage(long freeStorageSize, IntentSender pi) {
5128        freeStorage(null, freeStorageSize, pi);
5129    }
5130
5131    /** {@hide} */
5132    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
5133
5134    /**
5135     * Retrieve the size information for a package.
5136     * Since this may take a little while, the result will
5137     * be posted back to the given observer.  The calling context
5138     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
5139     *
5140     * @param packageName The name of the package whose size information is to be retrieved
5141     * @param userId The user whose size information should be retrieved.
5142     * @param observer An observer callback to get notified when the operation
5143     * is complete.
5144     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
5145     * The observer's callback is invoked with a PackageStats object(containing the
5146     * code, data and cache sizes of the package) and a boolean value representing
5147     * the status of the operation. observer may be null to indicate that
5148     * no callback is desired.
5149     *
5150     * @deprecated use {@link StorageStatsManager} instead.
5151     * @hide
5152     */
5153    @Deprecated
5154    public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
5155            IPackageStatsObserver observer);
5156
5157    /**
5158     * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
5159     * returns the size for the calling user.
5160     *
5161     * @deprecated use {@link StorageStatsManager} instead.
5162     * @hide
5163     */
5164    @Deprecated
5165    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
5166        getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer);
5167    }
5168
5169    /**
5170     * @deprecated This function no longer does anything; it was an old
5171     * approach to managing preferred activities, which has been superseded
5172     * by (and conflicts with) the modern activity-based preferences.
5173     */
5174    @Deprecated
5175    public abstract void addPackageToPreferred(String packageName);
5176
5177    /**
5178     * @deprecated This function no longer does anything; it was an old
5179     * approach to managing preferred activities, which has been superseded
5180     * by (and conflicts with) the modern activity-based preferences.
5181     */
5182    @Deprecated
5183    public abstract void removePackageFromPreferred(String packageName);
5184
5185    /**
5186     * Retrieve the list of all currently configured preferred packages. The
5187     * first package on the list is the most preferred, the last is the least
5188     * preferred.
5189     *
5190     * @param flags Additional option flags to modify the data returned.
5191     * @return A List of PackageInfo objects, one for each preferred
5192     *         application, in order of preference.
5193     */
5194    public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
5195
5196    /**
5197     * @deprecated This is a protected API that should not have been available
5198     * to third party applications.  It is the platform's responsibility for
5199     * assigning preferred activities and this cannot be directly modified.
5200     *
5201     * Add a new preferred activity mapping to the system.  This will be used
5202     * to automatically select the given activity component when
5203     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5204     * multiple matching activities and also matches the given filter.
5205     *
5206     * @param filter The set of intents under which this activity will be
5207     * made preferred.
5208     * @param match The IntentFilter match category that this preference
5209     * applies to.
5210     * @param set The set of activities that the user was picking from when
5211     * this preference was made.
5212     * @param activity The component name of the activity that is to be
5213     * preferred.
5214     */
5215    @Deprecated
5216    public abstract void addPreferredActivity(IntentFilter filter, int match,
5217            ComponentName[] set, ComponentName activity);
5218
5219    /**
5220     * Same as {@link #addPreferredActivity(IntentFilter, int,
5221            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5222            to.
5223     * @hide
5224     */
5225    public void addPreferredActivityAsUser(IntentFilter filter, int match,
5226            ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5227        throw new RuntimeException("Not implemented. Must override in a subclass.");
5228    }
5229
5230    /**
5231     * @deprecated This is a protected API that should not have been available
5232     * to third party applications.  It is the platform's responsibility for
5233     * assigning preferred activities and this cannot be directly modified.
5234     *
5235     * Replaces an existing preferred activity mapping to the system, and if that were not present
5236     * adds a new preferred activity.  This will be used
5237     * to automatically select the given activity component when
5238     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5239     * multiple matching activities and also matches the given filter.
5240     *
5241     * @param filter The set of intents under which this activity will be
5242     * made preferred.
5243     * @param match The IntentFilter match category that this preference
5244     * applies to.
5245     * @param set The set of activities that the user was picking from when
5246     * this preference was made.
5247     * @param activity The component name of the activity that is to be
5248     * preferred.
5249     * @hide
5250     */
5251    @Deprecated
5252    public abstract void replacePreferredActivity(IntentFilter filter, int match,
5253            ComponentName[] set, ComponentName activity);
5254
5255    /**
5256     * @hide
5257     */
5258    @Deprecated
5259    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
5260           ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5261        throw new RuntimeException("Not implemented. Must override in a subclass.");
5262    }
5263
5264    /**
5265     * Remove all preferred activity mappings, previously added with
5266     * {@link #addPreferredActivity}, from the
5267     * system whose activities are implemented in the given package name.
5268     * An application can only clear its own package(s).
5269     *
5270     * @param packageName The name of the package whose preferred activity
5271     * mappings are to be removed.
5272     */
5273    public abstract void clearPackagePreferredActivities(String packageName);
5274
5275    /**
5276     * Retrieve all preferred activities, previously added with
5277     * {@link #addPreferredActivity}, that are
5278     * currently registered with the system.
5279     *
5280     * @param outFilters A required list in which to place the filters of all of the
5281     * preferred activities.
5282     * @param outActivities A required list in which to place the component names of
5283     * all of the preferred activities.
5284     * @param packageName An optional package in which you would like to limit
5285     * the list.  If null, all activities will be returned; if non-null, only
5286     * those activities in the given package are returned.
5287     *
5288     * @return Returns the total number of registered preferred activities
5289     * (the number of distinct IntentFilter records, not the number of unique
5290     * activity components) that were found.
5291     */
5292    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5293            @NonNull List<ComponentName> outActivities, String packageName);
5294
5295    /**
5296     * Ask for the set of available 'home' activities and the current explicit
5297     * default, if any.
5298     * @hide
5299     */
5300    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5301
5302    /**
5303     * Set the enabled setting for a package component (activity, receiver, service, provider).
5304     * This setting will override any enabled state which may have been set by the component in its
5305     * manifest.
5306     *
5307     * @param componentName The component to enable
5308     * @param newState The new enabled state for the component.
5309     * @param flags Optional behavior flags.
5310     */
5311    public abstract void setComponentEnabledSetting(ComponentName componentName,
5312            @EnabledState int newState, @EnabledFlags int flags);
5313
5314    /**
5315     * Return the enabled setting for a package component (activity,
5316     * receiver, service, provider).  This returns the last value set by
5317     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5318     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5319     * the value originally specified in the manifest has not been modified.
5320     *
5321     * @param componentName The component to retrieve.
5322     * @return Returns the current enabled state for the component.
5323     */
5324    public abstract @EnabledState int getComponentEnabledSetting(
5325            ComponentName componentName);
5326
5327    /**
5328     * Set the enabled setting for an application
5329     * This setting will override any enabled state which may have been set by the application in
5330     * its manifest.  It also overrides the enabled state set in the manifest for any of the
5331     * application's components.  It does not override any enabled state set by
5332     * {@link #setComponentEnabledSetting} for any of the application's components.
5333     *
5334     * @param packageName The package name of the application to enable
5335     * @param newState The new enabled state for the application.
5336     * @param flags Optional behavior flags.
5337     */
5338    public abstract void setApplicationEnabledSetting(String packageName,
5339            @EnabledState int newState, @EnabledFlags int flags);
5340
5341    /**
5342     * Return the enabled setting for an application. This returns
5343     * the last value set by
5344     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5345     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5346     * the value originally specified in the manifest has not been modified.
5347     *
5348     * @param packageName The package name of the application to retrieve.
5349     * @return Returns the current enabled state for the application.
5350     * @throws IllegalArgumentException if the named package does not exist.
5351     */
5352    public abstract @EnabledState int getApplicationEnabledSetting(String packageName);
5353
5354    /**
5355     * Flush the package restrictions for a given user to disk. This forces the package restrictions
5356     * like component and package enabled settings to be written to disk and avoids the delay that
5357     * is otherwise present when changing those settings.
5358     *
5359     * @param userId Ther userId of the user whose restrictions are to be flushed.
5360     * @hide
5361     */
5362    public abstract void flushPackageRestrictionsAsUser(int userId);
5363
5364    /**
5365     * Puts the package in a hidden state, which is almost like an uninstalled state,
5366     * making the package unavailable, but it doesn't remove the data or the actual
5367     * package file. Application can be unhidden by either resetting the hidden state
5368     * or by installing it, such as with {@link #installExistingPackage(String)}
5369     * @hide
5370     */
5371    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
5372            UserHandle userHandle);
5373
5374    /**
5375     * Returns the hidden state of a package.
5376     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
5377     * @hide
5378     */
5379    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
5380            UserHandle userHandle);
5381
5382    /**
5383     * Return whether the device has been booted into safe mode.
5384     */
5385    public abstract boolean isSafeMode();
5386
5387    /**
5388     * Adds a listener for permission changes for installed packages.
5389     *
5390     * @param listener The listener to add.
5391     *
5392     * @hide
5393     */
5394    @SystemApi
5395    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5396    public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5397
5398    /**
5399     * Remvoes a listener for permission changes for installed packages.
5400     *
5401     * @param listener The listener to remove.
5402     *
5403     * @hide
5404     */
5405    @SystemApi
5406    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5407    public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5408
5409    /**
5410     * Return the {@link KeySet} associated with the String alias for this
5411     * application.
5412     *
5413     * @param alias The alias for a given {@link KeySet} as defined in the
5414     *        application's AndroidManifest.xml.
5415     * @hide
5416     */
5417    public abstract KeySet getKeySetByAlias(String packageName, String alias);
5418
5419    /** Return the signing {@link KeySet} for this application.
5420     * @hide
5421     */
5422    public abstract KeySet getSigningKeySet(String packageName);
5423
5424    /**
5425     * Return whether the package denoted by packageName has been signed by all
5426     * of the keys specified by the {@link KeySet} ks.  This will return true if
5427     * the package has been signed by additional keys (a superset) as well.
5428     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
5429     * @hide
5430     */
5431    public abstract boolean isSignedBy(String packageName, KeySet ks);
5432
5433    /**
5434     * Return whether the package denoted by packageName has been signed by all
5435     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5436     * {@link #isSignedBy(String packageName, KeySet ks)}.
5437     * @hide
5438     */
5439    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5440
5441    /**
5442     * Puts the package in a suspended state, where attempts at starting activities are denied.
5443     *
5444     * <p>It doesn't remove the data or the actual package file. The application notifications
5445     * will be hidden, the application will not show up in recents, will not be able to show
5446     * toasts or dialogs or ring the device.
5447     *
5448     * <p>The package must already be installed. If the package is uninstalled while suspended
5449     * the package will no longer be suspended.
5450     *
5451     * @param packageNames The names of the packages to set the suspended status.
5452     * @param suspended If set to {@code true} than the packages will be suspended, if set to
5453     * {@code false} the packages will be unsuspended.
5454     * @param userId The user id.
5455     *
5456     * @return an array of package names for which the suspended status is not set as requested in
5457     * this method.
5458     *
5459     * @hide
5460     */
5461    public abstract String[] setPackagesSuspendedAsUser(
5462            String[] packageNames, boolean suspended, @UserIdInt int userId);
5463
5464    /**
5465     * @see #setPackageSuspendedAsUser(String, boolean, int)
5466     * @param packageName The name of the package to get the suspended status of.
5467     * @param userId The user id.
5468     * @return {@code true} if the package is suspended or {@code false} if the package is not
5469     * suspended or could not be found.
5470     * @hide
5471     */
5472    public abstract boolean isPackageSuspendedForUser(String packageName, int userId);
5473
5474    /**
5475     * Provide a hint of what the {@link ApplicationInfo#category} value should
5476     * be for the given package.
5477     * <p>
5478     * This hint can only be set by the app which installed this package, as
5479     * determined by {@link #getInstallerPackageName(String)}.
5480     *
5481     * @param packageName the package to change the category hint for.
5482     * @param categoryHint the category hint to set.
5483     */
5484    public abstract void setApplicationCategoryHint(@NonNull String packageName,
5485            @ApplicationInfo.Category int categoryHint);
5486
5487    /** {@hide} */
5488    public static boolean isMoveStatusFinished(int status) {
5489        return (status < 0 || status > 100);
5490    }
5491
5492    /** {@hide} */
5493    public static abstract class MoveCallback {
5494        public void onCreated(int moveId, Bundle extras) {}
5495        public abstract void onStatusChanged(int moveId, int status, long estMillis);
5496    }
5497
5498    /** {@hide} */
5499    public abstract int getMoveStatus(int moveId);
5500
5501    /** {@hide} */
5502    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5503    /** {@hide} */
5504    public abstract void unregisterMoveCallback(MoveCallback callback);
5505
5506    /** {@hide} */
5507    public abstract int movePackage(String packageName, VolumeInfo vol);
5508    /** {@hide} */
5509    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5510    /** {@hide} */
5511    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5512
5513    /** {@hide} */
5514    public abstract int movePrimaryStorage(VolumeInfo vol);
5515    /** {@hide} */
5516    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5517    /** {@hide} */
5518    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
5519
5520    /**
5521     * Returns the device identity that verifiers can use to associate their scheme to a particular
5522     * device. This should not be used by anything other than a package verifier.
5523     *
5524     * @return identity that uniquely identifies current device
5525     * @hide
5526     */
5527    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
5528
5529    /**
5530     * Returns true if the device is upgrading, such as first boot after OTA.
5531     *
5532     * @hide
5533     */
5534    public abstract boolean isUpgrade();
5535
5536    /**
5537     * Return interface that offers the ability to install, upgrade, and remove
5538     * applications on the device.
5539     */
5540    public abstract @NonNull PackageInstaller getPackageInstaller();
5541
5542    /**
5543     * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5544     * intents sent from the user with id sourceUserId can also be be resolved
5545     * by activities in the user with id targetUserId if they match the
5546     * specified intent filter.
5547     *
5548     * @param filter The {@link IntentFilter} the intent has to match
5549     * @param sourceUserId The source user id.
5550     * @param targetUserId The target user id.
5551     * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5552     *            {@link #ONLY_IF_NO_MATCH_FOUND}.
5553     * @hide
5554     */
5555    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5556            int targetUserId, int flags);
5557
5558    /**
5559     * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5560     * as their source, and have been set by the app calling this method.
5561     *
5562     * @param sourceUserId The source user id.
5563     * @hide
5564     */
5565    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
5566
5567    /**
5568     * @hide
5569     */
5570    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5571
5572    /**
5573     * @hide
5574     */
5575    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5576
5577    /** {@hide} */
5578    public abstract boolean isPackageAvailable(String packageName);
5579
5580    /** {@hide} */
5581    public static String installStatusToString(int status, String msg) {
5582        final String str = installStatusToString(status);
5583        if (msg != null) {
5584            return str + ": " + msg;
5585        } else {
5586            return str;
5587        }
5588    }
5589
5590    /** {@hide} */
5591    public static String installStatusToString(int status) {
5592        switch (status) {
5593            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5594            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5595            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5596            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5597            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5598            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5599            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5600            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5601            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5602            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5603            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5604            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5605            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5606            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5607            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5608            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5609            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5610            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5611            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5612            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5613            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5614            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5615            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5616            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5617            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5618            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5619            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5620            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5621            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5622            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5623            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5624            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5625            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5626            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5627            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5628            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5629            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5630            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5631            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5632            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
5633            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
5634            default: return Integer.toString(status);
5635        }
5636    }
5637
5638    /** {@hide} */
5639    public static int installStatusToPublicStatus(int status) {
5640        switch (status) {
5641            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5642            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5643            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5644            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5645            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5646            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5647            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5648            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5649            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5650            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5651            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5652            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5653            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5654            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5655            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5656            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5657            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5658            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5659            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5660            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5661            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5662            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5663            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5664            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5665            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5666            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5667            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5668            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5669            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5670            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5671            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5672            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5673            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5674            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5675            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5676            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5677            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
5678            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5679            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5680            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5681            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5682            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5683            default: return PackageInstaller.STATUS_FAILURE;
5684        }
5685    }
5686
5687    /** {@hide} */
5688    public static String deleteStatusToString(int status, String msg) {
5689        final String str = deleteStatusToString(status);
5690        if (msg != null) {
5691            return str + ": " + msg;
5692        } else {
5693            return str;
5694        }
5695    }
5696
5697    /** {@hide} */
5698    public static String deleteStatusToString(int status) {
5699        switch (status) {
5700            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5701            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5702            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5703            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5704            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
5705            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
5706            case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY";
5707            default: return Integer.toString(status);
5708        }
5709    }
5710
5711    /** {@hide} */
5712    public static int deleteStatusToPublicStatus(int status) {
5713        switch (status) {
5714            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5715            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5716            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5717            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5718            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5719            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5720            case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5721            default: return PackageInstaller.STATUS_FAILURE;
5722        }
5723    }
5724
5725    /** {@hide} */
5726    public static String permissionFlagToString(int flag) {
5727        switch (flag) {
5728            case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
5729            case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
5730            case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
5731            case FLAG_PERMISSION_USER_SET: return "USER_SET";
5732            case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
5733            case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
5734            case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
5735            default: return Integer.toString(flag);
5736        }
5737    }
5738
5739    /** {@hide} */
5740    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
5741        private final IPackageDeleteObserver mLegacy;
5742
5743        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
5744            mLegacy = legacy;
5745        }
5746
5747        @Override
5748        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
5749            if (mLegacy == null) return;
5750            try {
5751                mLegacy.packageDeleted(basePackageName, returnCode);
5752            } catch (RemoteException ignored) {
5753            }
5754        }
5755    }
5756
5757    /**
5758     * Return the install reason that was recorded when a package was first
5759     * installed for a specific user. Requesting the install reason for another
5760     * user will require the permission INTERACT_ACROSS_USERS_FULL.
5761     *
5762     * @param packageName The package for which to retrieve the install reason
5763     * @param user The user for whom to retrieve the install reason
5764     * @return The install reason. If the package is not installed for the given
5765     *         user, {@code INSTALL_REASON_UNKNOWN} is returned.
5766     * @hide
5767     */
5768    @TestApi
5769    public abstract @InstallReason int getInstallReason(String packageName,
5770            @NonNull UserHandle user);
5771
5772    /**
5773     * Checks whether the calling package is allowed to request package installs through package
5774     * installer. Apps are encouraged to call this API before launching the package installer via
5775     * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the
5776     * user can explicitly choose what external sources they trust to install apps on the device.
5777     * If this API returns false, the install request will be blocked by the package installer and
5778     * a dialog will be shown to the user with an option to launch settings to change their
5779     * preference. An application must target Android O or higher and declare permission
5780     * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API.
5781     *
5782     * @return true if the calling package is trusted by the user to request install packages on
5783     * the device, false otherwise.
5784     * @see android.content.Intent#ACTION_INSTALL_PACKAGE
5785     * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES
5786     */
5787    public abstract boolean canRequestPackageInstalls();
5788
5789    /**
5790     * Return the {@link ComponentName} of the activity providing Settings for the Instant App
5791     * resolver.
5792     *
5793     * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS}
5794     * @hide
5795     */
5796    @SystemApi
5797    public abstract ComponentName getInstantAppResolverSettingsComponent();
5798
5799    /**
5800     * Return the {@link ComponentName} of the activity responsible for installing instant
5801     * applications.
5802     *
5803     * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE}
5804     * @hide
5805     */
5806    @SystemApi
5807    public abstract ComponentName getInstantAppInstallerComponent();
5808
5809    /**
5810     * Return the Android Id for a given Instant App.
5811     *
5812     * @see {@link android.provider.Settings.Secure#ANDROID_ID}
5813     * @hide
5814     */
5815    public abstract String getInstantAppAndroidId(String packageName, @NonNull UserHandle user);
5816
5817    /**
5818     * Callback use to notify the callers of module registration that the operation
5819     * has finished.
5820     *
5821     * @hide
5822     */
5823    @SystemApi
5824    public static abstract class DexModuleRegisterCallback {
5825        public abstract void onDexModuleRegistered(String dexModulePath, boolean success,
5826                String message);
5827    }
5828
5829    /**
5830     * Register an application dex module with the package manager.
5831     * The package manager will keep track of the given module for future optimizations.
5832     *
5833     * Dex module optimizations will disable the classpath checking at runtime. The client bares
5834     * the responsibility to ensure that the static assumptions on classes in the optimized code
5835     * hold at runtime (e.g. there's no duplicate classes in the classpath).
5836     *
5837     * Note that the package manager already keeps track of dex modules loaded with
5838     * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}.
5839     * This can be called for an eager registration.
5840     *
5841     * The call might take a while and the results will be posted on the main thread, using
5842     * the given callback.
5843     *
5844     * If the module is intended to be shared with other apps, make sure that the file
5845     * permissions allow for it.
5846     * If at registration time the permissions allow for others to read it, the module would
5847     * be marked as a shared module which might undergo a different optimization strategy.
5848     * (usually shared modules will generated larger optimizations artifacts,
5849     * taking more disk space).
5850     *
5851     * @param dexModulePath the absolute path of the dex module.
5852     * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will
5853     *                 be called once the registration finishes.
5854     *
5855     * @hide
5856     */
5857    @SystemApi
5858    public abstract void registerDexModule(String dexModulePath,
5859            @Nullable DexModuleRegisterCallback callback);
5860
5861    /**
5862     * Returns the {@link ArtManager} associated with this package manager.
5863     *
5864     * @hide
5865     */
5866    @SystemApi
5867    public @NonNull ArtManager getArtManager() {
5868        throw new UnsupportedOperationException("getArtManager not implemented in subclass");
5869    }
5870}
5871