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