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