PackageManager.java revision d6ee0ba57906f83f45ca2a2cd835d7ff6e7a88df
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 @Nullable String getServicesSystemSharedLibraryPackageName();
3514
3515    /**
3516     * Get a list of features that are available on the
3517     * system.
3518     *
3519     * @return An array of FeatureInfo classes describing the features
3520     * that are available on the system, or null if there are none(!!).
3521     */
3522    public abstract FeatureInfo[] getSystemAvailableFeatures();
3523
3524    /**
3525     * Check whether the given feature name is one of the available features as
3526     * returned by {@link #getSystemAvailableFeatures()}. This tests for the
3527     * presence of <em>any</em> version of the given feature name; use
3528     * {@link #hasSystemFeature(String, int)} to check for a minimum version.
3529     *
3530     * @return Returns true if the devices supports the feature, else false.
3531     */
3532    public abstract boolean hasSystemFeature(String name);
3533
3534    /**
3535     * Check whether the given feature name and version is one of the available
3536     * features as returned by {@link #getSystemAvailableFeatures()}. Since
3537     * features are defined to always be backwards compatible, this returns true
3538     * if the available feature version is greater than or equal to the
3539     * requested version.
3540     *
3541     * @return Returns true if the devices supports the feature, else false.
3542     */
3543    public abstract boolean hasSystemFeature(String name, int version);
3544
3545    /**
3546     * Determine the best action to perform for a given Intent. This is how
3547     * {@link Intent#resolveActivity} finds an activity if a class has not been
3548     * explicitly specified.
3549     * <p>
3550     * <em>Note:</em> if using an implicit Intent (without an explicit
3551     * ComponentName specified), be sure to consider whether to set the
3552     * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3553     * activity in the same way that
3554     * {@link android.content.Context#startActivity(Intent)} and
3555     * {@link android.content.Intent#resolveActivity(PackageManager)
3556     * Intent.resolveActivity(PackageManager)} do.
3557     * </p>
3558     *
3559     * @param intent An intent containing all of the desired specification
3560     *            (action, data, type, category, and/or component).
3561     * @param flags Additional option flags. Use any combination of
3562     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3563     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3564     *            {@link #MATCH_DISABLED_COMPONENTS},
3565     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3566     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3567     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3568     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3569     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3570     *            to limit the resolution to only those activities that support
3571     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
3572     * @return Returns a ResolveInfo object containing the final activity intent
3573     *         that was determined to be the best action. Returns null if no
3574     *         matching activity was found. If multiple matching activities are
3575     *         found and there is no default set, returns a ResolveInfo object
3576     *         containing something else, such as the activity resolver.
3577     * @see #GET_META_DATA
3578     * @see #GET_RESOLVED_FILTER
3579     * @see #GET_SHARED_LIBRARY_FILES
3580     * @see #MATCH_ALL
3581     * @see #MATCH_DISABLED_COMPONENTS
3582     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3583     * @see #MATCH_DEFAULT_ONLY
3584     * @see #MATCH_DIRECT_BOOT_AWARE
3585     * @see #MATCH_DIRECT_BOOT_UNAWARE
3586     * @see #MATCH_SYSTEM_ONLY
3587     * @see #MATCH_UNINSTALLED_PACKAGES
3588     */
3589    public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
3590
3591    /**
3592     * Determine the best action to perform for a given Intent for a given user.
3593     * This is how {@link Intent#resolveActivity} finds an activity if a class
3594     * has not been explicitly specified.
3595     * <p>
3596     * <em>Note:</em> if using an implicit Intent (without an explicit
3597     * ComponentName specified), be sure to consider whether to set the
3598     * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3599     * activity in the same way that
3600     * {@link android.content.Context#startActivity(Intent)} and
3601     * {@link android.content.Intent#resolveActivity(PackageManager)
3602     * Intent.resolveActivity(PackageManager)} do.
3603     * </p>
3604     *
3605     * @param intent An intent containing all of the desired specification
3606     *            (action, data, type, category, and/or component).
3607     * @param flags Additional option flags. Use any combination of
3608     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3609     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3610     *            {@link #MATCH_DISABLED_COMPONENTS},
3611     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3612     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3613     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3614     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3615     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3616     *            to limit the resolution to only those activities that support
3617     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
3618     * @param userId The user id.
3619     * @return Returns a ResolveInfo object containing the final activity intent
3620     *         that was determined to be the best action. Returns null if no
3621     *         matching activity was found. If multiple matching activities are
3622     *         found and there is no default set, returns a ResolveInfo object
3623     *         containing something else, such as the activity resolver.
3624     * @see #GET_META_DATA
3625     * @see #GET_RESOLVED_FILTER
3626     * @see #GET_SHARED_LIBRARY_FILES
3627     * @see #MATCH_ALL
3628     * @see #MATCH_DISABLED_COMPONENTS
3629     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3630     * @see #MATCH_DEFAULT_ONLY
3631     * @see #MATCH_DIRECT_BOOT_AWARE
3632     * @see #MATCH_DIRECT_BOOT_UNAWARE
3633     * @see #MATCH_SYSTEM_ONLY
3634     * @see #MATCH_UNINSTALLED_PACKAGES
3635     * @hide
3636     */
3637    public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
3638            @UserIdInt int userId);
3639
3640    /**
3641     * Retrieve all activities that can be performed for the given intent.
3642     *
3643     * @param intent The desired intent as per resolveActivity().
3644     * @param flags Additional option flags. Use any combination of
3645     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3646     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3647     *            {@link #MATCH_DISABLED_COMPONENTS},
3648     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3649     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3650     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3651     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3652     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3653     *            to limit the resolution to only those activities that support
3654     *            the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
3655     *            {@link #MATCH_ALL} to prevent any filtering of the results.
3656     * @return Returns a List of ResolveInfo objects containing one entry for
3657     *         each matching activity, ordered from best to worst. In other
3658     *         words, the first item is what would be returned by
3659     *         {@link #resolveActivity}. If there are no matching activities, an
3660     *         empty list is returned.
3661     * @see #GET_META_DATA
3662     * @see #GET_RESOLVED_FILTER
3663     * @see #GET_SHARED_LIBRARY_FILES
3664     * @see #MATCH_ALL
3665     * @see #MATCH_DISABLED_COMPONENTS
3666     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3667     * @see #MATCH_DEFAULT_ONLY
3668     * @see #MATCH_DIRECT_BOOT_AWARE
3669     * @see #MATCH_DIRECT_BOOT_UNAWARE
3670     * @see #MATCH_SYSTEM_ONLY
3671     * @see #MATCH_UNINSTALLED_PACKAGES
3672     */
3673    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
3674            @ResolveInfoFlags int flags);
3675
3676    /**
3677     * Retrieve all activities that can be performed for the given intent, for a
3678     * specific user.
3679     *
3680     * @param intent The desired intent as per resolveActivity().
3681     * @param flags Additional option flags. Use any combination of
3682     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3683     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3684     *            {@link #MATCH_DISABLED_COMPONENTS},
3685     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3686     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3687     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3688     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3689     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3690     *            to limit the resolution to only those activities that support
3691     *            the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
3692     *            {@link #MATCH_ALL} to prevent any filtering of the results.
3693     * @return Returns a List of ResolveInfo objects containing one entry for
3694     *         each matching activity, ordered from best to worst. In other
3695     *         words, the first item is what would be returned by
3696     *         {@link #resolveActivity}. If there are no matching activities, an
3697     *         empty list is returned.
3698     * @see #GET_META_DATA
3699     * @see #GET_RESOLVED_FILTER
3700     * @see #GET_SHARED_LIBRARY_FILES
3701     * @see #MATCH_ALL
3702     * @see #MATCH_DISABLED_COMPONENTS
3703     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3704     * @see #MATCH_DEFAULT_ONLY
3705     * @see #MATCH_DIRECT_BOOT_AWARE
3706     * @see #MATCH_DIRECT_BOOT_UNAWARE
3707     * @see #MATCH_SYSTEM_ONLY
3708     * @see #MATCH_UNINSTALLED_PACKAGES
3709     * @hide
3710     */
3711    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
3712            @ResolveInfoFlags int flags, @UserIdInt int userId);
3713
3714    /**
3715     * Retrieve a set of activities that should be presented to the user as
3716     * similar options. This is like {@link #queryIntentActivities}, except it
3717     * also allows you to supply a list of more explicit Intents that you would
3718     * like to resolve to particular options, and takes care of returning the
3719     * final ResolveInfo list in a reasonable order, with no duplicates, based
3720     * on those inputs.
3721     *
3722     * @param caller The class name of the activity that is making the request.
3723     *            This activity will never appear in the output list. Can be
3724     *            null.
3725     * @param specifics An array of Intents that should be resolved to the first
3726     *            specific results. Can be null.
3727     * @param intent The desired intent as per resolveActivity().
3728     * @param flags Additional option flags. Use any combination of
3729     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3730     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3731     *            {@link #MATCH_DISABLED_COMPONENTS},
3732     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3733     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3734     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3735     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3736     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3737     *            to limit the resolution to only those activities that support
3738     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
3739     * @return Returns a List of ResolveInfo objects containing one entry for
3740     *         each matching activity. The list is ordered first by all of the
3741     *         intents resolved in <var>specifics</var> and then any additional
3742     *         activities that can handle <var>intent</var> but did not get
3743     *         included by one of the <var>specifics</var> intents. If there are
3744     *         no matching activities, an empty list is returned.
3745     * @see #GET_META_DATA
3746     * @see #GET_RESOLVED_FILTER
3747     * @see #GET_SHARED_LIBRARY_FILES
3748     * @see #MATCH_ALL
3749     * @see #MATCH_DISABLED_COMPONENTS
3750     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3751     * @see #MATCH_DEFAULT_ONLY
3752     * @see #MATCH_DIRECT_BOOT_AWARE
3753     * @see #MATCH_DIRECT_BOOT_UNAWARE
3754     * @see #MATCH_SYSTEM_ONLY
3755     * @see #MATCH_UNINSTALLED_PACKAGES
3756     */
3757    public abstract List<ResolveInfo> queryIntentActivityOptions(
3758            ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
3759
3760    /**
3761     * Retrieve all receivers that can handle a broadcast of the given intent.
3762     *
3763     * @param intent The desired intent as per resolveActivity().
3764     * @param flags Additional option flags. Use any combination of
3765     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3766     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3767     *            {@link #MATCH_DISABLED_COMPONENTS},
3768     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3769     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3770     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3771     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3772     *            returned.
3773     * @return Returns a List of ResolveInfo objects containing one entry for
3774     *         each matching receiver, ordered from best to worst. If there are
3775     *         no matching receivers, an empty list or null is returned.
3776     * @see #GET_META_DATA
3777     * @see #GET_RESOLVED_FILTER
3778     * @see #GET_SHARED_LIBRARY_FILES
3779     * @see #MATCH_ALL
3780     * @see #MATCH_DISABLED_COMPONENTS
3781     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3782     * @see #MATCH_DEFAULT_ONLY
3783     * @see #MATCH_DIRECT_BOOT_AWARE
3784     * @see #MATCH_DIRECT_BOOT_UNAWARE
3785     * @see #MATCH_SYSTEM_ONLY
3786     * @see #MATCH_UNINSTALLED_PACKAGES
3787     */
3788    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3789            @ResolveInfoFlags int flags);
3790
3791    /**
3792     * Retrieve all receivers that can handle a broadcast of the given intent,
3793     * for a specific user.
3794     *
3795     * @param intent The desired intent as per resolveActivity().
3796     * @param flags Additional option flags. Use any combination of
3797     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3798     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3799     *            {@link #MATCH_DISABLED_COMPONENTS},
3800     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3801     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3802     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3803     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3804     *            returned.
3805     * @param userHandle UserHandle of the user being queried.
3806     * @return Returns a List of ResolveInfo objects containing one entry for
3807     *         each matching receiver, ordered from best to worst. If there are
3808     *         no matching receivers, an empty list or null is returned.
3809     * @see #GET_META_DATA
3810     * @see #GET_RESOLVED_FILTER
3811     * @see #GET_SHARED_LIBRARY_FILES
3812     * @see #MATCH_ALL
3813     * @see #MATCH_DISABLED_COMPONENTS
3814     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3815     * @see #MATCH_DEFAULT_ONLY
3816     * @see #MATCH_DIRECT_BOOT_AWARE
3817     * @see #MATCH_DIRECT_BOOT_UNAWARE
3818     * @see #MATCH_SYSTEM_ONLY
3819     * @see #MATCH_UNINSTALLED_PACKAGES
3820     * @hide
3821     */
3822    @SystemApi
3823    public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
3824            @ResolveInfoFlags int flags, UserHandle userHandle) {
3825        return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
3826    }
3827
3828    /**
3829     * @hide
3830     */
3831    public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
3832            @ResolveInfoFlags int flags, @UserIdInt int userId);
3833
3834
3835    /** {@hide} */
3836    @Deprecated
3837    public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3838            @ResolveInfoFlags int flags, @UserIdInt int userId) {
3839        Log.w(TAG, "STAHP USING HIDDEN APIS KTHX");
3840        return queryBroadcastReceiversAsUser(intent, flags, userId);
3841    }
3842
3843    /**
3844     * Determine the best service to handle for a given Intent.
3845     *
3846     * @param intent An intent containing all of the desired specification
3847     *            (action, data, type, category, and/or component).
3848     * @param flags Additional option flags. Use any combination of
3849     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3850     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3851     *            {@link #MATCH_DISABLED_COMPONENTS},
3852     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3853     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3854     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3855     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3856     *            returned.
3857     * @return Returns a ResolveInfo object containing the final service intent
3858     *         that was determined to be the best action. Returns null if no
3859     *         matching service was found.
3860     * @see #GET_META_DATA
3861     * @see #GET_RESOLVED_FILTER
3862     * @see #GET_SHARED_LIBRARY_FILES
3863     * @see #MATCH_ALL
3864     * @see #MATCH_DISABLED_COMPONENTS
3865     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3866     * @see #MATCH_DEFAULT_ONLY
3867     * @see #MATCH_DIRECT_BOOT_AWARE
3868     * @see #MATCH_DIRECT_BOOT_UNAWARE
3869     * @see #MATCH_SYSTEM_ONLY
3870     * @see #MATCH_UNINSTALLED_PACKAGES
3871     */
3872    public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
3873
3874    /**
3875     * Retrieve all services that can match the given intent.
3876     *
3877     * @param intent The desired intent as per resolveService().
3878     * @param flags Additional option flags. Use any combination of
3879     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3880     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3881     *            {@link #MATCH_DISABLED_COMPONENTS},
3882     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3883     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3884     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3885     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3886     *            returned.
3887     * @return Returns a List of ResolveInfo objects containing one entry for
3888     *         each matching service, ordered from best to worst. In other
3889     *         words, the first item is what would be returned by
3890     *         {@link #resolveService}. If there are no matching services, an
3891     *         empty list or null is returned.
3892     * @see #GET_META_DATA
3893     * @see #GET_RESOLVED_FILTER
3894     * @see #GET_SHARED_LIBRARY_FILES
3895     * @see #MATCH_ALL
3896     * @see #MATCH_DISABLED_COMPONENTS
3897     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3898     * @see #MATCH_DEFAULT_ONLY
3899     * @see #MATCH_DIRECT_BOOT_AWARE
3900     * @see #MATCH_DIRECT_BOOT_UNAWARE
3901     * @see #MATCH_SYSTEM_ONLY
3902     * @see #MATCH_UNINSTALLED_PACKAGES
3903     */
3904    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
3905            @ResolveInfoFlags int flags);
3906
3907    /**
3908     * Retrieve all services that can match the given intent for a given user.
3909     *
3910     * @param intent The desired intent as per resolveService().
3911     * @param flags Additional option flags. Use any combination of
3912     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3913     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3914     *            {@link #MATCH_DISABLED_COMPONENTS},
3915     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3916     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3917     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3918     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3919     *            returned.
3920     * @param userId The user id.
3921     * @return Returns a List of ResolveInfo objects containing one entry for
3922     *         each matching service, ordered from best to worst. In other
3923     *         words, the first item is what would be returned by
3924     *         {@link #resolveService}. If there are no matching services, an
3925     *         empty list or null is returned.
3926     * @see #GET_META_DATA
3927     * @see #GET_RESOLVED_FILTER
3928     * @see #GET_SHARED_LIBRARY_FILES
3929     * @see #MATCH_ALL
3930     * @see #MATCH_DISABLED_COMPONENTS
3931     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3932     * @see #MATCH_DEFAULT_ONLY
3933     * @see #MATCH_DIRECT_BOOT_AWARE
3934     * @see #MATCH_DIRECT_BOOT_UNAWARE
3935     * @see #MATCH_SYSTEM_ONLY
3936     * @see #MATCH_UNINSTALLED_PACKAGES
3937     * @hide
3938     */
3939    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
3940            @ResolveInfoFlags int flags, @UserIdInt int userId);
3941
3942    /**
3943     * Retrieve all providers that can match the given intent.
3944     *
3945     * @param intent An intent containing all of the desired specification
3946     *            (action, data, type, category, and/or component).
3947     * @param flags Additional option flags. Use any combination of
3948     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3949     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3950     *            {@link #MATCH_DISABLED_COMPONENTS},
3951     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3952     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3953     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3954     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3955     *            returned.
3956     * @param userId The user id.
3957     * @return Returns a List of ResolveInfo objects containing one entry for
3958     *         each matching provider, ordered from best to worst. If there are
3959     *         no matching services, an empty list or null is returned.
3960     * @see #GET_META_DATA
3961     * @see #GET_RESOLVED_FILTER
3962     * @see #GET_SHARED_LIBRARY_FILES
3963     * @see #MATCH_ALL
3964     * @see #MATCH_DISABLED_COMPONENTS
3965     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3966     * @see #MATCH_DEFAULT_ONLY
3967     * @see #MATCH_DIRECT_BOOT_AWARE
3968     * @see #MATCH_DIRECT_BOOT_UNAWARE
3969     * @see #MATCH_SYSTEM_ONLY
3970     * @see #MATCH_UNINSTALLED_PACKAGES
3971     * @hide
3972     */
3973    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
3974            Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
3975
3976    /**
3977     * Retrieve all providers that can match the given intent.
3978     *
3979     * @param intent An intent containing all of the desired specification
3980     *            (action, data, type, category, and/or component).
3981     * @param flags Additional option flags. Use any combination of
3982     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3983     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3984     *            {@link #MATCH_DISABLED_COMPONENTS},
3985     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3986     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3987     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3988     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3989     *            returned.
3990     * @return Returns a List of ResolveInfo objects containing one entry for
3991     *         each matching provider, ordered from best to worst. If there are
3992     *         no matching services, an empty list or null is returned.
3993     * @see #GET_META_DATA
3994     * @see #GET_RESOLVED_FILTER
3995     * @see #GET_SHARED_LIBRARY_FILES
3996     * @see #MATCH_ALL
3997     * @see #MATCH_DISABLED_COMPONENTS
3998     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3999     * @see #MATCH_DEFAULT_ONLY
4000     * @see #MATCH_DIRECT_BOOT_AWARE
4001     * @see #MATCH_DIRECT_BOOT_UNAWARE
4002     * @see #MATCH_SYSTEM_ONLY
4003     * @see #MATCH_UNINSTALLED_PACKAGES
4004     */
4005    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
4006            @ResolveInfoFlags int flags);
4007
4008    /**
4009     * Find a single content provider by its base path name.
4010     *
4011     * @param name The name of the provider to find.
4012     * @param flags Additional option flags. Use any combination of
4013     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4014     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4015     *            {@link #MATCH_DISABLED_COMPONENTS},
4016     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4017     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4018     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4019     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4020     *            returned.
4021     * @return A {@link ProviderInfo} object containing information about the
4022     *         provider. If a provider was not found, returns null.
4023     * @see #GET_META_DATA
4024     * @see #GET_SHARED_LIBRARY_FILES
4025     * @see #MATCH_ALL
4026     * @see #MATCH_DEBUG_TRIAGED_MISSING
4027     * @see #MATCH_DEFAULT_ONLY
4028     * @see #MATCH_DISABLED_COMPONENTS
4029     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4030     * @see #MATCH_DIRECT_BOOT_AWARE
4031     * @see #MATCH_DIRECT_BOOT_UNAWARE
4032     * @see #MATCH_SYSTEM_ONLY
4033     * @see #MATCH_UNINSTALLED_PACKAGES
4034     */
4035    public abstract ProviderInfo resolveContentProvider(String name,
4036            @ComponentInfoFlags int flags);
4037
4038    /**
4039     * Find a single content provider by its base path name.
4040     *
4041     * @param name The name of the provider to find.
4042     * @param flags Additional option flags. Use any combination of
4043     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4044     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4045     *            {@link #MATCH_DISABLED_COMPONENTS},
4046     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4047     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4048     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4049     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4050     *            returned.
4051     * @param userId The user id.
4052     * @return A {@link ProviderInfo} object containing information about the
4053     *         provider. If a provider was not found, returns null.
4054     * @see #GET_META_DATA
4055     * @see #GET_SHARED_LIBRARY_FILES
4056     * @see #MATCH_ALL
4057     * @see #MATCH_DEBUG_TRIAGED_MISSING
4058     * @see #MATCH_DEFAULT_ONLY
4059     * @see #MATCH_DISABLED_COMPONENTS
4060     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4061     * @see #MATCH_DIRECT_BOOT_AWARE
4062     * @see #MATCH_DIRECT_BOOT_UNAWARE
4063     * @see #MATCH_SYSTEM_ONLY
4064     * @see #MATCH_UNINSTALLED_PACKAGES
4065     * @hide
4066     */
4067    public abstract ProviderInfo resolveContentProviderAsUser(String name,
4068            @ComponentInfoFlags int flags, @UserIdInt int userId);
4069
4070    /**
4071     * Retrieve content provider information.
4072     * <p>
4073     * <em>Note: unlike most other methods, an empty result set is indicated
4074     * by a null return instead of an empty list.</em>
4075     *
4076     * @param processName If non-null, limits the returned providers to only
4077     *            those that are hosted by the given process. If null, all
4078     *            content providers are returned.
4079     * @param uid If <var>processName</var> is non-null, this is the required
4080     *            uid owning the requested content providers.
4081     * @param flags Additional option flags. Use any combination of
4082     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4083     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4084     *            {@link #MATCH_DISABLED_COMPONENTS},
4085     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4086     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4087     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4088     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4089     *            returned.
4090     * @return A list of {@link ProviderInfo} objects containing one entry for
4091     *         each provider either matching <var>processName</var> or, if
4092     *         <var>processName</var> is null, all known content providers.
4093     *         <em>If there are no matching providers, null is returned.</em>
4094     * @see #GET_META_DATA
4095     * @see #GET_SHARED_LIBRARY_FILES
4096     * @see #MATCH_ALL
4097     * @see #MATCH_DEBUG_TRIAGED_MISSING
4098     * @see #MATCH_DEFAULT_ONLY
4099     * @see #MATCH_DISABLED_COMPONENTS
4100     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4101     * @see #MATCH_DIRECT_BOOT_AWARE
4102     * @see #MATCH_DIRECT_BOOT_UNAWARE
4103     * @see #MATCH_SYSTEM_ONLY
4104     * @see #MATCH_UNINSTALLED_PACKAGES
4105     */
4106    public abstract List<ProviderInfo> queryContentProviders(
4107            String processName, int uid, @ComponentInfoFlags int flags);
4108
4109    /**
4110     * Retrieve all of the information we know about a particular
4111     * instrumentation class.
4112     *
4113     * @param className The full name (i.e.
4114     *                  com.google.apps.contacts.InstrumentList) of an
4115     *                  Instrumentation class.
4116     * @param flags Additional option flags. Use any combination of
4117     *         {@link #GET_META_DATA}
4118     *         to modify the data returned.
4119     *
4120     * @return An {@link InstrumentationInfo} object containing information about the
4121     *         instrumentation.
4122     * @throws NameNotFoundException if a package with the given name cannot be
4123     *             found on the system.
4124     *
4125     * @see #GET_META_DATA
4126     */
4127    public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
4128            @InstrumentationInfoFlags int flags) throws NameNotFoundException;
4129
4130    /**
4131     * Retrieve information about available instrumentation code.  May be used
4132     * to retrieve either all instrumentation code, or only the code targeting
4133     * a particular package.
4134     *
4135     * @param targetPackage If null, all instrumentation is returned; only the
4136     *                      instrumentation targeting this package name is
4137     *                      returned.
4138     * @param flags Additional option flags. Use any combination of
4139     *         {@link #GET_META_DATA}
4140     *         to modify the data returned.
4141     *
4142     * @return A list of {@link InstrumentationInfo} objects containing one
4143     *         entry for each matching instrumentation. If there are no
4144     *         instrumentation available, returns an empty list.
4145     *
4146     * @see #GET_META_DATA
4147     */
4148    public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
4149            @InstrumentationInfoFlags int flags);
4150
4151    /**
4152     * Retrieve an image from a package.  This is a low-level API used by
4153     * the various package manager info structures (such as
4154     * {@link ComponentInfo} to implement retrieval of their associated
4155     * icon.
4156     *
4157     * @param packageName The name of the package that this icon is coming from.
4158     * Cannot be null.
4159     * @param resid The resource identifier of the desired image.  Cannot be 0.
4160     * @param appInfo Overall information about <var>packageName</var>.  This
4161     * may be null, in which case the application information will be retrieved
4162     * for you if needed; if you already have this information around, it can
4163     * be much more efficient to supply it here.
4164     *
4165     * @return Returns a Drawable holding the requested image.  Returns null if
4166     * an image could not be found for any reason.
4167     */
4168    public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
4169            ApplicationInfo appInfo);
4170
4171    /**
4172     * Retrieve the icon associated with an activity.  Given the full name of
4173     * an activity, retrieves the information about it and calls
4174     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
4175     * If the activity cannot be found, NameNotFoundException is thrown.
4176     *
4177     * @param activityName Name of the activity whose icon is to be retrieved.
4178     *
4179     * @return Returns the image of the icon, or the default activity icon if
4180     * it could not be found.  Does not return null.
4181     * @throws NameNotFoundException Thrown if the resources for the given
4182     * activity could not be loaded.
4183     *
4184     * @see #getActivityIcon(Intent)
4185     */
4186    public abstract Drawable getActivityIcon(ComponentName activityName)
4187            throws NameNotFoundException;
4188
4189    /**
4190     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
4191     * set, this simply returns the result of
4192     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
4193     * component and returns the icon associated with the resolved component.
4194     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4195     * to a component, NameNotFoundException is thrown.
4196     *
4197     * @param intent The intent for which you would like to retrieve an icon.
4198     *
4199     * @return Returns the image of the icon, or the default activity icon if
4200     * it could not be found.  Does not return null.
4201     * @throws NameNotFoundException Thrown if the resources for application
4202     * matching the given intent could not be loaded.
4203     *
4204     * @see #getActivityIcon(ComponentName)
4205     */
4206    public abstract Drawable getActivityIcon(Intent intent)
4207            throws NameNotFoundException;
4208
4209    /**
4210     * Retrieve the banner associated with an activity. Given the full name of
4211     * an activity, retrieves the information about it and calls
4212     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4213     * banner. If the activity cannot be found, NameNotFoundException is thrown.
4214     *
4215     * @param activityName Name of the activity whose banner is to be retrieved.
4216     * @return Returns the image of the banner, or null if the activity has no
4217     *         banner specified.
4218     * @throws NameNotFoundException Thrown if the resources for the given
4219     *             activity could not be loaded.
4220     * @see #getActivityBanner(Intent)
4221     */
4222    public abstract Drawable getActivityBanner(ComponentName activityName)
4223            throws NameNotFoundException;
4224
4225    /**
4226     * Retrieve the banner associated with an Intent. If intent.getClassName()
4227     * is set, this simply returns the result of
4228     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4229     * intent's component and returns the banner associated with the resolved
4230     * component. If intent.getClassName() cannot be found or the Intent cannot
4231     * be resolved to a component, NameNotFoundException is thrown.
4232     *
4233     * @param intent The intent for which you would like to retrieve a banner.
4234     * @return Returns the image of the banner, or null if the activity has no
4235     *         banner specified.
4236     * @throws NameNotFoundException Thrown if the resources for application
4237     *             matching the given intent could not be loaded.
4238     * @see #getActivityBanner(ComponentName)
4239     */
4240    public abstract Drawable getActivityBanner(Intent intent)
4241            throws NameNotFoundException;
4242
4243    /**
4244     * Return the generic icon for an activity that is used when no specific
4245     * icon is defined.
4246     *
4247     * @return Drawable Image of the icon.
4248     */
4249    public abstract Drawable getDefaultActivityIcon();
4250
4251    /**
4252     * Retrieve the icon associated with an application.  If it has not defined
4253     * an icon, the default app icon is returned.  Does not return null.
4254     *
4255     * @param info Information about application being queried.
4256     *
4257     * @return Returns the image of the icon, or the default application icon
4258     * if it could not be found.
4259     *
4260     * @see #getApplicationIcon(String)
4261     */
4262    public abstract Drawable getApplicationIcon(ApplicationInfo info);
4263
4264    /**
4265     * Retrieve the icon associated with an application.  Given the name of the
4266     * application's package, retrieves the information about it and calls
4267     * getApplicationIcon() to return its icon. If the application cannot be
4268     * found, NameNotFoundException is thrown.
4269     *
4270     * @param packageName Name of the package whose application icon is to be
4271     *                    retrieved.
4272     *
4273     * @return Returns the image of the icon, or the default application icon
4274     * if it could not be found.  Does not return null.
4275     * @throws NameNotFoundException Thrown if the resources for the given
4276     * application could not be loaded.
4277     *
4278     * @see #getApplicationIcon(ApplicationInfo)
4279     */
4280    public abstract Drawable getApplicationIcon(String packageName)
4281            throws NameNotFoundException;
4282
4283    /**
4284     * Retrieve the banner associated with an application.
4285     *
4286     * @param info Information about application being queried.
4287     * @return Returns the image of the banner or null if the application has no
4288     *         banner specified.
4289     * @see #getApplicationBanner(String)
4290     */
4291    public abstract Drawable getApplicationBanner(ApplicationInfo info);
4292
4293    /**
4294     * Retrieve the banner associated with an application. Given the name of the
4295     * application's package, retrieves the information about it and calls
4296     * getApplicationIcon() to return its banner. If the application cannot be
4297     * found, NameNotFoundException is thrown.
4298     *
4299     * @param packageName Name of the package whose application banner is to be
4300     *            retrieved.
4301     * @return Returns the image of the banner or null if the application has no
4302     *         banner specified.
4303     * @throws NameNotFoundException Thrown if the resources for the given
4304     *             application could not be loaded.
4305     * @see #getApplicationBanner(ApplicationInfo)
4306     */
4307    public abstract Drawable getApplicationBanner(String packageName)
4308            throws NameNotFoundException;
4309
4310    /**
4311     * Retrieve the logo associated with an activity. Given the full name of an
4312     * activity, retrieves the information about it and calls
4313     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4314     * logo. If the activity cannot be found, NameNotFoundException is thrown.
4315     *
4316     * @param activityName Name of the activity whose logo is to be retrieved.
4317     * @return Returns the image of the logo or null if the activity has no logo
4318     *         specified.
4319     * @throws NameNotFoundException Thrown if the resources for the given
4320     *             activity could not be loaded.
4321     * @see #getActivityLogo(Intent)
4322     */
4323    public abstract Drawable getActivityLogo(ComponentName activityName)
4324            throws NameNotFoundException;
4325
4326    /**
4327     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
4328     * set, this simply returns the result of
4329     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
4330     * component and returns the logo associated with the resolved component.
4331     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4332     * to a component, NameNotFoundException is thrown.
4333     *
4334     * @param intent The intent for which you would like to retrieve a logo.
4335     *
4336     * @return Returns the image of the logo, or null if the activity has no
4337     * logo specified.
4338     *
4339     * @throws NameNotFoundException Thrown if the resources for application
4340     * matching the given intent could not be loaded.
4341     *
4342     * @see #getActivityLogo(ComponentName)
4343     */
4344    public abstract Drawable getActivityLogo(Intent intent)
4345            throws NameNotFoundException;
4346
4347    /**
4348     * Retrieve the logo associated with an application.  If it has not specified
4349     * a logo, this method returns null.
4350     *
4351     * @param info Information about application being queried.
4352     *
4353     * @return Returns the image of the logo, or null if no logo is specified
4354     * by the application.
4355     *
4356     * @see #getApplicationLogo(String)
4357     */
4358    public abstract Drawable getApplicationLogo(ApplicationInfo info);
4359
4360    /**
4361     * Retrieve the logo associated with an application.  Given the name of the
4362     * application's package, retrieves the information about it and calls
4363     * getApplicationLogo() to return its logo. If the application cannot be
4364     * found, NameNotFoundException is thrown.
4365     *
4366     * @param packageName Name of the package whose application logo is to be
4367     *                    retrieved.
4368     *
4369     * @return Returns the image of the logo, or null if no application logo
4370     * has been specified.
4371     *
4372     * @throws NameNotFoundException Thrown if the resources for the given
4373     * application could not be loaded.
4374     *
4375     * @see #getApplicationLogo(ApplicationInfo)
4376     */
4377    public abstract Drawable getApplicationLogo(String packageName)
4378            throws NameNotFoundException;
4379
4380    /**
4381     * Returns a managed-user-style badged copy of the given drawable allowing the user to
4382     * distinguish it from the original drawable.
4383     * The caller can specify the location in the bounds of the drawable to be
4384     * badged where the badge should be applied as well as the density of the
4385     * badge to be used.
4386     * <p>
4387     * If the original drawable is a BitmapDrawable and the backing bitmap is
4388     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4389     * is performed in place and the original drawable is returned.
4390     * </p>
4391     *
4392     * @param drawable The drawable to badge.
4393     * @param badgeLocation Where in the bounds of the badged drawable to place
4394     *         the badge. If it's {@code null}, the badge is applied on top of the entire
4395     *         drawable being badged.
4396     * @param badgeDensity The optional desired density for the badge as per
4397     *         {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4398     *         the density of the display is used.
4399     * @return A drawable that combines the original drawable and a badge as
4400     *         determined by the system.
4401     * @hide
4402     */
4403    public abstract Drawable getManagedUserBadgedDrawable(Drawable drawable, Rect badgeLocation,
4404        int badgeDensity);
4405
4406    /**
4407     * If the target user is a managed profile, then this returns a badged copy of the given icon
4408     * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
4409     * {@link #getUserBadgedDrawableForDensity(
4410     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4411     * <p>
4412     * If the original drawable is a BitmapDrawable and the backing bitmap is
4413     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4414     * is performed in place and the original drawable is returned.
4415     * </p>
4416     *
4417     * @param icon The icon to badge.
4418     * @param user The target user.
4419     * @return A drawable that combines the original icon and a badge as
4420     *         determined by the system.
4421     */
4422    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4423
4424    /**
4425     * If the target user is a managed profile of the calling user or the caller
4426     * is itself a managed profile, then this returns a badged copy of the given
4427     * drawable allowing the user to distinguish it from the original drawable.
4428     * The caller can specify the location in the bounds of the drawable to be
4429     * badged where the badge should be applied as well as the density of the
4430     * badge to be used.
4431     * <p>
4432     * If the original drawable is a BitmapDrawable and the backing bitmap is
4433     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4434     * is performed in place and the original drawable is returned.
4435     * </p>
4436     *
4437     * @param drawable The drawable to badge.
4438     * @param user The target user.
4439     * @param badgeLocation Where in the bounds of the badged drawable to place
4440     *         the badge. If it's {@code null}, the badge is applied on top of the entire
4441     *         drawable being badged.
4442     * @param badgeDensity The optional desired density for the badge as per
4443     *         {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4444     *         the density of the display is used.
4445     * @return A drawable that combines the original drawable and a badge as
4446     *         determined by the system.
4447     */
4448    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4449            UserHandle user, Rect badgeLocation, int badgeDensity);
4450
4451    /**
4452     * If the target user is a managed profile of the calling user or the caller
4453     * is itself a managed profile, then this returns a drawable to use as a small
4454     * icon to include in a view to distinguish it from the original icon.
4455     *
4456     * @param user The target user.
4457     * @param density The optional desired density for the badge as per
4458     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4459     *         the density of the current display is used.
4460     * @return the drawable or null if no drawable is required.
4461     * @hide
4462     */
4463    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4464
4465    /**
4466     * If the target user is a managed profile of the calling user or the caller
4467     * is itself a managed profile, then this returns a drawable to use as a small
4468     * icon to include in a view to distinguish it from the original icon. This version
4469     * doesn't have background protection and should be used over a light background instead of
4470     * a badge.
4471     *
4472     * @param user The target user.
4473     * @param density The optional desired density for the badge as per
4474     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4475     *         the density of the current display is used.
4476     * @return the drawable or null if no drawable is required.
4477     * @hide
4478     */
4479    public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4480
4481    /**
4482     * If the target user is a managed profile of the calling user or the caller
4483     * is itself a managed profile, then this returns a copy of the label with
4484     * badging for accessibility services like talkback. E.g. passing in "Email"
4485     * and it might return "Work Email" for Email in the work profile.
4486     *
4487     * @param label The label to change.
4488     * @param user The target user.
4489     * @return A label that combines the original label and a badge as
4490     *         determined by the system.
4491     */
4492    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4493
4494    /**
4495     * Retrieve text from a package.  This is a low-level API used by
4496     * the various package manager info structures (such as
4497     * {@link ComponentInfo} to implement retrieval of their associated
4498     * labels and other text.
4499     *
4500     * @param packageName The name of the package that this text is coming from.
4501     * Cannot be null.
4502     * @param resid The resource identifier of the desired text.  Cannot be 0.
4503     * @param appInfo Overall information about <var>packageName</var>.  This
4504     * may be null, in which case the application information will be retrieved
4505     * for you if needed; if you already have this information around, it can
4506     * be much more efficient to supply it here.
4507     *
4508     * @return Returns a CharSequence holding the requested text.  Returns null
4509     * if the text could not be found for any reason.
4510     */
4511    public abstract CharSequence getText(String packageName, @StringRes int resid,
4512            ApplicationInfo appInfo);
4513
4514    /**
4515     * Retrieve an XML file from a package.  This is a low-level API used to
4516     * retrieve XML meta data.
4517     *
4518     * @param packageName The name of the package that this xml is coming from.
4519     * Cannot be null.
4520     * @param resid The resource identifier of the desired xml.  Cannot be 0.
4521     * @param appInfo Overall information about <var>packageName</var>.  This
4522     * may be null, in which case the application information will be retrieved
4523     * for you if needed; if you already have this information around, it can
4524     * be much more efficient to supply it here.
4525     *
4526     * @return Returns an XmlPullParser allowing you to parse out the XML
4527     * data.  Returns null if the xml resource could not be found for any
4528     * reason.
4529     */
4530    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
4531            ApplicationInfo appInfo);
4532
4533    /**
4534     * Return the label to use for this application.
4535     *
4536     * @return Returns the label associated with this application, or null if
4537     * it could not be found for any reason.
4538     * @param info The application to get the label of.
4539     */
4540    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4541
4542    /**
4543     * Retrieve the resources associated with an activity.  Given the full
4544     * name of an activity, retrieves the information about it and calls
4545     * getResources() to return its application's resources.  If the activity
4546     * cannot be found, NameNotFoundException is thrown.
4547     *
4548     * @param activityName Name of the activity whose resources are to be
4549     *                     retrieved.
4550     *
4551     * @return Returns the application's Resources.
4552     * @throws NameNotFoundException Thrown if the resources for the given
4553     * application could not be loaded.
4554     *
4555     * @see #getResourcesForApplication(ApplicationInfo)
4556     */
4557    public abstract Resources getResourcesForActivity(ComponentName activityName)
4558            throws NameNotFoundException;
4559
4560    /**
4561     * Retrieve the resources for an application.  Throws NameNotFoundException
4562     * if the package is no longer installed.
4563     *
4564     * @param app Information about the desired application.
4565     *
4566     * @return Returns the application's Resources.
4567     * @throws NameNotFoundException Thrown if the resources for the given
4568     * application could not be loaded (most likely because it was uninstalled).
4569     */
4570    public abstract Resources getResourcesForApplication(ApplicationInfo app)
4571            throws NameNotFoundException;
4572
4573    /**
4574     * Retrieve the resources associated with an application.  Given the full
4575     * package name of an application, retrieves the information about it and
4576     * calls getResources() to return its application's resources.  If the
4577     * appPackageName cannot be found, NameNotFoundException is thrown.
4578     *
4579     * @param appPackageName Package name of the application whose resources
4580     *                       are to be retrieved.
4581     *
4582     * @return Returns the application's Resources.
4583     * @throws NameNotFoundException Thrown if the resources for the given
4584     * application could not be loaded.
4585     *
4586     * @see #getResourcesForApplication(ApplicationInfo)
4587     */
4588    public abstract Resources getResourcesForApplication(String appPackageName)
4589            throws NameNotFoundException;
4590
4591    /** @hide */
4592    public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4593            @UserIdInt int userId) throws NameNotFoundException;
4594
4595    /**
4596     * Retrieve overall information about an application package defined
4597     * in a package archive file
4598     *
4599     * @param archiveFilePath The path to the archive file
4600     * @param flags Additional option flags. Use any combination of
4601     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
4602     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
4603     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
4604     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
4605     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
4606     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
4607     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
4608     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4609     *         {@link #MATCH_UNINSTALLED_PACKAGES}
4610     *         to modify the data returned.
4611     *
4612     * @return A PackageInfo object containing information about the
4613     *         package archive. If the package could not be parsed,
4614     *         returns null.
4615     *
4616     * @see #GET_ACTIVITIES
4617     * @see #GET_CONFIGURATIONS
4618     * @see #GET_GIDS
4619     * @see #GET_INSTRUMENTATION
4620     * @see #GET_INTENT_FILTERS
4621     * @see #GET_META_DATA
4622     * @see #GET_PERMISSIONS
4623     * @see #GET_PROVIDERS
4624     * @see #GET_RECEIVERS
4625     * @see #GET_SERVICES
4626     * @see #GET_SHARED_LIBRARY_FILES
4627     * @see #GET_SIGNATURES
4628     * @see #GET_URI_PERMISSION_PATTERNS
4629     * @see #MATCH_DISABLED_COMPONENTS
4630     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4631     * @see #MATCH_UNINSTALLED_PACKAGES
4632     *
4633     */
4634    public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
4635        final PackageParser parser = new PackageParser();
4636        final File apkFile = new File(archiveFilePath);
4637        try {
4638            if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
4639                // Caller expressed an explicit opinion about what encryption
4640                // aware/unaware components they want to see, so fall through and
4641                // give them what they want
4642            } else {
4643                // Caller expressed no opinion, so match everything
4644                flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
4645            }
4646
4647            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
4648            if ((flags & GET_SIGNATURES) != 0) {
4649                PackageParser.collectCertificates(pkg, 0);
4650            }
4651            PackageUserState state = new PackageUserState();
4652            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4653        } catch (PackageParserException e) {
4654            return null;
4655        }
4656    }
4657
4658    /**
4659     * @deprecated replaced by {@link PackageInstaller}
4660     * @hide
4661     */
4662    @Deprecated
4663    public abstract void installPackage(
4664            Uri packageURI,
4665            IPackageInstallObserver observer,
4666            @InstallFlags int flags,
4667            String installerPackageName);
4668    /**
4669     * @deprecated replaced by {@link PackageInstaller}
4670     * @hide
4671     */
4672    @Deprecated
4673    public abstract void installPackage(
4674            Uri packageURI,
4675            PackageInstallObserver observer,
4676            @InstallFlags int flags,
4677            String installerPackageName);
4678
4679    /**
4680     * If there is already an application with the given package name installed
4681     * on the system for other users, also install it for the calling user.
4682     * @hide
4683     */
4684    public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
4685
4686    /**
4687     * If there is already an application with the given package name installed
4688     * on the system for other users, also install it for the specified user.
4689     * @hide
4690     */
4691     @RequiresPermission(anyOf = {
4692            Manifest.permission.INSTALL_PACKAGES,
4693            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4694    public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
4695            throws NameNotFoundException;
4696
4697    /**
4698     * Allows a package listening to the
4699     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4700     * broadcast} to respond to the package manager. The response must include
4701     * the {@code verificationCode} which is one of
4702     * {@link PackageManager#VERIFICATION_ALLOW} or
4703     * {@link PackageManager#VERIFICATION_REJECT}.
4704     *
4705     * @param id pending package identifier as passed via the
4706     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4707     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
4708     *            or {@link PackageManager#VERIFICATION_REJECT}.
4709     * @throws SecurityException if the caller does not have the
4710     *            PACKAGE_VERIFICATION_AGENT permission.
4711     */
4712    public abstract void verifyPendingInstall(int id, int verificationCode);
4713
4714    /**
4715     * Allows a package listening to the
4716     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4717     * broadcast} to extend the default timeout for a response and declare what
4718     * action to perform after the timeout occurs. The response must include
4719     * the {@code verificationCodeAtTimeout} which is one of
4720     * {@link PackageManager#VERIFICATION_ALLOW} or
4721     * {@link PackageManager#VERIFICATION_REJECT}.
4722     *
4723     * This method may only be called once per package id. Additional calls
4724     * will have no effect.
4725     *
4726     * @param id pending package identifier as passed via the
4727     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4728     * @param verificationCodeAtTimeout either
4729     *            {@link PackageManager#VERIFICATION_ALLOW} or
4730     *            {@link PackageManager#VERIFICATION_REJECT}. If
4731     *            {@code verificationCodeAtTimeout} is neither
4732     *            {@link PackageManager#VERIFICATION_ALLOW} or
4733     *            {@link PackageManager#VERIFICATION_REJECT}, then
4734     *            {@code verificationCodeAtTimeout} will default to
4735     *            {@link PackageManager#VERIFICATION_REJECT}.
4736     * @param millisecondsToDelay the amount of time requested for the timeout.
4737     *            Must be positive and less than
4738     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4739     *            {@code millisecondsToDelay} is out of bounds,
4740     *            {@code millisecondsToDelay} will be set to the closest in
4741     *            bounds value; namely, 0 or
4742     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
4743     * @throws SecurityException if the caller does not have the
4744     *            PACKAGE_VERIFICATION_AGENT permission.
4745     */
4746    public abstract void extendVerificationTimeout(int id,
4747            int verificationCodeAtTimeout, long millisecondsToDelay);
4748
4749    /**
4750     * Allows a package listening to the
4751     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
4752     * broadcast to respond to the package manager. The response must include
4753     * the {@code verificationCode} which is one of
4754     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4755     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4756     *
4757     * @param verificationId pending package identifier as passed via the
4758     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4759     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4760     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4761     * @param failedDomains a list of failed domains if the verificationCode is
4762     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4763     * @throws SecurityException if the caller does not have the
4764     *            INTENT_FILTER_VERIFICATION_AGENT permission.
4765     *
4766     * @hide
4767     */
4768    @SystemApi
4769    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
4770            List<String> failedDomains);
4771
4772    /**
4773     * Get the status of a Domain Verification Result for an IntentFilter. This is
4774     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4775     * {@link android.content.IntentFilter#getAutoVerify()}
4776     *
4777     * This is used by the ResolverActivity to change the status depending on what the User select
4778     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4779     * for a domain.
4780     *
4781     * @param packageName The package name of the Activity associated with the IntentFilter.
4782     * @param userId The user id.
4783     *
4784     * @return The status to set to. This can be
4785     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4786     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4787     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4788     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4789     *
4790     * @hide
4791     */
4792    public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
4793
4794    /**
4795     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4796     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4797     * {@link android.content.IntentFilter#getAutoVerify()}
4798     *
4799     * This is used by the ResolverActivity to change the status depending on what the User select
4800     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4801     * for a domain.
4802     *
4803     * @param packageName The package name of the Activity associated with the IntentFilter.
4804     * @param status The status to set to. This can be
4805     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4806     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4807     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4808     * @param userId The user id.
4809     *
4810     * @return true if the status has been set. False otherwise.
4811     *
4812     * @hide
4813     */
4814    public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
4815            @UserIdInt int userId);
4816
4817    /**
4818     * Get the list of IntentFilterVerificationInfo for a specific package and User.
4819     *
4820     * @param packageName the package name. When this parameter is set to a non null value,
4821     *                    the results will be filtered by the package name provided.
4822     *                    Otherwise, there will be no filtering and it will return a list
4823     *                    corresponding for all packages
4824     *
4825     * @return a list of IntentFilterVerificationInfo for a specific package.
4826     *
4827     * @hide
4828     */
4829    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4830            String packageName);
4831
4832    /**
4833     * Get the list of IntentFilter for a specific package.
4834     *
4835     * @param packageName the package name. This parameter is set to a non null value,
4836     *                    the list will contain all the IntentFilter for that package.
4837     *                    Otherwise, the list will be empty.
4838     *
4839     * @return a list of IntentFilter for a specific package.
4840     *
4841     * @hide
4842     */
4843    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4844
4845    /**
4846     * Get the default Browser package name for a specific user.
4847     *
4848     * @param userId The user id.
4849     *
4850     * @return the package name of the default Browser for the specified user. If the user id passed
4851     *         is -1 (all users) it will return a null value.
4852     *
4853     * @hide
4854     */
4855    @TestApi
4856    public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
4857
4858    /**
4859     * Set the default Browser package name for a specific user.
4860     *
4861     * @param packageName The package name of the default Browser.
4862     * @param userId The user id.
4863     *
4864     * @return true if the default Browser for the specified user has been set,
4865     *         otherwise return false. If the user id passed is -1 (all users) this call will not
4866     *         do anything and just return false.
4867     *
4868     * @hide
4869     */
4870    public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
4871            @UserIdInt int userId);
4872
4873    /**
4874     * Change the installer associated with a given package.  There are limitations
4875     * on how the installer package can be changed; in particular:
4876     * <ul>
4877     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
4878     * is not signed with the same certificate as the calling application.
4879     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
4880     * has an installer package, and that installer package is not signed with
4881     * the same certificate as the calling application.
4882     * </ul>
4883     *
4884     * @param targetPackage The installed package whose installer will be changed.
4885     * @param installerPackageName The package name of the new installer.  May be
4886     * null to clear the association.
4887     */
4888    public abstract void setInstallerPackageName(String targetPackage,
4889            String installerPackageName);
4890
4891    /**
4892     * Attempts to delete a package. Since this may take a little while, the
4893     * result will be posted back to the given observer. A deletion will fail if
4894     * the calling context lacks the
4895     * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
4896     * named package cannot be found, or if the named package is a system
4897     * package.
4898     *
4899     * @param packageName The name of the package to delete
4900     * @param observer An observer callback to get notified when the package
4901     *            deletion is complete.
4902     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
4903     *            will be called when that happens. observer may be null to
4904     *            indicate that no callback is desired.
4905     * @hide
4906     */
4907    public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
4908            @DeleteFlags int flags);
4909
4910    /**
4911     * Attempts to delete a package. Since this may take a little while, the
4912     * result will be posted back to the given observer. A deletion will fail if
4913     * the named package cannot be found, or if the named package is a system
4914     * package.
4915     *
4916     * @param packageName The name of the package to delete
4917     * @param observer An observer callback to get notified when the package
4918     *            deletion is complete.
4919     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
4920     *            will be called when that happens. observer may be null to
4921     *            indicate that no callback is desired.
4922     * @param userId The user Id
4923     * @hide
4924     */
4925     @RequiresPermission(anyOf = {
4926            Manifest.permission.DELETE_PACKAGES,
4927            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4928    public abstract void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
4929            @DeleteFlags int flags, @UserIdInt int userId);
4930
4931    /**
4932     * Retrieve the package name of the application that installed a package. This identifies
4933     * which market the package came from.
4934     *
4935     * @param packageName The name of the package to query
4936     */
4937    public abstract String getInstallerPackageName(String packageName);
4938
4939    /**
4940     * Attempts to clear the user data directory of an application.
4941     * Since this may take a little while, the result will
4942     * be posted back to the given observer.  A deletion will fail if the
4943     * named package cannot be found, or if the named package is a "system package".
4944     *
4945     * @param packageName The name of the package
4946     * @param observer An observer callback to get notified when the operation is finished
4947     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4948     * will be called when that happens.  observer may be null to indicate that
4949     * no callback is desired.
4950     *
4951     * @hide
4952     */
4953    public abstract void clearApplicationUserData(String packageName,
4954            IPackageDataObserver observer);
4955    /**
4956     * Attempts to delete the cache files associated with an application.
4957     * Since this may take a little while, the result will
4958     * be posted back to the given observer.  A deletion will fail if the calling context
4959     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
4960     * named package cannot be found, or if the named package is a "system package".
4961     *
4962     * @param packageName The name of the package to delete
4963     * @param observer An observer callback to get notified when the cache file deletion
4964     * is complete.
4965     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4966     * will be called when that happens.  observer may be null to indicate that
4967     * no callback is desired.
4968     *
4969     * @hide
4970     */
4971    public abstract void deleteApplicationCacheFiles(String packageName,
4972            IPackageDataObserver observer);
4973
4974    /**
4975     * Free storage by deleting LRU sorted list of cache files across
4976     * all applications. If the currently available free storage
4977     * on the device is greater than or equal to the requested
4978     * free storage, no cache files are cleared. If the currently
4979     * available storage on the device is less than the requested
4980     * free storage, some or all of the cache files across
4981     * all applications are deleted (based on last accessed time)
4982     * to increase the free storage space on the device to
4983     * the requested value. There is no guarantee that clearing all
4984     * the cache files from all applications will clear up
4985     * enough storage to achieve the desired value.
4986     * @param freeStorageSize The number of bytes of storage to be
4987     * freed by the system. Say if freeStorageSize is XX,
4988     * and the current free storage is YY,
4989     * if XX is less than YY, just return. if not free XX-YY number
4990     * of bytes if possible.
4991     * @param observer call back used to notify when
4992     * the operation is completed
4993     *
4994     * @hide
4995     */
4996    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
4997        freeStorageAndNotify(null, freeStorageSize, observer);
4998    }
4999
5000    /** {@hide} */
5001    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
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 pi IntentSender call back used to
5022     * notify when the operation is completed.May be null
5023     * to indicate that no call back is desired.
5024     *
5025     * @hide
5026     */
5027    public void freeStorage(long freeStorageSize, IntentSender pi) {
5028        freeStorage(null, freeStorageSize, pi);
5029    }
5030
5031    /** {@hide} */
5032    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
5033
5034    /**
5035     * Retrieve the size information for a package.
5036     * Since this may take a little while, the result will
5037     * be posted back to the given observer.  The calling context
5038     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
5039     *
5040     * @param packageName The name of the package whose size information is to be retrieved
5041     * @param userId The user whose size information should be retrieved.
5042     * @param observer An observer callback to get notified when the operation
5043     * is complete.
5044     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
5045     * The observer's callback is invoked with a PackageStats object(containing the
5046     * code, data and cache sizes of the package) and a boolean value representing
5047     * the status of the operation. observer may be null to indicate that
5048     * no callback is desired.
5049     *
5050     * @hide
5051     */
5052    public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
5053            IPackageStatsObserver observer);
5054
5055    /**
5056     * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
5057     * returns the size for the calling user.
5058     *
5059     * @hide
5060     */
5061    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
5062        getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer);
5063    }
5064
5065    /**
5066     * @deprecated This function no longer does anything; it was an old
5067     * approach to managing preferred activities, which has been superseded
5068     * by (and conflicts with) the modern activity-based preferences.
5069     */
5070    @Deprecated
5071    public abstract void addPackageToPreferred(String packageName);
5072
5073    /**
5074     * @deprecated This function no longer does anything; it was an old
5075     * approach to managing preferred activities, which has been superseded
5076     * by (and conflicts with) the modern activity-based preferences.
5077     */
5078    @Deprecated
5079    public abstract void removePackageFromPreferred(String packageName);
5080
5081    /**
5082     * Retrieve the list of all currently configured preferred packages.  The
5083     * first package on the list is the most preferred, the last is the
5084     * least preferred.
5085     *
5086     * @param flags Additional option flags. Use any combination of
5087     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
5088     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
5089     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
5090     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
5091     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
5092     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
5093     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
5094     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
5095     *         {@link #MATCH_UNINSTALLED_PACKAGES}
5096     *         to modify the data returned.
5097     *
5098     * @return A List of PackageInfo objects, one for each preferred application,
5099     *         in order of preference.
5100     *
5101     * @see #GET_ACTIVITIES
5102     * @see #GET_CONFIGURATIONS
5103     * @see #GET_GIDS
5104     * @see #GET_INSTRUMENTATION
5105     * @see #GET_INTENT_FILTERS
5106     * @see #GET_META_DATA
5107     * @see #GET_PERMISSIONS
5108     * @see #GET_PROVIDERS
5109     * @see #GET_RECEIVERS
5110     * @see #GET_SERVICES
5111     * @see #GET_SHARED_LIBRARY_FILES
5112     * @see #GET_SIGNATURES
5113     * @see #GET_URI_PERMISSION_PATTERNS
5114     * @see #MATCH_DISABLED_COMPONENTS
5115     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
5116     * @see #MATCH_UNINSTALLED_PACKAGES
5117     */
5118    public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
5119
5120    /**
5121     * @deprecated This is a protected API that should not have been available
5122     * to third party applications.  It is the platform's responsibility for
5123     * assigning preferred activities and this cannot be directly modified.
5124     *
5125     * Add a new preferred activity mapping to the system.  This will be used
5126     * to automatically select the given activity component when
5127     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5128     * multiple matching activities and also matches the given filter.
5129     *
5130     * @param filter The set of intents under which this activity will be
5131     * made preferred.
5132     * @param match The IntentFilter match category that this preference
5133     * applies to.
5134     * @param set The set of activities that the user was picking from when
5135     * this preference was made.
5136     * @param activity The component name of the activity that is to be
5137     * preferred.
5138     */
5139    @Deprecated
5140    public abstract void addPreferredActivity(IntentFilter filter, int match,
5141            ComponentName[] set, ComponentName activity);
5142
5143    /**
5144     * Same as {@link #addPreferredActivity(IntentFilter, int,
5145            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5146            to.
5147     * @hide
5148     */
5149    public void addPreferredActivityAsUser(IntentFilter filter, int match,
5150            ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5151        throw new RuntimeException("Not implemented. Must override in a subclass.");
5152    }
5153
5154    /**
5155     * @deprecated This is a protected API that should not have been available
5156     * to third party applications.  It is the platform's responsibility for
5157     * assigning preferred activities and this cannot be directly modified.
5158     *
5159     * Replaces an existing preferred activity mapping to the system, and if that were not present
5160     * adds a new preferred activity.  This will be used
5161     * to automatically select the given activity component when
5162     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5163     * multiple matching activities and also matches the given filter.
5164     *
5165     * @param filter The set of intents under which this activity will be
5166     * made preferred.
5167     * @param match The IntentFilter match category that this preference
5168     * applies to.
5169     * @param set The set of activities that the user was picking from when
5170     * this preference was made.
5171     * @param activity The component name of the activity that is to be
5172     * preferred.
5173     * @hide
5174     */
5175    @Deprecated
5176    public abstract void replacePreferredActivity(IntentFilter filter, int match,
5177            ComponentName[] set, ComponentName activity);
5178
5179    /**
5180     * @hide
5181     */
5182    @Deprecated
5183    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
5184           ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5185        throw new RuntimeException("Not implemented. Must override in a subclass.");
5186    }
5187
5188    /**
5189     * Remove all preferred activity mappings, previously added with
5190     * {@link #addPreferredActivity}, from the
5191     * system whose activities are implemented in the given package name.
5192     * An application can only clear its own package(s).
5193     *
5194     * @param packageName The name of the package whose preferred activity
5195     * mappings are to be removed.
5196     */
5197    public abstract void clearPackagePreferredActivities(String packageName);
5198
5199    /**
5200     * Retrieve all preferred activities, previously added with
5201     * {@link #addPreferredActivity}, that are
5202     * currently registered with the system.
5203     *
5204     * @param outFilters A required list in which to place the filters of all of the
5205     * preferred activities.
5206     * @param outActivities A required list in which to place the component names of
5207     * all of the preferred activities.
5208     * @param packageName An optional package in which you would like to limit
5209     * the list.  If null, all activities will be returned; if non-null, only
5210     * those activities in the given package are returned.
5211     *
5212     * @return Returns the total number of registered preferred activities
5213     * (the number of distinct IntentFilter records, not the number of unique
5214     * activity components) that were found.
5215     */
5216    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5217            @NonNull List<ComponentName> outActivities, String packageName);
5218
5219    /**
5220     * Ask for the set of available 'home' activities and the current explicit
5221     * default, if any.
5222     * @hide
5223     */
5224    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5225
5226    /**
5227     * Set the enabled setting for a package component (activity, receiver, service, provider).
5228     * This setting will override any enabled state which may have been set by the component in its
5229     * manifest.
5230     *
5231     * @param componentName The component to enable
5232     * @param newState The new enabled state for the component.  The legal values for this state
5233     *                 are:
5234     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
5235     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
5236     *                   and
5237     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5238     *                 The last one removes the setting, thereby restoring the component's state to
5239     *                 whatever was set in it's manifest (or enabled, by default).
5240     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5241     */
5242    public abstract void setComponentEnabledSetting(ComponentName componentName,
5243            int newState, int flags);
5244
5245    /**
5246     * Return the enabled setting for a package component (activity,
5247     * receiver, service, provider).  This returns the last value set by
5248     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5249     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5250     * the value originally specified in the manifest has not been modified.
5251     *
5252     * @param componentName The component to retrieve.
5253     * @return Returns the current enabled state for the component.  May
5254     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5255     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5256     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
5257     * component's enabled state is based on the original information in
5258     * the manifest as found in {@link ComponentInfo}.
5259     */
5260    public abstract int getComponentEnabledSetting(ComponentName componentName);
5261
5262    /**
5263     * Set the enabled setting for an application
5264     * This setting will override any enabled state which may have been set by the application in
5265     * its manifest.  It also overrides the enabled state set in the manifest for any of the
5266     * application's components.  It does not override any enabled state set by
5267     * {@link #setComponentEnabledSetting} for any of the application's components.
5268     *
5269     * @param packageName The package name of the application to enable
5270     * @param newState The new enabled state for the component.  The legal values for this state
5271     *                 are:
5272     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
5273     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
5274     *                   and
5275     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5276     *                 The last one removes the setting, thereby restoring the applications's state to
5277     *                 whatever was set in its manifest (or enabled, by default).
5278     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5279     */
5280    public abstract void setApplicationEnabledSetting(String packageName,
5281            int newState, int flags);
5282
5283    /**
5284     * Return the enabled setting for an application. This returns
5285     * the last value set by
5286     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5287     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5288     * the value originally specified in the manifest has not been modified.
5289     *
5290     * @param packageName The package name of the application to retrieve.
5291     * @return Returns the current enabled state for the application.  May
5292     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5293     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5294     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
5295     * application's enabled state is based on the original information in
5296     * the manifest as found in {@link ComponentInfo}.
5297     * @throws IllegalArgumentException if the named package does not exist.
5298     */
5299    public abstract int getApplicationEnabledSetting(String packageName);
5300
5301    /**
5302     * Flush the package restrictions for a given user to disk. This forces the package restrictions
5303     * like component and package enabled settings to be written to disk and avoids the delay that
5304     * is otherwise present when changing those settings.
5305     *
5306     * @param userId Ther userId of the user whose restrictions are to be flushed.
5307     * @hide
5308     */
5309    public abstract void flushPackageRestrictionsAsUser(int userId);
5310
5311    /**
5312     * Puts the package in a hidden state, which is almost like an uninstalled state,
5313     * making the package unavailable, but it doesn't remove the data or the actual
5314     * package file. Application can be unhidden by either resetting the hidden state
5315     * or by installing it, such as with {@link #installExistingPackage(String)}
5316     * @hide
5317     */
5318    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
5319            UserHandle userHandle);
5320
5321    /**
5322     * Returns the hidden state of a package.
5323     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
5324     * @hide
5325     */
5326    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
5327            UserHandle userHandle);
5328
5329    /**
5330     * Return whether the device has been booted into safe mode.
5331     */
5332    public abstract boolean isSafeMode();
5333
5334    /**
5335     * Adds a listener for permission changes for installed packages.
5336     *
5337     * @param listener The listener to add.
5338     *
5339     * @hide
5340     */
5341    @SystemApi
5342    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5343    public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5344
5345    /**
5346     * Remvoes a listener for permission changes for installed packages.
5347     *
5348     * @param listener The listener to remove.
5349     *
5350     * @hide
5351     */
5352    @SystemApi
5353    public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5354
5355    /**
5356     * Return the {@link KeySet} associated with the String alias for this
5357     * application.
5358     *
5359     * @param alias The alias for a given {@link KeySet} as defined in the
5360     *        application's AndroidManifest.xml.
5361     * @hide
5362     */
5363    public abstract KeySet getKeySetByAlias(String packageName, String alias);
5364
5365    /** Return the signing {@link KeySet} for this application.
5366     * @hide
5367     */
5368    public abstract KeySet getSigningKeySet(String packageName);
5369
5370    /**
5371     * Return whether the package denoted by packageName has been signed by all
5372     * of the keys specified by the {@link KeySet} ks.  This will return true if
5373     * the package has been signed by additional keys (a superset) as well.
5374     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
5375     * @hide
5376     */
5377    public abstract boolean isSignedBy(String packageName, KeySet ks);
5378
5379    /**
5380     * Return whether the package denoted by packageName has been signed by all
5381     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5382     * {@link #isSignedBy(String packageName, KeySet ks)}.
5383     * @hide
5384     */
5385    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5386
5387    /**
5388     * Puts the package in a suspended state, where attempts at starting activities are denied.
5389     *
5390     * <p>It doesn't remove the data or the actual package file. The application notifications
5391     * will be hidden, the application will not show up in recents, will not be able to show
5392     * toasts or dialogs or ring the device.
5393     *
5394     * <p>The package must already be installed. If the package is uninstalled while suspended
5395     * the package will no longer be suspended.
5396     *
5397     * @param packageNames The names of the packages to set the suspended status.
5398     * @param suspended If set to {@code true} than the packages will be suspended, if set to
5399     * {@code false} the packages will be unsuspended.
5400     * @param userId The user id.
5401     *
5402     * @return an array of package names for which the suspended status is not set as requested in
5403     * this method.
5404     *
5405     * @hide
5406     */
5407    public abstract String[] setPackagesSuspendedAsUser(
5408            String[] packageNames, boolean suspended, @UserIdInt int userId);
5409
5410    /**
5411     * @see #setPackageSuspendedAsUser(String, boolean, int)
5412     * @param packageName The name of the package to get the suspended status of.
5413     * @param userId The user id.
5414     * @return {@code true} if the package is suspended or {@code false} if the package is not
5415     * suspended or could not be found.
5416     * @hide
5417     */
5418    public abstract boolean isPackageSuspendedForUser(String packageName, int userId);
5419
5420    /** {@hide} */
5421    public static boolean isMoveStatusFinished(int status) {
5422        return (status < 0 || status > 100);
5423    }
5424
5425    /** {@hide} */
5426    public static abstract class MoveCallback {
5427        public void onCreated(int moveId, Bundle extras) {}
5428        public abstract void onStatusChanged(int moveId, int status, long estMillis);
5429    }
5430
5431    /** {@hide} */
5432    public abstract int getMoveStatus(int moveId);
5433
5434    /** {@hide} */
5435    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5436    /** {@hide} */
5437    public abstract void unregisterMoveCallback(MoveCallback callback);
5438
5439    /** {@hide} */
5440    public abstract int movePackage(String packageName, VolumeInfo vol);
5441    /** {@hide} */
5442    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5443    /** {@hide} */
5444    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5445
5446    /** {@hide} */
5447    public abstract int movePrimaryStorage(VolumeInfo vol);
5448    /** {@hide} */
5449    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5450    /** {@hide} */
5451    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
5452
5453    /**
5454     * Returns the device identity that verifiers can use to associate their scheme to a particular
5455     * device. This should not be used by anything other than a package verifier.
5456     *
5457     * @return identity that uniquely identifies current device
5458     * @hide
5459     */
5460    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
5461
5462    /**
5463     * Returns true if the device is upgrading, such as first boot after OTA.
5464     *
5465     * @hide
5466     */
5467    public abstract boolean isUpgrade();
5468
5469    /**
5470     * Return interface that offers the ability to install, upgrade, and remove
5471     * applications on the device.
5472     */
5473    public abstract @NonNull PackageInstaller getPackageInstaller();
5474
5475    /**
5476     * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5477     * intents sent from the user with id sourceUserId can also be be resolved
5478     * by activities in the user with id targetUserId if they match the
5479     * specified intent filter.
5480     *
5481     * @param filter The {@link IntentFilter} the intent has to match
5482     * @param sourceUserId The source user id.
5483     * @param targetUserId The target user id.
5484     * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5485     *            {@link #ONLY_IF_NO_MATCH_FOUND}.
5486     * @hide
5487     */
5488    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5489            int targetUserId, int flags);
5490
5491    /**
5492     * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5493     * as their source, and have been set by the app calling this method.
5494     *
5495     * @param sourceUserId The source user id.
5496     * @hide
5497     */
5498    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
5499
5500    /**
5501     * @hide
5502     */
5503    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5504
5505    /**
5506     * @hide
5507     */
5508    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5509
5510    /** {@hide} */
5511    public abstract boolean isPackageAvailable(String packageName);
5512
5513    /** {@hide} */
5514    public static String installStatusToString(int status, String msg) {
5515        final String str = installStatusToString(status);
5516        if (msg != null) {
5517            return str + ": " + msg;
5518        } else {
5519            return str;
5520        }
5521    }
5522
5523    /** {@hide} */
5524    public static String installStatusToString(int status) {
5525        switch (status) {
5526            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5527            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5528            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5529            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5530            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5531            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5532            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5533            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5534            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5535            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5536            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5537            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5538            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5539            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5540            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5541            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5542            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5543            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5544            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5545            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5546            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5547            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5548            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5549            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5550            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5551            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5552            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5553            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5554            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5555            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5556            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5557            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5558            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5559            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5560            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5561            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5562            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5563            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5564            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5565            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
5566            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
5567            default: return Integer.toString(status);
5568        }
5569    }
5570
5571    /** {@hide} */
5572    public static int installStatusToPublicStatus(int status) {
5573        switch (status) {
5574            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5575            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5576            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5577            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5578            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5579            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5580            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5581            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5582            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5583            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5584            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5585            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5586            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5587            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5588            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5589            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5590            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5591            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5592            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5593            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5594            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5595            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5596            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5597            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5598            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5599            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5600            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5601            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5602            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5603            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5604            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5605            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5606            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5607            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5608            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5609            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5610            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
5611            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5612            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5613            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5614            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5615            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5616            default: return PackageInstaller.STATUS_FAILURE;
5617        }
5618    }
5619
5620    /** {@hide} */
5621    public static String deleteStatusToString(int status, String msg) {
5622        final String str = deleteStatusToString(status);
5623        if (msg != null) {
5624            return str + ": " + msg;
5625        } else {
5626            return str;
5627        }
5628    }
5629
5630    /** {@hide} */
5631    public static String deleteStatusToString(int status) {
5632        switch (status) {
5633            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5634            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5635            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5636            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5637            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
5638            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
5639            default: return Integer.toString(status);
5640        }
5641    }
5642
5643    /** {@hide} */
5644    public static int deleteStatusToPublicStatus(int status) {
5645        switch (status) {
5646            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5647            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5648            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5649            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5650            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5651            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5652            default: return PackageInstaller.STATUS_FAILURE;
5653        }
5654    }
5655
5656    /** {@hide} */
5657    public static String permissionFlagToString(int flag) {
5658        switch (flag) {
5659            case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
5660            case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
5661            case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
5662            case FLAG_PERMISSION_USER_SET: return "USER_SET";
5663            case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
5664            case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
5665            case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
5666            default: return Integer.toString(flag);
5667        }
5668    }
5669
5670    /** {@hide} */
5671    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
5672        private final IPackageInstallObserver mLegacy;
5673
5674        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
5675            mLegacy = legacy;
5676        }
5677
5678        @Override
5679        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
5680                Bundle extras) {
5681            if (mLegacy == null) return;
5682            try {
5683                mLegacy.packageInstalled(basePackageName, returnCode);
5684            } catch (RemoteException ignored) {
5685            }
5686        }
5687    }
5688
5689    /** {@hide} */
5690    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
5691        private final IPackageDeleteObserver mLegacy;
5692
5693        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
5694            mLegacy = legacy;
5695        }
5696
5697        @Override
5698        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
5699            if (mLegacy == null) return;
5700            try {
5701                mLegacy.packageDeleted(basePackageName, returnCode);
5702            } catch (RemoteException ignored) {
5703            }
5704        }
5705    }
5706}
5707