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