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