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