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