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