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