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