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