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