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