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