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