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