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