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