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