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