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