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