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