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