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