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