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