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