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