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