2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.content.pm;
19 import android.Manifest;
20 import android.annotation.CheckResult;
21 import android.annotation.DrawableRes;
22 import android.annotation.IntDef;
23 import android.annotation.NonNull;
24 import android.annotation.Nullable;
25 import android.annotation.RequiresPermission;
26 import android.annotation.SdkConstant;
27 import android.annotation.SdkConstant.SdkConstantType;
28 import android.annotation.StringRes;
29 import android.annotation.SystemApi;
30 import android.annotation.TestApi;
31 import android.annotation.UserIdInt;
32 import android.annotation.XmlRes;
33 import android.app.PackageDeleteObserver;
34 import android.app.PackageInstallObserver;
35 import android.app.admin.DevicePolicyManager;
36 import android.content.ComponentName;
37 import android.content.Context;
38 import android.content.Intent;
39 import android.content.IntentFilter;
40 import android.content.IntentSender;
41 import android.content.pm.PackageParser.PackageParserException;
42 import android.content.res.Resources;
43 import android.content.res.XmlResourceParser;
44 import android.graphics.Rect;
45 import android.graphics.drawable.Drawable;
46 import android.net.Uri;
47 import android.os.Bundle;
48 import android.os.Handler;
49 import android.os.RemoteException;
50 import android.os.UserHandle;
51 import android.os.UserManager;
52 import android.os.storage.VolumeInfo;
53 import android.util.AndroidException;
54 import android.util.Log;
56 import com.android.internal.util.ArrayUtils;
59 import java.lang.annotation.Retention;
60 import java.lang.annotation.RetentionPolicy;
61 import java.util.List;
64 * Class for retrieving various kinds of information related to the application
65 * packages that are currently installed on the device.
67 * You can find this class through {@link Context#getPackageManager}.
69 public abstract class PackageManager {
70 private static final String TAG = "PackageManager";
73 public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true;
76 * This exception is thrown when a given package, application, or component
77 * name cannot be found.
79 public static class NameNotFoundException extends AndroidException {
80 public NameNotFoundException() {
83 public NameNotFoundException(String name) {
89 * Listener for changes in permissions granted to a UID.
94 public interface OnPermissionsChangedListener {
97 * Called when the permissions for a UID change.
98 * @param uid The UID with a change.
100 public void onPermissionsChanged(int uid);
104 * As a guiding principle:
106 * {@code GET_} flags are used to request additional data that may have been
107 * elided to save wire space.
109 * {@code MATCH_} flags are used to include components or packages that
110 * would have otherwise been omitted from a result set by current system
115 @IntDef(flag = true, value = {
126 GET_SHARED_LIBRARY_FILES,
128 GET_URI_PERMISSION_PATTERNS,
129 MATCH_UNINSTALLED_PACKAGES,
130 MATCH_DISABLED_COMPONENTS,
131 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
134 MATCH_DEBUG_TRIAGED_MISSING,
135 GET_DISABLED_COMPONENTS,
136 GET_DISABLED_UNTIL_USED_COMPONENTS,
137 GET_UNINSTALLED_PACKAGES,
139 @Retention(RetentionPolicy.SOURCE)
140 public @interface PackageInfoFlags {}
143 @IntDef(flag = true, value = {
145 GET_SHARED_LIBRARY_FILES,
146 MATCH_UNINSTALLED_PACKAGES,
148 MATCH_DEBUG_TRIAGED_MISSING,
149 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
150 GET_DISABLED_UNTIL_USED_COMPONENTS,
151 GET_UNINSTALLED_PACKAGES,
153 @Retention(RetentionPolicy.SOURCE)
154 public @interface ApplicationInfoFlags {}
157 @IntDef(flag = true, value = {
159 GET_SHARED_LIBRARY_FILES,
161 MATCH_DEBUG_TRIAGED_MISSING,
163 MATCH_DISABLED_COMPONENTS,
164 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
165 MATCH_DIRECT_BOOT_AWARE,
166 MATCH_DIRECT_BOOT_UNAWARE,
168 MATCH_UNINSTALLED_PACKAGES,
169 GET_DISABLED_COMPONENTS,
170 GET_DISABLED_UNTIL_USED_COMPONENTS,
171 GET_UNINSTALLED_PACKAGES,
173 @Retention(RetentionPolicy.SOURCE)
174 public @interface ComponentInfoFlags {}
177 @IntDef(flag = true, value = {
180 GET_SHARED_LIBRARY_FILES,
182 MATCH_DEBUG_TRIAGED_MISSING,
183 MATCH_DISABLED_COMPONENTS,
184 MATCH_DISABLED_UNTIL_USED_COMPONENTS,
186 MATCH_DIRECT_BOOT_AWARE,
187 MATCH_DIRECT_BOOT_UNAWARE,
189 MATCH_UNINSTALLED_PACKAGES,
190 GET_DISABLED_COMPONENTS,
191 GET_DISABLED_UNTIL_USED_COMPONENTS,
192 GET_UNINSTALLED_PACKAGES,
194 @Retention(RetentionPolicy.SOURCE)
195 public @interface ResolveInfoFlags {}
198 @IntDef(flag = true, value = {
201 @Retention(RetentionPolicy.SOURCE)
202 public @interface PermissionInfoFlags {}
205 @IntDef(flag = true, value = {
208 @Retention(RetentionPolicy.SOURCE)
209 public @interface PermissionGroupInfoFlags {}
212 @IntDef(flag = true, value = {
215 @Retention(RetentionPolicy.SOURCE)
216 public @interface InstrumentationInfoFlags {}
219 * {@link PackageInfo} flag: return information about
220 * activities in the package in {@link PackageInfo#activities}.
222 public static final int GET_ACTIVITIES = 0x00000001;
225 * {@link PackageInfo} flag: return information about
226 * intent receivers in the package in
227 * {@link PackageInfo#receivers}.
229 public static final int GET_RECEIVERS = 0x00000002;
232 * {@link PackageInfo} flag: return information about
233 * services in the package in {@link PackageInfo#services}.
235 public static final int GET_SERVICES = 0x00000004;
238 * {@link PackageInfo} flag: return information about
239 * content providers in the package in
240 * {@link PackageInfo#providers}.
242 public static final int GET_PROVIDERS = 0x00000008;
245 * {@link PackageInfo} flag: return information about
246 * instrumentation in the package in
247 * {@link PackageInfo#instrumentation}.
249 public static final int GET_INSTRUMENTATION = 0x00000010;
252 * {@link PackageInfo} flag: return information about the
253 * intent filters supported by the activity.
255 public static final int GET_INTENT_FILTERS = 0x00000020;
258 * {@link PackageInfo} flag: return information about the
259 * signatures included in the package.
261 public static final int GET_SIGNATURES = 0x00000040;
264 * {@link ResolveInfo} flag: return the IntentFilter that
265 * was matched for a particular ResolveInfo in
266 * {@link ResolveInfo#filter}.
268 public static final int GET_RESOLVED_FILTER = 0x00000040;
271 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
272 * data {@link android.os.Bundle}s that are associated with a component.
273 * This applies for any API returning a ComponentInfo subclass.
275 public static final int GET_META_DATA = 0x00000080;
278 * {@link PackageInfo} flag: return the
279 * {@link PackageInfo#gids group ids} that are associated with an
281 * This applies for any API returning a PackageInfo class, either
282 * directly or nested inside of another.
284 public static final int GET_GIDS = 0x00000100;
287 * @deprecated replaced with {@link #MATCH_DISABLED_COMPONENTS}
290 public static final int GET_DISABLED_COMPONENTS = 0x00000200;
293 * {@link PackageInfo} flag: include disabled components in the returned info.
295 public static final int MATCH_DISABLED_COMPONENTS = 0x00000200;
298 * {@link ApplicationInfo} flag: return the
299 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
300 * that are associated with an application.
301 * This applies for any API returning an ApplicationInfo class, either
302 * directly or nested inside of another.
304 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400;
307 * {@link ProviderInfo} flag: return the
308 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
309 * that are associated with a content provider.
310 * This applies for any API returning a ProviderInfo class, either
311 * directly or nested inside of another.
313 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800;
315 * {@link PackageInfo} flag: return information about
316 * permissions in the package in
317 * {@link PackageInfo#permissions}.
319 public static final int GET_PERMISSIONS = 0x00001000;
322 * @deprecated replaced with {@link #MATCH_UNINSTALLED_PACKAGES}
325 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
328 * Flag parameter to retrieve some information about all applications (even
329 * uninstalled ones) which have data directories. This state could have
330 * resulted if applications have been deleted with flag
331 * {@code DONT_DELETE_DATA} with a possibility of being replaced or
332 * reinstalled in future.
334 * Note: this flag may cause less information about currently installed
335 * applications to be returned.
337 public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000;
340 * {@link PackageInfo} flag: return information about
341 * hardware preferences in
342 * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
343 * and requested features in {@link PackageInfo#reqFeatures} and
344 * {@link PackageInfo#featureGroups}.
346 public static final int GET_CONFIGURATIONS = 0x00004000;
349 * @deprecated replaced with {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}.
352 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
355 * {@link PackageInfo} flag: include disabled components which are in
356 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
357 * in the returned info. Note that if you set this flag, applications
358 * that are in this disabled state will be reported as enabled.
360 public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
363 * Resolution and querying flag: if set, only filters that support the
364 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
365 * matching. This is a synonym for including the CATEGORY_DEFAULT in your
368 public static final int MATCH_DEFAULT_ONLY = 0x00010000;
371 * Querying flag: if set and if the platform is doing any filtering of the
372 * results, then the filtering will not happen. This is a synonym for saying
373 * that all results should be returned.
375 * <em>This flag should be used with extreme care.</em>
377 public static final int MATCH_ALL = 0x00020000;
380 * Querying flag: match components which are direct boot <em>unaware</em> in
381 * the returned info, regardless of the current user state.
383 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
384 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
385 * to match only runnable components based on the user state. For example,
386 * when a user is started but credentials have not been presented yet, the
387 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
388 * components are returned. Once the user credentials have been presented,
389 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
390 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
392 * @see UserManager#isUserUnlocked()
394 public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000;
397 * Querying flag: match components which are direct boot <em>aware</em> in
398 * the returned info, regardless of the current user state.
400 * When neither {@link #MATCH_DIRECT_BOOT_AWARE} nor
401 * {@link #MATCH_DIRECT_BOOT_UNAWARE} are specified, the default behavior is
402 * to match only runnable components based on the user state. For example,
403 * when a user is started but credentials have not been presented yet, the
404 * user is running "locked" and only {@link #MATCH_DIRECT_BOOT_AWARE}
405 * components are returned. Once the user credentials have been presented,
406 * the user is running "unlocked" and both {@link #MATCH_DIRECT_BOOT_AWARE}
407 * and {@link #MATCH_DIRECT_BOOT_UNAWARE} components are returned.
409 * @see UserManager#isUserUnlocked()
411 public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000;
415 public static final int MATCH_ENCRYPTION_UNAWARE = 0x00040000;
418 public static final int MATCH_ENCRYPTION_AWARE = 0x00080000;
421 public static final int MATCH_ENCRYPTION_AWARE_AND_UNAWARE = MATCH_ENCRYPTION_AWARE
422 | MATCH_ENCRYPTION_UNAWARE;
425 * Querying flag: include only components from applications that are marked
426 * with {@link ApplicationInfo#FLAG_SYSTEM}.
428 public static final int MATCH_SYSTEM_ONLY = 0x00100000;
431 * Internal {@link PackageInfo} flag: include only components on the system image.
432 * This will not return information on any unbundled update to system components.
435 public static final int MATCH_FACTORY_ONLY = 0x00200000;
438 * Internal flag used to indicate that a system component has done their
439 * homework and verified that they correctly handle packages and components
440 * that come and go over time. In particular:
442 * <li>Apps installed on external storage, which will appear to be
443 * uninstalled while the the device is ejected.
444 * <li>Apps with encryption unaware components, which will appear to not
445 * exist while the device is locked.
448 * @see #MATCH_UNINSTALLED_PACKAGES
449 * @see #MATCH_DIRECT_BOOT_AWARE
450 * @see #MATCH_DIRECT_BOOT_UNAWARE
453 public static final int MATCH_DEBUG_TRIAGED_MISSING = 0x10000000;
456 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when
457 * resolving an intent that matches the {@code CrossProfileIntentFilter},
458 * the current profile will be skipped. Only activities in the target user
459 * can respond to the intent.
463 public static final int SKIP_CURRENT_PROFILE = 0x00000002;
466 * Flag for {@link #addCrossProfileIntentFilter}: if this flag is set:
467 * activities in the other profiles can respond to the intent only if no activity with
468 * non-negative priority in current profile can respond to the intent.
471 public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
474 @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED})
475 @Retention(RetentionPolicy.SOURCE)
476 public @interface PermissionResult {}
479 * Permission check result: this is returned by {@link #checkPermission}
480 * if the permission has been granted to the given package.
482 public static final int PERMISSION_GRANTED = 0;
485 * Permission check result: this is returned by {@link #checkPermission}
486 * if the permission has not been granted to the given package.
488 public static final int PERMISSION_DENIED = -1;
491 * Signature check result: this is returned by {@link #checkSignatures}
492 * if all signatures on the two packages match.
494 public static final int SIGNATURE_MATCH = 0;
497 * Signature check result: this is returned by {@link #checkSignatures}
498 * if neither of the two packages is signed.
500 public static final int SIGNATURE_NEITHER_SIGNED = 1;
503 * Signature check result: this is returned by {@link #checkSignatures}
504 * if the first package is not signed but the second is.
506 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
509 * Signature check result: this is returned by {@link #checkSignatures}
510 * if the second package is not signed but the first is.
512 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
515 * Signature check result: this is returned by {@link #checkSignatures}
516 * if not all signatures on both packages match.
518 public static final int SIGNATURE_NO_MATCH = -3;
521 * Signature check result: this is returned by {@link #checkSignatures}
522 * if either of the packages are not valid.
524 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
527 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
528 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
529 * component or application is in its default enabled state (as specified
532 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
535 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
536 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
537 * component or application has been explictily enabled, regardless of
538 * what it has specified in its manifest.
540 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
543 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
544 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
545 * component or application has been explicitly disabled, regardless of
546 * what it has specified in its manifest.
548 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
551 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
552 * user has explicitly disabled the application, regardless of what it has
553 * specified in its manifest. Because this is due to the user's request,
554 * they may re-enable it if desired through the appropriate system UI. This
555 * option currently <strong>cannot</strong> be used with
556 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
558 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
561 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
562 * application should be considered, until the point where the user actually
563 * wants to use it. This means that it will not normally show up to the user
564 * (such as in the launcher), but various parts of the user interface can
565 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
566 * the user to select it (as for example an IME, device admin, etc). Such code,
567 * once the user has selected the app, should at that point also make it enabled.
568 * This option currently <strong>can not</strong> be used with
569 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
571 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
574 @IntDef(flag = true, value = {
575 INSTALL_FORWARD_LOCK,
576 INSTALL_REPLACE_EXISTING,
582 INSTALL_ALLOW_DOWNGRADE,
583 INSTALL_GRANT_RUNTIME_PERMISSIONS,
584 INSTALL_FORCE_VOLUME_UUID,
585 INSTALL_FORCE_PERMISSION_PROMPT,
587 INSTALL_DONT_KILL_APP,
589 @Retention(RetentionPolicy.SOURCE)
590 public @interface InstallFlags {}
593 * Flag parameter for {@link #installPackage} to indicate that this package
594 * should be installed as forward locked, i.e. only the app itself should
595 * have access to its code and non-resource assets.
599 public static final int INSTALL_FORWARD_LOCK = 0x00000001;
602 * Flag parameter for {@link #installPackage} to indicate that you want to
603 * replace an already installed package, if one exists.
607 public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
610 * Flag parameter for {@link #installPackage} to indicate that you want to
611 * allow test packages (those that have set android:testOnly in their
612 * manifest) to be installed.
615 public static final int INSTALL_ALLOW_TEST = 0x00000004;
618 * Flag parameter for {@link #installPackage} to indicate that this package
619 * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}.
623 public static final int INSTALL_EXTERNAL = 0x00000008;
626 * Flag parameter for {@link #installPackage} to indicate that this package
627 * must be installed to internal storage.
631 public static final int INSTALL_INTERNAL = 0x00000010;
634 * Flag parameter for {@link #installPackage} to indicate that this install
635 * was initiated via ADB.
639 public static final int INSTALL_FROM_ADB = 0x00000020;
642 * Flag parameter for {@link #installPackage} to indicate that this install
643 * should immediately be visible to all users.
647 public static final int INSTALL_ALL_USERS = 0x00000040;
650 * Flag parameter for {@link #installPackage} to indicate that it is okay
651 * to install an update to an app where the newly installed app has a lower
652 * version code than the currently installed app. This is permitted only if
653 * the currently installed app is marked debuggable.
657 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
660 * Flag parameter for {@link #installPackage} to indicate that all runtime
661 * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS}
662 * is set the runtime permissions will be granted to all users, otherwise
667 public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100;
670 public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
673 * Flag parameter for {@link #installPackage} to indicate that we always want to force
674 * the prompt for permission approval. This overrides any special behaviour for internal
679 public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400;
682 * Flag parameter for {@link #installPackage} to indicate that this package is
683 * to be installed as a lightweight "ephemeral" app.
687 public static final int INSTALL_EPHEMERAL = 0x00000800;
690 * Flag parameter for {@link #installPackage} to indicate that this package contains
691 * a feature split to an existing application and the existing application should not
692 * be killed during the installation process.
696 public static final int INSTALL_DONT_KILL_APP = 0x00001000;
699 * Flag parameter for {@link #installPackage} to indicate that this package is an
700 * upgrade to a package that refers to the SDK via release letter.
704 public static final int INSTALL_FORCE_SDK = 0x00002000;
708 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
709 * that you don't want to kill the app containing the component. Be careful when you set this
710 * since changing component states can make the containing application's behavior unpredictable.
712 public static final int DONT_KILL_APP = 0x00000001;
715 * Installation return code: this is passed to the
716 * {@link IPackageInstallObserver} on success.
721 public static final int INSTALL_SUCCEEDED = 1;
724 * Installation return code: this is passed to the
725 * {@link IPackageInstallObserver} if the package is already installed.
730 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
733 * Installation return code: this is passed to the
734 * {@link IPackageInstallObserver} if the package archive file is invalid.
739 public static final int INSTALL_FAILED_INVALID_APK = -2;
742 * Installation return code: this is passed to the
743 * {@link IPackageInstallObserver} if the URI passed in is invalid.
748 public static final int INSTALL_FAILED_INVALID_URI = -3;
751 * Installation return code: this is passed to the
752 * {@link IPackageInstallObserver} if the package manager service found that
753 * the device didn't have enough storage space to install the app.
758 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
761 * Installation return code: this is passed to the
762 * {@link IPackageInstallObserver} if a package is already installed with
768 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
771 * Installation return code: this is passed to the
772 * {@link IPackageInstallObserver} if the requested shared user does not
778 public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
781 * Installation return code: this is passed to the
782 * {@link IPackageInstallObserver} if a previously installed package of the
783 * same name has a different signature than the new package (and the old
784 * package's data was not removed).
789 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
792 * Installation return code: this is passed to the
793 * {@link IPackageInstallObserver} if the new package is requested a shared
794 * user which is already installed on the device and does not have matching
800 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
803 * Installation return code: this is passed to the
804 * {@link IPackageInstallObserver} if the new package uses a shared library
805 * that is not available.
810 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
813 * Installation return code: this is passed to the
814 * {@link IPackageInstallObserver} if the new package uses a shared library
815 * that is not available.
820 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
823 * Installation return code: this is passed to the
824 * {@link IPackageInstallObserver} if the new package failed while
825 * optimizing and validating its dex files, either because there was not
826 * enough storage or the validation failed.
831 public static final int INSTALL_FAILED_DEXOPT = -11;
834 * Installation return code: this is passed to the
835 * {@link IPackageInstallObserver} if the new package failed because the
836 * current SDK version is older than that required by the package.
841 public static final int INSTALL_FAILED_OLDER_SDK = -12;
844 * Installation return code: this is passed to the
845 * {@link IPackageInstallObserver} if the new package failed because it
846 * contains a content provider with the same authority as a provider already
847 * installed in the system.
852 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
855 * Installation return code: this is passed to the
856 * {@link IPackageInstallObserver} if the new package failed because the
857 * current SDK version is newer than that required by the package.
862 public static final int INSTALL_FAILED_NEWER_SDK = -14;
865 * Installation return code: this is passed to the
866 * {@link IPackageInstallObserver} if the new package failed because it has
867 * specified that it is a test-only package and the caller has not supplied
868 * the {@link #INSTALL_ALLOW_TEST} flag.
873 public static final int INSTALL_FAILED_TEST_ONLY = -15;
876 * Installation return code: this is passed to the
877 * {@link IPackageInstallObserver} if the package being installed contains
878 * native code, but none that is compatible with the device's CPU_ABI.
883 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
886 * Installation return code: this is passed to the
887 * {@link IPackageInstallObserver} if the new package uses a feature that is
893 public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
895 // ------ Errors related to sdcard
897 * Installation return code: this is passed to the
898 * {@link IPackageInstallObserver} if a secure container mount point
899 * couldn't be accessed on external media.
904 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
907 * Installation return code: this is passed to the
908 * {@link IPackageInstallObserver} if the new package couldn't be installed
909 * in the specified install location.
914 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
917 * Installation return code: this is passed to the
918 * {@link IPackageInstallObserver} if the new package couldn't be installed
919 * in the specified install location because the media is not available.
924 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
927 * Installation return code: this is passed to the
928 * {@link IPackageInstallObserver} if the new package couldn't be installed
929 * because the verification timed out.
934 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
937 * Installation return code: this is passed to the
938 * {@link IPackageInstallObserver} if the new package couldn't be installed
939 * because the verification did not succeed.
944 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
947 * Installation return code: this is passed to the
948 * {@link IPackageInstallObserver} if the package changed from what the
949 * calling program expected.
954 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
957 * Installation return code: this is passed to the
958 * {@link IPackageInstallObserver} if the new package is assigned a
959 * different UID than it previously held.
963 public static final int INSTALL_FAILED_UID_CHANGED = -24;
966 * Installation return code: this is passed to the
967 * {@link IPackageInstallObserver} if the new package has an older version
968 * code than the currently installed package.
972 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
975 * Installation return code: this is passed to the
976 * {@link IPackageInstallObserver} if the old package has target SDK high
977 * enough to support runtime permission and the new package has target SDK
978 * low enough to not support runtime permissions.
983 public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
986 * Installation parse return code: this is passed to the
987 * {@link IPackageInstallObserver} if the parser was given a path that is
988 * not a file, or does not end with the expected '.apk' extension.
993 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
996 * Installation parse return code: this is passed to the
997 * {@link IPackageInstallObserver} if the parser was unable to retrieve the
998 * AndroidManifest.xml file.
1003 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
1006 * Installation parse return code: this is passed to the
1007 * {@link IPackageInstallObserver} if the parser encountered an unexpected
1013 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
1016 * Installation parse return code: this is passed to the
1017 * {@link IPackageInstallObserver} if the parser did not find any
1018 * certificates in the .apk.
1023 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
1026 * Installation parse return code: this is passed to the
1027 * {@link IPackageInstallObserver} if the parser found inconsistent
1028 * certificates on the files in the .apk.
1033 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
1036 * Installation parse return code: this is passed to the
1037 * {@link IPackageInstallObserver} if the parser encountered a
1038 * CertificateEncodingException in one of the files in the .apk.
1043 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
1046 * Installation parse return code: this is passed to the
1047 * {@link IPackageInstallObserver} if the parser encountered a bad or
1048 * missing package name in the manifest.
1053 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
1056 * Installation parse return code: this is passed to the
1057 * {@link IPackageInstallObserver} if the parser encountered a bad shared
1058 * user id name in the manifest.
1063 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
1066 * Installation parse return code: this is passed to the
1067 * {@link IPackageInstallObserver} if the parser encountered some structural
1068 * problem in the manifest.
1073 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
1076 * Installation parse return code: this is passed to the
1077 * {@link IPackageInstallObserver} if the parser did not find any actionable
1078 * tags (instrumentation or application) in the manifest.
1083 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
1086 * Installation failed return code: this is passed to the
1087 * {@link IPackageInstallObserver} if the system failed to install the
1088 * package because of system issues.
1093 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
1096 * Installation failed return code: this is passed to the
1097 * {@link IPackageInstallObserver} if the system failed to install the
1098 * package because the user is restricted from installing apps.
1102 public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
1105 * Installation failed return code: this is passed to the
1106 * {@link IPackageInstallObserver} if the system failed to install the
1107 * package because it is attempting to define a permission that is already
1108 * defined by some existing package.
1110 * The package name of the app which has already defined the permission is
1111 * passed to a {@link PackageInstallObserver}, if any, as the
1112 * {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string extra; and the name of the
1113 * permission being redefined is passed in the
1114 * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra.
1118 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
1121 * Installation failed return code: this is passed to the
1122 * {@link IPackageInstallObserver} if the system failed to install the
1123 * package because its packaged native code did not match any of the ABIs
1124 * supported by the system.
1128 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
1131 * Internal return code for NativeLibraryHelper methods to indicate that the package
1132 * being processed did not contain any native code. This is placed here only so that
1133 * it can belong to the same value space as the other install failure codes.
1137 public static final int NO_NATIVE_LIBRARIES = -114;
1140 public static final int INSTALL_FAILED_ABORTED = -115;
1143 * Installation failed return code: ephemeral app installs are incompatible with some
1144 * other installation flags supplied for the operation; or other circumstances such
1145 * as trying to upgrade a system app via an ephemeral install.
1148 public static final int INSTALL_FAILED_EPHEMERAL_INVALID = -116;
1151 @IntDef(flag = true, value = {
1155 DELETE_DONT_KILL_APP,
1157 @Retention(RetentionPolicy.SOURCE)
1158 public @interface DeleteFlags {}
1161 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
1162 * package's data directory.
1166 public static final int DELETE_KEEP_DATA = 0x00000001;
1169 * Flag parameter for {@link #deletePackage} to indicate that you want the
1170 * package deleted for all users.
1174 public static final int DELETE_ALL_USERS = 0x00000002;
1177 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1178 * uninstall on a system that has been updated, then don't do the normal process
1179 * of uninstalling the update and rolling back to the older system version (which
1180 * needs to happen for all users); instead, just mark the app as uninstalled for
1185 public static final int DELETE_SYSTEM_APP = 0x00000004;
1188 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
1189 * uninstall on a package that is replaced to provide new feature splits, the
1190 * existing application should not be killed during the removal process.
1194 public static final int DELETE_DONT_KILL_APP = 0x00000008;
1197 * Return code for when package deletion succeeds. This is passed to the
1198 * {@link IPackageDeleteObserver} if the system succeeded in deleting the
1203 public static final int DELETE_SUCCEEDED = 1;
1206 * Deletion failed return code: this is passed to the
1207 * {@link IPackageDeleteObserver} if the system failed to delete the package
1208 * for an unspecified reason.
1212 public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
1215 * Deletion failed return code: this is passed to the
1216 * {@link IPackageDeleteObserver} if the system failed to delete the package
1217 * because it is the active DevicePolicy manager.
1221 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
1224 * Deletion failed return code: this is passed to the
1225 * {@link IPackageDeleteObserver} if the system failed to delete the package
1226 * since the user is restricted.
1230 public static final int DELETE_FAILED_USER_RESTRICTED = -3;
1233 * Deletion failed return code: this is passed to the
1234 * {@link IPackageDeleteObserver} if the system failed to delete the package
1235 * because a profile or device owner has marked the package as
1240 public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
1243 public static final int DELETE_FAILED_ABORTED = -5;
1246 * Return code that is passed to the {@link IPackageMoveObserver} when the
1247 * package has been successfully moved by the system.
1251 public static final int MOVE_SUCCEEDED = -100;
1254 * Error code that is passed to the {@link IPackageMoveObserver} when the
1255 * package hasn't been successfully moved by the system because of
1256 * insufficient memory on specified media.
1260 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
1263 * Error code that is passed to the {@link IPackageMoveObserver} if the
1264 * specified package doesn't exist.
1268 public static final int MOVE_FAILED_DOESNT_EXIST = -2;
1271 * Error code that is passed to the {@link IPackageMoveObserver} if the
1272 * specified package cannot be moved since its a system package.
1276 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
1279 * Error code that is passed to the {@link IPackageMoveObserver} if the
1280 * specified package cannot be moved since its forward locked.
1284 public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
1287 * Error code that is passed to the {@link IPackageMoveObserver} if the
1288 * specified package cannot be moved to the specified location.
1292 public static final int MOVE_FAILED_INVALID_LOCATION = -5;
1295 * Error code that is passed to the {@link IPackageMoveObserver} if the
1296 * specified package cannot be moved to the specified location.
1300 public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
1303 * Error code that is passed to the {@link IPackageMoveObserver} if the
1304 * specified package already has an operation pending in the queue.
1308 public static final int MOVE_FAILED_OPERATION_PENDING = -7;
1311 * Error code that is passed to the {@link IPackageMoveObserver} if the
1312 * specified package cannot be moved since it contains a device admin.
1316 public static final int MOVE_FAILED_DEVICE_ADMIN = -8;
1319 * Flag parameter for {@link #movePackage} to indicate that
1320 * the package should be moved to internal storage if its
1321 * been installed on external media.
1325 public static final int MOVE_INTERNAL = 0x00000001;
1328 * Flag parameter for {@link #movePackage} to indicate that
1329 * the package should be moved to external media.
1333 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
1336 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
1339 * Usable by the required verifier as the {@code verificationCode} argument
1340 * for {@link PackageManager#verifyPendingInstall} to indicate that it will
1341 * allow the installation to proceed without any of the optional verifiers
1346 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
1349 * Used as the {@code verificationCode} argument for
1350 * {@link PackageManager#verifyPendingInstall} to indicate that the calling
1351 * package verifier allows the installation to proceed.
1353 public static final int VERIFICATION_ALLOW = 1;
1356 * Used as the {@code verificationCode} argument for
1357 * {@link PackageManager#verifyPendingInstall} to indicate the calling
1358 * package verifier does not vote to allow the installation to proceed.
1360 public static final int VERIFICATION_REJECT = -1;
1363 * Used as the {@code verificationCode} argument for
1364 * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1365 * IntentFilter Verifier confirms that the IntentFilter is verified.
1370 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
1373 * Used as the {@code verificationCode} argument for
1374 * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1375 * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
1380 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
1383 * Internal status code to indicate that an IntentFilter verification result is not specified.
1387 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
1390 * Used as the {@code status} argument for
1391 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1392 * will always be prompted the Intent Disambiguation Dialog if there are two
1393 * or more Intent resolved for the IntentFilter's domain(s).
1397 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
1400 * Used as the {@code status} argument for
1401 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1402 * will never be prompted the Intent Disambiguation Dialog if there are two
1403 * or more resolution of the Intent. The default App for the domain(s)
1404 * specified in the IntentFilter will also ALWAYS be used.
1408 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
1411 * Used as the {@code status} argument for
1412 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User
1413 * may be prompted the Intent Disambiguation Dialog if there are two or more
1414 * Intent resolved. The default App for the domain(s) specified in the
1415 * IntentFilter will also NEVER be presented to the User.
1419 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
1422 * Used as the {@code status} argument for
1423 * {@link #updateIntentVerificationStatusAsUser} to indicate that this app
1424 * should always be considered as an ambiguous candidate for handling the
1425 * matching Intent even if there are other candidate apps in the "always"
1426 * state. Put another way: if there are any 'always ask' apps in a set of
1427 * more than one candidate app, then a disambiguation is *always* presented
1428 * even if there is another candidate app with the 'always' state.
1432 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
1435 * Can be used as the {@code millisecondsToDelay} argument for
1436 * {@link PackageManager#extendVerificationTimeout}. This is the
1437 * maximum time {@code PackageManager} waits for the verification
1438 * agent to return (in milliseconds).
1440 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
1443 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
1444 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
1445 * lag in sound input or output.
1447 @SdkConstant(SdkConstantType.FEATURE)
1448 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
1451 * Feature for {@link #getSystemAvailableFeatures} and
1452 * {@link #hasSystemFeature}: The device includes at least one form of audio
1453 * output, such as speakers, audio jack or streaming over bluetooth
1455 @SdkConstant(SdkConstantType.FEATURE)
1456 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
1459 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1460 * The device has professional audio level of functionality and performance.
1462 @SdkConstant(SdkConstantType.FEATURE)
1463 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
1466 * Feature for {@link #getSystemAvailableFeatures} and
1467 * {@link #hasSystemFeature}: The device is capable of communicating with
1468 * other devices via Bluetooth.
1470 @SdkConstant(SdkConstantType.FEATURE)
1471 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
1474 * Feature for {@link #getSystemAvailableFeatures} and
1475 * {@link #hasSystemFeature}: The device is capable of communicating with
1476 * other devices via Bluetooth Low Energy radio.
1478 @SdkConstant(SdkConstantType.FEATURE)
1479 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
1482 * Feature for {@link #getSystemAvailableFeatures} and
1483 * {@link #hasSystemFeature}: The device has a camera facing away
1486 @SdkConstant(SdkConstantType.FEATURE)
1487 public static final String FEATURE_CAMERA = "android.hardware.camera";
1490 * Feature for {@link #getSystemAvailableFeatures} and
1491 * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1493 @SdkConstant(SdkConstantType.FEATURE)
1494 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
1497 * Feature for {@link #getSystemAvailableFeatures} and
1498 * {@link #hasSystemFeature}: The device has at least one camera pointing in
1499 * some direction, or can support an external camera being connected to it.
1501 @SdkConstant(SdkConstantType.FEATURE)
1502 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1505 * Feature for {@link #getSystemAvailableFeatures} and
1506 * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1507 * The external camera may not always be connected or available to applications to use.
1509 @SdkConstant(SdkConstantType.FEATURE)
1510 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1513 * Feature for {@link #getSystemAvailableFeatures} and
1514 * {@link #hasSystemFeature}: The device's camera supports flash.
1516 @SdkConstant(SdkConstantType.FEATURE)
1517 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
1520 * Feature for {@link #getSystemAvailableFeatures} and
1521 * {@link #hasSystemFeature}: The device has a front facing camera.
1523 @SdkConstant(SdkConstantType.FEATURE)
1524 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1527 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1528 * of the cameras on the device supports the
1529 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1532 @SdkConstant(SdkConstantType.FEATURE)
1533 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1536 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1537 * of the cameras on the device supports the
1538 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1541 @SdkConstant(SdkConstantType.FEATURE)
1542 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1543 "android.hardware.camera.capability.manual_sensor";
1546 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1547 * of the cameras on the device supports the
1548 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1551 @SdkConstant(SdkConstantType.FEATURE)
1552 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1553 "android.hardware.camera.capability.manual_post_processing";
1556 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1557 * of the cameras on the device supports the
1558 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1561 @SdkConstant(SdkConstantType.FEATURE)
1562 public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1563 "android.hardware.camera.capability.raw";
1566 * Feature for {@link #getSystemAvailableFeatures} and
1567 * {@link #hasSystemFeature}: The device is capable of communicating with
1568 * consumer IR devices.
1570 @SdkConstant(SdkConstantType.FEATURE)
1571 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1574 * Feature for {@link #getSystemAvailableFeatures} and
1575 * {@link #hasSystemFeature}: The device supports one or more methods of
1576 * reporting current location.
1578 @SdkConstant(SdkConstantType.FEATURE)
1579 public static final String FEATURE_LOCATION = "android.hardware.location";
1582 * Feature for {@link #getSystemAvailableFeatures} and
1583 * {@link #hasSystemFeature}: The device has a Global Positioning System
1584 * receiver and can report precise location.
1586 @SdkConstant(SdkConstantType.FEATURE)
1587 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1590 * Feature for {@link #getSystemAvailableFeatures} and
1591 * {@link #hasSystemFeature}: The device can report location with coarse
1592 * accuracy using a network-based geolocation system.
1594 @SdkConstant(SdkConstantType.FEATURE)
1595 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1598 * Feature for {@link #getSystemAvailableFeatures} and
1599 * {@link #hasSystemFeature}: The device can record audio via a
1602 @SdkConstant(SdkConstantType.FEATURE)
1603 public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1606 * Feature for {@link #getSystemAvailableFeatures} and
1607 * {@link #hasSystemFeature}: The device can communicate using Near-Field
1608 * Communications (NFC).
1610 @SdkConstant(SdkConstantType.FEATURE)
1611 public static final String FEATURE_NFC = "android.hardware.nfc";
1614 * Feature for {@link #getSystemAvailableFeatures} and
1615 * {@link #hasSystemFeature}: The device supports host-
1616 * based NFC card emulation.
1618 * TODO remove when depending apps have moved to new constant.
1623 @SdkConstant(SdkConstantType.FEATURE)
1624 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1627 * Feature for {@link #getSystemAvailableFeatures} and
1628 * {@link #hasSystemFeature}: The device supports host-
1629 * based NFC card emulation.
1631 @SdkConstant(SdkConstantType.FEATURE)
1632 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1635 * Feature for {@link #getSystemAvailableFeatures} and
1636 * {@link #hasSystemFeature}: The device supports host-
1637 * based NFC-F card emulation.
1639 @SdkConstant(SdkConstantType.FEATURE)
1640 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef";
1643 * Feature for {@link #getSystemAvailableFeatures} and
1644 * {@link #hasSystemFeature}: The device supports the OpenGL ES
1645 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1646 * Android Extension Pack</a>.
1648 @SdkConstant(SdkConstantType.FEATURE)
1649 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1652 * Feature for {@link #getSystemAvailableFeatures} and
1653 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
1654 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
1655 * what level of optional hardware features limits it supports.
1657 * Level 0 includes the base Vulkan requirements as well as:
1658 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul>
1660 * Level 1 additionally includes:
1662 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li>
1663 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li>
1664 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li>
1665 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li>
1666 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li>
1667 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li>
1668 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li>
1669 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li>
1670 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li>
1671 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li>
1672 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li>
1675 @SdkConstant(SdkConstantType.FEATURE)
1676 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level";
1679 * Feature for {@link #getSystemAvailableFeatures} and
1680 * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest
1681 * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support
1682 * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version
1683 * uses the same encoding as Vulkan version numbers:
1685 * <li>Major version number in bits 31-22</li>
1686 * <li>Minor version number in bits 21-12</li>
1687 * <li>Patch version number in bits 11-0</li>
1690 @SdkConstant(SdkConstantType.FEATURE)
1691 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version";
1694 * Feature for {@link #getSystemAvailableFeatures} and
1695 * {@link #hasSystemFeature}: The device includes an accelerometer.
1697 @SdkConstant(SdkConstantType.FEATURE)
1698 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1701 * Feature for {@link #getSystemAvailableFeatures} and
1702 * {@link #hasSystemFeature}: The device includes a barometer (air
1705 @SdkConstant(SdkConstantType.FEATURE)
1706 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1709 * Feature for {@link #getSystemAvailableFeatures} and
1710 * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1712 @SdkConstant(SdkConstantType.FEATURE)
1713 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1716 * Feature for {@link #getSystemAvailableFeatures} and
1717 * {@link #hasSystemFeature}: The device includes a gyroscope.
1719 @SdkConstant(SdkConstantType.FEATURE)
1720 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
1723 * Feature for {@link #getSystemAvailableFeatures} and
1724 * {@link #hasSystemFeature}: The device includes a light sensor.
1726 @SdkConstant(SdkConstantType.FEATURE)
1727 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
1730 * Feature for {@link #getSystemAvailableFeatures} and
1731 * {@link #hasSystemFeature}: The device includes a proximity sensor.
1733 @SdkConstant(SdkConstantType.FEATURE)
1734 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
1737 * Feature for {@link #getSystemAvailableFeatures} and
1738 * {@link #hasSystemFeature}: The device includes a hardware step counter.
1740 @SdkConstant(SdkConstantType.FEATURE)
1741 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
1744 * Feature for {@link #getSystemAvailableFeatures} and
1745 * {@link #hasSystemFeature}: The device includes a hardware step detector.
1747 @SdkConstant(SdkConstantType.FEATURE)
1748 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
1751 * Feature for {@link #getSystemAvailableFeatures} and
1752 * {@link #hasSystemFeature}: The device includes a heart rate monitor.
1754 @SdkConstant(SdkConstantType.FEATURE)
1755 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
1758 * Feature for {@link #getSystemAvailableFeatures} and
1759 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram.
1761 @SdkConstant(SdkConstantType.FEATURE)
1762 public static final String FEATURE_SENSOR_HEART_RATE_ECG =
1763 "android.hardware.sensor.heartrate.ecg";
1766 * Feature for {@link #getSystemAvailableFeatures} and
1767 * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
1769 @SdkConstant(SdkConstantType.FEATURE)
1770 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
1771 "android.hardware.sensor.relative_humidity";
1774 * Feature for {@link #getSystemAvailableFeatures} and
1775 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
1777 @SdkConstant(SdkConstantType.FEATURE)
1778 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
1779 "android.hardware.sensor.ambient_temperature";
1782 * Feature for {@link #getSystemAvailableFeatures} and
1783 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
1786 @SdkConstant(SdkConstantType.FEATURE)
1787 public static final String FEATURE_HIFI_SENSORS =
1788 "android.hardware.sensor.hifi_sensors";
1791 * Feature for {@link #getSystemAvailableFeatures} and
1792 * {@link #hasSystemFeature}: The device has a telephony radio with data
1793 * communication support.
1795 @SdkConstant(SdkConstantType.FEATURE)
1796 public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
1799 * Feature for {@link #getSystemAvailableFeatures} and
1800 * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
1802 @SdkConstant(SdkConstantType.FEATURE)
1803 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
1806 * Feature for {@link #getSystemAvailableFeatures} and
1807 * {@link #hasSystemFeature}: The device has a GSM telephony stack.
1809 @SdkConstant(SdkConstantType.FEATURE)
1810 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
1813 * Feature for {@link #getSystemAvailableFeatures} and
1814 * {@link #hasSystemFeature}: The device supports connecting to USB devices
1817 @SdkConstant(SdkConstantType.FEATURE)
1818 public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
1821 * Feature for {@link #getSystemAvailableFeatures} and
1822 * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
1824 @SdkConstant(SdkConstantType.FEATURE)
1825 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
1828 * Feature for {@link #getSystemAvailableFeatures} and
1829 * {@link #hasSystemFeature}: The SIP API is enabled on the device.
1831 @SdkConstant(SdkConstantType.FEATURE)
1832 public static final String FEATURE_SIP = "android.software.sip";
1835 * Feature for {@link #getSystemAvailableFeatures} and
1836 * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
1838 @SdkConstant(SdkConstantType.FEATURE)
1839 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
1842 * Feature for {@link #getSystemAvailableFeatures} and
1843 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
1845 @SdkConstant(SdkConstantType.FEATURE)
1846 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
1849 * Feature for {@link #getSystemAvailableFeatures} and
1850 * {@link #hasSystemFeature}: The device's display has a touch screen.
1852 @SdkConstant(SdkConstantType.FEATURE)
1853 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1856 * Feature for {@link #getSystemAvailableFeatures} and
1857 * {@link #hasSystemFeature}: The device's touch screen supports
1858 * multitouch sufficient for basic two-finger gesture detection.
1860 @SdkConstant(SdkConstantType.FEATURE)
1861 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1864 * Feature for {@link #getSystemAvailableFeatures} and
1865 * {@link #hasSystemFeature}: The device's touch screen is capable of
1866 * tracking two or more fingers fully independently.
1868 @SdkConstant(SdkConstantType.FEATURE)
1869 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1872 * Feature for {@link #getSystemAvailableFeatures} and
1873 * {@link #hasSystemFeature}: The device's touch screen is capable of
1874 * tracking a full hand of fingers fully independently -- that is, 5 or
1875 * more simultaneous independent pointers.
1877 @SdkConstant(SdkConstantType.FEATURE)
1878 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1881 * Feature for {@link #getSystemAvailableFeatures} and
1882 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1883 * does support touch emulation for basic events. For instance, the
1884 * device might use a mouse or remote control to drive a cursor, and
1885 * emulate basic touch pointer events like down, up, drag, etc. All
1886 * devices that support android.hardware.touchscreen or a sub-feature are
1887 * presumed to also support faketouch.
1889 @SdkConstant(SdkConstantType.FEATURE)
1890 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1893 * Feature for {@link #getSystemAvailableFeatures} and
1894 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1895 * does support touch emulation for basic events that supports distinct
1896 * tracking of two or more fingers. This is an extension of
1897 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
1898 * that unlike a distinct multitouch screen as defined by
1899 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1900 * devices will not actually provide full two-finger gestures since the
1901 * input is being transformed to cursor movement on the screen. That is,
1902 * single finger gestures will move a cursor; two-finger swipes will
1903 * result in single-finger touch events; other two-finger gestures will
1904 * result in the corresponding two-finger touch event.
1906 @SdkConstant(SdkConstantType.FEATURE)
1907 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
1910 * Feature for {@link #getSystemAvailableFeatures} and
1911 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1912 * does support touch emulation for basic events that supports tracking
1913 * a hand of fingers (5 or more fingers) fully independently.
1914 * This is an extension of
1915 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
1916 * that unlike a multitouch screen as defined by
1917 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
1918 * gestures can be detected due to the limitations described for
1919 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1921 @SdkConstant(SdkConstantType.FEATURE)
1922 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1925 * Feature for {@link #getSystemAvailableFeatures} and
1926 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
1928 @SdkConstant(SdkConstantType.FEATURE)
1929 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
1932 * Feature for {@link #getSystemAvailableFeatures} and
1933 * {@link #hasSystemFeature}: The device supports portrait orientation
1934 * screens. For backwards compatibility, you can assume that if neither
1935 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1936 * both portrait and landscape.
1938 @SdkConstant(SdkConstantType.FEATURE)
1939 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1942 * Feature for {@link #getSystemAvailableFeatures} and
1943 * {@link #hasSystemFeature}: The device supports landscape orientation
1944 * screens. For backwards compatibility, you can assume that if neither
1945 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1946 * both portrait and landscape.
1948 @SdkConstant(SdkConstantType.FEATURE)
1949 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1952 * Feature for {@link #getSystemAvailableFeatures} and
1953 * {@link #hasSystemFeature}: The device supports live wallpapers.
1955 @SdkConstant(SdkConstantType.FEATURE)
1956 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1958 * Feature for {@link #getSystemAvailableFeatures} and
1959 * {@link #hasSystemFeature}: The device supports app widgets.
1961 @SdkConstant(SdkConstantType.FEATURE)
1962 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
1966 * Feature for {@link #getSystemAvailableFeatures} and
1967 * {@link #hasSystemFeature}: The device supports
1968 * {@link android.service.voice.VoiceInteractionService} and
1969 * {@link android.app.VoiceInteractor}.
1971 @SdkConstant(SdkConstantType.FEATURE)
1972 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
1976 * Feature for {@link #getSystemAvailableFeatures} and
1977 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
1978 * by third party applications.
1980 @SdkConstant(SdkConstantType.FEATURE)
1981 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
1984 * Feature for {@link #getSystemAvailableFeatures} and
1985 * {@link #hasSystemFeature}: The device supports adding new input methods implemented
1986 * with the {@link android.inputmethodservice.InputMethodService} API.
1988 @SdkConstant(SdkConstantType.FEATURE)
1989 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
1992 * Feature for {@link #getSystemAvailableFeatures} and
1993 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
1995 @SdkConstant(SdkConstantType.FEATURE)
1996 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
1999 * Feature for {@link #getSystemAvailableFeatures} and
2000 * {@link #hasSystemFeature}: The device supports leanback UI. This is
2001 * typically used in a living room television experience, but is a software
2002 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
2003 * feature will use resources associated with the "television" UI mode.
2005 @SdkConstant(SdkConstantType.FEATURE)
2006 public static final String FEATURE_LEANBACK = "android.software.leanback";
2009 * Feature for {@link #getSystemAvailableFeatures} and
2010 * {@link #hasSystemFeature}: The device supports only leanback UI. Only
2011 * applications designed for this experience should be run, though this is
2012 * not enforced by the system.
2015 @SdkConstant(SdkConstantType.FEATURE)
2016 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
2019 * Feature for {@link #getSystemAvailableFeatures} and
2020 * {@link #hasSystemFeature}: The device supports live TV and can display
2021 * contents from TV inputs implemented with the
2022 * {@link android.media.tv.TvInputService} API.
2024 @SdkConstant(SdkConstantType.FEATURE)
2025 public static final String FEATURE_LIVE_TV = "android.software.live_tv";
2028 * Feature for {@link #getSystemAvailableFeatures} and
2029 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
2031 @SdkConstant(SdkConstantType.FEATURE)
2032 public static final String FEATURE_WIFI = "android.hardware.wifi";
2035 * Feature for {@link #getSystemAvailableFeatures} and
2036 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
2038 @SdkConstant(SdkConstantType.FEATURE)
2039 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
2042 * Feature for {@link #getSystemAvailableFeatures} and
2043 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware (NAN)
2046 * @hide PROPOSED_NAN_API
2048 @SdkConstant(SdkConstantType.FEATURE)
2049 public static final String FEATURE_WIFI_NAN = "android.hardware.wifi.nan";
2052 * Feature for {@link #getSystemAvailableFeatures} and
2053 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2054 * on a vehicle headunit. A headunit here is defined to be inside a
2055 * vehicle that may or may not be moving. A headunit uses either a
2056 * primary display in the center console and/or additional displays in
2057 * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
2058 * have limited size and resolution. The user will likely be focused on
2059 * driving so limiting driver distraction is a primary concern. User input
2060 * can be a variety of hard buttons, touch, rotary controllers and even mouse-
2063 @SdkConstant(SdkConstantType.FEATURE)
2064 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
2067 * Feature for {@link #getSystemAvailableFeatures} and
2068 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2069 * on a television. Television here is defined to be a typical living
2070 * room television experience: displayed on a big screen, where the user
2071 * is sitting far away from it, and the dominant form of input will be
2072 * something like a DPAD, not through touch or mouse.
2073 * @deprecated use {@link #FEATURE_LEANBACK} instead.
2076 @SdkConstant(SdkConstantType.FEATURE)
2077 public static final String FEATURE_TELEVISION = "android.hardware.type.television";
2080 * Feature for {@link #getSystemAvailableFeatures} and
2081 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
2082 * on a watch. A watch here is defined to be a device worn on the body, perhaps on
2083 * the wrist. The user is very close when interacting with the device.
2085 @SdkConstant(SdkConstantType.FEATURE)
2086 public static final String FEATURE_WATCH = "android.hardware.type.watch";
2089 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2090 * The device supports printing.
2092 @SdkConstant(SdkConstantType.FEATURE)
2093 public static final String FEATURE_PRINTING = "android.software.print";
2096 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2097 * The device can perform backup and restore operations on installed applications.
2099 @SdkConstant(SdkConstantType.FEATURE)
2100 public static final String FEATURE_BACKUP = "android.software.backup";
2103 * Feature for {@link #getSystemAvailableFeatures} and
2104 * {@link #hasSystemFeature}: The device supports freeform window management.
2105 * Windows have title bars and can be moved and resized.
2107 // If this feature is present, you also need to set
2108 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay.
2109 @SdkConstant(SdkConstantType.FEATURE)
2110 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
2111 = "android.software.freeform_window_management";
2114 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2115 * The device supports picture-in-picture multi-window mode.
2117 @SdkConstant(SdkConstantType.FEATURE)
2118 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
2121 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2122 * The device supports creating secondary users and managed profiles via
2123 * {@link DevicePolicyManager}.
2125 @SdkConstant(SdkConstantType.FEATURE)
2126 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
2130 * TODO: Remove after dependencies updated b/17392243
2132 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
2135 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2136 * The device supports verified boot.
2138 @SdkConstant(SdkConstantType.FEATURE)
2139 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
2142 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2143 * The device supports secure removal of users. When a user is deleted the data associated
2144 * with that user is securely deleted and no longer available.
2146 @SdkConstant(SdkConstantType.FEATURE)
2147 public static final String FEATURE_SECURELY_REMOVES_USERS
2148 = "android.software.securely_removes_users";
2151 @SdkConstant(SdkConstantType.FEATURE)
2152 public static final String FEATURE_FILE_BASED_ENCRYPTION
2153 = "android.software.file_based_encryption";
2156 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2157 * The device has a full implementation of the android.webkit.* APIs. Devices
2158 * lacking this feature will not have a functioning WebView implementation.
2160 @SdkConstant(SdkConstantType.FEATURE)
2161 public static final String FEATURE_WEBVIEW = "android.software.webview";
2164 * Feature for {@link #getSystemAvailableFeatures} and
2165 * {@link #hasSystemFeature}: This device supports ethernet.
2167 @SdkConstant(SdkConstantType.FEATURE)
2168 public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
2171 * Feature for {@link #getSystemAvailableFeatures} and
2172 * {@link #hasSystemFeature}: This device supports HDMI-CEC.
2175 @SdkConstant(SdkConstantType.FEATURE)
2176 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
2179 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2180 * The device has all of the inputs necessary to be considered a compatible game controller, or
2181 * includes a compatible game controller in the box.
2183 @SdkConstant(SdkConstantType.FEATURE)
2184 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
2187 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2188 * The device has a full implementation of the android.media.midi.* APIs.
2190 @SdkConstant(SdkConstantType.FEATURE)
2191 public static final String FEATURE_MIDI = "android.software.midi";
2194 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2195 * The device implements an optimized mode for virtual reality (VR) applications that handles
2196 * stereoscopic rendering of notifications, and disables most monocular system UI components
2197 * while a VR application has user focus.
2198 * Devices declaring this feature must include an application implementing a
2199 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via
2200 * {@link android.app.Activity#setVrModeEnabled}.
2202 @SdkConstant(SdkConstantType.FEATURE)
2203 public static final String FEATURE_VR_MODE = "android.software.vr.mode";
2206 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
2207 * The device implements {@link #FEATURE_VR_MODE} but additionally meets extra CDD requirements
2208 * to provide a high-quality VR experience. In general, devices declaring this feature will
2211 * <li>Deliver consistent performance at a high framerate over an extended period of time
2212 * for typical VR application CPU/GPU workloads with a minimal number of frame drops for VR
2213 * applications that have called
2214 * {@link android.view.Window#setSustainedPerformanceMode}.</li>
2215 * <li>Implement {@link #FEATURE_HIFI_SENSORS} and have a low sensor latency.</li>
2216 * <li>Include optimizations to lower display persistence while running VR applications.</li>
2217 * <li>Implement an optimized render path to minimize latency to draw to the device's main
2219 * <li>Include the following EGL extensions: EGL_ANDROID_create_native_client_buffer,
2220 * EGL_ANDROID_front_buffer_auto_refresh, EGL_EXT_protected_content,
2221 * EGL_KHR_mutable_render_buffer, EGL_KHR_reusable_sync, and EGL_KHR_wait_sync.</li>
2222 * <li>Provide at least one CPU core that is reserved for use solely by the top, foreground
2223 * VR application process for critical render threads while such an application is
2227 @SdkConstant(SdkConstantType.FEATURE)
2228 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
2229 = "android.hardware.vr.high_performance";
2232 * Action to external storage service to clean out removed apps.
2235 public static final String ACTION_CLEAN_EXTERNAL_STORAGE
2236 = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
2239 * Extra field name for the URI to a verification file. Passed to a package
2244 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
2247 * Extra field name for the ID of a package pending verification. Passed to
2248 * a package verifier and is used to call back to
2249 * {@link PackageManager#verifyPendingInstall(int, int)}
2251 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
2254 * Extra field name for the package identifier which is trying to install
2259 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
2260 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
2263 * Extra field name for the requested install flags for a package pending
2264 * verification. Passed to a package verifier.
2268 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
2269 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
2272 * Extra field name for the uid of who is requesting to install
2277 public static final String EXTRA_VERIFICATION_INSTALLER_UID
2278 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
2281 * Extra field name for the package name of a package pending verification.
2285 public static final String EXTRA_VERIFICATION_PACKAGE_NAME
2286 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
2288 * Extra field name for the result of a verification, either
2289 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
2290 * Passed to package verifiers after a package is verified.
2292 public static final String EXTRA_VERIFICATION_RESULT
2293 = "android.content.pm.extra.VERIFICATION_RESULT";
2296 * Extra field name for the version code of a package pending verification.
2300 public static final String EXTRA_VERIFICATION_VERSION_CODE
2301 = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
2304 * Extra field name for the ID of a intent filter pending verification.
2305 * Passed to an intent filter verifier and is used to call back to
2306 * {@link #verifyIntentFilter}
2310 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
2311 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
2314 * Extra field name for the scheme used for an intent filter pending verification. Passed to
2315 * an intent filter verifier and is used to construct the URI to verify against.
2317 * Usually this is "https"
2321 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
2322 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
2325 * Extra field name for the host names to be used for an intent filter pending verification.
2326 * Passed to an intent filter verifier and is used to construct the URI to verify the
2329 * This is a space delimited list of hosts.
2333 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
2334 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
2337 * Extra field name for the package name to be used for an intent filter pending verification.
2338 * Passed to an intent filter verifier and is used to check the verification responses coming
2339 * from the hosts. Each host response will need to include the package name of APK containing
2340 * the intent filter.
2344 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
2345 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
2348 * The action used to request that the user approve a permission request
2349 * from the application.
2354 public static final String ACTION_REQUEST_PERMISSIONS =
2355 "android.content.pm.action.REQUEST_PERMISSIONS";
2358 * The names of the requested permissions.
2360 * <strong>Type:</strong> String[]
2366 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
2367 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
2370 * The results from the permissions request.
2372 * <strong>Type:</strong> int[] of #PermissionResult
2378 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
2379 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
2382 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2383 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides
2384 * the existing definition for the permission.
2387 public static final String EXTRA_FAILURE_EXISTING_PACKAGE
2388 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
2391 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
2392 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is
2393 * being redundantly defined by the package being installed.
2396 public static final String EXTRA_FAILURE_EXISTING_PERMISSION
2397 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
2400 * Permission flag: The permission is set in its current state
2401 * by the user and apps can still request it at runtime.
2406 public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
2409 * Permission flag: The permission is set in its current state
2410 * by the user and it is fixed, i.e. apps can no longer request
2416 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1;
2419 * Permission flag: The permission is set in its current state
2420 * by device policy and neither apps nor the user can change
2426 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2;
2429 * Permission flag: The permission is set in a granted state but
2430 * access to resources it guards is restricted by other means to
2431 * enable revoking a permission on legacy apps that do not support
2432 * runtime permissions. If this permission is upgraded to runtime
2433 * because the app was updated to support runtime permissions, the
2434 * the permission will be revoked in the upgrade process.
2439 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3;
2442 * Permission flag: The permission is set in its current state
2443 * because the app is a component that is a part of the system.
2448 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4;
2451 * Permission flag: The permission is granted by default because it
2452 * enables app functionality that is expected to work out-of-the-box
2453 * for providing a smooth user experience. For example, the phone app
2454 * is expected to have the phone permission.
2459 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5;
2462 * Permission flag: The permission has to be reviewed before any of
2463 * the app components can run.
2468 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6;
2471 * Mask for all permission flags.
2476 public static final int MASK_PERMISSION_FLAGS = 0xFF;
2479 * This is a library that contains components apps can invoke. For
2480 * example, a services for apps to bind to, or standard chooser UI,
2481 * etc. This library is versioned and backwards compatible. Clients
2482 * should check its version via {@link android.ext.services.Version
2483 * #getVersionCode()} and avoid calling APIs added in later versions.
2487 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
2490 * This is a library that contains components apps can dynamically
2491 * load. For example, new widgets, helper classes, etc. This library
2492 * is versioned and backwards compatible. Clients should check its
2493 * version via {@link android.ext.shared.Version#getVersionCode()}
2494 * and avoid calling APIs added in later versions.
2498 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
2501 * Used when starting a process for an Activity.
2505 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0;
2508 * Used when starting a process for a Service.
2512 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1;
2515 * Used when moving a Service to the foreground.
2519 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2;
2522 * Used when starting a process for a BroadcastReceiver.
2526 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3;
2529 * Used when starting a process for a ContentProvider.
2533 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4;
2536 * Used when starting a process for a BroadcastReceiver.
2540 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5;
2543 * Used with Context.getClassLoader() across Android packages.
2547 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6;
2550 * Used when starting a package within a process for Instrumentation.
2554 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7;
2557 * Total number of usage reasons.
2561 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8;
2564 * Retrieve overall information about an application package that is
2565 * installed on the system.
2567 * @param packageName The full name (i.e. com.google.apps.contacts) of the
2569 * @param flags Additional option flags. Use any combination of
2570 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2571 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2572 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2573 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2574 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2575 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2576 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2577 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2578 * {@link #MATCH_UNINSTALLED_PACKAGES}
2579 * to modify the data returned.
2581 * @return A PackageInfo object containing information about the
2582 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2583 * package is not found in the list of installed applications, the
2584 * package information is retrieved from the list of uninstalled
2585 * applications (which includes installed applications as well as
2586 * applications with data directory i.e. applications which had been
2587 * deleted with {@code DONT_DELETE_DATA} flag set).
2588 * @throws NameNotFoundException if a package with the given name cannot be
2589 * found on the system.
2590 * @see #GET_ACTIVITIES
2591 * @see #GET_CONFIGURATIONS
2593 * @see #GET_INSTRUMENTATION
2594 * @see #GET_INTENT_FILTERS
2595 * @see #GET_META_DATA
2596 * @see #GET_PERMISSIONS
2597 * @see #GET_PROVIDERS
2598 * @see #GET_RECEIVERS
2599 * @see #GET_SERVICES
2600 * @see #GET_SHARED_LIBRARY_FILES
2601 * @see #GET_SIGNATURES
2602 * @see #GET_URI_PERMISSION_PATTERNS
2603 * @see #MATCH_DISABLED_COMPONENTS
2604 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2605 * @see #MATCH_UNINSTALLED_PACKAGES
2607 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags)
2608 throws NameNotFoundException;
2612 * Retrieve overall information about an application package that is
2613 * installed on the system.
2615 * @param packageName The full name (i.e. com.google.apps.contacts) of the
2617 * @param flags Additional option flags. Use any combination of
2618 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
2619 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
2620 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
2621 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2622 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2623 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
2624 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
2625 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2626 * {@link #MATCH_UNINSTALLED_PACKAGES}
2627 * to modify the data returned.
2628 * @param userId The user id.
2630 * @return A PackageInfo object containing information about the
2631 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2632 * package is not found in the list of installed applications, the
2633 * package information is retrieved from the list of uninstalled
2634 * applications (which includes installed applications as well as
2635 * applications with data directory i.e. applications which had been
2636 * deleted with {@code DONT_DELETE_DATA} flag set).
2637 * @throws NameNotFoundException if a package with the given name cannot be
2638 * found on the system.
2639 * @see #GET_ACTIVITIES
2640 * @see #GET_CONFIGURATIONS
2642 * @see #GET_INSTRUMENTATION
2643 * @see #GET_INTENT_FILTERS
2644 * @see #GET_META_DATA
2645 * @see #GET_PERMISSIONS
2646 * @see #GET_PROVIDERS
2647 * @see #GET_RECEIVERS
2648 * @see #GET_SERVICES
2649 * @see #GET_SHARED_LIBRARY_FILES
2650 * @see #GET_SIGNATURES
2651 * @see #GET_URI_PERMISSION_PATTERNS
2652 * @see #MATCH_DISABLED_COMPONENTS
2653 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2654 * @see #MATCH_UNINSTALLED_PACKAGES
2656 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
2657 public abstract PackageInfo getPackageInfoAsUser(String packageName,
2658 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
2661 * Map from the current package names in use on the device to whatever
2662 * the current canonical name of that package is.
2663 * @param names Array of current names to be mapped.
2664 * @return Returns an array of the same size as the original, containing
2665 * the canonical name for each package.
2667 public abstract String[] currentToCanonicalPackageNames(String[] names);
2670 * Map from a packages canonical name to the current name in use on the device.
2671 * @param names Array of new names to be mapped.
2672 * @return Returns an array of the same size as the original, containing
2673 * the current name for each package.
2675 public abstract String[] canonicalToCurrentPackageNames(String[] names);
2678 * Returns a "good" intent to launch a front-door activity in a package.
2679 * This is used, for example, to implement an "open" button when browsing
2680 * through packages. The current implementation looks first for a main
2681 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
2682 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
2683 * <code>null</code> if neither are found.
2685 * @param packageName The name of the package to inspect.
2687 * @return A fully-qualified {@link Intent} that can be used to launch the
2688 * main activity in the package. Returns <code>null</code> if the package
2689 * does not contain such an activity, or if <em>packageName</em> is not
2692 public abstract Intent getLaunchIntentForPackage(String packageName);
2695 * Return a "good" intent to launch a front-door Leanback activity in a
2696 * package, for use for example to implement an "open" button when browsing
2697 * through packages. The current implementation will look for a main
2698 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
2699 * return null if no main leanback activities are found.
2701 * @param packageName The name of the package to inspect.
2702 * @return Returns either a fully-qualified Intent that can be used to launch
2703 * the main Leanback activity in the package, or null if the package
2704 * does not contain such an activity.
2706 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
2709 * Return an array of all of the POSIX secondary group IDs that have been
2710 * assigned to the given package.
2712 * Note that the same package may have different GIDs under different
2713 * {@link UserHandle} on the same device.
2715 * @param packageName The full name (i.e. com.google.apps.contacts) of the
2717 * @return Returns an int array of the assigned GIDs, or null if there are
2719 * @throws NameNotFoundException if a package with the given name cannot be
2720 * found on the system.
2722 public abstract int[] getPackageGids(String packageName)
2723 throws NameNotFoundException;
2726 * Return an array of all of the POSIX secondary group IDs that have been
2727 * assigned to the given package.
2729 * Note that the same package may have different GIDs under different
2730 * {@link UserHandle} on the same device.
2732 * @param packageName The full name (i.e. com.google.apps.contacts) of the
2734 * @return Returns an int array of the assigned gids, or null if there are
2736 * @throws NameNotFoundException if a package with the given name cannot be
2737 * found on the system.
2739 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
2740 throws NameNotFoundException;
2743 * Return the UID associated with the given package name.
2745 * Note that the same package will have different UIDs under different
2746 * {@link UserHandle} on the same device.
2748 * @param packageName The full name (i.e. com.google.apps.contacts) of the
2750 * @return Returns an integer UID who owns the given package name.
2751 * @throws NameNotFoundException if a package with the given name can not be
2752 * found on the system.
2754 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
2755 throws NameNotFoundException;
2758 * Return the UID associated with the given package name.
2760 * Note that the same package will have different UIDs under different
2761 * {@link UserHandle} on the same device.
2763 * @param packageName The full name (i.e. com.google.apps.contacts) of the
2765 * @param userId The user handle identifier to look up the package under.
2766 * @return Returns an integer UID who owns the given package name.
2767 * @throws NameNotFoundException if a package with the given name can not be
2768 * found on the system.
2771 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
2772 throws NameNotFoundException;
2775 * Return the UID associated with the given package name.
2777 * Note that the same package will have different UIDs under different
2778 * {@link UserHandle} on the same device.
2780 * @param packageName The full name (i.e. com.google.apps.contacts) of the
2782 * @param userId The user handle identifier to look up the package under.
2783 * @return Returns an integer UID who owns the given package name.
2784 * @throws NameNotFoundException if a package with the given name can not be
2785 * found on the system.
2788 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
2789 @UserIdInt int userId) throws NameNotFoundException;
2792 * Retrieve all of the information we know about a particular permission.
2794 * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
2795 * of the permission you are interested in.
2796 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
2797 * retrieve any meta-data associated with the permission.
2799 * @return Returns a {@link PermissionInfo} containing information about the
2801 * @throws NameNotFoundException if a package with the given name cannot be
2802 * found on the system.
2804 * @see #GET_META_DATA
2806 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
2807 throws NameNotFoundException;
2810 * Query for all of the permissions associated with a particular group.
2812 * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
2813 * of the permission group you are interested in. Use null to
2814 * find all of the permissions not associated with a group.
2815 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
2816 * retrieve any meta-data associated with the permissions.
2818 * @return Returns a list of {@link PermissionInfo} containing information
2819 * about all of the permissions in the given group.
2820 * @throws NameNotFoundException if a package with the given name cannot be
2821 * found on the system.
2823 * @see #GET_META_DATA
2825 public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
2826 @PermissionInfoFlags int flags) throws NameNotFoundException;
2829 * Retrieve all of the information we know about a particular group of
2832 * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
2833 * of the permission you are interested in.
2834 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
2835 * retrieve any meta-data associated with the permission group.
2837 * @return Returns a {@link PermissionGroupInfo} containing information
2838 * about the permission.
2839 * @throws NameNotFoundException if a package with the given name cannot be
2840 * found on the system.
2842 * @see #GET_META_DATA
2844 public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
2845 @PermissionGroupInfoFlags int flags) throws NameNotFoundException;
2848 * Retrieve all of the known permission groups in the system.
2850 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
2851 * retrieve any meta-data associated with the permission group.
2853 * @return Returns a list of {@link PermissionGroupInfo} containing
2854 * information about all of the known permission groups.
2856 * @see #GET_META_DATA
2858 public abstract List<PermissionGroupInfo> getAllPermissionGroups(
2859 @PermissionGroupInfoFlags int flags);
2862 * Retrieve all of the information we know about a particular
2863 * package/application.
2865 * @param packageName The full name (i.e. com.google.apps.contacts) of an
2867 * @param flags Additional option flags. Use any combination of
2868 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2869 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
2870 * to modify the data returned.
2872 * @return An {@link ApplicationInfo} containing information about the
2873 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the
2874 * package is not found in the list of installed applications, the
2875 * application information is retrieved from the list of uninstalled
2876 * applications (which includes installed applications as well as
2877 * applications with data directory i.e. applications which had been
2878 * deleted with {@code DONT_DELETE_DATA} flag set).
2879 * @throws NameNotFoundException if a package with the given name cannot be
2880 * found on the system.
2882 * @see #GET_META_DATA
2883 * @see #GET_SHARED_LIBRARY_FILES
2884 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2885 * @see #MATCH_SYSTEM_ONLY
2886 * @see #MATCH_UNINSTALLED_PACKAGES
2888 public abstract ApplicationInfo getApplicationInfo(String packageName,
2889 @ApplicationInfoFlags int flags) throws NameNotFoundException;
2892 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName,
2893 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
2896 * Retrieve all of the information we know about a particular activity
2899 * @param component The full component name (i.e.
2900 * com.google.apps.contacts/com.google.apps.contacts.
2901 * ContactsList) of an Activity class.
2902 * @param flags Additional option flags. Use any combination of
2903 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2904 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2905 * {@link #MATCH_DISABLED_COMPONENTS},
2906 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2907 * {@link #MATCH_DIRECT_BOOT_AWARE},
2908 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2909 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
2911 * @return An {@link ActivityInfo} containing information about the
2913 * @throws NameNotFoundException if a package with the given name cannot be
2914 * found on the system.
2915 * @see #GET_META_DATA
2916 * @see #GET_SHARED_LIBRARY_FILES
2918 * @see #MATCH_DEBUG_TRIAGED_MISSING
2919 * @see #MATCH_DEFAULT_ONLY
2920 * @see #MATCH_DISABLED_COMPONENTS
2921 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2922 * @see #MATCH_DIRECT_BOOT_AWARE
2923 * @see #MATCH_DIRECT_BOOT_UNAWARE
2924 * @see #MATCH_SYSTEM_ONLY
2925 * @see #MATCH_UNINSTALLED_PACKAGES
2927 public abstract ActivityInfo getActivityInfo(ComponentName component,
2928 @ComponentInfoFlags int flags) throws NameNotFoundException;
2931 * Retrieve all of the information we know about a particular receiver
2934 * @param component The full component name (i.e.
2935 * com.google.apps.calendar/com.google.apps.calendar.
2936 * CalendarAlarm) of a Receiver class.
2937 * @param flags Additional option flags. Use any combination of
2938 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2939 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2940 * {@link #MATCH_DISABLED_COMPONENTS},
2941 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2942 * {@link #MATCH_DIRECT_BOOT_AWARE},
2943 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2944 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
2946 * @return An {@link ActivityInfo} containing information about the
2948 * @throws NameNotFoundException if a package with the given name cannot be
2949 * found on the system.
2950 * @see #GET_META_DATA
2951 * @see #GET_SHARED_LIBRARY_FILES
2953 * @see #MATCH_DEBUG_TRIAGED_MISSING
2954 * @see #MATCH_DEFAULT_ONLY
2955 * @see #MATCH_DISABLED_COMPONENTS
2956 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2957 * @see #MATCH_DIRECT_BOOT_AWARE
2958 * @see #MATCH_DIRECT_BOOT_UNAWARE
2959 * @see #MATCH_SYSTEM_ONLY
2960 * @see #MATCH_UNINSTALLED_PACKAGES
2962 public abstract ActivityInfo getReceiverInfo(ComponentName component,
2963 @ComponentInfoFlags int flags) throws NameNotFoundException;
2966 * Retrieve all of the information we know about a particular service class.
2968 * @param component The full component name (i.e.
2969 * com.google.apps.media/com.google.apps.media.
2970 * BackgroundPlayback) of a Service class.
2971 * @param flags Additional option flags. Use any combination of
2972 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2973 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
2974 * {@link #MATCH_DISABLED_COMPONENTS},
2975 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
2976 * {@link #MATCH_DIRECT_BOOT_AWARE},
2977 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
2978 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
2980 * @return A {@link ServiceInfo} object containing information about the
2982 * @throws NameNotFoundException if a package with the given name cannot be
2983 * found on the system.
2984 * @see #GET_META_DATA
2985 * @see #GET_SHARED_LIBRARY_FILES
2987 * @see #MATCH_DEBUG_TRIAGED_MISSING
2988 * @see #MATCH_DEFAULT_ONLY
2989 * @see #MATCH_DISABLED_COMPONENTS
2990 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
2991 * @see #MATCH_DIRECT_BOOT_AWARE
2992 * @see #MATCH_DIRECT_BOOT_UNAWARE
2993 * @see #MATCH_SYSTEM_ONLY
2994 * @see #MATCH_UNINSTALLED_PACKAGES
2996 public abstract ServiceInfo getServiceInfo(ComponentName component,
2997 @ComponentInfoFlags int flags) throws NameNotFoundException;
3000 * Retrieve all of the information we know about a particular content
3003 * @param component The full component name (i.e.
3004 * com.google.providers.media/com.google.providers.media.
3005 * MediaProvider) of a ContentProvider class.
3006 * @param flags Additional option flags. Use any combination of
3007 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3008 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
3009 * {@link #MATCH_DISABLED_COMPONENTS},
3010 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3011 * {@link #MATCH_DIRECT_BOOT_AWARE},
3012 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3013 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3015 * @return A {@link ProviderInfo} object containing information about the
3017 * @throws NameNotFoundException if a package with the given name cannot be
3018 * found on the system.
3019 * @see #GET_META_DATA
3020 * @see #GET_SHARED_LIBRARY_FILES
3022 * @see #MATCH_DEBUG_TRIAGED_MISSING
3023 * @see #MATCH_DEFAULT_ONLY
3024 * @see #MATCH_DISABLED_COMPONENTS
3025 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3026 * @see #MATCH_DIRECT_BOOT_AWARE
3027 * @see #MATCH_DIRECT_BOOT_UNAWARE
3028 * @see #MATCH_SYSTEM_ONLY
3029 * @see #MATCH_UNINSTALLED_PACKAGES
3031 public abstract ProviderInfo getProviderInfo(ComponentName component,
3032 @ComponentInfoFlags int flags) throws NameNotFoundException;
3035 * Return a List of all packages that are installed
3038 * @param flags Additional option flags. Use any combination of
3039 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
3040 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
3041 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
3042 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3043 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3044 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3045 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3046 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3047 * {@link #MATCH_UNINSTALLED_PACKAGES}
3048 * to modify the data returned.
3050 * @return A List of PackageInfo objects, one for each installed package,
3051 * containing information about the package. In the unlikely case
3052 * there are no installed packages, an empty list is returned. If
3053 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3054 * information is retrieved from the list of uninstalled
3055 * applications (which includes installed applications as well as
3056 * applications with data directory i.e. applications which had been
3057 * deleted with {@code DONT_DELETE_DATA} flag set).
3059 * @see #GET_ACTIVITIES
3060 * @see #GET_CONFIGURATIONS
3062 * @see #GET_INSTRUMENTATION
3063 * @see #GET_INTENT_FILTERS
3064 * @see #GET_META_DATA
3065 * @see #GET_PERMISSIONS
3066 * @see #GET_PROVIDERS
3067 * @see #GET_RECEIVERS
3068 * @see #GET_SERVICES
3069 * @see #GET_SHARED_LIBRARY_FILES
3070 * @see #GET_SIGNATURES
3071 * @see #GET_URI_PERMISSION_PATTERNS
3072 * @see #MATCH_DISABLED_COMPONENTS
3073 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3074 * @see #MATCH_UNINSTALLED_PACKAGES
3076 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
3079 * Return a List of all installed packages that are currently
3080 * holding any of the given permissions.
3082 * @param flags Additional option flags. Use any combination of
3083 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
3084 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
3085 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
3086 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3087 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3088 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3089 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3090 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3091 * {@link #MATCH_UNINSTALLED_PACKAGES}
3092 * to modify the data returned.
3094 * @return A List of PackageInfo objects, one for each installed package
3095 * that holds any of the permissions that were provided, containing
3096 * information about the package. If no installed packages hold any
3097 * of the permissions, an empty list is returned. If flag
3098 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package information
3099 * is retrieved from the list of uninstalled applications (which
3100 * includes installed applications as well as applications with data
3101 * directory i.e. applications which had been deleted with
3102 * {@code DONT_DELETE_DATA} flag set).
3104 * @see #GET_ACTIVITIES
3105 * @see #GET_CONFIGURATIONS
3107 * @see #GET_INSTRUMENTATION
3108 * @see #GET_INTENT_FILTERS
3109 * @see #GET_META_DATA
3110 * @see #GET_PERMISSIONS
3111 * @see #GET_PROVIDERS
3112 * @see #GET_RECEIVERS
3113 * @see #GET_SERVICES
3114 * @see #GET_SHARED_LIBRARY_FILES
3115 * @see #GET_SIGNATURES
3116 * @see #GET_URI_PERMISSION_PATTERNS
3117 * @see #MATCH_DISABLED_COMPONENTS
3118 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3119 * @see #MATCH_UNINSTALLED_PACKAGES
3121 public abstract List<PackageInfo> getPackagesHoldingPermissions(
3122 String[] permissions, @PackageInfoFlags int flags);
3125 * Return a List of all packages that are installed on the device, for a specific user.
3126 * Requesting a list of installed packages for another user
3127 * will require the permission INTERACT_ACROSS_USERS_FULL.
3129 * @param flags Additional option flags. Use any combination of
3130 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
3131 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
3132 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
3133 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
3134 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
3135 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
3136 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
3137 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3138 * {@link #MATCH_UNINSTALLED_PACKAGES}
3139 * to modify the data returned.
3140 * @param userId The user for whom the installed packages are to be listed
3142 * @return A List of PackageInfo objects, one for each installed package,
3143 * containing information about the package. In the unlikely case
3144 * there are no installed packages, an empty list is returned. If
3145 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package
3146 * information is retrieved from the list of uninstalled
3147 * applications (which includes installed applications as well as
3148 * applications with data directory i.e. applications which had been
3149 * deleted with {@code DONT_DELETE_DATA} flag set).
3151 * @see #GET_ACTIVITIES
3152 * @see #GET_CONFIGURATIONS
3154 * @see #GET_INSTRUMENTATION
3155 * @see #GET_INTENT_FILTERS
3156 * @see #GET_META_DATA
3157 * @see #GET_PERMISSIONS
3158 * @see #GET_PROVIDERS
3159 * @see #GET_RECEIVERS
3160 * @see #GET_SERVICES
3161 * @see #GET_SHARED_LIBRARY_FILES
3162 * @see #GET_SIGNATURES
3163 * @see #GET_URI_PERMISSION_PATTERNS
3164 * @see #MATCH_DISABLED_COMPONENTS
3165 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3166 * @see #MATCH_UNINSTALLED_PACKAGES
3171 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
3172 @UserIdInt int userId);
3175 * Check whether a particular package has been granted a particular
3178 * @param permName The name of the permission you are checking for.
3179 * @param pkgName The name of the package you are checking against.
3181 * @return If the package has the permission, PERMISSION_GRANTED is
3182 * returned. If it does not have the permission, PERMISSION_DENIED
3185 * @see #PERMISSION_GRANTED
3186 * @see #PERMISSION_DENIED
3189 public abstract int checkPermission(String permName, String pkgName);
3192 * Checks whether a particular permissions has been revoked for a
3193 * package by policy. Typically the device owner or the profile owner
3194 * may apply such a policy. The user cannot grant policy revoked
3195 * permissions, hence the only way for an app to get such a permission
3196 * is by a policy change.
3198 * @param permName The name of the permission you are checking for.
3199 * @param pkgName The name of the package you are checking against.
3201 * @return Whether the permission is restricted by policy.
3204 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
3205 @NonNull String pkgName);
3208 * Gets the package name of the component controlling runtime permissions.
3210 * @return The package name.
3214 public abstract String getPermissionControllerPackageName();
3217 * Add a new dynamic permission to the system. For this to work, your
3218 * package must have defined a permission tree through the
3219 * {@link android.R.styleable#AndroidManifestPermissionTree
3220 * <permission-tree>} tag in its manifest. A package can only add
3221 * permissions to trees that were defined by either its own package or
3222 * another with the same user id; a permission is in a tree if it
3223 * matches the name of the permission tree + ".": for example,
3224 * "com.foo.bar" is a member of the permission tree "com.foo".
3226 * <p>It is good to make your permission tree name descriptive, because you
3227 * are taking possession of that entire set of permission names. Thus, it
3228 * must be under a domain you control, with a suffix that will not match
3229 * any normal permissions that may be declared in any applications that
3230 * are part of that domain.
3232 * <p>New permissions must be added before
3233 * any .apks are installed that use those permissions. Permissions you
3234 * add through this method are remembered across reboots of the device.
3235 * If the given permission already exists, the info you supply here
3236 * will be used to update it.
3238 * @param info Description of the permission to be added.
3240 * @return Returns true if a new permission was created, false if an
3241 * existing one was updated.
3243 * @throws SecurityException if you are not allowed to add the
3244 * given permission name.
3246 * @see #removePermission(String)
3248 public abstract boolean addPermission(PermissionInfo info);
3251 * Like {@link #addPermission(PermissionInfo)} but asynchronously
3252 * persists the package manager state after returning from the call,
3253 * allowing it to return quicker and batch a series of adds at the
3254 * expense of no guarantee the added permission will be retained if
3255 * the device is rebooted before it is written.
3257 public abstract boolean addPermissionAsync(PermissionInfo info);
3260 * Removes a permission that was previously added with
3261 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply
3262 * -- you are only allowed to remove permissions that you are allowed
3265 * @param name The name of the permission to remove.
3267 * @throws SecurityException if you are not allowed to remove the
3268 * given permission name.
3270 * @see #addPermission(PermissionInfo)
3272 public abstract void removePermission(String name);
3276 * Permission flags set when granting or revoking a permission.
3281 @IntDef({FLAG_PERMISSION_USER_SET,
3282 FLAG_PERMISSION_USER_FIXED,
3283 FLAG_PERMISSION_POLICY_FIXED,
3284 FLAG_PERMISSION_REVOKE_ON_UPGRADE,
3285 FLAG_PERMISSION_SYSTEM_FIXED,
3286 FLAG_PERMISSION_GRANTED_BY_DEFAULT})
3287 @Retention(RetentionPolicy.SOURCE)
3288 public @interface PermissionFlags {}
3291 * Grant a runtime permission to an application which the application does not
3292 * already have. The permission must have been requested by the application.
3293 * If the application is not allowed to hold the permission, a {@link
3294 * java.lang.SecurityException} is thrown.
3296 * <strong>Note: </strong>Using this API requires holding
3297 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
3298 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3301 * @param packageName The package to which to grant the permission.
3302 * @param permissionName The permission name to grant.
3303 * @param user The user for which to grant the permission.
3305 * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
3306 * @see android.content.pm.PackageManager.PermissionFlags
3311 public abstract void grantRuntimePermission(@NonNull String packageName,
3312 @NonNull String permissionName, @NonNull UserHandle user);
3315 * Revoke a runtime permission that was previously granted by {@link
3316 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
3317 * permission must have been requested by and granted to the application.
3318 * If the application is not allowed to hold the permission, a {@link
3319 * java.lang.SecurityException} is thrown.
3321 * <strong>Note: </strong>Using this API requires holding
3322 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
3323 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
3326 * @param packageName The package from which to revoke the permission.
3327 * @param permissionName The permission name to revoke.
3328 * @param user The user for which to revoke the permission.
3330 * @see #grantRuntimePermission(String, String, android.os.UserHandle)
3331 * @see android.content.pm.PackageManager.PermissionFlags
3336 public abstract void revokeRuntimePermission(@NonNull String packageName,
3337 @NonNull String permissionName, @NonNull UserHandle user);
3340 * Gets the state flags associated with a permission.
3342 * @param permissionName The permission for which to get the flags.
3343 * @param packageName The package name for which to get the flags.
3344 * @param user The user for which to get permission flags.
3345 * @return The permission flags.
3350 public abstract @PermissionFlags int getPermissionFlags(String permissionName,
3351 String packageName, @NonNull UserHandle user);
3354 * Updates the flags associated with a permission by replacing the flags in
3355 * the specified mask with the provided flag values.
3357 * @param permissionName The permission for which to update the flags.
3358 * @param packageName The package name for which to update the flags.
3359 * @param flagMask The flags which to replace.
3360 * @param flagValues The flags with which to replace.
3361 * @param user The user for which to update the permission flags.
3366 public abstract void updatePermissionFlags(String permissionName,
3367 String packageName, @PermissionFlags int flagMask, int flagValues,
3368 @NonNull UserHandle user);
3371 * Gets whether you should show UI with rationale for requesting a permission.
3372 * You should do this only if you do not have the permission and the context in
3373 * which the permission is requested does not clearly communicate to the user
3374 * what would be the benefit from grating this permission.
3376 * @param permission A permission your app wants to request.
3377 * @return Whether you can show permission rationale UI.
3381 public abstract boolean shouldShowRequestPermissionRationale(String permission);
3384 * Returns an {@link android.content.Intent} suitable for passing to
3385 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
3386 * which prompts the user to grant permissions to this application.
3388 * @throws NullPointerException if {@code permissions} is {@code null} or empty.
3392 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
3393 if (ArrayUtils.isEmpty(permissions)) {
3394 throw new IllegalArgumentException("permission cannot be null or empty");
3396 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
3397 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
3398 intent.setPackage(getPermissionControllerPackageName());
3403 * Compare the signatures of two packages to determine if the same
3404 * signature appears in both of them. If they do contain the same
3405 * signature, then they are allowed special privileges when working
3406 * with each other: they can share the same user-id, run instrumentation
3407 * against each other, etc.
3409 * @param pkg1 First package name whose signature will be compared.
3410 * @param pkg2 Second package name whose signature will be compared.
3412 * @return Returns an integer indicating whether all signatures on the
3413 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3414 * all signatures match or < 0 if there is not a match ({@link
3415 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3417 * @see #checkSignatures(int, int)
3418 * @see #SIGNATURE_MATCH
3419 * @see #SIGNATURE_NO_MATCH
3420 * @see #SIGNATURE_UNKNOWN_PACKAGE
3423 public abstract int checkSignatures(String pkg1, String pkg2);
3426 * Like {@link #checkSignatures(String, String)}, but takes UIDs of
3427 * the two packages to be checked. This can be useful, for example,
3428 * when doing the check in an IPC, where the UID is the only identity
3429 * available. It is functionally identical to determining the package
3430 * associated with the UIDs and checking their signatures.
3432 * @param uid1 First UID whose signature will be compared.
3433 * @param uid2 Second UID whose signature will be compared.
3435 * @return Returns an integer indicating whether all signatures on the
3436 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
3437 * all signatures match or < 0 if there is not a match ({@link
3438 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
3440 * @see #checkSignatures(String, String)
3441 * @see #SIGNATURE_MATCH
3442 * @see #SIGNATURE_NO_MATCH
3443 * @see #SIGNATURE_UNKNOWN_PACKAGE
3446 public abstract int checkSignatures(int uid1, int uid2);
3449 * Retrieve the names of all packages that are associated with a particular
3450 * user id. In most cases, this will be a single package name, the package
3451 * that has been assigned that user id. Where there are multiple packages
3452 * sharing the same user id through the "sharedUserId" mechanism, all
3453 * packages with that id will be returned.
3455 * @param uid The user id for which you would like to retrieve the
3456 * associated packages.
3458 * @return Returns an array of one or more packages assigned to the user
3459 * id, or null if there are no known packages with the given id.
3461 public abstract @Nullable String[] getPackagesForUid(int uid);
3464 * Retrieve the official name associated with a user id. This name is
3465 * guaranteed to never change, though it is possible for the underlying
3466 * user id to be changed. That is, if you are storing information about
3467 * user ids in persistent storage, you should use the string returned
3468 * by this function instead of the raw user-id.
3470 * @param uid The user id for which you would like to retrieve a name.
3471 * @return Returns a unique name for the given user id, or null if the
3472 * user id is not currently assigned.
3474 public abstract @Nullable String getNameForUid(int uid);
3477 * Return the user id associated with a shared user name. Multiple
3478 * applications can specify a shared user name in their manifest and thus
3479 * end up using a common uid. This might be used for new applications
3480 * that use an existing shared user name and need to know the uid of the
3483 * @param sharedUserName The shared user name whose uid is to be retrieved.
3484 * @return Returns the UID associated with the shared user.
3485 * @throws NameNotFoundException if a package with the given name cannot be
3486 * found on the system.
3489 public abstract int getUidForSharedUser(String sharedUserName)
3490 throws NameNotFoundException;
3493 * Return a List of all application packages that are installed on the
3494 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
3495 * applications including those deleted with {@code DONT_DELETE_DATA} (partially
3496 * installed apps with data directory) will be returned.
3498 * @param flags Additional option flags. Use any combination of
3499 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
3500 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES}
3501 * to modify the data returned.
3503 * @return A List of ApplicationInfo objects, one for each installed application.
3504 * In the unlikely case there are no installed packages, an empty list
3505 * is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the
3506 * application information is retrieved from the list of uninstalled
3507 * applications (which includes installed applications as well as
3508 * applications with data directory i.e. applications which had been
3509 * deleted with {@code DONT_DELETE_DATA} flag set).
3511 * @see #GET_META_DATA
3512 * @see #GET_SHARED_LIBRARY_FILES
3513 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3514 * @see #MATCH_SYSTEM_ONLY
3515 * @see #MATCH_UNINSTALLED_PACKAGES
3517 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
3520 * Gets the ephemeral applications the user recently used. Requires
3521 * holding "android.permission.ACCESS_EPHEMERAL_APPS".
3523 * @return The ephemeral app list.
3527 @RequiresPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS)
3528 public abstract List<EphemeralApplicationInfo> getEphemeralApplications();
3531 * Gets the icon for an ephemeral application.
3533 * @param packageName The app package name.
3537 public abstract Drawable getEphemeralApplicationIcon(String packageName);
3540 * Gets whether the caller is an ephemeral app.
3542 * @return Whether caller is an ephemeral app.
3544 * @see #setEphemeralCookie(byte[])
3545 * @see #getEphemeralCookie()
3546 * @see #getEphemeralCookieMaxSizeBytes()
3550 public abstract boolean isEphemeralApplication();
3553 * Gets the maximum size in bytes of the cookie data an ephemeral app
3554 * can store on the device.
3556 * @return The max cookie size in bytes.
3558 * @see #isEphemeralApplication()
3559 * @see #setEphemeralCookie(byte[])
3560 * @see #getEphemeralCookie()
3564 public abstract int getEphemeralCookieMaxSizeBytes();
3567 * Gets the ephemeral application cookie for this app. Non
3568 * ephemeral apps and apps that were ephemeral but were upgraded
3569 * to non-ephemeral can still access this API. For ephemeral apps
3570 * this cooke is cached for some time after uninstall while for
3571 * normal apps the cookie is deleted after the app is uninstalled.
3572 * The cookie is always present while the app is installed.
3574 * @return The cookie.
3576 * @see #isEphemeralApplication()
3577 * @see #setEphemeralCookie(byte[])
3578 * @see #getEphemeralCookieMaxSizeBytes()
3582 public abstract @NonNull byte[] getEphemeralCookie();
3585 * Sets the ephemeral application cookie for the calling app. Non
3586 * ephemeral apps and apps that were ephemeral but were upgraded
3587 * to non-ephemeral can still access this API. For ephemeral apps
3588 * this cooke is cached for some time after uninstall while for
3589 * normal apps the cookie is deleted after the app is uninstalled.
3590 * The cookie is always present while the app is installed. The
3591 * cookie size is limited by {@link #getEphemeralCookieMaxSizeBytes()}.
3593 * @param cookie The cookie data.
3594 * @return True if the cookie was set.
3596 * @see #isEphemeralApplication()
3597 * @see #getEphemeralCookieMaxSizeBytes()
3598 * @see #getEphemeralCookie()
3602 public abstract boolean setEphemeralCookie(@NonNull byte[] cookie);
3605 * Get a list of shared libraries that are available on the
3608 * @return An array of shared library names that are
3609 * available on the system, or null if none are installed.
3612 public abstract String[] getSystemSharedLibraryNames();
3615 * Get the name of the package hosting the services shared library.
3617 * @return The library host package.
3621 public abstract @NonNull String getServicesSystemSharedLibraryPackageName();
3624 * Get the name of the package hosting the shared components shared library.
3626 * @return The library host package.
3630 public abstract @NonNull String getSharedSystemSharedLibraryPackageName();
3633 * Get a list of features that are available on the
3636 * @return An array of FeatureInfo classes describing the features
3637 * that are available on the system, or null if there are none(!!).
3639 public abstract FeatureInfo[] getSystemAvailableFeatures();
3642 * Check whether the given feature name is one of the available features as
3643 * returned by {@link #getSystemAvailableFeatures()}. This tests for the
3644 * presence of <em>any</em> version of the given feature name; use
3645 * {@link #hasSystemFeature(String, int)} to check for a minimum version.
3647 * @return Returns true if the devices supports the feature, else false.
3649 public abstract boolean hasSystemFeature(String name);
3652 * Check whether the given feature name and version is one of the available
3653 * features as returned by {@link #getSystemAvailableFeatures()}. Since
3654 * features are defined to always be backwards compatible, this returns true
3655 * if the available feature version is greater than or equal to the
3656 * requested version.
3658 * @return Returns true if the devices supports the feature, else false.
3660 public abstract boolean hasSystemFeature(String name, int version);
3663 * Determine the best action to perform for a given Intent. This is how
3664 * {@link Intent#resolveActivity} finds an activity if a class has not been
3665 * explicitly specified.
3667 * <em>Note:</em> if using an implicit Intent (without an explicit
3668 * ComponentName specified), be sure to consider whether to set the
3669 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3670 * activity in the same way that
3671 * {@link android.content.Context#startActivity(Intent)} and
3672 * {@link android.content.Intent#resolveActivity(PackageManager)
3673 * Intent.resolveActivity(PackageManager)} do.
3676 * @param intent An intent containing all of the desired specification
3677 * (action, data, type, category, and/or component).
3678 * @param flags Additional option flags. Use any combination of
3679 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3680 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3681 * {@link #MATCH_DISABLED_COMPONENTS},
3682 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3683 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3684 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3685 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3686 * returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3687 * to limit the resolution to only those activities that support
3688 * the {@link android.content.Intent#CATEGORY_DEFAULT}.
3689 * @return Returns a ResolveInfo object containing the final activity intent
3690 * that was determined to be the best action. Returns null if no
3691 * matching activity was found. If multiple matching activities are
3692 * found and there is no default set, returns a ResolveInfo object
3693 * containing something else, such as the activity resolver.
3694 * @see #GET_META_DATA
3695 * @see #GET_RESOLVED_FILTER
3696 * @see #GET_SHARED_LIBRARY_FILES
3698 * @see #MATCH_DISABLED_COMPONENTS
3699 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3700 * @see #MATCH_DEFAULT_ONLY
3701 * @see #MATCH_DIRECT_BOOT_AWARE
3702 * @see #MATCH_DIRECT_BOOT_UNAWARE
3703 * @see #MATCH_SYSTEM_ONLY
3704 * @see #MATCH_UNINSTALLED_PACKAGES
3706 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags);
3709 * Determine the best action to perform for a given Intent for a given user.
3710 * This is how {@link Intent#resolveActivity} finds an activity if a class
3711 * has not been explicitly specified.
3713 * <em>Note:</em> if using an implicit Intent (without an explicit
3714 * ComponentName specified), be sure to consider whether to set the
3715 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the
3716 * activity in the same way that
3717 * {@link android.content.Context#startActivity(Intent)} and
3718 * {@link android.content.Intent#resolveActivity(PackageManager)
3719 * Intent.resolveActivity(PackageManager)} do.
3722 * @param intent An intent containing all of the desired specification
3723 * (action, data, type, category, and/or component).
3724 * @param flags Additional option flags. Use any combination of
3725 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3726 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3727 * {@link #MATCH_DISABLED_COMPONENTS},
3728 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3729 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3730 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3731 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3732 * returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3733 * to limit the resolution to only those activities that support
3734 * the {@link android.content.Intent#CATEGORY_DEFAULT}.
3735 * @param userId The user id.
3736 * @return Returns a ResolveInfo object containing the final activity intent
3737 * that was determined to be the best action. Returns null if no
3738 * matching activity was found. If multiple matching activities are
3739 * found and there is no default set, returns a ResolveInfo object
3740 * containing something else, such as the activity resolver.
3741 * @see #GET_META_DATA
3742 * @see #GET_RESOLVED_FILTER
3743 * @see #GET_SHARED_LIBRARY_FILES
3745 * @see #MATCH_DISABLED_COMPONENTS
3746 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3747 * @see #MATCH_DEFAULT_ONLY
3748 * @see #MATCH_DIRECT_BOOT_AWARE
3749 * @see #MATCH_DIRECT_BOOT_UNAWARE
3750 * @see #MATCH_SYSTEM_ONLY
3751 * @see #MATCH_UNINSTALLED_PACKAGES
3754 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
3755 @UserIdInt int userId);
3758 * Retrieve all activities that can be performed for the given intent.
3760 * @param intent The desired intent as per resolveActivity().
3761 * @param flags Additional option flags. Use any combination of
3762 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3763 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3764 * {@link #MATCH_DISABLED_COMPONENTS},
3765 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3766 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3767 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3768 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3769 * returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3770 * to limit the resolution to only those activities that support
3771 * the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
3772 * {@link #MATCH_ALL} to prevent any filtering of the results.
3773 * @return Returns a List of ResolveInfo objects containing one entry for
3774 * each matching activity, ordered from best to worst. In other
3775 * words, the first item is what would be returned by
3776 * {@link #resolveActivity}. If there are no matching activities, an
3777 * empty list is returned.
3778 * @see #GET_META_DATA
3779 * @see #GET_RESOLVED_FILTER
3780 * @see #GET_SHARED_LIBRARY_FILES
3782 * @see #MATCH_DISABLED_COMPONENTS
3783 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3784 * @see #MATCH_DEFAULT_ONLY
3785 * @see #MATCH_DIRECT_BOOT_AWARE
3786 * @see #MATCH_DIRECT_BOOT_UNAWARE
3787 * @see #MATCH_SYSTEM_ONLY
3788 * @see #MATCH_UNINSTALLED_PACKAGES
3790 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
3791 @ResolveInfoFlags int flags);
3794 * Retrieve all activities that can be performed for the given intent, for a
3797 * @param intent The desired intent as per resolveActivity().
3798 * @param flags Additional option flags. Use any combination of
3799 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3800 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3801 * {@link #MATCH_DISABLED_COMPONENTS},
3802 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3803 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3804 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3805 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3806 * returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3807 * to limit the resolution to only those activities that support
3808 * the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set
3809 * {@link #MATCH_ALL} to prevent any filtering of the results.
3810 * @return Returns a List of ResolveInfo objects containing one entry for
3811 * each matching activity, ordered from best to worst. In other
3812 * words, the first item is what would be returned by
3813 * {@link #resolveActivity}. If there are no matching activities, an
3814 * empty list is returned.
3815 * @see #GET_META_DATA
3816 * @see #GET_RESOLVED_FILTER
3817 * @see #GET_SHARED_LIBRARY_FILES
3819 * @see #MATCH_DISABLED_COMPONENTS
3820 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3821 * @see #MATCH_DEFAULT_ONLY
3822 * @see #MATCH_DIRECT_BOOT_AWARE
3823 * @see #MATCH_DIRECT_BOOT_UNAWARE
3824 * @see #MATCH_SYSTEM_ONLY
3825 * @see #MATCH_UNINSTALLED_PACKAGES
3828 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
3829 @ResolveInfoFlags int flags, @UserIdInt int userId);
3832 * Retrieve a set of activities that should be presented to the user as
3833 * similar options. This is like {@link #queryIntentActivities}, except it
3834 * also allows you to supply a list of more explicit Intents that you would
3835 * like to resolve to particular options, and takes care of returning the
3836 * final ResolveInfo list in a reasonable order, with no duplicates, based
3839 * @param caller The class name of the activity that is making the request.
3840 * This activity will never appear in the output list. Can be
3842 * @param specifics An array of Intents that should be resolved to the first
3843 * specific results. Can be null.
3844 * @param intent The desired intent as per resolveActivity().
3845 * @param flags Additional option flags. Use any combination of
3846 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3847 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3848 * {@link #MATCH_DISABLED_COMPONENTS},
3849 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3850 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3851 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3852 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3853 * returned. The most important is {@link #MATCH_DEFAULT_ONLY},
3854 * to limit the resolution to only those activities that support
3855 * the {@link android.content.Intent#CATEGORY_DEFAULT}.
3856 * @return Returns a List of ResolveInfo objects containing one entry for
3857 * each matching activity. The list is ordered first by all of the
3858 * intents resolved in <var>specifics</var> and then any additional
3859 * activities that can handle <var>intent</var> but did not get
3860 * included by one of the <var>specifics</var> intents. If there are
3861 * no matching activities, an empty list is returned.
3862 * @see #GET_META_DATA
3863 * @see #GET_RESOLVED_FILTER
3864 * @see #GET_SHARED_LIBRARY_FILES
3866 * @see #MATCH_DISABLED_COMPONENTS
3867 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3868 * @see #MATCH_DEFAULT_ONLY
3869 * @see #MATCH_DIRECT_BOOT_AWARE
3870 * @see #MATCH_DIRECT_BOOT_UNAWARE
3871 * @see #MATCH_SYSTEM_ONLY
3872 * @see #MATCH_UNINSTALLED_PACKAGES
3874 public abstract List<ResolveInfo> queryIntentActivityOptions(
3875 ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags);
3878 * Retrieve all receivers that can handle a broadcast of the given intent.
3880 * @param intent The desired intent as per resolveActivity().
3881 * @param flags Additional option flags. Use any combination of
3882 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3883 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3884 * {@link #MATCH_DISABLED_COMPONENTS},
3885 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3886 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3887 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3888 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3890 * @return Returns a List of ResolveInfo objects containing one entry for
3891 * each matching receiver, ordered from best to worst. If there are
3892 * no matching receivers, an empty list or null is returned.
3893 * @see #GET_META_DATA
3894 * @see #GET_RESOLVED_FILTER
3895 * @see #GET_SHARED_LIBRARY_FILES
3897 * @see #MATCH_DISABLED_COMPONENTS
3898 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3899 * @see #MATCH_DEFAULT_ONLY
3900 * @see #MATCH_DIRECT_BOOT_AWARE
3901 * @see #MATCH_DIRECT_BOOT_UNAWARE
3902 * @see #MATCH_SYSTEM_ONLY
3903 * @see #MATCH_UNINSTALLED_PACKAGES
3905 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3906 @ResolveInfoFlags int flags);
3909 * Retrieve all receivers that can handle a broadcast of the given intent,
3910 * for a specific user.
3912 * @param intent The desired intent as per resolveActivity().
3913 * @param flags Additional option flags. Use any combination of
3914 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3915 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3916 * {@link #MATCH_DISABLED_COMPONENTS},
3917 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3918 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3919 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3920 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3922 * @param userHandle UserHandle of the user being queried.
3923 * @return Returns a List of ResolveInfo objects containing one entry for
3924 * each matching receiver, ordered from best to worst. If there are
3925 * no matching receivers, an empty list or null is returned.
3926 * @see #GET_META_DATA
3927 * @see #GET_RESOLVED_FILTER
3928 * @see #GET_SHARED_LIBRARY_FILES
3930 * @see #MATCH_DISABLED_COMPONENTS
3931 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3932 * @see #MATCH_DEFAULT_ONLY
3933 * @see #MATCH_DIRECT_BOOT_AWARE
3934 * @see #MATCH_DIRECT_BOOT_UNAWARE
3935 * @see #MATCH_SYSTEM_ONLY
3936 * @see #MATCH_UNINSTALLED_PACKAGES
3940 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
3941 @ResolveInfoFlags int flags, UserHandle userHandle) {
3942 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier());
3948 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
3949 @ResolveInfoFlags int flags, @UserIdInt int userId);
3954 public List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3955 @ResolveInfoFlags int flags, @UserIdInt int userId) {
3956 Log.w(TAG, "STAHP USING HIDDEN APIS KTHX");
3957 return queryBroadcastReceiversAsUser(intent, flags, userId);
3961 * Determine the best service to handle for a given Intent.
3963 * @param intent An intent containing all of the desired specification
3964 * (action, data, type, category, and/or component).
3965 * @param flags Additional option flags. Use any combination of
3966 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3967 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3968 * {@link #MATCH_DISABLED_COMPONENTS},
3969 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
3970 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
3971 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
3972 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
3974 * @return Returns a ResolveInfo object containing the final service intent
3975 * that was determined to be the best action. Returns null if no
3976 * matching service was found.
3977 * @see #GET_META_DATA
3978 * @see #GET_RESOLVED_FILTER
3979 * @see #GET_SHARED_LIBRARY_FILES
3981 * @see #MATCH_DISABLED_COMPONENTS
3982 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
3983 * @see #MATCH_DEFAULT_ONLY
3984 * @see #MATCH_DIRECT_BOOT_AWARE
3985 * @see #MATCH_DIRECT_BOOT_UNAWARE
3986 * @see #MATCH_SYSTEM_ONLY
3987 * @see #MATCH_UNINSTALLED_PACKAGES
3989 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags);
3992 * Retrieve all services that can match the given intent.
3994 * @param intent The desired intent as per resolveService().
3995 * @param flags Additional option flags. Use any combination of
3996 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
3997 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
3998 * {@link #MATCH_DISABLED_COMPONENTS},
3999 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4000 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4001 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4002 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4004 * @return Returns a List of ResolveInfo objects containing one entry for
4005 * each matching service, ordered from best to worst. In other
4006 * words, the first item is what would be returned by
4007 * {@link #resolveService}. If there are no matching services, an
4008 * empty list or null is returned.
4009 * @see #GET_META_DATA
4010 * @see #GET_RESOLVED_FILTER
4011 * @see #GET_SHARED_LIBRARY_FILES
4013 * @see #MATCH_DISABLED_COMPONENTS
4014 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4015 * @see #MATCH_DEFAULT_ONLY
4016 * @see #MATCH_DIRECT_BOOT_AWARE
4017 * @see #MATCH_DIRECT_BOOT_UNAWARE
4018 * @see #MATCH_SYSTEM_ONLY
4019 * @see #MATCH_UNINSTALLED_PACKAGES
4021 public abstract List<ResolveInfo> queryIntentServices(Intent intent,
4022 @ResolveInfoFlags int flags);
4025 * Retrieve all services that can match the given intent for a given user.
4027 * @param intent The desired intent as per resolveService().
4028 * @param flags Additional option flags. Use any combination of
4029 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4030 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4031 * {@link #MATCH_DISABLED_COMPONENTS},
4032 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4033 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4034 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4035 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4037 * @param userId The user id.
4038 * @return Returns a List of ResolveInfo objects containing one entry for
4039 * each matching service, ordered from best to worst. In other
4040 * words, the first item is what would be returned by
4041 * {@link #resolveService}. If there are no matching services, an
4042 * empty list or null is returned.
4043 * @see #GET_META_DATA
4044 * @see #GET_RESOLVED_FILTER
4045 * @see #GET_SHARED_LIBRARY_FILES
4047 * @see #MATCH_DISABLED_COMPONENTS
4048 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4049 * @see #MATCH_DEFAULT_ONLY
4050 * @see #MATCH_DIRECT_BOOT_AWARE
4051 * @see #MATCH_DIRECT_BOOT_UNAWARE
4052 * @see #MATCH_SYSTEM_ONLY
4053 * @see #MATCH_UNINSTALLED_PACKAGES
4056 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
4057 @ResolveInfoFlags int flags, @UserIdInt int userId);
4060 * Retrieve all providers that can match the given intent.
4062 * @param intent An intent containing all of the desired specification
4063 * (action, data, type, category, and/or component).
4064 * @param flags Additional option flags. Use any combination of
4065 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4066 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4067 * {@link #MATCH_DISABLED_COMPONENTS},
4068 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4069 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4070 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4071 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4073 * @param userId The user id.
4074 * @return Returns a List of ResolveInfo objects containing one entry for
4075 * each matching provider, ordered from best to worst. If there are
4076 * no matching services, an empty list or null is returned.
4077 * @see #GET_META_DATA
4078 * @see #GET_RESOLVED_FILTER
4079 * @see #GET_SHARED_LIBRARY_FILES
4081 * @see #MATCH_DISABLED_COMPONENTS
4082 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4083 * @see #MATCH_DEFAULT_ONLY
4084 * @see #MATCH_DIRECT_BOOT_AWARE
4085 * @see #MATCH_DIRECT_BOOT_UNAWARE
4086 * @see #MATCH_SYSTEM_ONLY
4087 * @see #MATCH_UNINSTALLED_PACKAGES
4090 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
4091 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
4094 * Retrieve all providers that can match the given intent.
4096 * @param intent An intent containing all of the desired specification
4097 * (action, data, type, category, and/or component).
4098 * @param flags Additional option flags. Use any combination of
4099 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER},
4100 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL},
4101 * {@link #MATCH_DISABLED_COMPONENTS},
4102 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4103 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE},
4104 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4105 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4107 * @return Returns a List of ResolveInfo objects containing one entry for
4108 * each matching provider, ordered from best to worst. If there are
4109 * no matching services, an empty list or null is returned.
4110 * @see #GET_META_DATA
4111 * @see #GET_RESOLVED_FILTER
4112 * @see #GET_SHARED_LIBRARY_FILES
4114 * @see #MATCH_DISABLED_COMPONENTS
4115 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4116 * @see #MATCH_DEFAULT_ONLY
4117 * @see #MATCH_DIRECT_BOOT_AWARE
4118 * @see #MATCH_DIRECT_BOOT_UNAWARE
4119 * @see #MATCH_SYSTEM_ONLY
4120 * @see #MATCH_UNINSTALLED_PACKAGES
4122 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent,
4123 @ResolveInfoFlags int flags);
4126 * Find a single content provider by its base path name.
4128 * @param name The name of the provider to find.
4129 * @param flags Additional option flags. Use any combination of
4130 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4131 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4132 * {@link #MATCH_DISABLED_COMPONENTS},
4133 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4134 * {@link #MATCH_DIRECT_BOOT_AWARE},
4135 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4136 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4138 * @return A {@link ProviderInfo} object containing information about the
4139 * provider. If a provider was not found, returns null.
4140 * @see #GET_META_DATA
4141 * @see #GET_SHARED_LIBRARY_FILES
4143 * @see #MATCH_DEBUG_TRIAGED_MISSING
4144 * @see #MATCH_DEFAULT_ONLY
4145 * @see #MATCH_DISABLED_COMPONENTS
4146 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4147 * @see #MATCH_DIRECT_BOOT_AWARE
4148 * @see #MATCH_DIRECT_BOOT_UNAWARE
4149 * @see #MATCH_SYSTEM_ONLY
4150 * @see #MATCH_UNINSTALLED_PACKAGES
4152 public abstract ProviderInfo resolveContentProvider(String name,
4153 @ComponentInfoFlags int flags);
4156 * Find a single content provider by its base path name.
4158 * @param name The name of the provider to find.
4159 * @param flags Additional option flags. Use any combination of
4160 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4161 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4162 * {@link #MATCH_DISABLED_COMPONENTS},
4163 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4164 * {@link #MATCH_DIRECT_BOOT_AWARE},
4165 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4166 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4168 * @param userId The user id.
4169 * @return A {@link ProviderInfo} object containing information about the
4170 * provider. If a provider was not found, returns null.
4171 * @see #GET_META_DATA
4172 * @see #GET_SHARED_LIBRARY_FILES
4174 * @see #MATCH_DEBUG_TRIAGED_MISSING
4175 * @see #MATCH_DEFAULT_ONLY
4176 * @see #MATCH_DISABLED_COMPONENTS
4177 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4178 * @see #MATCH_DIRECT_BOOT_AWARE
4179 * @see #MATCH_DIRECT_BOOT_UNAWARE
4180 * @see #MATCH_SYSTEM_ONLY
4181 * @see #MATCH_UNINSTALLED_PACKAGES
4184 public abstract ProviderInfo resolveContentProviderAsUser(String name,
4185 @ComponentInfoFlags int flags, @UserIdInt int userId);
4188 * Retrieve content provider information.
4190 * <em>Note: unlike most other methods, an empty result set is indicated
4191 * by a null return instead of an empty list.</em>
4193 * @param processName If non-null, limits the returned providers to only
4194 * those that are hosted by the given process. If null, all
4195 * content providers are returned.
4196 * @param uid If <var>processName</var> is non-null, this is the required
4197 * uid owning the requested content providers.
4198 * @param flags Additional option flags. Use any combination of
4199 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
4200 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY},
4201 * {@link #MATCH_DISABLED_COMPONENTS},
4202 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4203 * {@link #MATCH_DIRECT_BOOT_AWARE},
4204 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY}
4205 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data
4207 * @return A list of {@link ProviderInfo} objects containing one entry for
4208 * each provider either matching <var>processName</var> or, if
4209 * <var>processName</var> is null, all known content providers.
4210 * <em>If there are no matching providers, null is returned.</em>
4211 * @see #GET_META_DATA
4212 * @see #GET_SHARED_LIBRARY_FILES
4214 * @see #MATCH_DEBUG_TRIAGED_MISSING
4215 * @see #MATCH_DEFAULT_ONLY
4216 * @see #MATCH_DISABLED_COMPONENTS
4217 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4218 * @see #MATCH_DIRECT_BOOT_AWARE
4219 * @see #MATCH_DIRECT_BOOT_UNAWARE
4220 * @see #MATCH_SYSTEM_ONLY
4221 * @see #MATCH_UNINSTALLED_PACKAGES
4223 public abstract List<ProviderInfo> queryContentProviders(
4224 String processName, int uid, @ComponentInfoFlags int flags);
4227 * Retrieve all of the information we know about a particular
4228 * instrumentation class.
4230 * @param className The full name (i.e.
4231 * com.google.apps.contacts.InstrumentList) of an
4232 * Instrumentation class.
4233 * @param flags Additional option flags. Use any combination of
4234 * {@link #GET_META_DATA}
4235 * to modify the data returned.
4237 * @return An {@link InstrumentationInfo} object containing information about the
4239 * @throws NameNotFoundException if a package with the given name cannot be
4240 * found on the system.
4242 * @see #GET_META_DATA
4244 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
4245 @InstrumentationInfoFlags int flags) throws NameNotFoundException;
4248 * Retrieve information about available instrumentation code. May be used
4249 * to retrieve either all instrumentation code, or only the code targeting
4250 * a particular package.
4252 * @param targetPackage If null, all instrumentation is returned; only the
4253 * instrumentation targeting this package name is
4255 * @param flags Additional option flags. Use any combination of
4256 * {@link #GET_META_DATA}
4257 * to modify the data returned.
4259 * @return A list of {@link InstrumentationInfo} objects containing one
4260 * entry for each matching instrumentation. If there are no
4261 * instrumentation available, returns an empty list.
4263 * @see #GET_META_DATA
4265 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage,
4266 @InstrumentationInfoFlags int flags);
4269 * Retrieve an image from a package. This is a low-level API used by
4270 * the various package manager info structures (such as
4271 * {@link ComponentInfo} to implement retrieval of their associated
4274 * @param packageName The name of the package that this icon is coming from.
4276 * @param resid The resource identifier of the desired image. Cannot be 0.
4277 * @param appInfo Overall information about <var>packageName</var>. This
4278 * may be null, in which case the application information will be retrieved
4279 * for you if needed; if you already have this information around, it can
4280 * be much more efficient to supply it here.
4282 * @return Returns a Drawable holding the requested image. Returns null if
4283 * an image could not be found for any reason.
4285 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
4286 ApplicationInfo appInfo);
4289 * Retrieve the icon associated with an activity. Given the full name of
4290 * an activity, retrieves the information about it and calls
4291 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
4292 * If the activity cannot be found, NameNotFoundException is thrown.
4294 * @param activityName Name of the activity whose icon is to be retrieved.
4296 * @return Returns the image of the icon, or the default activity icon if
4297 * it could not be found. Does not return null.
4298 * @throws NameNotFoundException Thrown if the resources for the given
4299 * activity could not be loaded.
4301 * @see #getActivityIcon(Intent)
4303 public abstract Drawable getActivityIcon(ComponentName activityName)
4304 throws NameNotFoundException;
4307 * Retrieve the icon associated with an Intent. If intent.getClassName() is
4308 * set, this simply returns the result of
4309 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
4310 * component and returns the icon associated with the resolved component.
4311 * If intent.getClassName() cannot be found or the Intent cannot be resolved
4312 * to a component, NameNotFoundException is thrown.
4314 * @param intent The intent for which you would like to retrieve an icon.
4316 * @return Returns the image of the icon, or the default activity icon if
4317 * it could not be found. Does not return null.
4318 * @throws NameNotFoundException Thrown if the resources for application
4319 * matching the given intent could not be loaded.
4321 * @see #getActivityIcon(ComponentName)
4323 public abstract Drawable getActivityIcon(Intent intent)
4324 throws NameNotFoundException;
4327 * Retrieve the banner associated with an activity. Given the full name of
4328 * an activity, retrieves the information about it and calls
4329 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
4330 * banner. If the activity cannot be found, NameNotFoundException is thrown.
4332 * @param activityName Name of the activity whose banner is to be retrieved.
4333 * @return Returns the image of the banner, or null if the activity has no
4335 * @throws NameNotFoundException Thrown if the resources for the given
4336 * activity could not be loaded.
4337 * @see #getActivityBanner(Intent)
4339 public abstract Drawable getActivityBanner(ComponentName activityName)
4340 throws NameNotFoundException;
4343 * Retrieve the banner associated with an Intent. If intent.getClassName()
4344 * is set, this simply returns the result of
4345 * getActivityBanner(intent.getClassName()). Otherwise it resolves the
4346 * intent's component and returns the banner associated with the resolved
4347 * component. If intent.getClassName() cannot be found or the Intent cannot
4348 * be resolved to a component, NameNotFoundException is thrown.
4350 * @param intent The intent for which you would like to retrieve a banner.
4351 * @return Returns the image of the banner, or null if the activity has no
4353 * @throws NameNotFoundException Thrown if the resources for application
4354 * matching the given intent could not be loaded.
4355 * @see #getActivityBanner(ComponentName)
4357 public abstract Drawable getActivityBanner(Intent intent)
4358 throws NameNotFoundException;
4361 * Return the generic icon for an activity that is used when no specific
4364 * @return Drawable Image of the icon.
4366 public abstract Drawable getDefaultActivityIcon();
4369 * Retrieve the icon associated with an application. If it has not defined
4370 * an icon, the default app icon is returned. Does not return null.
4372 * @param info Information about application being queried.
4374 * @return Returns the image of the icon, or the default application icon
4375 * if it could not be found.
4377 * @see #getApplicationIcon(String)
4379 public abstract Drawable getApplicationIcon(ApplicationInfo info);
4382 * Retrieve the icon associated with an application. Given the name of the
4383 * application's package, retrieves the information about it and calls
4384 * getApplicationIcon() to return its icon. If the application cannot be
4385 * found, NameNotFoundException is thrown.
4387 * @param packageName Name of the package whose application icon is to be
4390 * @return Returns the image of the icon, or the default application icon
4391 * if it could not be found. Does not return null.
4392 * @throws NameNotFoundException Thrown if the resources for the given
4393 * application could not be loaded.
4395 * @see #getApplicationIcon(ApplicationInfo)
4397 public abstract Drawable getApplicationIcon(String packageName)
4398 throws NameNotFoundException;
4401 * Retrieve the banner associated with an application.
4403 * @param info Information about application being queried.
4404 * @return Returns the image of the banner or null if the application has no
4406 * @see #getApplicationBanner(String)
4408 public abstract Drawable getApplicationBanner(ApplicationInfo info);
4411 * Retrieve the banner associated with an application. Given the name of the
4412 * application's package, retrieves the information about it and calls
4413 * getApplicationIcon() to return its banner. If the application cannot be
4414 * found, NameNotFoundException is thrown.
4416 * @param packageName Name of the package whose application banner is to be
4418 * @return Returns the image of the banner or null if the application has no
4420 * @throws NameNotFoundException Thrown if the resources for the given
4421 * application could not be loaded.
4422 * @see #getApplicationBanner(ApplicationInfo)
4424 public abstract Drawable getApplicationBanner(String packageName)
4425 throws NameNotFoundException;
4428 * Retrieve the logo associated with an activity. Given the full name of an
4429 * activity, retrieves the information about it and calls
4430 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
4431 * logo. If the activity cannot be found, NameNotFoundException is thrown.
4433 * @param activityName Name of the activity whose logo is to be retrieved.
4434 * @return Returns the image of the logo or null if the activity has no logo
4436 * @throws NameNotFoundException Thrown if the resources for the given
4437 * activity could not be loaded.
4438 * @see #getActivityLogo(Intent)
4440 public abstract Drawable getActivityLogo(ComponentName activityName)
4441 throws NameNotFoundException;
4444 * Retrieve the logo associated with an Intent. If intent.getClassName() is
4445 * set, this simply returns the result of
4446 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's
4447 * component and returns the logo associated with the resolved component.
4448 * If intent.getClassName() cannot be found or the Intent cannot be resolved
4449 * to a component, NameNotFoundException is thrown.
4451 * @param intent The intent for which you would like to retrieve a logo.
4453 * @return Returns the image of the logo, or null if the activity has no
4456 * @throws NameNotFoundException Thrown if the resources for application
4457 * matching the given intent could not be loaded.
4459 * @see #getActivityLogo(ComponentName)
4461 public abstract Drawable getActivityLogo(Intent intent)
4462 throws NameNotFoundException;
4465 * Retrieve the logo associated with an application. If it has not specified
4466 * a logo, this method returns null.
4468 * @param info Information about application being queried.
4470 * @return Returns the image of the logo, or null if no logo is specified
4471 * by the application.
4473 * @see #getApplicationLogo(String)
4475 public abstract Drawable getApplicationLogo(ApplicationInfo info);
4478 * Retrieve the logo associated with an application. Given the name of the
4479 * application's package, retrieves the information about it and calls
4480 * getApplicationLogo() to return its logo. If the application cannot be
4481 * found, NameNotFoundException is thrown.
4483 * @param packageName Name of the package whose application logo is to be
4486 * @return Returns the image of the logo, or null if no application logo
4487 * has been specified.
4489 * @throws NameNotFoundException Thrown if the resources for the given
4490 * application could not be loaded.
4492 * @see #getApplicationLogo(ApplicationInfo)
4494 public abstract Drawable getApplicationLogo(String packageName)
4495 throws NameNotFoundException;
4498 * Returns a managed-user-style badged copy of the given drawable allowing the user to
4499 * distinguish it from the original drawable.
4500 * The caller can specify the location in the bounds of the drawable to be
4501 * badged where the badge should be applied as well as the density of the
4504 * If the original drawable is a BitmapDrawable and the backing bitmap is
4505 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4506 * is performed in place and the original drawable is returned.
4509 * @param drawable The drawable to badge.
4510 * @param badgeLocation Where in the bounds of the badged drawable to place
4511 * the badge. If it's {@code null}, the badge is applied on top of the entire
4512 * drawable being badged.
4513 * @param badgeDensity The optional desired density for the badge as per
4514 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4515 * the density of the display is used.
4516 * @return A drawable that combines the original drawable and a badge as
4517 * determined by the system.
4520 public abstract Drawable getManagedUserBadgedDrawable(Drawable drawable, Rect badgeLocation,
4524 * If the target user is a managed profile, then this returns a badged copy of the given icon
4525 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use
4526 * {@link #getUserBadgedDrawableForDensity(
4527 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
4529 * If the original drawable is a BitmapDrawable and the backing bitmap is
4530 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4531 * is performed in place and the original drawable is returned.
4534 * @param icon The icon to badge.
4535 * @param user The target user.
4536 * @return A drawable that combines the original icon and a badge as
4537 * determined by the system.
4539 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
4542 * If the target user is a managed profile of the calling user or the caller
4543 * is itself a managed profile, then this returns a badged copy of the given
4544 * drawable allowing the user to distinguish it from the original drawable.
4545 * The caller can specify the location in the bounds of the drawable to be
4546 * badged where the badge should be applied as well as the density of the
4549 * If the original drawable is a BitmapDrawable and the backing bitmap is
4550 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
4551 * is performed in place and the original drawable is returned.
4554 * @param drawable The drawable to badge.
4555 * @param user The target user.
4556 * @param badgeLocation Where in the bounds of the badged drawable to place
4557 * the badge. If it's {@code null}, the badge is applied on top of the entire
4558 * drawable being badged.
4559 * @param badgeDensity The optional desired density for the badge as per
4560 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive,
4561 * the density of the display is used.
4562 * @return A drawable that combines the original drawable and a badge as
4563 * determined by the system.
4565 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
4566 UserHandle user, Rect badgeLocation, int badgeDensity);
4569 * If the target user is a managed profile of the calling user or the caller
4570 * is itself a managed profile, then this returns a drawable to use as a small
4571 * icon to include in a view to distinguish it from the original icon.
4573 * @param user The target user.
4574 * @param density The optional desired density for the badge as per
4575 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
4576 * the density of the current display is used.
4577 * @return the drawable or null if no drawable is required.
4580 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
4583 * If the target user is a managed profile of the calling user or the caller
4584 * is itself a managed profile, then this returns a drawable to use as a small
4585 * icon to include in a view to distinguish it from the original icon. This version
4586 * doesn't have background protection and should be used over a light background instead of
4589 * @param user The target user.
4590 * @param density The optional desired density for the badge as per
4591 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
4592 * the density of the current display is used.
4593 * @return the drawable or null if no drawable is required.
4596 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
4599 * If the target user is a managed profile of the calling user or the caller
4600 * is itself a managed profile, then this returns a copy of the label with
4601 * badging for accessibility services like talkback. E.g. passing in "Email"
4602 * and it might return "Work Email" for Email in the work profile.
4604 * @param label The label to change.
4605 * @param user The target user.
4606 * @return A label that combines the original label and a badge as
4607 * determined by the system.
4609 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
4612 * Retrieve text from a package. This is a low-level API used by
4613 * the various package manager info structures (such as
4614 * {@link ComponentInfo} to implement retrieval of their associated
4615 * labels and other text.
4617 * @param packageName The name of the package that this text is coming from.
4619 * @param resid The resource identifier of the desired text. Cannot be 0.
4620 * @param appInfo Overall information about <var>packageName</var>. This
4621 * may be null, in which case the application information will be retrieved
4622 * for you if needed; if you already have this information around, it can
4623 * be much more efficient to supply it here.
4625 * @return Returns a CharSequence holding the requested text. Returns null
4626 * if the text could not be found for any reason.
4628 public abstract CharSequence getText(String packageName, @StringRes int resid,
4629 ApplicationInfo appInfo);
4632 * Retrieve an XML file from a package. This is a low-level API used to
4633 * retrieve XML meta data.
4635 * @param packageName The name of the package that this xml is coming from.
4637 * @param resid The resource identifier of the desired xml. Cannot be 0.
4638 * @param appInfo Overall information about <var>packageName</var>. This
4639 * may be null, in which case the application information will be retrieved
4640 * for you if needed; if you already have this information around, it can
4641 * be much more efficient to supply it here.
4643 * @return Returns an XmlPullParser allowing you to parse out the XML
4644 * data. Returns null if the xml resource could not be found for any
4647 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
4648 ApplicationInfo appInfo);
4651 * Return the label to use for this application.
4653 * @return Returns the label associated with this application, or null if
4654 * it could not be found for any reason.
4655 * @param info The application to get the label of.
4657 public abstract CharSequence getApplicationLabel(ApplicationInfo info);
4660 * Retrieve the resources associated with an activity. Given the full
4661 * name of an activity, retrieves the information about it and calls
4662 * getResources() to return its application's resources. If the activity
4663 * cannot be found, NameNotFoundException is thrown.
4665 * @param activityName Name of the activity whose resources are to be
4668 * @return Returns the application's Resources.
4669 * @throws NameNotFoundException Thrown if the resources for the given
4670 * application could not be loaded.
4672 * @see #getResourcesForApplication(ApplicationInfo)
4674 public abstract Resources getResourcesForActivity(ComponentName activityName)
4675 throws NameNotFoundException;
4678 * Retrieve the resources for an application. Throws NameNotFoundException
4679 * if the package is no longer installed.
4681 * @param app Information about the desired application.
4683 * @return Returns the application's Resources.
4684 * @throws NameNotFoundException Thrown if the resources for the given
4685 * application could not be loaded (most likely because it was uninstalled).
4687 public abstract Resources getResourcesForApplication(ApplicationInfo app)
4688 throws NameNotFoundException;
4691 * Retrieve the resources associated with an application. Given the full
4692 * package name of an application, retrieves the information about it and
4693 * calls getResources() to return its application's resources. If the
4694 * appPackageName cannot be found, NameNotFoundException is thrown.
4696 * @param appPackageName Package name of the application whose resources
4697 * are to be retrieved.
4699 * @return Returns the application's Resources.
4700 * @throws NameNotFoundException Thrown if the resources for the given
4701 * application could not be loaded.
4703 * @see #getResourcesForApplication(ApplicationInfo)
4705 public abstract Resources getResourcesForApplication(String appPackageName)
4706 throws NameNotFoundException;
4709 public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
4710 @UserIdInt int userId) throws NameNotFoundException;
4713 * Retrieve overall information about an application package defined
4714 * in a package archive file
4716 * @param archiveFilePath The path to the archive file
4717 * @param flags Additional option flags. Use any combination of
4718 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
4719 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
4720 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
4721 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
4722 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
4723 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
4724 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
4725 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
4726 * {@link #MATCH_UNINSTALLED_PACKAGES}
4727 * to modify the data returned.
4729 * @return A PackageInfo object containing information about the
4730 * package archive. If the package could not be parsed,
4733 * @see #GET_ACTIVITIES
4734 * @see #GET_CONFIGURATIONS
4736 * @see #GET_INSTRUMENTATION
4737 * @see #GET_INTENT_FILTERS
4738 * @see #GET_META_DATA
4739 * @see #GET_PERMISSIONS
4740 * @see #GET_PROVIDERS
4741 * @see #GET_RECEIVERS
4742 * @see #GET_SERVICES
4743 * @see #GET_SHARED_LIBRARY_FILES
4744 * @see #GET_SIGNATURES
4745 * @see #GET_URI_PERMISSION_PATTERNS
4746 * @see #MATCH_DISABLED_COMPONENTS
4747 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
4748 * @see #MATCH_UNINSTALLED_PACKAGES
4751 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) {
4752 final PackageParser parser = new PackageParser();
4753 final File apkFile = new File(archiveFilePath);
4755 if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) {
4756 // Caller expressed an explicit opinion about what encryption
4757 // aware/unaware components they want to see, so fall through and
4758 // give them what they want
4760 // Caller expressed no opinion, so match everything
4761 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
4764 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
4765 if ((flags & GET_SIGNATURES) != 0) {
4766 PackageParser.collectCertificates(pkg, 0);
4768 PackageUserState state = new PackageUserState();
4769 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
4770 } catch (PackageParserException e) {
4776 * @deprecated replaced by {@link PackageInstaller}
4780 public abstract void installPackage(
4782 IPackageInstallObserver observer,
4783 @InstallFlags int flags,
4784 String installerPackageName);
4786 * @deprecated replaced by {@link PackageInstaller}
4790 public abstract void installPackage(
4792 PackageInstallObserver observer,
4793 @InstallFlags int flags,
4794 String installerPackageName);
4797 * If there is already an application with the given package name installed
4798 * on the system for other users, also install it for the calling user.
4801 public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
4804 * If there is already an application with the given package name installed
4805 * on the system for other users, also install it for the specified user.
4808 @RequiresPermission(anyOf = {
4809 Manifest.permission.INSTALL_PACKAGES,
4810 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4811 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
4812 throws NameNotFoundException;
4815 * Allows a package listening to the
4816 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4817 * broadcast} to respond to the package manager. The response must include
4818 * the {@code verificationCode} which is one of
4819 * {@link PackageManager#VERIFICATION_ALLOW} or
4820 * {@link PackageManager#VERIFICATION_REJECT}.
4822 * @param id pending package identifier as passed via the
4823 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4824 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
4825 * or {@link PackageManager#VERIFICATION_REJECT}.
4826 * @throws SecurityException if the caller does not have the
4827 * PACKAGE_VERIFICATION_AGENT permission.
4829 public abstract void verifyPendingInstall(int id, int verificationCode);
4832 * Allows a package listening to the
4833 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4834 * broadcast} to extend the default timeout for a response and declare what
4835 * action to perform after the timeout occurs. The response must include
4836 * the {@code verificationCodeAtTimeout} which is one of
4837 * {@link PackageManager#VERIFICATION_ALLOW} or
4838 * {@link PackageManager#VERIFICATION_REJECT}.
4840 * This method may only be called once per package id. Additional calls
4841 * will have no effect.
4843 * @param id pending package identifier as passed via the
4844 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4845 * @param verificationCodeAtTimeout either
4846 * {@link PackageManager#VERIFICATION_ALLOW} or
4847 * {@link PackageManager#VERIFICATION_REJECT}. If
4848 * {@code verificationCodeAtTimeout} is neither
4849 * {@link PackageManager#VERIFICATION_ALLOW} or
4850 * {@link PackageManager#VERIFICATION_REJECT}, then
4851 * {@code verificationCodeAtTimeout} will default to
4852 * {@link PackageManager#VERIFICATION_REJECT}.
4853 * @param millisecondsToDelay the amount of time requested for the timeout.
4854 * Must be positive and less than
4855 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4856 * {@code millisecondsToDelay} is out of bounds,
4857 * {@code millisecondsToDelay} will be set to the closest in
4858 * bounds value; namely, 0 or
4859 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
4860 * @throws SecurityException if the caller does not have the
4861 * PACKAGE_VERIFICATION_AGENT permission.
4863 public abstract void extendVerificationTimeout(int id,
4864 int verificationCodeAtTimeout, long millisecondsToDelay);
4867 * Allows a package listening to the
4868 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification
4869 * broadcast to respond to the package manager. The response must include
4870 * the {@code verificationCode} which is one of
4871 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4872 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4874 * @param verificationId pending package identifier as passed via the
4875 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4876 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4877 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4878 * @param failedDomains a list of failed domains if the verificationCode is
4879 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4880 * @throws SecurityException if the caller does not have the
4881 * INTENT_FILTER_VERIFICATION_AGENT permission.
4886 public abstract void verifyIntentFilter(int verificationId, int verificationCode,
4887 List<String> failedDomains);
4890 * Get the status of a Domain Verification Result for an IntentFilter. This is
4891 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4892 * {@link android.content.IntentFilter#getAutoVerify()}
4894 * This is used by the ResolverActivity to change the status depending on what the User select
4895 * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4898 * @param packageName The package name of the Activity associated with the IntentFilter.
4899 * @param userId The user id.
4901 * @return The status to set to. This can be
4902 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4903 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4904 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4905 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4909 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
4912 * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4913 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4914 * {@link android.content.IntentFilter#getAutoVerify()}
4916 * This is used by the ResolverActivity to change the status depending on what the User select
4917 * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4920 * @param packageName The package name of the Activity associated with the IntentFilter.
4921 * @param status The status to set to. This can be
4922 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4923 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4924 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4925 * @param userId The user id.
4927 * @return true if the status has been set. False otherwise.
4931 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
4932 @UserIdInt int userId);
4935 * Get the list of IntentFilterVerificationInfo for a specific package and User.
4937 * @param packageName the package name. When this parameter is set to a non null value,
4938 * the results will be filtered by the package name provided.
4939 * Otherwise, there will be no filtering and it will return a list
4940 * corresponding for all packages
4942 * @return a list of IntentFilterVerificationInfo for a specific package.
4946 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4947 String packageName);
4950 * Get the list of IntentFilter for a specific package.
4952 * @param packageName the package name. This parameter is set to a non null value,
4953 * the list will contain all the IntentFilter for that package.
4954 * Otherwise, the list will be empty.
4956 * @return a list of IntentFilter for a specific package.
4960 public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4963 * Get the default Browser package name for a specific user.
4965 * @param userId The user id.
4967 * @return the package name of the default Browser for the specified user. If the user id passed
4968 * is -1 (all users) it will return a null value.
4973 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
4976 * Set the default Browser package name for a specific user.
4978 * @param packageName The package name of the default Browser.
4979 * @param userId The user id.
4981 * @return true if the default Browser for the specified user has been set,
4982 * otherwise return false. If the user id passed is -1 (all users) this call will not
4983 * do anything and just return false.
4987 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
4988 @UserIdInt int userId);
4991 * Change the installer associated with a given package. There are limitations
4992 * on how the installer package can be changed; in particular:
4994 * <li> A SecurityException will be thrown if <var>installerPackageName</var>
4995 * is not signed with the same certificate as the calling application.
4996 * <li> A SecurityException will be thrown if <var>targetPackage</var> already
4997 * has an installer package, and that installer package is not signed with
4998 * the same certificate as the calling application.
5001 * @param targetPackage The installed package whose installer will be changed.
5002 * @param installerPackageName The package name of the new installer. May be
5003 * null to clear the association.
5005 public abstract void setInstallerPackageName(String targetPackage,
5006 String installerPackageName);
5009 * Attempts to delete a package. Since this may take a little while, the
5010 * result will be posted back to the given observer. A deletion will fail if
5011 * the calling context lacks the
5012 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
5013 * named package cannot be found, or if the named package is a system
5016 * @param packageName The name of the package to delete
5017 * @param observer An observer callback to get notified when the package
5018 * deletion is complete.
5019 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5020 * will be called when that happens. observer may be null to
5021 * indicate that no callback is desired.
5024 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer,
5025 @DeleteFlags int flags);
5028 * Attempts to delete a package. Since this may take a little while, the
5029 * result will be posted back to the given observer. A deletion will fail if
5030 * the named package cannot be found, or if the named package is a system
5033 * @param packageName The name of the package to delete
5034 * @param observer An observer callback to get notified when the package
5035 * deletion is complete.
5036 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted}
5037 * will be called when that happens. observer may be null to
5038 * indicate that no callback is desired.
5039 * @param userId The user Id
5042 @RequiresPermission(anyOf = {
5043 Manifest.permission.DELETE_PACKAGES,
5044 Manifest.permission.INTERACT_ACROSS_USERS_FULL})
5045 public abstract void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
5046 @DeleteFlags int flags, @UserIdInt int userId);
5049 * Retrieve the package name of the application that installed a package. This identifies
5050 * which market the package came from.
5052 * @param packageName The name of the package to query
5054 public abstract String getInstallerPackageName(String packageName);
5057 * Attempts to clear the user data directory of an application.
5058 * Since this may take a little while, the result will
5059 * be posted back to the given observer. A deletion will fail if the
5060 * named package cannot be found, or if the named package is a "system package".
5062 * @param packageName The name of the package
5063 * @param observer An observer callback to get notified when the operation is finished
5064 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5065 * will be called when that happens. observer may be null to indicate that
5066 * no callback is desired.
5070 public abstract void clearApplicationUserData(String packageName,
5071 IPackageDataObserver observer);
5073 * Attempts to delete the cache files associated with an application.
5074 * Since this may take a little while, the result will
5075 * be posted back to the given observer. A deletion will fail if the calling context
5076 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
5077 * named package cannot be found, or if the named package is a "system package".
5079 * @param packageName The name of the package to delete
5080 * @param observer An observer callback to get notified when the cache file deletion
5082 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5083 * will be called when that happens. observer may be null to indicate that
5084 * no callback is desired.
5088 public abstract void deleteApplicationCacheFiles(String packageName,
5089 IPackageDataObserver observer);
5092 * Attempts to delete the cache files associated with an application for a given user. Since
5093 * this may take a little while, the result will be posted back to the given observer. A
5094 * deletion will fail if the calling context lacks the
5095 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package
5096 * cannot be found, or if the named package is a "system package". If {@code userId} does not
5097 * belong to the calling user, the caller must have
5098 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
5100 * @param packageName The name of the package to delete
5101 * @param userId the user for which the cache files needs to be deleted
5102 * @param observer An observer callback to get notified when the cache file deletion is
5104 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
5105 * will be called when that happens. observer may be null to indicate that no
5106 * callback is desired.
5109 public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId,
5110 IPackageDataObserver observer);
5113 * Free storage by deleting LRU sorted list of cache files across
5114 * all applications. If the currently available free storage
5115 * on the device is greater than or equal to the requested
5116 * free storage, no cache files are cleared. If the currently
5117 * available storage on the device is less than the requested
5118 * free storage, some or all of the cache files across
5119 * all applications are deleted (based on last accessed time)
5120 * to increase the free storage space on the device to
5121 * the requested value. There is no guarantee that clearing all
5122 * the cache files from all applications will clear up
5123 * enough storage to achieve the desired value.
5124 * @param freeStorageSize The number of bytes of storage to be
5125 * freed by the system. Say if freeStorageSize is XX,
5126 * and the current free storage is YY,
5127 * if XX is less than YY, just return. if not free XX-YY number
5128 * of bytes if possible.
5129 * @param observer call back used to notify when
5130 * the operation is completed
5134 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
5135 freeStorageAndNotify(null, freeStorageSize, observer);
5139 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
5140 IPackageDataObserver observer);
5143 * Free storage by deleting LRU sorted list of cache files across
5144 * all applications. If the currently available free storage
5145 * on the device is greater than or equal to the requested
5146 * free storage, no cache files are cleared. If the currently
5147 * available storage on the device is less than the requested
5148 * free storage, some or all of the cache files across
5149 * all applications are deleted (based on last accessed time)
5150 * to increase the free storage space on the device to
5151 * the requested value. There is no guarantee that clearing all
5152 * the cache files from all applications will clear up
5153 * enough storage to achieve the desired value.
5154 * @param freeStorageSize The number of bytes of storage to be
5155 * freed by the system. Say if freeStorageSize is XX,
5156 * and the current free storage is YY,
5157 * if XX is less than YY, just return. if not free XX-YY number
5158 * of bytes if possible.
5159 * @param pi IntentSender call back used to
5160 * notify when the operation is completed.May be null
5161 * to indicate that no call back is desired.
5165 public void freeStorage(long freeStorageSize, IntentSender pi) {
5166 freeStorage(null, freeStorageSize, pi);
5170 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
5173 * Retrieve the size information for a package.
5174 * Since this may take a little while, the result will
5175 * be posted back to the given observer. The calling context
5176 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
5178 * @param packageName The name of the package whose size information is to be retrieved
5179 * @param userId The user whose size information should be retrieved.
5180 * @param observer An observer callback to get notified when the operation
5182 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
5183 * The observer's callback is invoked with a PackageStats object(containing the
5184 * code, data and cache sizes of the package) and a boolean value representing
5185 * the status of the operation. observer may be null to indicate that
5186 * no callback is desired.
5190 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
5191 IPackageStatsObserver observer);
5194 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but
5195 * returns the size for the calling user.
5199 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
5200 getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer);
5204 * @deprecated This function no longer does anything; it was an old
5205 * approach to managing preferred activities, which has been superseded
5206 * by (and conflicts with) the modern activity-based preferences.
5209 public abstract void addPackageToPreferred(String packageName);
5212 * @deprecated This function no longer does anything; it was an old
5213 * approach to managing preferred activities, which has been superseded
5214 * by (and conflicts with) the modern activity-based preferences.
5217 public abstract void removePackageFromPreferred(String packageName);
5220 * Retrieve the list of all currently configured preferred packages. The
5221 * first package on the list is the most preferred, the last is the
5224 * @param flags Additional option flags. Use any combination of
5225 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
5226 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
5227 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA},
5228 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
5229 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
5230 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES},
5231 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES},
5232 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS},
5233 * {@link #MATCH_UNINSTALLED_PACKAGES}
5234 * to modify the data returned.
5236 * @return A List of PackageInfo objects, one for each preferred application,
5237 * in order of preference.
5239 * @see #GET_ACTIVITIES
5240 * @see #GET_CONFIGURATIONS
5242 * @see #GET_INSTRUMENTATION
5243 * @see #GET_INTENT_FILTERS
5244 * @see #GET_META_DATA
5245 * @see #GET_PERMISSIONS
5246 * @see #GET_PROVIDERS
5247 * @see #GET_RECEIVERS
5248 * @see #GET_SERVICES
5249 * @see #GET_SHARED_LIBRARY_FILES
5250 * @see #GET_SIGNATURES
5251 * @see #GET_URI_PERMISSION_PATTERNS
5252 * @see #MATCH_DISABLED_COMPONENTS
5253 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS
5254 * @see #MATCH_UNINSTALLED_PACKAGES
5256 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags);
5259 * @deprecated This is a protected API that should not have been available
5260 * to third party applications. It is the platform's responsibility for
5261 * assigning preferred activities and this cannot be directly modified.
5263 * Add a new preferred activity mapping to the system. This will be used
5264 * to automatically select the given activity component when
5265 * {@link Context#startActivity(Intent) Context.startActivity()} finds
5266 * multiple matching activities and also matches the given filter.
5268 * @param filter The set of intents under which this activity will be
5270 * @param match The IntentFilter match category that this preference
5272 * @param set The set of activities that the user was picking from when
5273 * this preference was made.
5274 * @param activity The component name of the activity that is to be
5278 public abstract void addPreferredActivity(IntentFilter filter, int match,
5279 ComponentName[] set, ComponentName activity);
5282 * Same as {@link #addPreferredActivity(IntentFilter, int,
5283 ComponentName[], ComponentName)}, but with a specific userId to apply the preference
5287 public void addPreferredActivityAsUser(IntentFilter filter, int match,
5288 ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5289 throw new RuntimeException("Not implemented. Must override in a subclass.");
5293 * @deprecated This is a protected API that should not have been available
5294 * to third party applications. It is the platform's responsibility for
5295 * assigning preferred activities and this cannot be directly modified.
5297 * Replaces an existing preferred activity mapping to the system, and if that were not present
5298 * adds a new preferred activity. This will be used
5299 * to automatically select the given activity component when
5300 * {@link Context#startActivity(Intent) Context.startActivity()} finds
5301 * multiple matching activities and also matches the given filter.
5303 * @param filter The set of intents under which this activity will be
5305 * @param match The IntentFilter match category that this preference
5307 * @param set The set of activities that the user was picking from when
5308 * this preference was made.
5309 * @param activity The component name of the activity that is to be
5314 public abstract void replacePreferredActivity(IntentFilter filter, int match,
5315 ComponentName[] set, ComponentName activity);
5321 public void replacePreferredActivityAsUser(IntentFilter filter, int match,
5322 ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
5323 throw new RuntimeException("Not implemented. Must override in a subclass.");
5327 * Remove all preferred activity mappings, previously added with
5328 * {@link #addPreferredActivity}, from the
5329 * system whose activities are implemented in the given package name.
5330 * An application can only clear its own package(s).
5332 * @param packageName The name of the package whose preferred activity
5333 * mappings are to be removed.
5335 public abstract void clearPackagePreferredActivities(String packageName);
5338 * Retrieve all preferred activities, previously added with
5339 * {@link #addPreferredActivity}, that are
5340 * currently registered with the system.
5342 * @param outFilters A required list in which to place the filters of all of the
5343 * preferred activities.
5344 * @param outActivities A required list in which to place the component names of
5345 * all of the preferred activities.
5346 * @param packageName An optional package in which you would like to limit
5347 * the list. If null, all activities will be returned; if non-null, only
5348 * those activities in the given package are returned.
5350 * @return Returns the total number of registered preferred activities
5351 * (the number of distinct IntentFilter records, not the number of unique
5352 * activity components) that were found.
5354 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
5355 @NonNull List<ComponentName> outActivities, String packageName);
5358 * Ask for the set of available 'home' activities and the current explicit
5362 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
5365 * Set the enabled setting for a package component (activity, receiver, service, provider).
5366 * This setting will override any enabled state which may have been set by the component in its
5369 * @param componentName The component to enable
5370 * @param newState The new enabled state for the component. The legal values for this state
5372 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
5373 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
5375 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5376 * The last one removes the setting, thereby restoring the component's state to
5377 * whatever was set in it's manifest (or enabled, by default).
5378 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5380 public abstract void setComponentEnabledSetting(ComponentName componentName,
5381 int newState, int flags);
5384 * Return the enabled setting for a package component (activity,
5385 * receiver, service, provider). This returns the last value set by
5386 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
5387 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5388 * the value originally specified in the manifest has not been modified.
5390 * @param componentName The component to retrieve.
5391 * @return Returns the current enabled state for the component. May
5392 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5393 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5394 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
5395 * component's enabled state is based on the original information in
5396 * the manifest as found in {@link ComponentInfo}.
5398 public abstract int getComponentEnabledSetting(ComponentName componentName);
5401 * Set the enabled setting for an application
5402 * This setting will override any enabled state which may have been set by the application in
5403 * its manifest. It also overrides the enabled state set in the manifest for any of the
5404 * application's components. It does not override any enabled state set by
5405 * {@link #setComponentEnabledSetting} for any of the application's components.
5407 * @param packageName The package name of the application to enable
5408 * @param newState The new enabled state for the component. The legal values for this state
5410 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
5411 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
5413 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
5414 * The last one removes the setting, thereby restoring the applications's state to
5415 * whatever was set in its manifest (or enabled, by default).
5416 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
5418 public abstract void setApplicationEnabledSetting(String packageName,
5419 int newState, int flags);
5422 * Return the enabled setting for an application. This returns
5423 * the last value set by
5424 * {@link #setApplicationEnabledSetting(String, int, int)}; in most
5425 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
5426 * the value originally specified in the manifest has not been modified.
5428 * @param packageName The package name of the application to retrieve.
5429 * @return Returns the current enabled state for the application. May
5430 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
5431 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
5432 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
5433 * application's enabled state is based on the original information in
5434 * the manifest as found in {@link ApplicationInfo}.
5435 * @throws IllegalArgumentException if the named package does not exist.
5437 public abstract int getApplicationEnabledSetting(String packageName);
5440 * Flush the package restrictions for a given user to disk. This forces the package restrictions
5441 * like component and package enabled settings to be written to disk and avoids the delay that
5442 * is otherwise present when changing those settings.
5444 * @param userId Ther userId of the user whose restrictions are to be flushed.
5447 public abstract void flushPackageRestrictionsAsUser(int userId);
5450 * Puts the package in a hidden state, which is almost like an uninstalled state,
5451 * making the package unavailable, but it doesn't remove the data or the actual
5452 * package file. Application can be unhidden by either resetting the hidden state
5453 * or by installing it, such as with {@link #installExistingPackage(String)}
5456 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
5457 UserHandle userHandle);
5460 * Returns the hidden state of a package.
5461 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
5464 public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
5465 UserHandle userHandle);
5468 * Return whether the device has been booted into safe mode.
5470 public abstract boolean isSafeMode();
5473 * Adds a listener for permission changes for installed packages.
5475 * @param listener The listener to add.
5480 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
5481 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5484 * Remvoes a listener for permission changes for installed packages.
5486 * @param listener The listener to remove.
5491 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
5494 * Return the {@link KeySet} associated with the String alias for this
5497 * @param alias The alias for a given {@link KeySet} as defined in the
5498 * application's AndroidManifest.xml.
5501 public abstract KeySet getKeySetByAlias(String packageName, String alias);
5503 /** Return the signing {@link KeySet} for this application.
5506 public abstract KeySet getSigningKeySet(String packageName);
5509 * Return whether the package denoted by packageName has been signed by all
5510 * of the keys specified by the {@link KeySet} ks. This will return true if
5511 * the package has been signed by additional keys (a superset) as well.
5512 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
5515 public abstract boolean isSignedBy(String packageName, KeySet ks);
5518 * Return whether the package denoted by packageName has been signed by all
5519 * of, and only, the keys specified by the {@link KeySet} ks. Compare to
5520 * {@link #isSignedBy(String packageName, KeySet ks)}.
5523 public abstract boolean isSignedByExactly(String packageName, KeySet ks);
5526 * Puts the package in a suspended state, where attempts at starting activities are denied.
5528 * <p>It doesn't remove the data or the actual package file. The application notifications
5529 * will be hidden, the application will not show up in recents, will not be able to show
5530 * toasts or dialogs or ring the device.
5532 * <p>The package must already be installed. If the package is uninstalled while suspended
5533 * the package will no longer be suspended.
5535 * @param packageNames The names of the packages to set the suspended status.
5536 * @param suspended If set to {@code true} than the packages will be suspended, if set to
5537 * {@code false} the packages will be unsuspended.
5538 * @param userId The user id.
5540 * @return an array of package names for which the suspended status is not set as requested in
5545 public abstract String[] setPackagesSuspendedAsUser(
5546 String[] packageNames, boolean suspended, @UserIdInt int userId);
5549 * @see #setPackageSuspendedAsUser(String, boolean, int)
5550 * @param packageName The name of the package to get the suspended status of.
5551 * @param userId The user id.
5552 * @return {@code true} if the package is suspended or {@code false} if the package is not
5553 * suspended or could not be found.
5556 public abstract boolean isPackageSuspendedForUser(String packageName, int userId);
5559 public static boolean isMoveStatusFinished(int status) {
5560 return (status < 0 || status > 100);
5564 public static abstract class MoveCallback {
5565 public void onCreated(int moveId, Bundle extras) {}
5566 public abstract void onStatusChanged(int moveId, int status, long estMillis);
5570 public abstract int getMoveStatus(int moveId);
5573 public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
5575 public abstract void unregisterMoveCallback(MoveCallback callback);
5578 public abstract int movePackage(String packageName, VolumeInfo vol);
5580 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
5582 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
5585 public abstract int movePrimaryStorage(VolumeInfo vol);
5587 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
5589 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
5592 * Returns the device identity that verifiers can use to associate their scheme to a particular
5593 * device. This should not be used by anything other than a package verifier.
5595 * @return identity that uniquely identifies current device
5598 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
5601 * Returns true if the device is upgrading, such as first boot after OTA.
5605 public abstract boolean isUpgrade();
5608 * Return interface that offers the ability to install, upgrade, and remove
5609 * applications on the device.
5611 public abstract @NonNull PackageInstaller getPackageInstaller();
5614 * Adds a {@code CrossProfileIntentFilter}. After calling this method all
5615 * intents sent from the user with id sourceUserId can also be be resolved
5616 * by activities in the user with id targetUserId if they match the
5617 * specified intent filter.
5619 * @param filter The {@link IntentFilter} the intent has to match
5620 * @param sourceUserId The source user id.
5621 * @param targetUserId The target user id.
5622 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and
5623 * {@link #ONLY_IF_NO_MATCH_FOUND}.
5626 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
5627 int targetUserId, int flags);
5630 * Clearing {@code CrossProfileIntentFilter}s which have the specified user
5631 * as their source, and have been set by the app calling this method.
5633 * @param sourceUserId The source user id.
5636 public abstract void clearCrossProfileIntentFilters(int sourceUserId);
5641 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5646 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
5649 public abstract boolean isPackageAvailable(String packageName);
5652 public static String installStatusToString(int status, String msg) {
5653 final String str = installStatusToString(status);
5655 return str + ": " + msg;
5662 public static String installStatusToString(int status) {
5664 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
5665 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
5666 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
5667 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
5668 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
5669 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
5670 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
5671 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
5672 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
5673 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
5674 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
5675 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
5676 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
5677 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
5678 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
5679 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
5680 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
5681 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
5682 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
5683 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
5684 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
5685 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
5686 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
5687 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
5688 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
5689 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
5690 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
5691 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
5692 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
5693 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
5694 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
5695 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
5696 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
5697 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
5698 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
5699 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
5700 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
5701 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
5702 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
5703 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
5704 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
5705 default: return Integer.toString(status);
5710 public static int installStatusToPublicStatus(int status) {
5712 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5713 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5714 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5715 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
5716 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5717 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5718 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5719 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5720 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5721 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5722 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5723 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
5724 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5725 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5726 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5727 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
5728 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5729 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5730 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
5731 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
5732 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
5733 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
5734 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
5735 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5736 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
5737 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5738 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
5739 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
5740 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
5741 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
5742 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5743 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
5744 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
5745 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
5746 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
5747 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
5748 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
5749 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5750 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5751 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
5752 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
5753 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5754 default: return PackageInstaller.STATUS_FAILURE;
5759 public static String deleteStatusToString(int status, String msg) {
5760 final String str = deleteStatusToString(status);
5762 return str + ": " + msg;
5769 public static String deleteStatusToString(int status) {
5771 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
5772 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
5773 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
5774 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
5775 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
5776 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
5777 default: return Integer.toString(status);
5782 public static int deleteStatusToPublicStatus(int status) {
5784 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
5785 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
5786 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5787 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5788 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
5789 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
5790 default: return PackageInstaller.STATUS_FAILURE;
5795 public static String permissionFlagToString(int flag) {
5797 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
5798 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
5799 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
5800 case FLAG_PERMISSION_USER_SET: return "USER_SET";
5801 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
5802 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
5803 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
5804 default: return Integer.toString(flag);
5809 public static class LegacyPackageInstallObserver extends PackageInstallObserver {
5810 private final IPackageInstallObserver mLegacy;
5812 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
5817 public void onPackageInstalled(String basePackageName, int returnCode, String msg,
5819 if (mLegacy == null) return;
5821 mLegacy.packageInstalled(basePackageName, returnCode);
5822 } catch (RemoteException ignored) {
5828 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
5829 private final IPackageDeleteObserver mLegacy;
5831 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
5836 public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
5837 if (mLegacy == null) return;
5839 mLegacy.packageDeleted(basePackageName, returnCode);
5840 } catch (RemoteException ignored) {