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