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.content.ComponentName;
27 import android.content.Context;
28 import android.content.Intent;
29 import android.content.IntentFilter;
30 import android.content.IntentSender;
31 import android.content.pm.PackageInstaller.CommitCallback;
32 import android.content.pm.PackageInstaller.UninstallCallback;
33 import android.content.pm.PackageParser.PackageParserException;
34 import android.content.res.Resources;
35 import android.content.res.XmlResourceParser;
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} and
183 * requested features in {@link PackageInfo#reqFeatures
184 * PackageInfo.reqFeatures}.
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 * Resolution and querying flag: do not resolve intents cross-profile.
208 public static final int NO_CROSS_PROFILE = 0x00020000;
211 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
212 * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current
213 * profile will be skipped.
214 * Only activities in the target user can respond to the intent.
217 public static final int SKIP_CURRENT_PROFILE = 0x00000002;
220 @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED})
221 @Retention(RetentionPolicy.SOURCE)
222 public @interface PermissionResult {}
225 * Permission check result: this is returned by {@link #checkPermission}
226 * if the permission has been granted to the given package.
228 public static final int PERMISSION_GRANTED = 0;
231 * Permission check result: this is returned by {@link #checkPermission}
232 * if the permission has not been granted to the given package.
234 public static final int PERMISSION_DENIED = -1;
237 * Signature check result: this is returned by {@link #checkSignatures}
238 * if all signatures on the two packages match.
240 public static final int SIGNATURE_MATCH = 0;
243 * Signature check result: this is returned by {@link #checkSignatures}
244 * if neither of the two packages is signed.
246 public static final int SIGNATURE_NEITHER_SIGNED = 1;
249 * Signature check result: this is returned by {@link #checkSignatures}
250 * if the first package is not signed but the second is.
252 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
255 * Signature check result: this is returned by {@link #checkSignatures}
256 * if the second package is not signed but the first is.
258 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
261 * Signature check result: this is returned by {@link #checkSignatures}
262 * if not all signatures on both packages match.
264 public static final int SIGNATURE_NO_MATCH = -3;
267 * Signature check result: this is returned by {@link #checkSignatures}
268 * if either of the packages are not valid.
270 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
273 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
274 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
275 * component or application is in its default enabled state (as specified
278 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
281 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
282 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
283 * component or application has been explictily enabled, regardless of
284 * what it has specified in its manifest.
286 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
289 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
290 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
291 * component or application has been explicitly disabled, regardless of
292 * what it has specified in its manifest.
294 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
297 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
298 * user has explicitly disabled the application, regardless of what it has
299 * specified in its manifest. Because this is due to the user's request,
300 * they may re-enable it if desired through the appropriate system UI. This
301 * option currently <strong>cannot</strong> be used with
302 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
304 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
307 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
308 * application should be considered, until the point where the user actually
309 * wants to use it. This means that it will not normally show up to the user
310 * (such as in the launcher), but various parts of the user interface can
311 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
312 * the user to select it (as for example an IME, device admin, etc). Such code,
313 * once the user has selected the app, should at that point also make it enabled.
314 * This option currently <strong>can not</strong> be used with
315 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
317 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
320 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
321 * indicate that this package should be installed as forward locked, i.e. only the app itself
322 * should have access to its code and non-resource assets.
325 public static final int INSTALL_FORWARD_LOCK = 0x00000001;
328 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
329 * installed package, if one exists.
332 public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
335 * Flag parameter for {@link #installPackage} to indicate that you want to
336 * allow test packages (those that have set android:testOnly in their
337 * manifest) to be installed.
340 public static final int INSTALL_ALLOW_TEST = 0x00000004;
343 * Flag parameter for {@link #installPackage} to indicate that this
344 * package has to be installed on the sdcard.
347 public static final int INSTALL_EXTERNAL = 0x00000008;
350 * Flag parameter for {@link #installPackage} to indicate that this package
351 * has to be installed on the sdcard.
354 public static final int INSTALL_INTERNAL = 0x00000010;
357 * Flag parameter for {@link #installPackage} to indicate that this install
358 * was initiated via ADB.
362 public static final int INSTALL_FROM_ADB = 0x00000020;
365 * Flag parameter for {@link #installPackage} to indicate that this install
366 * should immediately be visible to all users.
370 public static final int INSTALL_ALL_USERS = 0x00000040;
373 * Flag parameter for {@link #installPackage} to indicate that it is okay
374 * to install an update to an app where the newly installed app has a lower
375 * version code than the currently installed app.
379 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
383 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
384 * that you don't want to kill the app containing the component. Be careful when you set this
385 * since changing component states can make the containing application's behavior unpredictable.
387 public static final int DONT_KILL_APP = 0x00000001;
390 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
391 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
395 public static final int INSTALL_SUCCEEDED = 1;
398 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
399 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
404 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
407 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
408 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
413 public static final int INSTALL_FAILED_INVALID_APK = -2;
416 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
417 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
422 public static final int INSTALL_FAILED_INVALID_URI = -3;
425 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
426 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
427 * service found that the device didn't have enough storage space to install the app.
431 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
434 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
435 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
436 * package is already installed with the same name.
440 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
443 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
444 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
445 * the requested shared user does not exist.
449 public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
452 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
453 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
454 * a previously installed package of the same name has a different signature
455 * than the new package (and the old package's data was not removed).
459 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
462 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
463 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
464 * the new package is requested a shared user which is already installed on the
465 * device and does not have matching signature.
469 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
472 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
473 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
474 * the new package uses a shared library that is not available.
478 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
481 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
482 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
483 * the new package uses a shared library that is not available.
487 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
490 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
491 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
492 * the new package failed while optimizing and validating its dex files,
493 * either because there was not enough storage or the validation failed.
497 public static final int INSTALL_FAILED_DEXOPT = -11;
500 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
501 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
502 * the new package failed because the current SDK version is older than
503 * that required by the package.
507 public static final int INSTALL_FAILED_OLDER_SDK = -12;
510 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
511 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
512 * the new package failed because it contains a content provider with the
513 * same authority as a provider already installed in the system.
517 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
520 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
521 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
522 * the new package failed because the current SDK version is newer than
523 * that required by the package.
527 public static final int INSTALL_FAILED_NEWER_SDK = -14;
530 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
531 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
532 * the new package failed because it has specified that it is a test-only
533 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
538 public static final int INSTALL_FAILED_TEST_ONLY = -15;
541 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
542 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
543 * the package being installed contains native code, but none that is
544 * compatible with the device's CPU_ABI.
548 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
551 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
552 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
553 * the new package uses a feature that is not available.
557 public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
559 // ------ Errors related to sdcard
561 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
562 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
563 * a secure container mount point couldn't be accessed on external media.
567 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
570 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
571 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
572 * the new package couldn't be installed in the specified install
577 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
580 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
581 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
582 * the new package couldn't be installed in the specified install
583 * location because the media is not available.
587 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
590 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
591 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
592 * the new package couldn't be installed because the verification timed out.
596 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
599 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
600 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
601 * the new package couldn't be installed because the verification did not succeed.
605 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
608 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
609 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
610 * the package changed from what the calling program expected.
614 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
617 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
618 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
619 * the new package is assigned a different UID than it previously held.
622 public static final int INSTALL_FAILED_UID_CHANGED = -24;
625 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
626 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
627 * the new package has an older version code than the currently installed package.
630 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
633 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
634 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
635 * if the parser was given a path that is not a file, or does not end with the expected
640 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
643 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
644 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
645 * if the parser was unable to retrieve the AndroidManifest.xml file.
649 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
652 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
653 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
654 * if the parser encountered an unexpected exception.
658 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
661 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
662 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
663 * if the parser did not find any certificates in the .apk.
667 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
670 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
671 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
672 * if the parser found inconsistent certificates on the files in the .apk.
676 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
679 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
680 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
681 * if the parser encountered a CertificateEncodingException in one of the
686 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
689 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
690 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
691 * if the parser encountered a bad or missing package name in the manifest.
695 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
698 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
699 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
700 * if the parser encountered a bad shared user id name in the manifest.
704 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
707 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
708 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
709 * if the parser encountered some structural problem in the manifest.
713 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
716 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
717 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
718 * if the parser did not find any actionable tags (instrumentation or application)
723 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
726 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
727 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
728 * if the system failed to install the package because of system issues.
732 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
735 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
736 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
737 * if the system failed to install the package because the user is restricted from installing
741 public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
744 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
745 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
746 * if the system failed to install the package because it is attempting to define a
747 * permission that is already defined by some existing package.
749 * <p>The package name of the app which has already defined the permission is passed to
750 * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE}
751 * string extra; and the name of the permission being redefined is passed in the
752 * {@link #EXTRA_EXISTING_PERMISSION} string extra.
755 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
758 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
759 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
760 * if the system failed to install the package because its packaged native code did not
761 * match any of the ABIs supported by the system.
765 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
768 * Internal return code for NativeLibraryHelper methods to indicate that the package
769 * being processed did not contain any native code. This is placed here only so that
770 * it can belong to the same value space as the other install failure codes.
774 public static final int NO_NATIVE_LIBRARIES = -114;
777 public static final int INSTALL_FAILED_ABORTED = -115;
780 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
781 * package's data directory.
785 public static final int DELETE_KEEP_DATA = 0x00000001;
788 * Flag parameter for {@link #deletePackage} to indicate that you want the
789 * package deleted for all users.
793 public static final int DELETE_ALL_USERS = 0x00000002;
796 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
797 * uninstall on a system that has been updated, then don't do the normal process
798 * of uninstalling the update and rolling back to the older system version (which
799 * needs to happen for all users); instead, just mark the app as uninstalled for
804 public static final int DELETE_SYSTEM_APP = 0x00000004;
807 * Return code for when package deletion succeeds. This is passed to the
808 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
809 * succeeded in deleting the package.
813 public static final int DELETE_SUCCEEDED = 1;
816 * Deletion failed return code: this is passed to the
817 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
818 * failed to delete the package for an unspecified reason.
822 public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
825 * Deletion failed return code: this is passed to the
826 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
827 * failed to delete the package because it is the active DevicePolicy
832 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
835 * Deletion failed return code: this is passed to the
836 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
837 * failed to delete the package since the user is restricted.
841 public static final int DELETE_FAILED_USER_RESTRICTED = -3;
844 * Deletion failed return code: this is passed to the
845 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
846 * failed to delete the package because a profile
847 * or device owner has marked the package as uninstallable.
851 public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
854 public static final int DELETE_FAILED_ABORTED = -5;
857 * Return code that is passed to the {@link IPackageMoveObserver} by
858 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
859 * package has been successfully moved by the system.
863 public static final int MOVE_SUCCEEDED = 1;
865 * Error code that is passed to the {@link IPackageMoveObserver} by
866 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
867 * when the package hasn't been successfully moved by the system
868 * because of insufficient memory on specified media.
871 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
874 * Error code that is passed to the {@link IPackageMoveObserver} by
875 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
876 * if the specified package doesn't exist.
879 public static final int MOVE_FAILED_DOESNT_EXIST = -2;
882 * Error code that is passed to the {@link IPackageMoveObserver} by
883 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
884 * if the specified package cannot be moved since its a system package.
887 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
890 * Error code that is passed to the {@link IPackageMoveObserver} by
891 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
892 * if the specified package cannot be moved since its forward locked.
895 public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
898 * Error code that is passed to the {@link IPackageMoveObserver} by
899 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
900 * if the specified package cannot be moved to the specified location.
903 public static final int MOVE_FAILED_INVALID_LOCATION = -5;
906 * Error code that is passed to the {@link IPackageMoveObserver} by
907 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
908 * if the specified package cannot be moved to the specified location.
911 public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
914 * Error code that is passed to the {@link IPackageMoveObserver} by
915 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
916 * specified package already has an operation pending in the
917 * {@link PackageHandler} queue.
921 public static final int MOVE_FAILED_OPERATION_PENDING = -7;
924 * Flag parameter for {@link #movePackage} to indicate that
925 * the package should be moved to internal storage if its
926 * been installed on external media.
929 public static final int MOVE_INTERNAL = 0x00000001;
932 * Flag parameter for {@link #movePackage} to indicate that
933 * the package should be moved to external media.
936 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
939 * Usable by the required verifier as the {@code verificationCode} argument
940 * for {@link PackageManager#verifyPendingInstall} to indicate that it will
941 * allow the installation to proceed without any of the optional verifiers
946 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
949 * Used as the {@code verificationCode} argument for
950 * {@link PackageManager#verifyPendingInstall} to indicate that the calling
951 * package verifier allows the installation to proceed.
953 public static final int VERIFICATION_ALLOW = 1;
956 * Used as the {@code verificationCode} argument for
957 * {@link PackageManager#verifyPendingInstall} to indicate the calling
958 * package verifier does not vote to allow the installation to proceed.
960 public static final int VERIFICATION_REJECT = -1;
963 * Can be used as the {@code millisecondsToDelay} argument for
964 * {@link PackageManager#extendVerificationTimeout}. This is the
965 * maximum time {@code PackageManager} waits for the verification
966 * agent to return (in milliseconds).
968 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
971 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
972 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
973 * lag in sound input or output.
975 @SdkConstant(SdkConstantType.FEATURE)
976 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
979 * Feature for {@link #getSystemAvailableFeatures} and
980 * {@link #hasSystemFeature}: The device is capable of communicating with
981 * other devices via Bluetooth.
983 @SdkConstant(SdkConstantType.FEATURE)
984 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
987 * Feature for {@link #getSystemAvailableFeatures} and
988 * {@link #hasSystemFeature}: The device is capable of communicating with
989 * other devices via Bluetooth Low Energy radio.
991 @SdkConstant(SdkConstantType.FEATURE)
992 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
995 * Feature for {@link #getSystemAvailableFeatures} and
996 * {@link #hasSystemFeature}: The device has a camera facing away
999 @SdkConstant(SdkConstantType.FEATURE)
1000 public static final String FEATURE_CAMERA = "android.hardware.camera";
1003 * Feature for {@link #getSystemAvailableFeatures} and
1004 * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1006 @SdkConstant(SdkConstantType.FEATURE)
1007 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
1010 * Feature for {@link #getSystemAvailableFeatures} and
1011 * {@link #hasSystemFeature}: The device has at least one camera pointing in
1012 * some direction, or can support an external camera being connected to it.
1014 @SdkConstant(SdkConstantType.FEATURE)
1015 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1018 * Feature for {@link #getSystemAvailableFeatures} and
1019 * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1020 * The external camera may not always be connected or available to applications to use.
1022 @SdkConstant(SdkConstantType.FEATURE)
1023 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1026 * Feature for {@link #getSystemAvailableFeatures} and
1027 * {@link #hasSystemFeature}: The device's camera supports flash.
1029 @SdkConstant(SdkConstantType.FEATURE)
1030 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
1033 * Feature for {@link #getSystemAvailableFeatures} and
1034 * {@link #hasSystemFeature}: The device has a front facing camera.
1036 @SdkConstant(SdkConstantType.FEATURE)
1037 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1040 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1041 * of the cameras on the device supports the
1042 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1045 @SdkConstant(SdkConstantType.FEATURE)
1046 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1049 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1050 * of the cameras on the device supports the
1051 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1054 @SdkConstant(SdkConstantType.FEATURE)
1055 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1056 "android.hardware.camera.capability.manual_sensor";
1059 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1060 * of the cameras on the device supports the
1061 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1064 @SdkConstant(SdkConstantType.FEATURE)
1065 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1066 "android.hardware.camera.capability.manual_post_processing";
1069 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1070 * of the cameras on the device supports the
1071 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1074 @SdkConstant(SdkConstantType.FEATURE)
1075 public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1076 "android.hardware.camera.capability.raw";
1079 * Feature for {@link #getSystemAvailableFeatures} and
1080 * {@link #hasSystemFeature}: The device is capable of communicating with
1081 * consumer IR devices.
1083 @SdkConstant(SdkConstantType.FEATURE)
1084 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1087 * Feature for {@link #getSystemAvailableFeatures} and
1088 * {@link #hasSystemFeature}: The device supports one or more methods of
1089 * reporting current location.
1091 @SdkConstant(SdkConstantType.FEATURE)
1092 public static final String FEATURE_LOCATION = "android.hardware.location";
1095 * Feature for {@link #getSystemAvailableFeatures} and
1096 * {@link #hasSystemFeature}: The device has a Global Positioning System
1097 * receiver and can report precise location.
1099 @SdkConstant(SdkConstantType.FEATURE)
1100 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1103 * Feature for {@link #getSystemAvailableFeatures} and
1104 * {@link #hasSystemFeature}: The device can report location with coarse
1105 * accuracy using a network-based geolocation system.
1107 @SdkConstant(SdkConstantType.FEATURE)
1108 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1111 * Feature for {@link #getSystemAvailableFeatures} and
1112 * {@link #hasSystemFeature}: The device can record audio via a
1115 @SdkConstant(SdkConstantType.FEATURE)
1116 public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1119 * Feature for {@link #getSystemAvailableFeatures} and
1120 * {@link #hasSystemFeature}: The device can communicate using Near-Field
1121 * Communications (NFC).
1123 @SdkConstant(SdkConstantType.FEATURE)
1124 public static final String FEATURE_NFC = "android.hardware.nfc";
1127 * Feature for {@link #getSystemAvailableFeatures} and
1128 * {@link #hasSystemFeature}: The device supports host-
1129 * based NFC card emulation.
1131 * TODO remove when depending apps have moved to new constant.
1136 @SdkConstant(SdkConstantType.FEATURE)
1137 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1140 * Feature for {@link #getSystemAvailableFeatures} and
1141 * {@link #hasSystemFeature}: The device supports host-
1142 * based NFC card emulation.
1144 @SdkConstant(SdkConstantType.FEATURE)
1145 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1148 * Feature for {@link #getSystemAvailableFeatures} and
1149 * {@link #hasSystemFeature}: The device supports the OpenGL ES
1150 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1151 * Android Extension Pack</a>.
1153 @SdkConstant(SdkConstantType.FEATURE)
1154 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1157 * Feature for {@link #getSystemAvailableFeatures} and
1158 * {@link #hasSystemFeature}: The device includes an accelerometer.
1160 @SdkConstant(SdkConstantType.FEATURE)
1161 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1164 * Feature for {@link #getSystemAvailableFeatures} and
1165 * {@link #hasSystemFeature}: The device includes a barometer (air
1168 @SdkConstant(SdkConstantType.FEATURE)
1169 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1172 * Feature for {@link #getSystemAvailableFeatures} and
1173 * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1175 @SdkConstant(SdkConstantType.FEATURE)
1176 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1179 * Feature for {@link #getSystemAvailableFeatures} and
1180 * {@link #hasSystemFeature}: The device includes a gyroscope.
1182 @SdkConstant(SdkConstantType.FEATURE)
1183 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
1186 * Feature for {@link #getSystemAvailableFeatures} and
1187 * {@link #hasSystemFeature}: The device includes a light sensor.
1189 @SdkConstant(SdkConstantType.FEATURE)
1190 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
1193 * Feature for {@link #getSystemAvailableFeatures} and
1194 * {@link #hasSystemFeature}: The device includes a proximity sensor.
1196 @SdkConstant(SdkConstantType.FEATURE)
1197 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
1200 * Feature for {@link #getSystemAvailableFeatures} and
1201 * {@link #hasSystemFeature}: The device includes a hardware step counter.
1203 @SdkConstant(SdkConstantType.FEATURE)
1204 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
1207 * Feature for {@link #getSystemAvailableFeatures} and
1208 * {@link #hasSystemFeature}: The device includes a hardware step detector.
1210 @SdkConstant(SdkConstantType.FEATURE)
1211 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
1214 * Feature for {@link #getSystemAvailableFeatures} and
1215 * {@link #hasSystemFeature}: The device includes a heart rate monitor.
1217 @SdkConstant(SdkConstantType.FEATURE)
1218 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
1221 * Feature for {@link #getSystemAvailableFeatures} and
1222 * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
1224 @SdkConstant(SdkConstantType.FEATURE)
1225 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
1226 "android.hardware.sensor.relative_humidity";
1229 * Feature for {@link #getSystemAvailableFeatures} and
1230 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
1232 @SdkConstant(SdkConstantType.FEATURE)
1233 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
1234 "android.hardware.sensor.ambient_temperature";
1237 * Feature for {@link #getSystemAvailableFeatures} and
1238 * {@link #hasSystemFeature}: The device has a telephony radio with data
1239 * communication support.
1241 @SdkConstant(SdkConstantType.FEATURE)
1242 public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
1245 * Feature for {@link #getSystemAvailableFeatures} and
1246 * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
1248 @SdkConstant(SdkConstantType.FEATURE)
1249 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
1252 * Feature for {@link #getSystemAvailableFeatures} and
1253 * {@link #hasSystemFeature}: The device has a GSM telephony stack.
1255 @SdkConstant(SdkConstantType.FEATURE)
1256 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
1259 * Feature for {@link #getSystemAvailableFeatures} and
1260 * {@link #hasSystemFeature}: The device supports connecting to USB devices
1263 @SdkConstant(SdkConstantType.FEATURE)
1264 public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
1267 * Feature for {@link #getSystemAvailableFeatures} and
1268 * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
1270 @SdkConstant(SdkConstantType.FEATURE)
1271 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
1274 * Feature for {@link #getSystemAvailableFeatures} and
1275 * {@link #hasSystemFeature}: The SIP API is enabled on the device.
1277 @SdkConstant(SdkConstantType.FEATURE)
1278 public static final String FEATURE_SIP = "android.software.sip";
1281 * Feature for {@link #getSystemAvailableFeatures} and
1282 * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
1284 @SdkConstant(SdkConstantType.FEATURE)
1285 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
1288 * Feature for {@link #getSystemAvailableFeatures} and
1289 * {@link #hasSystemFeature}: The device's display has a touch screen.
1291 @SdkConstant(SdkConstantType.FEATURE)
1292 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1296 * Feature for {@link #getSystemAvailableFeatures} and
1297 * {@link #hasSystemFeature}: The device's touch screen supports
1298 * multitouch sufficient for basic two-finger gesture detection.
1300 @SdkConstant(SdkConstantType.FEATURE)
1301 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1304 * Feature for {@link #getSystemAvailableFeatures} and
1305 * {@link #hasSystemFeature}: The device's touch screen is capable of
1306 * tracking two or more fingers fully independently.
1308 @SdkConstant(SdkConstantType.FEATURE)
1309 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1312 * Feature for {@link #getSystemAvailableFeatures} and
1313 * {@link #hasSystemFeature}: The device's touch screen is capable of
1314 * tracking a full hand of fingers fully independently -- that is, 5 or
1315 * more simultaneous independent pointers.
1317 @SdkConstant(SdkConstantType.FEATURE)
1318 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1321 * Feature for {@link #getSystemAvailableFeatures} and
1322 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1323 * does support touch emulation for basic events. For instance, the
1324 * device might use a mouse or remote control to drive a cursor, and
1325 * emulate basic touch pointer events like down, up, drag, etc. All
1326 * devices that support android.hardware.touchscreen or a sub-feature are
1327 * presumed to also support faketouch.
1329 @SdkConstant(SdkConstantType.FEATURE)
1330 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1333 * Feature for {@link #getSystemAvailableFeatures} and
1334 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1335 * does support touch emulation for basic events that supports distinct
1336 * tracking of two or more fingers. This is an extension of
1337 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
1338 * that unlike a distinct multitouch screen as defined by
1339 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1340 * devices will not actually provide full two-finger gestures since the
1341 * input is being transformed to cursor movement on the screen. That is,
1342 * single finger gestures will move a cursor; two-finger swipes will
1343 * result in single-finger touch events; other two-finger gestures will
1344 * result in the corresponding two-finger touch event.
1346 @SdkConstant(SdkConstantType.FEATURE)
1347 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
1350 * Feature for {@link #getSystemAvailableFeatures} and
1351 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1352 * does support touch emulation for basic events that supports tracking
1353 * a hand of fingers (5 or more fingers) fully independently.
1354 * This is an extension of
1355 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
1356 * that unlike a multitouch screen as defined by
1357 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
1358 * gestures can be detected due to the limitations described for
1359 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1361 @SdkConstant(SdkConstantType.FEATURE)
1362 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1365 * Feature for {@link #getSystemAvailableFeatures} and
1366 * {@link #hasSystemFeature}: The device supports portrait orientation
1367 * screens. For backwards compatibility, you can assume that if neither
1368 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1369 * both portrait and landscape.
1371 @SdkConstant(SdkConstantType.FEATURE)
1372 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1375 * Feature for {@link #getSystemAvailableFeatures} and
1376 * {@link #hasSystemFeature}: The device supports landscape orientation
1377 * screens. For backwards compatibility, you can assume that if neither
1378 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1379 * both portrait and landscape.
1381 @SdkConstant(SdkConstantType.FEATURE)
1382 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1385 * Feature for {@link #getSystemAvailableFeatures} and
1386 * {@link #hasSystemFeature}: The device supports live wallpapers.
1388 @SdkConstant(SdkConstantType.FEATURE)
1389 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1391 * Feature for {@link #getSystemAvailableFeatures} and
1392 * {@link #hasSystemFeature}: The device supports app widgets.
1394 @SdkConstant(SdkConstantType.FEATURE)
1395 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
1399 * Feature for {@link #getSystemAvailableFeatures} and
1400 * {@link #hasSystemFeature}: The device supports
1401 * {@link android.service.voice.VoiceInteractionService} and
1402 * {@link android.app.VoiceInteractor}.
1404 @SdkConstant(SdkConstantType.FEATURE)
1405 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
1409 * Feature for {@link #getSystemAvailableFeatures} and
1410 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
1411 * by third party applications.
1413 @SdkConstant(SdkConstantType.FEATURE)
1414 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
1417 * Feature for {@link #getSystemAvailableFeatures} and
1418 * {@link #hasSystemFeature}: The device supports adding new input methods implemented
1419 * with the {@link android.inputmethodservice.InputMethodService} API.
1421 @SdkConstant(SdkConstantType.FEATURE)
1422 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
1425 * Feature for {@link #getSystemAvailableFeatures} and
1426 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
1428 @SdkConstant(SdkConstantType.FEATURE)
1429 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
1432 * Feature for {@link #getSystemAvailableFeatures} and
1433 * {@link #hasSystemFeature}: The device supports leanback UI. This is
1434 * typically used in a living room television experience, but is a software
1435 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
1436 * feature will use resources associated with the "television" UI mode.
1438 @SdkConstant(SdkConstantType.FEATURE)
1439 public static final String FEATURE_LEANBACK = "android.software.leanback";
1442 * Feature for {@link #getSystemAvailableFeatures} and
1443 * {@link #hasSystemFeature}: The device supports only leanback UI. Only
1444 * applications designed for this experience should be run, though this is
1445 * not enforced by the system.
1448 @SdkConstant(SdkConstantType.FEATURE)
1449 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
1452 * Feature for {@link #getSystemAvailableFeatures} and
1453 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1455 @SdkConstant(SdkConstantType.FEATURE)
1456 public static final String FEATURE_WIFI = "android.hardware.wifi";
1459 * Feature for {@link #getSystemAvailableFeatures} and
1460 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1462 @SdkConstant(SdkConstantType.FEATURE)
1463 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1466 * Feature for {@link #getSystemAvailableFeatures} and
1467 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1468 * on a television. Television here is defined to be a typical living
1469 * room television experience: displayed on a big screen, where the user
1470 * is sitting far away from it, and the dominant form of input will be
1471 * something like a DPAD, not through touch or mouse.
1472 * @deprecated use {@link #FEATURE_LEANBACK} instead.
1475 @SdkConstant(SdkConstantType.FEATURE)
1476 public static final String FEATURE_TELEVISION = "android.hardware.type.television";
1479 * Feature for {@link #getSystemAvailableFeatures} and
1480 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1481 * on a watch. A watch here is defined to be a device worn on the body, perhaps on
1482 * the wrist. The user is very close when interacting with the device.
1484 @SdkConstant(SdkConstantType.FEATURE)
1485 public static final String FEATURE_WATCH = "android.hardware.type.watch";
1488 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1489 * The device supports printing.
1491 @SdkConstant(SdkConstantType.FEATURE)
1492 public static final String FEATURE_PRINTING = "android.software.print";
1495 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1496 * The device can perform backup and restore operations on installed applications.
1498 @SdkConstant(SdkConstantType.FEATURE)
1499 public static final String FEATURE_BACKUP = "android.software.backup";
1502 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1503 * The device supports managed profiles for enterprise users.
1505 @SdkConstant(SdkConstantType.FEATURE)
1506 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_profiles";
1509 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1510 * The device has a full implementation of the android.webkit.* APIs. Devices
1511 * lacking this feature will not have a functioning WebView implementation.
1513 @SdkConstant(SdkConstantType.FEATURE)
1514 public static final String FEATURE_WEBVIEW = "android.software.webview";
1517 * Feature for {@link #getSystemAvailableFeatures} and
1518 * {@link #hasSystemFeature}: This device supports ethernet.
1521 @SdkConstant(SdkConstantType.FEATURE)
1522 public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
1525 * Feature for {@link #getSystemAvailableFeatures} and
1526 * {@link #hasSystemFeature}: This device supports HDMI-CEC.
1529 @SdkConstant(SdkConstantType.FEATURE)
1530 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
1533 * Action to external storage service to clean out removed apps.
1536 public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1537 = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1540 * Extra field name for the URI to a verification file. Passed to a package
1545 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1548 * Extra field name for the ID of a package pending verification. Passed to
1549 * a package verifier and is used to call back to
1550 * {@link PackageManager#verifyPendingInstall(int, int)}
1552 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1555 * Extra field name for the package identifier which is trying to install
1560 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1561 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1564 * Extra field name for the requested install flags for a package pending
1565 * verification. Passed to a package verifier.
1569 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1570 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1573 * Extra field name for the uid of who is requesting to install
1578 public static final String EXTRA_VERIFICATION_INSTALLER_UID
1579 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
1582 * Extra field name for the package name of a package pending verification.
1586 public static final String EXTRA_VERIFICATION_PACKAGE_NAME
1587 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
1589 * Extra field name for the result of a verification, either
1590 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
1591 * Passed to package verifiers after a package is verified.
1593 public static final String EXTRA_VERIFICATION_RESULT
1594 = "android.content.pm.extra.VERIFICATION_RESULT";
1597 * Extra field name for the version code of a package pending verification.
1601 public static final String EXTRA_VERIFICATION_VERSION_CODE
1602 = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
1605 * The action used to request that the user approve a permission request
1606 * from the application.
1610 public static final String ACTION_REQUEST_PERMISSION
1611 = "android.content.pm.action.REQUEST_PERMISSION";
1614 * Extra field name for the list of permissions, which the user must approve.
1618 public static final String EXTRA_REQUEST_PERMISSION_PERMISSION_LIST
1619 = "android.content.pm.extra.PERMISSION_LIST";
1622 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1623 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides
1624 * the existing definition for the permission.
1627 public static final String EXTRA_FAILURE_EXISTING_PACKAGE
1628 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
1631 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1632 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is
1633 * being redundantly defined by the package being installed.
1636 public static final String EXTRA_FAILURE_EXISTING_PERMISSION
1637 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
1640 * Retrieve overall information about an application package that is
1641 * installed on the system.
1643 * Throws {@link NameNotFoundException} if a package with the given name can
1644 * not be found on the system.
1646 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1648 * @param flags Additional option flags. Use any combination of
1649 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1650 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1651 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1652 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1653 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1654 * modify the data returned.
1655 * @return Returns a PackageInfo object containing information about the
1656 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the
1657 * package is not found in the list of installed applications, the
1658 * package information is retrieved from the list of uninstalled
1659 * applications (which includes installed applications as well as
1660 * applications with data directory i.e. applications which had been
1661 * deleted with {@code DONT_DELETE_DATA} flag set).
1662 * @see #GET_ACTIVITIES
1664 * @see #GET_CONFIGURATIONS
1665 * @see #GET_INSTRUMENTATION
1666 * @see #GET_PERMISSIONS
1667 * @see #GET_PROVIDERS
1668 * @see #GET_RECEIVERS
1669 * @see #GET_SERVICES
1670 * @see #GET_SIGNATURES
1671 * @see #GET_UNINSTALLED_PACKAGES
1673 public abstract PackageInfo getPackageInfo(String packageName, int flags)
1674 throws NameNotFoundException;
1677 * Map from the current package names in use on the device to whatever
1678 * the current canonical name of that package is.
1679 * @param names Array of current names to be mapped.
1680 * @return Returns an array of the same size as the original, containing
1681 * the canonical name for each package.
1683 public abstract String[] currentToCanonicalPackageNames(String[] names);
1686 * Map from a packages canonical name to the current name in use on the device.
1687 * @param names Array of new names to be mapped.
1688 * @return Returns an array of the same size as the original, containing
1689 * the current name for each package.
1691 public abstract String[] canonicalToCurrentPackageNames(String[] names);
1694 * Returns a "good" intent to launch a front-door activity in a package.
1695 * This is used, for example, to implement an "open" button when browsing
1696 * through packages. The current implementation looks first for a main
1697 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
1698 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
1699 * <code>null</code> if neither are found.
1701 * @param packageName The name of the package to inspect.
1703 * @return A fully-qualified {@link Intent} that can be used to launch the
1704 * main activity in the package. Returns <code>null</code> if the package
1705 * does not contain such an activity, or if <em>packageName</em> is not
1708 public abstract Intent getLaunchIntentForPackage(String packageName);
1711 * Return a "good" intent to launch a front-door Leanback activity in a
1712 * package, for use for example to implement an "open" button when browsing
1713 * through packages. The current implementation will look for a main
1714 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
1715 * return null if no main leanback activities are found.
1717 * Throws {@link NameNotFoundException} if a package with the given name
1718 * cannot be found on the system.
1720 * @param packageName The name of the package to inspect.
1721 * @return Returns either a fully-qualified Intent that can be used to launch
1722 * the main Leanback activity in the package, or null if the package
1723 * does not contain such an activity.
1725 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
1728 * Return an array of all of the secondary group-ids that have been assigned
1731 * Throws {@link NameNotFoundException} if a package with the given name
1732 * cannot be found on the system.
1734 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1736 * @return Returns an int array of the assigned gids, or null if there are
1739 public abstract int[] getPackageGids(String packageName)
1740 throws NameNotFoundException;
1743 * @hide Return the uid associated with the given package name for the
1746 * <p>Throws {@link NameNotFoundException} if a package with the given
1747 * name can not be found on the system.
1749 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1751 * @param userHandle The user handle identifier to look up the package under.
1753 * @return Returns an integer uid who owns the given package name.
1755 public abstract int getPackageUid(String packageName, int userHandle)
1756 throws NameNotFoundException;
1759 * Retrieve all of the information we know about a particular permission.
1761 * <p>Throws {@link NameNotFoundException} if a permission with the given
1762 * name cannot be found on the system.
1764 * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1765 * of the permission you are interested in.
1766 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1767 * retrieve any meta-data associated with the permission.
1769 * @return Returns a {@link PermissionInfo} containing information about the
1772 public abstract PermissionInfo getPermissionInfo(String name, int flags)
1773 throws NameNotFoundException;
1776 * Query for all of the permissions associated with a particular group.
1778 * <p>Throws {@link NameNotFoundException} if the given group does not
1781 * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1782 * of the permission group you are interested in. Use null to
1783 * find all of the permissions not associated with a group.
1784 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1785 * retrieve any meta-data associated with the permissions.
1787 * @return Returns a list of {@link PermissionInfo} containing information
1788 * about all of the permissions in the given group.
1790 public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1791 int flags) throws NameNotFoundException;
1794 * Retrieve all of the information we know about a particular group of
1797 * <p>Throws {@link NameNotFoundException} if a permission group with the given
1798 * name cannot be found on the system.
1800 * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1801 * of the permission you are interested in.
1802 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1803 * retrieve any meta-data associated with the permission group.
1805 * @return Returns a {@link PermissionGroupInfo} containing information
1806 * about the permission.
1808 public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1809 int flags) throws NameNotFoundException;
1812 * Retrieve all of the known permission groups in the system.
1814 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1815 * retrieve any meta-data associated with the permission group.
1817 * @return Returns a list of {@link PermissionGroupInfo} containing
1818 * information about all of the known permission groups.
1820 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1823 * Retrieve all of the information we know about a particular
1824 * package/application.
1826 * <p>Throws {@link NameNotFoundException} if an application with the given
1827 * package name cannot be found on the system.
1829 * @param packageName The full name (i.e. com.google.apps.contacts) of an
1831 * @param flags Additional option flags. Use any combination of
1832 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1833 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1835 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing
1836 * information about the package.
1837 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not
1838 * found in the list of installed applications,
1839 * the application information is retrieved from the
1840 * list of uninstalled applications(which includes
1841 * installed applications as well as applications
1842 * with data directory ie applications which had been
1843 * deleted with {@code DONT_DELETE_DATA} flag set).
1845 * @see #GET_META_DATA
1846 * @see #GET_SHARED_LIBRARY_FILES
1847 * @see #GET_UNINSTALLED_PACKAGES
1849 public abstract ApplicationInfo getApplicationInfo(String packageName,
1850 int flags) throws NameNotFoundException;
1853 * Retrieve all of the information we know about a particular activity
1856 * <p>Throws {@link NameNotFoundException} if an activity with the given
1857 * class name cannot be found on the system.
1859 * @param component The full component name (i.e.
1860 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1862 * @param flags Additional option flags. Use any combination of
1863 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1864 * to modify the data (in ApplicationInfo) returned.
1866 * @return {@link ActivityInfo} containing information about the activity.
1868 * @see #GET_INTENT_FILTERS
1869 * @see #GET_META_DATA
1870 * @see #GET_SHARED_LIBRARY_FILES
1872 public abstract ActivityInfo getActivityInfo(ComponentName component,
1873 int flags) throws NameNotFoundException;
1876 * Retrieve all of the information we know about a particular receiver
1879 * <p>Throws {@link NameNotFoundException} if a receiver with the given
1880 * class name cannot be found on the system.
1882 * @param component The full component name (i.e.
1883 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1885 * @param flags Additional option flags. Use any combination of
1886 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1887 * to modify the data returned.
1889 * @return {@link ActivityInfo} containing information about the receiver.
1891 * @see #GET_INTENT_FILTERS
1892 * @see #GET_META_DATA
1893 * @see #GET_SHARED_LIBRARY_FILES
1895 public abstract ActivityInfo getReceiverInfo(ComponentName component,
1896 int flags) throws NameNotFoundException;
1899 * Retrieve all of the information we know about a particular service
1902 * <p>Throws {@link NameNotFoundException} if a service with the given
1903 * class name cannot be found on the system.
1905 * @param component The full component name (i.e.
1906 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1908 * @param flags Additional option flags. Use any combination of
1909 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1910 * to modify the data returned.
1912 * @return ServiceInfo containing information about the service.
1914 * @see #GET_META_DATA
1915 * @see #GET_SHARED_LIBRARY_FILES
1917 public abstract ServiceInfo getServiceInfo(ComponentName component,
1918 int flags) throws NameNotFoundException;
1921 * Retrieve all of the information we know about a particular content
1924 * <p>Throws {@link NameNotFoundException} if a provider with the given
1925 * class name cannot be found on the system.
1927 * @param component The full component name (i.e.
1928 * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1929 * ContentProvider class.
1930 * @param flags Additional option flags. Use any combination of
1931 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1932 * to modify the data returned.
1934 * @return ProviderInfo containing information about the service.
1936 * @see #GET_META_DATA
1937 * @see #GET_SHARED_LIBRARY_FILES
1939 public abstract ProviderInfo getProviderInfo(ComponentName component,
1940 int flags) throws NameNotFoundException;
1943 * Return a List of all packages that are installed
1946 * @param flags Additional option flags. Use any combination of
1947 * {@link #GET_ACTIVITIES},
1948 * {@link #GET_GIDS},
1949 * {@link #GET_CONFIGURATIONS},
1950 * {@link #GET_INSTRUMENTATION},
1951 * {@link #GET_PERMISSIONS},
1952 * {@link #GET_PROVIDERS},
1953 * {@link #GET_RECEIVERS},
1954 * {@link #GET_SERVICES},
1955 * {@link #GET_SIGNATURES},
1956 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1958 * @return A List of PackageInfo objects, one for each package that is
1959 * installed on the device. In the unlikely case of there being no
1960 * installed packages, an empty list is returned.
1961 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1962 * applications including those deleted with {@code DONT_DELETE_DATA}
1963 * (partially installed apps with data directory) will be returned.
1965 * @see #GET_ACTIVITIES
1967 * @see #GET_CONFIGURATIONS
1968 * @see #GET_INSTRUMENTATION
1969 * @see #GET_PERMISSIONS
1970 * @see #GET_PROVIDERS
1971 * @see #GET_RECEIVERS
1972 * @see #GET_SERVICES
1973 * @see #GET_SIGNATURES
1974 * @see #GET_UNINSTALLED_PACKAGES
1976 public abstract List<PackageInfo> getInstalledPackages(int flags);
1979 * Return a List of all installed packages that are currently
1980 * holding any of the given permissions.
1982 * @param flags Additional option flags. Use any combination of
1983 * {@link #GET_ACTIVITIES},
1984 * {@link #GET_GIDS},
1985 * {@link #GET_CONFIGURATIONS},
1986 * {@link #GET_INSTRUMENTATION},
1987 * {@link #GET_PERMISSIONS},
1988 * {@link #GET_PROVIDERS},
1989 * {@link #GET_RECEIVERS},
1990 * {@link #GET_SERVICES},
1991 * {@link #GET_SIGNATURES},
1992 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1994 * @return Returns a List of PackageInfo objects, one for each installed
1995 * application that is holding any of the permissions that were provided.
1997 * @see #GET_ACTIVITIES
1999 * @see #GET_CONFIGURATIONS
2000 * @see #GET_INSTRUMENTATION
2001 * @see #GET_PERMISSIONS
2002 * @see #GET_PROVIDERS
2003 * @see #GET_RECEIVERS
2004 * @see #GET_SERVICES
2005 * @see #GET_SIGNATURES
2006 * @see #GET_UNINSTALLED_PACKAGES
2008 public abstract List<PackageInfo> getPackagesHoldingPermissions(
2009 String[] permissions, int flags);
2012 * Return a List of all packages that are installed on the device, for a specific user.
2013 * Requesting a list of installed packages for another user
2014 * will require the permission INTERACT_ACROSS_USERS_FULL.
2015 * @param flags Additional option flags. Use any combination of
2016 * {@link #GET_ACTIVITIES},
2017 * {@link #GET_GIDS},
2018 * {@link #GET_CONFIGURATIONS},
2019 * {@link #GET_INSTRUMENTATION},
2020 * {@link #GET_PERMISSIONS},
2021 * {@link #GET_PROVIDERS},
2022 * {@link #GET_RECEIVERS},
2023 * {@link #GET_SERVICES},
2024 * {@link #GET_SIGNATURES},
2025 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2026 * @param userId The user for whom the installed packages are to be listed
2028 * @return A List of PackageInfo objects, one for each package that is
2029 * installed on the device. In the unlikely case of there being no
2030 * installed packages, an empty list is returned.
2031 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2032 * applications including those deleted with {@code DONT_DELETE_DATA}
2033 * (partially installed apps with data directory) will be returned.
2035 * @see #GET_ACTIVITIES
2037 * @see #GET_CONFIGURATIONS
2038 * @see #GET_INSTRUMENTATION
2039 * @see #GET_PERMISSIONS
2040 * @see #GET_PROVIDERS
2041 * @see #GET_RECEIVERS
2042 * @see #GET_SERVICES
2043 * @see #GET_SIGNATURES
2044 * @see #GET_UNINSTALLED_PACKAGES
2048 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
2051 * Check whether a particular package has been granted a particular
2054 * @param permName The name of the permission you are checking for,
2055 * @param pkgName The name of the package you are checking against.
2057 * @return If the package has the permission, PERMISSION_GRANTED is
2058 * returned. If it does not have the permission, PERMISSION_DENIED
2061 * @see #PERMISSION_GRANTED
2062 * @see #PERMISSION_DENIED
2064 public abstract int checkPermission(String permName, String pkgName);
2067 * Add a new dynamic permission to the system. For this to work, your
2068 * package must have defined a permission tree through the
2069 * {@link android.R.styleable#AndroidManifestPermissionTree
2070 * <permission-tree>} tag in its manifest. A package can only add
2071 * permissions to trees that were defined by either its own package or
2072 * another with the same user id; a permission is in a tree if it
2073 * matches the name of the permission tree + ".": for example,
2074 * "com.foo.bar" is a member of the permission tree "com.foo".
2076 * <p>It is good to make your permission tree name descriptive, because you
2077 * are taking possession of that entire set of permission names. Thus, it
2078 * must be under a domain you control, with a suffix that will not match
2079 * any normal permissions that may be declared in any applications that
2080 * are part of that domain.
2082 * <p>New permissions must be added before
2083 * any .apks are installed that use those permissions. Permissions you
2084 * add through this method are remembered across reboots of the device.
2085 * If the given permission already exists, the info you supply here
2086 * will be used to update it.
2088 * @param info Description of the permission to be added.
2090 * @return Returns true if a new permission was created, false if an
2091 * existing one was updated.
2093 * @throws SecurityException if you are not allowed to add the
2094 * given permission name.
2096 * @see #removePermission(String)
2098 public abstract boolean addPermission(PermissionInfo info);
2101 * Like {@link #addPermission(PermissionInfo)} but asynchronously
2102 * persists the package manager state after returning from the call,
2103 * allowing it to return quicker and batch a series of adds at the
2104 * expense of no guarantee the added permission will be retained if
2105 * the device is rebooted before it is written.
2107 public abstract boolean addPermissionAsync(PermissionInfo info);
2110 * Removes a permission that was previously added with
2111 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply
2112 * -- you are only allowed to remove permissions that you are allowed
2115 * @param name The name of the permission to remove.
2117 * @throws SecurityException if you are not allowed to remove the
2118 * given permission name.
2120 * @see #addPermission(PermissionInfo)
2122 public abstract void removePermission(String name);
2125 * Returns an {@link Intent} suitable for passing to {@code startActivityForResult}
2126 * which prompts the user to grant {@code permissions} to this application.
2129 * @throws NullPointerException if {@code permissions} is {@code null}.
2130 * @throws IllegalArgumentException if {@code permissions} contains {@code null}.
2132 public Intent buildPermissionRequestIntent(String... permissions) {
2133 if (permissions == null) {
2134 throw new NullPointerException("permissions cannot be null");
2136 for (String permission : permissions) {
2137 if (permission == null) {
2138 throw new IllegalArgumentException("permissions cannot contain null");
2142 Intent i = new Intent(ACTION_REQUEST_PERMISSION);
2143 i.putExtra(EXTRA_REQUEST_PERMISSION_PERMISSION_LIST, permissions);
2144 i.setPackage("com.android.packageinstaller");
2149 * Grant a permission to an application which the application does not
2150 * already have. The permission must have been requested by the application,
2151 * but as an optional permission. If the application is not allowed to
2152 * hold the permission, a SecurityException is thrown.
2155 * @param packageName The name of the package that the permission will be
2157 * @param permissionName The name of the permission.
2159 public abstract void grantPermission(String packageName, String permissionName);
2162 * Revoke a permission that was previously granted by {@link #grantPermission}.
2165 * @param packageName The name of the package that the permission will be
2167 * @param permissionName The name of the permission.
2169 public abstract void revokePermission(String packageName, String permissionName);
2172 * Compare the signatures of two packages to determine if the same
2173 * signature appears in both of them. If they do contain the same
2174 * signature, then they are allowed special privileges when working
2175 * with each other: they can share the same user-id, run instrumentation
2176 * against each other, etc.
2178 * @param pkg1 First package name whose signature will be compared.
2179 * @param pkg2 Second package name whose signature will be compared.
2181 * @return Returns an integer indicating whether all signatures on the
2182 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2183 * all signatures match or < 0 if there is not a match ({@link
2184 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2186 * @see #checkSignatures(int, int)
2187 * @see #SIGNATURE_MATCH
2188 * @see #SIGNATURE_NO_MATCH
2189 * @see #SIGNATURE_UNKNOWN_PACKAGE
2191 public abstract int checkSignatures(String pkg1, String pkg2);
2194 * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2195 * the two packages to be checked. This can be useful, for example,
2196 * when doing the check in an IPC, where the UID is the only identity
2197 * available. It is functionally identical to determining the package
2198 * associated with the UIDs and checking their signatures.
2200 * @param uid1 First UID whose signature will be compared.
2201 * @param uid2 Second UID whose signature will be compared.
2203 * @return Returns an integer indicating whether all signatures on the
2204 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2205 * all signatures match or < 0 if there is not a match ({@link
2206 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2208 * @see #checkSignatures(String, String)
2209 * @see #SIGNATURE_MATCH
2210 * @see #SIGNATURE_NO_MATCH
2211 * @see #SIGNATURE_UNKNOWN_PACKAGE
2213 public abstract int checkSignatures(int uid1, int uid2);
2216 * Retrieve the names of all packages that are associated with a particular
2217 * user id. In most cases, this will be a single package name, the package
2218 * that has been assigned that user id. Where there are multiple packages
2219 * sharing the same user id through the "sharedUserId" mechanism, all
2220 * packages with that id will be returned.
2222 * @param uid The user id for which you would like to retrieve the
2223 * associated packages.
2225 * @return Returns an array of one or more packages assigned to the user
2226 * id, or null if there are no known packages with the given id.
2228 public abstract String[] getPackagesForUid(int uid);
2231 * Retrieve the official name associated with a user id. This name is
2232 * guaranteed to never change, though it is possibly for the underlying
2233 * user id to be changed. That is, if you are storing information about
2234 * user ids in persistent storage, you should use the string returned
2235 * by this function instead of the raw user-id.
2237 * @param uid The user id for which you would like to retrieve a name.
2238 * @return Returns a unique name for the given user id, or null if the
2239 * user id is not currently assigned.
2241 public abstract String getNameForUid(int uid);
2244 * Return the user id associated with a shared user name. Multiple
2245 * applications can specify a shared user name in their manifest and thus
2246 * end up using a common uid. This might be used for new applications
2247 * that use an existing shared user name and need to know the uid of the
2250 * @param sharedUserName The shared user name whose uid is to be retrieved.
2251 * @return Returns the uid associated with the shared user, or NameNotFoundException
2252 * if the shared user name is not being used by any installed packages
2255 public abstract int getUidForSharedUser(String sharedUserName)
2256 throws NameNotFoundException;
2259 * Return a List of all application packages that are installed on the
2260 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2261 * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2262 * installed apps with data directory) will be returned.
2264 * @param flags Additional option flags. Use any combination of
2265 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2266 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2268 * @return Returns a List of ApplicationInfo objects, one for each application that
2269 * is installed on the device. In the unlikely case of there being
2270 * no installed applications, an empty list is returned.
2271 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2272 * applications including those deleted with {@code DONT_DELETE_DATA}
2273 * (partially installed apps with data directory) will be returned.
2275 * @see #GET_META_DATA
2276 * @see #GET_SHARED_LIBRARY_FILES
2277 * @see #GET_UNINSTALLED_PACKAGES
2279 public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2282 * Get a list of shared libraries that are available on the
2285 * @return An array of shared library names that are
2286 * available on the system, or null if none are installed.
2289 public abstract String[] getSystemSharedLibraryNames();
2292 * Get a list of features that are available on the
2295 * @return An array of FeatureInfo classes describing the features
2296 * that are available on the system, or null if there are none(!!).
2298 public abstract FeatureInfo[] getSystemAvailableFeatures();
2301 * Check whether the given feature name is one of the available
2302 * features as returned by {@link #getSystemAvailableFeatures()}.
2304 * @return Returns true if the devices supports the feature, else
2307 public abstract boolean hasSystemFeature(String name);
2310 * Determine the best action to perform for a given Intent. This is how
2311 * {@link Intent#resolveActivity} finds an activity if a class has not
2312 * been explicitly specified.
2314 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2315 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2316 * only flag. You need to do so to resolve the activity in the same way
2317 * that {@link android.content.Context#startActivity(Intent)} and
2318 * {@link android.content.Intent#resolveActivity(PackageManager)
2319 * Intent.resolveActivity(PackageManager)} do.</p>
2321 * @param intent An intent containing all of the desired specification
2322 * (action, data, type, category, and/or component).
2323 * @param flags Additional option flags. The most important is
2324 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2325 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2327 * @return Returns a ResolveInfo containing the final activity intent that
2328 * was determined to be the best action. Returns null if no
2329 * matching activity was found. If multiple matching activities are
2330 * found and there is no default set, returns a ResolveInfo
2331 * containing something else, such as the activity resolver.
2333 * @see #MATCH_DEFAULT_ONLY
2334 * @see #GET_INTENT_FILTERS
2335 * @see #GET_RESOLVED_FILTER
2337 public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2340 * Determine the best action to perform for a given Intent for a given user. This
2341 * is how {@link Intent#resolveActivity} finds an activity if a class has not
2342 * been explicitly specified.
2344 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2345 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2346 * only flag. You need to do so to resolve the activity in the same way
2347 * that {@link android.content.Context#startActivity(Intent)} and
2348 * {@link android.content.Intent#resolveActivity(PackageManager)
2349 * Intent.resolveActivity(PackageManager)} do.</p>
2351 * @param intent An intent containing all of the desired specification
2352 * (action, data, type, category, and/or component).
2353 * @param flags Additional option flags. The most important is
2354 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2355 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2356 * @param userId The user id.
2358 * @return Returns a ResolveInfo containing the final activity intent that
2359 * was determined to be the best action. Returns null if no
2360 * matching activity was found. If multiple matching activities are
2361 * found and there is no default set, returns a ResolveInfo
2362 * containing something else, such as the activity resolver.
2364 * @see #MATCH_DEFAULT_ONLY
2365 * @see #GET_INTENT_FILTERS
2366 * @see #GET_RESOLVED_FILTER
2370 public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
2373 * Retrieve all activities that can be performed for the given intent.
2375 * @param intent The desired intent as per resolveActivity().
2376 * @param flags Additional option flags. The most important is
2377 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2378 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2380 * @return A List<ResolveInfo> containing one entry for each matching
2381 * Activity. These are ordered from best to worst match -- that
2382 * is, the first item in the list is what is returned by
2383 * {@link #resolveActivity}. If there are no matching activities, an empty
2386 * @see #MATCH_DEFAULT_ONLY
2387 * @see #GET_INTENT_FILTERS
2388 * @see #GET_RESOLVED_FILTER
2390 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
2394 * Retrieve all activities that can be performed for the given intent, for a specific user.
2396 * @param intent The desired intent as per resolveActivity().
2397 * @param flags Additional option flags. The most important is
2398 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2399 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2401 * @return A List<ResolveInfo> containing one entry for each matching
2402 * Activity. These are ordered from best to worst match -- that
2403 * is, the first item in the list is what is returned by
2404 * {@link #resolveActivity}. If there are no matching activities, an empty
2407 * @see #MATCH_DEFAULT_ONLY
2408 * @see #GET_INTENT_FILTERS
2409 * @see #GET_RESOLVED_FILTER
2410 * @see #NO_CROSS_PROFILE
2413 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
2414 int flags, int userId);
2418 * Retrieve a set of activities that should be presented to the user as
2419 * similar options. This is like {@link #queryIntentActivities}, except it
2420 * also allows you to supply a list of more explicit Intents that you would
2421 * like to resolve to particular options, and takes care of returning the
2422 * final ResolveInfo list in a reasonable order, with no duplicates, based
2425 * @param caller The class name of the activity that is making the
2426 * request. This activity will never appear in the output
2427 * list. Can be null.
2428 * @param specifics An array of Intents that should be resolved to the
2429 * first specific results. Can be null.
2430 * @param intent The desired intent as per resolveActivity().
2431 * @param flags Additional option flags. The most important is
2432 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2433 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2435 * @return A List<ResolveInfo> containing one entry for each matching
2436 * Activity. These are ordered first by all of the intents resolved
2437 * in <var>specifics</var> and then any additional activities that
2438 * can handle <var>intent</var> but did not get included by one of
2439 * the <var>specifics</var> intents. If there are no matching
2440 * activities, an empty list is returned.
2442 * @see #MATCH_DEFAULT_ONLY
2443 * @see #GET_INTENT_FILTERS
2444 * @see #GET_RESOLVED_FILTER
2446 public abstract List<ResolveInfo> queryIntentActivityOptions(
2447 ComponentName caller, Intent[] specifics, Intent intent, int flags);
2450 * Retrieve all receivers that can handle a broadcast of the given intent.
2452 * @param intent The desired intent as per resolveActivity().
2453 * @param flags Additional option flags.
2455 * @return A List<ResolveInfo> containing one entry for each matching
2456 * Receiver. These are ordered from first to last in priority. If
2457 * there are no matching receivers, an empty list is returned.
2459 * @see #MATCH_DEFAULT_ONLY
2460 * @see #GET_INTENT_FILTERS
2461 * @see #GET_RESOLVED_FILTER
2463 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2467 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
2470 * @param intent The desired intent as per resolveActivity().
2471 * @param flags Additional option flags.
2472 * @param userId The userId of the user being queried.
2474 * @return A List<ResolveInfo> containing one entry for each matching
2475 * Receiver. These are ordered from first to last in priority. If
2476 * there are no matching receivers, an empty list is returned.
2478 * @see #MATCH_DEFAULT_ONLY
2479 * @see #GET_INTENT_FILTERS
2480 * @see #GET_RESOLVED_FILTER
2483 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2484 int flags, int userId);
2487 * Determine the best service to handle for a given Intent.
2489 * @param intent An intent containing all of the desired specification
2490 * (action, data, type, category, and/or component).
2491 * @param flags Additional option flags.
2493 * @return Returns a ResolveInfo containing the final service intent that
2494 * was determined to be the best action. Returns null if no
2495 * matching service was found.
2497 * @see #GET_INTENT_FILTERS
2498 * @see #GET_RESOLVED_FILTER
2500 public abstract ResolveInfo resolveService(Intent intent, int flags);
2503 * Retrieve all services that can match the given intent.
2505 * @param intent The desired intent as per resolveService().
2506 * @param flags Additional option flags.
2508 * @return A List<ResolveInfo> containing one entry for each matching
2509 * ServiceInfo. These are ordered from best to worst match -- that
2510 * is, the first item in the list is what is returned by
2511 * resolveService(). If there are no matching services, an empty
2514 * @see #GET_INTENT_FILTERS
2515 * @see #GET_RESOLVED_FILTER
2517 public abstract List<ResolveInfo> queryIntentServices(Intent intent,
2521 * Retrieve all services that can match the given intent for a given user.
2523 * @param intent The desired intent as per resolveService().
2524 * @param flags Additional option flags.
2525 * @param userId The user id.
2527 * @return A List<ResolveInfo> containing one entry for each matching
2528 * ServiceInfo. These are ordered from best to worst match -- that
2529 * is, the first item in the list is what is returned by
2530 * resolveService(). If there are no matching services, an empty
2533 * @see #GET_INTENT_FILTERS
2534 * @see #GET_RESOLVED_FILTER
2538 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
2539 int flags, int userId);
2542 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
2543 Intent intent, int flags, int userId);
2546 * Retrieve all providers that can match the given intent.
2548 * @param intent An intent containing all of the desired specification
2549 * (action, data, type, category, and/or component).
2550 * @param flags Additional option flags.
2551 * @return A List<ResolveInfo> containing one entry for each matching
2552 * ProviderInfo. These are ordered from best to worst match. If
2553 * there are no matching providers, an empty list is returned.
2554 * @see #GET_INTENT_FILTERS
2555 * @see #GET_RESOLVED_FILTER
2557 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
2560 * Find a single content provider by its base path name.
2562 * @param name The name of the provider to find.
2563 * @param flags Additional option flags. Currently should always be 0.
2565 * @return ContentProviderInfo Information about the provider, if found,
2568 public abstract ProviderInfo resolveContentProvider(String name,
2572 * Find a single content provider by its base path name.
2574 * @param name The name of the provider to find.
2575 * @param flags Additional option flags. Currently should always be 0.
2576 * @param userId The user id.
2578 * @return ContentProviderInfo Information about the provider, if found,
2582 public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
2585 * Retrieve content provider information.
2587 * <p><em>Note: unlike most other methods, an empty result set is indicated
2588 * by a null return instead of an empty list.</em>
2590 * @param processName If non-null, limits the returned providers to only
2591 * those that are hosted by the given process. If null,
2592 * all content providers are returned.
2593 * @param uid If <var>processName</var> is non-null, this is the required
2594 * uid owning the requested content providers.
2595 * @param flags Additional option flags. Currently should always be 0.
2597 * @return A List<ContentProviderInfo> containing one entry for each
2598 * content provider either patching <var>processName</var> or, if
2599 * <var>processName</var> is null, all known content providers.
2600 * <em>If there are no matching providers, null is returned.</em>
2602 public abstract List<ProviderInfo> queryContentProviders(
2603 String processName, int uid, int flags);
2606 * Retrieve all of the information we know about a particular
2607 * instrumentation class.
2609 * <p>Throws {@link NameNotFoundException} if instrumentation with the
2610 * given class name cannot be found on the system.
2612 * @param className The full name (i.e.
2613 * com.google.apps.contacts.InstrumentList) of an
2614 * Instrumentation class.
2615 * @param flags Additional option flags. Currently should always be 0.
2617 * @return InstrumentationInfo containing information about the
2620 public abstract InstrumentationInfo getInstrumentationInfo(
2621 ComponentName className, int flags) throws NameNotFoundException;
2624 * Retrieve information about available instrumentation code. May be used
2625 * to retrieve either all instrumentation code, or only the code targeting
2626 * a particular package.
2628 * @param targetPackage If null, all instrumentation is returned; only the
2629 * instrumentation targeting this package name is
2631 * @param flags Additional option flags. Currently should always be 0.
2633 * @return A List<InstrumentationInfo> containing one entry for each
2634 * matching available Instrumentation. Returns an empty list if
2635 * there is no instrumentation available for the given package.
2637 public abstract List<InstrumentationInfo> queryInstrumentation(
2638 String targetPackage, int flags);
2641 * Retrieve an image from a package. This is a low-level API used by
2642 * the various package manager info structures (such as
2643 * {@link ComponentInfo} to implement retrieval of their associated
2646 * @param packageName The name of the package that this icon is coming from.
2648 * @param resid The resource identifier of the desired image. Cannot be 0.
2649 * @param appInfo Overall information about <var>packageName</var>. This
2650 * may be null, in which case the application information will be retrieved
2651 * for you if needed; if you already have this information around, it can
2652 * be much more efficient to supply it here.
2654 * @return Returns a Drawable holding the requested image. Returns null if
2655 * an image could not be found for any reason.
2657 public abstract Drawable getDrawable(String packageName, int resid,
2658 ApplicationInfo appInfo);
2661 * Retrieve the icon associated with an activity. Given the full name of
2662 * an activity, retrieves the information about it and calls
2663 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
2664 * If the activity cannot be found, NameNotFoundException is thrown.
2666 * @param activityName Name of the activity whose icon is to be retrieved.
2668 * @return Returns the image of the icon, or the default activity icon if
2669 * it could not be found. Does not return null.
2670 * @throws NameNotFoundException Thrown if the resources for the given
2671 * activity could not be loaded.
2673 * @see #getActivityIcon(Intent)
2675 public abstract Drawable getActivityIcon(ComponentName activityName)
2676 throws NameNotFoundException;
2679 * Retrieve the icon associated with an Intent. If intent.getClassName() is
2680 * set, this simply returns the result of
2681 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
2682 * component and returns the icon associated with the resolved component.
2683 * If intent.getClassName() cannot be found or the Intent cannot be resolved
2684 * to a component, NameNotFoundException is thrown.
2686 * @param intent The intent for which you would like to retrieve an icon.
2688 * @return Returns the image of the icon, or the default activity icon if
2689 * it could not be found. Does not return null.
2690 * @throws NameNotFoundException Thrown if the resources for application
2691 * matching the given intent could not be loaded.
2693 * @see #getActivityIcon(ComponentName)
2695 public abstract Drawable getActivityIcon(Intent intent)
2696 throws NameNotFoundException;
2699 * Retrieve the banner associated with an activity. Given the full name of
2700 * an activity, retrieves the information about it and calls
2701 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
2702 * banner. If the activity cannot be found, NameNotFoundException is thrown.
2704 * @param activityName Name of the activity whose banner is to be retrieved.
2705 * @return Returns the image of the banner, or null if the activity has no
2707 * @throws NameNotFoundException Thrown if the resources for the given
2708 * activity could not be loaded.
2709 * @see #getActivityBanner(Intent)
2711 public abstract Drawable getActivityBanner(ComponentName activityName)
2712 throws NameNotFoundException;
2715 * Retrieve the banner associated with an Intent. If intent.getClassName()
2716 * is set, this simply returns the result of
2717 * getActivityBanner(intent.getClassName()). Otherwise it resolves the
2718 * intent's component and returns the banner associated with the resolved
2719 * component. If intent.getClassName() cannot be found or the Intent cannot
2720 * be resolved to a component, NameNotFoundException is thrown.
2722 * @param intent The intent for which you would like to retrieve a banner.
2723 * @return Returns the image of the banner, or null if the activity has no
2725 * @throws NameNotFoundException Thrown if the resources for application
2726 * matching the given intent could not be loaded.
2727 * @see #getActivityBanner(ComponentName)
2729 public abstract Drawable getActivityBanner(Intent intent)
2730 throws NameNotFoundException;
2733 * Return the generic icon for an activity that is used when no specific
2736 * @return Drawable Image of the icon.
2738 public abstract Drawable getDefaultActivityIcon();
2741 * Retrieve the icon associated with an application. If it has not defined
2742 * an icon, the default app icon is returned. Does not return null.
2744 * @param info Information about application being queried.
2746 * @return Returns the image of the icon, or the default application icon
2747 * if it could not be found.
2749 * @see #getApplicationIcon(String)
2751 public abstract Drawable getApplicationIcon(ApplicationInfo info);
2754 * Retrieve the icon associated with an application. Given the name of the
2755 * application's package, retrieves the information about it and calls
2756 * getApplicationIcon() to return its icon. If the application cannot be
2757 * found, NameNotFoundException is thrown.
2759 * @param packageName Name of the package whose application icon is to be
2762 * @return Returns the image of the icon, or the default application icon
2763 * if it could not be found. Does not return null.
2764 * @throws NameNotFoundException Thrown if the resources for the given
2765 * application could not be loaded.
2767 * @see #getApplicationIcon(ApplicationInfo)
2769 public abstract Drawable getApplicationIcon(String packageName)
2770 throws NameNotFoundException;
2773 * Retrieve the banner associated with an application.
2775 * @param info Information about application being queried.
2776 * @return Returns the image of the banner or null if the application has no
2778 * @see #getApplicationBanner(String)
2780 public abstract Drawable getApplicationBanner(ApplicationInfo info);
2783 * Retrieve the banner associated with an application. Given the name of the
2784 * application's package, retrieves the information about it and calls
2785 * getApplicationIcon() to return its banner. If the application cannot be
2786 * found, NameNotFoundException is thrown.
2788 * @param packageName Name of the package whose application banner is to be
2790 * @return Returns the image of the banner or null if the application has no
2792 * @throws NameNotFoundException Thrown if the resources for the given
2793 * application could not be loaded.
2794 * @see #getApplicationBanner(ApplicationInfo)
2796 public abstract Drawable getApplicationBanner(String packageName)
2797 throws NameNotFoundException;
2800 * Retrieve the logo associated with an activity. Given the full name of an
2801 * activity, retrieves the information about it and calls
2802 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
2803 * logo. If the activity cannot be found, NameNotFoundException is thrown.
2805 * @param activityName Name of the activity whose logo is to be retrieved.
2806 * @return Returns the image of the logo or null if the activity has no logo
2808 * @throws NameNotFoundException Thrown if the resources for the given
2809 * activity could not be loaded.
2810 * @see #getActivityLogo(Intent)
2812 public abstract Drawable getActivityLogo(ComponentName activityName)
2813 throws NameNotFoundException;
2816 * Retrieve the logo associated with an Intent. If intent.getClassName() is
2817 * set, this simply returns the result of
2818 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's
2819 * component and returns the logo associated with the resolved component.
2820 * If intent.getClassName() cannot be found or the Intent cannot be resolved
2821 * to a component, NameNotFoundException is thrown.
2823 * @param intent The intent for which you would like to retrieve a logo.
2825 * @return Returns the image of the logo, or null if the activity has no
2828 * @throws NameNotFoundException Thrown if the resources for application
2829 * matching the given intent could not be loaded.
2831 * @see #getActivityLogo(ComponentName)
2833 public abstract Drawable getActivityLogo(Intent intent)
2834 throws NameNotFoundException;
2837 * Retrieve the logo associated with an application. If it has not specified
2838 * a logo, this method returns null.
2840 * @param info Information about application being queried.
2842 * @return Returns the image of the logo, or null if no logo is specified
2843 * by the application.
2845 * @see #getApplicationLogo(String)
2847 public abstract Drawable getApplicationLogo(ApplicationInfo info);
2850 * Retrieve the logo associated with an application. Given the name of the
2851 * application's package, retrieves the information about it and calls
2852 * getApplicationLogo() to return its logo. If the application cannot be
2853 * found, NameNotFoundException is thrown.
2855 * @param packageName Name of the package whose application logo is to be
2858 * @return Returns the image of the logo, or null if no application logo
2859 * has been specified.
2861 * @throws NameNotFoundException Thrown if the resources for the given
2862 * application could not be loaded.
2864 * @see #getApplicationLogo(ApplicationInfo)
2866 public abstract Drawable getApplicationLogo(String packageName)
2867 throws NameNotFoundException;
2870 * Retrieve text from a package. This is a low-level API used by
2871 * the various package manager info structures (such as
2872 * {@link ComponentInfo} to implement retrieval of their associated
2873 * labels and other text.
2875 * @param packageName The name of the package that this text is coming from.
2877 * @param resid The resource identifier of the desired text. Cannot be 0.
2878 * @param appInfo Overall information about <var>packageName</var>. This
2879 * may be null, in which case the application information will be retrieved
2880 * for you if needed; if you already have this information around, it can
2881 * be much more efficient to supply it here.
2883 * @return Returns a CharSequence holding the requested text. Returns null
2884 * if the text could not be found for any reason.
2886 public abstract CharSequence getText(String packageName, int resid,
2887 ApplicationInfo appInfo);
2890 * Retrieve an XML file from a package. This is a low-level API used to
2891 * retrieve XML meta data.
2893 * @param packageName The name of the package that this xml is coming from.
2895 * @param resid The resource identifier of the desired xml. Cannot be 0.
2896 * @param appInfo Overall information about <var>packageName</var>. This
2897 * may be null, in which case the application information will be retrieved
2898 * for you if needed; if you already have this information around, it can
2899 * be much more efficient to supply it here.
2901 * @return Returns an XmlPullParser allowing you to parse out the XML
2902 * data. Returns null if the xml resource could not be found for any
2905 public abstract XmlResourceParser getXml(String packageName, int resid,
2906 ApplicationInfo appInfo);
2909 * Return the label to use for this application.
2911 * @return Returns the label associated with this application, or null if
2912 * it could not be found for any reason.
2913 * @param info The application to get the label of.
2915 public abstract CharSequence getApplicationLabel(ApplicationInfo info);
2918 * Retrieve the resources associated with an activity. Given the full
2919 * name of an activity, retrieves the information about it and calls
2920 * getResources() to return its application's resources. If the activity
2921 * cannot be found, NameNotFoundException is thrown.
2923 * @param activityName Name of the activity whose resources are to be
2926 * @return Returns the application's Resources.
2927 * @throws NameNotFoundException Thrown if the resources for the given
2928 * application could not be loaded.
2930 * @see #getResourcesForApplication(ApplicationInfo)
2932 public abstract Resources getResourcesForActivity(ComponentName activityName)
2933 throws NameNotFoundException;
2936 * Retrieve the resources for an application. Throws NameNotFoundException
2937 * if the package is no longer installed.
2939 * @param app Information about the desired application.
2941 * @return Returns the application's Resources.
2942 * @throws NameNotFoundException Thrown if the resources for the given
2943 * application could not be loaded (most likely because it was uninstalled).
2945 public abstract Resources getResourcesForApplication(ApplicationInfo app)
2946 throws NameNotFoundException;
2949 * Retrieve the resources associated with an application. Given the full
2950 * package name of an application, retrieves the information about it and
2951 * calls getResources() to return its application's resources. If the
2952 * appPackageName cannot be found, NameNotFoundException is thrown.
2954 * @param appPackageName Package name of the application whose resources
2955 * are to be retrieved.
2957 * @return Returns the application's Resources.
2958 * @throws NameNotFoundException Thrown if the resources for the given
2959 * application could not be loaded.
2961 * @see #getResourcesForApplication(ApplicationInfo)
2963 public abstract Resources getResourcesForApplication(String appPackageName)
2964 throws NameNotFoundException;
2967 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
2968 throws NameNotFoundException;
2971 * Retrieve overall information about an application package defined
2972 * in a package archive file
2974 * @param archiveFilePath The path to the archive file
2975 * @param flags Additional option flags. Use any combination of
2976 * {@link #GET_ACTIVITIES},
2977 * {@link #GET_GIDS},
2978 * {@link #GET_CONFIGURATIONS},
2979 * {@link #GET_INSTRUMENTATION},
2980 * {@link #GET_PERMISSIONS},
2981 * {@link #GET_PROVIDERS},
2982 * {@link #GET_RECEIVERS},
2983 * {@link #GET_SERVICES},
2984 * {@link #GET_SIGNATURES}, to modify the data returned.
2986 * @return Returns the information about the package. Returns
2987 * null if the package could not be successfully parsed.
2989 * @see #GET_ACTIVITIES
2991 * @see #GET_CONFIGURATIONS
2992 * @see #GET_INSTRUMENTATION
2993 * @see #GET_PERMISSIONS
2994 * @see #GET_PROVIDERS
2995 * @see #GET_RECEIVERS
2996 * @see #GET_SERVICES
2997 * @see #GET_SIGNATURES
3000 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
3001 final PackageParser parser = new PackageParser();
3002 final File apkFile = new File(archiveFilePath);
3004 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3005 if ((flags & GET_SIGNATURES) != 0) {
3006 parser.collectCertificates(pkg, 0);
3007 parser.collectManifestDigest(pkg);
3009 PackageUserState state = new PackageUserState();
3010 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3011 } catch (PackageParserException e) {
3017 * @hide Install a package. Since this may take a little while, the result
3018 * will be posted back to the given observer. An installation will
3019 * fail if the calling context lacks the
3020 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3021 * the package named in the package file's manifest is already
3022 * installed, or if there's no space available on the device.
3023 * @param packageURI The location of the package file to install. This can
3024 * be a 'file:' or a 'content:' URI.
3025 * @param observer An observer callback to get notified when the package
3026 * installation is complete.
3027 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3028 * will be called when that happens. This parameter must not be
3030 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3031 * {@link #INSTALL_REPLACE_EXISTING},
3032 * {@link #INSTALL_ALLOW_TEST}.
3033 * @param installerPackageName Optional package name of the application that
3034 * is performing the installation. This identifies which market
3035 * the package came from.
3036 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3037 * String)} instead. This method will continue to be supported
3038 * but the older observer interface will not get additional
3042 public abstract void installPackage(
3043 Uri packageURI, IPackageInstallObserver observer, int flags,
3044 String installerPackageName);
3048 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3049 * with an extra verification file provided.
3051 * @param packageURI The location of the package file to install. This can
3052 * be a 'file:' or a 'content:' URI.
3053 * @param observer An observer callback to get notified when the package
3054 * installation is complete.
3055 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3056 * will be called when that happens. This parameter must not be
3058 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3059 * {@link #INSTALL_REPLACE_EXISTING},
3060 * {@link #INSTALL_ALLOW_TEST}.
3061 * @param installerPackageName Optional package name of the application that
3062 * is performing the installation. This identifies which market
3063 * the package came from.
3064 * @param verificationURI The location of the supplementary verification
3065 * file. This can be a 'file:' or a 'content:' URI. May be
3067 * @param manifestDigest an object that holds the digest of the package
3068 * which can be used to verify ownership. May be {@code null}.
3069 * @param encryptionParams if the package to be installed is encrypted,
3070 * these parameters describing the encryption and authentication
3071 * used. May be {@code null}.
3073 * @deprecated Use {@link #installPackageWithVerification(Uri,
3074 * PackageInstallObserver, int, String, Uri, ManifestDigest,
3075 * ContainerEncryptionParams)} instead. This method will
3076 * continue to be supported but the older observer interface
3077 * will not get additional failure details.
3080 public abstract void installPackageWithVerification(Uri packageURI,
3081 IPackageInstallObserver observer, int flags, String installerPackageName,
3082 Uri verificationURI, ManifestDigest manifestDigest,
3083 ContainerEncryptionParams encryptionParams);
3087 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3088 * with an extra verification information provided.
3090 * @param packageURI The location of the package file to install. This can
3091 * be a 'file:' or a 'content:' URI.
3092 * @param observer An observer callback to get notified when the package
3093 * installation is complete.
3094 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3095 * will be called when that happens. This parameter must not be
3097 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3098 * {@link #INSTALL_REPLACE_EXISTING},
3099 * {@link #INSTALL_ALLOW_TEST}.
3100 * @param installerPackageName Optional package name of the application that
3101 * is performing the installation. This identifies which market
3102 * the package came from.
3103 * @param verificationParams an object that holds signal information to
3104 * assist verification. May be {@code null}.
3105 * @param encryptionParams if the package to be installed is encrypted,
3106 * these parameters describing the encryption and authentication
3107 * used. May be {@code null}.
3109 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3110 * PackageInstallObserver, int, String, VerificationParams,
3111 * ContainerEncryptionParams)} instead. This method will
3112 * continue to be supported but the older observer interface
3113 * will not get additional failure details.
3116 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3117 IPackageInstallObserver observer, int flags, String installerPackageName,
3118 VerificationParams verificationParams,
3119 ContainerEncryptionParams encryptionParams);
3121 // Package-install variants that take the new, expanded form of observer interface.
3122 // Note that these *also* take the original observer type and will redundantly
3123 // report the same information to that observer if supplied; but it is not required.
3128 * Install a package. Since this may take a little while, the result will
3129 * be posted back to the given observer. An installation will fail if the calling context
3130 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3131 * package named in the package file's manifest is already installed, or if there's no space
3132 * available on the device.
3134 * @param packageURI The location of the package file to install. This can be a 'file:' or a
3136 * @param observer An observer callback to get notified when the package installation is
3137 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3138 * called when that happens. This parameter must not be null.
3139 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3140 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3141 * @param installerPackageName Optional package name of the application that is performing the
3142 * installation. This identifies which market the package came from.
3144 public abstract void installPackage(
3145 Uri packageURI, PackageInstallObserver observer,
3146 int flags, String installerPackageName);
3150 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3151 * with an extra verification file provided.
3153 * @param packageURI The location of the package file to install. This can
3154 * be a 'file:' or a 'content:' URI.
3155 * @param observer An observer callback to get notified when the package installation is
3156 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3157 * called when that happens. This parameter must not be null.
3158 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3159 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3160 * @param installerPackageName Optional package name of the application that
3161 * is performing the installation. This identifies which market
3162 * the package came from.
3163 * @param verificationURI The location of the supplementary verification
3164 * file. This can be a 'file:' or a 'content:' URI. May be
3166 * @param manifestDigest an object that holds the digest of the package
3167 * which can be used to verify ownership. May be {@code null}.
3168 * @param encryptionParams if the package to be installed is encrypted,
3169 * these parameters describing the encryption and authentication
3170 * used. May be {@code null}.
3173 public abstract void installPackageWithVerification(Uri packageURI,
3174 PackageInstallObserver observer, int flags, String installerPackageName,
3175 Uri verificationURI, ManifestDigest manifestDigest,
3176 ContainerEncryptionParams encryptionParams);
3180 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3181 * with an extra verification information provided.
3183 * @param packageURI The location of the package file to install. This can
3184 * be a 'file:' or a 'content:' URI.
3185 * @param observer An observer callback to get notified when the package installation is
3186 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3187 * called when that happens. This parameter must not be null.
3188 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3189 * {@link #INSTALL_REPLACE_EXISTING}, {@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 verificationParams an object that holds signal information to
3194 * assist verification. May be {@code null}.
3195 * @param encryptionParams if the package to be installed is encrypted,
3196 * these parameters describing the encryption and authentication
3197 * used. May be {@code null}.
3201 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3202 PackageInstallObserver observer, int flags, String installerPackageName,
3203 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3206 * If there is already an application with the given package name installed
3207 * on the system for other users, also install it for the calling user.
3211 public abstract int installExistingPackage(String packageName)
3212 throws NameNotFoundException;
3215 * Allows a package listening to the
3216 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3217 * broadcast} to respond to the package manager. The response must include
3218 * the {@code verificationCode} which is one of
3219 * {@link PackageManager#VERIFICATION_ALLOW} or
3220 * {@link PackageManager#VERIFICATION_REJECT}.
3222 * @param id pending package identifier as passed via the
3223 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3224 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3225 * or {@link PackageManager#VERIFICATION_REJECT}.
3226 * @throws SecurityException if the caller does not have the
3227 * PACKAGE_VERIFICATION_AGENT permission.
3229 public abstract void verifyPendingInstall(int id, int verificationCode);
3232 * Allows a package listening to the
3233 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3234 * broadcast} to extend the default timeout for a response and declare what
3235 * action to perform after the timeout occurs. The response must include
3236 * the {@code verificationCodeAtTimeout} which is one of
3237 * {@link PackageManager#VERIFICATION_ALLOW} or
3238 * {@link PackageManager#VERIFICATION_REJECT}.
3240 * This method may only be called once per package id. Additional calls
3241 * will have no effect.
3243 * @param id pending package identifier as passed via the
3244 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3245 * @param verificationCodeAtTimeout either
3246 * {@link PackageManager#VERIFICATION_ALLOW} or
3247 * {@link PackageManager#VERIFICATION_REJECT}. If
3248 * {@code verificationCodeAtTimeout} is neither
3249 * {@link PackageManager#VERIFICATION_ALLOW} or
3250 * {@link PackageManager#VERIFICATION_REJECT}, then
3251 * {@code verificationCodeAtTimeout} will default to
3252 * {@link PackageManager#VERIFICATION_REJECT}.
3253 * @param millisecondsToDelay the amount of time requested for the timeout.
3254 * Must be positive and less than
3255 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3256 * {@code millisecondsToDelay} is out of bounds,
3257 * {@code millisecondsToDelay} will be set to the closest in
3258 * bounds value; namely, 0 or
3259 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3260 * @throws SecurityException if the caller does not have the
3261 * PACKAGE_VERIFICATION_AGENT permission.
3263 public abstract void extendVerificationTimeout(int id,
3264 int verificationCodeAtTimeout, long millisecondsToDelay);
3267 * Change the installer associated with a given package. There are limitations
3268 * on how the installer package can be changed; in particular:
3270 * <li> A SecurityException will be thrown if <var>installerPackageName</var>
3271 * is not signed with the same certificate as the calling application.
3272 * <li> A SecurityException will be thrown if <var>targetPackage</var> already
3273 * has an installer package, and that installer package is not signed with
3274 * the same certificate as the calling application.
3277 * @param targetPackage The installed package whose installer will be changed.
3278 * @param installerPackageName The package name of the new installer. May be
3279 * null to clear the association.
3281 public abstract void setInstallerPackageName(String targetPackage,
3282 String installerPackageName);
3285 * Attempts to delete a package. Since this may take a little while, the result will
3286 * be posted back to the given observer. A deletion will fail if the calling context
3287 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
3288 * named package cannot be found, or if the named package is a "system package".
3289 * (TODO: include pointer to documentation on "system packages")
3291 * @param packageName The name of the package to delete
3292 * @param observer An observer callback to get notified when the package deletion is
3293 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
3294 * called when that happens. observer may be null to indicate that no callback is desired.
3295 * @param flags - possible values: {@link #DELETE_KEEP_DATA},
3296 * {@link #DELETE_ALL_USERS}.
3301 public abstract void deletePackage(
3302 String packageName, IPackageDeleteObserver observer, int flags);
3305 * Retrieve the package name of the application that installed a package. This identifies
3306 * which market the package came from.
3308 * @param packageName The name of the package to query
3310 public abstract String getInstallerPackageName(String packageName);
3313 * Attempts to clear the user data directory of an application.
3314 * Since this may take a little while, the result will
3315 * be posted back to the given observer. A deletion will fail if the
3316 * named package cannot be found, or if the named package is a "system package".
3318 * @param packageName The name of the package
3319 * @param observer An observer callback to get notified when the operation is finished
3320 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3321 * will be called when that happens. observer may be null to indicate that
3322 * no callback is desired.
3326 public abstract void clearApplicationUserData(String packageName,
3327 IPackageDataObserver observer);
3329 * Attempts to delete the cache files associated with an application.
3330 * Since this may take a little while, the result will
3331 * be posted back to the given observer. A deletion will fail if the calling context
3332 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
3333 * named package cannot be found, or if the named package is a "system package".
3335 * @param packageName The name of the package to delete
3336 * @param observer An observer callback to get notified when the cache file deletion
3338 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3339 * will be called when that happens. observer may be null to indicate that
3340 * no callback is desired.
3344 public abstract void deleteApplicationCacheFiles(String packageName,
3345 IPackageDataObserver observer);
3348 * Free storage by deleting LRU sorted list of cache files across
3349 * all applications. If the currently available free storage
3350 * on the device is greater than or equal to the requested
3351 * free storage, no cache files are cleared. If the currently
3352 * available storage on the device is less than the requested
3353 * free storage, some or all of the cache files across
3354 * all applications are deleted (based on last accessed time)
3355 * to increase the free storage space on the device to
3356 * the requested value. There is no guarantee that clearing all
3357 * the cache files from all applications will clear up
3358 * enough storage to achieve the desired value.
3359 * @param freeStorageSize The number of bytes of storage to be
3360 * freed by the system. Say if freeStorageSize is XX,
3361 * and the current free storage is YY,
3362 * if XX is less than YY, just return. if not free XX-YY number
3363 * of bytes if possible.
3364 * @param observer call back used to notify when
3365 * the operation is completed
3370 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
3373 * Free storage by deleting LRU sorted list of cache files across
3374 * all applications. If the currently available free storage
3375 * on the device is greater than or equal to the requested
3376 * free storage, no cache files are cleared. If the currently
3377 * available storage on the device is less than the requested
3378 * free storage, some or all of the cache files across
3379 * all applications are deleted (based on last accessed time)
3380 * to increase the free storage space on the device to
3381 * the requested value. There is no guarantee that clearing all
3382 * the cache files from all applications will clear up
3383 * enough storage to achieve the desired value.
3384 * @param freeStorageSize The number of bytes of storage to be
3385 * freed by the system. Say if freeStorageSize is XX,
3386 * and the current free storage is YY,
3387 * if XX is less than YY, just return. if not free XX-YY number
3388 * of bytes if possible.
3389 * @param pi IntentSender call back used to
3390 * notify when the operation is completed.May be null
3391 * to indicate that no call back is desired.
3395 public abstract void freeStorage(long freeStorageSize, IntentSender pi);
3398 * Retrieve the size information for a package.
3399 * Since this may take a little while, the result will
3400 * be posted back to the given observer. The calling context
3401 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
3403 * @param packageName The name of the package whose size information is to be retrieved
3404 * @param userHandle The user whose size information should be retrieved.
3405 * @param observer An observer callback to get notified when the operation
3407 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
3408 * The observer's callback is invoked with a PackageStats object(containing the
3409 * code, data and cache sizes of the package) and a boolean value representing
3410 * the status of the operation. observer may be null to indicate that
3411 * no callback is desired.
3415 public abstract void getPackageSizeInfo(String packageName, int userHandle,
3416 IPackageStatsObserver observer);
3419 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
3420 * returns the size for the calling user.
3424 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
3425 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
3429 * @deprecated This function no longer does anything; it was an old
3430 * approach to managing preferred activities, which has been superseded
3431 * by (and conflicts with) the modern activity-based preferences.
3434 public abstract void addPackageToPreferred(String packageName);
3437 * @deprecated This function no longer does anything; it was an old
3438 * approach to managing preferred activities, which has been superseded
3439 * by (and conflicts with) the modern activity-based preferences.
3442 public abstract void removePackageFromPreferred(String packageName);
3445 * Retrieve the list of all currently configured preferred packages. The
3446 * first package on the list is the most preferred, the last is the
3449 * @param flags Additional option flags. Use any combination of
3450 * {@link #GET_ACTIVITIES},
3451 * {@link #GET_GIDS},
3452 * {@link #GET_CONFIGURATIONS},
3453 * {@link #GET_INSTRUMENTATION},
3454 * {@link #GET_PERMISSIONS},
3455 * {@link #GET_PROVIDERS},
3456 * {@link #GET_RECEIVERS},
3457 * {@link #GET_SERVICES},
3458 * {@link #GET_SIGNATURES}, to modify the data returned.
3460 * @return Returns a list of PackageInfo objects describing each
3461 * preferred application, in order of preference.
3463 * @see #GET_ACTIVITIES
3465 * @see #GET_CONFIGURATIONS
3466 * @see #GET_INSTRUMENTATION
3467 * @see #GET_PERMISSIONS
3468 * @see #GET_PROVIDERS
3469 * @see #GET_RECEIVERS
3470 * @see #GET_SERVICES
3471 * @see #GET_SIGNATURES
3473 public abstract List<PackageInfo> getPreferredPackages(int flags);
3476 * @deprecated This is a protected API that should not have been available
3477 * to third party applications. It is the platform's responsibility for
3478 * assigning preferred activities and this cannot be directly modified.
3480 * Add a new preferred activity mapping to the system. This will be used
3481 * to automatically select the given activity component when
3482 * {@link Context#startActivity(Intent) Context.startActivity()} finds
3483 * multiple matching activities and also matches the given filter.
3485 * @param filter The set of intents under which this activity will be
3487 * @param match The IntentFilter match category that this preference
3489 * @param set The set of activities that the user was picking from when
3490 * this preference was made.
3491 * @param activity The component name of the activity that is to be
3495 public abstract void addPreferredActivity(IntentFilter filter, int match,
3496 ComponentName[] set, ComponentName activity);
3499 * Same as {@link #addPreferredActivity(IntentFilter, int,
3500 ComponentName[], ComponentName)}, but with a specific userId to apply the preference
3504 public void addPreferredActivity(IntentFilter filter, int match,
3505 ComponentName[] set, ComponentName activity, int userId) {
3506 throw new RuntimeException("Not implemented. Must override in a subclass.");
3510 * @deprecated This is a protected API that should not have been available
3511 * to third party applications. It is the platform's responsibility for
3512 * assigning preferred activities and this cannot be directly modified.
3514 * Replaces an existing preferred activity mapping to the system, and if that were not present
3515 * adds a new preferred activity. This will be used
3516 * to automatically select the given activity component when
3517 * {@link Context#startActivity(Intent) Context.startActivity()} finds
3518 * multiple matching activities and also matches the given filter.
3520 * @param filter The set of intents under which this activity will be
3522 * @param match The IntentFilter match category that this preference
3524 * @param set The set of activities that the user was picking from when
3525 * this preference was made.
3526 * @param activity The component name of the activity that is to be
3531 public abstract void replacePreferredActivity(IntentFilter filter, int match,
3532 ComponentName[] set, ComponentName activity);
3538 public void replacePreferredActivityAsUser(IntentFilter filter, int match,
3539 ComponentName[] set, ComponentName activity, int userId) {
3540 throw new RuntimeException("Not implemented. Must override in a subclass.");
3544 * Remove all preferred activity mappings, previously added with
3545 * {@link #addPreferredActivity}, from the
3546 * system whose activities are implemented in the given package name.
3547 * An application can only clear its own package(s).
3549 * @param packageName The name of the package whose preferred activity
3550 * mappings are to be removed.
3552 public abstract void clearPackagePreferredActivities(String packageName);
3555 * Retrieve all preferred activities, previously added with
3556 * {@link #addPreferredActivity}, that are
3557 * currently registered with the system.
3559 * @param outFilters A list in which to place the filters of all of the
3560 * preferred activities, or null for none.
3561 * @param outActivities A list in which to place the component names of
3562 * all of the preferred activities, or null for none.
3563 * @param packageName An option package in which you would like to limit
3564 * the list. If null, all activities will be returned; if non-null, only
3565 * those activities in the given package are returned.
3567 * @return Returns the total number of registered preferred activities
3568 * (the number of distinct IntentFilter records, not the number of unique
3569 * activity components) that were found.
3571 public abstract int getPreferredActivities(List<IntentFilter> outFilters,
3572 List<ComponentName> outActivities, String packageName);
3575 * Ask for the set of available 'home' activities and the current explicit
3579 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
3582 * Set the enabled setting for a package component (activity, receiver, service, provider).
3583 * This setting will override any enabled state which may have been set by the component in its
3586 * @param componentName The component to enable
3587 * @param newState The new enabled state for the component. The legal values for this state
3589 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
3590 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
3592 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3593 * The last one removes the setting, thereby restoring the component's state to
3594 * whatever was set in it's manifest (or enabled, by default).
3595 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3597 public abstract void setComponentEnabledSetting(ComponentName componentName,
3598 int newState, int flags);
3602 * Return the enabled setting for a package component (activity,
3603 * receiver, service, provider). This returns the last value set by
3604 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
3605 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3606 * the value originally specified in the manifest has not been modified.
3608 * @param componentName The component to retrieve.
3609 * @return Returns the current enabled state for the component. May
3610 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3611 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3612 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
3613 * component's enabled state is based on the original information in
3614 * the manifest as found in {@link ComponentInfo}.
3616 public abstract int getComponentEnabledSetting(ComponentName componentName);
3619 * Set the enabled setting for an application
3620 * This setting will override any enabled state which may have been set by the application in
3621 * its manifest. It also overrides the enabled state set in the manifest for any of the
3622 * application's components. It does not override any enabled state set by
3623 * {@link #setComponentEnabledSetting} for any of the application's components.
3625 * @param packageName The package name of the application to enable
3626 * @param newState The new enabled state for the component. The legal values for this state
3628 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
3629 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
3631 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3632 * The last one removes the setting, thereby restoring the applications's state to
3633 * whatever was set in its manifest (or enabled, by default).
3634 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3636 public abstract void setApplicationEnabledSetting(String packageName,
3637 int newState, int flags);
3640 * Return the enabled setting for an application. This returns
3641 * the last value set by
3642 * {@link #setApplicationEnabledSetting(String, int, int)}; in most
3643 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3644 * the value originally specified in the manifest has not been modified.
3646 * @param packageName The package name of the application to retrieve.
3647 * @return Returns the current enabled state for the application. May
3648 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3649 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3650 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
3651 * application's enabled state is based on the original information in
3652 * the manifest as found in {@link ComponentInfo}.
3653 * @throws IllegalArgumentException if the named package does not exist.
3655 public abstract int getApplicationEnabledSetting(String packageName);
3658 * Puts the package in a hidden state, which is almost like an uninstalled state,
3659 * making the package unavailable, but it doesn't remove the data or the actual
3660 * package file. Application can be unhidden by either resetting the hidden state
3661 * or by installing it, such as with {@link #installExistingPackage(String)}
3664 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
3665 UserHandle userHandle);
3668 * Returns the hidden state of a package.
3669 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
3672 public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
3673 UserHandle userHandle);
3676 * Return whether the device has been booted into safe mode.
3678 public abstract boolean isSafeMode();
3681 * Return the {@link KeySet} associated with the String alias for this
3684 * @param alias The alias for a given {@link KeySet} as defined in the
3685 * application's AndroidManifest.xml.
3688 public abstract KeySet getKeySetByAlias(String packageName, String alias);
3690 /** Return the signing {@link KeySet} for this application.
3693 public abstract KeySet getSigningKeySet(String packageName);
3696 * Return whether the package denoted by packageName has been signed by all
3697 * of the keys specified by the {@link KeySet} ks. This will return true if
3698 * the package has been signed by additional keys (a superset) as well.
3699 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
3702 public abstract boolean isSignedBy(String packageName, KeySet ks);
3705 * Return whether the package denoted by packageName has been signed by all
3706 * of, and only, the keys specified by the {@link KeySet} ks. Compare to
3707 * {@link #isSignedBy(String packageName, KeySet ks)}.
3710 public abstract boolean isSignedByExactly(String packageName, KeySet ks);
3713 * Attempts to move package resources from internal to external media or vice versa.
3714 * Since this may take a little while, the result will
3715 * be posted back to the given observer. This call may fail if the calling context
3716 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
3717 * named package cannot be found, or if the named package is a "system package".
3719 * @param packageName The name of the package to delete
3720 * @param observer An observer callback to get notified when the package move is
3721 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
3722 * called when that happens. observer may be null to indicate that no callback is desired.
3723 * @param flags To indicate install location {@link #MOVE_INTERNAL} or
3724 * {@link #MOVE_EXTERNAL_MEDIA}
3728 public abstract void movePackage(
3729 String packageName, IPackageMoveObserver observer, int flags);
3732 * Returns the device identity that verifiers can use to associate their scheme to a particular
3733 * device. This should not be used by anything other than a package verifier.
3735 * @return identity that uniquely identifies current device
3738 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
3741 * Return interface that offers the ability to install, upgrade, and remove
3742 * applications on the device.
3744 public abstract @NonNull PackageInstaller getPackageInstaller();
3747 * Returns the data directory for a particular user and package, given the uid of the package.
3748 * @param uid uid of the package, including the userId and appId
3749 * @param packageName name of the package
3750 * @return the user-specific data directory for the package
3753 public static String getDataDirForUser(int userId, String packageName) {
3754 // TODO: This should be shared with Installer's knowledge of user directory
3755 return Environment.getDataDirectory().toString() + "/user/" + userId
3756 + "/" + packageName;
3760 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
3761 * user with id sourceUserId can also be be resolved by activities in the user with id
3762 * targetUserId if they match the specified intent filter.
3763 * @param filter The {@link IntentFilter} the intent has to match
3764 * @param sourceUserId The source user id.
3765 * @param targetUserId The target user id.
3766 * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
3769 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
3770 int targetUserId, int flags);
3773 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
3774 * source, and have been set by the app calling this method.
3775 * @param sourceUserId The source user id.
3778 public abstract void clearCrossProfileIntentFilters(int sourceUserId);
3781 * Forwards all intents for {@link packageName} for user {@link sourceUserId} to user
3782 * {@link targetUserId}.
3785 public abstract void addCrossProfileIntentsForPackage(String packageName,
3786 int sourceUserId, int targetUserId);
3789 * Removes all intents for {@link packageName} for user {@link sourceUserId} to user
3790 * {@link targetUserId}.
3793 public abstract void removeCrossProfileIntentsForPackage(String packageName,
3794 int sourceUserId, int targetUserId);
3799 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
3802 public abstract boolean isPackageAvailable(String packageName);
3805 public static String installStatusToString(int status) {
3807 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
3808 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
3809 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
3810 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
3811 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
3812 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
3813 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
3814 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
3815 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
3816 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
3817 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
3818 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
3819 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
3820 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
3821 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
3822 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
3823 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
3824 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
3825 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
3826 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
3827 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
3828 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
3829 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
3830 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
3831 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
3832 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
3833 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
3834 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
3835 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
3836 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
3837 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
3838 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
3839 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
3840 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
3841 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
3842 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
3843 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
3844 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
3845 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
3846 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
3847 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
3848 default: return Integer.toString(status);
3853 public static int installStatusToFailureReason(int status) {
3855 case INSTALL_FAILED_ALREADY_EXISTS: return CommitCallback.FAILURE_CONFLICT;
3856 case INSTALL_FAILED_INVALID_APK: return CommitCallback.FAILURE_INVALID;
3857 case INSTALL_FAILED_INVALID_URI: return CommitCallback.FAILURE_INVALID;
3858 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return CommitCallback.FAILURE_STORAGE;
3859 case INSTALL_FAILED_DUPLICATE_PACKAGE: return CommitCallback.FAILURE_CONFLICT;
3860 case INSTALL_FAILED_NO_SHARED_USER: return CommitCallback.FAILURE_CONFLICT;
3861 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return CommitCallback.FAILURE_CONFLICT;
3862 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return CommitCallback.FAILURE_CONFLICT;
3863 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return CommitCallback.FAILURE_INCOMPATIBLE;
3864 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return CommitCallback.FAILURE_CONFLICT;
3865 case INSTALL_FAILED_DEXOPT: return CommitCallback.FAILURE_INVALID;
3866 case INSTALL_FAILED_OLDER_SDK: return CommitCallback.FAILURE_INCOMPATIBLE;
3867 case INSTALL_FAILED_CONFLICTING_PROVIDER: return CommitCallback.FAILURE_CONFLICT;
3868 case INSTALL_FAILED_NEWER_SDK: return CommitCallback.FAILURE_INCOMPATIBLE;
3869 case INSTALL_FAILED_TEST_ONLY: return CommitCallback.FAILURE_INVALID;
3870 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return CommitCallback.FAILURE_INCOMPATIBLE;
3871 case INSTALL_FAILED_MISSING_FEATURE: return CommitCallback.FAILURE_INCOMPATIBLE;
3872 case INSTALL_FAILED_CONTAINER_ERROR: return CommitCallback.FAILURE_STORAGE;
3873 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return CommitCallback.FAILURE_STORAGE;
3874 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return CommitCallback.FAILURE_STORAGE;
3875 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return CommitCallback.FAILURE_ABORTED;
3876 case INSTALL_FAILED_VERIFICATION_FAILURE: return CommitCallback.FAILURE_ABORTED;
3877 case INSTALL_FAILED_PACKAGE_CHANGED: return CommitCallback.FAILURE_INVALID;
3878 case INSTALL_FAILED_UID_CHANGED: return CommitCallback.FAILURE_INVALID;
3879 case INSTALL_FAILED_VERSION_DOWNGRADE: return CommitCallback.FAILURE_INVALID;
3880 case INSTALL_PARSE_FAILED_NOT_APK: return CommitCallback.FAILURE_INVALID;
3881 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return CommitCallback.FAILURE_INVALID;
3882 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return CommitCallback.FAILURE_INVALID;
3883 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return CommitCallback.FAILURE_INVALID;
3884 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return CommitCallback.FAILURE_INVALID;
3885 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return CommitCallback.FAILURE_INVALID;
3886 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return CommitCallback.FAILURE_INVALID;
3887 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return CommitCallback.FAILURE_INVALID;
3888 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return CommitCallback.FAILURE_INVALID;
3889 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return CommitCallback.FAILURE_INVALID;
3890 case INSTALL_FAILED_INTERNAL_ERROR: return CommitCallback.FAILURE_UNKNOWN;
3891 case INSTALL_FAILED_USER_RESTRICTED: return CommitCallback.FAILURE_INCOMPATIBLE;
3892 case INSTALL_FAILED_DUPLICATE_PERMISSION: return CommitCallback.FAILURE_CONFLICT;
3893 case INSTALL_FAILED_NO_MATCHING_ABIS: return CommitCallback.FAILURE_INCOMPATIBLE;
3894 case INSTALL_FAILED_ABORTED: return CommitCallback.FAILURE_ABORTED;
3895 default: return CommitCallback.FAILURE_UNKNOWN;
3900 public static String deleteStatusToString(int status) {
3902 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
3903 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
3904 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
3905 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
3906 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
3907 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
3908 default: return Integer.toString(status);
3913 public static int deleteStatusToFailureReason(int status) {
3915 case DELETE_FAILED_INTERNAL_ERROR: return UninstallCallback.FAILURE_UNKNOWN;
3916 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return UninstallCallback.FAILURE_BLOCKED;
3917 case DELETE_FAILED_USER_RESTRICTED: return UninstallCallback.FAILURE_BLOCKED;
3918 case DELETE_FAILED_OWNER_BLOCKED: return UninstallCallback.FAILURE_BLOCKED;
3919 case DELETE_FAILED_ABORTED: return UninstallCallback.FAILURE_ABORTED;
3920 default: return UninstallCallback.FAILURE_UNKNOWN;
3925 public static class LegacyPackageInstallObserver extends PackageInstallObserver {
3926 private final IPackageInstallObserver mLegacy;
3928 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
3933 public void onPackageInstalled(String basePackageName, int returnCode, String msg,
3935 if (mLegacy == null) return;
3937 mLegacy.packageInstalled(basePackageName, returnCode);
3938 } catch (RemoteException ignored) {
3944 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
3945 private final IPackageDeleteObserver mLegacy;
3947 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
3952 public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
3953 if (mLegacy == null) return;
3955 mLegacy.packageDeleted(basePackageName, returnCode);
3956 } catch (RemoteException ignored) {