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.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.SdkConstant;
22 import android.annotation.SdkConstant.SdkConstantType;
23 import android.annotation.SystemApi;
24 import android.app.PackageDeleteObserver;
25 import android.app.PackageInstallObserver;
26 import android.app.admin.DevicePolicyManager;
27 import android.content.ComponentName;
28 import android.content.Context;
29 import android.content.Intent;
30 import android.content.IntentFilter;
31 import android.content.IntentSender;
32 import android.content.pm.PackageParser.PackageParserException;
33 import android.content.res.Resources;
34 import android.content.res.XmlResourceParser;
35 import android.graphics.Rect;
36 import android.graphics.drawable.Drawable;
37 import android.net.Uri;
38 import android.os.Bundle;
39 import android.os.Environment;
40 import android.os.RemoteException;
41 import android.os.UserHandle;
42 import android.util.AndroidException;
45 import java.lang.annotation.Retention;
46 import java.lang.annotation.RetentionPolicy;
47 import java.util.List;
50 * Class for retrieving various kinds of information related to the application
51 * packages that are currently installed on the device.
53 * You can find this class through {@link Context#getPackageManager}.
55 public abstract class PackageManager {
58 * This exception is thrown when a given package, application, or component
59 * name cannot be found.
61 public static class NameNotFoundException extends AndroidException {
62 public NameNotFoundException() {
65 public NameNotFoundException(String name) {
71 * {@link PackageInfo} flag: return information about
72 * activities in the package in {@link PackageInfo#activities}.
74 public static final int GET_ACTIVITIES = 0x00000001;
77 * {@link PackageInfo} flag: return information about
78 * intent receivers in the package in
79 * {@link PackageInfo#receivers}.
81 public static final int GET_RECEIVERS = 0x00000002;
84 * {@link PackageInfo} flag: return information about
85 * services in the package in {@link PackageInfo#services}.
87 public static final int GET_SERVICES = 0x00000004;
90 * {@link PackageInfo} flag: return information about
91 * content providers in the package in
92 * {@link PackageInfo#providers}.
94 public static final int GET_PROVIDERS = 0x00000008;
97 * {@link PackageInfo} flag: return information about
98 * instrumentation in the package in
99 * {@link PackageInfo#instrumentation}.
101 public static final int GET_INSTRUMENTATION = 0x00000010;
104 * {@link PackageInfo} flag: return information about the
105 * intent filters supported by the activity.
107 public static final int GET_INTENT_FILTERS = 0x00000020;
110 * {@link PackageInfo} flag: return information about the
111 * signatures included in the package.
113 public static final int GET_SIGNATURES = 0x00000040;
116 * {@link ResolveInfo} flag: return the IntentFilter that
117 * was matched for a particular ResolveInfo in
118 * {@link ResolveInfo#filter}.
120 public static final int GET_RESOLVED_FILTER = 0x00000040;
123 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
124 * data {@link android.os.Bundle}s that are associated with a component.
125 * This applies for any API returning a ComponentInfo subclass.
127 public static final int GET_META_DATA = 0x00000080;
130 * {@link PackageInfo} flag: return the
131 * {@link PackageInfo#gids group ids} that are associated with an
133 * This applies for any API returning a PackageInfo class, either
134 * directly or nested inside of another.
136 public static final int GET_GIDS = 0x00000100;
139 * {@link PackageInfo} flag: include disabled components in the returned info.
141 public static final int GET_DISABLED_COMPONENTS = 0x00000200;
144 * {@link ApplicationInfo} flag: return the
145 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
146 * that are associated with an application.
147 * This applies for any API returning an ApplicationInfo class, either
148 * directly or nested inside of another.
150 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400;
153 * {@link ProviderInfo} flag: return the
154 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
155 * that are associated with a content provider.
156 * This applies for any API returning a ProviderInfo class, either
157 * directly or nested inside of another.
159 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800;
161 * {@link PackageInfo} flag: return information about
162 * permissions in the package in
163 * {@link PackageInfo#permissions}.
165 public static final int GET_PERMISSIONS = 0x00001000;
168 * Flag parameter to retrieve some information about all applications (even
169 * uninstalled ones) which have data directories. This state could have
170 * resulted if applications have been deleted with flag
171 * {@code DONT_DELETE_DATA} with a possibility of being replaced or
172 * reinstalled in future.
174 * Note: this flag may cause less information about currently installed
175 * applications to be returned.
177 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
180 * {@link PackageInfo} flag: return information about
181 * hardware preferences in
182 * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
183 * and requested features in {@link PackageInfo#reqFeatures} and
184 * {@link PackageInfo#featureGroups}.
186 public static final int GET_CONFIGURATIONS = 0x00004000;
189 * {@link PackageInfo} flag: include disabled components which are in
190 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
191 * in the returned info. Note that if you set this flag, applications
192 * that are in this disabled state will be reported as enabled.
194 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
197 * Resolution and querying flag: if set, only filters that support the
198 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
199 * matching. This is a synonym for including the CATEGORY_DEFAULT in your
202 public static final int MATCH_DEFAULT_ONLY = 0x00010000;
205 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
206 * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current
207 * profile will be skipped.
208 * Only activities in the target user can respond to the intent.
211 public static final int SKIP_CURRENT_PROFILE = 0x00000002;
214 @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED})
215 @Retention(RetentionPolicy.SOURCE)
216 public @interface PermissionResult {}
219 * Permission check result: this is returned by {@link #checkPermission}
220 * if the permission has been granted to the given package.
222 public static final int PERMISSION_GRANTED = 0;
225 * Permission check result: this is returned by {@link #checkPermission}
226 * if the permission has not been granted to the given package.
228 public static final int PERMISSION_DENIED = -1;
231 * Signature check result: this is returned by {@link #checkSignatures}
232 * if all signatures on the two packages match.
234 public static final int SIGNATURE_MATCH = 0;
237 * Signature check result: this is returned by {@link #checkSignatures}
238 * if neither of the two packages is signed.
240 public static final int SIGNATURE_NEITHER_SIGNED = 1;
243 * Signature check result: this is returned by {@link #checkSignatures}
244 * if the first package is not signed but the second is.
246 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
249 * Signature check result: this is returned by {@link #checkSignatures}
250 * if the second package is not signed but the first is.
252 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
255 * Signature check result: this is returned by {@link #checkSignatures}
256 * if not all signatures on both packages match.
258 public static final int SIGNATURE_NO_MATCH = -3;
261 * Signature check result: this is returned by {@link #checkSignatures}
262 * if either of the packages are not valid.
264 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
267 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
268 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
269 * component or application is in its default enabled state (as specified
272 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
275 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
276 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
277 * component or application has been explictily enabled, regardless of
278 * what it has specified in its manifest.
280 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
283 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
284 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
285 * component or application has been explicitly disabled, regardless of
286 * what it has specified in its manifest.
288 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
291 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
292 * user has explicitly disabled the application, regardless of what it has
293 * specified in its manifest. Because this is due to the user's request,
294 * they may re-enable it if desired through the appropriate system UI. This
295 * option currently <strong>cannot</strong> be used with
296 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
298 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
301 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
302 * application should be considered, until the point where the user actually
303 * wants to use it. This means that it will not normally show up to the user
304 * (such as in the launcher), but various parts of the user interface can
305 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
306 * the user to select it (as for example an IME, device admin, etc). Such code,
307 * once the user has selected the app, should at that point also make it enabled.
308 * This option currently <strong>can not</strong> be used with
309 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
311 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
314 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
315 * indicate that this package should be installed as forward locked, i.e. only the app itself
316 * should have access to its code and non-resource assets.
319 public static final int INSTALL_FORWARD_LOCK = 0x00000001;
322 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
323 * installed package, if one exists.
326 public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
329 * Flag parameter for {@link #installPackage} to indicate that you want to
330 * allow test packages (those that have set android:testOnly in their
331 * manifest) to be installed.
334 public static final int INSTALL_ALLOW_TEST = 0x00000004;
337 * Flag parameter for {@link #installPackage} to indicate that this
338 * package has to be installed on the sdcard.
341 public static final int INSTALL_EXTERNAL = 0x00000008;
344 * Flag parameter for {@link #installPackage} to indicate that this package
345 * has to be installed on the sdcard.
348 public static final int INSTALL_INTERNAL = 0x00000010;
351 * Flag parameter for {@link #installPackage} to indicate that this install
352 * was initiated via ADB.
356 public static final int INSTALL_FROM_ADB = 0x00000020;
359 * Flag parameter for {@link #installPackage} to indicate that this install
360 * should immediately be visible to all users.
364 public static final int INSTALL_ALL_USERS = 0x00000040;
367 * Flag parameter for {@link #installPackage} to indicate that it is okay
368 * to install an update to an app where the newly installed app has a lower
369 * version code than the currently installed app.
373 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
377 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
378 * that you don't want to kill the app containing the component. Be careful when you set this
379 * since changing component states can make the containing application's behavior unpredictable.
381 public static final int DONT_KILL_APP = 0x00000001;
384 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
385 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
389 public static final int INSTALL_SUCCEEDED = 1;
392 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
393 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
398 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
401 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
402 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
407 public static final int INSTALL_FAILED_INVALID_APK = -2;
410 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
411 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
416 public static final int INSTALL_FAILED_INVALID_URI = -3;
419 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
420 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
421 * service found that the device didn't have enough storage space to install the app.
425 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
428 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
429 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
430 * package is already installed with the same name.
434 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
437 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
438 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
439 * the requested shared user does not exist.
443 public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
446 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
447 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
448 * a previously installed package of the same name has a different signature
449 * than the new package (and the old package's data was not removed).
453 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
456 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
457 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
458 * the new package is requested a shared user which is already installed on the
459 * device and does not have matching signature.
463 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
466 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
467 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
468 * the new package uses a shared library that is not available.
472 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
475 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
476 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
477 * the new package uses a shared library that is not available.
481 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
484 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
485 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
486 * the new package failed while optimizing and validating its dex files,
487 * either because there was not enough storage or the validation failed.
491 public static final int INSTALL_FAILED_DEXOPT = -11;
494 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
495 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
496 * the new package failed because the current SDK version is older than
497 * that required by the package.
501 public static final int INSTALL_FAILED_OLDER_SDK = -12;
504 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
505 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
506 * the new package failed because it contains a content provider with the
507 * same authority as a provider already installed in the system.
511 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
514 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
515 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
516 * the new package failed because the current SDK version is newer than
517 * that required by the package.
521 public static final int INSTALL_FAILED_NEWER_SDK = -14;
524 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
525 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
526 * the new package failed because it has specified that it is a test-only
527 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
532 public static final int INSTALL_FAILED_TEST_ONLY = -15;
535 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
536 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
537 * the package being installed contains native code, but none that is
538 * compatible with the device's CPU_ABI.
542 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
545 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
546 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
547 * the new package uses a feature that is not available.
551 public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
553 // ------ Errors related to sdcard
555 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
556 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
557 * a secure container mount point couldn't be accessed on external media.
561 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
564 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
565 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
566 * the new package couldn't be installed in the specified install
571 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
574 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
575 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
576 * the new package couldn't be installed in the specified install
577 * location because the media is not available.
581 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
584 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
585 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
586 * the new package couldn't be installed because the verification timed out.
590 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
593 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
594 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
595 * the new package couldn't be installed because the verification did not succeed.
599 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
602 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
603 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
604 * the package changed from what the calling program expected.
608 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
611 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
612 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
613 * the new package is assigned a different UID than it previously held.
616 public static final int INSTALL_FAILED_UID_CHANGED = -24;
619 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
620 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
621 * the new package has an older version code than the currently installed package.
624 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
627 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
628 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
629 * if the parser was given a path that is not a file, or does not end with the expected
634 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
637 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
638 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
639 * if the parser was unable to retrieve the AndroidManifest.xml file.
643 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
646 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
647 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
648 * if the parser encountered an unexpected exception.
652 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
655 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
656 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
657 * if the parser did not find any certificates in the .apk.
661 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
664 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
665 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
666 * if the parser found inconsistent certificates on the files in the .apk.
670 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
673 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
674 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
675 * if the parser encountered a CertificateEncodingException in one of the
680 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
683 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
684 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
685 * if the parser encountered a bad or missing package name in the manifest.
689 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
692 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
693 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
694 * if the parser encountered a bad shared user id name in the manifest.
698 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
701 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
702 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
703 * if the parser encountered some structural problem in the manifest.
707 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
710 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
711 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
712 * if the parser did not find any actionable tags (instrumentation or application)
717 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
720 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
721 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
722 * if the system failed to install the package because of system issues.
726 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
729 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
730 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
731 * if the system failed to install the package because the user is restricted from installing
735 public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
738 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
739 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
740 * if the system failed to install the package because it is attempting to define a
741 * permission that is already defined by some existing package.
743 * <p>The package name of the app which has already defined the permission is passed to
744 * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE}
745 * string extra; and the name of the permission being redefined is passed in the
746 * {@link #EXTRA_EXISTING_PERMISSION} string extra.
749 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
752 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
753 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
754 * if the system failed to install the package because its packaged native code did not
755 * match any of the ABIs supported by the system.
759 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
762 * Internal return code for NativeLibraryHelper methods to indicate that the package
763 * being processed did not contain any native code. This is placed here only so that
764 * it can belong to the same value space as the other install failure codes.
768 public static final int NO_NATIVE_LIBRARIES = -114;
771 public static final int INSTALL_FAILED_ABORTED = -115;
774 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
775 * package's data directory.
779 public static final int DELETE_KEEP_DATA = 0x00000001;
782 * Flag parameter for {@link #deletePackage} to indicate that you want the
783 * package deleted for all users.
787 public static final int DELETE_ALL_USERS = 0x00000002;
790 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
791 * uninstall on a system that has been updated, then don't do the normal process
792 * of uninstalling the update and rolling back to the older system version (which
793 * needs to happen for all users); instead, just mark the app as uninstalled for
798 public static final int DELETE_SYSTEM_APP = 0x00000004;
801 * Return code for when package deletion succeeds. This is passed to the
802 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
803 * succeeded in deleting the package.
807 public static final int DELETE_SUCCEEDED = 1;
810 * Deletion failed return code: this is passed to the
811 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
812 * failed to delete the package for an unspecified reason.
816 public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
819 * Deletion failed return code: this is passed to the
820 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
821 * failed to delete the package because it is the active DevicePolicy
826 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
829 * Deletion failed return code: this is passed to the
830 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
831 * failed to delete the package since the user is restricted.
835 public static final int DELETE_FAILED_USER_RESTRICTED = -3;
838 * Deletion failed return code: this is passed to the
839 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
840 * failed to delete the package because a profile
841 * or device owner has marked the package as uninstallable.
845 public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
848 public static final int DELETE_FAILED_ABORTED = -5;
851 * Return code that is passed to the {@link IPackageMoveObserver} by
852 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
853 * package has been successfully moved by the system.
857 public static final int MOVE_SUCCEEDED = 1;
859 * Error code that is passed to the {@link IPackageMoveObserver} by
860 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
861 * when the package hasn't been successfully moved by the system
862 * because of insufficient memory on specified media.
865 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
868 * Error code that is passed to the {@link IPackageMoveObserver} by
869 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
870 * if the specified package doesn't exist.
873 public static final int MOVE_FAILED_DOESNT_EXIST = -2;
876 * Error code that is passed to the {@link IPackageMoveObserver} by
877 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
878 * if the specified package cannot be moved since its a system package.
881 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
884 * Error code that is passed to the {@link IPackageMoveObserver} by
885 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
886 * if the specified package cannot be moved since its forward locked.
889 public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
892 * Error code that is passed to the {@link IPackageMoveObserver} by
893 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
894 * if the specified package cannot be moved to the specified location.
897 public static final int MOVE_FAILED_INVALID_LOCATION = -5;
900 * Error code that is passed to the {@link IPackageMoveObserver} by
901 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
902 * if the specified package cannot be moved to the specified location.
905 public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
908 * Error code that is passed to the {@link IPackageMoveObserver} by
909 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
910 * specified package already has an operation pending in the
911 * {@link PackageHandler} queue.
915 public static final int MOVE_FAILED_OPERATION_PENDING = -7;
918 * Flag parameter for {@link #movePackage} to indicate that
919 * the package should be moved to internal storage if its
920 * been installed on external media.
923 public static final int MOVE_INTERNAL = 0x00000001;
926 * Flag parameter for {@link #movePackage} to indicate that
927 * the package should be moved to external media.
930 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
933 * Usable by the required verifier as the {@code verificationCode} argument
934 * for {@link PackageManager#verifyPendingInstall} to indicate that it will
935 * allow the installation to proceed without any of the optional verifiers
940 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
943 * Used as the {@code verificationCode} argument for
944 * {@link PackageManager#verifyPendingInstall} to indicate that the calling
945 * package verifier allows the installation to proceed.
947 public static final int VERIFICATION_ALLOW = 1;
950 * Used as the {@code verificationCode} argument for
951 * {@link PackageManager#verifyPendingInstall} to indicate the calling
952 * package verifier does not vote to allow the installation to proceed.
954 public static final int VERIFICATION_REJECT = -1;
957 * Can be used as the {@code millisecondsToDelay} argument for
958 * {@link PackageManager#extendVerificationTimeout}. This is the
959 * maximum time {@code PackageManager} waits for the verification
960 * agent to return (in milliseconds).
962 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
965 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
966 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
967 * lag in sound input or output.
969 @SdkConstant(SdkConstantType.FEATURE)
970 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
973 * Feature for {@link #getSystemAvailableFeatures} and
974 * {@link #hasSystemFeature}: The device includes at least one form of audio
975 * output, such as speakers, audio jack or streaming over bluetooth
977 @SdkConstant(SdkConstantType.FEATURE)
978 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
981 * Feature for {@link #getSystemAvailableFeatures} and
982 * {@link #hasSystemFeature}: The device is capable of communicating with
983 * other devices via Bluetooth.
985 @SdkConstant(SdkConstantType.FEATURE)
986 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
989 * Feature for {@link #getSystemAvailableFeatures} and
990 * {@link #hasSystemFeature}: The device is capable of communicating with
991 * other devices via Bluetooth Low Energy radio.
993 @SdkConstant(SdkConstantType.FEATURE)
994 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
997 * Feature for {@link #getSystemAvailableFeatures} and
998 * {@link #hasSystemFeature}: The device has a camera facing away
1001 @SdkConstant(SdkConstantType.FEATURE)
1002 public static final String FEATURE_CAMERA = "android.hardware.camera";
1005 * Feature for {@link #getSystemAvailableFeatures} and
1006 * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1008 @SdkConstant(SdkConstantType.FEATURE)
1009 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
1012 * Feature for {@link #getSystemAvailableFeatures} and
1013 * {@link #hasSystemFeature}: The device has at least one camera pointing in
1014 * some direction, or can support an external camera being connected to it.
1016 @SdkConstant(SdkConstantType.FEATURE)
1017 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1020 * Feature for {@link #getSystemAvailableFeatures} and
1021 * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1022 * The external camera may not always be connected or available to applications to use.
1024 @SdkConstant(SdkConstantType.FEATURE)
1025 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1028 * Feature for {@link #getSystemAvailableFeatures} and
1029 * {@link #hasSystemFeature}: The device's camera supports flash.
1031 @SdkConstant(SdkConstantType.FEATURE)
1032 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
1035 * Feature for {@link #getSystemAvailableFeatures} and
1036 * {@link #hasSystemFeature}: The device has a front facing camera.
1038 @SdkConstant(SdkConstantType.FEATURE)
1039 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1042 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1043 * of the cameras on the device supports the
1044 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1047 @SdkConstant(SdkConstantType.FEATURE)
1048 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1051 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1052 * of the cameras on the device supports the
1053 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1056 @SdkConstant(SdkConstantType.FEATURE)
1057 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1058 "android.hardware.camera.capability.manual_sensor";
1061 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1062 * of the cameras on the device supports the
1063 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1066 @SdkConstant(SdkConstantType.FEATURE)
1067 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1068 "android.hardware.camera.capability.manual_post_processing";
1071 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1072 * of the cameras on the device supports the
1073 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1076 @SdkConstant(SdkConstantType.FEATURE)
1077 public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1078 "android.hardware.camera.capability.raw";
1081 * Feature for {@link #getSystemAvailableFeatures} and
1082 * {@link #hasSystemFeature}: The device is capable of communicating with
1083 * consumer IR devices.
1085 @SdkConstant(SdkConstantType.FEATURE)
1086 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1089 * Feature for {@link #getSystemAvailableFeatures} and
1090 * {@link #hasSystemFeature}: The device supports one or more methods of
1091 * reporting current location.
1093 @SdkConstant(SdkConstantType.FEATURE)
1094 public static final String FEATURE_LOCATION = "android.hardware.location";
1097 * Feature for {@link #getSystemAvailableFeatures} and
1098 * {@link #hasSystemFeature}: The device has a Global Positioning System
1099 * receiver and can report precise location.
1101 @SdkConstant(SdkConstantType.FEATURE)
1102 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1105 * Feature for {@link #getSystemAvailableFeatures} and
1106 * {@link #hasSystemFeature}: The device can report location with coarse
1107 * accuracy using a network-based geolocation system.
1109 @SdkConstant(SdkConstantType.FEATURE)
1110 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1113 * Feature for {@link #getSystemAvailableFeatures} and
1114 * {@link #hasSystemFeature}: The device can record audio via a
1117 @SdkConstant(SdkConstantType.FEATURE)
1118 public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1121 * Feature for {@link #getSystemAvailableFeatures} and
1122 * {@link #hasSystemFeature}: The device can communicate using Near-Field
1123 * Communications (NFC).
1125 @SdkConstant(SdkConstantType.FEATURE)
1126 public static final String FEATURE_NFC = "android.hardware.nfc";
1129 * Feature for {@link #getSystemAvailableFeatures} and
1130 * {@link #hasSystemFeature}: The device supports host-
1131 * based NFC card emulation.
1133 * TODO remove when depending apps have moved to new constant.
1138 @SdkConstant(SdkConstantType.FEATURE)
1139 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1142 * Feature for {@link #getSystemAvailableFeatures} and
1143 * {@link #hasSystemFeature}: The device supports host-
1144 * based NFC card emulation.
1146 @SdkConstant(SdkConstantType.FEATURE)
1147 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1150 * Feature for {@link #getSystemAvailableFeatures} and
1151 * {@link #hasSystemFeature}: The device supports the OpenGL ES
1152 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1153 * Android Extension Pack</a>.
1155 @SdkConstant(SdkConstantType.FEATURE)
1156 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1159 * Feature for {@link #getSystemAvailableFeatures} and
1160 * {@link #hasSystemFeature}: The device includes an accelerometer.
1162 @SdkConstant(SdkConstantType.FEATURE)
1163 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1166 * Feature for {@link #getSystemAvailableFeatures} and
1167 * {@link #hasSystemFeature}: The device includes a barometer (air
1170 @SdkConstant(SdkConstantType.FEATURE)
1171 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1174 * Feature for {@link #getSystemAvailableFeatures} and
1175 * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1177 @SdkConstant(SdkConstantType.FEATURE)
1178 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1181 * Feature for {@link #getSystemAvailableFeatures} and
1182 * {@link #hasSystemFeature}: The device includes a gyroscope.
1184 @SdkConstant(SdkConstantType.FEATURE)
1185 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
1188 * Feature for {@link #getSystemAvailableFeatures} and
1189 * {@link #hasSystemFeature}: The device includes a light sensor.
1191 @SdkConstant(SdkConstantType.FEATURE)
1192 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
1195 * Feature for {@link #getSystemAvailableFeatures} and
1196 * {@link #hasSystemFeature}: The device includes a proximity sensor.
1198 @SdkConstant(SdkConstantType.FEATURE)
1199 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
1202 * Feature for {@link #getSystemAvailableFeatures} and
1203 * {@link #hasSystemFeature}: The device includes a hardware step counter.
1205 @SdkConstant(SdkConstantType.FEATURE)
1206 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
1209 * Feature for {@link #getSystemAvailableFeatures} and
1210 * {@link #hasSystemFeature}: The device includes a hardware step detector.
1212 @SdkConstant(SdkConstantType.FEATURE)
1213 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
1216 * Feature for {@link #getSystemAvailableFeatures} and
1217 * {@link #hasSystemFeature}: The device includes a heart rate monitor.
1219 @SdkConstant(SdkConstantType.FEATURE)
1220 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
1223 * Feature for {@link #getSystemAvailableFeatures} and
1224 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram.
1226 @SdkConstant(SdkConstantType.FEATURE)
1227 public static final String FEATURE_SENSOR_HEART_RATE_ECG =
1228 "android.hardware.sensor.heartrate.ecg";
1231 * Feature for {@link #getSystemAvailableFeatures} and
1232 * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
1234 @SdkConstant(SdkConstantType.FEATURE)
1235 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
1236 "android.hardware.sensor.relative_humidity";
1239 * Feature for {@link #getSystemAvailableFeatures} and
1240 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
1242 @SdkConstant(SdkConstantType.FEATURE)
1243 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
1244 "android.hardware.sensor.ambient_temperature";
1247 * Feature for {@link #getSystemAvailableFeatures} and
1248 * {@link #hasSystemFeature}: The device has a telephony radio with data
1249 * communication support.
1251 @SdkConstant(SdkConstantType.FEATURE)
1252 public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
1255 * Feature for {@link #getSystemAvailableFeatures} and
1256 * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
1258 @SdkConstant(SdkConstantType.FEATURE)
1259 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
1262 * Feature for {@link #getSystemAvailableFeatures} and
1263 * {@link #hasSystemFeature}: The device has a GSM telephony stack.
1265 @SdkConstant(SdkConstantType.FEATURE)
1266 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
1269 * Feature for {@link #getSystemAvailableFeatures} and
1270 * {@link #hasSystemFeature}: The device supports connecting to USB devices
1273 @SdkConstant(SdkConstantType.FEATURE)
1274 public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
1277 * Feature for {@link #getSystemAvailableFeatures} and
1278 * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
1280 @SdkConstant(SdkConstantType.FEATURE)
1281 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
1284 * Feature for {@link #getSystemAvailableFeatures} and
1285 * {@link #hasSystemFeature}: The SIP API is enabled on the device.
1287 @SdkConstant(SdkConstantType.FEATURE)
1288 public static final String FEATURE_SIP = "android.software.sip";
1291 * Feature for {@link #getSystemAvailableFeatures} and
1292 * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
1294 @SdkConstant(SdkConstantType.FEATURE)
1295 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
1298 * Feature for {@link #getSystemAvailableFeatures} and
1299 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
1301 @SdkConstant(SdkConstantType.FEATURE)
1302 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
1305 * Feature for {@link #getSystemAvailableFeatures} and
1306 * {@link #hasSystemFeature}: The device's display has a touch screen.
1308 @SdkConstant(SdkConstantType.FEATURE)
1309 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1312 * Feature for {@link #getSystemAvailableFeatures} and
1313 * {@link #hasSystemFeature}: The device's touch screen supports
1314 * multitouch sufficient for basic two-finger gesture detection.
1316 @SdkConstant(SdkConstantType.FEATURE)
1317 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1320 * Feature for {@link #getSystemAvailableFeatures} and
1321 * {@link #hasSystemFeature}: The device's touch screen is capable of
1322 * tracking two or more fingers fully independently.
1324 @SdkConstant(SdkConstantType.FEATURE)
1325 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1328 * Feature for {@link #getSystemAvailableFeatures} and
1329 * {@link #hasSystemFeature}: The device's touch screen is capable of
1330 * tracking a full hand of fingers fully independently -- that is, 5 or
1331 * more simultaneous independent pointers.
1333 @SdkConstant(SdkConstantType.FEATURE)
1334 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1337 * Feature for {@link #getSystemAvailableFeatures} and
1338 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1339 * does support touch emulation for basic events. For instance, the
1340 * device might use a mouse or remote control to drive a cursor, and
1341 * emulate basic touch pointer events like down, up, drag, etc. All
1342 * devices that support android.hardware.touchscreen or a sub-feature are
1343 * presumed to also support faketouch.
1345 @SdkConstant(SdkConstantType.FEATURE)
1346 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1349 * Feature for {@link #getSystemAvailableFeatures} and
1350 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1351 * does support touch emulation for basic events that supports distinct
1352 * tracking of two or more fingers. This is an extension of
1353 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
1354 * that unlike a distinct multitouch screen as defined by
1355 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1356 * devices will not actually provide full two-finger gestures since the
1357 * input is being transformed to cursor movement on the screen. That is,
1358 * single finger gestures will move a cursor; two-finger swipes will
1359 * result in single-finger touch events; other two-finger gestures will
1360 * result in the corresponding two-finger touch event.
1362 @SdkConstant(SdkConstantType.FEATURE)
1363 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
1366 * Feature for {@link #getSystemAvailableFeatures} and
1367 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1368 * does support touch emulation for basic events that supports tracking
1369 * a hand of fingers (5 or more fingers) fully independently.
1370 * This is an extension of
1371 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
1372 * that unlike a multitouch screen as defined by
1373 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
1374 * gestures can be detected due to the limitations described for
1375 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1377 @SdkConstant(SdkConstantType.FEATURE)
1378 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1381 * Feature for {@link #getSystemAvailableFeatures} and
1382 * {@link #hasSystemFeature}: The device supports portrait orientation
1383 * screens. For backwards compatibility, you can assume that if neither
1384 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1385 * both portrait and landscape.
1387 @SdkConstant(SdkConstantType.FEATURE)
1388 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1391 * Feature for {@link #getSystemAvailableFeatures} and
1392 * {@link #hasSystemFeature}: The device supports landscape orientation
1393 * screens. For backwards compatibility, you can assume that if neither
1394 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1395 * both portrait and landscape.
1397 @SdkConstant(SdkConstantType.FEATURE)
1398 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1401 * Feature for {@link #getSystemAvailableFeatures} and
1402 * {@link #hasSystemFeature}: The device supports live wallpapers.
1404 @SdkConstant(SdkConstantType.FEATURE)
1405 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1407 * Feature for {@link #getSystemAvailableFeatures} and
1408 * {@link #hasSystemFeature}: The device supports app widgets.
1410 @SdkConstant(SdkConstantType.FEATURE)
1411 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
1415 * Feature for {@link #getSystemAvailableFeatures} and
1416 * {@link #hasSystemFeature}: The device supports
1417 * {@link android.service.voice.VoiceInteractionService} and
1418 * {@link android.app.VoiceInteractor}.
1420 @SdkConstant(SdkConstantType.FEATURE)
1421 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
1425 * Feature for {@link #getSystemAvailableFeatures} and
1426 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
1427 * by third party applications.
1429 @SdkConstant(SdkConstantType.FEATURE)
1430 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
1433 * Feature for {@link #getSystemAvailableFeatures} and
1434 * {@link #hasSystemFeature}: The device supports adding new input methods implemented
1435 * with the {@link android.inputmethodservice.InputMethodService} API.
1437 @SdkConstant(SdkConstantType.FEATURE)
1438 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
1441 * Feature for {@link #getSystemAvailableFeatures} and
1442 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
1444 @SdkConstant(SdkConstantType.FEATURE)
1445 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
1448 * Feature for {@link #getSystemAvailableFeatures} and
1449 * {@link #hasSystemFeature}: The device supports leanback UI. This is
1450 * typically used in a living room television experience, but is a software
1451 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
1452 * feature will use resources associated with the "television" UI mode.
1454 @SdkConstant(SdkConstantType.FEATURE)
1455 public static final String FEATURE_LEANBACK = "android.software.leanback";
1458 * Feature for {@link #getSystemAvailableFeatures} and
1459 * {@link #hasSystemFeature}: The device supports only leanback UI. Only
1460 * applications designed for this experience should be run, though this is
1461 * not enforced by the system.
1464 @SdkConstant(SdkConstantType.FEATURE)
1465 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
1468 * Feature for {@link #getSystemAvailableFeatures} and
1469 * {@link #hasSystemFeature}: The device supports live TV and can display
1470 * contents from TV inputs implemented with the
1471 * {@link android.media.tv.TvInputService} API.
1473 @SdkConstant(SdkConstantType.FEATURE)
1474 public static final String FEATURE_LIVE_TV = "android.software.live_tv";
1477 * Feature for {@link #getSystemAvailableFeatures} and
1478 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1480 @SdkConstant(SdkConstantType.FEATURE)
1481 public static final String FEATURE_WIFI = "android.hardware.wifi";
1484 * Feature for {@link #getSystemAvailableFeatures} and
1485 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1487 @SdkConstant(SdkConstantType.FEATURE)
1488 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1491 * Feature for {@link #getSystemAvailableFeatures} and
1492 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1493 * on a television. Television here is defined to be a typical living
1494 * room television experience: displayed on a big screen, where the user
1495 * is sitting far away from it, and the dominant form of input will be
1496 * something like a DPAD, not through touch or mouse.
1497 * @deprecated use {@link #FEATURE_LEANBACK} instead.
1500 @SdkConstant(SdkConstantType.FEATURE)
1501 public static final String FEATURE_TELEVISION = "android.hardware.type.television";
1504 * Feature for {@link #getSystemAvailableFeatures} and
1505 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1506 * on a watch. A watch here is defined to be a device worn on the body, perhaps on
1507 * the wrist. The user is very close when interacting with the device.
1509 @SdkConstant(SdkConstantType.FEATURE)
1510 public static final String FEATURE_WATCH = "android.hardware.type.watch";
1513 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1514 * The device supports printing.
1516 @SdkConstant(SdkConstantType.FEATURE)
1517 public static final String FEATURE_PRINTING = "android.software.print";
1520 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1521 * The device can perform backup and restore operations on installed applications.
1523 @SdkConstant(SdkConstantType.FEATURE)
1524 public static final String FEATURE_BACKUP = "android.software.backup";
1527 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1528 * The device supports creating secondary users and managed profiles via
1529 * {@link DevicePolicyManager}.
1531 @SdkConstant(SdkConstantType.FEATURE)
1532 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
1536 * TODO: Remove after dependencies updated b/17392243
1538 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
1541 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1542 * The device supports verified boot.
1544 @SdkConstant(SdkConstantType.FEATURE)
1545 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
1548 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1549 * The device supports secure removal of users. When a user is deleted the data associated
1550 * with that user is securely deleted and no longer available.
1552 @SdkConstant(SdkConstantType.FEATURE)
1553 public static final String FEATURE_SECURELY_REMOVES_USERS
1554 = "android.software.securely_removes_users";
1557 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1558 * The device has a full implementation of the android.webkit.* APIs. Devices
1559 * lacking this feature will not have a functioning WebView implementation.
1561 @SdkConstant(SdkConstantType.FEATURE)
1562 public static final String FEATURE_WEBVIEW = "android.software.webview";
1565 * Feature for {@link #getSystemAvailableFeatures} and
1566 * {@link #hasSystemFeature}: This device supports ethernet.
1569 @SdkConstant(SdkConstantType.FEATURE)
1570 public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
1573 * Feature for {@link #getSystemAvailableFeatures} and
1574 * {@link #hasSystemFeature}: This device supports HDMI-CEC.
1577 @SdkConstant(SdkConstantType.FEATURE)
1578 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
1581 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1582 * The device has all of the inputs necessary to be considered a compatible game controller, or
1583 * includes a compatible game controller in the box.
1585 @SdkConstant(SdkConstantType.FEATURE)
1586 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
1590 * Action to external storage service to clean out removed apps.
1593 public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1594 = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1597 * Extra field name for the URI to a verification file. Passed to a package
1602 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1605 * Extra field name for the ID of a package pending verification. Passed to
1606 * a package verifier and is used to call back to
1607 * {@link PackageManager#verifyPendingInstall(int, int)}
1609 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1612 * Extra field name for the package identifier which is trying to install
1617 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1618 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1621 * Extra field name for the requested install flags for a package pending
1622 * verification. Passed to a package verifier.
1626 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1627 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1630 * Extra field name for the uid of who is requesting to install
1635 public static final String EXTRA_VERIFICATION_INSTALLER_UID
1636 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
1639 * Extra field name for the package name of a package pending verification.
1643 public static final String EXTRA_VERIFICATION_PACKAGE_NAME
1644 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
1646 * Extra field name for the result of a verification, either
1647 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
1648 * Passed to package verifiers after a package is verified.
1650 public static final String EXTRA_VERIFICATION_RESULT
1651 = "android.content.pm.extra.VERIFICATION_RESULT";
1654 * Extra field name for the version code of a package pending verification.
1658 public static final String EXTRA_VERIFICATION_VERSION_CODE
1659 = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
1662 * The action used to request that the user approve a permission request
1663 * from the application.
1667 public static final String ACTION_REQUEST_PERMISSION
1668 = "android.content.pm.action.REQUEST_PERMISSION";
1671 * Extra field name for the list of permissions, which the user must approve.
1675 public static final String EXTRA_REQUEST_PERMISSION_PERMISSION_LIST
1676 = "android.content.pm.extra.PERMISSION_LIST";
1679 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1680 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides
1681 * the existing definition for the permission.
1684 public static final String EXTRA_FAILURE_EXISTING_PACKAGE
1685 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
1688 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1689 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is
1690 * being redundantly defined by the package being installed.
1693 public static final String EXTRA_FAILURE_EXISTING_PERMISSION
1694 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
1697 * Retrieve overall information about an application package that is
1698 * installed on the system.
1700 * Throws {@link NameNotFoundException} if a package with the given name can
1701 * not be found on the system.
1703 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1705 * @param flags Additional option flags. Use any combination of
1706 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1707 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1708 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1709 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1710 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1711 * modify the data returned.
1712 * @return Returns a PackageInfo object containing information about the
1713 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the
1714 * package is not found in the list of installed applications, the
1715 * package information is retrieved from the list of uninstalled
1716 * applications (which includes installed applications as well as
1717 * applications with data directory i.e. applications which had been
1718 * deleted with {@code DONT_DELETE_DATA} flag set).
1719 * @see #GET_ACTIVITIES
1721 * @see #GET_CONFIGURATIONS
1722 * @see #GET_INSTRUMENTATION
1723 * @see #GET_PERMISSIONS
1724 * @see #GET_PROVIDERS
1725 * @see #GET_RECEIVERS
1726 * @see #GET_SERVICES
1727 * @see #GET_SIGNATURES
1728 * @see #GET_UNINSTALLED_PACKAGES
1730 public abstract PackageInfo getPackageInfo(String packageName, int flags)
1731 throws NameNotFoundException;
1734 * Map from the current package names in use on the device to whatever
1735 * the current canonical name of that package is.
1736 * @param names Array of current names to be mapped.
1737 * @return Returns an array of the same size as the original, containing
1738 * the canonical name for each package.
1740 public abstract String[] currentToCanonicalPackageNames(String[] names);
1743 * Map from a packages canonical name to the current name in use on the device.
1744 * @param names Array of new names to be mapped.
1745 * @return Returns an array of the same size as the original, containing
1746 * the current name for each package.
1748 public abstract String[] canonicalToCurrentPackageNames(String[] names);
1751 * Returns a "good" intent to launch a front-door activity in a package.
1752 * This is used, for example, to implement an "open" button when browsing
1753 * through packages. The current implementation looks first for a main
1754 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
1755 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
1756 * <code>null</code> if neither are found.
1758 * @param packageName The name of the package to inspect.
1760 * @return A fully-qualified {@link Intent} that can be used to launch the
1761 * main activity in the package. Returns <code>null</code> if the package
1762 * does not contain such an activity, or if <em>packageName</em> is not
1765 public abstract Intent getLaunchIntentForPackage(String packageName);
1768 * Return a "good" intent to launch a front-door Leanback activity in a
1769 * package, for use for example to implement an "open" button when browsing
1770 * through packages. The current implementation will look for a main
1771 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
1772 * return null if no main leanback activities are found.
1774 * Throws {@link NameNotFoundException} if a package with the given name
1775 * cannot be found on the system.
1777 * @param packageName The name of the package to inspect.
1778 * @return Returns either a fully-qualified Intent that can be used to launch
1779 * the main Leanback activity in the package, or null if the package
1780 * does not contain such an activity.
1782 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
1785 * Return an array of all of the secondary group-ids that have been assigned
1788 * Throws {@link NameNotFoundException} if a package with the given name
1789 * cannot be found on the system.
1791 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1793 * @return Returns an int array of the assigned gids, or null if there are
1796 public abstract int[] getPackageGids(String packageName)
1797 throws NameNotFoundException;
1800 * @hide Return the uid associated with the given package name for the
1803 * <p>Throws {@link NameNotFoundException} if a package with the given
1804 * name can not be found on the system.
1806 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1808 * @param userHandle The user handle identifier to look up the package under.
1810 * @return Returns an integer uid who owns the given package name.
1812 public abstract int getPackageUid(String packageName, int userHandle)
1813 throws NameNotFoundException;
1816 * Retrieve all of the information we know about a particular permission.
1818 * <p>Throws {@link NameNotFoundException} if a permission with the given
1819 * name cannot be found on the system.
1821 * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1822 * of the permission you are interested in.
1823 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1824 * retrieve any meta-data associated with the permission.
1826 * @return Returns a {@link PermissionInfo} containing information about the
1829 public abstract PermissionInfo getPermissionInfo(String name, int flags)
1830 throws NameNotFoundException;
1833 * Query for all of the permissions associated with a particular group.
1835 * <p>Throws {@link NameNotFoundException} if the given group does not
1838 * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1839 * of the permission group you are interested in. Use null to
1840 * find all of the permissions not associated with a group.
1841 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1842 * retrieve any meta-data associated with the permissions.
1844 * @return Returns a list of {@link PermissionInfo} containing information
1845 * about all of the permissions in the given group.
1847 public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1848 int flags) throws NameNotFoundException;
1851 * Retrieve all of the information we know about a particular group of
1854 * <p>Throws {@link NameNotFoundException} if a permission group with the given
1855 * name cannot be found on the system.
1857 * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1858 * of the permission you are interested in.
1859 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1860 * retrieve any meta-data associated with the permission group.
1862 * @return Returns a {@link PermissionGroupInfo} containing information
1863 * about the permission.
1865 public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1866 int flags) throws NameNotFoundException;
1869 * Retrieve all of the known permission groups in the system.
1871 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1872 * retrieve any meta-data associated with the permission group.
1874 * @return Returns a list of {@link PermissionGroupInfo} containing
1875 * information about all of the known permission groups.
1877 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1880 * Retrieve all of the information we know about a particular
1881 * package/application.
1883 * <p>Throws {@link NameNotFoundException} if an application with the given
1884 * package name cannot be found on the system.
1886 * @param packageName The full name (i.e. com.google.apps.contacts) of an
1888 * @param flags Additional option flags. Use any combination of
1889 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1890 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1892 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing
1893 * information about the package.
1894 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not
1895 * found in the list of installed applications,
1896 * the application information is retrieved from the
1897 * list of uninstalled applications(which includes
1898 * installed applications as well as applications
1899 * with data directory ie applications which had been
1900 * deleted with {@code DONT_DELETE_DATA} flag set).
1902 * @see #GET_META_DATA
1903 * @see #GET_SHARED_LIBRARY_FILES
1904 * @see #GET_UNINSTALLED_PACKAGES
1906 public abstract ApplicationInfo getApplicationInfo(String packageName,
1907 int flags) throws NameNotFoundException;
1910 * Retrieve all of the information we know about a particular activity
1913 * <p>Throws {@link NameNotFoundException} if an activity with the given
1914 * class name cannot be found on the system.
1916 * @param component The full component name (i.e.
1917 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1919 * @param flags Additional option flags. Use any combination of
1920 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1921 * to modify the data (in ApplicationInfo) returned.
1923 * @return {@link ActivityInfo} containing information about the activity.
1925 * @see #GET_INTENT_FILTERS
1926 * @see #GET_META_DATA
1927 * @see #GET_SHARED_LIBRARY_FILES
1929 public abstract ActivityInfo getActivityInfo(ComponentName component,
1930 int flags) throws NameNotFoundException;
1933 * Retrieve all of the information we know about a particular receiver
1936 * <p>Throws {@link NameNotFoundException} if a receiver with the given
1937 * class name cannot be found on the system.
1939 * @param component The full component name (i.e.
1940 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1942 * @param flags Additional option flags. Use any combination of
1943 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1944 * to modify the data returned.
1946 * @return {@link ActivityInfo} containing information about the receiver.
1948 * @see #GET_INTENT_FILTERS
1949 * @see #GET_META_DATA
1950 * @see #GET_SHARED_LIBRARY_FILES
1952 public abstract ActivityInfo getReceiverInfo(ComponentName component,
1953 int flags) throws NameNotFoundException;
1956 * Retrieve all of the information we know about a particular service
1959 * <p>Throws {@link NameNotFoundException} if a service with the given
1960 * class name cannot be found on the system.
1962 * @param component The full component name (i.e.
1963 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1965 * @param flags Additional option flags. Use any combination of
1966 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1967 * to modify the data returned.
1969 * @return ServiceInfo containing information about the service.
1971 * @see #GET_META_DATA
1972 * @see #GET_SHARED_LIBRARY_FILES
1974 public abstract ServiceInfo getServiceInfo(ComponentName component,
1975 int flags) throws NameNotFoundException;
1978 * Retrieve all of the information we know about a particular content
1981 * <p>Throws {@link NameNotFoundException} if a provider with the given
1982 * class name cannot be found on the system.
1984 * @param component The full component name (i.e.
1985 * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1986 * ContentProvider class.
1987 * @param flags Additional option flags. Use any combination of
1988 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1989 * to modify the data returned.
1991 * @return ProviderInfo containing information about the service.
1993 * @see #GET_META_DATA
1994 * @see #GET_SHARED_LIBRARY_FILES
1996 public abstract ProviderInfo getProviderInfo(ComponentName component,
1997 int flags) throws NameNotFoundException;
2000 * Return a List of all packages that are installed
2003 * @param flags Additional option flags. Use any combination of
2004 * {@link #GET_ACTIVITIES},
2005 * {@link #GET_GIDS},
2006 * {@link #GET_CONFIGURATIONS},
2007 * {@link #GET_INSTRUMENTATION},
2008 * {@link #GET_PERMISSIONS},
2009 * {@link #GET_PROVIDERS},
2010 * {@link #GET_RECEIVERS},
2011 * {@link #GET_SERVICES},
2012 * {@link #GET_SIGNATURES},
2013 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2015 * @return A List of PackageInfo objects, one for each package that is
2016 * installed on the device. In the unlikely case of there being no
2017 * installed packages, an empty list is returned.
2018 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2019 * applications including those deleted with {@code DONT_DELETE_DATA}
2020 * (partially installed apps with data directory) will be returned.
2022 * @see #GET_ACTIVITIES
2024 * @see #GET_CONFIGURATIONS
2025 * @see #GET_INSTRUMENTATION
2026 * @see #GET_PERMISSIONS
2027 * @see #GET_PROVIDERS
2028 * @see #GET_RECEIVERS
2029 * @see #GET_SERVICES
2030 * @see #GET_SIGNATURES
2031 * @see #GET_UNINSTALLED_PACKAGES
2033 public abstract List<PackageInfo> getInstalledPackages(int flags);
2036 * Return a List of all installed packages that are currently
2037 * holding any of the given permissions.
2039 * @param flags Additional option flags. Use any combination of
2040 * {@link #GET_ACTIVITIES},
2041 * {@link #GET_GIDS},
2042 * {@link #GET_CONFIGURATIONS},
2043 * {@link #GET_INSTRUMENTATION},
2044 * {@link #GET_PERMISSIONS},
2045 * {@link #GET_PROVIDERS},
2046 * {@link #GET_RECEIVERS},
2047 * {@link #GET_SERVICES},
2048 * {@link #GET_SIGNATURES},
2049 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2051 * @return Returns a List of PackageInfo objects, one for each installed
2052 * application that is holding any of the permissions that were provided.
2054 * @see #GET_ACTIVITIES
2056 * @see #GET_CONFIGURATIONS
2057 * @see #GET_INSTRUMENTATION
2058 * @see #GET_PERMISSIONS
2059 * @see #GET_PROVIDERS
2060 * @see #GET_RECEIVERS
2061 * @see #GET_SERVICES
2062 * @see #GET_SIGNATURES
2063 * @see #GET_UNINSTALLED_PACKAGES
2065 public abstract List<PackageInfo> getPackagesHoldingPermissions(
2066 String[] permissions, int flags);
2069 * Return a List of all packages that are installed on the device, for a specific user.
2070 * Requesting a list of installed packages for another user
2071 * will require the permission INTERACT_ACROSS_USERS_FULL.
2072 * @param flags Additional option flags. Use any combination of
2073 * {@link #GET_ACTIVITIES},
2074 * {@link #GET_GIDS},
2075 * {@link #GET_CONFIGURATIONS},
2076 * {@link #GET_INSTRUMENTATION},
2077 * {@link #GET_PERMISSIONS},
2078 * {@link #GET_PROVIDERS},
2079 * {@link #GET_RECEIVERS},
2080 * {@link #GET_SERVICES},
2081 * {@link #GET_SIGNATURES},
2082 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2083 * @param userId The user for whom the installed packages are to be listed
2085 * @return A List of PackageInfo objects, one for each package that is
2086 * installed on the device. In the unlikely case of there being no
2087 * installed packages, an empty list is returned.
2088 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2089 * applications including those deleted with {@code DONT_DELETE_DATA}
2090 * (partially installed apps with data directory) will be returned.
2092 * @see #GET_ACTIVITIES
2094 * @see #GET_CONFIGURATIONS
2095 * @see #GET_INSTRUMENTATION
2096 * @see #GET_PERMISSIONS
2097 * @see #GET_PROVIDERS
2098 * @see #GET_RECEIVERS
2099 * @see #GET_SERVICES
2100 * @see #GET_SIGNATURES
2101 * @see #GET_UNINSTALLED_PACKAGES
2105 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
2108 * Check whether a particular package has been granted a particular
2111 * @param permName The name of the permission you are checking for,
2112 * @param pkgName The name of the package you are checking against.
2114 * @return If the package has the permission, PERMISSION_GRANTED is
2115 * returned. If it does not have the permission, PERMISSION_DENIED
2118 * @see #PERMISSION_GRANTED
2119 * @see #PERMISSION_DENIED
2121 public abstract int checkPermission(String permName, String pkgName);
2124 * Add a new dynamic permission to the system. For this to work, your
2125 * package must have defined a permission tree through the
2126 * {@link android.R.styleable#AndroidManifestPermissionTree
2127 * <permission-tree>} tag in its manifest. A package can only add
2128 * permissions to trees that were defined by either its own package or
2129 * another with the same user id; a permission is in a tree if it
2130 * matches the name of the permission tree + ".": for example,
2131 * "com.foo.bar" is a member of the permission tree "com.foo".
2133 * <p>It is good to make your permission tree name descriptive, because you
2134 * are taking possession of that entire set of permission names. Thus, it
2135 * must be under a domain you control, with a suffix that will not match
2136 * any normal permissions that may be declared in any applications that
2137 * are part of that domain.
2139 * <p>New permissions must be added before
2140 * any .apks are installed that use those permissions. Permissions you
2141 * add through this method are remembered across reboots of the device.
2142 * If the given permission already exists, the info you supply here
2143 * will be used to update it.
2145 * @param info Description of the permission to be added.
2147 * @return Returns true if a new permission was created, false if an
2148 * existing one was updated.
2150 * @throws SecurityException if you are not allowed to add the
2151 * given permission name.
2153 * @see #removePermission(String)
2155 public abstract boolean addPermission(PermissionInfo info);
2158 * Like {@link #addPermission(PermissionInfo)} but asynchronously
2159 * persists the package manager state after returning from the call,
2160 * allowing it to return quicker and batch a series of adds at the
2161 * expense of no guarantee the added permission will be retained if
2162 * the device is rebooted before it is written.
2164 public abstract boolean addPermissionAsync(PermissionInfo info);
2167 * Removes a permission that was previously added with
2168 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply
2169 * -- you are only allowed to remove permissions that you are allowed
2172 * @param name The name of the permission to remove.
2174 * @throws SecurityException if you are not allowed to remove the
2175 * given permission name.
2177 * @see #addPermission(PermissionInfo)
2179 public abstract void removePermission(String name);
2182 * Returns an {@link Intent} suitable for passing to {@code startActivityForResult}
2183 * which prompts the user to grant {@code permissions} to this application.
2186 * @throws NullPointerException if {@code permissions} is {@code null}.
2187 * @throws IllegalArgumentException if {@code permissions} contains {@code null}.
2189 public Intent buildPermissionRequestIntent(String... permissions) {
2190 if (permissions == null) {
2191 throw new NullPointerException("permissions cannot be null");
2193 for (String permission : permissions) {
2194 if (permission == null) {
2195 throw new IllegalArgumentException("permissions cannot contain null");
2199 Intent i = new Intent(ACTION_REQUEST_PERMISSION);
2200 i.putExtra(EXTRA_REQUEST_PERMISSION_PERMISSION_LIST, permissions);
2201 i.setPackage("com.android.packageinstaller");
2206 * Grant a permission to an application which the application does not
2207 * already have. The permission must have been requested by the application,
2208 * but as an optional permission. If the application is not allowed to
2209 * hold the permission, a SecurityException is thrown.
2212 * @param packageName The name of the package that the permission will be
2214 * @param permissionName The name of the permission.
2216 public abstract void grantPermission(String packageName, String permissionName);
2219 * Revoke a permission that was previously granted by {@link #grantPermission}.
2222 * @param packageName The name of the package that the permission will be
2224 * @param permissionName The name of the permission.
2226 public abstract void revokePermission(String packageName, String permissionName);
2229 * Compare the signatures of two packages to determine if the same
2230 * signature appears in both of them. If they do contain the same
2231 * signature, then they are allowed special privileges when working
2232 * with each other: they can share the same user-id, run instrumentation
2233 * against each other, etc.
2235 * @param pkg1 First package name whose signature will be compared.
2236 * @param pkg2 Second package name whose signature will be compared.
2238 * @return Returns an integer indicating whether all signatures on the
2239 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2240 * all signatures match or < 0 if there is not a match ({@link
2241 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2243 * @see #checkSignatures(int, int)
2244 * @see #SIGNATURE_MATCH
2245 * @see #SIGNATURE_NO_MATCH
2246 * @see #SIGNATURE_UNKNOWN_PACKAGE
2248 public abstract int checkSignatures(String pkg1, String pkg2);
2251 * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2252 * the two packages to be checked. This can be useful, for example,
2253 * when doing the check in an IPC, where the UID is the only identity
2254 * available. It is functionally identical to determining the package
2255 * associated with the UIDs and checking their signatures.
2257 * @param uid1 First UID whose signature will be compared.
2258 * @param uid2 Second UID whose signature will be compared.
2260 * @return Returns an integer indicating whether all signatures on the
2261 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2262 * all signatures match or < 0 if there is not a match ({@link
2263 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2265 * @see #checkSignatures(String, String)
2266 * @see #SIGNATURE_MATCH
2267 * @see #SIGNATURE_NO_MATCH
2268 * @see #SIGNATURE_UNKNOWN_PACKAGE
2270 public abstract int checkSignatures(int uid1, int uid2);
2273 * Retrieve the names of all packages that are associated with a particular
2274 * user id. In most cases, this will be a single package name, the package
2275 * that has been assigned that user id. Where there are multiple packages
2276 * sharing the same user id through the "sharedUserId" mechanism, all
2277 * packages with that id will be returned.
2279 * @param uid The user id for which you would like to retrieve the
2280 * associated packages.
2282 * @return Returns an array of one or more packages assigned to the user
2283 * id, or null if there are no known packages with the given id.
2285 public abstract String[] getPackagesForUid(int uid);
2288 * Retrieve the official name associated with a user id. This name is
2289 * guaranteed to never change, though it is possibly for the underlying
2290 * user id to be changed. That is, if you are storing information about
2291 * user ids in persistent storage, you should use the string returned
2292 * by this function instead of the raw user-id.
2294 * @param uid The user id for which you would like to retrieve a name.
2295 * @return Returns a unique name for the given user id, or null if the
2296 * user id is not currently assigned.
2298 public abstract String getNameForUid(int uid);
2301 * Return the user id associated with a shared user name. Multiple
2302 * applications can specify a shared user name in their manifest and thus
2303 * end up using a common uid. This might be used for new applications
2304 * that use an existing shared user name and need to know the uid of the
2307 * @param sharedUserName The shared user name whose uid is to be retrieved.
2308 * @return Returns the uid associated with the shared user, or NameNotFoundException
2309 * if the shared user name is not being used by any installed packages
2312 public abstract int getUidForSharedUser(String sharedUserName)
2313 throws NameNotFoundException;
2316 * Return a List of all application packages that are installed on the
2317 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2318 * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2319 * installed apps with data directory) will be returned.
2321 * @param flags Additional option flags. Use any combination of
2322 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2323 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2325 * @return Returns a List of ApplicationInfo objects, one for each application that
2326 * is installed on the device. In the unlikely case of there being
2327 * no installed applications, an empty list is returned.
2328 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2329 * applications including those deleted with {@code DONT_DELETE_DATA}
2330 * (partially installed apps with data directory) will be returned.
2332 * @see #GET_META_DATA
2333 * @see #GET_SHARED_LIBRARY_FILES
2334 * @see #GET_UNINSTALLED_PACKAGES
2336 public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2339 * Get a list of shared libraries that are available on the
2342 * @return An array of shared library names that are
2343 * available on the system, or null if none are installed.
2346 public abstract String[] getSystemSharedLibraryNames();
2349 * Get a list of features that are available on the
2352 * @return An array of FeatureInfo classes describing the features
2353 * that are available on the system, or null if there are none(!!).
2355 public abstract FeatureInfo[] getSystemAvailableFeatures();
2358 * Check whether the given feature name is one of the available
2359 * features as returned by {@link #getSystemAvailableFeatures()}.
2361 * @return Returns true if the devices supports the feature, else
2364 public abstract boolean hasSystemFeature(String name);
2367 * Determine the best action to perform for a given Intent. This is how
2368 * {@link Intent#resolveActivity} finds an activity if a class has not
2369 * been explicitly specified.
2371 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2372 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2373 * only flag. You need to do so to resolve the activity in the same way
2374 * that {@link android.content.Context#startActivity(Intent)} and
2375 * {@link android.content.Intent#resolveActivity(PackageManager)
2376 * Intent.resolveActivity(PackageManager)} do.</p>
2378 * @param intent An intent containing all of the desired specification
2379 * (action, data, type, category, and/or component).
2380 * @param flags Additional option flags. The most important is
2381 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2382 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2384 * @return Returns a ResolveInfo containing the final activity intent that
2385 * was determined to be the best action. Returns null if no
2386 * matching activity was found. If multiple matching activities are
2387 * found and there is no default set, returns a ResolveInfo
2388 * containing something else, such as the activity resolver.
2390 * @see #MATCH_DEFAULT_ONLY
2391 * @see #GET_INTENT_FILTERS
2392 * @see #GET_RESOLVED_FILTER
2394 public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2397 * Determine the best action to perform for a given Intent for a given user. This
2398 * is how {@link Intent#resolveActivity} finds an activity if a class has not
2399 * been explicitly specified.
2401 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2402 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2403 * only flag. You need to do so to resolve the activity in the same way
2404 * that {@link android.content.Context#startActivity(Intent)} and
2405 * {@link android.content.Intent#resolveActivity(PackageManager)
2406 * Intent.resolveActivity(PackageManager)} do.</p>
2408 * @param intent An intent containing all of the desired specification
2409 * (action, data, type, category, and/or component).
2410 * @param flags Additional option flags. The most important is
2411 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2412 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2413 * @param userId The user id.
2415 * @return Returns a ResolveInfo containing the final activity intent that
2416 * was determined to be the best action. Returns null if no
2417 * matching activity was found. If multiple matching activities are
2418 * found and there is no default set, returns a ResolveInfo
2419 * containing something else, such as the activity resolver.
2421 * @see #MATCH_DEFAULT_ONLY
2422 * @see #GET_INTENT_FILTERS
2423 * @see #GET_RESOLVED_FILTER
2427 public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
2430 * Retrieve all activities that can be performed for the given intent.
2432 * @param intent The desired intent as per resolveActivity().
2433 * @param flags Additional option flags. The most important is
2434 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2435 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2437 * @return A List<ResolveInfo> containing one entry for each matching
2438 * Activity. These are ordered from best to worst match -- that
2439 * is, the first item in the list is what is returned by
2440 * {@link #resolveActivity}. If there are no matching activities, an empty
2443 * @see #MATCH_DEFAULT_ONLY
2444 * @see #GET_INTENT_FILTERS
2445 * @see #GET_RESOLVED_FILTER
2447 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
2451 * Retrieve all activities that can be performed for the given intent, for a specific user.
2453 * @param intent The desired intent as per resolveActivity().
2454 * @param flags Additional option flags. The most important is
2455 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2456 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2458 * @return A List<ResolveInfo> containing one entry for each matching
2459 * Activity. These are ordered from best to worst match -- that
2460 * is, the first item in the list is what is returned by
2461 * {@link #resolveActivity}. If there are no matching activities, an empty
2464 * @see #MATCH_DEFAULT_ONLY
2465 * @see #GET_INTENT_FILTERS
2466 * @see #GET_RESOLVED_FILTER
2469 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
2470 int flags, int userId);
2474 * Retrieve a set of activities that should be presented to the user as
2475 * similar options. This is like {@link #queryIntentActivities}, except it
2476 * also allows you to supply a list of more explicit Intents that you would
2477 * like to resolve to particular options, and takes care of returning the
2478 * final ResolveInfo list in a reasonable order, with no duplicates, based
2481 * @param caller The class name of the activity that is making the
2482 * request. This activity will never appear in the output
2483 * list. Can be null.
2484 * @param specifics An array of Intents that should be resolved to the
2485 * first specific results. Can be null.
2486 * @param intent The desired intent as per resolveActivity().
2487 * @param flags Additional option flags. The most important is
2488 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2489 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2491 * @return A List<ResolveInfo> containing one entry for each matching
2492 * Activity. These are ordered first by all of the intents resolved
2493 * in <var>specifics</var> and then any additional activities that
2494 * can handle <var>intent</var> but did not get included by one of
2495 * the <var>specifics</var> intents. If there are no matching
2496 * activities, an empty list is returned.
2498 * @see #MATCH_DEFAULT_ONLY
2499 * @see #GET_INTENT_FILTERS
2500 * @see #GET_RESOLVED_FILTER
2502 public abstract List<ResolveInfo> queryIntentActivityOptions(
2503 ComponentName caller, Intent[] specifics, Intent intent, int flags);
2506 * Retrieve all receivers that can handle a broadcast of the given intent.
2508 * @param intent The desired intent as per resolveActivity().
2509 * @param flags Additional option flags.
2511 * @return A List<ResolveInfo> containing one entry for each matching
2512 * Receiver. These are ordered from first to last in priority. If
2513 * there are no matching receivers, an empty list is returned.
2515 * @see #MATCH_DEFAULT_ONLY
2516 * @see #GET_INTENT_FILTERS
2517 * @see #GET_RESOLVED_FILTER
2519 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2523 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
2526 * @param intent The desired intent as per resolveActivity().
2527 * @param flags Additional option flags.
2528 * @param userId The userId of the user being queried.
2530 * @return A List<ResolveInfo> containing one entry for each matching
2531 * Receiver. These are ordered from first to last in priority. If
2532 * there are no matching receivers, an empty list is returned.
2534 * @see #MATCH_DEFAULT_ONLY
2535 * @see #GET_INTENT_FILTERS
2536 * @see #GET_RESOLVED_FILTER
2539 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2540 int flags, int userId);
2543 * Determine the best service to handle for a given Intent.
2545 * @param intent An intent containing all of the desired specification
2546 * (action, data, type, category, and/or component).
2547 * @param flags Additional option flags.
2549 * @return Returns a ResolveInfo containing the final service intent that
2550 * was determined to be the best action. Returns null if no
2551 * matching service was found.
2553 * @see #GET_INTENT_FILTERS
2554 * @see #GET_RESOLVED_FILTER
2556 public abstract ResolveInfo resolveService(Intent intent, int flags);
2559 * Retrieve all services that can match the given intent.
2561 * @param intent The desired intent as per resolveService().
2562 * @param flags Additional option flags.
2564 * @return A List<ResolveInfo> containing one entry for each matching
2565 * ServiceInfo. These are ordered from best to worst match -- that
2566 * is, the first item in the list is what is returned by
2567 * resolveService(). If there are no matching services, an empty
2570 * @see #GET_INTENT_FILTERS
2571 * @see #GET_RESOLVED_FILTER
2573 public abstract List<ResolveInfo> queryIntentServices(Intent intent,
2577 * Retrieve all services that can match the given intent for a given user.
2579 * @param intent The desired intent as per resolveService().
2580 * @param flags Additional option flags.
2581 * @param userId The user id.
2583 * @return A List<ResolveInfo> containing one entry for each matching
2584 * ServiceInfo. These are ordered from best to worst match -- that
2585 * is, the first item in the list is what is returned by
2586 * resolveService(). If there are no matching services, an empty
2589 * @see #GET_INTENT_FILTERS
2590 * @see #GET_RESOLVED_FILTER
2594 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
2595 int flags, int userId);
2598 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
2599 Intent intent, int flags, int userId);
2602 * Retrieve all providers that can match the given intent.
2604 * @param intent An intent containing all of the desired specification
2605 * (action, data, type, category, and/or component).
2606 * @param flags Additional option flags.
2607 * @return A List<ResolveInfo> containing one entry for each matching
2608 * ProviderInfo. These are ordered from best to worst match. If
2609 * there are no matching providers, an empty list is returned.
2610 * @see #GET_INTENT_FILTERS
2611 * @see #GET_RESOLVED_FILTER
2613 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
2616 * Find a single content provider by its base path name.
2618 * @param name The name of the provider to find.
2619 * @param flags Additional option flags. Currently should always be 0.
2621 * @return ContentProviderInfo Information about the provider, if found,
2624 public abstract ProviderInfo resolveContentProvider(String name,
2628 * Find a single content provider by its base path name.
2630 * @param name The name of the provider to find.
2631 * @param flags Additional option flags. Currently should always be 0.
2632 * @param userId The user id.
2634 * @return ContentProviderInfo Information about the provider, if found,
2638 public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
2641 * Retrieve content provider information.
2643 * <p><em>Note: unlike most other methods, an empty result set is indicated
2644 * by a null return instead of an empty list.</em>
2646 * @param processName If non-null, limits the returned providers to only
2647 * those that are hosted by the given process. If null,
2648 * all content providers are returned.
2649 * @param uid If <var>processName</var> is non-null, this is the required
2650 * uid owning the requested content providers.
2651 * @param flags Additional option flags. Currently should always be 0.
2653 * @return A List<ContentProviderInfo> containing one entry for each
2654 * content provider either patching <var>processName</var> or, if
2655 * <var>processName</var> is null, all known content providers.
2656 * <em>If there are no matching providers, null is returned.</em>
2658 public abstract List<ProviderInfo> queryContentProviders(
2659 String processName, int uid, int flags);
2662 * Retrieve all of the information we know about a particular
2663 * instrumentation class.
2665 * <p>Throws {@link NameNotFoundException} if instrumentation with the
2666 * given class name cannot be found on the system.
2668 * @param className The full name (i.e.
2669 * com.google.apps.contacts.InstrumentList) of an
2670 * Instrumentation class.
2671 * @param flags Additional option flags. Currently should always be 0.
2673 * @return InstrumentationInfo containing information about the
2676 public abstract InstrumentationInfo getInstrumentationInfo(
2677 ComponentName className, int flags) throws NameNotFoundException;
2680 * Retrieve information about available instrumentation code. May be used
2681 * to retrieve either all instrumentation code, or only the code targeting
2682 * a particular package.
2684 * @param targetPackage If null, all instrumentation is returned; only the
2685 * instrumentation targeting this package name is
2687 * @param flags Additional option flags. Currently should always be 0.
2689 * @return A List<InstrumentationInfo> containing one entry for each
2690 * matching available Instrumentation. Returns an empty list if
2691 * there is no instrumentation available for the given package.
2693 public abstract List<InstrumentationInfo> queryInstrumentation(
2694 String targetPackage, int flags);
2697 * Retrieve an image from a package. This is a low-level API used by
2698 * the various package manager info structures (such as
2699 * {@link ComponentInfo} to implement retrieval of their associated
2702 * @param packageName The name of the package that this icon is coming from.
2704 * @param resid The resource identifier of the desired image. Cannot be 0.
2705 * @param appInfo Overall information about <var>packageName</var>. This
2706 * may be null, in which case the application information will be retrieved
2707 * for you if needed; if you already have this information around, it can
2708 * be much more efficient to supply it here.
2710 * @return Returns a Drawable holding the requested image. Returns null if
2711 * an image could not be found for any reason.
2713 public abstract Drawable getDrawable(String packageName, int resid,
2714 ApplicationInfo appInfo);
2717 * Retrieve the icon associated with an activity. Given the full name of
2718 * an activity, retrieves the information about it and calls
2719 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
2720 * If the activity cannot be found, NameNotFoundException is thrown.
2722 * @param activityName Name of the activity whose icon is to be retrieved.
2724 * @return Returns the image of the icon, or the default activity icon if
2725 * it could not be found. Does not return null.
2726 * @throws NameNotFoundException Thrown if the resources for the given
2727 * activity could not be loaded.
2729 * @see #getActivityIcon(Intent)
2731 public abstract Drawable getActivityIcon(ComponentName activityName)
2732 throws NameNotFoundException;
2735 * Retrieve the icon associated with an Intent. If intent.getClassName() is
2736 * set, this simply returns the result of
2737 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
2738 * component and returns the icon associated with the resolved component.
2739 * If intent.getClassName() cannot be found or the Intent cannot be resolved
2740 * to a component, NameNotFoundException is thrown.
2742 * @param intent The intent for which you would like to retrieve an icon.
2744 * @return Returns the image of the icon, or the default activity icon if
2745 * it could not be found. Does not return null.
2746 * @throws NameNotFoundException Thrown if the resources for application
2747 * matching the given intent could not be loaded.
2749 * @see #getActivityIcon(ComponentName)
2751 public abstract Drawable getActivityIcon(Intent intent)
2752 throws NameNotFoundException;
2755 * Retrieve the banner associated with an activity. Given the full name of
2756 * an activity, retrieves the information about it and calls
2757 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
2758 * banner. If the activity cannot be found, NameNotFoundException is thrown.
2760 * @param activityName Name of the activity whose banner is to be retrieved.
2761 * @return Returns the image of the banner, or null if the activity has no
2763 * @throws NameNotFoundException Thrown if the resources for the given
2764 * activity could not be loaded.
2765 * @see #getActivityBanner(Intent)
2767 public abstract Drawable getActivityBanner(ComponentName activityName)
2768 throws NameNotFoundException;
2771 * Retrieve the banner associated with an Intent. If intent.getClassName()
2772 * is set, this simply returns the result of
2773 * getActivityBanner(intent.getClassName()). Otherwise it resolves the
2774 * intent's component and returns the banner associated with the resolved
2775 * component. If intent.getClassName() cannot be found or the Intent cannot
2776 * be resolved to a component, NameNotFoundException is thrown.
2778 * @param intent The intent for which you would like to retrieve a banner.
2779 * @return Returns the image of the banner, or null if the activity has no
2781 * @throws NameNotFoundException Thrown if the resources for application
2782 * matching the given intent could not be loaded.
2783 * @see #getActivityBanner(ComponentName)
2785 public abstract Drawable getActivityBanner(Intent intent)
2786 throws NameNotFoundException;
2789 * Return the generic icon for an activity that is used when no specific
2792 * @return Drawable Image of the icon.
2794 public abstract Drawable getDefaultActivityIcon();
2797 * Retrieve the icon associated with an application. If it has not defined
2798 * an icon, the default app icon is returned. Does not return null.
2800 * @param info Information about application being queried.
2802 * @return Returns the image of the icon, or the default application icon
2803 * if it could not be found.
2805 * @see #getApplicationIcon(String)
2807 public abstract Drawable getApplicationIcon(ApplicationInfo info);
2810 * Retrieve the icon associated with an application. Given the name of the
2811 * application's package, retrieves the information about it and calls
2812 * getApplicationIcon() to return its icon. If the application cannot be
2813 * found, NameNotFoundException is thrown.
2815 * @param packageName Name of the package whose application icon is to be
2818 * @return Returns the image of the icon, or the default application icon
2819 * if it could not be found. Does not return null.
2820 * @throws NameNotFoundException Thrown if the resources for the given
2821 * application could not be loaded.
2823 * @see #getApplicationIcon(ApplicationInfo)
2825 public abstract Drawable getApplicationIcon(String packageName)
2826 throws NameNotFoundException;
2829 * Retrieve the banner associated with an application.
2831 * @param info Information about application being queried.
2832 * @return Returns the image of the banner or null if the application has no
2834 * @see #getApplicationBanner(String)
2836 public abstract Drawable getApplicationBanner(ApplicationInfo info);
2839 * Retrieve the banner associated with an application. Given the name of the
2840 * application's package, retrieves the information about it and calls
2841 * getApplicationIcon() to return its banner. If the application cannot be
2842 * found, NameNotFoundException is thrown.
2844 * @param packageName Name of the package whose application banner is to be
2846 * @return Returns the image of the banner or null if the application has no
2848 * @throws NameNotFoundException Thrown if the resources for the given
2849 * application could not be loaded.
2850 * @see #getApplicationBanner(ApplicationInfo)
2852 public abstract Drawable getApplicationBanner(String packageName)
2853 throws NameNotFoundException;
2856 * Retrieve the logo associated with an activity. Given the full name of an
2857 * activity, retrieves the information about it and calls
2858 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
2859 * logo. If the activity cannot be found, NameNotFoundException is thrown.
2861 * @param activityName Name of the activity whose logo is to be retrieved.
2862 * @return Returns the image of the logo or null if the activity has no logo
2864 * @throws NameNotFoundException Thrown if the resources for the given
2865 * activity could not be loaded.
2866 * @see #getActivityLogo(Intent)
2868 public abstract Drawable getActivityLogo(ComponentName activityName)
2869 throws NameNotFoundException;
2872 * Retrieve the logo associated with an Intent. If intent.getClassName() is
2873 * set, this simply returns the result of
2874 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's
2875 * component and returns the logo associated with the resolved component.
2876 * If intent.getClassName() cannot be found or the Intent cannot be resolved
2877 * to a component, NameNotFoundException is thrown.
2879 * @param intent The intent for which you would like to retrieve a logo.
2881 * @return Returns the image of the logo, or null if the activity has no
2884 * @throws NameNotFoundException Thrown if the resources for application
2885 * matching the given intent could not be loaded.
2887 * @see #getActivityLogo(ComponentName)
2889 public abstract Drawable getActivityLogo(Intent intent)
2890 throws NameNotFoundException;
2893 * Retrieve the logo associated with an application. If it has not specified
2894 * a logo, this method returns null.
2896 * @param info Information about application being queried.
2898 * @return Returns the image of the logo, or null if no logo is specified
2899 * by the application.
2901 * @see #getApplicationLogo(String)
2903 public abstract Drawable getApplicationLogo(ApplicationInfo info);
2906 * Retrieve the logo associated with an application. Given the name of the
2907 * application's package, retrieves the information about it and calls
2908 * getApplicationLogo() to return its logo. If the application cannot be
2909 * found, NameNotFoundException is thrown.
2911 * @param packageName Name of the package whose application logo is to be
2914 * @return Returns the image of the logo, or null if no application logo
2915 * has been specified.
2917 * @throws NameNotFoundException Thrown if the resources for the given
2918 * application could not be loaded.
2920 * @see #getApplicationLogo(ApplicationInfo)
2922 public abstract Drawable getApplicationLogo(String packageName)
2923 throws NameNotFoundException;
2926 * If the target user is a managed profile of the calling user or the caller
2927 * is itself a managed profile, then this returns a badged copy of the given
2928 * icon to be able to distinguish it from the original icon. For badging an
2929 * arbitrary drawable use {@link #getUserBadgedDrawableForDensity(
2930 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
2932 * If the original drawable is a BitmapDrawable and the backing bitmap is
2933 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
2934 * is performed in place and the original drawable is returned.
2937 * @param icon The icon to badge.
2938 * @param user The target user.
2939 * @return A drawable that combines the original icon and a badge as
2940 * determined by the system.
2942 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
2945 * If the target user is a managed profile of the calling user or the caller
2946 * is itself a managed profile, then this returns a badged copy of the given
2947 * drawable allowing the user to distinguish it from the original drawable.
2948 * The caller can specify the location in the bounds of the drawable to be
2949 * badged where the badge should be applied as well as the density of the
2952 * If the original drawable is a BitmapDrawable and the backing bitmap is
2953 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
2954 * is performed in place and the original drawable is returned.
2957 * @param drawable The drawable to badge.
2958 * @param user The target user.
2959 * @param badgeLocation Where in the bounds of the badged drawable to place
2960 * the badge. If not provided, the badge is applied on top of the entire
2961 * drawable being badged.
2962 * @param badgeDensity The optional desired density for the badge as per
2963 * {@link android.util.DisplayMetrics#densityDpi}. If not provided,
2964 * the density of the display is used.
2965 * @return A drawable that combines the original drawable and a badge as
2966 * determined by the system.
2968 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
2969 UserHandle user, Rect badgeLocation, int badgeDensity);
2972 * If the target user is a managed profile of the calling user or the caller
2973 * is itself a managed profile, then this returns a drawable to use as a small
2974 * icon to include in a view to distinguish it from the original icon.
2976 * @param user The target user.
2977 * @param density The optional desired density for the badge as per
2978 * {@link android.util.DisplayMetrics#densityDpi}. If not provided
2979 * the density of the current display is used.
2980 * @return the drawable or null if no drawable is required.
2983 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
2986 * If the target user is a managed profile of the calling user or the caller
2987 * is itself a managed profile, then this returns a copy of the label with
2988 * badging for accessibility services like talkback. E.g. passing in "Email"
2989 * and it might return "Work Email" for Email in the work profile.
2991 * @param label The label to change.
2992 * @param user The target user.
2993 * @return A label that combines the original label and a badge as
2994 * determined by the system.
2996 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
2999 * Retrieve text from a package. This is a low-level API used by
3000 * the various package manager info structures (such as
3001 * {@link ComponentInfo} to implement retrieval of their associated
3002 * labels and other text.
3004 * @param packageName The name of the package that this text is coming from.
3006 * @param resid The resource identifier of the desired text. Cannot be 0.
3007 * @param appInfo Overall information about <var>packageName</var>. This
3008 * may be null, in which case the application information will be retrieved
3009 * for you if needed; if you already have this information around, it can
3010 * be much more efficient to supply it here.
3012 * @return Returns a CharSequence holding the requested text. Returns null
3013 * if the text could not be found for any reason.
3015 public abstract CharSequence getText(String packageName, int resid,
3016 ApplicationInfo appInfo);
3019 * Retrieve an XML file from a package. This is a low-level API used to
3020 * retrieve XML meta data.
3022 * @param packageName The name of the package that this xml is coming from.
3024 * @param resid The resource identifier of the desired xml. Cannot be 0.
3025 * @param appInfo Overall information about <var>packageName</var>. This
3026 * may be null, in which case the application information will be retrieved
3027 * for you if needed; if you already have this information around, it can
3028 * be much more efficient to supply it here.
3030 * @return Returns an XmlPullParser allowing you to parse out the XML
3031 * data. Returns null if the xml resource could not be found for any
3034 public abstract XmlResourceParser getXml(String packageName, int resid,
3035 ApplicationInfo appInfo);
3038 * Return the label to use for this application.
3040 * @return Returns the label associated with this application, or null if
3041 * it could not be found for any reason.
3042 * @param info The application to get the label of.
3044 public abstract CharSequence getApplicationLabel(ApplicationInfo info);
3047 * Retrieve the resources associated with an activity. Given the full
3048 * name of an activity, retrieves the information about it and calls
3049 * getResources() to return its application's resources. If the activity
3050 * cannot be found, NameNotFoundException is thrown.
3052 * @param activityName Name of the activity whose resources are to be
3055 * @return Returns the application's Resources.
3056 * @throws NameNotFoundException Thrown if the resources for the given
3057 * application could not be loaded.
3059 * @see #getResourcesForApplication(ApplicationInfo)
3061 public abstract Resources getResourcesForActivity(ComponentName activityName)
3062 throws NameNotFoundException;
3065 * Retrieve the resources for an application. Throws NameNotFoundException
3066 * if the package is no longer installed.
3068 * @param app Information about the desired application.
3070 * @return Returns the application's Resources.
3071 * @throws NameNotFoundException Thrown if the resources for the given
3072 * application could not be loaded (most likely because it was uninstalled).
3074 public abstract Resources getResourcesForApplication(ApplicationInfo app)
3075 throws NameNotFoundException;
3078 * Retrieve the resources associated with an application. Given the full
3079 * package name of an application, retrieves the information about it and
3080 * calls getResources() to return its application's resources. If the
3081 * appPackageName cannot be found, NameNotFoundException is thrown.
3083 * @param appPackageName Package name of the application whose resources
3084 * are to be retrieved.
3086 * @return Returns the application's Resources.
3087 * @throws NameNotFoundException Thrown if the resources for the given
3088 * application could not be loaded.
3090 * @see #getResourcesForApplication(ApplicationInfo)
3092 public abstract Resources getResourcesForApplication(String appPackageName)
3093 throws NameNotFoundException;
3096 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
3097 throws NameNotFoundException;
3100 * Retrieve overall information about an application package defined
3101 * in a package archive file
3103 * @param archiveFilePath The path to the archive file
3104 * @param flags Additional option flags. Use any combination of
3105 * {@link #GET_ACTIVITIES},
3106 * {@link #GET_GIDS},
3107 * {@link #GET_CONFIGURATIONS},
3108 * {@link #GET_INSTRUMENTATION},
3109 * {@link #GET_PERMISSIONS},
3110 * {@link #GET_PROVIDERS},
3111 * {@link #GET_RECEIVERS},
3112 * {@link #GET_SERVICES},
3113 * {@link #GET_SIGNATURES}, to modify the data returned.
3115 * @return Returns the information about the package. Returns
3116 * null if the package could not be successfully parsed.
3118 * @see #GET_ACTIVITIES
3120 * @see #GET_CONFIGURATIONS
3121 * @see #GET_INSTRUMENTATION
3122 * @see #GET_PERMISSIONS
3123 * @see #GET_PROVIDERS
3124 * @see #GET_RECEIVERS
3125 * @see #GET_SERVICES
3126 * @see #GET_SIGNATURES
3129 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
3130 final PackageParser parser = new PackageParser();
3131 final File apkFile = new File(archiveFilePath);
3133 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3134 if ((flags & GET_SIGNATURES) != 0) {
3135 parser.collectCertificates(pkg, 0);
3136 parser.collectManifestDigest(pkg);
3138 PackageUserState state = new PackageUserState();
3139 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3140 } catch (PackageParserException e) {
3146 * @hide Install a package. Since this may take a little while, the result
3147 * will be posted back to the given observer. An installation will
3148 * fail if the calling context lacks the
3149 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3150 * the package named in the package file's manifest is already
3151 * installed, or if there's no space available on the device.
3152 * @param packageURI The location of the package file to install. This can
3153 * be a 'file:' or a 'content:' URI.
3154 * @param observer An observer callback to get notified when the package
3155 * installation is complete.
3156 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3157 * will be called when that happens. This parameter must not be
3159 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3160 * {@link #INSTALL_REPLACE_EXISTING},
3161 * {@link #INSTALL_ALLOW_TEST}.
3162 * @param installerPackageName Optional package name of the application that
3163 * is performing the installation. This identifies which market
3164 * the package came from.
3165 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3166 * String)} instead. This method will continue to be supported
3167 * but the older observer interface will not get additional
3171 public abstract void installPackage(
3172 Uri packageURI, IPackageInstallObserver observer, int flags,
3173 String installerPackageName);
3177 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3178 * with an extra verification file provided.
3180 * @param packageURI The location of the package file to install. This can
3181 * be a 'file:' or a 'content:' URI.
3182 * @param observer An observer callback to get notified when the package
3183 * installation is complete.
3184 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3185 * will be called when that happens. This parameter must not be
3187 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3188 * {@link #INSTALL_REPLACE_EXISTING},
3189 * {@link #INSTALL_ALLOW_TEST}.
3190 * @param installerPackageName Optional package name of the application that
3191 * is performing the installation. This identifies which market
3192 * the package came from.
3193 * @param verificationURI The location of the supplementary verification
3194 * file. This can be a 'file:' or a 'content:' URI. May be
3196 * @param manifestDigest an object that holds the digest of the package
3197 * which can be used to verify ownership. May be {@code null}.
3198 * @param encryptionParams if the package to be installed is encrypted,
3199 * these parameters describing the encryption and authentication
3200 * used. May be {@code null}.
3202 * @deprecated Use {@link #installPackageWithVerification(Uri,
3203 * PackageInstallObserver, int, String, Uri, ManifestDigest,
3204 * ContainerEncryptionParams)} instead. This method will
3205 * continue to be supported but the older observer interface
3206 * will not get additional failure details.
3209 public abstract void installPackageWithVerification(Uri packageURI,
3210 IPackageInstallObserver observer, int flags, String installerPackageName,
3211 Uri verificationURI, ManifestDigest manifestDigest,
3212 ContainerEncryptionParams encryptionParams);
3216 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3217 * with an extra verification information provided.
3219 * @param packageURI The location of the package file to install. This can
3220 * be a 'file:' or a 'content:' URI.
3221 * @param observer An observer callback to get notified when the package
3222 * installation is complete.
3223 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3224 * will be called when that happens. This parameter must not be
3226 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3227 * {@link #INSTALL_REPLACE_EXISTING},
3228 * {@link #INSTALL_ALLOW_TEST}.
3229 * @param installerPackageName Optional package name of the application that
3230 * is performing the installation. This identifies which market
3231 * the package came from.
3232 * @param verificationParams an object that holds signal information to
3233 * assist verification. May be {@code null}.
3234 * @param encryptionParams if the package to be installed is encrypted,
3235 * these parameters describing the encryption and authentication
3236 * used. May be {@code null}.
3238 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3239 * PackageInstallObserver, int, String, VerificationParams,
3240 * ContainerEncryptionParams)} instead. This method will
3241 * continue to be supported but the older observer interface
3242 * will not get additional failure details.
3245 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3246 IPackageInstallObserver observer, int flags, String installerPackageName,
3247 VerificationParams verificationParams,
3248 ContainerEncryptionParams encryptionParams);
3250 // Package-install variants that take the new, expanded form of observer interface.
3251 // Note that these *also* take the original observer type and will redundantly
3252 // report the same information to that observer if supplied; but it is not required.
3257 * Install a package. Since this may take a little while, the result will
3258 * be posted back to the given observer. An installation will fail if the calling context
3259 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3260 * package named in the package file's manifest is already installed, or if there's no space
3261 * available on the device.
3263 * @param packageURI The location of the package file to install. This can be a 'file:' or a
3265 * @param observer An observer callback to get notified when the package installation is
3266 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3267 * called when that happens. This parameter must not be null.
3268 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3269 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3270 * @param installerPackageName Optional package name of the application that is performing the
3271 * installation. This identifies which market the package came from.
3273 public abstract void installPackage(
3274 Uri packageURI, PackageInstallObserver observer,
3275 int flags, String installerPackageName);
3279 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3280 * with an extra verification file provided.
3282 * @param packageURI The location of the package file to install. This can
3283 * be a 'file:' or a 'content:' URI.
3284 * @param observer An observer callback to get notified when the package installation is
3285 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3286 * called when that happens. This parameter must not be null.
3287 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3288 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3289 * @param installerPackageName Optional package name of the application that
3290 * is performing the installation. This identifies which market
3291 * the package came from.
3292 * @param verificationURI The location of the supplementary verification
3293 * file. This can be a 'file:' or a 'content:' URI. May be
3295 * @param manifestDigest an object that holds the digest of the package
3296 * which can be used to verify ownership. May be {@code null}.
3297 * @param encryptionParams if the package to be installed is encrypted,
3298 * these parameters describing the encryption and authentication
3299 * used. May be {@code null}.
3302 public abstract void installPackageWithVerification(Uri packageURI,
3303 PackageInstallObserver observer, int flags, String installerPackageName,
3304 Uri verificationURI, ManifestDigest manifestDigest,
3305 ContainerEncryptionParams encryptionParams);
3309 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3310 * with an extra verification information provided.
3312 * @param packageURI The location of the package file to install. This can
3313 * be a 'file:' or a 'content:' URI.
3314 * @param observer An observer callback to get notified when the package installation is
3315 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3316 * called when that happens. This parameter must not be null.
3317 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3318 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3319 * @param installerPackageName Optional package name of the application that
3320 * is performing the installation. This identifies which market
3321 * the package came from.
3322 * @param verificationParams an object that holds signal information to
3323 * assist verification. May be {@code null}.
3324 * @param encryptionParams if the package to be installed is encrypted,
3325 * these parameters describing the encryption and authentication
3326 * used. May be {@code null}.
3330 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3331 PackageInstallObserver observer, int flags, String installerPackageName,
3332 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3335 * If there is already an application with the given package name installed
3336 * on the system for other users, also install it for the calling user.
3340 public abstract int installExistingPackage(String packageName)
3341 throws NameNotFoundException;
3344 * Allows a package listening to the
3345 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3346 * broadcast} to respond to the package manager. The response must include
3347 * the {@code verificationCode} which is one of
3348 * {@link PackageManager#VERIFICATION_ALLOW} or
3349 * {@link PackageManager#VERIFICATION_REJECT}.
3351 * @param id pending package identifier as passed via the
3352 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3353 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3354 * or {@link PackageManager#VERIFICATION_REJECT}.
3355 * @throws SecurityException if the caller does not have the
3356 * PACKAGE_VERIFICATION_AGENT permission.
3358 public abstract void verifyPendingInstall(int id, int verificationCode);
3361 * Allows a package listening to the
3362 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3363 * broadcast} to extend the default timeout for a response and declare what
3364 * action to perform after the timeout occurs. The response must include
3365 * the {@code verificationCodeAtTimeout} which is one of
3366 * {@link PackageManager#VERIFICATION_ALLOW} or
3367 * {@link PackageManager#VERIFICATION_REJECT}.
3369 * This method may only be called once per package id. Additional calls
3370 * will have no effect.
3372 * @param id pending package identifier as passed via the
3373 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3374 * @param verificationCodeAtTimeout either
3375 * {@link PackageManager#VERIFICATION_ALLOW} or
3376 * {@link PackageManager#VERIFICATION_REJECT}. If
3377 * {@code verificationCodeAtTimeout} is neither
3378 * {@link PackageManager#VERIFICATION_ALLOW} or
3379 * {@link PackageManager#VERIFICATION_REJECT}, then
3380 * {@code verificationCodeAtTimeout} will default to
3381 * {@link PackageManager#VERIFICATION_REJECT}.
3382 * @param millisecondsToDelay the amount of time requested for the timeout.
3383 * Must be positive and less than
3384 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3385 * {@code millisecondsToDelay} is out of bounds,
3386 * {@code millisecondsToDelay} will be set to the closest in
3387 * bounds value; namely, 0 or
3388 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3389 * @throws SecurityException if the caller does not have the
3390 * PACKAGE_VERIFICATION_AGENT permission.
3392 public abstract void extendVerificationTimeout(int id,
3393 int verificationCodeAtTimeout, long millisecondsToDelay);
3396 * Change the installer associated with a given package. There are limitations
3397 * on how the installer package can be changed; in particular:
3399 * <li> A SecurityException will be thrown if <var>installerPackageName</var>
3400 * is not signed with the same certificate as the calling application.
3401 * <li> A SecurityException will be thrown if <var>targetPackage</var> already
3402 * has an installer package, and that installer package is not signed with
3403 * the same certificate as the calling application.
3406 * @param targetPackage The installed package whose installer will be changed.
3407 * @param installerPackageName The package name of the new installer. May be
3408 * null to clear the association.
3410 public abstract void setInstallerPackageName(String targetPackage,
3411 String installerPackageName);
3414 * Attempts to delete a package. Since this may take a little while, the result will
3415 * be posted back to the given observer. A deletion will fail if the calling context
3416 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
3417 * named package cannot be found, or if the named package is a "system package".
3418 * (TODO: include pointer to documentation on "system packages")
3420 * @param packageName The name of the package to delete
3421 * @param observer An observer callback to get notified when the package deletion is
3422 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
3423 * called when that happens. observer may be null to indicate that no callback is desired.
3424 * @param flags - possible values: {@link #DELETE_KEEP_DATA},
3425 * {@link #DELETE_ALL_USERS}.
3430 public abstract void deletePackage(
3431 String packageName, IPackageDeleteObserver observer, int flags);
3434 * Retrieve the package name of the application that installed a package. This identifies
3435 * which market the package came from.
3437 * @param packageName The name of the package to query
3439 public abstract String getInstallerPackageName(String packageName);
3442 * Attempts to clear the user data directory of an application.
3443 * Since this may take a little while, the result will
3444 * be posted back to the given observer. A deletion will fail if the
3445 * named package cannot be found, or if the named package is a "system package".
3447 * @param packageName The name of the package
3448 * @param observer An observer callback to get notified when the operation is finished
3449 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3450 * will be called when that happens. observer may be null to indicate that
3451 * no callback is desired.
3455 public abstract void clearApplicationUserData(String packageName,
3456 IPackageDataObserver observer);
3458 * Attempts to delete the cache files associated with an application.
3459 * Since this may take a little while, the result will
3460 * be posted back to the given observer. A deletion will fail if the calling context
3461 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
3462 * named package cannot be found, or if the named package is a "system package".
3464 * @param packageName The name of the package to delete
3465 * @param observer An observer callback to get notified when the cache file deletion
3467 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3468 * will be called when that happens. observer may be null to indicate that
3469 * no callback is desired.
3473 public abstract void deleteApplicationCacheFiles(String packageName,
3474 IPackageDataObserver observer);
3477 * Free storage by deleting LRU sorted list of cache files across
3478 * all applications. If the currently available free storage
3479 * on the device is greater than or equal to the requested
3480 * free storage, no cache files are cleared. If the currently
3481 * available storage on the device is less than the requested
3482 * free storage, some or all of the cache files across
3483 * all applications are deleted (based on last accessed time)
3484 * to increase the free storage space on the device to
3485 * the requested value. There is no guarantee that clearing all
3486 * the cache files from all applications will clear up
3487 * enough storage to achieve the desired value.
3488 * @param freeStorageSize The number of bytes of storage to be
3489 * freed by the system. Say if freeStorageSize is XX,
3490 * and the current free storage is YY,
3491 * if XX is less than YY, just return. if not free XX-YY number
3492 * of bytes if possible.
3493 * @param observer call back used to notify when
3494 * the operation is completed
3499 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
3502 * Free storage by deleting LRU sorted list of cache files across
3503 * all applications. If the currently available free storage
3504 * on the device is greater than or equal to the requested
3505 * free storage, no cache files are cleared. If the currently
3506 * available storage on the device is less than the requested
3507 * free storage, some or all of the cache files across
3508 * all applications are deleted (based on last accessed time)
3509 * to increase the free storage space on the device to
3510 * the requested value. There is no guarantee that clearing all
3511 * the cache files from all applications will clear up
3512 * enough storage to achieve the desired value.
3513 * @param freeStorageSize The number of bytes of storage to be
3514 * freed by the system. Say if freeStorageSize is XX,
3515 * and the current free storage is YY,
3516 * if XX is less than YY, just return. if not free XX-YY number
3517 * of bytes if possible.
3518 * @param pi IntentSender call back used to
3519 * notify when the operation is completed.May be null
3520 * to indicate that no call back is desired.
3524 public abstract void freeStorage(long freeStorageSize, IntentSender pi);
3527 * Retrieve the size information for a package.
3528 * Since this may take a little while, the result will
3529 * be posted back to the given observer. The calling context
3530 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
3532 * @param packageName The name of the package whose size information is to be retrieved
3533 * @param userHandle The user whose size information should be retrieved.
3534 * @param observer An observer callback to get notified when the operation
3536 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
3537 * The observer's callback is invoked with a PackageStats object(containing the
3538 * code, data and cache sizes of the package) and a boolean value representing
3539 * the status of the operation. observer may be null to indicate that
3540 * no callback is desired.
3544 public abstract void getPackageSizeInfo(String packageName, int userHandle,
3545 IPackageStatsObserver observer);
3548 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
3549 * returns the size for the calling user.
3553 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
3554 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
3558 * @deprecated This function no longer does anything; it was an old
3559 * approach to managing preferred activities, which has been superseded
3560 * by (and conflicts with) the modern activity-based preferences.
3563 public abstract void addPackageToPreferred(String packageName);
3566 * @deprecated This function no longer does anything; it was an old
3567 * approach to managing preferred activities, which has been superseded
3568 * by (and conflicts with) the modern activity-based preferences.
3571 public abstract void removePackageFromPreferred(String packageName);
3574 * Retrieve the list of all currently configured preferred packages. The
3575 * first package on the list is the most preferred, the last is the
3578 * @param flags Additional option flags. Use any combination of
3579 * {@link #GET_ACTIVITIES},
3580 * {@link #GET_GIDS},
3581 * {@link #GET_CONFIGURATIONS},
3582 * {@link #GET_INSTRUMENTATION},
3583 * {@link #GET_PERMISSIONS},
3584 * {@link #GET_PROVIDERS},
3585 * {@link #GET_RECEIVERS},
3586 * {@link #GET_SERVICES},
3587 * {@link #GET_SIGNATURES}, to modify the data returned.
3589 * @return Returns a list of PackageInfo objects describing each
3590 * preferred application, in order of preference.
3592 * @see #GET_ACTIVITIES
3594 * @see #GET_CONFIGURATIONS
3595 * @see #GET_INSTRUMENTATION
3596 * @see #GET_PERMISSIONS
3597 * @see #GET_PROVIDERS
3598 * @see #GET_RECEIVERS
3599 * @see #GET_SERVICES
3600 * @see #GET_SIGNATURES
3602 public abstract List<PackageInfo> getPreferredPackages(int flags);
3605 * @deprecated This is a protected API that should not have been available
3606 * to third party applications. It is the platform's responsibility for
3607 * assigning preferred activities and this cannot be directly modified.
3609 * Add a new preferred activity mapping to the system. This will be used
3610 * to automatically select the given activity component when
3611 * {@link Context#startActivity(Intent) Context.startActivity()} finds
3612 * multiple matching activities and also matches the given filter.
3614 * @param filter The set of intents under which this activity will be
3616 * @param match The IntentFilter match category that this preference
3618 * @param set The set of activities that the user was picking from when
3619 * this preference was made.
3620 * @param activity The component name of the activity that is to be
3624 public abstract void addPreferredActivity(IntentFilter filter, int match,
3625 ComponentName[] set, ComponentName activity);
3628 * Same as {@link #addPreferredActivity(IntentFilter, int,
3629 ComponentName[], ComponentName)}, but with a specific userId to apply the preference
3633 public void addPreferredActivity(IntentFilter filter, int match,
3634 ComponentName[] set, ComponentName activity, int userId) {
3635 throw new RuntimeException("Not implemented. Must override in a subclass.");
3639 * @deprecated This is a protected API that should not have been available
3640 * to third party applications. It is the platform's responsibility for
3641 * assigning preferred activities and this cannot be directly modified.
3643 * Replaces an existing preferred activity mapping to the system, and if that were not present
3644 * adds a new preferred activity. This will be used
3645 * to automatically select the given activity component when
3646 * {@link Context#startActivity(Intent) Context.startActivity()} finds
3647 * multiple matching activities and also matches the given filter.
3649 * @param filter The set of intents under which this activity will be
3651 * @param match The IntentFilter match category that this preference
3653 * @param set The set of activities that the user was picking from when
3654 * this preference was made.
3655 * @param activity The component name of the activity that is to be
3660 public abstract void replacePreferredActivity(IntentFilter filter, int match,
3661 ComponentName[] set, ComponentName activity);
3667 public void replacePreferredActivityAsUser(IntentFilter filter, int match,
3668 ComponentName[] set, ComponentName activity, int userId) {
3669 throw new RuntimeException("Not implemented. Must override in a subclass.");
3673 * Remove all preferred activity mappings, previously added with
3674 * {@link #addPreferredActivity}, from the
3675 * system whose activities are implemented in the given package name.
3676 * An application can only clear its own package(s).
3678 * @param packageName The name of the package whose preferred activity
3679 * mappings are to be removed.
3681 public abstract void clearPackagePreferredActivities(String packageName);
3684 * Retrieve all preferred activities, previously added with
3685 * {@link #addPreferredActivity}, that are
3686 * currently registered with the system.
3688 * @param outFilters A list in which to place the filters of all of the
3689 * preferred activities, or null for none.
3690 * @param outActivities A list in which to place the component names of
3691 * all of the preferred activities, or null for none.
3692 * @param packageName An option package in which you would like to limit
3693 * the list. If null, all activities will be returned; if non-null, only
3694 * those activities in the given package are returned.
3696 * @return Returns the total number of registered preferred activities
3697 * (the number of distinct IntentFilter records, not the number of unique
3698 * activity components) that were found.
3700 public abstract int getPreferredActivities(List<IntentFilter> outFilters,
3701 List<ComponentName> outActivities, String packageName);
3704 * Ask for the set of available 'home' activities and the current explicit
3708 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
3711 * Set the enabled setting for a package component (activity, receiver, service, provider).
3712 * This setting will override any enabled state which may have been set by the component in its
3715 * @param componentName The component to enable
3716 * @param newState The new enabled state for the component. The legal values for this state
3718 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
3719 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
3721 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3722 * The last one removes the setting, thereby restoring the component's state to
3723 * whatever was set in it's manifest (or enabled, by default).
3724 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3726 public abstract void setComponentEnabledSetting(ComponentName componentName,
3727 int newState, int flags);
3731 * Return the enabled setting for a package component (activity,
3732 * receiver, service, provider). This returns the last value set by
3733 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
3734 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3735 * the value originally specified in the manifest has not been modified.
3737 * @param componentName The component to retrieve.
3738 * @return Returns the current enabled state for the component. May
3739 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3740 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3741 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
3742 * component's enabled state is based on the original information in
3743 * the manifest as found in {@link ComponentInfo}.
3745 public abstract int getComponentEnabledSetting(ComponentName componentName);
3748 * Set the enabled setting for an application
3749 * This setting will override any enabled state which may have been set by the application in
3750 * its manifest. It also overrides the enabled state set in the manifest for any of the
3751 * application's components. It does not override any enabled state set by
3752 * {@link #setComponentEnabledSetting} for any of the application's components.
3754 * @param packageName The package name of the application to enable
3755 * @param newState The new enabled state for the component. The legal values for this state
3757 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
3758 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
3760 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3761 * The last one removes the setting, thereby restoring the applications's state to
3762 * whatever was set in its manifest (or enabled, by default).
3763 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3765 public abstract void setApplicationEnabledSetting(String packageName,
3766 int newState, int flags);
3769 * Return the enabled setting for an application. This returns
3770 * the last value set by
3771 * {@link #setApplicationEnabledSetting(String, int, int)}; in most
3772 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3773 * the value originally specified in the manifest has not been modified.
3775 * @param packageName The package name of the application to retrieve.
3776 * @return Returns the current enabled state for the application. May
3777 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3778 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3779 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
3780 * application's enabled state is based on the original information in
3781 * the manifest as found in {@link ComponentInfo}.
3782 * @throws IllegalArgumentException if the named package does not exist.
3784 public abstract int getApplicationEnabledSetting(String packageName);
3787 * Puts the package in a hidden state, which is almost like an uninstalled state,
3788 * making the package unavailable, but it doesn't remove the data or the actual
3789 * package file. Application can be unhidden by either resetting the hidden state
3790 * or by installing it, such as with {@link #installExistingPackage(String)}
3793 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
3794 UserHandle userHandle);
3797 * Returns the hidden state of a package.
3798 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
3801 public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
3802 UserHandle userHandle);
3805 * Return whether the device has been booted into safe mode.
3807 public abstract boolean isSafeMode();
3810 * Return the {@link KeySet} associated with the String alias for this
3813 * @param alias The alias for a given {@link KeySet} as defined in the
3814 * application's AndroidManifest.xml.
3817 public abstract KeySet getKeySetByAlias(String packageName, String alias);
3819 /** Return the signing {@link KeySet} for this application.
3822 public abstract KeySet getSigningKeySet(String packageName);
3825 * Return whether the package denoted by packageName has been signed by all
3826 * of the keys specified by the {@link KeySet} ks. This will return true if
3827 * the package has been signed by additional keys (a superset) as well.
3828 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
3831 public abstract boolean isSignedBy(String packageName, KeySet ks);
3834 * Return whether the package denoted by packageName has been signed by all
3835 * of, and only, the keys specified by the {@link KeySet} ks. Compare to
3836 * {@link #isSignedBy(String packageName, KeySet ks)}.
3839 public abstract boolean isSignedByExactly(String packageName, KeySet ks);
3842 * Attempts to move package resources from internal to external media or vice versa.
3843 * Since this may take a little while, the result will
3844 * be posted back to the given observer. This call may fail if the calling context
3845 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
3846 * named package cannot be found, or if the named package is a "system package".
3848 * @param packageName The name of the package to delete
3849 * @param observer An observer callback to get notified when the package move is
3850 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
3851 * called when that happens. observer may be null to indicate that no callback is desired.
3852 * @param flags To indicate install location {@link #MOVE_INTERNAL} or
3853 * {@link #MOVE_EXTERNAL_MEDIA}
3857 public abstract void movePackage(
3858 String packageName, IPackageMoveObserver observer, int flags);
3861 * Returns the device identity that verifiers can use to associate their scheme to a particular
3862 * device. This should not be used by anything other than a package verifier.
3864 * @return identity that uniquely identifies current device
3867 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
3870 * Returns true if the device is upgrading, such as first boot after OTA.
3874 public abstract boolean isUpgrade();
3877 * Return interface that offers the ability to install, upgrade, and remove
3878 * applications on the device.
3880 public abstract @NonNull PackageInstaller getPackageInstaller();
3883 * Returns the data directory for a particular user and package, given the uid of the package.
3884 * @param uid uid of the package, including the userId and appId
3885 * @param packageName name of the package
3886 * @return the user-specific data directory for the package
3889 public static String getDataDirForUser(int userId, String packageName) {
3890 // TODO: This should be shared with Installer's knowledge of user directory
3891 return Environment.getDataDirectory().toString() + "/user/" + userId
3892 + "/" + packageName;
3896 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
3897 * user with id sourceUserId can also be be resolved by activities in the user with id
3898 * targetUserId if they match the specified intent filter.
3899 * @param filter The {@link IntentFilter} the intent has to match
3900 * @param sourceUserId The source user id.
3901 * @param targetUserId The target user id.
3902 * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
3905 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
3906 int targetUserId, int flags);
3909 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
3910 * source, and have been set by the app calling this method.
3911 * @param sourceUserId The source user id.
3914 public abstract void clearCrossProfileIntentFilters(int sourceUserId);
3919 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
3922 public abstract boolean isPackageAvailable(String packageName);
3925 public static String installStatusToString(int status, String msg) {
3926 final String str = installStatusToString(status);
3928 return str + ": " + msg;
3935 public static String installStatusToString(int status) {
3937 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
3938 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
3939 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
3940 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
3941 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
3942 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
3943 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
3944 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
3945 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
3946 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
3947 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
3948 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
3949 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
3950 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
3951 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
3952 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
3953 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
3954 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
3955 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
3956 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
3957 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
3958 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
3959 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
3960 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
3961 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
3962 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
3963 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
3964 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
3965 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
3966 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
3967 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
3968 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
3969 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
3970 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
3971 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
3972 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
3973 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
3974 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
3975 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
3976 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
3977 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
3978 default: return Integer.toString(status);
3983 public static int installStatusToPublicStatus(int status) {
3985 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
3986 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3987 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
3988 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
3989 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
3990 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3991 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3992 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3993 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3994 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3995 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3996 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
3997 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3998 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3999 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4000 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
4001 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4002 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4003 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
4004 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
4005 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4006 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
4007 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
4008 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4009 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4010 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4011 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4012 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
4013 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
4014 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4015 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4016 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
4017 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
4018 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
4019 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
4020 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
4021 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4022 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4023 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4024 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4025 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4026 default: return PackageInstaller.STATUS_FAILURE;
4031 public static String deleteStatusToString(int status, String msg) {
4032 final String str = deleteStatusToString(status);
4034 return str + ": " + msg;
4041 public static String deleteStatusToString(int status) {
4043 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
4044 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
4045 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
4046 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
4047 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
4048 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
4049 default: return Integer.toString(status);
4054 public static int deleteStatusToPublicStatus(int status) {
4056 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4057 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4058 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4059 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4060 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4061 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4062 default: return PackageInstaller.STATUS_FAILURE;
4067 public static class LegacyPackageInstallObserver extends PackageInstallObserver {
4068 private final IPackageInstallObserver mLegacy;
4070 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
4075 public void onPackageInstalled(String basePackageName, int returnCode, String msg,
4077 if (mLegacy == null) return;
4079 mLegacy.packageInstalled(basePackageName, returnCode);
4080 } catch (RemoteException ignored) {
4086 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
4087 private final IPackageDeleteObserver mLegacy;
4089 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
4094 public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
4095 if (mLegacy == null) return;
4097 mLegacy.packageDeleted(basePackageName, returnCode);
4098 } catch (RemoteException ignored) {