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