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