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