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