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