PackageManager.java revision 31d80ea1815d41b3b8fe2698732dfc310a0fc633
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    /**
2021     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2022     * The device has a full implementation of the android.webkit.* APIs. Devices
2023     * lacking this feature will not have a functioning WebView implementation.
2024     */
2025    @SdkConstant(SdkConstantType.FEATURE)
2026    public static final String FEATURE_WEBVIEW = "android.software.webview";
2027
2028    /**
2029     * Feature for {@link #getSystemAvailableFeatures} and
2030     * {@link #hasSystemFeature}: This device supports ethernet.
2031     */
2032    @SdkConstant(SdkConstantType.FEATURE)
2033    public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
2034
2035    /**
2036     * Feature for {@link #getSystemAvailableFeatures} and
2037     * {@link #hasSystemFeature}: This device supports HDMI-CEC.
2038     * @hide
2039     */
2040    @SdkConstant(SdkConstantType.FEATURE)
2041    public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
2042
2043    /**
2044     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2045     * The device has all of the inputs necessary to be considered a compatible game controller, or
2046     * includes a compatible game controller in the box.
2047     */
2048    @SdkConstant(SdkConstantType.FEATURE)
2049    public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
2050
2051    /**
2052     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2053     * The device has a full implementation of the android.media.midi.* APIs.
2054     */
2055    @SdkConstant(SdkConstantType.FEATURE)
2056    public static final String FEATURE_MIDI = "android.software.midi";
2057
2058    /**
2059     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2060     * The device implements a an optimized mode for virtual reality (VR) applications that handles
2061     * stereoscopic rendering of notifications, and may potentially also include optimizations to
2062     * reduce latency in the graphics, display, and sensor stacks.
2063     */
2064    @SdkConstant(SdkConstantType.FEATURE)
2065    public static final String FEATURE_VR_MODE = "android.software.vr.mode";
2066
2067    /**
2068     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2069     * The device implements {@link #FEATURE_VR_MODE} but additionally meets all CTS requirements
2070     * to be certified as a "VR Ready" device, which guarantees that the device is capable of
2071     * delivering consistent performance at a high framerate over an extended period of time for
2072     * typical VR application CPU/GPU workloads with a minimal number of frame drops, implements
2073     * {@link #FEATURE_HIFI_SENSORS} with a low sensor latency, implements an optimized render path
2074     * to minimize latency to draw to the device's main display, and includes optimizations to
2075     * lower display persistence to an acceptable level.
2076     */
2077    @SdkConstant(SdkConstantType.FEATURE)
2078    public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
2079            = "android.hardware.vr.high_performance";
2080
2081    /**
2082     * Action to external storage service to clean out removed apps.
2083     * @hide
2084     */
2085    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
2086            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
2087
2088    /**
2089     * Extra field name for the URI to a verification file. Passed to a package
2090     * verifier.
2091     *
2092     * @hide
2093     */
2094    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
2095
2096    /**
2097     * Extra field name for the ID of a package pending verification. Passed to
2098     * a package verifier and is used to call back to
2099     * {@link PackageManager#verifyPendingInstall(int, int)}
2100     */
2101    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
2102
2103    /**
2104     * Extra field name for the package identifier which is trying to install
2105     * the package.
2106     *
2107     * @hide
2108     */
2109    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
2110            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
2111
2112    /**
2113     * Extra field name for the requested install flags for a package pending
2114     * verification. Passed to a package verifier.
2115     *
2116     * @hide
2117     */
2118    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
2119            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
2120
2121    /**
2122     * Extra field name for the uid of who is requesting to install
2123     * the package.
2124     *
2125     * @hide
2126     */
2127    public static final String EXTRA_VERIFICATION_INSTALLER_UID
2128            = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
2129
2130    /**
2131     * Extra field name for the package name of a package pending verification.
2132     *
2133     * @hide
2134     */
2135    public static final String EXTRA_VERIFICATION_PACKAGE_NAME
2136            = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
2137    /**
2138     * Extra field name for the result of a verification, either
2139     * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
2140     * Passed to package verifiers after a package is verified.
2141     */
2142    public static final String EXTRA_VERIFICATION_RESULT
2143            = "android.content.pm.extra.VERIFICATION_RESULT";
2144
2145    /**
2146     * Extra field name for the version code of a package pending verification.
2147     *
2148     * @hide
2149     */
2150    public static final String EXTRA_VERIFICATION_VERSION_CODE
2151            = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
2152
2153    /**
2154     * Extra field name for the ID of a intent filter pending verification.
2155     * Passed to an intent filter verifier and is used to call back to
2156     * {@link #verifyIntentFilter}
2157     *
2158     * @hide
2159     */
2160    public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
2161            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
2162
2163    /**
2164     * Extra field name for the scheme used for an intent filter pending verification. Passed to
2165     * an intent filter verifier and is used to construct the URI to verify against.
2166     *
2167     * Usually this is "https"
2168     *
2169     * @hide
2170     */
2171    public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
2172            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
2173
2174    /**
2175     * Extra field name for the host names to be used for an intent filter pending verification.
2176     * Passed to an intent filter verifier and is used to construct the URI to verify the
2177     * intent filter.
2178     *
2179     * This is a space delimited list of hosts.
2180     *
2181     * @hide
2182     */
2183    public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
2184            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
2185
2186    /**
2187     * Extra field name for the package name to be used for an intent filter pending verification.
2188     * Passed to an intent filter verifier and is used to check the verification responses coming
2189     * from the hosts. Each host response will need to include the package name of APK containing
2190     * the intent filter.
2191     *
2192     * @hide
2193     */
2194    public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
2195            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
2196
2197    /**
2198     * The action used to request that the user approve a permission request
2199     * from the application.
2200     *
2201     * @hide
2202     */
2203    @SystemApi
2204    public static final String ACTION_REQUEST_PERMISSIONS =
2205            "android.content.pm.action.REQUEST_PERMISSIONS";
2206
2207    /**
2208     * The names of the requested permissions.
2209     * <p>
2210     * <strong>Type:</strong> String[]
2211     * </p>
2212     *
2213     * @hide
2214     */
2215    @SystemApi
2216    public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
2217            "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
2218
2219    /**
2220     * The results from the permissions request.
2221     * <p>
2222     * <strong>Type:</strong> int[] of #PermissionResult
2223     * </p>
2224     *
2225     * @hide
2226     */
2227    @SystemApi
2228    public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
2229            = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
2230
2231    /**
2232     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2233     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
2234     * the existing definition for the permission.
2235     * @hide
2236     */
2237    public static final String EXTRA_FAILURE_EXISTING_PACKAGE
2238            = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
2239
2240    /**
2241     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2242     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
2243     * being redundantly defined by the package being installed.
2244     * @hide
2245     */
2246    public static final String EXTRA_FAILURE_EXISTING_PERMISSION
2247            = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
2248
2249   /**
2250    * Permission flag: The permission is set in its current state
2251    * by the user and apps can still request it at runtime.
2252    *
2253    * @hide
2254    */
2255    public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
2256
2257    /**
2258     * Permission flag: The permission is set in its current state
2259     * by the user and it is fixed, i.e. apps can no longer request
2260     * this permission.
2261     *
2262     * @hide
2263     */
2264    public static final int FLAG_PERMISSION_USER_FIXED =  1 << 1;
2265
2266    /**
2267     * Permission flag: The permission is set in its current state
2268     * by device policy and neither apps nor the user can change
2269     * its state.
2270     *
2271     * @hide
2272     */
2273    public static final int FLAG_PERMISSION_POLICY_FIXED =  1 << 2;
2274
2275    /**
2276     * Permission flag: The permission is set in a granted state but
2277     * access to resources it guards is restricted by other means to
2278     * enable revoking a permission on legacy apps that do not support
2279     * runtime permissions. If this permission is upgraded to runtime
2280     * because the app was updated to support runtime permissions, the
2281     * the permission will be revoked in the upgrade process.
2282     *
2283     * @hide
2284     */
2285    public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE =  1 << 3;
2286
2287    /**
2288     * Permission flag: The permission is set in its current state
2289     * because the app is a component that is a part of the system.
2290     *
2291     * @hide
2292     */
2293    public static final int FLAG_PERMISSION_SYSTEM_FIXED =  1 << 4;
2294
2295    /**
2296     * Permission flag: The permission is granted by default because it
2297     * enables app functionality that is expected to work out-of-the-box
2298     * for providing a smooth user experience. For example, the phone app
2299     * is expected to have the phone permission.
2300     *
2301     * @hide
2302     */
2303    public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
2304
2305    /**
2306     * Permission flag: The permission has to be reviewed before any of
2307     * the app components can run.
2308     *
2309     * @hide
2310     */
2311    public static final int FLAG_PERMISSION_REVIEW_REQUIRED =  1 << 6;
2312
2313    /**
2314     * Mask for all permission flags.
2315     *
2316     * @hide
2317     */
2318    @SystemApi
2319    public static final int MASK_PERMISSION_FLAGS = 0xFF;
2320
2321    /**
2322     * Retrieve overall information about an application package that is
2323     * installed on the system.
2324     *
2325     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2326     *         desired package.
2327     * @param flags Additional option flags. Use any combination of
2328     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2329     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2330     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2331     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2332     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2333     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2334     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2335     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2336     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2337     *         to modify the data returned.
2338     *
2339     * @return A PackageInfo object containing information about the
2340     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2341     *         package is not found in the list of installed applications, the
2342     *         package information is retrieved from the list of uninstalled
2343     *         applications (which includes installed applications as well as
2344     *         applications with data directory i.e. applications which had been
2345     *         deleted with {@code DONT_DELETE_DATA} flag set).
2346     * @throws NameNotFoundException if a package with the given name cannot be
2347     *             found on the system.
2348     * @see #GET_ACTIVITIES
2349     * @see #GET_CONFIGURATIONS
2350     * @see #GET_GIDS
2351     * @see #GET_INSTRUMENTATION
2352     * @see #GET_INTENT_FILTERS
2353     * @see #GET_META_DATA
2354     * @see #GET_PERMISSIONS
2355     * @see #GET_PROVIDERS
2356     * @see #GET_RECEIVERS
2357     * @see #GET_SERVICES
2358     * @see #GET_SHARED_LIBRARY_FILES
2359     * @see #GET_SIGNATURES
2360     * @see #GET_URI_PERMISSION_PATTERNS
2361     * @see #MATCH_DISABLED_COMPONENTS
2362     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2363     * @see #MATCH_UNINSTALLED_PACKAGES
2364     */
2365    public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags)
2366            throws NameNotFoundException;
2367
2368    /**
2369     * @hide
2370     * Retrieve overall information about an application package that is
2371     * installed on the system.
2372     *
2373     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2374     *         desired package.
2375     * @param flags Additional option flags. Use any combination of
2376     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2377     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2378     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2379     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2380     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2381     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2382     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2383     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2384     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2385     *         to modify the data returned.
2386     * @param userId The user id.
2387     *
2388     * @return A PackageInfo object containing information about the
2389     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2390     *         package is not found in the list of installed applications, the
2391     *         package information is retrieved from the list of uninstalled
2392     *         applications (which includes installed applications as well as
2393     *         applications with data directory i.e. applications which had been
2394     *         deleted with {@code DONT_DELETE_DATA} flag set).
2395     * @throws NameNotFoundException if a package with the given name cannot be
2396     *             found on the system.
2397     * @see #GET_ACTIVITIES
2398     * @see #GET_CONFIGURATIONS
2399     * @see #GET_GIDS
2400     * @see #GET_INSTRUMENTATION
2401     * @see #GET_INTENT_FILTERS
2402     * @see #GET_META_DATA
2403     * @see #GET_PERMISSIONS
2404     * @see #GET_PROVIDERS
2405     * @see #GET_RECEIVERS
2406     * @see #GET_SERVICES
2407     * @see #GET_SHARED_LIBRARY_FILES
2408     * @see #GET_SIGNATURES
2409     * @see #GET_URI_PERMISSION_PATTERNS
2410     * @see #MATCH_DISABLED_COMPONENTS
2411     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2412     * @see #MATCH_UNINSTALLED_PACKAGES
2413     */
2414    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
2415    public abstract PackageInfo getPackageInfoAsUser(String packageName,
2416            @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
2417
2418    /**
2419     * Map from the current package names in use on the device to whatever
2420     * the current canonical name of that package is.
2421     * @param names Array of current names to be mapped.
2422     * @return Returns an array of the same size as the original, containing
2423     * the canonical name for each package.
2424     */
2425    public abstract String[] currentToCanonicalPackageNames(String[] names);
2426
2427    /**
2428     * Map from a packages canonical name to the current name in use on the device.
2429     * @param names Array of new names to be mapped.
2430     * @return Returns an array of the same size as the original, containing
2431     * the current name for each package.
2432     */
2433    public abstract String[] canonicalToCurrentPackageNames(String[] names);
2434
2435    /**
2436     * Returns a "good" intent to launch a front-door activity in a package.
2437     * This is used, for example, to implement an "open" button when browsing
2438     * through packages.  The current implementation looks first for a main
2439     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
2440     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
2441     * <code>null</code> if neither are found.
2442     *
2443     * @param packageName The name of the package to inspect.
2444     *
2445     * @return A fully-qualified {@link Intent} that can be used to launch the
2446     * main activity in the package. Returns <code>null</code> if the package
2447     * does not contain such an activity, or if <em>packageName</em> is not
2448     * recognized.
2449     */
2450    public abstract Intent getLaunchIntentForPackage(String packageName);
2451
2452    /**
2453     * Return a "good" intent to launch a front-door Leanback activity in a
2454     * package, for use for example to implement an "open" button when browsing
2455     * through packages. The current implementation will look for a main
2456     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
2457     * return null if no main leanback activities are found.
2458     *
2459     * @param packageName The name of the package to inspect.
2460     * @return Returns either a fully-qualified Intent that can be used to launch
2461     *         the main Leanback activity in the package, or null if the package
2462     *         does not contain such an activity.
2463     */
2464    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
2465
2466    /**
2467     * Return an array of all of the secondary group-ids that have been assigned
2468     * to a package.
2469     *
2470     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2471     *         desired package.
2472     * @return Returns an int array of the assigned gids, or null if there are
2473     *         none.
2474     * @throws NameNotFoundException if a package with the given name cannot be
2475     *             found on the system.
2476     */
2477    public abstract int[] getPackageGids(String packageName)
2478            throws NameNotFoundException;
2479
2480    /**
2481     * Return an array of all of the secondary group-ids that have been assigned
2482     * to a package.
2483     *
2484     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2485     *            desired package.
2486     * @return Returns an int array of the assigned gids, or null if there are
2487     *         none.
2488     * @throws NameNotFoundException if a package with the given name cannot be
2489     *             found on the system.
2490     */
2491    public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
2492            throws NameNotFoundException;
2493
2494    /**
2495     * Return the UID associated with the given package name.
2496     *
2497     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2498     *            desired package.
2499     * @return Returns an integer UID who owns the given package name.
2500     * @throws NameNotFoundException if a package with the given name can not be
2501     *             found on the system.
2502     */
2503    public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
2504            throws NameNotFoundException;
2505
2506    /**
2507     * Return the UID associated with the given package name.
2508     *
2509     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2510     *            desired package.
2511     * @param userId The user handle identifier to look up the package under.
2512     * @return Returns an integer UID who owns the given package name.
2513     * @throws NameNotFoundException if a package with the given name can not be
2514     *             found on the system.
2515     * @hide
2516     */
2517    public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
2518            throws NameNotFoundException;
2519
2520    /**
2521     * Return the UID associated with the given package name.
2522     *
2523     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2524     *            desired package.
2525     * @param userId The user handle identifier to look up the package under.
2526     * @return Returns an integer UID who owns the given package name.
2527     * @throws NameNotFoundException if a package with the given name can not be
2528     *             found on the system.
2529     * @hide
2530     */
2531    public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
2532            @UserIdInt int userId) throws NameNotFoundException;
2533
2534    /**
2535     * Retrieve all of the information we know about a particular permission.
2536     *
2537     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
2538     *         of the permission you are interested in.
2539     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2540     *         retrieve any meta-data associated with the permission.
2541     *
2542     * @return Returns a {@link PermissionInfo} containing information about the
2543     *         permission.
2544     * @throws NameNotFoundException if a package with the given name cannot be
2545     *             found on the system.
2546     *
2547     * @see #GET_META_DATA
2548     */
2549    public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
2550            throws NameNotFoundException;
2551
2552    /**
2553     * Query for all of the permissions associated with a particular group.
2554     *
2555     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
2556     *         of the permission group you are interested in.  Use null to
2557     *         find all of the permissions not associated with a group.
2558     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2559     *         retrieve any meta-data associated with the permissions.
2560     *
2561     * @return Returns a list of {@link PermissionInfo} containing information
2562     *             about all of the permissions in the given group.
2563     * @throws NameNotFoundException if a package with the given name cannot be
2564     *             found on the system.
2565     *
2566     * @see #GET_META_DATA
2567     */
2568    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
2569            @PermissionInfoFlags int flags) throws NameNotFoundException;
2570
2571    /**
2572     * Retrieve all of the information we know about a particular group of
2573     * permissions.
2574     *
2575     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
2576     *         of the permission you are interested in.
2577     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2578     *         retrieve any meta-data associated with the permission group.
2579     *
2580     * @return Returns a {@link PermissionGroupInfo} containing information
2581     *         about the permission.
2582     * @throws NameNotFoundException if a package with the given name cannot be
2583     *             found on the system.
2584     *
2585     * @see #GET_META_DATA
2586     */
2587    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
2588            @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
2589
2590    /**
2591     * Retrieve all of the known permission groups in the system.
2592     *
2593     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2594     *         retrieve any meta-data associated with the permission group.
2595     *
2596     * @return Returns a list of {@link PermissionGroupInfo} containing
2597     *         information about all of the known permission groups.
2598     *
2599     * @see #GET_META_DATA
2600     */
2601    public abstract List<PermissionGroupInfo> getAllPermissionGroups(
2602            @PermissionGroupInfoFlags int flags);
2603
2604    /**
2605     * Retrieve all of the information we know about a particular
2606     * package/application.
2607     *
2608     * @param packageName The full name (i.e. com.google.apps.contacts) of an
2609     *         application.
2610     * @param flags Additional option flags. Use any combination of
2611     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2612     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
2613     *         to modify the data returned.
2614     *
2615     * @return An {@link ApplicationInfo} containing information about the
2616     *         package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2617     *         package is not found in the list of installed applications, the
2618     *         application information is retrieved from the list of uninstalled
2619     *         applications (which includes installed applications as well as
2620     *         applications with data directory i.e. applications which had been
2621     *         deleted with {@code DONT_DELETE_DATA} flag set).
2622     * @throws NameNotFoundException if a package with the given name cannot be
2623     *             found on the system.
2624     *
2625     * @see #GET_META_DATA
2626     * @see #GET_SHARED_LIBRARY_FILES
2627     * @see #MATCH_SYSTEM_ONLY
2628     * @see #MATCH_UNINSTALLED_PACKAGES
2629     */
2630    public abstract ApplicationInfo getApplicationInfo(String packageName,
2631            @ApplicationInfoFlags int flags) throws NameNotFoundException;
2632
2633    /** {@hide} */
2634    public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
2635            @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
2636
2637    /**
2638     * Retrieve all of the information we know about a particular activity
2639     * class.
2640     *
2641     * @param component The full component name (i.e.
2642     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
2643     * class.
2644     * @param flags Additional option flags. Use any combination of
2645     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2646     *         {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2647     *         {@link #MATCH_DISABLED_COMPONENTS},  {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2648     *         {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE},
2649     *         {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2650     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2651     *         to modify the data returned.
2652     *
2653     * @return An {@link ActivityInfo} containing information about the activity.
2654     * @throws NameNotFoundException if a package with the given name cannot be
2655     *             found on the system.
2656     *
2657     * @see #GET_META_DATA
2658     * @see #GET_SHARED_LIBRARY_FILES
2659     * @see #MATCH_ALL
2660     * @see #MATCH_DEBUG_TRIAGED_MISSING
2661     * @see #MATCH_DEFAULT_ONLY
2662     * @see #MATCH_DISABLED_COMPONENTS
2663     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2664     * @see #MATCH_ENCRYPTION_AWARE
2665     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
2666     * @see #MATCH_ENCRYPTION_UNAWARE
2667     * @see #MATCH_SYSTEM_ONLY
2668     * @see #MATCH_UNINSTALLED_PACKAGES
2669     */
2670    public abstract ActivityInfo getActivityInfo(ComponentName component,
2671            @ComponentInfoFlags int flags) throws NameNotFoundException;
2672
2673    /**
2674     * Retrieve all of the information we know about a particular receiver
2675     * class.
2676     *
2677     * @param component The full component name (i.e.
2678     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
2679     * class.
2680     * @param flags Additional option flags. Use any combination of
2681     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2682     *         {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2683     *         {@link #MATCH_DISABLED_COMPONENTS},  {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2684     *         {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE},
2685     *         {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2686     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2687     *         to modify the data returned.
2688     *
2689     * @return An {@link ActivityInfo} containing information about the receiver.
2690     * @throws NameNotFoundException if a package with the given name cannot be
2691     *             found on the system.
2692     *
2693     * @see #GET_META_DATA
2694     * @see #GET_SHARED_LIBRARY_FILES
2695     * @see #MATCH_ALL
2696     * @see #MATCH_DEBUG_TRIAGED_MISSING
2697     * @see #MATCH_DEFAULT_ONLY
2698     * @see #MATCH_DISABLED_COMPONENTS
2699     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2700     * @see #MATCH_ENCRYPTION_AWARE
2701     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
2702     * @see #MATCH_ENCRYPTION_UNAWARE
2703     * @see #MATCH_SYSTEM_ONLY
2704     * @see #MATCH_UNINSTALLED_PACKAGES
2705     */
2706    public abstract ActivityInfo getReceiverInfo(ComponentName component,
2707            @ComponentInfoFlags int flags) throws NameNotFoundException;
2708
2709    /**
2710     * Retrieve all of the information we know about a particular service
2711     * class.
2712     *
2713     * @param component The full component name (i.e.
2714     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
2715     * class.
2716     * @param flags Additional option flags. Use any combination of
2717     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2718     *         {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2719     *         {@link #MATCH_DISABLED_COMPONENTS},  {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2720     *         {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE},
2721     *         {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2722     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2723     *         to modify the data returned.
2724     *
2725     * @return A {@link ServiceInfo} object containing information about the service.
2726     * @throws NameNotFoundException if a package with the given name cannot be
2727     *             found on the system.
2728     *
2729     * @see #GET_META_DATA
2730     * @see #GET_SHARED_LIBRARY_FILES
2731     * @see #MATCH_ALL
2732     * @see #MATCH_DEBUG_TRIAGED_MISSING
2733     * @see #MATCH_DEFAULT_ONLY
2734     * @see #MATCH_DISABLED_COMPONENTS
2735     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2736     * @see #MATCH_ENCRYPTION_AWARE
2737     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
2738     * @see #MATCH_ENCRYPTION_UNAWARE
2739     * @see #MATCH_SYSTEM_ONLY
2740     * @see #MATCH_UNINSTALLED_PACKAGES
2741     */
2742    public abstract ServiceInfo getServiceInfo(ComponentName component,
2743            @ComponentInfoFlags int flags) throws NameNotFoundException;
2744
2745    /**
2746     * Retrieve all of the information we know about a particular content
2747     * provider class.
2748     *
2749     * @param component The full component name (i.e.
2750     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
2751     * ContentProvider class.
2752     * @param flags Additional option flags. Use any combination of
2753     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2754     *         {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2755     *         {@link #MATCH_DISABLED_COMPONENTS},  {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2756     *         {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE},
2757     *         {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2758     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2759     *         to modify the data returned.
2760     *
2761     * @return A {@link ProviderInfo} object containing information about the provider.
2762     * @throws NameNotFoundException if a package with the given name cannot be
2763     *             found on the system.
2764     *
2765     * @see #GET_META_DATA
2766     * @see #GET_SHARED_LIBRARY_FILES
2767     * @see #MATCH_ALL
2768     * @see #MATCH_DEBUG_TRIAGED_MISSING
2769     * @see #MATCH_DEFAULT_ONLY
2770     * @see #MATCH_DISABLED_COMPONENTS
2771     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2772     * @see #MATCH_ENCRYPTION_AWARE
2773     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
2774     * @see #MATCH_ENCRYPTION_UNAWARE
2775     * @see #MATCH_SYSTEM_ONLY
2776     * @see #MATCH_UNINSTALLED_PACKAGES
2777     */
2778    public abstract ProviderInfo getProviderInfo(ComponentName component,
2779            @ComponentInfoFlags int flags) throws NameNotFoundException;
2780
2781    /**
2782     * Return a List of all packages that are installed
2783     * on the device.
2784     *
2785     * @param flags Additional option flags. Use any combination of
2786     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2787     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2788     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2789     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2790     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2791     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2792     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2793     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2794     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2795     *         to modify the data returned.
2796     *
2797     * @return A List of PackageInfo objects, one for each installed package,
2798     *         containing information about the package.  In the unlikely case
2799     *         there are no installed packages, an empty list is returned. If
2800     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
2801     *         information is retrieved from the list of uninstalled
2802     *         applications (which includes installed applications as well as
2803     *         applications with data directory i.e. applications which had been
2804     *         deleted with {@code DONT_DELETE_DATA} flag set).
2805     *
2806     * @see #GET_ACTIVITIES
2807     * @see #GET_CONFIGURATIONS
2808     * @see #GET_GIDS
2809     * @see #GET_INSTRUMENTATION
2810     * @see #GET_INTENT_FILTERS
2811     * @see #GET_META_DATA
2812     * @see #GET_PERMISSIONS
2813     * @see #GET_PROVIDERS
2814     * @see #GET_RECEIVERS
2815     * @see #GET_SERVICES
2816     * @see #GET_SHARED_LIBRARY_FILES
2817     * @see #GET_SIGNATURES
2818     * @see #GET_URI_PERMISSION_PATTERNS
2819     * @see #MATCH_DISABLED_COMPONENTS
2820     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2821     * @see #MATCH_UNINSTALLED_PACKAGES
2822     */
2823    public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
2824
2825    /**
2826     * Return a List of all installed packages that are currently
2827     * holding any of the given permissions.
2828     *
2829     * @param flags Additional option flags. Use any combination of
2830     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2831     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2832     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2833     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2834     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2835     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2836     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2837     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2838     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2839     *         to modify the data returned.
2840     *
2841     * @return A List of PackageInfo objects, one for each installed package
2842     *         that holds any of the permissions that were provided, containing
2843     *         information about the package. If no installed packages hold any
2844     *         of the permissions, an empty list is returned. If flag
2845     *         {@code MATCH_UNINSTALLED_PACKAGES} is set, the package information
2846     *         is retrieved from the list of uninstalled applications (which
2847     *         includes installed applications as well as applications with data
2848     *         directory i.e. applications which had been deleted with
2849     *         {@code DONT_DELETE_DATA} flag set).
2850     *
2851     * @see #GET_ACTIVITIES
2852     * @see #GET_CONFIGURATIONS
2853     * @see #GET_GIDS
2854     * @see #GET_INSTRUMENTATION
2855     * @see #GET_INTENT_FILTERS
2856     * @see #GET_META_DATA
2857     * @see #GET_PERMISSIONS
2858     * @see #GET_PROVIDERS
2859     * @see #GET_RECEIVERS
2860     * @see #GET_SERVICES
2861     * @see #GET_SHARED_LIBRARY_FILES
2862     * @see #GET_SIGNATURES
2863     * @see #GET_URI_PERMISSION_PATTERNS
2864     * @see #MATCH_DISABLED_COMPONENTS
2865     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2866     * @see #MATCH_UNINSTALLED_PACKAGES
2867     */
2868    public abstract List<PackageInfo> getPackagesHoldingPermissions(
2869            String[] permissions, @PackageInfoFlags int flags);
2870
2871    /**
2872     * Return a List of all packages that are installed on the device, for a specific user.
2873     * Requesting a list of installed packages for another user
2874     * will require the permission INTERACT_ACROSS_USERS_FULL.
2875     *
2876     * @param flags Additional option flags. Use any combination of
2877     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2878     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2879     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2880     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2881     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2882     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2883     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2884     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2885     *         {@link #MATCH_UNINSTALLED_PACKAGES}
2886     *         to modify the data returned.
2887     * @param userId The user for whom the installed packages are to be listed
2888     *
2889     * @return A List of PackageInfo objects, one for each installed package,
2890     *         containing information about the package.  In the unlikely case
2891     *         there are no installed packages, an empty list is returned. If
2892     *         flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
2893     *         information is retrieved from the list of uninstalled
2894     *         applications (which includes installed applications as well as
2895     *         applications with data directory i.e. applications which had been
2896     *         deleted with {@code DONT_DELETE_DATA} flag set).
2897     *
2898     * @see #GET_ACTIVITIES
2899     * @see #GET_CONFIGURATIONS
2900     * @see #GET_GIDS
2901     * @see #GET_INSTRUMENTATION
2902     * @see #GET_INTENT_FILTERS
2903     * @see #GET_META_DATA
2904     * @see #GET_PERMISSIONS
2905     * @see #GET_PROVIDERS
2906     * @see #GET_RECEIVERS
2907     * @see #GET_SERVICES
2908     * @see #GET_SHARED_LIBRARY_FILES
2909     * @see #GET_SIGNATURES
2910     * @see #GET_URI_PERMISSION_PATTERNS
2911     * @see #MATCH_DISABLED_COMPONENTS
2912     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2913     * @see #MATCH_UNINSTALLED_PACKAGES
2914     *
2915     * @hide
2916     */
2917    public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
2918            @UserIdInt int userId);
2919
2920    /**
2921     * Check whether a particular package has been granted a particular
2922     * permission.
2923     *
2924     * @param permName The name of the permission you are checking for.
2925     * @param pkgName The name of the package you are checking against.
2926     *
2927     * @return If the package has the permission, PERMISSION_GRANTED is
2928     * returned.  If it does not have the permission, PERMISSION_DENIED
2929     * is returned.
2930     *
2931     * @see #PERMISSION_GRANTED
2932     * @see #PERMISSION_DENIED
2933     */
2934    @CheckResult
2935    public abstract int checkPermission(String permName, String pkgName);
2936
2937    /**
2938     * Checks whether a particular permissions has been revoked for a
2939     * package by policy. Typically the device owner or the profile owner
2940     * may apply such a policy. The user cannot grant policy revoked
2941     * permissions, hence the only way for an app to get such a permission
2942     * is by a policy change.
2943     *
2944     * @param permName The name of the permission you are checking for.
2945     * @param pkgName The name of the package you are checking against.
2946     *
2947     * @return Whether the permission is restricted by policy.
2948     */
2949    @CheckResult
2950    public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
2951            @NonNull String pkgName);
2952
2953    /**
2954     * Gets the package name of the component controlling runtime permissions.
2955     *
2956     * @return The package name.
2957     *
2958     * @hide
2959     */
2960    public abstract String getPermissionControllerPackageName();
2961
2962    /**
2963     * Add a new dynamic permission to the system.  For this to work, your
2964     * package must have defined a permission tree through the
2965     * {@link android.R.styleable#AndroidManifestPermissionTree
2966     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
2967     * permissions to trees that were defined by either its own package or
2968     * another with the same user id; a permission is in a tree if it
2969     * matches the name of the permission tree + ".": for example,
2970     * "com.foo.bar" is a member of the permission tree "com.foo".
2971     *
2972     * <p>It is good to make your permission tree name descriptive, because you
2973     * are taking possession of that entire set of permission names.  Thus, it
2974     * must be under a domain you control, with a suffix that will not match
2975     * any normal permissions that may be declared in any applications that
2976     * are part of that domain.
2977     *
2978     * <p>New permissions must be added before
2979     * any .apks are installed that use those permissions.  Permissions you
2980     * add through this method are remembered across reboots of the device.
2981     * If the given permission already exists, the info you supply here
2982     * will be used to update it.
2983     *
2984     * @param info Description of the permission to be added.
2985     *
2986     * @return Returns true if a new permission was created, false if an
2987     * existing one was updated.
2988     *
2989     * @throws SecurityException if you are not allowed to add the
2990     * given permission name.
2991     *
2992     * @see #removePermission(String)
2993     */
2994    public abstract boolean addPermission(PermissionInfo info);
2995
2996    /**
2997     * Like {@link #addPermission(PermissionInfo)} but asynchronously
2998     * persists the package manager state after returning from the call,
2999     * allowing it to return quicker and batch a series of adds at the
3000     * expense of no guarantee the added permission will be retained if
3001     * the device is rebooted before it is written.
3002     */
3003    public abstract boolean addPermissionAsync(PermissionInfo info);
3004
3005    /**
3006     * Removes a permission that was previously added with
3007     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
3008     * -- you are only allowed to remove permissions that you are allowed
3009     * to add.
3010     *
3011     * @param name The name of the permission to remove.
3012     *
3013     * @throws SecurityException if you are not allowed to remove the
3014     * given permission name.
3015     *
3016     * @see #addPermission(PermissionInfo)
3017     */
3018    public abstract void removePermission(String name);
3019
3020
3021    /**
3022     * Permission flags set when granting or revoking a permission.
3023     *
3024     * @hide
3025     */
3026    @SystemApi
3027    @IntDef({FLAG_PERMISSION_USER_SET,
3028            FLAG_PERMISSION_USER_FIXED,
3029            FLAG_PERMISSION_POLICY_FIXED,
3030            FLAG_PERMISSION_REVOKE_ON_UPGRADE,
3031            FLAG_PERMISSION_SYSTEM_FIXED,
3032            FLAG_PERMISSION_GRANTED_BY_DEFAULT})
3033    @Retention(RetentionPolicy.SOURCE)
3034    public @interface PermissionFlags {}
3035
3036    /**
3037     * Grant a runtime permission to an application which the application does not
3038     * already have. The permission must have been requested by the application.
3039     * If the application is not allowed to hold the permission, a {@link
3040     * java.lang.SecurityException} is thrown.
3041     * <p>
3042     * <strong>Note: </strong>Using this API requires holding
3043     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
3044     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3045     * </p>
3046     *
3047     * @param packageName The package to which to grant the permission.
3048     * @param permissionName The permission name to grant.
3049     * @param user The user for which to grant the permission.
3050     *
3051     * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
3052     * @see android.content.pm.PackageManager.PermissionFlags
3053     *
3054     * @hide
3055     */
3056    @SystemApi
3057    public abstract void grantRuntimePermission(@NonNull String packageName,
3058            @NonNull String permissionName, @NonNull UserHandle user);
3059
3060    /**
3061     * Revoke a runtime permission that was previously granted by {@link
3062     * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
3063     * permission must have been requested by and granted to the application.
3064     * If the application is not allowed to hold the permission, a {@link
3065     * java.lang.SecurityException} is thrown.
3066     * <p>
3067     * <strong>Note: </strong>Using this API requires holding
3068     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
3069     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3070     * </p>
3071     *
3072     * @param packageName The package from which to revoke the permission.
3073     * @param permissionName The permission name to revoke.
3074     * @param user The user for which to revoke the permission.
3075     *
3076     * @see #grantRuntimePermission(String, String, android.os.UserHandle)
3077     * @see android.content.pm.PackageManager.PermissionFlags
3078     *
3079     * @hide
3080     */
3081    @SystemApi
3082    public abstract void revokeRuntimePermission(@NonNull String packageName,
3083            @NonNull String permissionName, @NonNull UserHandle user);
3084
3085    /**
3086     * Gets the state flags associated with a permission.
3087     *
3088     * @param permissionName The permission for which to get the flags.
3089     * @param packageName The package name for which to get the flags.
3090     * @param user The user for which to get permission flags.
3091     * @return The permission flags.
3092     *
3093     * @hide
3094     */
3095    @SystemApi
3096    public abstract @PermissionFlags int getPermissionFlags(String permissionName,
3097            String packageName, @NonNull UserHandle user);
3098
3099    /**
3100     * Updates the flags associated with a permission by replacing the flags in
3101     * the specified mask with the provided flag values.
3102     *
3103     * @param permissionName The permission for which to update the flags.
3104     * @param packageName The package name for which to update the flags.
3105     * @param flagMask The flags which to replace.
3106     * @param flagValues The flags with which to replace.
3107     * @param user The user for which to update the permission flags.
3108     *
3109     * @hide
3110     */
3111    @SystemApi
3112    public abstract void updatePermissionFlags(String permissionName,
3113            String packageName, @PermissionFlags int flagMask, int flagValues,
3114            @NonNull UserHandle user);
3115
3116    /**
3117     * Gets whether you should show UI with rationale for requesting a permission.
3118     * You should do this only if you do not have the permission and the context in
3119     * which the permission is requested does not clearly communicate to the user
3120     * what would be the benefit from grating this permission.
3121     *
3122     * @param permission A permission your app wants to request.
3123     * @return Whether you can show permission rationale UI.
3124     *
3125     * @hide
3126     */
3127    public abstract boolean shouldShowRequestPermissionRationale(String permission);
3128
3129    /**
3130     * Returns an {@link android.content.Intent} suitable for passing to
3131     * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
3132     * which prompts the user to grant permissions to this application.
3133     *
3134     * @throws NullPointerException if {@code permissions} is {@code null} or empty.
3135     *
3136     * @hide
3137     */
3138    public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
3139        if (ArrayUtils.isEmpty(permissions)) {
3140           throw new NullPointerException("permission cannot be null or empty");
3141        }
3142        Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
3143        intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
3144        intent.setPackage(getPermissionControllerPackageName());
3145        return intent;
3146    }
3147
3148    /**
3149     * Compare the signatures of two packages to determine if the same
3150     * signature appears in both of them.  If they do contain the same
3151     * signature, then they are allowed special privileges when working
3152     * with each other: they can share the same user-id, run instrumentation
3153     * against each other, etc.
3154     *
3155     * @param pkg1 First package name whose signature will be compared.
3156     * @param pkg2 Second package name whose signature will be compared.
3157     *
3158     * @return Returns an integer indicating whether all signatures on the
3159     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3160     * all signatures match or < 0 if there is not a match ({@link
3161     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3162     *
3163     * @see #checkSignatures(int, int)
3164     * @see #SIGNATURE_MATCH
3165     * @see #SIGNATURE_NO_MATCH
3166     * @see #SIGNATURE_UNKNOWN_PACKAGE
3167     */
3168    @CheckResult
3169    public abstract int checkSignatures(String pkg1, String pkg2);
3170
3171    /**
3172     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
3173     * the two packages to be checked.  This can be useful, for example,
3174     * when doing the check in an IPC, where the UID is the only identity
3175     * available.  It is functionally identical to determining the package
3176     * associated with the UIDs and checking their signatures.
3177     *
3178     * @param uid1 First UID whose signature will be compared.
3179     * @param uid2 Second UID whose signature will be compared.
3180     *
3181     * @return Returns an integer indicating whether all signatures on the
3182     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3183     * all signatures match or < 0 if there is not a match ({@link
3184     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3185     *
3186     * @see #checkSignatures(String, String)
3187     * @see #SIGNATURE_MATCH
3188     * @see #SIGNATURE_NO_MATCH
3189     * @see #SIGNATURE_UNKNOWN_PACKAGE
3190     */
3191    @CheckResult
3192    public abstract int checkSignatures(int uid1, int uid2);
3193
3194    /**
3195     * Retrieve the names of all packages that are associated with a particular
3196     * user id.  In most cases, this will be a single package name, the package
3197     * that has been assigned that user id.  Where there are multiple packages
3198     * sharing the same user id through the "sharedUserId" mechanism, all
3199     * packages with that id will be returned.
3200     *
3201     * @param uid The user id for which you would like to retrieve the
3202     * associated packages.
3203     *
3204     * @return Returns an array of one or more packages assigned to the user
3205     * id, or null if there are no known packages with the given id.
3206     */
3207    public abstract @Nullable String[] getPackagesForUid(int uid);
3208
3209    /**
3210     * Retrieve the official name associated with a user id.  This name is
3211     * guaranteed to never change, though it is possible for the underlying
3212     * user id to be changed.  That is, if you are storing information about
3213     * user ids in persistent storage, you should use the string returned
3214     * by this function instead of the raw user-id.
3215     *
3216     * @param uid The user id for which you would like to retrieve a name.
3217     * @return Returns a unique name for the given user id, or null if the
3218     * user id is not currently assigned.
3219     */
3220    public abstract @Nullable String getNameForUid(int uid);
3221
3222    /**
3223     * Return the user id associated with a shared user name. Multiple
3224     * applications can specify a shared user name in their manifest and thus
3225     * end up using a common uid. This might be used for new applications
3226     * that use an existing shared user name and need to know the uid of the
3227     * shared user.
3228     *
3229     * @param sharedUserName The shared user name whose uid is to be retrieved.
3230     * @return Returns the UID associated with the shared user.
3231     * @throws NameNotFoundException if a package with the given name cannot be
3232     *             found on the system.
3233     * @hide
3234     */
3235    public abstract int getUidForSharedUser(String sharedUserName)
3236            throws NameNotFoundException;
3237
3238    /**
3239     * Return a List of all application packages that are installed on the
3240     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
3241     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
3242     * installed apps with data directory) will be returned.
3243     *
3244     * @param flags Additional option flags. Use any combination of
3245     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3246     * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3247     * to modify the data returned.
3248     *
3249     * @return A List of ApplicationInfo objects, one for each installed application.
3250     *         In the unlikely case there are no installed packages, an empty list
3251     *         is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the
3252     *         application information is retrieved from the list of uninstalled
3253     *         applications (which includes installed applications as well as
3254     *         applications with data directory i.e. applications which had been
3255     *         deleted with {@code DONT_DELETE_DATA} flag set).
3256     *
3257     * @see #GET_META_DATA
3258     * @see #GET_SHARED_LIBRARY_FILES
3259     * @see #MATCH_SYSTEM_ONLY
3260     * @see #MATCH_UNINSTALLED_PACKAGES
3261     */
3262    public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
3263
3264    /**
3265     * Gets the ephemeral applications the user recently used. Requires
3266     * holding "android.permission.ACCESS_EPHEMERAL_APPS".
3267     *
3268     * @return The ephemeral app list.
3269     *
3270     * @hide
3271     */
3272    @RequiresPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS)
3273    public abstract List<EphemeralApplicationInfo> getEphemeralApplications();
3274
3275    /**
3276     * Gets the icon for an ephemeral application.
3277     *
3278     * @param packageName The app package name.
3279     *
3280     * @hide
3281     */
3282    public abstract Drawable getEphemeralApplicationIcon(String packageName);
3283
3284    /**
3285     * Gets whether the caller is an ephemeral app.
3286     *
3287     * @return Whether caller is an ephemeral app.
3288     *
3289     * @see #setEphemeralCookie(byte[])
3290     * @see #getEphemeralCookie()
3291     * @see #getEphemeralCookieMaxSizeBytes()
3292     *
3293     * @hide
3294     */
3295    public abstract boolean isEphemeralApplication();
3296
3297    /**
3298     * Gets the maximum size in bytes of the cookie data an ephemeral app
3299     * can store on the device.
3300     *
3301     * @return The max cookie size in bytes.
3302     *
3303     * @see #isEphemeralApplication()
3304     * @see #setEphemeralCookie(byte[])
3305     * @see #getEphemeralCookie()
3306     *
3307     * @hide
3308     */
3309    public abstract int getEphemeralCookieMaxSizeBytes();
3310
3311    /**
3312     * Gets the ephemeral application cookie for this app. Non
3313     * ephemeral apps and apps that were ephemeral but were upgraded
3314     * to non-ephemeral can still access this API. For ephemeral apps
3315     * this cooke is cached for some time after uninstall while for
3316     * normal apps the cookie is deleted after the app is uninstalled.
3317     * The cookie is always present while the app is installed.
3318     *
3319     * @return The cookie.
3320     *
3321     * @see #isEphemeralApplication()
3322     * @see #setEphemeralCookie(byte[])
3323     * @see #getEphemeralCookieMaxSizeBytes()
3324     *
3325     * @hide
3326     */
3327    public abstract @NonNull byte[] getEphemeralCookie();
3328
3329    /**
3330     * Sets the ephemeral application cookie for the calling app. Non
3331     * ephemeral apps and apps that were ephemeral but were upgraded
3332     * to non-ephemeral can still access this API. For ephemeral apps
3333     * this cooke is cached for some time after uninstall while for
3334     * normal apps the cookie is deleted after the app is uninstalled.
3335     * The cookie is always present while the app is installed. The
3336     * cookie size is limited by {@link #getEphemeralCookieMaxSizeBytes()}.
3337     *
3338     * @param cookie The cookie data.
3339     * @return True if the cookie was set.
3340     *
3341     * @see #isEphemeralApplication()
3342     * @see #getEphemeralCookieMaxSizeBytes()
3343     * @see #getEphemeralCookie()
3344     *
3345     * @hide
3346     */
3347    public abstract boolean setEphemeralCookie(@NonNull  byte[] cookie);
3348
3349    /**
3350     * Get a list of shared libraries that are available on the
3351     * system.
3352     *
3353     * @return An array of shared library names that are
3354     * available on the system, or null if none are installed.
3355     *
3356     */
3357    public abstract String[] getSystemSharedLibraryNames();
3358
3359    /**
3360     * Get a list of features that are available on the
3361     * system.
3362     *
3363     * @return An array of FeatureInfo classes describing the features
3364     * that are available on the system, or null if there are none(!!).
3365     */
3366    public abstract FeatureInfo[] getSystemAvailableFeatures();
3367
3368    /**
3369     * Check whether the given feature name is one of the available
3370     * features as returned by {@link #getSystemAvailableFeatures()}.
3371     *
3372     * @return Returns true if the devices supports the feature, else
3373     * false.
3374     */
3375    public abstract boolean hasSystemFeature(String name);
3376
3377    /**
3378     * Determine the best action to perform for a given Intent.  This is how
3379     * {@link Intent#resolveActivity} finds an activity if a class has not
3380     * been explicitly specified.
3381     *
3382     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
3383     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
3384     * only flag.  You need to do so to resolve the activity in the same way
3385     * that {@link android.content.Context#startActivity(Intent)} and
3386     * {@link android.content.Intent#resolveActivity(PackageManager)
3387     * Intent.resolveActivity(PackageManager)} do.</p>
3388     *
3389     * @param intent An intent containing all of the desired specification
3390     *               (action, data, type, category, and/or component).
3391     * @param flags Additional option flags. Use any combination of
3392     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3393     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3394     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3395     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3396     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3397     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3398     *         to modify the data returned. The most important is
3399     *         {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3400     *         those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3401     *
3402     * @return Returns a ResolveInfo object containing the final activity intent
3403     *         that was determined to be the best action.  Returns null if no
3404     *         matching activity was found. If multiple matching activities are
3405     *         found and there is no default set, returns a ResolveInfo object
3406     *         containing something else, such as the activity resolver.
3407     *
3408     * @see #GET_META_DATA
3409     * @see #GET_RESOLVED_FILTER
3410     * @see #GET_SHARED_LIBRARY_FILES
3411     * @see #MATCH_ALL
3412     * @see #MATCH_DISABLED_COMPONENTS
3413     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3414     * @see #MATCH_DEFAULT_ONLY
3415     * @see #MATCH_ENCRYPTION_AWARE
3416     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3417     * @see #MATCH_ENCRYPTION_UNAWARE
3418     * @see #MATCH_SYSTEM_ONLY
3419     * @see #MATCH_UNINSTALLED_PACKAGES
3420     */
3421    public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
3422
3423    /**
3424     * Determine the best action to perform for a given Intent for a given user. This
3425     * is how {@link Intent#resolveActivity} finds an activity if a class has not
3426     * been explicitly specified.
3427     *
3428     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
3429     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
3430     * only flag.  You need to do so to resolve the activity in the same way
3431     * that {@link android.content.Context#startActivity(Intent)} and
3432     * {@link android.content.Intent#resolveActivity(PackageManager)
3433     * Intent.resolveActivity(PackageManager)} do.</p>
3434     *
3435     * @param intent An intent containing all of the desired specification
3436     *               (action, data, type, category, and/or component).
3437     * @param flags Additional option flags. Use any combination of
3438     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3439     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3440     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3441     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3442     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3443     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3444     *         to modify the data returned. The most important is
3445     *         {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3446     *         those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3447     * @param userId The user id.
3448     *
3449     * @return Returns a ResolveInfo object containing the final activity intent
3450     *         that was determined to be the best action.  Returns null if no
3451     *         matching activity was found. If multiple matching activities are
3452     *         found and there is no default set, returns a ResolveInfo object
3453     *         containing something else, such as the activity resolver.
3454     *
3455     * @see #GET_META_DATA
3456     * @see #GET_RESOLVED_FILTER
3457     * @see #GET_SHARED_LIBRARY_FILES
3458     * @see #MATCH_ALL
3459     * @see #MATCH_DISABLED_COMPONENTS
3460     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3461     * @see #MATCH_DEFAULT_ONLY
3462     * @see #MATCH_ENCRYPTION_AWARE
3463     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3464     * @see #MATCH_ENCRYPTION_UNAWARE
3465     * @see #MATCH_SYSTEM_ONLY
3466     * @see #MATCH_UNINSTALLED_PACKAGES
3467     *
3468     * @hide
3469     */
3470    public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
3471            @UserIdInt int userId);
3472
3473    /**
3474     * Retrieve all activities that can be performed for the given intent.
3475     *
3476     * @param intent The desired intent as per resolveActivity().
3477     * @param flags Additional option flags. Use any combination of
3478     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3479     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3480     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3481     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3482     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3483     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3484     *         to modify the data returned. The most important is
3485     *         {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3486     *         those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3487     *         Or, set {@link #MATCH_ALL} to prevent any filtering of the results.
3488     *
3489     * @return Returns a List of ResolveInfo objects containing one entry for each
3490     *         matching activity, ordered from best to worst. In other words, the
3491     *         first item is what would be returned by {@link #resolveActivity}.
3492     *         If there are no matching activities, an empty list is returned.
3493     *
3494     * @see #GET_META_DATA
3495     * @see #GET_RESOLVED_FILTER
3496     * @see #GET_SHARED_LIBRARY_FILES
3497     * @see #MATCH_ALL
3498     * @see #MATCH_DISABLED_COMPONENTS
3499     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3500     * @see #MATCH_DEFAULT_ONLY
3501     * @see #MATCH_ENCRYPTION_AWARE
3502     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3503     * @see #MATCH_ENCRYPTION_UNAWARE
3504     * @see #MATCH_SYSTEM_ONLY
3505     * @see #MATCH_UNINSTALLED_PACKAGES
3506     */
3507    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
3508            @ResolveInfoFlags int flags);
3509
3510    /**
3511     * Retrieve all activities that can be performed for the given intent, for a specific user.
3512     *
3513     * @param intent The desired intent as per resolveActivity().
3514     * @param flags Additional option flags. Use any combination of
3515     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3516     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3517     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3518     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3519     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3520     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3521     *         to modify the data returned. The most important is
3522     *         {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3523     *         those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3524     *         Or, set {@link #MATCH_ALL} to prevent any filtering of the results.
3525     *
3526     * @return Returns a List of ResolveInfo objects containing one entry for each
3527     *         matching activity, ordered from best to worst. In other words, the
3528     *         first item is what would be returned by {@link #resolveActivity}.
3529     *         If there are no matching activities, an empty list is returned.
3530     *
3531     * @see #GET_META_DATA
3532     * @see #GET_RESOLVED_FILTER
3533     * @see #GET_SHARED_LIBRARY_FILES
3534     * @see #MATCH_ALL
3535     * @see #MATCH_DISABLED_COMPONENTS
3536     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3537     * @see #MATCH_DEFAULT_ONLY
3538     * @see #MATCH_ENCRYPTION_AWARE
3539     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3540     * @see #MATCH_ENCRYPTION_UNAWARE
3541     * @see #MATCH_SYSTEM_ONLY
3542     * @see #MATCH_UNINSTALLED_PACKAGES
3543     *
3544     * @hide
3545     */
3546    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
3547            @ResolveInfoFlags int flags, @UserIdInt int userId);
3548
3549    /**
3550     * Retrieve a set of activities that should be presented to the user as
3551     * similar options.  This is like {@link #queryIntentActivities}, except it
3552     * also allows you to supply a list of more explicit Intents that you would
3553     * like to resolve to particular options, and takes care of returning the
3554     * final ResolveInfo list in a reasonable order, with no duplicates, based
3555     * on those inputs.
3556     *
3557     * @param caller The class name of the activity that is making the
3558     *               request.  This activity will never appear in the output
3559     *               list.  Can be null.
3560     * @param specifics An array of Intents that should be resolved to the
3561     *                  first specific results.  Can be null.
3562     * @param intent The desired intent as per resolveActivity().
3563     * @param flags Additional option flags. Use any combination of
3564     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3565     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3566     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3567     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3568     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3569     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3570     *         to modify the data returned. The most important is
3571     *         {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3572     *         those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3573     *
3574     * @return Returns a List of ResolveInfo objects containing one entry for each
3575     *         matching activity. The list is ordered first by all of the intents resolved
3576     *         in <var>specifics</var> and then any additional activities that
3577     *         can handle <var>intent</var> but did not get included by one of
3578     *         the <var>specifics</var> intents.  If there are no matching
3579     *         activities, an empty list is returned.
3580     *
3581     * @see #GET_META_DATA
3582     * @see #GET_RESOLVED_FILTER
3583     * @see #GET_SHARED_LIBRARY_FILES
3584     * @see #MATCH_ALL
3585     * @see #MATCH_DISABLED_COMPONENTS
3586     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3587     * @see #MATCH_DEFAULT_ONLY
3588     * @see #MATCH_ENCRYPTION_AWARE
3589     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3590     * @see #MATCH_ENCRYPTION_UNAWARE
3591     * @see #MATCH_SYSTEM_ONLY
3592     * @see #MATCH_UNINSTALLED_PACKAGES
3593     */
3594    public abstract List<ResolveInfo> queryIntentActivityOptions(
3595            ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
3596
3597    /**
3598     * Retrieve all receivers that can handle a broadcast of the given intent.
3599     *
3600     * @param intent The desired intent as per resolveActivity().
3601     * @param flags Additional option flags. Use any combination of
3602     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3603     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3604     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3605     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3606     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3607     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3608     *         to modify the data returned.
3609     *
3610     * @return Returns a List of ResolveInfo objects containing one entry for each
3611     *         matching receiver, ordered from best to worst. If there are no matching
3612     *         receivers, an empty list or null is returned.
3613     *
3614     * @see #GET_META_DATA
3615     * @see #GET_RESOLVED_FILTER
3616     * @see #GET_SHARED_LIBRARY_FILES
3617     * @see #MATCH_ALL
3618     * @see #MATCH_DISABLED_COMPONENTS
3619     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3620     * @see #MATCH_DEFAULT_ONLY
3621     * @see #MATCH_ENCRYPTION_AWARE
3622     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3623     * @see #MATCH_ENCRYPTION_UNAWARE
3624     * @see #MATCH_SYSTEM_ONLY
3625     * @see #MATCH_UNINSTALLED_PACKAGES
3626     */
3627    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3628            @ResolveInfoFlags int flags);
3629
3630    /**
3631     * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
3632     * user.
3633     *
3634     * @param intent The desired intent as per resolveActivity().
3635     * @param flags Additional option flags. Use any combination of
3636     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3637     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3638     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3639     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3640     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3641     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3642     *         to modify the data returned.
3643     * @param userId The userId of the user being queried.
3644     *
3645     * @return Returns a List of ResolveInfo objects containing one entry for each
3646     *         matching receiver, ordered from best to worst. If there are no matching
3647     *         receivers, an empty list or null is returned.
3648     *
3649     * @see #GET_META_DATA
3650     * @see #GET_RESOLVED_FILTER
3651     * @see #GET_SHARED_LIBRARY_FILES
3652     * @see #MATCH_ALL
3653     * @see #MATCH_DISABLED_COMPONENTS
3654     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3655     * @see #MATCH_DEFAULT_ONLY
3656     * @see #MATCH_ENCRYPTION_AWARE
3657     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3658     * @see #MATCH_ENCRYPTION_UNAWARE
3659     * @see #MATCH_SYSTEM_ONLY
3660     * @see #MATCH_UNINSTALLED_PACKAGES
3661     *
3662     * @hide
3663     */
3664    public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
3665            @ResolveInfoFlags int flags, @UserIdInt int userId);
3666
3667    /** {@hide} */
3668    @Deprecated
3669    public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3670            @ResolveInfoFlags int flags, @UserIdInt int userId) {
3671        Log.w(TAG, "STAHP USING HIDDEN APIS KTHX");
3672        return queryBroadcastReceiversAsUser(intent, flags, userId);
3673    }
3674
3675    /**
3676     * Determine the best service to handle for a given Intent.
3677     *
3678     * @param intent An intent containing all of the desired specification
3679     *               (action, data, type, category, and/or component).
3680     * @param flags Additional option flags. Use any combination of
3681     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3682     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3683     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3684     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3685     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3686     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3687     *         to modify the data returned.
3688     *
3689     * @return Returns a ResolveInfo object containing the final service intent
3690     *         that was determined to be the best action.  Returns null if no
3691     *         matching service was found.
3692     *
3693     * @see #GET_META_DATA
3694     * @see #GET_RESOLVED_FILTER
3695     * @see #GET_SHARED_LIBRARY_FILES
3696     * @see #MATCH_ALL
3697     * @see #MATCH_DISABLED_COMPONENTS
3698     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3699     * @see #MATCH_DEFAULT_ONLY
3700     * @see #MATCH_ENCRYPTION_AWARE
3701     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3702     * @see #MATCH_ENCRYPTION_UNAWARE
3703     * @see #MATCH_SYSTEM_ONLY
3704     * @see #MATCH_UNINSTALLED_PACKAGES
3705     */
3706    public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
3707
3708    /**
3709     * Retrieve all services that can match the given intent.
3710     *
3711     * @param intent The desired intent as per resolveService().
3712     * @param flags Additional option flags. Use any combination of
3713     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3714     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3715     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3716     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3717     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3718     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3719     *         to modify the data returned.
3720     *
3721     * @return Returns a List of ResolveInfo objects containing one entry for each
3722     *         matching service, ordered from best to worst. In other words, the first
3723     *         item is what would be returned by {@link #resolveService}. If there are
3724     *         no matching services, an empty list or null is returned.
3725     *
3726     * @see #GET_META_DATA
3727     * @see #GET_RESOLVED_FILTER
3728     * @see #GET_SHARED_LIBRARY_FILES
3729     * @see #MATCH_ALL
3730     * @see #MATCH_DISABLED_COMPONENTS
3731     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3732     * @see #MATCH_DEFAULT_ONLY
3733     * @see #MATCH_ENCRYPTION_AWARE
3734     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3735     * @see #MATCH_ENCRYPTION_UNAWARE
3736     * @see #MATCH_SYSTEM_ONLY
3737     * @see #MATCH_UNINSTALLED_PACKAGES
3738     */
3739    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
3740            @ResolveInfoFlags int flags);
3741
3742    /**
3743     * Retrieve all services that can match the given intent for a given user.
3744     *
3745     * @param intent The desired intent as per resolveService().
3746     * @param flags Additional option flags. Use any combination of
3747     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3748     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3749     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3750     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3751     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3752     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3753     *         to modify the data returned.
3754     * @param userId The user id.
3755     *
3756     * @return Returns a List of ResolveInfo objects containing one entry for each
3757     *         matching service, ordered from best to worst. In other words, the first
3758     *         item is what would be returned by {@link #resolveService}. If there are
3759     *         no matching services, an empty list or null is returned.
3760     *
3761     * @see #GET_META_DATA
3762     * @see #GET_RESOLVED_FILTER
3763     * @see #GET_SHARED_LIBRARY_FILES
3764     * @see #MATCH_ALL
3765     * @see #MATCH_DISABLED_COMPONENTS
3766     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3767     * @see #MATCH_DEFAULT_ONLY
3768     * @see #MATCH_ENCRYPTION_AWARE
3769     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3770     * @see #MATCH_ENCRYPTION_UNAWARE
3771     * @see #MATCH_SYSTEM_ONLY
3772     * @see #MATCH_UNINSTALLED_PACKAGES
3773     *
3774     * @hide
3775     */
3776    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
3777            @ResolveInfoFlags int flags, @UserIdInt int userId);
3778
3779    /**
3780     * Retrieve all providers that can match the given intent.
3781     *
3782     * @param intent An intent containing all of the desired specification
3783     *            (action, data, type, category, and/or component).
3784     * @param flags Additional option flags. Use any combination of
3785     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3786     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3787     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3788     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3789     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3790     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3791     *         to modify the data returned.
3792     * @param userId The user id.
3793     *
3794     * @return Returns a List of ResolveInfo objects containing one entry for each
3795     *         matching provider, ordered from best to worst. If there are no
3796     *         matching services, an empty list or null is returned.
3797     *
3798     * @see #GET_META_DATA
3799     * @see #GET_RESOLVED_FILTER
3800     * @see #GET_SHARED_LIBRARY_FILES
3801     * @see #MATCH_ALL
3802     * @see #MATCH_DISABLED_COMPONENTS
3803     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3804     * @see #MATCH_DEFAULT_ONLY
3805     * @see #MATCH_ENCRYPTION_AWARE
3806     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3807     * @see #MATCH_ENCRYPTION_UNAWARE
3808     * @see #MATCH_SYSTEM_ONLY
3809     * @see #MATCH_UNINSTALLED_PACKAGES
3810     *
3811     * @hide
3812     */
3813    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
3814            Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
3815
3816    /**
3817     * Retrieve all providers that can match the given intent.
3818     *
3819     * @param intent An intent containing all of the desired specification
3820     *            (action, data, type, category, and/or component).
3821     * @param flags Additional option flags. Use any combination of
3822     *         {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3823     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3824     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3825     *         {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_ENCRYPTION_AWARE},
3826     *         {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE}, {@link #MATCH_ENCRYPTION_UNAWARE},
3827     *         {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3828     *         to modify the data returned.
3829     *
3830     * @return Returns a List of ResolveInfo objects containing one entry for each
3831     *         matching provider, ordered from best to worst. If there are no
3832     *         matching services, an empty list or null is returned.
3833     *
3834     * @see #GET_META_DATA
3835     * @see #GET_RESOLVED_FILTER
3836     * @see #GET_SHARED_LIBRARY_FILES
3837     * @see #MATCH_ALL
3838     * @see #MATCH_DISABLED_COMPONENTS
3839     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3840     * @see #MATCH_DEFAULT_ONLY
3841     * @see #MATCH_ENCRYPTION_AWARE
3842     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3843     * @see #MATCH_ENCRYPTION_UNAWARE
3844     * @see #MATCH_SYSTEM_ONLY
3845     * @see #MATCH_UNINSTALLED_PACKAGES
3846     */
3847    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
3848            @ResolveInfoFlags int flags);
3849
3850    /**
3851     * Find a single content provider by its base path name.
3852     *
3853     * @param name The name of the provider to find.
3854     * @param flags Additional option flags. Use any combination of
3855     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3856     *         {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
3857     *         {@link #MATCH_DISABLED_COMPONENTS},  {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3858     *         {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE},
3859     *         {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3860     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3861     *         to modify the data returned.
3862     *
3863     * @return A {@link ProviderInfo} object containing information about the provider.
3864     *         If a provider was not found, returns null.
3865     *
3866     * @see #GET_META_DATA
3867     * @see #GET_SHARED_LIBRARY_FILES
3868     * @see #MATCH_ALL
3869     * @see #MATCH_DEBUG_TRIAGED_MISSING
3870     * @see #MATCH_DEFAULT_ONLY
3871     * @see #MATCH_DISABLED_COMPONENTS
3872     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3873     * @see #MATCH_ENCRYPTION_AWARE
3874     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3875     * @see #MATCH_ENCRYPTION_UNAWARE
3876     * @see #MATCH_SYSTEM_ONLY
3877     * @see #MATCH_UNINSTALLED_PACKAGES
3878     */
3879    public abstract ProviderInfo resolveContentProvider(String name,
3880            @ComponentInfoFlags int flags);
3881
3882    /**
3883     * Find a single content provider by its base path name.
3884     *
3885     * @param name The name of the provider to find.
3886     * @param flags Additional option flags. Use any combination of
3887     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3888     *         {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
3889     *         {@link #MATCH_DISABLED_COMPONENTS},  {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3890     *         {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE},
3891     *         {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3892     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3893     *         to modify the data returned.
3894     * @param userId The user id.
3895     *
3896     * @return A {@link ProviderInfo} object containing information about the provider.
3897     *         If a provider was not found, returns null.
3898     *
3899     * @see #GET_META_DATA
3900     * @see #GET_SHARED_LIBRARY_FILES
3901     * @see #MATCH_ALL
3902     * @see #MATCH_DEBUG_TRIAGED_MISSING
3903     * @see #MATCH_DEFAULT_ONLY
3904     * @see #MATCH_DISABLED_COMPONENTS
3905     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3906     * @see #MATCH_ENCRYPTION_AWARE
3907     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3908     * @see #MATCH_ENCRYPTION_UNAWARE
3909     * @see #MATCH_SYSTEM_ONLY
3910     * @see #MATCH_UNINSTALLED_PACKAGES
3911     *
3912     * @hide
3913     */
3914    public abstract ProviderInfo resolveContentProviderAsUser(String name,
3915            @ComponentInfoFlags int flags, @UserIdInt int userId);
3916
3917    /**
3918     * Retrieve content provider information.
3919     *
3920     * <p><em>Note: unlike most other methods, an empty result set is indicated
3921     * by a null return instead of an empty list.</em>
3922     *
3923     * @param processName If non-null, limits the returned providers to only
3924     *                    those that are hosted by the given process.  If null,
3925     *                    all content providers are returned.
3926     * @param uid If <var>processName</var> is non-null, this is the required
3927     *        uid owning the requested content providers.
3928     * @param flags Additional option flags. Use any combination of
3929     *         {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3930     *         {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
3931     *         {@link #MATCH_DISABLED_COMPONENTS},  {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3932     *         {@link #MATCH_ENCRYPTION_AWARE}, {@link #MATCH_ENCRYPTION_AWARE_AND_UNAWARE},
3933     *         {@link #MATCH_ENCRYPTION_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3934     *         {@link #MATCH_UNINSTALLED_PACKAGES}
3935     *         to modify the data returned.
3936     *
3937     * @return A list of {@link ProviderInfo} objects containing one entry for
3938     *         each provider either matching <var>processName</var> or, if
3939     *         <var>processName</var> is null, all known content providers.
3940     *         <em>If there are no matching providers, null is returned.</em>
3941     *
3942     * @see #GET_META_DATA
3943     * @see #GET_SHARED_LIBRARY_FILES
3944     * @see #MATCH_ALL
3945     * @see #MATCH_DEBUG_TRIAGED_MISSING
3946     * @see #MATCH_DEFAULT_ONLY
3947     * @see #MATCH_DISABLED_COMPONENTS
3948     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3949     * @see #MATCH_ENCRYPTION_AWARE
3950     * @see #MATCH_ENCRYPTION_AWARE_AND_UNAWARE
3951     * @see #MATCH_ENCRYPTION_UNAWARE
3952     * @see #MATCH_SYSTEM_ONLY
3953     * @see #MATCH_UNINSTALLED_PACKAGES
3954     */
3955    public abstract List<ProviderInfo> queryContentProviders(
3956            String processName, int uid, @ComponentInfoFlags int flags);
3957
3958    /**
3959     * Retrieve all of the information we know about a particular
3960     * instrumentation class.
3961     *
3962     * @param className The full name (i.e.
3963     *                  com.google.apps.contacts.InstrumentList) of an
3964     *                  Instrumentation class.
3965     * @param flags Additional option flags. Use any combination of
3966     *         {@link #GET_META_DATA}
3967     *         to modify the data returned.
3968     *
3969     * @return An {@link InstrumentationInfo} object containing information about the
3970     *         instrumentation.
3971     * @throws NameNotFoundException if a package with the given name cannot be
3972     *             found on the system.
3973     *
3974     * @see #GET_META_DATA
3975     */
3976    public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
3977            @InstrumentationInfoFlags int flags) throws NameNotFoundException;
3978
3979    /**
3980     * Retrieve information about available instrumentation code.  May be used
3981     * to retrieve either all instrumentation code, or only the code targeting
3982     * a particular package.
3983     *
3984     * @param targetPackage If null, all instrumentation is returned; only the
3985     *                      instrumentation targeting this package name is
3986     *                      returned.
3987     * @param flags Additional option flags. Use any combination of
3988     *         {@link #GET_META_DATA}
3989     *         to modify the data returned.
3990     *
3991     * @return A list of {@link InstrumentationInfo} objects containing one
3992     *         entry for each matching instrumentation. If there are no
3993     *         instrumentation available, returns and empty list.
3994     *
3995     * @see #GET_META_DATA
3996     */
3997    public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
3998            @InstrumentationInfoFlags int flags);
3999
4000    /**
4001     * Retrieve an image from a package.  This is a low-level API used by
4002     * the various package manager info structures (such as
4003     * {@link ComponentInfo} to implement retrieval of their associated
4004     * icon.
4005     *
4006     * @param packageName The name of the package that this icon is coming from.
4007     * Cannot be null.
4008     * @param resid The resource identifier of the desired image.  Cannot be 0.
4009     * @param appInfo Overall information about <var>packageName</var>.  This
4010     * may be null, in which case the application information will be retrieved
4011     * for you if needed; if you already have this information around, it can
4012     * be much more efficient to supply it here.
4013     *
4014     * @return Returns a Drawable holding the requested image.  Returns null if
4015     * an image could not be found for any reason.
4016     */
4017    public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
4018            ApplicationInfo appInfo);
4019
4020    /**
4021     * Retrieve the icon associated with an activity.  Given the full name of
4022     * an activity, retrieves the information about it and calls
4023     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
4024     * If the activity cannot be found, NameNotFoundException is thrown.
4025     *
4026     * @param activityName Name of the activity whose icon is to be retrieved.
4027     *
4028     * @return Returns the image of the icon, or the default activity icon if
4029     * it could not be found.  Does not return null.
4030     * @throws NameNotFoundException Thrown if the resources for the given
4031     * activity could not be loaded.
4032     *
4033     * @see #getActivityIcon(Intent)
4034     */
4035    public abstract Drawable getActivityIcon(ComponentName activityName)
4036            throws NameNotFoundException;
4037
4038    /**
4039     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
4040     * set, this simply returns the result of
4041     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
4042     * component and returns the icon associated with the resolved component.
4043     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4044     * to a component, NameNotFoundException is thrown.
4045     *
4046     * @param intent The intent for which you would like to retrieve an icon.
4047     *
4048     * @return Returns the image of the icon, or the default activity icon if
4049     * it could not be found.  Does not return null.
4050     * @throws NameNotFoundException Thrown if the resources for application
4051     * matching the given intent could not be loaded.
4052     *
4053     * @see #getActivityIcon(ComponentName)
4054     */
4055    public abstract Drawable getActivityIcon(Intent intent)
4056            throws NameNotFoundException;
4057
4058    /**
4059     * Retrieve the banner associated with an activity. Given the full name of
4060     * an activity, retrieves the information about it and calls
4061     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4062     * banner. If the activity cannot be found, NameNotFoundException is thrown.
4063     *
4064     * @param activityName Name of the activity whose banner is to be retrieved.
4065     * @return Returns the image of the banner, or null if the activity has no
4066     *         banner specified.
4067     * @throws NameNotFoundException Thrown if the resources for the given
4068     *             activity could not be loaded.
4069     * @see #getActivityBanner(Intent)
4070     */
4071    public abstract Drawable getActivityBanner(ComponentName activityName)
4072            throws NameNotFoundException;
4073
4074    /**
4075     * Retrieve the banner associated with an Intent. If intent.getClassName()
4076     * is set, this simply returns the result of
4077     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4078     * intent's component and returns the banner associated with the resolved
4079     * component. If intent.getClassName() cannot be found or the Intent cannot
4080     * be resolved to a component, NameNotFoundException is thrown.
4081     *
4082     * @param intent The intent for which you would like to retrieve a banner.
4083     * @return Returns the image of the banner, or null if the activity has no
4084     *         banner specified.
4085     * @throws NameNotFoundException Thrown if the resources for application
4086     *             matching the given intent could not be loaded.
4087     * @see #getActivityBanner(ComponentName)
4088     */
4089    public abstract Drawable getActivityBanner(Intent intent)
4090            throws NameNotFoundException;
4091
4092    /**
4093     * Return the generic icon for an activity that is used when no specific
4094     * icon is defined.
4095     *
4096     * @return Drawable Image of the icon.
4097     */
4098    public abstract Drawable getDefaultActivityIcon();
4099
4100    /**
4101     * Retrieve the icon associated with an application.  If it has not defined
4102     * an icon, the default app icon is returned.  Does not return null.
4103     *
4104     * @param info Information about application being queried.
4105     *
4106     * @return Returns the image of the icon, or the default application icon
4107     * if it could not be found.
4108     *
4109     * @see #getApplicationIcon(String)
4110     */
4111    public abstract Drawable getApplicationIcon(ApplicationInfo info);
4112
4113    /**
4114     * Retrieve the icon associated with an application.  Given the name of the
4115     * application's package, retrieves the information about it and calls
4116     * getApplicationIcon() to return its icon. If the application cannot be
4117     * found, NameNotFoundException is thrown.
4118     *
4119     * @param packageName Name of the package whose application icon is to be
4120     *                    retrieved.
4121     *
4122     * @return Returns the image of the icon, or the default application icon
4123     * if it could not be found.  Does not return null.
4124     * @throws NameNotFoundException Thrown if the resources for the given
4125     * application could not be loaded.
4126     *
4127     * @see #getApplicationIcon(ApplicationInfo)
4128     */
4129    public abstract Drawable getApplicationIcon(String packageName)
4130            throws NameNotFoundException;
4131
4132    /**
4133     * Retrieve the banner associated with an application.
4134     *
4135     * @param info Information about application being queried.
4136     * @return Returns the image of the banner or null if the application has no
4137     *         banner specified.
4138     * @see #getApplicationBanner(String)
4139     */
4140    public abstract Drawable getApplicationBanner(ApplicationInfo info);
4141
4142    /**
4143     * Retrieve the banner associated with an application. Given the name of the
4144     * application's package, retrieves the information about it and calls
4145     * getApplicationIcon() to return its banner. If the application cannot be
4146     * found, NameNotFoundException is thrown.
4147     *
4148     * @param packageName Name of the package whose application banner is to be
4149     *            retrieved.
4150     * @return Returns the image of the banner or null if the application has no
4151     *         banner specified.
4152     * @throws NameNotFoundException Thrown if the resources for the given
4153     *             application could not be loaded.
4154     * @see #getApplicationBanner(ApplicationInfo)
4155     */
4156    public abstract Drawable getApplicationBanner(String packageName)
4157            throws NameNotFoundException;
4158
4159    /**
4160     * Retrieve the logo associated with an activity. Given the full name of an
4161     * activity, retrieves the information about it and calls
4162     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4163     * logo. If the activity cannot be found, NameNotFoundException is thrown.
4164     *
4165     * @param activityName Name of the activity whose logo is to be retrieved.
4166     * @return Returns the image of the logo or null if the activity has no logo
4167     *         specified.
4168     * @throws NameNotFoundException Thrown if the resources for the given
4169     *             activity could not be loaded.
4170     * @see #getActivityLogo(Intent)
4171     */
4172    public abstract Drawable getActivityLogo(ComponentName activityName)
4173            throws NameNotFoundException;
4174
4175    /**
4176     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
4177     * set, this simply returns the result of
4178     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
4179     * component and returns the logo associated with the resolved component.
4180     * If intent.getClassName() cannot be found or the Intent cannot be resolved
4181     * to a component, NameNotFoundException is thrown.
4182     *
4183     * @param intent The intent for which you would like to retrieve a logo.
4184     *
4185     * @return Returns the image of the logo, or null if the activity has no
4186     * logo specified.
4187     *
4188     * @throws NameNotFoundException Thrown if the resources for application
4189     * matching the given intent could not be loaded.
4190     *
4191     * @see #getActivityLogo(ComponentName)
4192     */
4193    public abstract Drawable getActivityLogo(Intent intent)
4194            throws NameNotFoundException;
4195
4196    /**
4197     * Retrieve the logo associated with an application.  If it has not specified
4198     * a logo, this method returns null.
4199     *
4200     * @param info Information about application being queried.
4201     *
4202     * @return Returns the image of the logo, or null if no logo is specified
4203     * by the application.
4204     *
4205     * @see #getApplicationLogo(String)
4206     */
4207    public abstract Drawable getApplicationLogo(ApplicationInfo info);
4208
4209    /**
4210     * Retrieve the logo associated with an application.  Given the name of the
4211     * application's package, retrieves the information about it and calls
4212     * getApplicationLogo() to return its logo. If the application cannot be
4213     * found, NameNotFoundException is thrown.
4214     *
4215     * @param packageName Name of the package whose application logo is to be
4216     *                    retrieved.
4217     *
4218     * @return Returns the image of the logo, or null if no application logo
4219     * has been specified.
4220     *
4221     * @throws NameNotFoundException Thrown if the resources for the given
4222     * application could not be loaded.
4223     *
4224     * @see #getApplicationLogo(ApplicationInfo)
4225     */
4226    public abstract Drawable getApplicationLogo(String packageName)
4227            throws NameNotFoundException;
4228
4229    /**
4230     * If the target user is a managed profile of the calling user or if the
4231     * target user is the caller and is itself a managed profile, then this
4232     * returns a badged copy of the given icon to be able to distinguish it from
4233     * the original icon. For badging an arbitrary drawable use
4234     * {@link #getUserBadgedDrawableForDensity(
4235     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4236     * <p>
4237     * If the original drawable is a BitmapDrawable and the backing bitmap is
4238     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4239     * is performed in place and the original drawable is returned.
4240     * </p>
4241     *
4242     * @param icon The icon to badge.
4243     * @param user The target user.
4244     * @return A drawable that combines the original icon and a badge as
4245     *         determined by the system.
4246     */
4247    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4248
4249    /**
4250     * If the target user is a managed profile of the calling user or the caller
4251     * is itself a managed profile, then this returns a badged copy of the given
4252     * drawable allowing the user to distinguish it from the original drawable.
4253     * The caller can specify the location in the bounds of the drawable to be
4254     * badged where the badge should be applied as well as the density of the
4255     * badge to be used.
4256     * <p>
4257     * If the original drawable is a BitmapDrawable and the backing bitmap is
4258     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
4259     * is performed in place and the original drawable is returned.
4260     * </p>
4261     *
4262     * @param drawable The drawable to badge.
4263     * @param user The target user.
4264     * @param badgeLocation Where in the bounds of the badged drawable to place
4265     *         the badge. If not provided, the badge is applied on top of the entire
4266     *         drawable being badged.
4267     * @param badgeDensity The optional desired density for the badge as per
4268     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided,
4269     *         the density of the display is used.
4270     * @return A drawable that combines the original drawable and a badge as
4271     *         determined by the system.
4272     */
4273    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4274            UserHandle user, Rect badgeLocation, int badgeDensity);
4275
4276    /**
4277     * If the target user is a managed profile of the calling user or the caller
4278     * is itself a managed profile, then this returns a drawable to use as a small
4279     * icon to include in a view to distinguish it from the original icon.
4280     *
4281     * @param user The target user.
4282     * @param density The optional desired density for the badge as per
4283     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4284     *         the density of the current display is used.
4285     * @return the drawable or null if no drawable is required.
4286     * @hide
4287     */
4288    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4289
4290    /**
4291     * If the target user is a managed profile of the calling user or the caller
4292     * is itself a managed profile, then this returns a drawable to use as a small
4293     * icon to include in a view to distinguish it from the original icon. This version
4294     * doesn't have background protection and should be used over a light background instead of
4295     * a badge.
4296     *
4297     * @param user The target user.
4298     * @param density The optional desired density for the badge as per
4299     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
4300     *         the density of the current display is used.
4301     * @return the drawable or null if no drawable is required.
4302     * @hide
4303     */
4304    public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4305
4306    /**
4307     * If the target user is a managed profile of the calling user or the caller
4308     * is itself a managed profile, then this returns a copy of the label with
4309     * badging for accessibility services like talkback. E.g. passing in "Email"
4310     * and it might return "Work Email" for Email in the work profile.
4311     *
4312     * @param label The label to change.
4313     * @param user The target user.
4314     * @return A label that combines the original label and a badge as
4315     *         determined by the system.
4316     */
4317    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4318
4319    /**
4320     * Retrieve text from a package.  This is a low-level API used by
4321     * the various package manager info structures (such as
4322     * {@link ComponentInfo} to implement retrieval of their associated
4323     * labels and other text.
4324     *
4325     * @param packageName The name of the package that this text is coming from.
4326     * Cannot be null.
4327     * @param resid The resource identifier of the desired text.  Cannot be 0.
4328     * @param appInfo Overall information about <var>packageName</var>.  This
4329     * may be null, in which case the application information will be retrieved
4330     * for you if needed; if you already have this information around, it can
4331     * be much more efficient to supply it here.
4332     *
4333     * @return Returns a CharSequence holding the requested text.  Returns null
4334     * if the text could not be found for any reason.
4335     */
4336    public abstract CharSequence getText(String packageName, @StringRes int resid,
4337            ApplicationInfo appInfo);
4338
4339    /**
4340     * Retrieve an XML file from a package.  This is a low-level API used to
4341     * retrieve XML meta data.
4342     *
4343     * @param packageName The name of the package that this xml is coming from.
4344     * Cannot be null.
4345     * @param resid The resource identifier of the desired xml.  Cannot be 0.
4346     * @param appInfo Overall information about <var>packageName</var>.  This
4347     * may be null, in which case the application information will be retrieved
4348     * for you if needed; if you already have this information around, it can
4349     * be much more efficient to supply it here.
4350     *
4351     * @return Returns an XmlPullParser allowing you to parse out the XML
4352     * data.  Returns null if the xml resource could not be found for any
4353     * reason.
4354     */
4355    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
4356            ApplicationInfo appInfo);
4357
4358    /**
4359     * Return the label to use for this application.
4360     *
4361     * @return Returns the label associated with this application, or null if
4362     * it could not be found for any reason.
4363     * @param info The application to get the label of.
4364     */
4365    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4366
4367    /**
4368     * Retrieve the resources associated with an activity.  Given the full
4369     * name of an activity, retrieves the information about it and calls
4370     * getResources() to return its application's resources.  If the activity
4371     * cannot be found, NameNotFoundException is thrown.
4372     *
4373     * @param activityName Name of the activity whose resources are to be
4374     *                     retrieved.
4375     *
4376     * @return Returns the application's Resources.
4377     * @throws NameNotFoundException Thrown if the resources for the given
4378     * application could not be loaded.
4379     *
4380     * @see #getResourcesForApplication(ApplicationInfo)
4381     */
4382    public abstract Resources getResourcesForActivity(ComponentName activityName)
4383            throws NameNotFoundException;
4384
4385    /**
4386     * Retrieve the resources for an application.  Throws NameNotFoundException
4387     * if the package is no longer installed.
4388     *
4389     * @param app Information about the desired application.
4390     *
4391     * @return Returns the application's Resources.
4392     * @throws NameNotFoundException Thrown if the resources for the given
4393     * application could not be loaded (most likely because it was uninstalled).
4394     */
4395    public abstract Resources getResourcesForApplication(ApplicationInfo app)
4396            throws NameNotFoundException;
4397
4398    /**
4399     * Retrieve the resources associated with an application.  Given the full
4400     * package name of an application, retrieves the information about it and
4401     * calls getResources() to return its application's resources.  If the
4402     * appPackageName cannot be found, NameNotFoundException is thrown.
4403     *
4404     * @param appPackageName Package name of the application whose resources
4405     *                       are to be retrieved.
4406     *
4407     * @return Returns the application's Resources.
4408     * @throws NameNotFoundException Thrown if the resources for the given
4409     * application could not be loaded.
4410     *
4411     * @see #getResourcesForApplication(ApplicationInfo)
4412     */
4413    public abstract Resources getResourcesForApplication(String appPackageName)
4414            throws NameNotFoundException;
4415
4416    /** @hide */
4417    public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4418            @UserIdInt int userId) throws NameNotFoundException;
4419
4420    /**
4421     * Retrieve overall information about an application package defined
4422     * in a package archive file
4423     *
4424     * @param archiveFilePath The path to the archive file
4425     * @param flags Additional option flags. Use any combination of
4426     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
4427     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
4428     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
4429     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
4430     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
4431     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
4432     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
4433     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4434     *         {@link #MATCH_UNINSTALLED_PACKAGES}
4435     *         to modify the data returned.
4436     *
4437     * @return A PackageInfo object containing information about the
4438     *         package archive. If the package could not be parsed,
4439     *         returns null.
4440     *
4441     * @see #GET_ACTIVITIES
4442     * @see #GET_CONFIGURATIONS
4443     * @see #GET_GIDS
4444     * @see #GET_INSTRUMENTATION
4445     * @see #GET_INTENT_FILTERS
4446     * @see #GET_META_DATA
4447     * @see #GET_PERMISSIONS
4448     * @see #GET_PROVIDERS
4449     * @see #GET_RECEIVERS
4450     * @see #GET_SERVICES
4451     * @see #GET_SHARED_LIBRARY_FILES
4452     * @see #GET_SIGNATURES
4453     * @see #GET_URI_PERMISSION_PATTERNS
4454     * @see #MATCH_DISABLED_COMPONENTS
4455     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4456     * @see #MATCH_UNINSTALLED_PACKAGES
4457     *
4458     */
4459    public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
4460        final PackageParser parser = new PackageParser();
4461        final File apkFile = new File(archiveFilePath);
4462        try {
4463            if ((flags & (MATCH_ENCRYPTION_UNAWARE | MATCH_ENCRYPTION_AWARE)) != 0) {
4464                // Caller expressed an explicit opinion about what encryption
4465                // aware/unaware components they want to see, so fall through and
4466                // give them what they want
4467            } else {
4468                // Caller expressed no opinion, so match everything
4469                flags |= MATCH_ENCRYPTION_AWARE_AND_UNAWARE;
4470            }
4471
4472            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
4473            if ((flags & GET_SIGNATURES) != 0) {
4474                parser.collectCertificates(pkg, 0);
4475            }
4476            PackageUserState state = new PackageUserState();
4477            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4478        } catch (PackageParserException e) {
4479            return null;
4480        }
4481    }
4482
4483    /**
4484     * @deprecated replaced by {@link PackageInstaller}
4485     * @hide
4486     */
4487    @Deprecated
4488    public abstract void installPackage(
4489            Uri packageURI, IPackageInstallObserver observer, @InstallFlags int flags,
4490            String installerPackageName);
4491
4492    /**
4493     * @deprecated replaced by {@link PackageInstaller}
4494     * @hide
4495     */
4496    @Deprecated
4497    public abstract void installPackageWithVerification(Uri packageURI,
4498            IPackageInstallObserver observer, @InstallFlags int flags, String installerPackageName,
4499            Uri verificationURI, ContainerEncryptionParams encryptionParams);
4500
4501    /**
4502     * @deprecated replaced by {@link PackageInstaller}
4503     * @hide
4504     */
4505    @Deprecated
4506    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
4507            IPackageInstallObserver observer, @InstallFlags int flags, String installerPackageName,
4508            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
4509
4510    /**
4511     * @deprecated replaced by {@link PackageInstaller}
4512     * @hide
4513     */
4514    @Deprecated
4515    public abstract void installPackage(Uri packageURI, PackageInstallObserver observer,
4516            @InstallFlags int flags, String installerPackageName);
4517
4518    /**
4519     * @deprecated replaced by {@link PackageInstaller}
4520     * @hide
4521     */
4522    @Deprecated
4523    public abstract void installPackageAsUser(Uri packageURI, PackageInstallObserver observer,
4524            @InstallFlags int flags, String installerPackageName, @UserIdInt int userId);
4525
4526    /**
4527     * @deprecated replaced by {@link PackageInstaller}
4528     * @hide
4529     */
4530    @Deprecated
4531    public abstract void installPackageWithVerification(Uri packageURI,
4532            PackageInstallObserver observer, @InstallFlags int flags, String installerPackageName,
4533            Uri verificationURI, ContainerEncryptionParams encryptionParams);
4534
4535    /**
4536     * @deprecated replaced by {@link PackageInstaller}
4537     * @hide
4538     */
4539    @Deprecated
4540    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
4541            PackageInstallObserver observer, @InstallFlags int flags, String installerPackageName,
4542            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
4543
4544    /**
4545     * If there is already an application with the given package name installed
4546     * on the system for other users, also install it for the calling user.
4547     * @hide
4548     */
4549    public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
4550
4551    /**
4552     * If there is already an application with the given package name installed
4553     * on the system for other users, also install it for the specified user.
4554     * @hide
4555     */
4556     @RequiresPermission(anyOf = {
4557            Manifest.permission.INSTALL_PACKAGES,
4558            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4559    public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
4560            throws NameNotFoundException;
4561
4562    /**
4563     * Allows a package listening to the
4564     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4565     * broadcast} to respond to the package manager. The response must include
4566     * the {@code verificationCode} which is one of
4567     * {@link PackageManager#VERIFICATION_ALLOW} or
4568     * {@link PackageManager#VERIFICATION_REJECT}.
4569     *
4570     * @param id pending package identifier as passed via the
4571     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4572     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
4573     *            or {@link PackageManager#VERIFICATION_REJECT}.
4574     * @throws SecurityException if the caller does not have the
4575     *            PACKAGE_VERIFICATION_AGENT permission.
4576     */
4577    public abstract void verifyPendingInstall(int id, int verificationCode);
4578
4579    /**
4580     * Allows a package listening to the
4581     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4582     * broadcast} to extend the default timeout for a response and declare what
4583     * action to perform after the timeout occurs. The response must include
4584     * the {@code verificationCodeAtTimeout} which is one of
4585     * {@link PackageManager#VERIFICATION_ALLOW} or
4586     * {@link PackageManager#VERIFICATION_REJECT}.
4587     *
4588     * This method may only be called once per package id. Additional calls
4589     * will have no effect.
4590     *
4591     * @param id pending package identifier as passed via the
4592     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4593     * @param verificationCodeAtTimeout either
4594     *            {@link PackageManager#VERIFICATION_ALLOW} or
4595     *            {@link PackageManager#VERIFICATION_REJECT}. If
4596     *            {@code verificationCodeAtTimeout} is neither
4597     *            {@link PackageManager#VERIFICATION_ALLOW} or
4598     *            {@link PackageManager#VERIFICATION_REJECT}, then
4599     *            {@code verificationCodeAtTimeout} will default to
4600     *            {@link PackageManager#VERIFICATION_REJECT}.
4601     * @param millisecondsToDelay the amount of time requested for the timeout.
4602     *            Must be positive and less than
4603     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4604     *            {@code millisecondsToDelay} is out of bounds,
4605     *            {@code millisecondsToDelay} will be set to the closest in
4606     *            bounds value; namely, 0 or
4607     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
4608     * @throws SecurityException if the caller does not have the
4609     *            PACKAGE_VERIFICATION_AGENT permission.
4610     */
4611    public abstract void extendVerificationTimeout(int id,
4612            int verificationCodeAtTimeout, long millisecondsToDelay);
4613
4614    /**
4615     * Allows a package listening to the
4616     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification
4617     * broadcast} to respond to the package manager. The response must include
4618     * the {@code verificationCode} which is one of
4619     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4620     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4621     *
4622     * @param verificationId pending package identifier as passed via the
4623     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4624     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4625     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4626     * @param outFailedDomains a list of failed domains if the verificationCode is
4627     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4628     * @throws SecurityException if the caller does not have the
4629     *            INTENT_FILTER_VERIFICATION_AGENT permission.
4630     *
4631     * @hide
4632     */
4633    @SystemApi
4634    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
4635            List<String> outFailedDomains);
4636
4637    /**
4638     * Get the status of a Domain Verification Result for an IntentFilter. This is
4639     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4640     * {@link android.content.IntentFilter#getAutoVerify()}
4641     *
4642     * This is used by the ResolverActivity to change the status depending on what the User select
4643     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4644     * for a domain.
4645     *
4646     * @param packageName The package name of the Activity associated with the IntentFilter.
4647     * @param userId The user id.
4648     *
4649     * @return The status to set to. This can be
4650     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4651     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4652     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4653     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4654     *
4655     * @hide
4656     */
4657    public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
4658
4659    /**
4660     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4661     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4662     * {@link android.content.IntentFilter#getAutoVerify()}
4663     *
4664     * This is used by the ResolverActivity to change the status depending on what the User select
4665     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4666     * for a domain.
4667     *
4668     * @param packageName The package name of the Activity associated with the IntentFilter.
4669     * @param status The status to set to. This can be
4670     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4671     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4672     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4673     * @param userId The user id.
4674     *
4675     * @return true if the status has been set. False otherwise.
4676     *
4677     * @hide
4678     */
4679    public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
4680            @UserIdInt int userId);
4681
4682    /**
4683     * Get the list of IntentFilterVerificationInfo for a specific package and User.
4684     *
4685     * @param packageName the package name. When this parameter is set to a non null value,
4686     *                    the results will be filtered by the package name provided.
4687     *                    Otherwise, there will be no filtering and it will return a list
4688     *                    corresponding for all packages
4689     *
4690     * @return a list of IntentFilterVerificationInfo for a specific package.
4691     *
4692     * @hide
4693     */
4694    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4695            String packageName);
4696
4697    /**
4698     * Get the list of IntentFilter for a specific package.
4699     *
4700     * @param packageName the package name. This parameter is set to a non null value,
4701     *                    the list will contain all the IntentFilter for that package.
4702     *                    Otherwise, the list will be empty.
4703     *
4704     * @return a list of IntentFilter for a specific package.
4705     *
4706     * @hide
4707     */
4708    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4709
4710    /**
4711     * Get the default Browser package name for a specific user.
4712     *
4713     * @param userId The user id.
4714     *
4715     * @return the package name of the default Browser for the specified user. If the user id passed
4716     *         is -1 (all users) it will return a null value.
4717     *
4718     * @hide
4719     */
4720    @TestApi
4721    public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
4722
4723    /**
4724     * Set the default Browser package name for a specific user.
4725     *
4726     * @param packageName The package name of the default Browser.
4727     * @param userId The user id.
4728     *
4729     * @return true if the default Browser for the specified user has been set,
4730     *         otherwise return false. If the user id passed is -1 (all users) this call will not
4731     *         do anything and just return false.
4732     *
4733     * @hide
4734     */
4735    public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
4736            @UserIdInt int userId);
4737
4738    /**
4739     * Change the installer associated with a given package.  There are limitations
4740     * on how the installer package can be changed; in particular:
4741     * <ul>
4742     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
4743     * is not signed with the same certificate as the calling application.
4744     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
4745     * has an installer package, and that installer package is not signed with
4746     * the same certificate as the calling application.
4747     * </ul>
4748     *
4749     * @param targetPackage The installed package whose installer will be changed.
4750     * @param installerPackageName The package name of the new installer.  May be
4751     * null to clear the association.
4752     */
4753    public abstract void setInstallerPackageName(String targetPackage,
4754            String installerPackageName);
4755
4756    /**
4757     * Attempts to delete a package. Since this may take a little while, the
4758     * result will be posted back to the given observer. A deletion will fail if
4759     * the calling context lacks the
4760     * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
4761     * named package cannot be found, or if the named package is a system
4762     * package.
4763     *
4764     * @param packageName The name of the package to delete
4765     * @param observer An observer callback to get notified when the package
4766     *            deletion is complete.
4767     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
4768     *            will be called when that happens. observer may be null to
4769     *            indicate that no callback is desired.
4770     * @hide
4771     */
4772    public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
4773            @DeleteFlags int flags);
4774
4775    /**
4776     * Attempts to delete a package. Since this may take a little while, the
4777     * result will be posted back to the given observer. A deletion will fail if
4778     * the named package cannot be found, or if the named package is a system
4779     * package.
4780     *
4781     * @param packageName The name of the package to delete
4782     * @param observer An observer callback to get notified when the package
4783     *            deletion is complete.
4784     *            {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
4785     *            will be called when that happens. observer may be null to
4786     *            indicate that no callback is desired.
4787     * @param userId The user Id
4788     * @hide
4789     */
4790     @RequiresPermission(anyOf = {
4791            Manifest.permission.DELETE_PACKAGES,
4792            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4793    public abstract void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
4794            @DeleteFlags int flags, @UserIdInt int userId);
4795
4796    /**
4797     * Retrieve the package name of the application that installed a package. This identifies
4798     * which market the package came from.
4799     *
4800     * @param packageName The name of the package to query
4801     */
4802    public abstract String getInstallerPackageName(String packageName);
4803
4804    /**
4805     * Attempts to clear the user data directory of an application.
4806     * Since this may take a little while, the result will
4807     * be posted back to the given observer.  A deletion will fail if the
4808     * named package cannot be found, or if the named package is a "system package".
4809     *
4810     * @param packageName The name of the package
4811     * @param observer An observer callback to get notified when the operation is finished
4812     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4813     * will be called when that happens.  observer may be null to indicate that
4814     * no callback is desired.
4815     *
4816     * @hide
4817     */
4818    public abstract void clearApplicationUserData(String packageName,
4819            IPackageDataObserver observer);
4820    /**
4821     * Attempts to delete the cache files associated with an application.
4822     * Since this may take a little while, the result will
4823     * be posted back to the given observer.  A deletion will fail if the calling context
4824     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
4825     * named package cannot be found, or if the named package is a "system package".
4826     *
4827     * @param packageName The name of the package to delete
4828     * @param observer An observer callback to get notified when the cache file deletion
4829     * is complete.
4830     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4831     * will be called when that happens.  observer may be null to indicate that
4832     * no callback is desired.
4833     *
4834     * @hide
4835     */
4836    public abstract void deleteApplicationCacheFiles(String packageName,
4837            IPackageDataObserver observer);
4838
4839    /**
4840     * Free storage by deleting LRU sorted list of cache files across
4841     * all applications. If the currently available free storage
4842     * on the device is greater than or equal to the requested
4843     * free storage, no cache files are cleared. If the currently
4844     * available storage on the device is less than the requested
4845     * free storage, some or all of the cache files across
4846     * all applications are deleted (based on last accessed time)
4847     * to increase the free storage space on the device to
4848     * the requested value. There is no guarantee that clearing all
4849     * the cache files from all applications will clear up
4850     * enough storage to achieve the desired value.
4851     * @param freeStorageSize The number of bytes of storage to be
4852     * freed by the system. Say if freeStorageSize is XX,
4853     * and the current free storage is YY,
4854     * if XX is less than YY, just return. if not free XX-YY number
4855     * of bytes if possible.
4856     * @param observer call back used to notify when
4857     * the operation is completed
4858     *
4859     * @hide
4860     */
4861    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
4862        freeStorageAndNotify(null, freeStorageSize, observer);
4863    }
4864
4865    /** {@hide} */
4866    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
4867            IPackageDataObserver observer);
4868
4869    /**
4870     * Free storage by deleting LRU sorted list of cache files across
4871     * all applications. If the currently available free storage
4872     * on the device is greater than or equal to the requested
4873     * free storage, no cache files are cleared. If the currently
4874     * available storage on the device is less than the requested
4875     * free storage, some or all of the cache files across
4876     * all applications are deleted (based on last accessed time)
4877     * to increase the free storage space on the device to
4878     * the requested value. There is no guarantee that clearing all
4879     * the cache files from all applications will clear up
4880     * enough storage to achieve the desired value.
4881     * @param freeStorageSize The number of bytes of storage to be
4882     * freed by the system. Say if freeStorageSize is XX,
4883     * and the current free storage is YY,
4884     * if XX is less than YY, just return. if not free XX-YY number
4885     * of bytes if possible.
4886     * @param pi IntentSender call back used to
4887     * notify when the operation is completed.May be null
4888     * to indicate that no call back is desired.
4889     *
4890     * @hide
4891     */
4892    public void freeStorage(long freeStorageSize, IntentSender pi) {
4893        freeStorage(null, freeStorageSize, pi);
4894    }
4895
4896    /** {@hide} */
4897    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
4898
4899    /**
4900     * Retrieve the size information for a package.
4901     * Since this may take a little while, the result will
4902     * be posted back to the given observer.  The calling context
4903     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
4904     *
4905     * @param packageName The name of the package whose size information is to be retrieved
4906     * @param userId The user whose size information should be retrieved.
4907     * @param observer An observer callback to get notified when the operation
4908     * is complete.
4909     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
4910     * The observer's callback is invoked with a PackageStats object(containing the
4911     * code, data and cache sizes of the package) and a boolean value representing
4912     * the status of the operation. observer may be null to indicate that
4913     * no callback is desired.
4914     *
4915     * @hide
4916     */
4917    public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
4918            IPackageStatsObserver observer);
4919
4920    /**
4921     * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
4922     * returns the size for the calling user.
4923     *
4924     * @hide
4925     */
4926    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
4927        getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer);
4928    }
4929
4930    /**
4931     * @deprecated This function no longer does anything; it was an old
4932     * approach to managing preferred activities, which has been superseded
4933     * by (and conflicts with) the modern activity-based preferences.
4934     */
4935    @Deprecated
4936    public abstract void addPackageToPreferred(String packageName);
4937
4938    /**
4939     * @deprecated This function no longer does anything; it was an old
4940     * approach to managing preferred activities, which has been superseded
4941     * by (and conflicts with) the modern activity-based preferences.
4942     */
4943    @Deprecated
4944    public abstract void removePackageFromPreferred(String packageName);
4945
4946    /**
4947     * Retrieve the list of all currently configured preferred packages.  The
4948     * first package on the list is the most preferred, the last is the
4949     * least preferred.
4950     *
4951     * @param flags Additional option flags. Use any combination of
4952     *         {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
4953     *         {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
4954     *         {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
4955     *         {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
4956     *         {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
4957     *         {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
4958     *         {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
4959     *         {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4960     *         {@link #MATCH_UNINSTALLED_PACKAGES}
4961     *         to modify the data returned.
4962     *
4963     * @return A List of PackageInfo objects, one for each preferred application,
4964     *         in order of preference.
4965     *
4966     * @see #GET_ACTIVITIES
4967     * @see #GET_CONFIGURATIONS
4968     * @see #GET_GIDS
4969     * @see #GET_INSTRUMENTATION
4970     * @see #GET_INTENT_FILTERS
4971     * @see #GET_META_DATA
4972     * @see #GET_PERMISSIONS
4973     * @see #GET_PROVIDERS
4974     * @see #GET_RECEIVERS
4975     * @see #GET_SERVICES
4976     * @see #GET_SHARED_LIBRARY_FILES
4977     * @see #GET_SIGNATURES
4978     * @see #GET_URI_PERMISSION_PATTERNS
4979     * @see #MATCH_DISABLED_COMPONENTS
4980     * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4981     * @see #MATCH_UNINSTALLED_PACKAGES
4982     */
4983    public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
4984
4985    /**
4986     * @deprecated This is a protected API that should not have been available
4987     * to third party applications.  It is the platform's responsibility for
4988     * assigning preferred activities and this cannot be directly modified.
4989     *
4990     * Add a new preferred activity mapping to the system.  This will be used
4991     * to automatically select the given activity component when
4992     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4993     * multiple matching activities and also matches the given filter.
4994     *
4995     * @param filter The set of intents under which this activity will be
4996     * made preferred.
4997     * @param match The IntentFilter match category that this preference
4998     * applies to.
4999     * @param set The set of activities that the user was picking from when
5000     * this preference was made.
5001     * @param activity The component name of the activity that is to be
5002     * preferred.
5003     */
5004    @Deprecated
5005    public abstract void addPreferredActivity(IntentFilter filter, int match,
5006            ComponentName[] set, ComponentName activity);
5007
5008    /**
5009     * Same as {@link #addPreferredActivity(IntentFilter, int,
5010            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5011            to.
5012     * @hide
5013     */
5014    public void addPreferredActivityAsUser(IntentFilter filter, int match,
5015            ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5016        throw new RuntimeException("Not implemented. Must override in a subclass.");
5017    }
5018
5019    /**
5020     * @deprecated This is a protected API that should not have been available
5021     * to third party applications.  It is the platform's responsibility for
5022     * assigning preferred activities and this cannot be directly modified.
5023     *
5024     * Replaces an existing preferred activity mapping to the system, and if that were not present
5025     * adds a new preferred activity.  This will be used
5026     * to automatically select the given activity component when
5027     * {@link Context#startActivity(Intent) Context.startActivity()} finds
5028     * multiple matching activities and also matches the given filter.
5029     *
5030     * @param filter The set of intents under which this activity will be
5031     * made preferred.
5032     * @param match The IntentFilter match category that this preference
5033     * applies to.
5034     * @param set The set of activities that the user was picking from when
5035     * this preference was made.
5036     * @param activity The component name of the activity that is to be
5037     * preferred.
5038     * @hide
5039     */
5040    @Deprecated
5041    public abstract void replacePreferredActivity(IntentFilter filter, int match,
5042            ComponentName[] set, ComponentName activity);
5043
5044    /**
5045     * @hide
5046     */
5047    @Deprecated
5048    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
5049           ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5050        throw new RuntimeException("Not implemented. Must override in a subclass.");
5051    }
5052
5053    /**
5054     * Remove all preferred activity mappings, previously added with
5055     * {@link #addPreferredActivity}, from the
5056     * system whose activities are implemented in the given package name.
5057     * An application can only clear its own package(s).
5058     *
5059     * @param packageName The name of the package whose preferred activity
5060     * mappings are to be removed.
5061     */
5062    public abstract void clearPackagePreferredActivities(String packageName);
5063
5064    /**
5065     * Retrieve all preferred activities, previously added with
5066     * {@link #addPreferredActivity}, that are
5067     * currently registered with the system.
5068     *
5069     * @param outFilters A required list in which to place the filters of all of the
5070     * preferred activities.
5071     * @param outActivities A required list in which to place the component names of
5072     * all of the preferred activities.
5073     * @param packageName An optional package in which you would like to limit
5074     * the list.  If null, all activities will be returned; if non-null, only
5075     * those activities in the given package are returned.
5076     *
5077     * @return Returns the total number of registered preferred activities
5078     * (the number of distinct IntentFilter records, not the number of unique
5079     * activity components) that were found.
5080     */
5081    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5082            @NonNull List<ComponentName> outActivities, String packageName);
5083
5084    /**
5085     * Ask for the set of available 'home' activities and the current explicit
5086     * default, if any.
5087     * @hide
5088     */
5089    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5090
5091    /**
5092     * Set the enabled setting for a package component (activity, receiver, service, provider).
5093     * This setting will override any enabled state which may have been set by the component in its
5094     * manifest.
5095     *
5096     * @param componentName The component to enable
5097     * @param newState The new enabled state for the component.  The legal values for this state
5098     *                 are:
5099     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
5100     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
5101     *                   and
5102     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5103     *                 The last one removes the setting, thereby restoring the component's state to
5104     *                 whatever was set in it's manifest (or enabled, by default).
5105     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5106     */
5107    public abstract void setComponentEnabledSetting(ComponentName componentName,
5108            int newState, int flags);
5109
5110
5111    /**
5112     * Return the enabled setting for a package component (activity,
5113     * receiver, service, provider).  This returns the last value set by
5114     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5115     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5116     * the value originally specified in the manifest has not been modified.
5117     *
5118     * @param componentName The component to retrieve.
5119     * @return Returns the current enabled state for the component.  May
5120     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5121     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5122     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
5123     * component's enabled state is based on the original information in
5124     * the manifest as found in {@link ComponentInfo}.
5125     */
5126    public abstract int getComponentEnabledSetting(ComponentName componentName);
5127
5128    /**
5129     * Set the enabled setting for an application
5130     * This setting will override any enabled state which may have been set by the application in
5131     * its manifest.  It also overrides the enabled state set in the manifest for any of the
5132     * application's components.  It does not override any enabled state set by
5133     * {@link #setComponentEnabledSetting} for any of the application's components.
5134     *
5135     * @param packageName The package name of the application to enable
5136     * @param newState The new enabled state for the component.  The legal values for this state
5137     *                 are:
5138     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
5139     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
5140     *                   and
5141     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5142     *                 The last one removes the setting, thereby restoring the applications's state to
5143     *                 whatever was set in its manifest (or enabled, by default).
5144     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5145     */
5146    public abstract void setApplicationEnabledSetting(String packageName,
5147            int newState, int flags);
5148
5149    /**
5150     * Return the enabled setting for an application. This returns
5151     * the last value set by
5152     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5153     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5154     * the value originally specified in the manifest has not been modified.
5155     *
5156     * @param packageName The package name of the application to retrieve.
5157     * @return Returns the current enabled state for the application.  May
5158     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5159     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5160     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
5161     * application's enabled state is based on the original information in
5162     * the manifest as found in {@link ComponentInfo}.
5163     * @throws IllegalArgumentException if the named package does not exist.
5164     */
5165    public abstract int getApplicationEnabledSetting(String packageName);
5166
5167    /**
5168     * Puts the package in a hidden state, which is almost like an uninstalled state,
5169     * making the package unavailable, but it doesn't remove the data or the actual
5170     * package file. Application can be unhidden by either resetting the hidden state
5171     * or by installing it, such as with {@link #installExistingPackage(String)}
5172     * @hide
5173     */
5174    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
5175            UserHandle userHandle);
5176
5177    /**
5178     * Returns the hidden state of a package.
5179     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
5180     * @hide
5181     */
5182    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
5183            UserHandle userHandle);
5184
5185    /**
5186     * Return whether the device has been booted into safe mode.
5187     */
5188    public abstract boolean isSafeMode();
5189
5190    /**
5191     * Adds a listener for permission changes for installed packages.
5192     *
5193     * @param listener The listener to add.
5194     *
5195     * @hide
5196     */
5197    @SystemApi
5198    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5199    public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5200
5201    /**
5202     * Remvoes a listener for permission changes for installed packages.
5203     *
5204     * @param listener The listener to remove.
5205     *
5206     * @hide
5207     */
5208    @SystemApi
5209    public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5210
5211    /**
5212     * Return the {@link KeySet} associated with the String alias for this
5213     * application.
5214     *
5215     * @param alias The alias for a given {@link KeySet} as defined in the
5216     *        application's AndroidManifest.xml.
5217     * @hide
5218     */
5219    public abstract KeySet getKeySetByAlias(String packageName, String alias);
5220
5221    /** Return the signing {@link KeySet} for this application.
5222     * @hide
5223     */
5224    public abstract KeySet getSigningKeySet(String packageName);
5225
5226    /**
5227     * Return whether the package denoted by packageName has been signed by all
5228     * of the keys specified by the {@link KeySet} ks.  This will return true if
5229     * the package has been signed by additional keys (a superset) as well.
5230     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
5231     * @hide
5232     */
5233    public abstract boolean isSignedBy(String packageName, KeySet ks);
5234
5235    /**
5236     * Return whether the package denoted by packageName has been signed by all
5237     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5238     * {@link #isSignedBy(String packageName, KeySet ks)}.
5239     * @hide
5240     */
5241    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5242
5243    /**
5244     * Puts the package in a suspended state, making the package un-runnable,
5245     * but it doesn't remove the data or the actual package file. The application notifications
5246     * will be hidden and also the application will not show up in recents.
5247     *
5248     * @param packageName The name of the package to set the suspended status.
5249     * @param suspended If set to {@code true} than the package will be suspended, if set to
5250     * {@code false} the package will be unsuspended.
5251     * @param userId The user id.
5252     *
5253     * @hide
5254     */
5255    public abstract boolean setPackageSuspendedAsUser(
5256            String packageName, boolean suspended, @UserIdInt int userId);
5257
5258    /** {@hide} */
5259    public static boolean isMoveStatusFinished(int status) {
5260        return (status < 0 || status > 100);
5261    }
5262
5263    /** {@hide} */
5264    public static abstract class MoveCallback {
5265        public void onCreated(int moveId, Bundle extras) {}
5266        public abstract void onStatusChanged(int moveId, int status, long estMillis);
5267    }
5268
5269    /** {@hide} */
5270    public abstract int getMoveStatus(int moveId);
5271
5272    /** {@hide} */
5273    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5274    /** {@hide} */
5275    public abstract void unregisterMoveCallback(MoveCallback callback);
5276
5277    /** {@hide} */
5278    public abstract int movePackage(String packageName, VolumeInfo vol);
5279    /** {@hide} */
5280    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5281    /** {@hide} */
5282    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5283
5284    /** {@hide} */
5285    public abstract int movePrimaryStorage(VolumeInfo vol);
5286    /** {@hide} */
5287    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5288    /** {@hide} */
5289    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
5290
5291    /**
5292     * Returns the device identity that verifiers can use to associate their scheme to a particular
5293     * device. This should not be used by anything other than a package verifier.
5294     *
5295     * @return identity that uniquely identifies current device
5296     * @hide
5297     */
5298    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
5299
5300    /**
5301     * Returns true if the device is upgrading, such as first boot after OTA.
5302     *
5303     * @hide
5304     */
5305    public abstract boolean isUpgrade();
5306
5307    /**
5308     * Return interface that offers the ability to install, upgrade, and remove
5309     * applications on the device.
5310     */
5311    public abstract @NonNull PackageInstaller getPackageInstaller();
5312
5313    /**
5314     * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5315     * intents sent from the user with id sourceUserId can also be be resolved
5316     * by activities in the user with id targetUserId if they match the
5317     * specified intent filter.
5318     *
5319     * @param filter The {@link IntentFilter} the intent has to match
5320     * @param sourceUserId The source user id.
5321     * @param targetUserId The target user id.
5322     * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5323     *            {@link #ONLY_IF_NO_MATCH_FOUND}.
5324     * @hide
5325     */
5326    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5327            int targetUserId, int flags);
5328
5329    /**
5330     * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5331     * as their source, and have been set by the app calling this method.
5332     *
5333     * @param sourceUserId The source user id.
5334     * @hide
5335     */
5336    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
5337
5338    /**
5339     * @hide
5340     */
5341    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5342
5343    /**
5344     * @hide
5345     */
5346    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5347
5348    /** {@hide} */
5349    public abstract boolean isPackageAvailable(String packageName);
5350
5351    /** {@hide} */
5352    public static String installStatusToString(int status, String msg) {
5353        final String str = installStatusToString(status);
5354        if (msg != null) {
5355            return str + ": " + msg;
5356        } else {
5357            return str;
5358        }
5359    }
5360
5361    /** {@hide} */
5362    public static String installStatusToString(int status) {
5363        switch (status) {
5364            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5365            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5366            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5367            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5368            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5369            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5370            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5371            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5372            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5373            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5374            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5375            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5376            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5377            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5378            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5379            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5380            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5381            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5382            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5383            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5384            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5385            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5386            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5387            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5388            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5389            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5390            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5391            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5392            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5393            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5394            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5395            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5396            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5397            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5398            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5399            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5400            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5401            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5402            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5403            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
5404            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
5405            default: return Integer.toString(status);
5406        }
5407    }
5408
5409    /** {@hide} */
5410    public static int installStatusToPublicStatus(int status) {
5411        switch (status) {
5412            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5413            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5414            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5415            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5416            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5417            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5418            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5419            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5420            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5421            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5422            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5423            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5424            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5425            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5426            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5427            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5428            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5429            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5430            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5431            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5432            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5433            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5434            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5435            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5436            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5437            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5438            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5439            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5440            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5441            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5442            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5443            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5444            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5445            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5446            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5447            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5448            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
5449            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5450            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5451            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5452            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5453            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5454            default: return PackageInstaller.STATUS_FAILURE;
5455        }
5456    }
5457
5458    /** {@hide} */
5459    public static String deleteStatusToString(int status, String msg) {
5460        final String str = deleteStatusToString(status);
5461        if (msg != null) {
5462            return str + ": " + msg;
5463        } else {
5464            return str;
5465        }
5466    }
5467
5468    /** {@hide} */
5469    public static String deleteStatusToString(int status) {
5470        switch (status) {
5471            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5472            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5473            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5474            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5475            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
5476            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
5477            default: return Integer.toString(status);
5478        }
5479    }
5480
5481    /** {@hide} */
5482    public static int deleteStatusToPublicStatus(int status) {
5483        switch (status) {
5484            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5485            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5486            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5487            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5488            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5489            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5490            default: return PackageInstaller.STATUS_FAILURE;
5491        }
5492    }
5493
5494    /** {@hide} */
5495    public static String permissionFlagToString(int flag) {
5496        switch (flag) {
5497            case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
5498            case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
5499            case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
5500            case FLAG_PERMISSION_USER_SET: return "USER_SET";
5501            case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
5502            case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
5503            case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
5504            default: return Integer.toString(flag);
5505        }
5506    }
5507
5508    /** {@hide} */
5509    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
5510        private final IPackageInstallObserver mLegacy;
5511
5512        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
5513            mLegacy = legacy;
5514        }
5515
5516        @Override
5517        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
5518                Bundle extras) {
5519            if (mLegacy == null) return;
5520            try {
5521                mLegacy.packageInstalled(basePackageName, returnCode);
5522            } catch (RemoteException ignored) {
5523            }
5524        }
5525    }
5526
5527    /** {@hide} */
5528    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
5529        private final IPackageDeleteObserver mLegacy;
5530
5531        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
5532            mLegacy = legacy;
5533        }
5534
5535        @Override
5536        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
5537            if (mLegacy == null) return;
5538            try {
5539                mLegacy.packageDeleted(basePackageName, returnCode);
5540            } catch (RemoteException ignored) {
5541            }
5542        }
5543    }
5544}
5545