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