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