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