PackageManager.java revision 5a91b615232374084a45752d7c09c25265e263ed
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 Electrocardiogram.
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 CDD 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     * Used when starting a process for an Activity.
2460     *
2461     * @hide
2462     */
2463    public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
2464
2465    /**
2466     * Used when starting a process for a Service.
2467     *
2468     * @hide
2469     */
2470    public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
2471
2472    /**
2473     * Used when moving a Service to the foreground.
2474     *
2475     * @hide
2476     */
2477    public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
2478
2479    /**
2480     * Used when starting a process for a BroadcastReceiver.
2481     *
2482     * @hide
2483     */
2484    public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
2485
2486    /**
2487     * Used when starting a process for a ContentProvider.
2488     *
2489     * @hide
2490     */
2491    public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
2492
2493    /**
2494     * Used when starting a process for a BroadcastReceiver.
2495     *
2496     * @hide
2497     */
2498    public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
2499
2500    /**
2501     * Used with Context.getClassLoader() across Android packages.
2502     *
2503     * @hide
2504     */
2505    public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
2506
2507    /**
2508     * Used when starting a package within a process for Instrumentation.
2509     *
2510     * @hide
2511     */
2512    public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
2513
2514    /**
2515     * Total number of usage reasons.
2516     *
2517     * @hide
2518     */
2519    public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
2520
2521    /**
2522     * Retrieve overall information about an application package that is
2523     * installed on the system.
2524     *
2525     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2526     *         desired package.
2527     * @param flags Additional option flags. Use any combination of
2528     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2529     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2530     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2531     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2532     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2533     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2534     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2535     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2536     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2537     *         to modify the data returned.
2538     *
2539     * @return A PackageInfo object containing information about the
2540     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2541     *         package is not found in the list of installed applications, the
2542     *         package information is retrieved from the list of uninstalled
2543     *         applications (which includes installed applications as well as
2544     *         applications with data directory i.e. applications which had been
2545     *         deleted with {@code DONT_DELETE_DATA} flag set).
2546     * @throws NameNotFoundException if a package with the given name cannot be
2547     *             found on the system.
2548     * @see #GET_ACTIVITIES
2549     * @see #GET_CONFIGURATIONS
2550     * @see #GET_GIDS
2551     * @see #GET_INSTRUMENTATION
2552     * @see #GET_INTENT_FILTERS
2553     * @see #GET_META_DATA
2554     * @see #GET_PERMISSIONS
2555     * @see #GET_PROVIDERS
2556     * @see #GET_RECEIVERS
2557     * @see #GET_SERVICES
2558     * @see #GET_SHARED_LIBRARY_FILES
2559     * @see #GET_SIGNATURES
2560     * @see #GET_URI_PERMISSION_PATTERNS
2561     * @see #MATCH_DISABLED_COMPONENTS
2562     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2563     * @see #MATCH_UNINSTALLED_PACKAGES
2564     */
2565    public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags)
2566            throws NameNotFoundException;
2567
2568    /**
2569     * @hide
2570     * Retrieve overall information about an application package that is
2571     * installed on the system.
2572     *
2573     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2574     *         desired package.
2575     * @param flags Additional option flags. Use any combination of
2576     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2577     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2578     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2579     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2580     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2581     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2582     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2583     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2584     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2585     *         to modify the data returned.
2586     * @param userId The user id.
2587     *
2588     * @return A PackageInfo object containing information about the
2589     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2590     *         package is not found in the list of installed applications, the
2591     *         package information is retrieved from the list of uninstalled
2592     *         applications (which includes installed applications as well as
2593     *         applications with data directory i.e. applications which had been
2594     *         deleted with {@code DONT_DELETE_DATA} flag set).
2595     * @throws NameNotFoundException if a package with the given name cannot be
2596     *             found on the system.
2597     * @see #GET_ACTIVITIES
2598     * @see #GET_CONFIGURATIONS
2599     * @see #GET_GIDS
2600     * @see #GET_INSTRUMENTATION
2601     * @see #GET_INTENT_FILTERS
2602     * @see #GET_META_DATA
2603     * @see #GET_PERMISSIONS
2604     * @see #GET_PROVIDERS
2605     * @see #GET_RECEIVERS
2606     * @see #GET_SERVICES
2607     * @see #GET_SHARED_LIBRARY_FILES
2608     * @see #GET_SIGNATURES
2609     * @see #GET_URI_PERMISSION_PATTERNS
2610     * @see #MATCH_DISABLED_COMPONENTS
2611     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2612     * @see #MATCH_UNINSTALLED_PACKAGES
2613     */
2614    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
2615    public abstract PackageInfo getPackageInfoAsUser(String packageName,
2616            @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
2617
2618    /**
2619     * Map from the current package names in use on the device to whatever
2620     * the current canonical name of that package is.
2621     * @param names Array of current names to be mapped.
2622     * @return Returns an array of the same size as the original, containing
2623     * the canonical name for each package.
2624     */
2625    public abstract String[] currentToCanonicalPackageNames(String[] names);
2626
2627    /**
2628     * Map from a packages canonical name to the current name in use on the device.
2629     * @param names Array of new names to be mapped.
2630     * @return Returns an array of the same size as the original, containing
2631     * the current name for each package.
2632     */
2633    public abstract String[] canonicalToCurrentPackageNames(String[] names);
2634
2635    /**
2636     * Returns a "good" intent to launch a front-door activity in a package.
2637     * This is used, for example, to implement an "open" button when browsing
2638     * through packages.  The current implementation looks first for a main
2639     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
2640     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
2641     * <code>null</code> if neither are found.
2642     *
2643     * @param packageName The name of the package to inspect.
2644     *
2645     * @return A fully-qualified {@link Intent} that can be used to launch the
2646     * main activity in the package. Returns <code>null</code> if the package
2647     * does not contain such an activity, or if <em>packageName</em> is not
2648     * recognized.
2649     */
2650    public abstract Intent getLaunchIntentForPackage(String packageName);
2651
2652    /**
2653     * Return a "good" intent to launch a front-door Leanback activity in a
2654     * package, for use for example to implement an "open" button when browsing
2655     * through packages. The current implementation will look for a main
2656     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
2657     * return null if no main leanback activities are found.
2658     *
2659     * @param packageName The name of the package to inspect.
2660     * @return Returns either a fully-qualified Intent that can be used to launch
2661     *         the main Leanback activity in the package, or null if the package
2662     *         does not contain such an activity.
2663     */
2664    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
2665
2666    /**
2667     * Return an array of all of the POSIX secondary group IDs that have been
2668     * assigned to the given package.
2669     * <p>
2670     * Note that the same package may have different GIDs under different
2671     * {@link UserHandle} on the same device.
2672     *
2673     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2674     *            desired package.
2675     * @return Returns an int array of the assigned GIDs, or null if there are
2676     *         none.
2677     * @throws NameNotFoundException if a package with the given name cannot be
2678     *             found on the system.
2679     */
2680    public abstract int[] getPackageGids(String packageName)
2681            throws NameNotFoundException;
2682
2683    /**
2684     * Return an array of all of the POSIX secondary group IDs that have been
2685     * assigned to the given package.
2686     * <p>
2687     * Note that the same package may have different GIDs under different
2688     * {@link UserHandle} on the same device.
2689     *
2690     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2691     *            desired package.
2692     * @return Returns an int array of the assigned gids, or null if there are
2693     *         none.
2694     * @throws NameNotFoundException if a package with the given name cannot be
2695     *             found on the system.
2696     */
2697    public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
2698            throws NameNotFoundException;
2699
2700    /**
2701     * Return the UID associated with the given package name.
2702     * <p>
2703     * Note that the same package will have different UIDs under different
2704     * {@link UserHandle} on the same device.
2705     *
2706     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2707     *            desired package.
2708     * @return Returns an integer UID who owns the given package name.
2709     * @throws NameNotFoundException if a package with the given name can not be
2710     *             found on the system.
2711     */
2712    public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
2713            throws NameNotFoundException;
2714
2715    /**
2716     * Return the UID associated with the given package name.
2717     * <p>
2718     * Note that the same package will have different UIDs under different
2719     * {@link UserHandle} on the same device.
2720     *
2721     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2722     *            desired package.
2723     * @param userId The user handle identifier to look up the package under.
2724     * @return Returns an integer UID who owns the given package name.
2725     * @throws NameNotFoundException if a package with the given name can not be
2726     *             found on the system.
2727     * @hide
2728     */
2729    public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
2730            throws NameNotFoundException;
2731
2732    /**
2733     * Return the UID associated with the given package name.
2734     * <p>
2735     * Note that the same package will have different UIDs under different
2736     * {@link UserHandle} on the same device.
2737     *
2738     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2739     *            desired package.
2740     * @param userId The user handle identifier to look up the package under.
2741     * @return Returns an integer UID who owns the given package name.
2742     * @throws NameNotFoundException if a package with the given name can not be
2743     *             found on the system.
2744     * @hide
2745     */
2746    public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
2747            @UserIdInt int userId) throws NameNotFoundException;
2748
2749    /**
2750     * Retrieve all of the information we know about a particular permission.
2751     *
2752     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
2753     *         of the permission you are interested in.
2754     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2755     *         retrieve any meta-data associated with the permission.
2756     *
2757     * @return Returns a {@link PermissionInfo} containing information about the
2758     *         permission.
2759     * @throws NameNotFoundException if a package with the given name cannot be
2760     *             found on the system.
2761     *
2762     * @see #GET_META_DATA
2763     */
2764    public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
2765            throws NameNotFoundException;
2766
2767    /**
2768     * Query for all of the permissions associated with a particular group.
2769     *
2770     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
2771     *         of the permission group you are interested in.  Use null to
2772     *         find all of the permissions not associated with a group.
2773     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2774     *         retrieve any meta-data associated with the permissions.
2775     *
2776     * @return Returns a list of {@link PermissionInfo} containing information
2777     *             about all of the permissions in the given group.
2778     * @throws NameNotFoundException if a package with the given name cannot be
2779     *             found on the system.
2780     *
2781     * @see #GET_META_DATA
2782     */
2783    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
2784            @PermissionInfoFlags int flags) throws NameNotFoundException;
2785
2786    /**
2787     * Retrieve all of the information we know about a particular group of
2788     * permissions.
2789     *
2790     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
2791     *         of the permission you are interested in.
2792     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2793     *         retrieve any meta-data associated with the permission group.
2794     *
2795     * @return Returns a {@link PermissionGroupInfo} containing information
2796     *         about the permission.
2797     * @throws NameNotFoundException if a package with the given name cannot be
2798     *             found on the system.
2799     *
2800     * @see #GET_META_DATA
2801     */
2802    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
2803            @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
2804
2805    /**
2806     * Retrieve all of the known permission groups in the system.
2807     *
2808     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2809     *         retrieve any meta-data associated with the permission group.
2810     *
2811     * @return Returns a list of {@link PermissionGroupInfo} containing
2812     *         information about all of the known permission groups.
2813     *
2814     * @see #GET_META_DATA
2815     */
2816    public abstract List<PermissionGroupInfo> getAllPermissionGroups(
2817            @PermissionGroupInfoFlags int flags);
2818
2819    /**
2820     * Retrieve all of the information we know about a particular
2821     * package/application.
2822     *
2823     * @param packageName The full name (i.e. com.google.apps.contacts) of an
2824     *         application.
2825     * @param flags Additional option flags. Use any combination of
2826     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2827     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
2828     *         to modify the data returned.
2829     *
2830     * @return An {@link ApplicationInfo} containing information about the
2831     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2832     *         package is not found in the list of installed applications, the
2833     *         application information is retrieved from the list of uninstalled
2834     *         applications (which includes installed applications as well as
2835     *         applications with data directory i.e. applications which had been
2836     *         deleted with {@code DONT_DELETE_DATA} flag set).
2837     * @throws NameNotFoundException if a package with the given name cannot be
2838     *             found on the system.
2839     *
2840     * @see #GET_META_DATA
2841     * @see #GET_SHARED_LIBRARY_FILES
2842     * @see #MATCH_SYSTEM_ONLY
2843     * @see #MATCH_UNINSTALLED_PACKAGES
2844     */
2845    public abstract ApplicationInfo getApplicationInfo(String packageName,
2846            @ApplicationInfoFlags int flags) throws NameNotFoundException;
2847
2848    /** {@hide} */
2849    public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
2850            @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
2851
2852    /**
2853     * Retrieve all of the information we know about a particular activity
2854     * class.
2855     *
2856     * @param component The full component name (i.e.
2857     *            com.google.apps.contacts/com.google.apps.contacts.
2858     *            ContactsList) of an Activity class.
2859     * @param flags Additional option flags. Use any combination of
2860     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2861     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2862     *            {@link #MATCH_DISABLED_COMPONENTS},
2863     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2864     *            {@link #MATCH_DIRECT_BOOT_AWARE},
2865     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2866     *            {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
2867     *            returned.
2868     * @return An {@link ActivityInfo} containing information about the
2869     *         activity.
2870     * @throws NameNotFoundException if a package with the given name cannot be
2871     *             found on the system.
2872     * @see #GET_META_DATA
2873     * @see #GET_SHARED_LIBRARY_FILES
2874     * @see #MATCH_ALL
2875     * @see #MATCH_DEBUG_TRIAGED_MISSING
2876     * @see #MATCH_DEFAULT_ONLY
2877     * @see #MATCH_DISABLED_COMPONENTS
2878     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2879     * @see #MATCH_DIRECT_BOOT_AWARE
2880     * @see #MATCH_DIRECT_BOOT_UNAWARE
2881     * @see #MATCH_SYSTEM_ONLY
2882     * @see #MATCH_UNINSTALLED_PACKAGES
2883     */
2884    public abstract ActivityInfo getActivityInfo(ComponentName component,
2885            @ComponentInfoFlags int flags) throws NameNotFoundException;
2886
2887    /**
2888     * Retrieve all of the information we know about a particular receiver
2889     * class.
2890     *
2891     * @param component The full component name (i.e.
2892     *            com.google.apps.calendar/com.google.apps.calendar.
2893     *            CalendarAlarm) of a Receiver class.
2894     * @param flags Additional option flags. Use any combination of
2895     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2896     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2897     *            {@link #MATCH_DISABLED_COMPONENTS},
2898     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2899     *            {@link #MATCH_DIRECT_BOOT_AWARE},
2900     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2901     *            {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
2902     *            returned.
2903     * @return An {@link ActivityInfo} containing information about the
2904     *         receiver.
2905     * @throws NameNotFoundException if a package with the given name cannot be
2906     *             found on the system.
2907     * @see #GET_META_DATA
2908     * @see #GET_SHARED_LIBRARY_FILES
2909     * @see #MATCH_ALL
2910     * @see #MATCH_DEBUG_TRIAGED_MISSING
2911     * @see #MATCH_DEFAULT_ONLY
2912     * @see #MATCH_DISABLED_COMPONENTS
2913     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2914     * @see #MATCH_DIRECT_BOOT_AWARE
2915     * @see #MATCH_DIRECT_BOOT_UNAWARE
2916     * @see #MATCH_SYSTEM_ONLY
2917     * @see #MATCH_UNINSTALLED_PACKAGES
2918     */
2919    public abstract ActivityInfo getReceiverInfo(ComponentName component,
2920            @ComponentInfoFlags int flags) throws NameNotFoundException;
2921
2922    /**
2923     * Retrieve all of the information we know about a particular service class.
2924     *
2925     * @param component The full component name (i.e.
2926     *            com.google.apps.media/com.google.apps.media.
2927     *            BackgroundPlayback) of a Service class.
2928     * @param flags Additional option flags. Use any combination of
2929     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2930     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2931     *            {@link #MATCH_DISABLED_COMPONENTS},
2932     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2933     *            {@link #MATCH_DIRECT_BOOT_AWARE},
2934     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2935     *            {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
2936     *            returned.
2937     * @return A {@link ServiceInfo} object containing information about the
2938     *         service.
2939     * @throws NameNotFoundException if a package with the given name cannot be
2940     *             found on the system.
2941     * @see #GET_META_DATA
2942     * @see #GET_SHARED_LIBRARY_FILES
2943     * @see #MATCH_ALL
2944     * @see #MATCH_DEBUG_TRIAGED_MISSING
2945     * @see #MATCH_DEFAULT_ONLY
2946     * @see #MATCH_DISABLED_COMPONENTS
2947     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2948     * @see #MATCH_DIRECT_BOOT_AWARE
2949     * @see #MATCH_DIRECT_BOOT_UNAWARE
2950     * @see #MATCH_SYSTEM_ONLY
2951     * @see #MATCH_UNINSTALLED_PACKAGES
2952     */
2953    public abstract ServiceInfo getServiceInfo(ComponentName component,
2954            @ComponentInfoFlags int flags) throws NameNotFoundException;
2955
2956    /**
2957     * Retrieve all of the information we know about a particular content
2958     * provider class.
2959     *
2960     * @param component The full component name (i.e.
2961     *            com.google.providers.media/com.google.providers.media.
2962     *            MediaProvider) of a ContentProvider class.
2963     * @param flags Additional option flags. Use any combination of
2964     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2965     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2966     *            {@link #MATCH_DISABLED_COMPONENTS},
2967     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2968     *            {@link #MATCH_DIRECT_BOOT_AWARE},
2969     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2970     *            {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
2971     *            returned.
2972     * @return A {@link ProviderInfo} object containing information about the
2973     *         provider.
2974     * @throws NameNotFoundException if a package with the given name cannot be
2975     *             found on the system.
2976     * @see #GET_META_DATA
2977     * @see #GET_SHARED_LIBRARY_FILES
2978     * @see #MATCH_ALL
2979     * @see #MATCH_DEBUG_TRIAGED_MISSING
2980     * @see #MATCH_DEFAULT_ONLY
2981     * @see #MATCH_DISABLED_COMPONENTS
2982     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2983     * @see #MATCH_DIRECT_BOOT_AWARE
2984     * @see #MATCH_DIRECT_BOOT_UNAWARE
2985     * @see #MATCH_SYSTEM_ONLY
2986     * @see #MATCH_UNINSTALLED_PACKAGES
2987     */
2988    public abstract ProviderInfo getProviderInfo(ComponentName component,
2989            @ComponentInfoFlags int flags) throws NameNotFoundException;
2990
2991    /**
2992     * Return a List of all packages that are installed
2993     * on the device.
2994     *
2995     * @param flags Additional option flags. Use any combination of
2996     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2997     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2998     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2999     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3000     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3001     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3002     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3003     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3004     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3005     *         to modify the data returned.
3006     *
3007     * @return A List of PackageInfo objects, one for each installed package,
3008     *         containing information about the package.  In the unlikely case
3009     *         there are no installed packages, an empty list is returned. If
3010     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3011     *         information is retrieved from the list of uninstalled
3012     *         applications (which includes installed applications as well as
3013     *         applications with data directory i.e. applications which had been
3014     *         deleted with {@code DONT_DELETE_DATA} flag set).
3015     *
3016     * @see #GET_ACTIVITIES
3017     * @see #GET_CONFIGURATIONS
3018     * @see #GET_GIDS
3019     * @see #GET_INSTRUMENTATION
3020     * @see #GET_INTENT_FILTERS
3021     * @see #GET_META_DATA
3022     * @see #GET_PERMISSIONS
3023     * @see #GET_PROVIDERS
3024     * @see #GET_RECEIVERS
3025     * @see #GET_SERVICES
3026     * @see #GET_SHARED_LIBRARY_FILES
3027     * @see #GET_SIGNATURES
3028     * @see #GET_URI_PERMISSION_PATTERNS
3029     * @see #MATCH_DISABLED_COMPONENTS
3030     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3031     * @see #MATCH_UNINSTALLED_PACKAGES
3032     */
3033    public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
3034
3035    /**
3036     * Return a List of all installed packages that are currently
3037     * holding any of the given permissions.
3038     *
3039     * @param flags Additional option flags. Use any combination of
3040     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
3041     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
3042     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
3043     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3044     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3045     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3046     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3047     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3048     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3049     *         to modify the data returned.
3050     *
3051     * @return A List of PackageInfo objects, one for each installed package
3052     *         that holds any of the permissions that were provided, containing
3053     *         information about the package. If no installed packages hold any
3054     *         of the permissions, an empty list is returned. If flag
3055     *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the package information
3056     *         is retrieved from the list of uninstalled applications (which
3057     *         includes installed applications as well as applications with data
3058     *         directory i.e. applications which had been deleted with
3059     *         {@code DONT_DELETE_DATA} flag set).
3060     *
3061     * @see #GET_ACTIVITIES
3062     * @see #GET_CONFIGURATIONS
3063     * @see #GET_GIDS
3064     * @see #GET_INSTRUMENTATION
3065     * @see #GET_INTENT_FILTERS
3066     * @see #GET_META_DATA
3067     * @see #GET_PERMISSIONS
3068     * @see #GET_PROVIDERS
3069     * @see #GET_RECEIVERS
3070     * @see #GET_SERVICES
3071     * @see #GET_SHARED_LIBRARY_FILES
3072     * @see #GET_SIGNATURES
3073     * @see #GET_URI_PERMISSION_PATTERNS
3074     * @see #MATCH_DISABLED_COMPONENTS
3075     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3076     * @see #MATCH_UNINSTALLED_PACKAGES
3077     */
3078    public abstract List<PackageInfo> getPackagesHoldingPermissions(
3079            String[] permissions, @PackageInfoFlags int flags);
3080
3081    /**
3082     * Return a List of all packages that are installed on the device, for a specific user.
3083     * Requesting a list of installed packages for another user
3084     * will require the permission INTERACT_ACROSS_USERS_FULL.
3085     *
3086     * @param flags Additional option flags. Use any combination of
3087     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
3088     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
3089     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
3090     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3091     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3092     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3093     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3094     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3095     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3096     *         to modify the data returned.
3097     * @param userId The user for whom the installed packages are to be listed
3098     *
3099     * @return A List of PackageInfo objects, one for each installed package,
3100     *         containing information about the package.  In the unlikely case
3101     *         there are no installed packages, an empty list is returned. If
3102     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3103     *         information is retrieved from the list of uninstalled
3104     *         applications (which includes installed applications as well as
3105     *         applications with data directory i.e. applications which had been
3106     *         deleted with {@code DONT_DELETE_DATA} flag set).
3107     *
3108     * @see #GET_ACTIVITIES
3109     * @see #GET_CONFIGURATIONS
3110     * @see #GET_GIDS
3111     * @see #GET_INSTRUMENTATION
3112     * @see #GET_INTENT_FILTERS
3113     * @see #GET_META_DATA
3114     * @see #GET_PERMISSIONS
3115     * @see #GET_PROVIDERS
3116     * @see #GET_RECEIVERS
3117     * @see #GET_SERVICES
3118     * @see #GET_SHARED_LIBRARY_FILES
3119     * @see #GET_SIGNATURES
3120     * @see #GET_URI_PERMISSION_PATTERNS
3121     * @see #MATCH_DISABLED_COMPONENTS
3122     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3123     * @see #MATCH_UNINSTALLED_PACKAGES
3124     *
3125     * @hide
3126     */
3127    public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
3128            @UserIdInt int userId);
3129
3130    /**
3131     * Check whether a particular package has been granted a particular
3132     * permission.
3133     *
3134     * @param permName The name of the permission you are checking for.
3135     * @param pkgName The name of the package you are checking against.
3136     *
3137     * @return If the package has the permission, PERMISSION_GRANTED is
3138     * returned.  If it does not have the permission, PERMISSION_DENIED
3139     * is returned.
3140     *
3141     * @see #PERMISSION_GRANTED
3142     * @see #PERMISSION_DENIED
3143     */
3144    @CheckResult
3145    public abstract int checkPermission(String permName, String pkgName);
3146
3147    /**
3148     * Checks whether a particular permissions has been revoked for a
3149     * package by policy. Typically the device owner or the profile owner
3150     * may apply such a policy. The user cannot grant policy revoked
3151     * permissions, hence the only way for an app to get such a permission
3152     * is by a policy change.
3153     *
3154     * @param permName The name of the permission you are checking for.
3155     * @param pkgName The name of the package you are checking against.
3156     *
3157     * @return Whether the permission is restricted by policy.
3158     */
3159    @CheckResult
3160    public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
3161            @NonNull String pkgName);
3162
3163    /**
3164     * Gets the package name of the component controlling runtime permissions.
3165     *
3166     * @return The package name.
3167     *
3168     * @hide
3169     */
3170    public abstract String getPermissionControllerPackageName();
3171
3172    /**
3173     * Add a new dynamic permission to the system.  For this to work, your
3174     * package must have defined a permission tree through the
3175     * {@link android.R.styleable#AndroidManifestPermissionTree
3176     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
3177     * permissions to trees that were defined by either its own package or
3178     * another with the same user id; a permission is in a tree if it
3179     * matches the name of the permission tree + ".": for example,
3180     * "com.foo.bar" is a member of the permission tree "com.foo".
3181     *
3182     * <p>It is good to make your permission tree name descriptive, because you
3183     * are taking possession of that entire set of permission names.  Thus, it
3184     * must be under a domain you control, with a suffix that will not match
3185     * any normal permissions that may be declared in any applications that
3186     * are part of that domain.
3187     *
3188     * <p>New permissions must be added before
3189     * any .apks are installed that use those permissions.  Permissions you
3190     * add through this method are remembered across reboots of the device.
3191     * If the given permission already exists, the info you supply here
3192     * will be used to update it.
3193     *
3194     * @param info Description of the permission to be added.
3195     *
3196     * @return Returns true if a new permission was created, false if an
3197     * existing one was updated.
3198     *
3199     * @throws SecurityException if you are not allowed to add the
3200     * given permission name.
3201     *
3202     * @see #removePermission(String)
3203     */
3204    public abstract boolean addPermission(PermissionInfo info);
3205
3206    /**
3207     * Like {@link #addPermission(PermissionInfo)} but asynchronously
3208     * persists the package manager state after returning from the call,
3209     * allowing it to return quicker and batch a series of adds at the
3210     * expense of no guarantee the added permission will be retained if
3211     * the device is rebooted before it is written.
3212     */
3213    public abstract boolean addPermissionAsync(PermissionInfo info);
3214
3215    /**
3216     * Removes a permission that was previously added with
3217     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
3218     * -- you are only allowed to remove permissions that you are allowed
3219     * to add.
3220     *
3221     * @param name The name of the permission to remove.
3222     *
3223     * @throws SecurityException if you are not allowed to remove the
3224     * given permission name.
3225     *
3226     * @see #addPermission(PermissionInfo)
3227     */
3228    public abstract void removePermission(String name);
3229
3230
3231    /**
3232     * Permission flags set when granting or revoking a permission.
3233     *
3234     * @hide
3235     */
3236    @SystemApi
3237    @IntDef({FLAG_PERMISSION_USER_SET,
3238            FLAG_PERMISSION_USER_FIXED,
3239            FLAG_PERMISSION_POLICY_FIXED,
3240            FLAG_PERMISSION_REVOKE_ON_UPGRADE,
3241            FLAG_PERMISSION_SYSTEM_FIXED,
3242            FLAG_PERMISSION_GRANTED_BY_DEFAULT})
3243    @Retention(RetentionPolicy.SOURCE)
3244    public @interface PermissionFlags {}
3245
3246    /**
3247     * Grant a runtime permission to an application which the application does not
3248     * already have. The permission must have been requested by the application.
3249     * If the application is not allowed to hold the permission, a {@link
3250     * java.lang.SecurityException} is thrown.
3251     * <p>
3252     * <strong>Note: </strong>Using this API requires holding
3253     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
3254     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3255     * </p>
3256     *
3257     * @param packageName The package to which to grant the permission.
3258     * @param permissionName The permission name to grant.
3259     * @param user The user for which to grant the permission.
3260     *
3261     * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
3262     * @see android.content.pm.PackageManager.PermissionFlags
3263     *
3264     * @hide
3265     */
3266    @SystemApi
3267    public abstract void grantRuntimePermission(@NonNull String packageName,
3268            @NonNull String permissionName, @NonNull UserHandle user);
3269
3270    /**
3271     * Revoke a runtime permission that was previously granted by {@link
3272     * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
3273     * permission must have been requested by and granted to the application.
3274     * If the application is not allowed to hold the permission, a {@link
3275     * java.lang.SecurityException} is thrown.
3276     * <p>
3277     * <strong>Note: </strong>Using this API requires holding
3278     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
3279     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3280     * </p>
3281     *
3282     * @param packageName The package from which to revoke the permission.
3283     * @param permissionName The permission name to revoke.
3284     * @param user The user for which to revoke the permission.
3285     *
3286     * @see #grantRuntimePermission(String, String, android.os.UserHandle)
3287     * @see android.content.pm.PackageManager.PermissionFlags
3288     *
3289     * @hide
3290     */
3291    @SystemApi
3292    public abstract void revokeRuntimePermission(@NonNull String packageName,
3293            @NonNull String permissionName, @NonNull UserHandle user);
3294
3295    /**
3296     * Gets the state flags associated with a permission.
3297     *
3298     * @param permissionName The permission for which to get the flags.
3299     * @param packageName The package name for which to get the flags.
3300     * @param user The user for which to get permission flags.
3301     * @return The permission flags.
3302     *
3303     * @hide
3304     */
3305    @SystemApi
3306    public abstract @PermissionFlags int getPermissionFlags(String permissionName,
3307            String packageName, @NonNull UserHandle user);
3308
3309    /**
3310     * Updates the flags associated with a permission by replacing the flags in
3311     * the specified mask with the provided flag values.
3312     *
3313     * @param permissionName The permission for which to update the flags.
3314     * @param packageName The package name for which to update the flags.
3315     * @param flagMask The flags which to replace.
3316     * @param flagValues The flags with which to replace.
3317     * @param user The user for which to update the permission flags.
3318     *
3319     * @hide
3320     */
3321    @SystemApi
3322    public abstract void updatePermissionFlags(String permissionName,
3323            String packageName, @PermissionFlags int flagMask, int flagValues,
3324            @NonNull UserHandle user);
3325
3326    /**
3327     * Gets whether you should show UI with rationale for requesting a permission.
3328     * You should do this only if you do not have the permission and the context in
3329     * which the permission is requested does not clearly communicate to the user
3330     * what would be the benefit from grating this permission.
3331     *
3332     * @param permission A permission your app wants to request.
3333     * @return Whether you can show permission rationale UI.
3334     *
3335     * @hide
3336     */
3337    public abstract boolean shouldShowRequestPermissionRationale(String permission);
3338
3339    /**
3340     * Returns an {@link android.content.Intent} suitable for passing to
3341     * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
3342     * which prompts the user to grant permissions to this application.
3343     *
3344     * @throws NullPointerException if {@code permissions} is {@code null} or empty.
3345     *
3346     * @hide
3347     */
3348    public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
3349        if (ArrayUtils.isEmpty(permissions)) {
3350           throw new IllegalArgumentException("permission cannot be null or empty");
3351        }
3352        Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
3353        intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
3354        intent.setPackage(getPermissionControllerPackageName());
3355        return intent;
3356    }
3357
3358    /**
3359     * Compare the signatures of two packages to determine if the same
3360     * signature appears in both of them.  If they do contain the same
3361     * signature, then they are allowed special privileges when working
3362     * with each other: they can share the same user-id, run instrumentation
3363     * against each other, etc.
3364     *
3365     * @param pkg1 First package name whose signature will be compared.
3366     * @param pkg2 Second package name whose signature will be compared.
3367     *
3368     * @return Returns an integer indicating whether all signatures on the
3369     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3370     * all signatures match or < 0 if there is not a match ({@link
3371     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3372     *
3373     * @see #checkSignatures(int, int)
3374     * @see #SIGNATURE_MATCH
3375     * @see #SIGNATURE_NO_MATCH
3376     * @see #SIGNATURE_UNKNOWN_PACKAGE
3377     */
3378    @CheckResult
3379    public abstract int checkSignatures(String pkg1, String pkg2);
3380
3381    /**
3382     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
3383     * the two packages to be checked.  This can be useful, for example,
3384     * when doing the check in an IPC, where the UID is the only identity
3385     * available.  It is functionally identical to determining the package
3386     * associated with the UIDs and checking their signatures.
3387     *
3388     * @param uid1 First UID whose signature will be compared.
3389     * @param uid2 Second UID whose signature will be compared.
3390     *
3391     * @return Returns an integer indicating whether all signatures on the
3392     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3393     * all signatures match or < 0 if there is not a match ({@link
3394     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3395     *
3396     * @see #checkSignatures(String, String)
3397     * @see #SIGNATURE_MATCH
3398     * @see #SIGNATURE_NO_MATCH
3399     * @see #SIGNATURE_UNKNOWN_PACKAGE
3400     */
3401    @CheckResult
3402    public abstract int checkSignatures(int uid1, int uid2);
3403
3404    /**
3405     * Retrieve the names of all packages that are associated with a particular
3406     * user id.  In most cases, this will be a single package name, the package
3407     * that has been assigned that user id.  Where there are multiple packages
3408     * sharing the same user id through the "sharedUserId" mechanism, all
3409     * packages with that id will be returned.
3410     *
3411     * @param uid The user id for which you would like to retrieve the
3412     * associated packages.
3413     *
3414     * @return Returns an array of one or more packages assigned to the user
3415     * id, or null if there are no known packages with the given id.
3416     */
3417    public abstract @Nullable String[] getPackagesForUid(int uid);
3418
3419    /**
3420     * Retrieve the official name associated with a user id.  This name is
3421     * guaranteed to never change, though it is possible for the underlying
3422     * user id to be changed.  That is, if you are storing information about
3423     * user ids in persistent storage, you should use the string returned
3424     * by this function instead of the raw user-id.
3425     *
3426     * @param uid The user id for which you would like to retrieve a name.
3427     * @return Returns a unique name for the given user id, or null if the
3428     * user id is not currently assigned.
3429     */
3430    public abstract @Nullable String getNameForUid(int uid);
3431
3432    /**
3433     * Return the user id associated with a shared user name. Multiple
3434     * applications can specify a shared user name in their manifest and thus
3435     * end up using a common uid. This might be used for new applications
3436     * that use an existing shared user name and need to know the uid of the
3437     * shared user.
3438     *
3439     * @param sharedUserName The shared user name whose uid is to be retrieved.
3440     * @return Returns the UID associated with the shared user.
3441     * @throws NameNotFoundException if a package with the given name cannot be
3442     *             found on the system.
3443     * @hide
3444     */
3445    public abstract int getUidForSharedUser(String sharedUserName)
3446            throws NameNotFoundException;
3447
3448    /**
3449     * Return a List of all application packages that are installed on the
3450     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
3451     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
3452     * installed apps with data directory) will be returned.
3453     *
3454     * @param flags Additional option flags. Use any combination of
3455     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3456     * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3457     * to modify the data returned.
3458     *
3459     * @return A List of ApplicationInfo objects, one for each installed application.
3460     *         In the unlikely case there are no installed packages, an empty list
3461     *         is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the
3462     *         application information is retrieved from the list of uninstalled
3463     *         applications (which includes installed applications as well as
3464     *         applications with data directory i.e. applications which had been
3465     *         deleted with {@code DONT_DELETE_DATA} flag set).
3466     *
3467     * @see #GET_META_DATA
3468     * @see #GET_SHARED_LIBRARY_FILES
3469     * @see #MATCH_SYSTEM_ONLY
3470     * @see #MATCH_UNINSTALLED_PACKAGES
3471     */
3472    public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
3473
3474    /**
3475     * Gets the ephemeral applications the user recently used. Requires
3476     * holding "android.permission.ACCESS_EPHEMERAL_APPS".
3477     *
3478     * @return The ephemeral app list.
3479     *
3480     * @hide
3481     */
3482    @RequiresPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS)
3483    public abstract List<EphemeralApplicationInfo> getEphemeralApplications();
3484
3485    /**
3486     * Gets the icon for an ephemeral application.
3487     *
3488     * @param packageName The app package name.
3489     *
3490     * @hide
3491     */
3492    public abstract Drawable getEphemeralApplicationIcon(String packageName);
3493
3494    /**
3495     * Gets whether the caller is an ephemeral app.
3496     *
3497     * @return Whether caller is an ephemeral app.
3498     *
3499     * @see #setEphemeralCookie(byte[])
3500     * @see #getEphemeralCookie()
3501     * @see #getEphemeralCookieMaxSizeBytes()
3502     *
3503     * @hide
3504     */
3505    public abstract boolean isEphemeralApplication();
3506
3507    /**
3508     * Gets the maximum size in bytes of the cookie data an ephemeral app
3509     * can store on the device.
3510     *
3511     * @return The max cookie size in bytes.
3512     *
3513     * @see #isEphemeralApplication()
3514     * @see #setEphemeralCookie(byte[])
3515     * @see #getEphemeralCookie()
3516     *
3517     * @hide
3518     */
3519    public abstract int getEphemeralCookieMaxSizeBytes();
3520
3521    /**
3522     * Gets the ephemeral application cookie for this app. Non
3523     * ephemeral apps and apps that were ephemeral but were upgraded
3524     * to non-ephemeral can still access this API. For ephemeral apps
3525     * this cooke is cached for some time after uninstall while for
3526     * normal apps the cookie is deleted after the app is uninstalled.
3527     * The cookie is always present while the app is installed.
3528     *
3529     * @return The cookie.
3530     *
3531     * @see #isEphemeralApplication()
3532     * @see #setEphemeralCookie(byte[])
3533     * @see #getEphemeralCookieMaxSizeBytes()
3534     *
3535     * @hide
3536     */
3537    public abstract @NonNull byte[] getEphemeralCookie();
3538
3539    /**
3540     * Sets the ephemeral application cookie for the calling app. Non
3541     * ephemeral apps and apps that were ephemeral but were upgraded
3542     * to non-ephemeral can still access this API. For ephemeral apps
3543     * this cooke is cached for some time after uninstall while for
3544     * normal apps the cookie is deleted after the app is uninstalled.
3545     * The cookie is always present while the app is installed. The
3546     * cookie size is limited by {@link #getEphemeralCookieMaxSizeBytes()}.
3547     *
3548     * @param cookie The cookie data.
3549     * @return True if the cookie was set.
3550     *
3551     * @see #isEphemeralApplication()
3552     * @see #getEphemeralCookieMaxSizeBytes()
3553     * @see #getEphemeralCookie()
3554     *
3555     * @hide
3556     */
3557    public abstract boolean setEphemeralCookie(@NonNull  byte[] cookie);
3558
3559    /**
3560     * Get a list of shared libraries that are available on the
3561     * system.
3562     *
3563     * @return An array of shared library names that are
3564     * available on the system, or null if none are installed.
3565     *
3566     */
3567    public abstract String[] getSystemSharedLibraryNames();
3568
3569    /**
3570     * Get the name of the package hosting the services shared library.
3571     *
3572     * @return The library host package.
3573     *
3574     * @hide
3575     */
3576    public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
3577
3578    /**
3579     * Get the name of the package hosting the shared components shared library.
3580     *
3581     * @return The library host package.
3582     *
3583     * @hide
3584     */
3585    public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
3586
3587    /**
3588     * Get a list of features that are available on the
3589     * system.
3590     *
3591     * @return An array of FeatureInfo classes describing the features
3592     * that are available on the system, or null if there are none(!!).
3593     */
3594    public abstract FeatureInfo[] getSystemAvailableFeatures();
3595
3596    /**
3597     * Check whether the given feature name is one of the available features as
3598     * returned by {@link #getSystemAvailableFeatures()}. This tests for the
3599     * presence of <em>any</em> version of the given feature name; use
3600     * {@link #hasSystemFeature(String, int)} to check for a minimum version.
3601     *
3602     * @return Returns true if the devices supports the feature, else false.
3603     */
3604    public abstract boolean hasSystemFeature(String name);
3605
3606    /**
3607     * Check whether the given feature name and version is one of the available
3608     * features as returned by {@link #getSystemAvailableFeatures()}. Since
3609     * features are defined to always be backwards compatible, this returns true
3610     * if the available feature version is greater than or equal to the
3611     * requested version.
3612     *
3613     * @return Returns true if the devices supports the feature, else false.
3614     */
3615    public abstract boolean hasSystemFeature(String name, int version);
3616
3617    /**
3618     * Determine the best action to perform for a given Intent. This is how
3619     * {@link Intent#resolveActivity} finds an activity if a class has not been
3620     * explicitly specified.
3621     * <p>
3622     * <em>Note:</em> if using an implicit Intent (without an explicit
3623     * ComponentName specified), be sure to consider whether to set the
3624     * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3625     * activity in the same way that
3626     * {@link android.content.Context#startActivity(Intent)} and
3627     * {@link android.content.Intent#resolveActivity(PackageManager)
3628     * Intent.resolveActivity(PackageManager)} do.
3629     * </p>
3630     *
3631     * @param intent An intent containing all of the desired specification
3632     *            (action, data, type, category, and/or component).
3633     * @param flags Additional option flags. Use any combination of
3634     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3635     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3636     *            {@link #MATCH_DISABLED_COMPONENTS},
3637     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3638     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3639     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3640     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3641     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3642     *            to limit the resolution to only those activities that support
3643     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
3644     * @return Returns a ResolveInfo object containing the final activity intent
3645     *         that was determined to be the best action. Returns null if no
3646     *         matching activity was found. If multiple matching activities are
3647     *         found and there is no default set, returns a ResolveInfo object
3648     *         containing something else, such as the activity resolver.
3649     * @see #GET_META_DATA
3650     * @see #GET_RESOLVED_FILTER
3651     * @see #GET_SHARED_LIBRARY_FILES
3652     * @see #MATCH_ALL
3653     * @see #MATCH_DISABLED_COMPONENTS
3654     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3655     * @see #MATCH_DEFAULT_ONLY
3656     * @see #MATCH_DIRECT_BOOT_AWARE
3657     * @see #MATCH_DIRECT_BOOT_UNAWARE
3658     * @see #MATCH_SYSTEM_ONLY
3659     * @see #MATCH_UNINSTALLED_PACKAGES
3660     */
3661    public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
3662
3663    /**
3664     * Determine the best action to perform for a given Intent for a given user.
3665     * This is how {@link Intent#resolveActivity} finds an activity if a class
3666     * has not been explicitly specified.
3667     * <p>
3668     * <em>Note:</em> if using an implicit Intent (without an explicit
3669     * ComponentName specified), be sure to consider whether to set the
3670     * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3671     * activity in the same way that
3672     * {@link android.content.Context#startActivity(Intent)} and
3673     * {@link android.content.Intent#resolveActivity(PackageManager)
3674     * Intent.resolveActivity(PackageManager)} do.
3675     * </p>
3676     *
3677     * @param intent An intent containing all of the desired specification
3678     *            (action, data, type, category, and/or component).
3679     * @param flags Additional option flags. Use any combination of
3680     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3681     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3682     *            {@link #MATCH_DISABLED_COMPONENTS},
3683     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3684     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3685     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3686     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3687     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3688     *            to limit the resolution to only those activities that support
3689     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
3690     * @param userId The user id.
3691     * @return Returns a ResolveInfo object containing the final activity intent
3692     *         that was determined to be the best action. Returns null if no
3693     *         matching activity was found. If multiple matching activities are
3694     *         found and there is no default set, returns a ResolveInfo object
3695     *         containing something else, such as the activity resolver.
3696     * @see #GET_META_DATA
3697     * @see #GET_RESOLVED_FILTER
3698     * @see #GET_SHARED_LIBRARY_FILES
3699     * @see #MATCH_ALL
3700     * @see #MATCH_DISABLED_COMPONENTS
3701     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3702     * @see #MATCH_DEFAULT_ONLY
3703     * @see #MATCH_DIRECT_BOOT_AWARE
3704     * @see #MATCH_DIRECT_BOOT_UNAWARE
3705     * @see #MATCH_SYSTEM_ONLY
3706     * @see #MATCH_UNINSTALLED_PACKAGES
3707     * @hide
3708     */
3709    public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
3710            @UserIdInt int userId);
3711
3712    /**
3713     * Retrieve all activities that can be performed for the given intent.
3714     *
3715     * @param intent The desired intent as per resolveActivity().
3716     * @param flags Additional option flags. Use any combination of
3717     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3718     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3719     *            {@link #MATCH_DISABLED_COMPONENTS},
3720     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3721     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3722     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3723     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3724     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3725     *            to limit the resolution to only those activities that support
3726     *            the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
3727     *            {@link #MATCH_ALL} to prevent any filtering of the results.
3728     * @return Returns a List of ResolveInfo objects containing one entry for
3729     *         each matching activity, ordered from best to worst. In other
3730     *         words, the first item is what would be returned by
3731     *         {@link #resolveActivity}. If there are no matching activities, an
3732     *         empty list is returned.
3733     * @see #GET_META_DATA
3734     * @see #GET_RESOLVED_FILTER
3735     * @see #GET_SHARED_LIBRARY_FILES
3736     * @see #MATCH_ALL
3737     * @see #MATCH_DISABLED_COMPONENTS
3738     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3739     * @see #MATCH_DEFAULT_ONLY
3740     * @see #MATCH_DIRECT_BOOT_AWARE
3741     * @see #MATCH_DIRECT_BOOT_UNAWARE
3742     * @see #MATCH_SYSTEM_ONLY
3743     * @see #MATCH_UNINSTALLED_PACKAGES
3744     */
3745    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
3746            @ResolveInfoFlags int flags);
3747
3748    /**
3749     * Retrieve all activities that can be performed for the given intent, for a
3750     * specific user.
3751     *
3752     * @param intent The desired intent as per resolveActivity().
3753     * @param flags Additional option flags. Use any combination of
3754     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3755     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3756     *            {@link #MATCH_DISABLED_COMPONENTS},
3757     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3758     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3759     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3760     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3761     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3762     *            to limit the resolution to only those activities that support
3763     *            the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
3764     *            {@link #MATCH_ALL} to prevent any filtering of the results.
3765     * @return Returns a List of ResolveInfo objects containing one entry for
3766     *         each matching activity, ordered from best to worst. In other
3767     *         words, the first item is what would be returned by
3768     *         {@link #resolveActivity}. If there are no matching activities, an
3769     *         empty list is returned.
3770     * @see #GET_META_DATA
3771     * @see #GET_RESOLVED_FILTER
3772     * @see #GET_SHARED_LIBRARY_FILES
3773     * @see #MATCH_ALL
3774     * @see #MATCH_DISABLED_COMPONENTS
3775     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3776     * @see #MATCH_DEFAULT_ONLY
3777     * @see #MATCH_DIRECT_BOOT_AWARE
3778     * @see #MATCH_DIRECT_BOOT_UNAWARE
3779     * @see #MATCH_SYSTEM_ONLY
3780     * @see #MATCH_UNINSTALLED_PACKAGES
3781     * @hide
3782     */
3783    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
3784            @ResolveInfoFlags int flags, @UserIdInt int userId);
3785
3786    /**
3787     * Retrieve a set of activities that should be presented to the user as
3788     * similar options. This is like {@link #queryIntentActivities}, except it
3789     * also allows you to supply a list of more explicit Intents that you would
3790     * like to resolve to particular options, and takes care of returning the
3791     * final ResolveInfo list in a reasonable order, with no duplicates, based
3792     * on those inputs.
3793     *
3794     * @param caller The class name of the activity that is making the request.
3795     *            This activity will never appear in the output list. Can be
3796     *            null.
3797     * @param specifics An array of Intents that should be resolved to the first
3798     *            specific results. Can be null.
3799     * @param intent The desired intent as per resolveActivity().
3800     * @param flags Additional option flags. Use any combination of
3801     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3802     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3803     *            {@link #MATCH_DISABLED_COMPONENTS},
3804     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3805     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3806     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3807     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3808     *            returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3809     *            to limit the resolution to only those activities that support
3810     *            the {@link android.content.Intent#CATEGORY_DEFAULT}.
3811     * @return Returns a List of ResolveInfo objects containing one entry for
3812     *         each matching activity. The list is ordered first by all of the
3813     *         intents resolved in <var>specifics</var> and then any additional
3814     *         activities that can handle <var>intent</var> but did not get
3815     *         included by one of the <var>specifics</var> intents. If there are
3816     *         no matching activities, an empty list is returned.
3817     * @see #GET_META_DATA
3818     * @see #GET_RESOLVED_FILTER
3819     * @see #GET_SHARED_LIBRARY_FILES
3820     * @see #MATCH_ALL
3821     * @see #MATCH_DISABLED_COMPONENTS
3822     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3823     * @see #MATCH_DEFAULT_ONLY
3824     * @see #MATCH_DIRECT_BOOT_AWARE
3825     * @see #MATCH_DIRECT_BOOT_UNAWARE
3826     * @see #MATCH_SYSTEM_ONLY
3827     * @see #MATCH_UNINSTALLED_PACKAGES
3828     */
3829    public abstract List<ResolveInfo> queryIntentActivityOptions(
3830            ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
3831
3832    /**
3833     * Retrieve all receivers that can handle a broadcast of the given intent.
3834     *
3835     * @param intent The desired intent as per resolveActivity().
3836     * @param flags Additional option flags. Use any combination of
3837     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3838     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3839     *            {@link #MATCH_DISABLED_COMPONENTS},
3840     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3841     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3842     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3843     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3844     *            returned.
3845     * @return Returns a List of ResolveInfo objects containing one entry for
3846     *         each matching receiver, ordered from best to worst. If there are
3847     *         no matching receivers, an empty list or null is returned.
3848     * @see #GET_META_DATA
3849     * @see #GET_RESOLVED_FILTER
3850     * @see #GET_SHARED_LIBRARY_FILES
3851     * @see #MATCH_ALL
3852     * @see #MATCH_DISABLED_COMPONENTS
3853     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3854     * @see #MATCH_DEFAULT_ONLY
3855     * @see #MATCH_DIRECT_BOOT_AWARE
3856     * @see #MATCH_DIRECT_BOOT_UNAWARE
3857     * @see #MATCH_SYSTEM_ONLY
3858     * @see #MATCH_UNINSTALLED_PACKAGES
3859     */
3860    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3861            @ResolveInfoFlags int flags);
3862
3863    /**
3864     * Retrieve all receivers that can handle a broadcast of the given intent,
3865     * for a specific user.
3866     *
3867     * @param intent The desired intent as per resolveActivity().
3868     * @param flags Additional option flags. Use any combination of
3869     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3870     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3871     *            {@link #MATCH_DISABLED_COMPONENTS},
3872     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3873     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3874     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3875     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3876     *            returned.
3877     * @param userHandle UserHandle of the user being queried.
3878     * @return Returns a List of ResolveInfo objects containing one entry for
3879     *         each matching receiver, ordered from best to worst. If there are
3880     *         no matching receivers, an empty list or null is returned.
3881     * @see #GET_META_DATA
3882     * @see #GET_RESOLVED_FILTER
3883     * @see #GET_SHARED_LIBRARY_FILES
3884     * @see #MATCH_ALL
3885     * @see #MATCH_DISABLED_COMPONENTS
3886     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3887     * @see #MATCH_DEFAULT_ONLY
3888     * @see #MATCH_DIRECT_BOOT_AWARE
3889     * @see #MATCH_DIRECT_BOOT_UNAWARE
3890     * @see #MATCH_SYSTEM_ONLY
3891     * @see #MATCH_UNINSTALLED_PACKAGES
3892     * @hide
3893     */
3894    @SystemApi
3895    public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
3896            @ResolveInfoFlags int flags, UserHandle userHandle) {
3897        return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
3898    }
3899
3900    /**
3901     * @hide
3902     */
3903    public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
3904            @ResolveInfoFlags int flags, @UserIdInt int userId);
3905
3906
3907    /** {@hide} */
3908    @Deprecated
3909    public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3910            @ResolveInfoFlags int flags, @UserIdInt int userId) {
3911        Log.w(TAG, "STAHP USING HIDDEN APIS KTHX");
3912        return queryBroadcastReceiversAsUser(intent, flags, userId);
3913    }
3914
3915    /**
3916     * Determine the best service to handle for a given Intent.
3917     *
3918     * @param intent An intent containing all of the desired specification
3919     *            (action, data, type, category, and/or component).
3920     * @param flags Additional option flags. Use any combination of
3921     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3922     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3923     *            {@link #MATCH_DISABLED_COMPONENTS},
3924     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3925     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3926     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3927     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3928     *            returned.
3929     * @return Returns a ResolveInfo object containing the final service intent
3930     *         that was determined to be the best action. Returns null if no
3931     *         matching service was found.
3932     * @see #GET_META_DATA
3933     * @see #GET_RESOLVED_FILTER
3934     * @see #GET_SHARED_LIBRARY_FILES
3935     * @see #MATCH_ALL
3936     * @see #MATCH_DISABLED_COMPONENTS
3937     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3938     * @see #MATCH_DEFAULT_ONLY
3939     * @see #MATCH_DIRECT_BOOT_AWARE
3940     * @see #MATCH_DIRECT_BOOT_UNAWARE
3941     * @see #MATCH_SYSTEM_ONLY
3942     * @see #MATCH_UNINSTALLED_PACKAGES
3943     */
3944    public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
3945
3946    /**
3947     * Retrieve all services that can match the given intent.
3948     *
3949     * @param intent The desired intent as per resolveService().
3950     * @param flags Additional option flags. Use any combination of
3951     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3952     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3953     *            {@link #MATCH_DISABLED_COMPONENTS},
3954     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3955     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3956     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3957     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3958     *            returned.
3959     * @return Returns a List of ResolveInfo objects containing one entry for
3960     *         each matching service, ordered from best to worst. In other
3961     *         words, the first item is what would be returned by
3962     *         {@link #resolveService}. If there are no matching services, an
3963     *         empty list or null is returned.
3964     * @see #GET_META_DATA
3965     * @see #GET_RESOLVED_FILTER
3966     * @see #GET_SHARED_LIBRARY_FILES
3967     * @see #MATCH_ALL
3968     * @see #MATCH_DISABLED_COMPONENTS
3969     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3970     * @see #MATCH_DEFAULT_ONLY
3971     * @see #MATCH_DIRECT_BOOT_AWARE
3972     * @see #MATCH_DIRECT_BOOT_UNAWARE
3973     * @see #MATCH_SYSTEM_ONLY
3974     * @see #MATCH_UNINSTALLED_PACKAGES
3975     */
3976    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
3977            @ResolveInfoFlags int flags);
3978
3979    /**
3980     * Retrieve all services that can match the given intent for a given user.
3981     *
3982     * @param intent The desired intent as per resolveService().
3983     * @param flags Additional option flags. Use any combination of
3984     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3985     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3986     *            {@link #MATCH_DISABLED_COMPONENTS},
3987     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3988     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3989     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3990     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3991     *            returned.
3992     * @param userId The user id.
3993     * @return Returns a List of ResolveInfo objects containing one entry for
3994     *         each matching service, ordered from best to worst. In other
3995     *         words, the first item is what would be returned by
3996     *         {@link #resolveService}. If there are no matching services, an
3997     *         empty list or null is returned.
3998     * @see #GET_META_DATA
3999     * @see #GET_RESOLVED_FILTER
4000     * @see #GET_SHARED_LIBRARY_FILES
4001     * @see #MATCH_ALL
4002     * @see #MATCH_DISABLED_COMPONENTS
4003     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4004     * @see #MATCH_DEFAULT_ONLY
4005     * @see #MATCH_DIRECT_BOOT_AWARE
4006     * @see #MATCH_DIRECT_BOOT_UNAWARE
4007     * @see #MATCH_SYSTEM_ONLY
4008     * @see #MATCH_UNINSTALLED_PACKAGES
4009     * @hide
4010     */
4011    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
4012            @ResolveInfoFlags int flags, @UserIdInt int userId);
4013
4014    /**
4015     * Retrieve all providers that can match the given intent.
4016     *
4017     * @param intent An intent containing all of the desired specification
4018     *            (action, data, type, category, and/or component).
4019     * @param flags Additional option flags. Use any combination of
4020     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4021     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4022     *            {@link #MATCH_DISABLED_COMPONENTS},
4023     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4024     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4025     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4026     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4027     *            returned.
4028     * @param userId The user id.
4029     * @return Returns a List of ResolveInfo objects containing one entry for
4030     *         each matching provider, ordered from best to worst. If there are
4031     *         no matching services, an empty list or null is returned.
4032     * @see #GET_META_DATA
4033     * @see #GET_RESOLVED_FILTER
4034     * @see #GET_SHARED_LIBRARY_FILES
4035     * @see #MATCH_ALL
4036     * @see #MATCH_DISABLED_COMPONENTS
4037     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4038     * @see #MATCH_DEFAULT_ONLY
4039     * @see #MATCH_DIRECT_BOOT_AWARE
4040     * @see #MATCH_DIRECT_BOOT_UNAWARE
4041     * @see #MATCH_SYSTEM_ONLY
4042     * @see #MATCH_UNINSTALLED_PACKAGES
4043     * @hide
4044     */
4045    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
4046            Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
4047
4048    /**
4049     * Retrieve all providers that can match the given intent.
4050     *
4051     * @param intent An intent containing all of the desired specification
4052     *            (action, data, type, category, and/or component).
4053     * @param flags Additional option flags. Use any combination of
4054     *            {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4055     *            {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4056     *            {@link #MATCH_DISABLED_COMPONENTS},
4057     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4058     *            {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4059     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4060     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4061     *            returned.
4062     * @return Returns a List of ResolveInfo objects containing one entry for
4063     *         each matching provider, ordered from best to worst. If there are
4064     *         no matching services, an empty list or null is returned.
4065     * @see #GET_META_DATA
4066     * @see #GET_RESOLVED_FILTER
4067     * @see #GET_SHARED_LIBRARY_FILES
4068     * @see #MATCH_ALL
4069     * @see #MATCH_DISABLED_COMPONENTS
4070     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4071     * @see #MATCH_DEFAULT_ONLY
4072     * @see #MATCH_DIRECT_BOOT_AWARE
4073     * @see #MATCH_DIRECT_BOOT_UNAWARE
4074     * @see #MATCH_SYSTEM_ONLY
4075     * @see #MATCH_UNINSTALLED_PACKAGES
4076     */
4077    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
4078            @ResolveInfoFlags int flags);
4079
4080    /**
4081     * Find a single content provider by its base path name.
4082     *
4083     * @param name The name of the provider to find.
4084     * @param flags Additional option flags. Use any combination of
4085     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4086     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4087     *            {@link #MATCH_DISABLED_COMPONENTS},
4088     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4089     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4090     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4091     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4092     *            returned.
4093     * @return A {@link ProviderInfo} object containing information about the
4094     *         provider. If a provider was not found, returns null.
4095     * @see #GET_META_DATA
4096     * @see #GET_SHARED_LIBRARY_FILES
4097     * @see #MATCH_ALL
4098     * @see #MATCH_DEBUG_TRIAGED_MISSING
4099     * @see #MATCH_DEFAULT_ONLY
4100     * @see #MATCH_DISABLED_COMPONENTS
4101     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4102     * @see #MATCH_DIRECT_BOOT_AWARE
4103     * @see #MATCH_DIRECT_BOOT_UNAWARE
4104     * @see #MATCH_SYSTEM_ONLY
4105     * @see #MATCH_UNINSTALLED_PACKAGES
4106     */
4107    public abstract ProviderInfo resolveContentProvider(String name,
4108            @ComponentInfoFlags int flags);
4109
4110    /**
4111     * Find a single content provider by its base path name.
4112     *
4113     * @param name The name of the provider to find.
4114     * @param flags Additional option flags. Use any combination of
4115     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4116     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4117     *            {@link #MATCH_DISABLED_COMPONENTS},
4118     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4119     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4120     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4121     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4122     *            returned.
4123     * @param userId The user id.
4124     * @return A {@link ProviderInfo} object containing information about the
4125     *         provider. If a provider was not found, returns null.
4126     * @see #GET_META_DATA
4127     * @see #GET_SHARED_LIBRARY_FILES
4128     * @see #MATCH_ALL
4129     * @see #MATCH_DEBUG_TRIAGED_MISSING
4130     * @see #MATCH_DEFAULT_ONLY
4131     * @see #MATCH_DISABLED_COMPONENTS
4132     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4133     * @see #MATCH_DIRECT_BOOT_AWARE
4134     * @see #MATCH_DIRECT_BOOT_UNAWARE
4135     * @see #MATCH_SYSTEM_ONLY
4136     * @see #MATCH_UNINSTALLED_PACKAGES
4137     * @hide
4138     */
4139    public abstract ProviderInfo resolveContentProviderAsUser(String name,
4140            @ComponentInfoFlags int flags, @UserIdInt int userId);
4141
4142    /**
4143     * Retrieve content provider information.
4144     * <p>
4145     * <em>Note: unlike most other methods, an empty result set is indicated
4146     * by a null return instead of an empty list.</em>
4147     *
4148     * @param processName If non-null, limits the returned providers to only
4149     *            those that are hosted by the given process. If null, all
4150     *            content providers are returned.
4151     * @param uid If <var>processName</var> is non-null, this is the required
4152     *            uid owning the requested content providers.
4153     * @param flags Additional option flags. Use any combination of
4154     *            {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4155     *            {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4156     *            {@link #MATCH_DISABLED_COMPONENTS},
4157     *            {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4158     *            {@link #MATCH_DIRECT_BOOT_AWARE},
4159     *            {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4160     *            or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4161     *            returned.
4162     * @return A list of {@link ProviderInfo} objects containing one entry for
4163     *         each provider either matching <var>processName</var> or, if
4164     *         <var>processName</var> is null, all known content providers.
4165     *         <em>If there are no matching providers, null is returned.</em>
4166     * @see #GET_META_DATA
4167     * @see #GET_SHARED_LIBRARY_FILES
4168     * @see #MATCH_ALL
4169     * @see #MATCH_DEBUG_TRIAGED_MISSING
4170     * @see #MATCH_DEFAULT_ONLY
4171     * @see #MATCH_DISABLED_COMPONENTS
4172     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4173     * @see #MATCH_DIRECT_BOOT_AWARE
4174     * @see #MATCH_DIRECT_BOOT_UNAWARE
4175     * @see #MATCH_SYSTEM_ONLY
4176     * @see #MATCH_UNINSTALLED_PACKAGES
4177     */
4178    public abstract List<ProviderInfo> queryContentProviders(
4179            String processName, int uid, @ComponentInfoFlags int flags);
4180
4181    /**
4182     * Retrieve all of the information we know about a particular
4183     * instrumentation class.
4184     *
4185     * @param className The full name (i.e.
4186     *                  com.google.apps.contacts.InstrumentList) of an
4187     *                  Instrumentation class.
4188     * @param flags Additional option flags. Use any combination of
4189     *         {@link #GET_META_DATA}
4190     *         to modify the data returned.
4191     *
4192     * @return An {@link InstrumentationInfo} object containing information about the
4193     *         instrumentation.
4194     * @throws NameNotFoundException if a package with the given name cannot be
4195     *             found on the system.
4196     *
4197     * @see #GET_META_DATA
4198     */
4199    public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
4200            @InstrumentationInfoFlags int flags) throws NameNotFoundException;
4201
4202    /**
4203     * Retrieve information about available instrumentation code.  May be used
4204     * to retrieve either all instrumentation code, or only the code targeting
4205     * a particular package.
4206     *
4207     * @param targetPackage If null, all instrumentation is returned; only the
4208     *                      instrumentation targeting this package name is
4209     *                      returned.
4210     * @param flags Additional option flags. Use any combination of
4211     *         {@link #GET_META_DATA}
4212     *         to modify the data returned.
4213     *
4214     * @return A list of {@link InstrumentationInfo} objects containing one
4215     *         entry for each matching instrumentation. If there are no
4216     *         instrumentation available, returns an empty list.
4217     *
4218     * @see #GET_META_DATA
4219     */
4220    public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
4221            @InstrumentationInfoFlags int flags);
4222
4223    /**
4224     * Retrieve an image from a package.  This is a low-level API used by
4225     * the various package manager info structures (such as
4226     * {@link ComponentInfo} to implement retrieval of their associated
4227     * icon.
4228     *
4229     * @param packageName The name of the package that this icon is coming from.
4230     * Cannot be null.
4231     * @param resid The resource identifier of the desired image.  Cannot be 0.
4232     * @param appInfo Overall information about <var>packageName</var>.  This
4233     * may be null, in which case the application information will be retrieved
4234     * for you if needed; if you already have this information around, it can
4235     * be much more efficient to supply it here.
4236     *
4237     * @return Returns a Drawable holding the requested image.  Returns null if
4238     * an image could not be found for any reason.
4239     */
4240    public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
4241            ApplicationInfo appInfo);
4242
4243    /**
4244     * Retrieve the icon associated with an activity.  Given the full name of
4245     * an activity, retrieves the information about it and calls
4246     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
4247     * If the activity cannot be found, NameNotFoundException is thrown.
4248     *
4249     * @param activityName Name of the activity whose icon is to be retrieved.
4250     *
4251     * @return Returns the image of the icon, or the default activity icon if
4252     * it could not be found.  Does not return null.
4253     * @throws NameNotFoundException Thrown if the resources for the given
4254     * activity could not be loaded.
4255     *
4256     * @see #getActivityIcon(Intent)
4257     */
4258    public abstract Drawable getActivityIcon(ComponentName activityName)
4259            throws NameNotFoundException;
4260
4261    /**
4262     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
4263     * set, this simply returns the result of
4264     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
4265     * component and returns the icon associated with the resolved component.
4266     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4267     * to a component, NameNotFoundException is thrown.
4268     *
4269     * @param intent The intent for which you would like to retrieve an icon.
4270     *
4271     * @return Returns the image of the icon, or the default activity icon if
4272     * it could not be found.  Does not return null.
4273     * @throws NameNotFoundException Thrown if the resources for application
4274     * matching the given intent could not be loaded.
4275     *
4276     * @see #getActivityIcon(ComponentName)
4277     */
4278    public abstract Drawable getActivityIcon(Intent intent)
4279            throws NameNotFoundException;
4280
4281    /**
4282     * Retrieve the banner associated with an activity. Given the full name of
4283     * an activity, retrieves the information about it and calls
4284     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4285     * banner. If the activity cannot be found, NameNotFoundException is thrown.
4286     *
4287     * @param activityName Name of the activity whose banner is to be retrieved.
4288     * @return Returns the image of the banner, or null if the activity has no
4289     *         banner specified.
4290     * @throws NameNotFoundException Thrown if the resources for the given
4291     *             activity could not be loaded.
4292     * @see #getActivityBanner(Intent)
4293     */
4294    public abstract Drawable getActivityBanner(ComponentName activityName)
4295            throws NameNotFoundException;
4296
4297    /**
4298     * Retrieve the banner associated with an Intent. If intent.getClassName()
4299     * is set, this simply returns the result of
4300     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4301     * intent's component and returns the banner associated with the resolved
4302     * component. If intent.getClassName() cannot be found or the Intent cannot
4303     * be resolved to a component, NameNotFoundException is thrown.
4304     *
4305     * @param intent The intent for which you would like to retrieve a banner.
4306     * @return Returns the image of the banner, or null if the activity has no
4307     *         banner specified.
4308     * @throws NameNotFoundException Thrown if the resources for application
4309     *             matching the given intent could not be loaded.
4310     * @see #getActivityBanner(ComponentName)
4311     */
4312    public abstract Drawable getActivityBanner(Intent intent)
4313            throws NameNotFoundException;
4314
4315    /**
4316     * Return the generic icon for an activity that is used when no specific
4317     * icon is defined.
4318     *
4319     * @return Drawable Image of the icon.
4320     */
4321    public abstract Drawable getDefaultActivityIcon();
4322
4323    /**
4324     * Retrieve the icon associated with an application.  If it has not defined
4325     * an icon, the default app icon is returned.  Does not return null.
4326     *
4327     * @param info Information about application being queried.
4328     *
4329     * @return Returns the image of the icon, or the default application icon
4330     * if it could not be found.
4331     *
4332     * @see #getApplicationIcon(String)
4333     */
4334    public abstract Drawable getApplicationIcon(ApplicationInfo info);
4335
4336    /**
4337     * Retrieve the icon associated with an application.  Given the name of the
4338     * application's package, retrieves the information about it and calls
4339     * getApplicationIcon() to return its icon. If the application cannot be
4340     * found, NameNotFoundException is thrown.
4341     *
4342     * @param packageName Name of the package whose application icon is to be
4343     *                    retrieved.
4344     *
4345     * @return Returns the image of the icon, or the default application icon
4346     * if it could not be found.  Does not return null.
4347     * @throws NameNotFoundException Thrown if the resources for the given
4348     * application could not be loaded.
4349     *
4350     * @see #getApplicationIcon(ApplicationInfo)
4351     */
4352    public abstract Drawable getApplicationIcon(String packageName)
4353            throws NameNotFoundException;
4354
4355    /**
4356     * Retrieve the banner associated with an application.
4357     *
4358     * @param info Information about application being queried.
4359     * @return Returns the image of the banner or null if the application has no
4360     *         banner specified.
4361     * @see #getApplicationBanner(String)
4362     */
4363    public abstract Drawable getApplicationBanner(ApplicationInfo info);
4364
4365    /**
4366     * Retrieve the banner associated with an application. Given the name of the
4367     * application's package, retrieves the information about it and calls
4368     * getApplicationIcon() to return its banner. If the application cannot be
4369     * found, NameNotFoundException is thrown.
4370     *
4371     * @param packageName Name of the package whose application banner is to be
4372     *            retrieved.
4373     * @return Returns the image of the banner or null if the application has no
4374     *         banner specified.
4375     * @throws NameNotFoundException Thrown if the resources for the given
4376     *             application could not be loaded.
4377     * @see #getApplicationBanner(ApplicationInfo)
4378     */
4379    public abstract Drawable getApplicationBanner(String packageName)
4380            throws NameNotFoundException;
4381
4382    /**
4383     * Retrieve the logo associated with an activity. Given the full name of an
4384     * activity, retrieves the information about it and calls
4385     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4386     * logo. If the activity cannot be found, NameNotFoundException is thrown.
4387     *
4388     * @param activityName Name of the activity whose logo is to be retrieved.
4389     * @return Returns the image of the logo or null if the activity has no logo
4390     *         specified.
4391     * @throws NameNotFoundException Thrown if the resources for the given
4392     *             activity could not be loaded.
4393     * @see #getActivityLogo(Intent)
4394     */
4395    public abstract Drawable getActivityLogo(ComponentName activityName)
4396            throws NameNotFoundException;
4397
4398    /**
4399     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
4400     * set, this simply returns the result of
4401     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
4402     * component and returns the logo associated with the resolved component.
4403     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4404     * to a component, NameNotFoundException is thrown.
4405     *
4406     * @param intent The intent for which you would like to retrieve a logo.
4407     *
4408     * @return Returns the image of the logo, or null if the activity has no
4409     * logo specified.
4410     *
4411     * @throws NameNotFoundException Thrown if the resources for application
4412     * matching the given intent could not be loaded.
4413     *
4414     * @see #getActivityLogo(ComponentName)
4415     */
4416    public abstract Drawable getActivityLogo(Intent intent)
4417            throws NameNotFoundException;
4418
4419    /**
4420     * Retrieve the logo associated with an application.  If it has not specified
4421     * a logo, this method returns null.
4422     *
4423     * @param info Information about application being queried.
4424     *
4425     * @return Returns the image of the logo, or null if no logo is specified
4426     * by the application.
4427     *
4428     * @see #getApplicationLogo(String)
4429     */
4430    public abstract Drawable getApplicationLogo(ApplicationInfo info);
4431
4432    /**
4433     * Retrieve the logo associated with an application.  Given the name of the
4434     * application's package, retrieves the information about it and calls
4435     * getApplicationLogo() to return its logo. If the application cannot be
4436     * found, NameNotFoundException is thrown.
4437     *
4438     * @param packageName Name of the package whose application logo is to be
4439     *                    retrieved.
4440     *
4441     * @return Returns the image of the logo, or null if no application logo
4442     * has been specified.
4443     *
4444     * @throws NameNotFoundException Thrown if the resources for the given
4445     * application could not be loaded.
4446     *
4447     * @see #getApplicationLogo(ApplicationInfo)
4448     */
4449    public abstract Drawable getApplicationLogo(String packageName)
4450            throws NameNotFoundException;
4451
4452    /**
4453     * Returns a managed-user-style badged copy of the given drawable allowing the user to
4454     * distinguish it from the original drawable.
4455     * The caller can specify the location in the bounds of the drawable to be
4456     * badged where the badge should be applied as well as the density of the
4457     * badge to be used.
4458     * <p>
4459     * If the original drawable is a BitmapDrawable and the backing bitmap is
4460     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4461     * is performed in place and the original drawable is returned.
4462     * </p>
4463     *
4464     * @param drawable The drawable to badge.
4465     * @param badgeLocation Where in the bounds of the badged drawable to place
4466     *         the badge. If it's {@code null}, the badge is applied on top of the entire
4467     *         drawable being badged.
4468     * @param badgeDensity The optional desired density for the badge as per
4469     *         {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4470     *         the density of the display is used.
4471     * @return A drawable that combines the original drawable and a badge as
4472     *         determined by the system.
4473     * @hide
4474     */
4475    public abstract Drawable getManagedUserBadgedDrawable(Drawable drawable, Rect badgeLocation,
4476        int badgeDensity);
4477
4478    /**
4479     * If the target user is a managed profile, then this returns a badged copy of the given icon
4480     * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
4481     * {@link #getUserBadgedDrawableForDensity(
4482     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4483     * <p>
4484     * If the original drawable is a BitmapDrawable and the backing bitmap is
4485     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4486     * is performed in place and the original drawable is returned.
4487     * </p>
4488     *
4489     * @param icon The icon to badge.
4490     * @param user The target user.
4491     * @return A drawable that combines the original icon and a badge as
4492     *         determined by the system.
4493     */
4494    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4495
4496    /**
4497     * If the target user is a managed profile of the calling user or the caller
4498     * is itself a managed profile, then this returns a badged copy of the given
4499     * drawable allowing the user to distinguish it from the original drawable.
4500     * The caller can specify the location in the bounds of the drawable to be
4501     * badged where the badge should be applied as well as the density of the
4502     * badge to be used.
4503     * <p>
4504     * If the original drawable is a BitmapDrawable and the backing bitmap is
4505     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4506     * is performed in place and the original drawable is returned.
4507     * </p>
4508     *
4509     * @param drawable The drawable to badge.
4510     * @param user The target user.
4511     * @param badgeLocation Where in the bounds of the badged drawable to place
4512     *         the badge. If it's {@code null}, the badge is applied on top of the entire
4513     *         drawable being badged.
4514     * @param badgeDensity The optional desired density for the badge as per
4515     *         {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4516     *         the density of the display is used.
4517     * @return A drawable that combines the original drawable and a badge as
4518     *         determined by the system.
4519     */
4520    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4521            UserHandle user, Rect badgeLocation, int badgeDensity);
4522
4523    /**
4524     * If the target user is a managed profile of the calling user or the caller
4525     * is itself a managed profile, then this returns a drawable to use as a small
4526     * icon to include in a view to distinguish it from the original icon.
4527     *
4528     * @param user The target user.
4529     * @param density The optional desired density for the badge as per
4530     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4531     *         the density of the current display is used.
4532     * @return the drawable or null if no drawable is required.
4533     * @hide
4534     */
4535    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4536
4537    /**
4538     * If the target user is a managed profile of the calling user or the caller
4539     * is itself a managed profile, then this returns a drawable to use as a small
4540     * icon to include in a view to distinguish it from the original icon. This version
4541     * doesn't have background protection and should be used over a light background instead of
4542     * a badge.
4543     *
4544     * @param user The target user.
4545     * @param density The optional desired density for the badge as per
4546     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4547     *         the density of the current display is used.
4548     * @return the drawable or null if no drawable is required.
4549     * @hide
4550     */
4551    public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4552
4553    /**
4554     * If the target user is a managed profile of the calling user or the caller
4555     * is itself a managed profile, then this returns a copy of the label with
4556     * badging for accessibility services like talkback. E.g. passing in "Email"
4557     * and it might return "Work Email" for Email in the work profile.
4558     *
4559     * @param label The label to change.
4560     * @param user The target user.
4561     * @return A label that combines the original label and a badge as
4562     *         determined by the system.
4563     */
4564    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4565
4566    /**
4567     * Retrieve text from a package.  This is a low-level API used by
4568     * the various package manager info structures (such as
4569     * {@link ComponentInfo} to implement retrieval of their associated
4570     * labels and other text.
4571     *
4572     * @param packageName The name of the package that this text is coming from.
4573     * Cannot be null.
4574     * @param resid The resource identifier of the desired text.  Cannot be 0.
4575     * @param appInfo Overall information about <var>packageName</var>.  This
4576     * may be null, in which case the application information will be retrieved
4577     * for you if needed; if you already have this information around, it can
4578     * be much more efficient to supply it here.
4579     *
4580     * @return Returns a CharSequence holding the requested text.  Returns null
4581     * if the text could not be found for any reason.
4582     */
4583    public abstract CharSequence getText(String packageName, @StringRes int resid,
4584            ApplicationInfo appInfo);
4585
4586    /**
4587     * Retrieve an XML file from a package.  This is a low-level API used to
4588     * retrieve XML meta data.
4589     *
4590     * @param packageName The name of the package that this xml is coming from.
4591     * Cannot be null.
4592     * @param resid The resource identifier of the desired xml.  Cannot be 0.
4593     * @param appInfo Overall information about <var>packageName</var>.  This
4594     * may be null, in which case the application information will be retrieved
4595     * for you if needed; if you already have this information around, it can
4596     * be much more efficient to supply it here.
4597     *
4598     * @return Returns an XmlPullParser allowing you to parse out the XML
4599     * data.  Returns null if the xml resource could not be found for any
4600     * reason.
4601     */
4602    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
4603            ApplicationInfo appInfo);
4604
4605    /**
4606     * Return the label to use for this application.
4607     *
4608     * @return Returns the label associated with this application, or null if
4609     * it could not be found for any reason.
4610     * @param info The application to get the label of.
4611     */
4612    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4613
4614    /**
4615     * Retrieve the resources associated with an activity.  Given the full
4616     * name of an activity, retrieves the information about it and calls
4617     * getResources() to return its application's resources.  If the activity
4618     * cannot be found, NameNotFoundException is thrown.
4619     *
4620     * @param activityName Name of the activity whose resources are to be
4621     *                     retrieved.
4622     *
4623     * @return Returns the application's Resources.
4624     * @throws NameNotFoundException Thrown if the resources for the given
4625     * application could not be loaded.
4626     *
4627     * @see #getResourcesForApplication(ApplicationInfo)
4628     */
4629    public abstract Resources getResourcesForActivity(ComponentName activityName)
4630            throws NameNotFoundException;
4631
4632    /**
4633     * Retrieve the resources for an application.  Throws NameNotFoundException
4634     * if the package is no longer installed.
4635     *
4636     * @param app Information about the desired application.
4637     *
4638     * @return Returns the application's Resources.
4639     * @throws NameNotFoundException Thrown if the resources for the given
4640     * application could not be loaded (most likely because it was uninstalled).
4641     */
4642    public abstract Resources getResourcesForApplication(ApplicationInfo app)
4643            throws NameNotFoundException;
4644
4645    /**
4646     * Retrieve the resources associated with an application.  Given the full
4647     * package name of an application, retrieves the information about it and
4648     * calls getResources() to return its application's resources.  If the
4649     * appPackageName cannot be found, NameNotFoundException is thrown.
4650     *
4651     * @param appPackageName Package name of the application whose resources
4652     *                       are to be retrieved.
4653     *
4654     * @return Returns the application's Resources.
4655     * @throws NameNotFoundException Thrown if the resources for the given
4656     * application could not be loaded.
4657     *
4658     * @see #getResourcesForApplication(ApplicationInfo)
4659     */
4660    public abstract Resources getResourcesForApplication(String appPackageName)
4661            throws NameNotFoundException;
4662
4663    /** @hide */
4664    public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4665            @UserIdInt int userId) throws NameNotFoundException;
4666
4667    /**
4668     * Retrieve overall information about an application package defined
4669     * in a package archive file
4670     *
4671     * @param archiveFilePath The path to the archive file
4672     * @param flags Additional option flags. Use any combination of
4673     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
4674     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
4675     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
4676     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
4677     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
4678     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
4679     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
4680     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4681     *         {@link #MATCH_UNINSTALLED_PACKAGES}
4682     *         to modify the data returned.
4683     *
4684     * @return A PackageInfo object containing information about the
4685     *         package archive. If the package could not be parsed,
4686     *         returns null.
4687     *
4688     * @see #GET_ACTIVITIES
4689     * @see #GET_CONFIGURATIONS
4690     * @see #GET_GIDS
4691     * @see #GET_INSTRUMENTATION
4692     * @see #GET_INTENT_FILTERS
4693     * @see #GET_META_DATA
4694     * @see #GET_PERMISSIONS
4695     * @see #GET_PROVIDERS
4696     * @see #GET_RECEIVERS
4697     * @see #GET_SERVICES
4698     * @see #GET_SHARED_LIBRARY_FILES
4699     * @see #GET_SIGNATURES
4700     * @see #GET_URI_PERMISSION_PATTERNS
4701     * @see #MATCH_DISABLED_COMPONENTS
4702     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4703     * @see #MATCH_UNINSTALLED_PACKAGES
4704     *
4705     */
4706    public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
4707        final PackageParser parser = new PackageParser();
4708        final File apkFile = new File(archiveFilePath);
4709        try {
4710            if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
4711                // Caller expressed an explicit opinion about what encryption
4712                // aware/unaware components they want to see, so fall through and
4713                // give them what they want
4714            } else {
4715                // Caller expressed no opinion, so match everything
4716                flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
4717            }
4718
4719            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
4720            if ((flags & GET_SIGNATURES) != 0) {
4721                PackageParser.collectCertificates(pkg, 0);
4722            }
4723            PackageUserState state = new PackageUserState();
4724            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4725        } catch (PackageParserException e) {
4726            return null;
4727        }
4728    }
4729
4730    /**
4731     * @deprecated replaced by {@link PackageInstaller}
4732     * @hide
4733     */
4734    @Deprecated
4735    public abstract void installPackage(
4736            Uri packageURI,
4737            IPackageInstallObserver observer,
4738            @InstallFlags int flags,
4739            String installerPackageName);
4740    /**
4741     * @deprecated replaced by {@link PackageInstaller}
4742     * @hide
4743     */
4744    @Deprecated
4745    public abstract void installPackage(
4746            Uri packageURI,
4747            PackageInstallObserver observer,
4748            @InstallFlags int flags,
4749            String installerPackageName);
4750
4751    /**
4752     * If there is already an application with the given package name installed
4753     * on the system for other users, also install it for the calling user.
4754     * @hide
4755     */
4756    public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
4757
4758    /**
4759     * If there is already an application with the given package name installed
4760     * on the system for other users, also install it for the specified user.
4761     * @hide
4762     */
4763     @RequiresPermission(anyOf = {
4764            Manifest.permission.INSTALL_PACKAGES,
4765            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4766    public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
4767            throws NameNotFoundException;
4768
4769    /**
4770     * Allows a package listening to the
4771     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4772     * broadcast} to respond to the package manager. The response must include
4773     * the {@code verificationCode} which is one of
4774     * {@link PackageManager#VERIFICATION_ALLOW} or
4775     * {@link PackageManager#VERIFICATION_REJECT}.
4776     *
4777     * @param id pending package identifier as passed via the
4778     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4779     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
4780     *            or {@link PackageManager#VERIFICATION_REJECT}.
4781     * @throws SecurityException if the caller does not have the
4782     *            PACKAGE_VERIFICATION_AGENT permission.
4783     */
4784    public abstract void verifyPendingInstall(int id, int verificationCode);
4785
4786    /**
4787     * Allows a package listening to the
4788     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4789     * broadcast} to extend the default timeout for a response and declare what
4790     * action to perform after the timeout occurs. The response must include
4791     * the {@code verificationCodeAtTimeout} which is one of
4792     * {@link PackageManager#VERIFICATION_ALLOW} or
4793     * {@link PackageManager#VERIFICATION_REJECT}.
4794     *
4795     * This method may only be called once per package id. Additional calls
4796     * will have no effect.
4797     *
4798     * @param id pending package identifier as passed via the
4799     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4800     * @param verificationCodeAtTimeout either
4801     *            {@link PackageManager#VERIFICATION_ALLOW} or
4802     *            {@link PackageManager#VERIFICATION_REJECT}. If
4803     *            {@code verificationCodeAtTimeout} is neither
4804     *            {@link PackageManager#VERIFICATION_ALLOW} or
4805     *            {@link PackageManager#VERIFICATION_REJECT}, then
4806     *            {@code verificationCodeAtTimeout} will default to
4807     *            {@link PackageManager#VERIFICATION_REJECT}.
4808     * @param millisecondsToDelay the amount of time requested for the timeout.
4809     *            Must be positive and less than
4810     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4811     *            {@code millisecondsToDelay} is out of bounds,
4812     *            {@code millisecondsToDelay} will be set to the closest in
4813     *            bounds value; namely, 0 or
4814     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
4815     * @throws SecurityException if the caller does not have the
4816     *            PACKAGE_VERIFICATION_AGENT permission.
4817     */
4818    public abstract void extendVerificationTimeout(int id,
4819            int verificationCodeAtTimeout, long millisecondsToDelay);
4820
4821    /**
4822     * Allows a package listening to the
4823     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
4824     * broadcast to respond to the package manager. The response must include
4825     * the {@code verificationCode} which is one of
4826     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4827     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4828     *
4829     * @param verificationId pending package identifier as passed via the
4830     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4831     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4832     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4833     * @param failedDomains a list of failed domains if the verificationCode is
4834     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4835     * @throws SecurityException if the caller does not have the
4836     *            INTENT_FILTER_VERIFICATION_AGENT permission.
4837     *
4838     * @hide
4839     */
4840    @SystemApi
4841    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
4842            List<String> failedDomains);
4843
4844    /**
4845     * Get the status of a Domain Verification Result for an IntentFilter. This is
4846     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4847     * {@link android.content.IntentFilter#getAutoVerify()}
4848     *
4849     * This is used by the ResolverActivity to change the status depending on what the User select
4850     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4851     * for a domain.
4852     *
4853     * @param packageName The package name of the Activity associated with the IntentFilter.
4854     * @param userId The user id.
4855     *
4856     * @return The status to set to. This can be
4857     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4858     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4859     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4860     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4861     *
4862     * @hide
4863     */
4864    public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
4865
4866    /**
4867     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4868     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4869     * {@link android.content.IntentFilter#getAutoVerify()}
4870     *
4871     * This is used by the ResolverActivity to change the status depending on what the User select
4872     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4873     * for a domain.
4874     *
4875     * @param packageName The package name of the Activity associated with the IntentFilter.
4876     * @param status The status to set to. This can be
4877     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4878     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4879     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4880     * @param userId The user id.
4881     *
4882     * @return true if the status has been set. False otherwise.
4883     *
4884     * @hide
4885     */
4886    public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
4887            @UserIdInt int userId);
4888
4889    /**
4890     * Get the list of IntentFilterVerificationInfo for a specific package and User.
4891     *
4892     * @param packageName the package name. When this parameter is set to a non null value,
4893     *                    the results will be filtered by the package name provided.
4894     *                    Otherwise, there will be no filtering and it will return a list
4895     *                    corresponding for all packages
4896     *
4897     * @return a list of IntentFilterVerificationInfo for a specific package.
4898     *
4899     * @hide
4900     */
4901    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4902            String packageName);
4903
4904    /**
4905     * Get the list of IntentFilter for a specific package.
4906     *
4907     * @param packageName the package name. This parameter is set to a non null value,
4908     *                    the list will contain all the IntentFilter for that package.
4909     *                    Otherwise, the list will be empty.
4910     *
4911     * @return a list of IntentFilter for a specific package.
4912     *
4913     * @hide
4914     */
4915    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4916
4917    /**
4918     * Get the default Browser package name for a specific user.
4919     *
4920     * @param userId The user id.
4921     *
4922     * @return the package name of the default Browser for the specified user. If the user id passed
4923     *         is -1 (all users) it will return a null value.
4924     *
4925     * @hide
4926     */
4927    @TestApi
4928    public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
4929
4930    /**
4931     * Set the default Browser package name for a specific user.
4932     *
4933     * @param packageName The package name of the default Browser.
4934     * @param userId The user id.
4935     *
4936     * @return true if the default Browser for the specified user has been set,
4937     *         otherwise return false. If the user id passed is -1 (all users) this call will not
4938     *         do anything and just return false.
4939     *
4940     * @hide
4941     */
4942    public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
4943            @UserIdInt int userId);
4944
4945    /**
4946     * Change the installer associated with a given package.  There are limitations
4947     * on how the installer package can be changed; in particular:
4948     * <ul>
4949     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
4950     * is not signed with the same certificate as the calling application.
4951     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
4952     * has an installer package, and that installer package is not signed with
4953     * the same certificate as the calling application.
4954     * </ul>
4955     *
4956     * @param targetPackage The installed package whose installer will be changed.
4957     * @param installerPackageName The package name of the new installer.  May be
4958     * null to clear the association.
4959     */
4960    public abstract void setInstallerPackageName(String targetPackage,
4961            String installerPackageName);
4962
4963    /**
4964     * Attempts to delete a package. Since this may take a little while, the
4965     * result will be posted back to the given observer. A deletion will fail if
4966     * the calling context lacks the
4967     * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
4968     * named package cannot be found, or if the named package is a system
4969     * package.
4970     *
4971     * @param packageName The name of the package to delete
4972     * @param observer An observer callback to get notified when the package
4973     *            deletion is complete.
4974     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
4975     *            will be called when that happens. observer may be null to
4976     *            indicate that no callback is desired.
4977     * @hide
4978     */
4979    public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
4980            @DeleteFlags int flags);
4981
4982    /**
4983     * Attempts to delete a package. Since this may take a little while, the
4984     * result will be posted back to the given observer. A deletion will fail if
4985     * the named package cannot be found, or if the named package is a system
4986     * package.
4987     *
4988     * @param packageName The name of the package to delete
4989     * @param observer An observer callback to get notified when the package
4990     *            deletion is complete.
4991     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
4992     *            will be called when that happens. observer may be null to
4993     *            indicate that no callback is desired.
4994     * @param userId The user Id
4995     * @hide
4996     */
4997     @RequiresPermission(anyOf = {
4998            Manifest.permission.DELETE_PACKAGES,
4999            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
5000    public abstract void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
5001            @DeleteFlags int flags, @UserIdInt int userId);
5002
5003    /**
5004     * Retrieve the package name of the application that installed a package. This identifies
5005     * which market the package came from.
5006     *
5007     * @param packageName The name of the package to query
5008     */
5009    public abstract String getInstallerPackageName(String packageName);
5010
5011    /**
5012     * Attempts to clear the user data directory of an application.
5013     * Since this may take a little while, the result will
5014     * be posted back to the given observer.  A deletion will fail if the
5015     * named package cannot be found, or if the named package is a "system package".
5016     *
5017     * @param packageName The name of the package
5018     * @param observer An observer callback to get notified when the operation is finished
5019     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5020     * will be called when that happens.  observer may be null to indicate that
5021     * no callback is desired.
5022     *
5023     * @hide
5024     */
5025    public abstract void clearApplicationUserData(String packageName,
5026            IPackageDataObserver observer);
5027    /**
5028     * Attempts to delete the cache files associated with an application.
5029     * Since this may take a little while, the result will
5030     * be posted back to the given observer.  A deletion will fail if the calling context
5031     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
5032     * named package cannot be found, or if the named package is a "system package".
5033     *
5034     * @param packageName The name of the package to delete
5035     * @param observer An observer callback to get notified when the cache file deletion
5036     * is complete.
5037     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5038     * will be called when that happens.  observer may be null to indicate that
5039     * no callback is desired.
5040     *
5041     * @hide
5042     */
5043    public abstract void deleteApplicationCacheFiles(String packageName,
5044            IPackageDataObserver observer);
5045
5046    /**
5047     * Attempts to delete the cache files associated with an application for a given user. Since
5048     * this may take a little while, the result will be posted back to the given observer. A
5049     * deletion will fail if the calling context lacks the
5050     * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
5051     * cannot be found, or if the named package is a "system package". If {@code userId} does not
5052     * belong to the calling user, the caller must have
5053     * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
5054     *
5055     * @param packageName The name of the package to delete
5056     * @param userId the user for which the cache files needs to be deleted
5057     * @param observer An observer callback to get notified when the cache file deletion is
5058     *            complete.
5059     *            {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5060     *            will be called when that happens. observer may be null to indicate that no
5061     *            callback is desired.
5062     * @hide
5063     */
5064    public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId,
5065            IPackageDataObserver observer);
5066
5067    /**
5068     * Free storage by deleting LRU sorted list of cache files across
5069     * all applications. If the currently available free storage
5070     * on the device is greater than or equal to the requested
5071     * free storage, no cache files are cleared. If the currently
5072     * available storage on the device is less than the requested
5073     * free storage, some or all of the cache files across
5074     * all applications are deleted (based on last accessed time)
5075     * to increase the free storage space on the device to
5076     * the requested value. There is no guarantee that clearing all
5077     * the cache files from all applications will clear up
5078     * enough storage to achieve the desired value.
5079     * @param freeStorageSize The number of bytes of storage to be
5080     * freed by the system. Say if freeStorageSize is XX,
5081     * and the current free storage is YY,
5082     * if XX is less than YY, just return. if not free XX-YY number
5083     * of bytes if possible.
5084     * @param observer call back used to notify when
5085     * the operation is completed
5086     *
5087     * @hide
5088     */
5089    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
5090        freeStorageAndNotify(null, freeStorageSize, observer);
5091    }
5092
5093    /** {@hide} */
5094    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
5095            IPackageDataObserver observer);
5096
5097    /**
5098     * Free storage by deleting LRU sorted list of cache files across
5099     * all applications. If the currently available free storage
5100     * on the device is greater than or equal to the requested
5101     * free storage, no cache files are cleared. If the currently
5102     * available storage on the device is less than the requested
5103     * free storage, some or all of the cache files across
5104     * all applications are deleted (based on last accessed time)
5105     * to increase the free storage space on the device to
5106     * the requested value. There is no guarantee that clearing all
5107     * the cache files from all applications will clear up
5108     * enough storage to achieve the desired value.
5109     * @param freeStorageSize The number of bytes of storage to be
5110     * freed by the system. Say if freeStorageSize is XX,
5111     * and the current free storage is YY,
5112     * if XX is less than YY, just return. if not free XX-YY number
5113     * of bytes if possible.
5114     * @param pi IntentSender call back used to
5115     * notify when the operation is completed.May be null
5116     * to indicate that no call back is desired.
5117     *
5118     * @hide
5119     */
5120    public void freeStorage(long freeStorageSize, IntentSender pi) {
5121        freeStorage(null, freeStorageSize, pi);
5122    }
5123
5124    /** {@hide} */
5125    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
5126
5127    /**
5128     * Retrieve the size information for a package.
5129     * Since this may take a little while, the result will
5130     * be posted back to the given observer.  The calling context
5131     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
5132     *
5133     * @param packageName The name of the package whose size information is to be retrieved
5134     * @param userId The user whose size information should be retrieved.
5135     * @param observer An observer callback to get notified when the operation
5136     * is complete.
5137     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
5138     * The observer's callback is invoked with a PackageStats object(containing the
5139     * code, data and cache sizes of the package) and a boolean value representing
5140     * the status of the operation. observer may be null to indicate that
5141     * no callback is desired.
5142     *
5143     * @hide
5144     */
5145    public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
5146            IPackageStatsObserver observer);
5147
5148    /**
5149     * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
5150     * returns the size for the calling user.
5151     *
5152     * @hide
5153     */
5154    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
5155        getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer);
5156    }
5157
5158    /**
5159     * @deprecated This function no longer does anything; it was an old
5160     * approach to managing preferred activities, which has been superseded
5161     * by (and conflicts with) the modern activity-based preferences.
5162     */
5163    @Deprecated
5164    public abstract void addPackageToPreferred(String packageName);
5165
5166    /**
5167     * @deprecated This function no longer does anything; it was an old
5168     * approach to managing preferred activities, which has been superseded
5169     * by (and conflicts with) the modern activity-based preferences.
5170     */
5171    @Deprecated
5172    public abstract void removePackageFromPreferred(String packageName);
5173
5174    /**
5175     * Retrieve the list of all currently configured preferred packages.  The
5176     * first package on the list is the most preferred, the last is the
5177     * least preferred.
5178     *
5179     * @param flags Additional option flags. Use any combination of
5180     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
5181     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
5182     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
5183     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
5184     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
5185     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
5186     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
5187     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
5188     *         {@link #MATCH_UNINSTALLED_PACKAGES}
5189     *         to modify the data returned.
5190     *
5191     * @return A List of PackageInfo objects, one for each preferred application,
5192     *         in order of preference.
5193     *
5194     * @see #GET_ACTIVITIES
5195     * @see #GET_CONFIGURATIONS
5196     * @see #GET_GIDS
5197     * @see #GET_INSTRUMENTATION
5198     * @see #GET_INTENT_FILTERS
5199     * @see #GET_META_DATA
5200     * @see #GET_PERMISSIONS
5201     * @see #GET_PROVIDERS
5202     * @see #GET_RECEIVERS
5203     * @see #GET_SERVICES
5204     * @see #GET_SHARED_LIBRARY_FILES
5205     * @see #GET_SIGNATURES
5206     * @see #GET_URI_PERMISSION_PATTERNS
5207     * @see #MATCH_DISABLED_COMPONENTS
5208     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
5209     * @see #MATCH_UNINSTALLED_PACKAGES
5210     */
5211    public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
5212
5213    /**
5214     * @deprecated This is a protected API that should not have been available
5215     * to third party applications.  It is the platform's responsibility for
5216     * assigning preferred activities and this cannot be directly modified.
5217     *
5218     * Add a new preferred activity mapping to the system.  This will be used
5219     * to automatically select the given activity component when
5220     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5221     * multiple matching activities and also matches the given filter.
5222     *
5223     * @param filter The set of intents under which this activity will be
5224     * made preferred.
5225     * @param match The IntentFilter match category that this preference
5226     * applies to.
5227     * @param set The set of activities that the user was picking from when
5228     * this preference was made.
5229     * @param activity The component name of the activity that is to be
5230     * preferred.
5231     */
5232    @Deprecated
5233    public abstract void addPreferredActivity(IntentFilter filter, int match,
5234            ComponentName[] set, ComponentName activity);
5235
5236    /**
5237     * Same as {@link #addPreferredActivity(IntentFilter, int,
5238            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5239            to.
5240     * @hide
5241     */
5242    public void addPreferredActivityAsUser(IntentFilter filter, int match,
5243            ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5244        throw new RuntimeException("Not implemented. Must override in a subclass.");
5245    }
5246
5247    /**
5248     * @deprecated This is a protected API that should not have been available
5249     * to third party applications.  It is the platform's responsibility for
5250     * assigning preferred activities and this cannot be directly modified.
5251     *
5252     * Replaces an existing preferred activity mapping to the system, and if that were not present
5253     * adds a new preferred activity.  This will be used
5254     * to automatically select the given activity component when
5255     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5256     * multiple matching activities and also matches the given filter.
5257     *
5258     * @param filter The set of intents under which this activity will be
5259     * made preferred.
5260     * @param match The IntentFilter match category that this preference
5261     * applies to.
5262     * @param set The set of activities that the user was picking from when
5263     * this preference was made.
5264     * @param activity The component name of the activity that is to be
5265     * preferred.
5266     * @hide
5267     */
5268    @Deprecated
5269    public abstract void replacePreferredActivity(IntentFilter filter, int match,
5270            ComponentName[] set, ComponentName activity);
5271
5272    /**
5273     * @hide
5274     */
5275    @Deprecated
5276    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
5277           ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5278        throw new RuntimeException("Not implemented. Must override in a subclass.");
5279    }
5280
5281    /**
5282     * Remove all preferred activity mappings, previously added with
5283     * {@link #addPreferredActivity}, from the
5284     * system whose activities are implemented in the given package name.
5285     * An application can only clear its own package(s).
5286     *
5287     * @param packageName The name of the package whose preferred activity
5288     * mappings are to be removed.
5289     */
5290    public abstract void clearPackagePreferredActivities(String packageName);
5291
5292    /**
5293     * Retrieve all preferred activities, previously added with
5294     * {@link #addPreferredActivity}, that are
5295     * currently registered with the system.
5296     *
5297     * @param outFilters A required list in which to place the filters of all of the
5298     * preferred activities.
5299     * @param outActivities A required list in which to place the component names of
5300     * all of the preferred activities.
5301     * @param packageName An optional package in which you would like to limit
5302     * the list.  If null, all activities will be returned; if non-null, only
5303     * those activities in the given package are returned.
5304     *
5305     * @return Returns the total number of registered preferred activities
5306     * (the number of distinct IntentFilter records, not the number of unique
5307     * activity components) that were found.
5308     */
5309    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5310            @NonNull List<ComponentName> outActivities, String packageName);
5311
5312    /**
5313     * Ask for the set of available 'home' activities and the current explicit
5314     * default, if any.
5315     * @hide
5316     */
5317    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5318
5319    /**
5320     * Set the enabled setting for a package component (activity, receiver, service, provider).
5321     * This setting will override any enabled state which may have been set by the component in its
5322     * manifest.
5323     *
5324     * @param componentName The component to enable
5325     * @param newState The new enabled state for the component.  The legal values for this state
5326     *                 are:
5327     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
5328     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
5329     *                   and
5330     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5331     *                 The last one removes the setting, thereby restoring the component's state to
5332     *                 whatever was set in it's manifest (or enabled, by default).
5333     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5334     */
5335    public abstract void setComponentEnabledSetting(ComponentName componentName,
5336            int newState, int flags);
5337
5338    /**
5339     * Return the enabled setting for a package component (activity,
5340     * receiver, service, provider).  This returns the last value set by
5341     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5342     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5343     * the value originally specified in the manifest has not been modified.
5344     *
5345     * @param componentName The component to retrieve.
5346     * @return Returns the current enabled state for the component.  May
5347     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5348     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5349     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
5350     * component's enabled state is based on the original information in
5351     * the manifest as found in {@link ComponentInfo}.
5352     */
5353    public abstract int getComponentEnabledSetting(ComponentName componentName);
5354
5355    /**
5356     * Set the enabled setting for an application
5357     * This setting will override any enabled state which may have been set by the application in
5358     * its manifest.  It also overrides the enabled state set in the manifest for any of the
5359     * application's components.  It does not override any enabled state set by
5360     * {@link #setComponentEnabledSetting} for any of the application's components.
5361     *
5362     * @param packageName The package name of the application to enable
5363     * @param newState The new enabled state for the component.  The legal values for this state
5364     *                 are:
5365     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
5366     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
5367     *                   and
5368     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5369     *                 The last one removes the setting, thereby restoring the applications's state to
5370     *                 whatever was set in its manifest (or enabled, by default).
5371     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5372     */
5373    public abstract void setApplicationEnabledSetting(String packageName,
5374            int newState, int flags);
5375
5376    /**
5377     * Return the enabled setting for an application. This returns
5378     * the last value set by
5379     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5380     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5381     * the value originally specified in the manifest has not been modified.
5382     *
5383     * @param packageName The package name of the application to retrieve.
5384     * @return Returns the current enabled state for the application.  May
5385     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5386     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5387     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
5388     * application's enabled state is based on the original information in
5389     * the manifest as found in {@link ComponentInfo}.
5390     * @throws IllegalArgumentException if the named package does not exist.
5391     */
5392    public abstract int getApplicationEnabledSetting(String packageName);
5393
5394    /**
5395     * Flush the package restrictions for a given user to disk. This forces the package restrictions
5396     * like component and package enabled settings to be written to disk and avoids the delay that
5397     * is otherwise present when changing those settings.
5398     *
5399     * @param userId Ther userId of the user whose restrictions are to be flushed.
5400     * @hide
5401     */
5402    public abstract void flushPackageRestrictionsAsUser(int userId);
5403
5404    /**
5405     * Puts the package in a hidden state, which is almost like an uninstalled state,
5406     * making the package unavailable, but it doesn't remove the data or the actual
5407     * package file. Application can be unhidden by either resetting the hidden state
5408     * or by installing it, such as with {@link #installExistingPackage(String)}
5409     * @hide
5410     */
5411    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
5412            UserHandle userHandle);
5413
5414    /**
5415     * Returns the hidden state of a package.
5416     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
5417     * @hide
5418     */
5419    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
5420            UserHandle userHandle);
5421
5422    /**
5423     * Return whether the device has been booted into safe mode.
5424     */
5425    public abstract boolean isSafeMode();
5426
5427    /**
5428     * Adds a listener for permission changes for installed packages.
5429     *
5430     * @param listener The listener to add.
5431     *
5432     * @hide
5433     */
5434    @SystemApi
5435    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5436    public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5437
5438    /**
5439     * Remvoes a listener for permission changes for installed packages.
5440     *
5441     * @param listener The listener to remove.
5442     *
5443     * @hide
5444     */
5445    @SystemApi
5446    public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5447
5448    /**
5449     * Return the {@link KeySet} associated with the String alias for this
5450     * application.
5451     *
5452     * @param alias The alias for a given {@link KeySet} as defined in the
5453     *        application's AndroidManifest.xml.
5454     * @hide
5455     */
5456    public abstract KeySet getKeySetByAlias(String packageName, String alias);
5457
5458    /** Return the signing {@link KeySet} for this application.
5459     * @hide
5460     */
5461    public abstract KeySet getSigningKeySet(String packageName);
5462
5463    /**
5464     * Return whether the package denoted by packageName has been signed by all
5465     * of the keys specified by the {@link KeySet} ks.  This will return true if
5466     * the package has been signed by additional keys (a superset) as well.
5467     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
5468     * @hide
5469     */
5470    public abstract boolean isSignedBy(String packageName, KeySet ks);
5471
5472    /**
5473     * Return whether the package denoted by packageName has been signed by all
5474     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5475     * {@link #isSignedBy(String packageName, KeySet ks)}.
5476     * @hide
5477     */
5478    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5479
5480    /**
5481     * Puts the package in a suspended state, where attempts at starting activities are denied.
5482     *
5483     * <p>It doesn't remove the data or the actual package file. The application notifications
5484     * will be hidden, the application will not show up in recents, will not be able to show
5485     * toasts or dialogs or ring the device.
5486     *
5487     * <p>The package must already be installed. If the package is uninstalled while suspended
5488     * the package will no longer be suspended.
5489     *
5490     * @param packageNames The names of the packages to set the suspended status.
5491     * @param suspended If set to {@code true} than the packages will be suspended, if set to
5492     * {@code false} the packages will be unsuspended.
5493     * @param userId The user id.
5494     *
5495     * @return an array of package names for which the suspended status is not set as requested in
5496     * this method.
5497     *
5498     * @hide
5499     */
5500    public abstract String[] setPackagesSuspendedAsUser(
5501            String[] packageNames, boolean suspended, @UserIdInt int userId);
5502
5503    /**
5504     * @see #setPackageSuspendedAsUser(String, boolean, int)
5505     * @param packageName The name of the package to get the suspended status of.
5506     * @param userId The user id.
5507     * @return {@code true} if the package is suspended or {@code false} if the package is not
5508     * suspended or could not be found.
5509     * @hide
5510     */
5511    public abstract boolean isPackageSuspendedForUser(String packageName, int userId);
5512
5513    /** {@hide} */
5514    public static boolean isMoveStatusFinished(int status) {
5515        return (status < 0 || status > 100);
5516    }
5517
5518    /** {@hide} */
5519    public static abstract class MoveCallback {
5520        public void onCreated(int moveId, Bundle extras) {}
5521        public abstract void onStatusChanged(int moveId, int status, long estMillis);
5522    }
5523
5524    /** {@hide} */
5525    public abstract int getMoveStatus(int moveId);
5526
5527    /** {@hide} */
5528    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5529    /** {@hide} */
5530    public abstract void unregisterMoveCallback(MoveCallback callback);
5531
5532    /** {@hide} */
5533    public abstract int movePackage(String packageName, VolumeInfo vol);
5534    /** {@hide} */
5535    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5536    /** {@hide} */
5537    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5538
5539    /** {@hide} */
5540    public abstract int movePrimaryStorage(VolumeInfo vol);
5541    /** {@hide} */
5542    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5543    /** {@hide} */
5544    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
5545
5546    /**
5547     * Returns the device identity that verifiers can use to associate their scheme to a particular
5548     * device. This should not be used by anything other than a package verifier.
5549     *
5550     * @return identity that uniquely identifies current device
5551     * @hide
5552     */
5553    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
5554
5555    /**
5556     * Returns true if the device is upgrading, such as first boot after OTA.
5557     *
5558     * @hide
5559     */
5560    public abstract boolean isUpgrade();
5561
5562    /**
5563     * Return interface that offers the ability to install, upgrade, and remove
5564     * applications on the device.
5565     */
5566    public abstract @NonNull PackageInstaller getPackageInstaller();
5567
5568    /**
5569     * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5570     * intents sent from the user with id sourceUserId can also be be resolved
5571     * by activities in the user with id targetUserId if they match the
5572     * specified intent filter.
5573     *
5574     * @param filter The {@link IntentFilter} the intent has to match
5575     * @param sourceUserId The source user id.
5576     * @param targetUserId The target user id.
5577     * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5578     *            {@link #ONLY_IF_NO_MATCH_FOUND}.
5579     * @hide
5580     */
5581    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5582            int targetUserId, int flags);
5583
5584    /**
5585     * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5586     * as their source, and have been set by the app calling this method.
5587     *
5588     * @param sourceUserId The source user id.
5589     * @hide
5590     */
5591    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
5592
5593    /**
5594     * @hide
5595     */
5596    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5597
5598    /**
5599     * @hide
5600     */
5601    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5602
5603    /** {@hide} */
5604    public abstract boolean isPackageAvailable(String packageName);
5605
5606    /** {@hide} */
5607    public static String installStatusToString(int status, String msg) {
5608        final String str = installStatusToString(status);
5609        if (msg != null) {
5610            return str + ": " + msg;
5611        } else {
5612            return str;
5613        }
5614    }
5615
5616    /** {@hide} */
5617    public static String installStatusToString(int status) {
5618        switch (status) {
5619            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5620            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5621            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5622            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5623            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5624            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5625            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5626            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5627            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5628            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5629            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5630            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5631            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5632            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5633            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5634            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5635            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5636            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5637            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5638            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5639            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5640            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5641            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5642            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5643            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5644            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5645            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5646            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5647            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5648            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5649            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5650            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5651            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5652            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5653            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5654            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5655            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5656            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5657            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5658            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
5659            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
5660            default: return Integer.toString(status);
5661        }
5662    }
5663
5664    /** {@hide} */
5665    public static int installStatusToPublicStatus(int status) {
5666        switch (status) {
5667            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5668            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5669            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5670            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5671            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5672            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5673            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5674            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5675            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5676            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5677            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5678            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5679            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5680            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5681            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5682            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5683            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5684            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5685            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5686            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5687            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5688            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5689            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5690            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5691            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5692            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5693            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5694            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5695            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5696            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5697            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5698            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5699            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5700            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5701            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5702            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5703            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
5704            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5705            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5706            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5707            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5708            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5709            default: return PackageInstaller.STATUS_FAILURE;
5710        }
5711    }
5712
5713    /** {@hide} */
5714    public static String deleteStatusToString(int status, String msg) {
5715        final String str = deleteStatusToString(status);
5716        if (msg != null) {
5717            return str + ": " + msg;
5718        } else {
5719            return str;
5720        }
5721    }
5722
5723    /** {@hide} */
5724    public static String deleteStatusToString(int status) {
5725        switch (status) {
5726            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5727            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5728            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5729            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5730            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
5731            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
5732            default: return Integer.toString(status);
5733        }
5734    }
5735
5736    /** {@hide} */
5737    public static int deleteStatusToPublicStatus(int status) {
5738        switch (status) {
5739            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5740            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5741            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5742            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5743            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5744            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5745            default: return PackageInstaller.STATUS_FAILURE;
5746        }
5747    }
5748
5749    /** {@hide} */
5750    public static String permissionFlagToString(int flag) {
5751        switch (flag) {
5752            case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
5753            case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
5754            case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
5755            case FLAG_PERMISSION_USER_SET: return "USER_SET";
5756            case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
5757            case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
5758            case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
5759            default: return Integer.toString(flag);
5760        }
5761    }
5762
5763    /** {@hide} */
5764    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
5765        private final IPackageInstallObserver mLegacy;
5766
5767        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
5768            mLegacy = legacy;
5769        }
5770
5771        @Override
5772        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
5773                Bundle extras) {
5774            if (mLegacy == null) return;
5775            try {
5776                mLegacy.packageInstalled(basePackageName, returnCode);
5777            } catch (RemoteException ignored) {
5778            }
5779        }
5780    }
5781
5782    /** {@hide} */
5783    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
5784        private final IPackageDeleteObserver mLegacy;
5785
5786        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
5787            mLegacy = legacy;
5788        }
5789
5790        @Override
5791        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
5792            if (mLegacy == null) return;
5793            try {
5794                mLegacy.packageDeleted(basePackageName, returnCode);
5795            } catch (RemoteException ignored) {
5796            }
5797        }
5798    }
5799}
5800