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