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