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.SdkConstant;
21 import android.annotation.SdkConstant.SdkConstantType;
22 import android.annotation.SystemApi;
23 import android.app.PackageInstallObserver;
24 import android.content.ComponentName;
25 import android.content.Context;
26 import android.content.Intent;
27 import android.content.IntentFilter;
28 import android.content.IntentSender;
29 import android.content.pm.PackageParser.PackageParserException;
30 import android.content.res.Resources;
31 import android.content.res.XmlResourceParser;
32 import android.graphics.drawable.Drawable;
33 import android.net.Uri;
34 import android.os.Bundle;
35 import android.os.Environment;
36 import android.os.UserHandle;
37 import android.util.AndroidException;
40 import java.lang.annotation.Retention;
41 import java.lang.annotation.RetentionPolicy;
42 import java.util.List;
45 * Class for retrieving various kinds of information related to the application
46 * packages that are currently installed on the device.
48 * You can find this class through {@link Context#getPackageManager}.
50 public abstract class PackageManager {
53 * This exception is thrown when a given package, application, or component
54 * name cannot be found.
56 public static class NameNotFoundException extends AndroidException {
57 public NameNotFoundException() {
60 public NameNotFoundException(String name) {
66 * {@link PackageInfo} flag: return information about
67 * activities in the package in {@link PackageInfo#activities}.
69 public static final int GET_ACTIVITIES = 0x00000001;
72 * {@link PackageInfo} flag: return information about
73 * intent receivers in the package in
74 * {@link PackageInfo#receivers}.
76 public static final int GET_RECEIVERS = 0x00000002;
79 * {@link PackageInfo} flag: return information about
80 * services in the package in {@link PackageInfo#services}.
82 public static final int GET_SERVICES = 0x00000004;
85 * {@link PackageInfo} flag: return information about
86 * content providers in the package in
87 * {@link PackageInfo#providers}.
89 public static final int GET_PROVIDERS = 0x00000008;
92 * {@link PackageInfo} flag: return information about
93 * instrumentation in the package in
94 * {@link PackageInfo#instrumentation}.
96 public static final int GET_INSTRUMENTATION = 0x00000010;
99 * {@link PackageInfo} flag: return information about the
100 * intent filters supported by the activity.
102 public static final int GET_INTENT_FILTERS = 0x00000020;
105 * {@link PackageInfo} flag: return information about the
106 * signatures included in the package.
108 public static final int GET_SIGNATURES = 0x00000040;
111 * {@link ResolveInfo} flag: return the IntentFilter that
112 * was matched for a particular ResolveInfo in
113 * {@link ResolveInfo#filter}.
115 public static final int GET_RESOLVED_FILTER = 0x00000040;
118 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
119 * data {@link android.os.Bundle}s that are associated with a component.
120 * This applies for any API returning a ComponentInfo subclass.
122 public static final int GET_META_DATA = 0x00000080;
125 * {@link PackageInfo} flag: return the
126 * {@link PackageInfo#gids group ids} that are associated with an
128 * This applies for any API returning a PackageInfo class, either
129 * directly or nested inside of another.
131 public static final int GET_GIDS = 0x00000100;
134 * {@link PackageInfo} flag: include disabled components in the returned info.
136 public static final int GET_DISABLED_COMPONENTS = 0x00000200;
139 * {@link ApplicationInfo} flag: return the
140 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
141 * that are associated with an application.
142 * This applies for any API returning an ApplicationInfo class, either
143 * directly or nested inside of another.
145 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400;
148 * {@link ProviderInfo} flag: return the
149 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
150 * that are associated with a content provider.
151 * This applies for any API returning a ProviderInfo class, either
152 * directly or nested inside of another.
154 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800;
156 * {@link PackageInfo} flag: return information about
157 * permissions in the package in
158 * {@link PackageInfo#permissions}.
160 public static final int GET_PERMISSIONS = 0x00001000;
163 * Flag parameter to retrieve some information about all applications (even
164 * uninstalled ones) which have data directories. This state could have
165 * resulted if applications have been deleted with flag
166 * {@code DONT_DELETE_DATA} with a possibility of being replaced or
167 * reinstalled in future.
169 * Note: this flag may cause less information about currently installed
170 * applications to be returned.
172 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
175 * {@link PackageInfo} flag: return information about
176 * hardware preferences in
177 * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and
178 * requested features in {@link PackageInfo#reqFeatures
179 * PackageInfo.reqFeatures}.
181 public static final int GET_CONFIGURATIONS = 0x00004000;
184 * {@link PackageInfo} flag: include disabled components which are in
185 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
186 * in the returned info. Note that if you set this flag, applications
187 * that are in this disabled state will be reported as enabled.
189 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
192 * Resolution and querying flag: if set, only filters that support the
193 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
194 * matching. This is a synonym for including the CATEGORY_DEFAULT in your
197 public static final int MATCH_DEFAULT_ONLY = 0x00010000;
200 * Resolution and querying flag: do not resolve intents cross-profile.
203 public static final int NO_CROSS_PROFILE = 0x00020000;
206 * Flag for {@link addCrossProfileIntentFilter}: if the cross-profile intent has been set by the
210 public static final int SET_BY_PROFILE_OWNER= 0x00000001;
213 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
214 * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current
215 * profile will be skipped.
216 * Only activities in the target user can respond to the intent.
219 public static final int SKIP_CURRENT_PROFILE = 0x00000002;
222 @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED})
223 @Retention(RetentionPolicy.SOURCE)
224 public @interface PermissionResult {}
227 * Permission check result: this is returned by {@link #checkPermission}
228 * if the permission has been granted to the given package.
230 public static final int PERMISSION_GRANTED = 0;
233 * Permission check result: this is returned by {@link #checkPermission}
234 * if the permission has not been granted to the given package.
236 public static final int PERMISSION_DENIED = -1;
239 * Signature check result: this is returned by {@link #checkSignatures}
240 * if all signatures on the two packages match.
242 public static final int SIGNATURE_MATCH = 0;
245 * Signature check result: this is returned by {@link #checkSignatures}
246 * if neither of the two packages is signed.
248 public static final int SIGNATURE_NEITHER_SIGNED = 1;
251 * Signature check result: this is returned by {@link #checkSignatures}
252 * if the first package is not signed but the second is.
254 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
257 * Signature check result: this is returned by {@link #checkSignatures}
258 * if the second package is not signed but the first is.
260 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
263 * Signature check result: this is returned by {@link #checkSignatures}
264 * if not all signatures on both packages match.
266 public static final int SIGNATURE_NO_MATCH = -3;
269 * Signature check result: this is returned by {@link #checkSignatures}
270 * if either of the packages are not valid.
272 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
275 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
276 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
277 * component or application is in its default enabled state (as specified
280 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
283 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
284 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
285 * component or application has been explictily enabled, regardless of
286 * what it has specified in its manifest.
288 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
291 * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
292 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
293 * component or application has been explicitly disabled, regardless of
294 * what it has specified in its manifest.
296 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
299 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
300 * user has explicitly disabled the application, regardless of what it has
301 * specified in its manifest. Because this is due to the user's request,
302 * they may re-enable it if desired through the appropriate system UI. This
303 * option currently <strong>cannot</strong> be used with
304 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
306 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
309 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
310 * application should be considered, until the point where the user actually
311 * wants to use it. This means that it will not normally show up to the user
312 * (such as in the launcher), but various parts of the user interface can
313 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
314 * the user to select it (as for example an IME, device admin, etc). Such code,
315 * once the user has selected the app, should at that point also make it enabled.
316 * This option currently <strong>can not</strong> be used with
317 * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
319 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
322 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
323 * indicate that this package should be installed as forward locked, i.e. only the app itself
324 * should have access to its code and non-resource assets.
327 public static final int INSTALL_FORWARD_LOCK = 0x00000001;
330 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
331 * installed package, if one exists.
334 public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
337 * Flag parameter for {@link #installPackage} to indicate that you want to
338 * allow test packages (those that have set android:testOnly in their
339 * manifest) to be installed.
342 public static final int INSTALL_ALLOW_TEST = 0x00000004;
345 * Flag parameter for {@link #installPackage} to indicate that this
346 * package has to be installed on the sdcard.
349 public static final int INSTALL_EXTERNAL = 0x00000008;
352 * Flag parameter for {@link #installPackage} to indicate that this package
353 * has to be installed on the sdcard.
356 public static final int INSTALL_INTERNAL = 0x00000010;
359 * Flag parameter for {@link #installPackage} to indicate that this install
360 * was initiated via ADB.
364 public static final int INSTALL_FROM_ADB = 0x00000020;
367 * Flag parameter for {@link #installPackage} to indicate that this install
368 * should immediately be visible to all users.
372 public static final int INSTALL_ALL_USERS = 0x00000040;
375 * Flag parameter for {@link #installPackage} to indicate that it is okay
376 * to install an update to an app where the newly installed app has a lower
377 * version code than the currently installed app.
381 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
385 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
386 * that you don't want to kill the app containing the component. Be careful when you set this
387 * since changing component states can make the containing application's behavior unpredictable.
389 public static final int DONT_KILL_APP = 0x00000001;
392 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
393 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
397 public static final int INSTALL_SUCCEEDED = 1;
400 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
401 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
406 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
409 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
410 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
415 public static final int INSTALL_FAILED_INVALID_APK = -2;
418 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
419 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
424 public static final int INSTALL_FAILED_INVALID_URI = -3;
427 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
428 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
429 * service found that the device didn't have enough storage space to install the app.
433 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
436 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
437 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
438 * package is already installed with the same name.
442 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
445 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
446 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
447 * the requested shared user does not exist.
451 public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
454 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
455 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
456 * a previously installed package of the same name has a different signature
457 * than the new package (and the old package's data was not removed).
461 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
464 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
465 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
466 * the new package is requested a shared user which is already installed on the
467 * device and does not have matching signature.
471 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
474 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
475 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
476 * the new package uses a shared library that is not available.
480 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
483 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
484 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
485 * the new package uses a shared library that is not available.
489 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
492 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
493 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
494 * the new package failed while optimizing and validating its dex files,
495 * either because there was not enough storage or the validation failed.
499 public static final int INSTALL_FAILED_DEXOPT = -11;
502 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
503 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
504 * the new package failed because the current SDK version is older than
505 * that required by the package.
509 public static final int INSTALL_FAILED_OLDER_SDK = -12;
512 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
513 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
514 * the new package failed because it contains a content provider with the
515 * same authority as a provider already installed in the system.
519 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
522 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
523 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
524 * the new package failed because the current SDK version is newer than
525 * that required by the package.
529 public static final int INSTALL_FAILED_NEWER_SDK = -14;
532 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
533 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
534 * the new package failed because it has specified that it is a test-only
535 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
540 public static final int INSTALL_FAILED_TEST_ONLY = -15;
543 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
544 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
545 * the package being installed contains native code, but none that is
546 * compatible with the device's CPU_ABI.
550 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
553 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
554 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
555 * the new package uses a feature that is not available.
559 public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
561 // ------ Errors related to sdcard
563 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
564 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
565 * a secure container mount point couldn't be accessed on external media.
569 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
572 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
573 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
574 * the new package couldn't be installed in the specified install
579 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
582 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
583 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
584 * the new package couldn't be installed in the specified install
585 * location because the media is not available.
589 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
592 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
593 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
594 * the new package couldn't be installed because the verification timed out.
598 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
601 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
602 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
603 * the new package couldn't be installed because the verification did not succeed.
607 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
610 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
611 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
612 * the package changed from what the calling program expected.
616 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
619 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
620 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
621 * the new package is assigned a different UID than it previously held.
624 public static final int INSTALL_FAILED_UID_CHANGED = -24;
627 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
628 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
629 * the new package has an older version code than the currently installed package.
632 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
635 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
636 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
637 * if the parser was given a path that is not a file, or does not end with the expected
642 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
645 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
646 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
647 * if the parser was unable to retrieve the AndroidManifest.xml file.
651 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
654 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
655 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
656 * if the parser encountered an unexpected exception.
660 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
663 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
664 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
665 * if the parser did not find any certificates in the .apk.
669 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
672 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
673 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
674 * if the parser found inconsistent certificates on the files in the .apk.
678 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
681 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
682 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
683 * if the parser encountered a CertificateEncodingException in one of the
688 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
691 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
692 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
693 * if the parser encountered a bad or missing package name in the manifest.
697 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
700 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
701 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
702 * if the parser encountered a bad shared user id name in the manifest.
706 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
709 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
710 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
711 * if the parser encountered some structural problem in the manifest.
715 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
718 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
719 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
720 * if the parser did not find any actionable tags (instrumentation or application)
725 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
728 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
729 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
730 * if the system failed to install the package because of system issues.
734 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
737 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
738 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
739 * if the system failed to install the package because the user is restricted from installing
743 public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
746 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
747 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
748 * if the system failed to install the package because it is attempting to define a
749 * permission that is already defined by some existing package.
751 * <p>The package name of the app which has already defined the permission is passed to
752 * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE}
753 * string extra; and the name of the permission being redefined is passed in the
754 * {@link #EXTRA_EXISTING_PERMISSION} string extra.
757 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
760 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
761 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
762 * if the system failed to install the package because its packaged native code did not
763 * match any of the ABIs supported by the system.
767 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
770 * Internal return code for NativeLibraryHelper methods to indicate that the package
771 * being processed did not contain any native code. This is placed here only so that
772 * it can belong to the same value space as the other install failure codes.
776 public static final int NO_NATIVE_LIBRARIES = -114;
779 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
780 * package's data directory.
784 public static final int DELETE_KEEP_DATA = 0x00000001;
787 * Flag parameter for {@link #deletePackage} to indicate that you want the
788 * package deleted for all users.
792 public static final int DELETE_ALL_USERS = 0x00000002;
795 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
796 * uninstall on a system that has been updated, then don't do the normal process
797 * of uninstalling the update and rolling back to the older system version (which
798 * needs to happen for all users); instead, just mark the app as uninstalled for
803 public static final int DELETE_SYSTEM_APP = 0x00000004;
806 * Return code for when package deletion succeeds. This is passed to the
807 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
808 * succeeded in deleting the package.
812 public static final int DELETE_SUCCEEDED = 1;
815 * Deletion failed return code: this is passed to the
816 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
817 * failed to delete the package for an unspecified reason.
821 public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
824 * Deletion failed return code: this is passed to the
825 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
826 * failed to delete the package because it is the active DevicePolicy
831 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
834 * Deletion failed return code: this is passed to the
835 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
836 * failed to delete the package since the user is restricted.
840 public static final int DELETE_FAILED_USER_RESTRICTED = -3;
843 * Deletion failed return code: this is passed to the
844 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
845 * failed to delete the package because a profile
846 * or device owner has marked the package as uninstallable.
850 public static final int DELETE_FAILED_OWNER_BLOCKED= -4;
853 * Return code that is passed to the {@link IPackageMoveObserver} by
854 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
855 * package has been successfully moved by the system.
859 public static final int MOVE_SUCCEEDED = 1;
861 * Error code that is passed to the {@link IPackageMoveObserver} by
862 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
863 * when the package hasn't been successfully moved by the system
864 * because of insufficient memory on specified media.
867 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
870 * Error code that is passed to the {@link IPackageMoveObserver} by
871 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
872 * if the specified package doesn't exist.
875 public static final int MOVE_FAILED_DOESNT_EXIST = -2;
878 * Error code that is passed to the {@link IPackageMoveObserver} by
879 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
880 * if the specified package cannot be moved since its a system package.
883 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
886 * Error code that is passed to the {@link IPackageMoveObserver} by
887 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
888 * if the specified package cannot be moved since its forward locked.
891 public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
894 * Error code that is passed to the {@link IPackageMoveObserver} by
895 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
896 * if the specified package cannot be moved to the specified location.
899 public static final int MOVE_FAILED_INVALID_LOCATION = -5;
902 * Error code that is passed to the {@link IPackageMoveObserver} by
903 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
904 * if the specified package cannot be moved to the specified location.
907 public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
910 * Error code that is passed to the {@link IPackageMoveObserver} by
911 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
912 * specified package already has an operation pending in the
913 * {@link PackageHandler} queue.
917 public static final int MOVE_FAILED_OPERATION_PENDING = -7;
920 * Flag parameter for {@link #movePackage} to indicate that
921 * the package should be moved to internal storage if its
922 * been installed on external media.
925 public static final int MOVE_INTERNAL = 0x00000001;
928 * Flag parameter for {@link #movePackage} to indicate that
929 * the package should be moved to external media.
932 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
935 * Usable by the required verifier as the {@code verificationCode} argument
936 * for {@link PackageManager#verifyPendingInstall} to indicate that it will
937 * allow the installation to proceed without any of the optional verifiers
942 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
945 * Used as the {@code verificationCode} argument for
946 * {@link PackageManager#verifyPendingInstall} to indicate that the calling
947 * package verifier allows the installation to proceed.
949 public static final int VERIFICATION_ALLOW = 1;
952 * Used as the {@code verificationCode} argument for
953 * {@link PackageManager#verifyPendingInstall} to indicate the calling
954 * package verifier does not vote to allow the installation to proceed.
956 public static final int VERIFICATION_REJECT = -1;
959 * Can be used as the {@code millisecondsToDelay} argument for
960 * {@link PackageManager#extendVerificationTimeout}. This is the
961 * maximum time {@code PackageManager} waits for the verification
962 * agent to return (in milliseconds).
964 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
967 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
968 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
969 * lag in sound input or output.
971 @SdkConstant(SdkConstantType.FEATURE)
972 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
975 * Feature for {@link #getSystemAvailableFeatures} and
976 * {@link #hasSystemFeature}: The device is capable of communicating with
977 * other devices via Bluetooth.
979 @SdkConstant(SdkConstantType.FEATURE)
980 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
983 * Feature for {@link #getSystemAvailableFeatures} and
984 * {@link #hasSystemFeature}: The device is capable of communicating with
985 * other devices via Bluetooth Low Energy radio.
987 @SdkConstant(SdkConstantType.FEATURE)
988 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
991 * Feature for {@link #getSystemAvailableFeatures} and
992 * {@link #hasSystemFeature}: The device has a camera facing away
995 @SdkConstant(SdkConstantType.FEATURE)
996 public static final String FEATURE_CAMERA = "android.hardware.camera";
999 * Feature for {@link #getSystemAvailableFeatures} and
1000 * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1002 @SdkConstant(SdkConstantType.FEATURE)
1003 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
1006 * Feature for {@link #getSystemAvailableFeatures} and
1007 * {@link #hasSystemFeature}: The device has at least one camera pointing in
1008 * some direction, or can support an external camera being connected to it.
1010 @SdkConstant(SdkConstantType.FEATURE)
1011 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1014 * Feature for {@link #getSystemAvailableFeatures} and
1015 * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1016 * The external camera may not always be connected or available to applications to use.
1018 @SdkConstant(SdkConstantType.FEATURE)
1019 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1022 * Feature for {@link #getSystemAvailableFeatures} and
1023 * {@link #hasSystemFeature}: The device's camera supports flash.
1025 @SdkConstant(SdkConstantType.FEATURE)
1026 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
1029 * Feature for {@link #getSystemAvailableFeatures} and
1030 * {@link #hasSystemFeature}: The device has a front facing camera.
1032 @SdkConstant(SdkConstantType.FEATURE)
1033 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1036 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1037 * of the cameras on the device supports the
1038 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1041 @SdkConstant(SdkConstantType.FEATURE)
1042 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1045 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1046 * of the cameras on the device supports the
1047 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1050 @SdkConstant(SdkConstantType.FEATURE)
1051 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1052 "android.hardware.camera.capability.manual_sensor";
1055 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1056 * of the cameras on the device supports the
1057 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1060 @SdkConstant(SdkConstantType.FEATURE)
1061 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1062 "android.hardware.camera.capability.manual_post_processing";
1065 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1066 * of the cameras on the device supports the
1067 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1070 @SdkConstant(SdkConstantType.FEATURE)
1071 public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1072 "android.hardware.camera.capability.raw";
1075 * Feature for {@link #getSystemAvailableFeatures} and
1076 * {@link #hasSystemFeature}: The device is capable of communicating with
1077 * consumer IR devices.
1079 @SdkConstant(SdkConstantType.FEATURE)
1080 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1083 * Feature for {@link #getSystemAvailableFeatures} and
1084 * {@link #hasSystemFeature}: The device supports one or more methods of
1085 * reporting current location.
1087 @SdkConstant(SdkConstantType.FEATURE)
1088 public static final String FEATURE_LOCATION = "android.hardware.location";
1091 * Feature for {@link #getSystemAvailableFeatures} and
1092 * {@link #hasSystemFeature}: The device has a Global Positioning System
1093 * receiver and can report precise location.
1095 @SdkConstant(SdkConstantType.FEATURE)
1096 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1099 * Feature for {@link #getSystemAvailableFeatures} and
1100 * {@link #hasSystemFeature}: The device can report location with coarse
1101 * accuracy using a network-based geolocation system.
1103 @SdkConstant(SdkConstantType.FEATURE)
1104 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1107 * Feature for {@link #getSystemAvailableFeatures} and
1108 * {@link #hasSystemFeature}: The device can record audio via a
1111 @SdkConstant(SdkConstantType.FEATURE)
1112 public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1115 * Feature for {@link #getSystemAvailableFeatures} and
1116 * {@link #hasSystemFeature}: The device can communicate using Near-Field
1117 * Communications (NFC).
1119 @SdkConstant(SdkConstantType.FEATURE)
1120 public static final String FEATURE_NFC = "android.hardware.nfc";
1123 * Feature for {@link #getSystemAvailableFeatures} and
1124 * {@link #hasSystemFeature}: The device supports host-
1125 * based NFC card emulation.
1127 * TODO remove when depending apps have moved to new constant.
1132 @SdkConstant(SdkConstantType.FEATURE)
1133 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1136 * Feature for {@link #getSystemAvailableFeatures} and
1137 * {@link #hasSystemFeature}: The device supports host-
1138 * based NFC card emulation.
1140 @SdkConstant(SdkConstantType.FEATURE)
1141 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1144 * Feature for {@link #getSystemAvailableFeatures} and
1145 * {@link #hasSystemFeature}: The device supports the OpenGL ES
1146 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1147 * Android Extension Pack</a>.
1149 @SdkConstant(SdkConstantType.FEATURE)
1150 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1153 * Feature for {@link #getSystemAvailableFeatures} and
1154 * {@link #hasSystemFeature}: The device includes an accelerometer.
1156 @SdkConstant(SdkConstantType.FEATURE)
1157 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1160 * Feature for {@link #getSystemAvailableFeatures} and
1161 * {@link #hasSystemFeature}: The device includes a barometer (air
1164 @SdkConstant(SdkConstantType.FEATURE)
1165 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1168 * Feature for {@link #getSystemAvailableFeatures} and
1169 * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1171 @SdkConstant(SdkConstantType.FEATURE)
1172 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1175 * Feature for {@link #getSystemAvailableFeatures} and
1176 * {@link #hasSystemFeature}: The device includes a gyroscope.
1178 @SdkConstant(SdkConstantType.FEATURE)
1179 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
1182 * Feature for {@link #getSystemAvailableFeatures} and
1183 * {@link #hasSystemFeature}: The device includes a light sensor.
1185 @SdkConstant(SdkConstantType.FEATURE)
1186 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
1189 * Feature for {@link #getSystemAvailableFeatures} and
1190 * {@link #hasSystemFeature}: The device includes a proximity sensor.
1192 @SdkConstant(SdkConstantType.FEATURE)
1193 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
1196 * Feature for {@link #getSystemAvailableFeatures} and
1197 * {@link #hasSystemFeature}: The device includes a hardware step counter.
1199 @SdkConstant(SdkConstantType.FEATURE)
1200 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
1203 * Feature for {@link #getSystemAvailableFeatures} and
1204 * {@link #hasSystemFeature}: The device includes a hardware step detector.
1206 @SdkConstant(SdkConstantType.FEATURE)
1207 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
1210 * Feature for {@link #getSystemAvailableFeatures} and
1211 * {@link #hasSystemFeature}: The device includes a heart rate monitor.
1213 @SdkConstant(SdkConstantType.FEATURE)
1214 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
1217 * Feature for {@link #getSystemAvailableFeatures} and
1218 * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
1220 @SdkConstant(SdkConstantType.FEATURE)
1221 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
1222 "android.hardware.sensor.relative_humidity";
1225 * Feature for {@link #getSystemAvailableFeatures} and
1226 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
1228 @SdkConstant(SdkConstantType.FEATURE)
1229 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
1230 "android.hardware.sensor.ambient_temperature";
1233 * Feature for {@link #getSystemAvailableFeatures} and
1234 * {@link #hasSystemFeature}: The device has a telephony radio with data
1235 * communication support.
1237 @SdkConstant(SdkConstantType.FEATURE)
1238 public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
1241 * Feature for {@link #getSystemAvailableFeatures} and
1242 * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
1244 @SdkConstant(SdkConstantType.FEATURE)
1245 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
1248 * Feature for {@link #getSystemAvailableFeatures} and
1249 * {@link #hasSystemFeature}: The device has a GSM telephony stack.
1251 @SdkConstant(SdkConstantType.FEATURE)
1252 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
1255 * Feature for {@link #getSystemAvailableFeatures} and
1256 * {@link #hasSystemFeature}: The device supports connecting to USB devices
1259 @SdkConstant(SdkConstantType.FEATURE)
1260 public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
1263 * Feature for {@link #getSystemAvailableFeatures} and
1264 * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
1266 @SdkConstant(SdkConstantType.FEATURE)
1267 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
1270 * Feature for {@link #getSystemAvailableFeatures} and
1271 * {@link #hasSystemFeature}: The SIP API is enabled on the device.
1273 @SdkConstant(SdkConstantType.FEATURE)
1274 public static final String FEATURE_SIP = "android.software.sip";
1277 * Feature for {@link #getSystemAvailableFeatures} and
1278 * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
1280 @SdkConstant(SdkConstantType.FEATURE)
1281 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
1284 * Feature for {@link #getSystemAvailableFeatures} and
1285 * {@link #hasSystemFeature}: The device's display has a touch screen.
1287 @SdkConstant(SdkConstantType.FEATURE)
1288 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1292 * Feature for {@link #getSystemAvailableFeatures} and
1293 * {@link #hasSystemFeature}: The device's touch screen supports
1294 * multitouch sufficient for basic two-finger gesture detection.
1296 @SdkConstant(SdkConstantType.FEATURE)
1297 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1300 * Feature for {@link #getSystemAvailableFeatures} and
1301 * {@link #hasSystemFeature}: The device's touch screen is capable of
1302 * tracking two or more fingers fully independently.
1304 @SdkConstant(SdkConstantType.FEATURE)
1305 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1308 * Feature for {@link #getSystemAvailableFeatures} and
1309 * {@link #hasSystemFeature}: The device's touch screen is capable of
1310 * tracking a full hand of fingers fully independently -- that is, 5 or
1311 * more simultaneous independent pointers.
1313 @SdkConstant(SdkConstantType.FEATURE)
1314 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1317 * Feature for {@link #getSystemAvailableFeatures} and
1318 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1319 * does support touch emulation for basic events. For instance, the
1320 * device might use a mouse or remote control to drive a cursor, and
1321 * emulate basic touch pointer events like down, up, drag, etc. All
1322 * devices that support android.hardware.touchscreen or a sub-feature are
1323 * presumed to also support faketouch.
1325 @SdkConstant(SdkConstantType.FEATURE)
1326 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1329 * Feature for {@link #getSystemAvailableFeatures} and
1330 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1331 * does support touch emulation for basic events that supports distinct
1332 * tracking of two or more fingers. This is an extension of
1333 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
1334 * that unlike a distinct multitouch screen as defined by
1335 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1336 * devices will not actually provide full two-finger gestures since the
1337 * input is being transformed to cursor movement on the screen. That is,
1338 * single finger gestures will move a cursor; two-finger swipes will
1339 * result in single-finger touch events; other two-finger gestures will
1340 * result in the corresponding two-finger touch event.
1342 @SdkConstant(SdkConstantType.FEATURE)
1343 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
1346 * Feature for {@link #getSystemAvailableFeatures} and
1347 * {@link #hasSystemFeature}: The device does not have a touch screen, but
1348 * does support touch emulation for basic events that supports tracking
1349 * a hand of fingers (5 or more fingers) fully independently.
1350 * This is an extension of
1351 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note
1352 * that unlike a multitouch screen as defined by
1353 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
1354 * gestures can be detected due to the limitations described for
1355 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1357 @SdkConstant(SdkConstantType.FEATURE)
1358 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1361 * Feature for {@link #getSystemAvailableFeatures} and
1362 * {@link #hasSystemFeature}: The device supports portrait orientation
1363 * screens. For backwards compatibility, you can assume that if neither
1364 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1365 * both portrait and landscape.
1367 @SdkConstant(SdkConstantType.FEATURE)
1368 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1371 * Feature for {@link #getSystemAvailableFeatures} and
1372 * {@link #hasSystemFeature}: The device supports landscape orientation
1373 * screens. For backwards compatibility, you can assume that if neither
1374 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1375 * both portrait and landscape.
1377 @SdkConstant(SdkConstantType.FEATURE)
1378 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1381 * Feature for {@link #getSystemAvailableFeatures} and
1382 * {@link #hasSystemFeature}: The device supports live wallpapers.
1384 @SdkConstant(SdkConstantType.FEATURE)
1385 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1387 * Feature for {@link #getSystemAvailableFeatures} and
1388 * {@link #hasSystemFeature}: The device supports app widgets.
1390 @SdkConstant(SdkConstantType.FEATURE)
1391 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
1395 * Feature for {@link #getSystemAvailableFeatures} and
1396 * {@link #hasSystemFeature}: The device supports
1397 * {@link android.service.voice.VoiceInteractionService} and
1398 * {@link android.app.VoiceInteractor}.
1400 @SdkConstant(SdkConstantType.FEATURE)
1401 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
1405 * Feature for {@link #getSystemAvailableFeatures} and
1406 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
1407 * by third party applications.
1409 @SdkConstant(SdkConstantType.FEATURE)
1410 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
1413 * Feature for {@link #getSystemAvailableFeatures} and
1414 * {@link #hasSystemFeature}: The device supports adding new input methods implemented
1415 * with the {@link android.inputmethodservice.InputMethodService} API.
1417 @SdkConstant(SdkConstantType.FEATURE)
1418 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
1421 * Feature for {@link #getSystemAvailableFeatures} and
1422 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
1424 @SdkConstant(SdkConstantType.FEATURE)
1425 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
1428 * Feature for {@link #getSystemAvailableFeatures} and
1429 * {@link #hasSystemFeature}: The device supports leanback UI. This is
1430 * typically used in a living room television experience, but is a software
1431 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
1432 * feature will use resources associated with the "television" UI mode.
1434 @SdkConstant(SdkConstantType.FEATURE)
1435 public static final String FEATURE_LEANBACK = "android.software.leanback";
1438 * Feature for {@link #getSystemAvailableFeatures} and
1439 * {@link #hasSystemFeature}: The device supports only leanback UI. Only
1440 * applications designed for this experience should be run, though this is
1441 * not enforced by the system.
1444 @SdkConstant(SdkConstantType.FEATURE)
1445 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
1448 * Feature for {@link #getSystemAvailableFeatures} and
1449 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1451 @SdkConstant(SdkConstantType.FEATURE)
1452 public static final String FEATURE_WIFI = "android.hardware.wifi";
1455 * Feature for {@link #getSystemAvailableFeatures} and
1456 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1458 @SdkConstant(SdkConstantType.FEATURE)
1459 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1462 * Feature for {@link #getSystemAvailableFeatures} and
1463 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1464 * on a television. Television here is defined to be a typical living
1465 * room television experience: displayed on a big screen, where the user
1466 * is sitting far away from it, and the dominant form of input will be
1467 * something like a DPAD, not through touch or mouse.
1468 * @deprecated use {@link #FEATURE_LEANBACK} instead.
1471 @SdkConstant(SdkConstantType.FEATURE)
1472 public static final String FEATURE_TELEVISION = "android.hardware.type.television";
1475 * Feature for {@link #getSystemAvailableFeatures} and
1476 * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1477 * on a watch. A watch here is defined to be a device worn on the body, perhaps on
1478 * the wrist. The user is very close when interacting with the device.
1480 @SdkConstant(SdkConstantType.FEATURE)
1481 public static final String FEATURE_WATCH = "android.hardware.type.watch";
1484 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1485 * The device supports printing.
1487 @SdkConstant(SdkConstantType.FEATURE)
1488 public static final String FEATURE_PRINTING = "android.software.print";
1491 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1492 * The device can perform backup and restore operations on installed applications.
1494 @SdkConstant(SdkConstantType.FEATURE)
1495 public static final String FEATURE_BACKUP = "android.software.backup";
1498 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1499 * The device supports managed profiles for enterprise users.
1501 @SdkConstant(SdkConstantType.FEATURE)
1502 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_profiles";
1505 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1506 * The device has a full implementation of the android.webkit.* APIs. Devices
1507 * lacking this feature will not have a functioning WebView implementation.
1509 @SdkConstant(SdkConstantType.FEATURE)
1510 public static final String FEATURE_WEBVIEW = "android.software.webview";
1513 * Feature for {@link #getSystemAvailableFeatures} and
1514 * {@link #hasSystemFeature}: This device supports ethernet.
1517 @SdkConstant(SdkConstantType.FEATURE)
1518 public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
1521 * Feature for {@link #getSystemAvailableFeatures} and
1522 * {@link #hasSystemFeature}: This device supports HDMI-CEC.
1525 @SdkConstant(SdkConstantType.FEATURE)
1526 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
1529 * Action to external storage service to clean out removed apps.
1532 public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1533 = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1536 * Extra field name for the URI to a verification file. Passed to a package
1541 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1544 * Extra field name for the ID of a package pending verification. Passed to
1545 * a package verifier and is used to call back to
1546 * {@link PackageManager#verifyPendingInstall(int, int)}
1548 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1551 * Extra field name for the package identifier which is trying to install
1556 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1557 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1560 * Extra field name for the requested install flags for a package pending
1561 * verification. Passed to a package verifier.
1565 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1566 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1569 * Extra field name for the uid of who is requesting to install
1574 public static final String EXTRA_VERIFICATION_INSTALLER_UID
1575 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
1578 * Extra field name for the package name of a package pending verification.
1582 public static final String EXTRA_VERIFICATION_PACKAGE_NAME
1583 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
1585 * Extra field name for the result of a verification, either
1586 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
1587 * Passed to package verifiers after a package is verified.
1589 public static final String EXTRA_VERIFICATION_RESULT
1590 = "android.content.pm.extra.VERIFICATION_RESULT";
1593 * Extra field name for the version code of a package pending verification.
1597 public static final String EXTRA_VERIFICATION_VERSION_CODE
1598 = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
1601 * The action used to request that the user approve a permission request
1602 * from the application.
1606 public static final String ACTION_REQUEST_PERMISSION
1607 = "android.content.pm.action.REQUEST_PERMISSION";
1610 * Extra field name for the list of permissions, which the user must approve.
1614 public static final String EXTRA_REQUEST_PERMISSION_PERMISSION_LIST
1615 = "android.content.pm.extra.PERMISSION_LIST";
1618 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1619 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides
1620 * the existing definition for the permission.
1623 public static final String EXTRA_FAILURE_EXISTING_PACKAGE
1624 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
1627 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1628 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is
1629 * being redundantly defined by the package being installed.
1632 public static final String EXTRA_FAILURE_EXISTING_PERMISSION
1633 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
1636 * Retrieve overall information about an application package that is
1637 * installed on the system.
1639 * Throws {@link NameNotFoundException} if a package with the given name can
1640 * not be found on the system.
1642 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1644 * @param flags Additional option flags. Use any combination of
1645 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1646 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1647 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1648 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1649 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1650 * modify the data returned.
1651 * @return Returns a PackageInfo object containing information about the
1652 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the
1653 * package is not found in the list of installed applications, the
1654 * package information is retrieved from the list of uninstalled
1655 * applications (which includes installed applications as well as
1656 * applications with data directory i.e. applications which had been
1657 * deleted with {@code DONT_DELETE_DATA} flag set).
1658 * @see #GET_ACTIVITIES
1660 * @see #GET_CONFIGURATIONS
1661 * @see #GET_INSTRUMENTATION
1662 * @see #GET_PERMISSIONS
1663 * @see #GET_PROVIDERS
1664 * @see #GET_RECEIVERS
1665 * @see #GET_SERVICES
1666 * @see #GET_SIGNATURES
1667 * @see #GET_UNINSTALLED_PACKAGES
1669 public abstract PackageInfo getPackageInfo(String packageName, int flags)
1670 throws NameNotFoundException;
1673 * Map from the current package names in use on the device to whatever
1674 * the current canonical name of that package is.
1675 * @param names Array of current names to be mapped.
1676 * @return Returns an array of the same size as the original, containing
1677 * the canonical name for each package.
1679 public abstract String[] currentToCanonicalPackageNames(String[] names);
1682 * Map from a packages canonical name to the current name in use on the device.
1683 * @param names Array of new names to be mapped.
1684 * @return Returns an array of the same size as the original, containing
1685 * the current name for each package.
1687 public abstract String[] canonicalToCurrentPackageNames(String[] names);
1690 * Returns a "good" intent to launch a front-door activity in a package.
1691 * This is used, for example, to implement an "open" button when browsing
1692 * through packages. The current implementation looks first for a main
1693 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
1694 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
1695 * <code>null</code> if neither are found.
1697 * @param packageName The name of the package to inspect.
1699 * @return A fully-qualified {@link Intent} that can be used to launch the
1700 * main activity in the package. Returns <code>null</code> if the package
1701 * does not contain such an activity, or if <em>packageName</em> is not
1704 public abstract Intent getLaunchIntentForPackage(String packageName);
1707 * Return a "good" intent to launch a front-door Leanback activity in a
1708 * package, for use for example to implement an "open" button when browsing
1709 * through packages. The current implementation will look for a main
1710 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
1711 * return null if no main leanback activities are found.
1713 * Throws {@link NameNotFoundException} if a package with the given name
1714 * cannot be found on the system.
1716 * @param packageName The name of the package to inspect.
1717 * @return Returns either a fully-qualified Intent that can be used to launch
1718 * the main Leanback activity in the package, or null if the package
1719 * does not contain such an activity.
1721 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
1724 * Return an array of all of the secondary group-ids that have been assigned
1727 * Throws {@link NameNotFoundException} if a package with the given name
1728 * cannot be found on the system.
1730 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1732 * @return Returns an int array of the assigned gids, or null if there are
1735 public abstract int[] getPackageGids(String packageName)
1736 throws NameNotFoundException;
1739 * @hide Return the uid associated with the given package name for the
1742 * <p>Throws {@link NameNotFoundException} if a package with the given
1743 * name can not be found on the system.
1745 * @param packageName The full name (i.e. com.google.apps.contacts) of the
1747 * @param userHandle The user handle identifier to look up the package under.
1749 * @return Returns an integer uid who owns the given package name.
1751 public abstract int getPackageUid(String packageName, int userHandle)
1752 throws NameNotFoundException;
1755 * Retrieve all of the information we know about a particular permission.
1757 * <p>Throws {@link NameNotFoundException} if a permission with the given
1758 * name cannot be found on the system.
1760 * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1761 * of the permission you are interested in.
1762 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1763 * retrieve any meta-data associated with the permission.
1765 * @return Returns a {@link PermissionInfo} containing information about the
1768 public abstract PermissionInfo getPermissionInfo(String name, int flags)
1769 throws NameNotFoundException;
1772 * Query for all of the permissions associated with a particular group.
1774 * <p>Throws {@link NameNotFoundException} if the given group does not
1777 * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1778 * of the permission group you are interested in. Use null to
1779 * find all of the permissions not associated with a group.
1780 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1781 * retrieve any meta-data associated with the permissions.
1783 * @return Returns a list of {@link PermissionInfo} containing information
1784 * about all of the permissions in the given group.
1786 public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1787 int flags) throws NameNotFoundException;
1790 * Retrieve all of the information we know about a particular group of
1793 * <p>Throws {@link NameNotFoundException} if a permission group with the given
1794 * name cannot be found on the system.
1796 * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1797 * of the permission you are interested in.
1798 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1799 * retrieve any meta-data associated with the permission group.
1801 * @return Returns a {@link PermissionGroupInfo} containing information
1802 * about the permission.
1804 public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1805 int flags) throws NameNotFoundException;
1808 * Retrieve all of the known permission groups in the system.
1810 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
1811 * retrieve any meta-data associated with the permission group.
1813 * @return Returns a list of {@link PermissionGroupInfo} containing
1814 * information about all of the known permission groups.
1816 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1819 * Retrieve all of the information we know about a particular
1820 * package/application.
1822 * <p>Throws {@link NameNotFoundException} if an application with the given
1823 * package name cannot be found on the system.
1825 * @param packageName The full name (i.e. com.google.apps.contacts) of an
1827 * @param flags Additional option flags. Use any combination of
1828 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1829 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1831 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing
1832 * information about the package.
1833 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not
1834 * found in the list of installed applications,
1835 * the application information is retrieved from the
1836 * list of uninstalled applications(which includes
1837 * installed applications as well as applications
1838 * with data directory ie applications which had been
1839 * deleted with {@code DONT_DELETE_DATA} flag set).
1841 * @see #GET_META_DATA
1842 * @see #GET_SHARED_LIBRARY_FILES
1843 * @see #GET_UNINSTALLED_PACKAGES
1845 public abstract ApplicationInfo getApplicationInfo(String packageName,
1846 int flags) throws NameNotFoundException;
1849 * Retrieve all of the information we know about a particular activity
1852 * <p>Throws {@link NameNotFoundException} if an activity with the given
1853 * class name cannot be found on the system.
1855 * @param component The full component name (i.e.
1856 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1858 * @param flags Additional option flags. Use any combination of
1859 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1860 * to modify the data (in ApplicationInfo) returned.
1862 * @return {@link ActivityInfo} containing information about the activity.
1864 * @see #GET_INTENT_FILTERS
1865 * @see #GET_META_DATA
1866 * @see #GET_SHARED_LIBRARY_FILES
1868 public abstract ActivityInfo getActivityInfo(ComponentName component,
1869 int flags) throws NameNotFoundException;
1872 * Retrieve all of the information we know about a particular receiver
1875 * <p>Throws {@link NameNotFoundException} if a receiver with the given
1876 * class name cannot be found on the system.
1878 * @param component The full component name (i.e.
1879 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1881 * @param flags Additional option flags. Use any combination of
1882 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1883 * to modify the data returned.
1885 * @return {@link ActivityInfo} containing information about the receiver.
1887 * @see #GET_INTENT_FILTERS
1888 * @see #GET_META_DATA
1889 * @see #GET_SHARED_LIBRARY_FILES
1891 public abstract ActivityInfo getReceiverInfo(ComponentName component,
1892 int flags) throws NameNotFoundException;
1895 * Retrieve all of the information we know about a particular service
1898 * <p>Throws {@link NameNotFoundException} if a service with the given
1899 * class name cannot be found on the system.
1901 * @param component The full component name (i.e.
1902 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1904 * @param flags Additional option flags. Use any combination of
1905 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1906 * to modify the data returned.
1908 * @return ServiceInfo containing information about the service.
1910 * @see #GET_META_DATA
1911 * @see #GET_SHARED_LIBRARY_FILES
1913 public abstract ServiceInfo getServiceInfo(ComponentName component,
1914 int flags) throws NameNotFoundException;
1917 * Retrieve all of the information we know about a particular content
1920 * <p>Throws {@link NameNotFoundException} if a provider with the given
1921 * class name cannot be found on the system.
1923 * @param component The full component name (i.e.
1924 * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1925 * ContentProvider class.
1926 * @param flags Additional option flags. Use any combination of
1927 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1928 * to modify the data returned.
1930 * @return ProviderInfo containing information about the service.
1932 * @see #GET_META_DATA
1933 * @see #GET_SHARED_LIBRARY_FILES
1935 public abstract ProviderInfo getProviderInfo(ComponentName component,
1936 int flags) throws NameNotFoundException;
1939 * Return a List of all packages that are installed
1942 * @param flags Additional option flags. Use any combination of
1943 * {@link #GET_ACTIVITIES},
1944 * {@link #GET_GIDS},
1945 * {@link #GET_CONFIGURATIONS},
1946 * {@link #GET_INSTRUMENTATION},
1947 * {@link #GET_PERMISSIONS},
1948 * {@link #GET_PROVIDERS},
1949 * {@link #GET_RECEIVERS},
1950 * {@link #GET_SERVICES},
1951 * {@link #GET_SIGNATURES},
1952 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1954 * @return A List of PackageInfo objects, one for each package that is
1955 * installed on the device. In the unlikely case of there being no
1956 * installed packages, an empty list is returned.
1957 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1958 * applications including those deleted with {@code DONT_DELETE_DATA}
1959 * (partially installed apps with data directory) will be returned.
1961 * @see #GET_ACTIVITIES
1963 * @see #GET_CONFIGURATIONS
1964 * @see #GET_INSTRUMENTATION
1965 * @see #GET_PERMISSIONS
1966 * @see #GET_PROVIDERS
1967 * @see #GET_RECEIVERS
1968 * @see #GET_SERVICES
1969 * @see #GET_SIGNATURES
1970 * @see #GET_UNINSTALLED_PACKAGES
1972 public abstract List<PackageInfo> getInstalledPackages(int flags);
1975 * Return a List of all installed packages that are currently
1976 * holding any of the given permissions.
1978 * @param flags Additional option flags. Use any combination of
1979 * {@link #GET_ACTIVITIES},
1980 * {@link #GET_GIDS},
1981 * {@link #GET_CONFIGURATIONS},
1982 * {@link #GET_INSTRUMENTATION},
1983 * {@link #GET_PERMISSIONS},
1984 * {@link #GET_PROVIDERS},
1985 * {@link #GET_RECEIVERS},
1986 * {@link #GET_SERVICES},
1987 * {@link #GET_SIGNATURES},
1988 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1990 * @return Returns a List of PackageInfo objects, one for each installed
1991 * application that is holding any of the permissions that were provided.
1993 * @see #GET_ACTIVITIES
1995 * @see #GET_CONFIGURATIONS
1996 * @see #GET_INSTRUMENTATION
1997 * @see #GET_PERMISSIONS
1998 * @see #GET_PROVIDERS
1999 * @see #GET_RECEIVERS
2000 * @see #GET_SERVICES
2001 * @see #GET_SIGNATURES
2002 * @see #GET_UNINSTALLED_PACKAGES
2004 public abstract List<PackageInfo> getPackagesHoldingPermissions(
2005 String[] permissions, int flags);
2008 * Return a List of all packages that are installed on the device, for a specific user.
2009 * Requesting a list of installed packages for another user
2010 * will require the permission INTERACT_ACROSS_USERS_FULL.
2011 * @param flags Additional option flags. Use any combination of
2012 * {@link #GET_ACTIVITIES},
2013 * {@link #GET_GIDS},
2014 * {@link #GET_CONFIGURATIONS},
2015 * {@link #GET_INSTRUMENTATION},
2016 * {@link #GET_PERMISSIONS},
2017 * {@link #GET_PROVIDERS},
2018 * {@link #GET_RECEIVERS},
2019 * {@link #GET_SERVICES},
2020 * {@link #GET_SIGNATURES},
2021 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2022 * @param userId The user for whom the installed packages are to be listed
2024 * @return A List of PackageInfo objects, one for each package that is
2025 * installed on the device. In the unlikely case of there being no
2026 * installed packages, an empty list is returned.
2027 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2028 * applications including those deleted with {@code DONT_DELETE_DATA}
2029 * (partially installed apps with data directory) will be returned.
2031 * @see #GET_ACTIVITIES
2033 * @see #GET_CONFIGURATIONS
2034 * @see #GET_INSTRUMENTATION
2035 * @see #GET_PERMISSIONS
2036 * @see #GET_PROVIDERS
2037 * @see #GET_RECEIVERS
2038 * @see #GET_SERVICES
2039 * @see #GET_SIGNATURES
2040 * @see #GET_UNINSTALLED_PACKAGES
2044 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
2047 * Check whether a particular package has been granted a particular
2050 * @param permName The name of the permission you are checking for,
2051 * @param pkgName The name of the package you are checking against.
2053 * @return If the package has the permission, PERMISSION_GRANTED is
2054 * returned. If it does not have the permission, PERMISSION_DENIED
2057 * @see #PERMISSION_GRANTED
2058 * @see #PERMISSION_DENIED
2060 public abstract int checkPermission(String permName, String pkgName);
2063 * Add a new dynamic permission to the system. For this to work, your
2064 * package must have defined a permission tree through the
2065 * {@link android.R.styleable#AndroidManifestPermissionTree
2066 * <permission-tree>} tag in its manifest. A package can only add
2067 * permissions to trees that were defined by either its own package or
2068 * another with the same user id; a permission is in a tree if it
2069 * matches the name of the permission tree + ".": for example,
2070 * "com.foo.bar" is a member of the permission tree "com.foo".
2072 * <p>It is good to make your permission tree name descriptive, because you
2073 * are taking possession of that entire set of permission names. Thus, it
2074 * must be under a domain you control, with a suffix that will not match
2075 * any normal permissions that may be declared in any applications that
2076 * are part of that domain.
2078 * <p>New permissions must be added before
2079 * any .apks are installed that use those permissions. Permissions you
2080 * add through this method are remembered across reboots of the device.
2081 * If the given permission already exists, the info you supply here
2082 * will be used to update it.
2084 * @param info Description of the permission to be added.
2086 * @return Returns true if a new permission was created, false if an
2087 * existing one was updated.
2089 * @throws SecurityException if you are not allowed to add the
2090 * given permission name.
2092 * @see #removePermission(String)
2094 public abstract boolean addPermission(PermissionInfo info);
2097 * Like {@link #addPermission(PermissionInfo)} but asynchronously
2098 * persists the package manager state after returning from the call,
2099 * allowing it to return quicker and batch a series of adds at the
2100 * expense of no guarantee the added permission will be retained if
2101 * the device is rebooted before it is written.
2103 public abstract boolean addPermissionAsync(PermissionInfo info);
2106 * Removes a permission that was previously added with
2107 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply
2108 * -- you are only allowed to remove permissions that you are allowed
2111 * @param name The name of the permission to remove.
2113 * @throws SecurityException if you are not allowed to remove the
2114 * given permission name.
2116 * @see #addPermission(PermissionInfo)
2118 public abstract void removePermission(String name);
2121 * Returns an {@link Intent} suitable for passing to {@code startActivityForResult}
2122 * which prompts the user to grant {@code permissions} to this application.
2125 * @throws NullPointerException if {@code permissions} is {@code null}.
2126 * @throws IllegalArgumentException if {@code permissions} contains {@code null}.
2128 public Intent buildPermissionRequestIntent(String... permissions) {
2129 if (permissions == null) {
2130 throw new NullPointerException("permissions cannot be null");
2132 for (String permission : permissions) {
2133 if (permission == null) {
2134 throw new IllegalArgumentException("permissions cannot contain null");
2138 Intent i = new Intent(ACTION_REQUEST_PERMISSION);
2139 i.putExtra(EXTRA_REQUEST_PERMISSION_PERMISSION_LIST, permissions);
2140 i.setPackage("com.android.packageinstaller");
2145 * Grant a permission to an application which the application does not
2146 * already have. The permission must have been requested by the application,
2147 * but as an optional permission. If the application is not allowed to
2148 * hold the permission, a SecurityException is thrown.
2151 * @param packageName The name of the package that the permission will be
2153 * @param permissionName The name of the permission.
2155 public abstract void grantPermission(String packageName, String permissionName);
2158 * Revoke a permission that was previously granted by {@link #grantPermission}.
2161 * @param packageName The name of the package that the permission will be
2163 * @param permissionName The name of the permission.
2165 public abstract void revokePermission(String packageName, String permissionName);
2168 * Compare the signatures of two packages to determine if the same
2169 * signature appears in both of them. If they do contain the same
2170 * signature, then they are allowed special privileges when working
2171 * with each other: they can share the same user-id, run instrumentation
2172 * against each other, etc.
2174 * @param pkg1 First package name whose signature will be compared.
2175 * @param pkg2 Second package name whose signature will be compared.
2177 * @return Returns an integer indicating whether all signatures on the
2178 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2179 * all signatures match or < 0 if there is not a match ({@link
2180 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2182 * @see #checkSignatures(int, int)
2183 * @see #SIGNATURE_MATCH
2184 * @see #SIGNATURE_NO_MATCH
2185 * @see #SIGNATURE_UNKNOWN_PACKAGE
2187 public abstract int checkSignatures(String pkg1, String pkg2);
2190 * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2191 * the two packages to be checked. This can be useful, for example,
2192 * when doing the check in an IPC, where the UID is the only identity
2193 * available. It is functionally identical to determining the package
2194 * associated with the UIDs and checking their signatures.
2196 * @param uid1 First UID whose signature will be compared.
2197 * @param uid2 Second UID whose signature will be compared.
2199 * @return Returns an integer indicating whether all signatures on the
2200 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2201 * all signatures match or < 0 if there is not a match ({@link
2202 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2204 * @see #checkSignatures(String, String)
2205 * @see #SIGNATURE_MATCH
2206 * @see #SIGNATURE_NO_MATCH
2207 * @see #SIGNATURE_UNKNOWN_PACKAGE
2209 public abstract int checkSignatures(int uid1, int uid2);
2212 * Retrieve the names of all packages that are associated with a particular
2213 * user id. In most cases, this will be a single package name, the package
2214 * that has been assigned that user id. Where there are multiple packages
2215 * sharing the same user id through the "sharedUserId" mechanism, all
2216 * packages with that id will be returned.
2218 * @param uid The user id for which you would like to retrieve the
2219 * associated packages.
2221 * @return Returns an array of one or more packages assigned to the user
2222 * id, or null if there are no known packages with the given id.
2224 public abstract String[] getPackagesForUid(int uid);
2227 * Retrieve the official name associated with a user id. This name is
2228 * guaranteed to never change, though it is possibly for the underlying
2229 * user id to be changed. That is, if you are storing information about
2230 * user ids in persistent storage, you should use the string returned
2231 * by this function instead of the raw user-id.
2233 * @param uid The user id for which you would like to retrieve a name.
2234 * @return Returns a unique name for the given user id, or null if the
2235 * user id is not currently assigned.
2237 public abstract String getNameForUid(int uid);
2240 * Return the user id associated with a shared user name. Multiple
2241 * applications can specify a shared user name in their manifest and thus
2242 * end up using a common uid. This might be used for new applications
2243 * that use an existing shared user name and need to know the uid of the
2246 * @param sharedUserName The shared user name whose uid is to be retrieved.
2247 * @return Returns the uid associated with the shared user, or NameNotFoundException
2248 * if the shared user name is not being used by any installed packages
2251 public abstract int getUidForSharedUser(String sharedUserName)
2252 throws NameNotFoundException;
2255 * Return a List of all application packages that are installed on the
2256 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2257 * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2258 * installed apps with data directory) will be returned.
2260 * @param flags Additional option flags. Use any combination of
2261 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2262 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2264 * @return Returns a List of ApplicationInfo objects, one for each application that
2265 * is installed on the device. In the unlikely case of there being
2266 * no installed applications, an empty list is returned.
2267 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2268 * applications including those deleted with {@code DONT_DELETE_DATA}
2269 * (partially installed apps with data directory) will be returned.
2271 * @see #GET_META_DATA
2272 * @see #GET_SHARED_LIBRARY_FILES
2273 * @see #GET_UNINSTALLED_PACKAGES
2275 public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2278 * Get a list of shared libraries that are available on the
2281 * @return An array of shared library names that are
2282 * available on the system, or null if none are installed.
2285 public abstract String[] getSystemSharedLibraryNames();
2288 * Get a list of features that are available on the
2291 * @return An array of FeatureInfo classes describing the features
2292 * that are available on the system, or null if there are none(!!).
2294 public abstract FeatureInfo[] getSystemAvailableFeatures();
2297 * Check whether the given feature name is one of the available
2298 * features as returned by {@link #getSystemAvailableFeatures()}.
2300 * @return Returns true if the devices supports the feature, else
2303 public abstract boolean hasSystemFeature(String name);
2306 * Determine the best action to perform for a given Intent. This is how
2307 * {@link Intent#resolveActivity} finds an activity if a class has not
2308 * been explicitly specified.
2310 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2311 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2312 * only flag. You need to do so to resolve the activity in the same way
2313 * that {@link android.content.Context#startActivity(Intent)} and
2314 * {@link android.content.Intent#resolveActivity(PackageManager)
2315 * Intent.resolveActivity(PackageManager)} do.</p>
2317 * @param intent An intent containing all of the desired specification
2318 * (action, data, type, category, and/or component).
2319 * @param flags Additional option flags. The most important is
2320 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2321 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2323 * @return Returns a ResolveInfo containing the final activity intent that
2324 * was determined to be the best action. Returns null if no
2325 * matching activity was found. If multiple matching activities are
2326 * found and there is no default set, returns a ResolveInfo
2327 * containing something else, such as the activity resolver.
2329 * @see #MATCH_DEFAULT_ONLY
2330 * @see #GET_INTENT_FILTERS
2331 * @see #GET_RESOLVED_FILTER
2333 public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2336 * Determine the best action to perform for a given Intent for a given user. This
2337 * is how {@link Intent#resolveActivity} finds an activity if a class has not
2338 * been explicitly specified.
2340 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2341 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2342 * only flag. You need to do so to resolve the activity in the same way
2343 * that {@link android.content.Context#startActivity(Intent)} and
2344 * {@link android.content.Intent#resolveActivity(PackageManager)
2345 * Intent.resolveActivity(PackageManager)} do.</p>
2347 * @param intent An intent containing all of the desired specification
2348 * (action, data, type, category, and/or component).
2349 * @param flags Additional option flags. The most important is
2350 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2351 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2352 * @param userId The user id.
2354 * @return Returns a ResolveInfo containing the final activity intent that
2355 * was determined to be the best action. Returns null if no
2356 * matching activity was found. If multiple matching activities are
2357 * found and there is no default set, returns a ResolveInfo
2358 * containing something else, such as the activity resolver.
2360 * @see #MATCH_DEFAULT_ONLY
2361 * @see #GET_INTENT_FILTERS
2362 * @see #GET_RESOLVED_FILTER
2366 public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
2369 * Retrieve all activities that can be performed for the given intent.
2371 * @param intent The desired intent as per resolveActivity().
2372 * @param flags Additional option flags. The most important is
2373 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2374 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2376 * @return A List<ResolveInfo> containing one entry for each matching
2377 * Activity. These are ordered from best to worst match -- that
2378 * is, the first item in the list is what is returned by
2379 * {@link #resolveActivity}. If there are no matching activities, an empty
2382 * @see #MATCH_DEFAULT_ONLY
2383 * @see #GET_INTENT_FILTERS
2384 * @see #GET_RESOLVED_FILTER
2386 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
2390 * Retrieve all activities that can be performed for the given intent, for a specific user.
2392 * @param intent The desired intent as per resolveActivity().
2393 * @param flags Additional option flags. The most important is
2394 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2395 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2397 * @return A List<ResolveInfo> containing one entry for each matching
2398 * Activity. These are ordered from best to worst match -- that
2399 * is, the first item in the list is what is returned by
2400 * {@link #resolveActivity}. If there are no matching activities, an empty
2403 * @see #MATCH_DEFAULT_ONLY
2404 * @see #GET_INTENT_FILTERS
2405 * @see #GET_RESOLVED_FILTER
2406 * @see #NO_CROSS_PROFILE
2409 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
2410 int flags, int userId);
2414 * Retrieve a set of activities that should be presented to the user as
2415 * similar options. This is like {@link #queryIntentActivities}, except it
2416 * also allows you to supply a list of more explicit Intents that you would
2417 * like to resolve to particular options, and takes care of returning the
2418 * final ResolveInfo list in a reasonable order, with no duplicates, based
2421 * @param caller The class name of the activity that is making the
2422 * request. This activity will never appear in the output
2423 * list. Can be null.
2424 * @param specifics An array of Intents that should be resolved to the
2425 * first specific results. Can be null.
2426 * @param intent The desired intent as per resolveActivity().
2427 * @param flags Additional option flags. The most important is
2428 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2429 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2431 * @return A List<ResolveInfo> containing one entry for each matching
2432 * Activity. These are ordered first by all of the intents resolved
2433 * in <var>specifics</var> and then any additional activities that
2434 * can handle <var>intent</var> but did not get included by one of
2435 * the <var>specifics</var> intents. If there are no matching
2436 * activities, an empty list is returned.
2438 * @see #MATCH_DEFAULT_ONLY
2439 * @see #GET_INTENT_FILTERS
2440 * @see #GET_RESOLVED_FILTER
2442 public abstract List<ResolveInfo> queryIntentActivityOptions(
2443 ComponentName caller, Intent[] specifics, Intent intent, int flags);
2446 * Retrieve all receivers that can handle a broadcast of the given intent.
2448 * @param intent The desired intent as per resolveActivity().
2449 * @param flags Additional option flags.
2451 * @return A List<ResolveInfo> containing one entry for each matching
2452 * Receiver. These are ordered from first to last in priority. If
2453 * there are no matching receivers, an empty list is returned.
2455 * @see #MATCH_DEFAULT_ONLY
2456 * @see #GET_INTENT_FILTERS
2457 * @see #GET_RESOLVED_FILTER
2459 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2463 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
2466 * @param intent The desired intent as per resolveActivity().
2467 * @param flags Additional option flags.
2468 * @param userId The userId of the user being queried.
2470 * @return A List<ResolveInfo> containing one entry for each matching
2471 * Receiver. These are ordered from first to last in priority. If
2472 * there are no matching receivers, an empty list is returned.
2474 * @see #MATCH_DEFAULT_ONLY
2475 * @see #GET_INTENT_FILTERS
2476 * @see #GET_RESOLVED_FILTER
2479 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2480 int flags, int userId);
2483 * Determine the best service to handle for a given Intent.
2485 * @param intent An intent containing all of the desired specification
2486 * (action, data, type, category, and/or component).
2487 * @param flags Additional option flags.
2489 * @return Returns a ResolveInfo containing the final service intent that
2490 * was determined to be the best action. Returns null if no
2491 * matching service was found.
2493 * @see #GET_INTENT_FILTERS
2494 * @see #GET_RESOLVED_FILTER
2496 public abstract ResolveInfo resolveService(Intent intent, int flags);
2499 * Retrieve all services that can match the given intent.
2501 * @param intent The desired intent as per resolveService().
2502 * @param flags Additional option flags.
2504 * @return A List<ResolveInfo> containing one entry for each matching
2505 * ServiceInfo. These are ordered from best to worst match -- that
2506 * is, the first item in the list is what is returned by
2507 * resolveService(). If there are no matching services, an empty
2510 * @see #GET_INTENT_FILTERS
2511 * @see #GET_RESOLVED_FILTER
2513 public abstract List<ResolveInfo> queryIntentServices(Intent intent,
2517 * Retrieve all services that can match the given intent for a given user.
2519 * @param intent The desired intent as per resolveService().
2520 * @param flags Additional option flags.
2521 * @param userId The user id.
2523 * @return A List<ResolveInfo> containing one entry for each matching
2524 * ServiceInfo. These are ordered from best to worst match -- that
2525 * is, the first item in the list is what is returned by
2526 * resolveService(). If there are no matching services, an empty
2529 * @see #GET_INTENT_FILTERS
2530 * @see #GET_RESOLVED_FILTER
2534 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
2535 int flags, int userId);
2538 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
2539 Intent intent, int flags, int userId);
2542 * Retrieve all providers that can match the given intent.
2544 * @param intent An intent containing all of the desired specification
2545 * (action, data, type, category, and/or component).
2546 * @param flags Additional option flags.
2547 * @return A List<ResolveInfo> containing one entry for each matching
2548 * ProviderInfo. These are ordered from best to worst match. If
2549 * there are no matching providers, an empty list is returned.
2550 * @see #GET_INTENT_FILTERS
2551 * @see #GET_RESOLVED_FILTER
2553 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
2556 * Find a single content provider by its base path name.
2558 * @param name The name of the provider to find.
2559 * @param flags Additional option flags. Currently should always be 0.
2561 * @return ContentProviderInfo Information about the provider, if found,
2564 public abstract ProviderInfo resolveContentProvider(String name,
2568 * Find a single content provider by its base path name.
2570 * @param name The name of the provider to find.
2571 * @param flags Additional option flags. Currently should always be 0.
2572 * @param userId The user id.
2574 * @return ContentProviderInfo Information about the provider, if found,
2578 public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
2581 * Retrieve content provider information.
2583 * <p><em>Note: unlike most other methods, an empty result set is indicated
2584 * by a null return instead of an empty list.</em>
2586 * @param processName If non-null, limits the returned providers to only
2587 * those that are hosted by the given process. If null,
2588 * all content providers are returned.
2589 * @param uid If <var>processName</var> is non-null, this is the required
2590 * uid owning the requested content providers.
2591 * @param flags Additional option flags. Currently should always be 0.
2593 * @return A List<ContentProviderInfo> containing one entry for each
2594 * content provider either patching <var>processName</var> or, if
2595 * <var>processName</var> is null, all known content providers.
2596 * <em>If there are no matching providers, null is returned.</em>
2598 public abstract List<ProviderInfo> queryContentProviders(
2599 String processName, int uid, int flags);
2602 * Retrieve all of the information we know about a particular
2603 * instrumentation class.
2605 * <p>Throws {@link NameNotFoundException} if instrumentation with the
2606 * given class name cannot be found on the system.
2608 * @param className The full name (i.e.
2609 * com.google.apps.contacts.InstrumentList) of an
2610 * Instrumentation class.
2611 * @param flags Additional option flags. Currently should always be 0.
2613 * @return InstrumentationInfo containing information about the
2616 public abstract InstrumentationInfo getInstrumentationInfo(
2617 ComponentName className, int flags) throws NameNotFoundException;
2620 * Retrieve information about available instrumentation code. May be used
2621 * to retrieve either all instrumentation code, or only the code targeting
2622 * a particular package.
2624 * @param targetPackage If null, all instrumentation is returned; only the
2625 * instrumentation targeting this package name is
2627 * @param flags Additional option flags. Currently should always be 0.
2629 * @return A List<InstrumentationInfo> containing one entry for each
2630 * matching available Instrumentation. Returns an empty list if
2631 * there is no instrumentation available for the given package.
2633 public abstract List<InstrumentationInfo> queryInstrumentation(
2634 String targetPackage, int flags);
2637 * Retrieve an image from a package. This is a low-level API used by
2638 * the various package manager info structures (such as
2639 * {@link ComponentInfo} to implement retrieval of their associated
2642 * @param packageName The name of the package that this icon is coming from.
2644 * @param resid The resource identifier of the desired image. Cannot be 0.
2645 * @param appInfo Overall information about <var>packageName</var>. This
2646 * may be null, in which case the application information will be retrieved
2647 * for you if needed; if you already have this information around, it can
2648 * be much more efficient to supply it here.
2650 * @return Returns a Drawable holding the requested image. Returns null if
2651 * an image could not be found for any reason.
2653 public abstract Drawable getDrawable(String packageName, int resid,
2654 ApplicationInfo appInfo);
2657 * Retrieve the icon associated with an activity. Given the full name of
2658 * an activity, retrieves the information about it and calls
2659 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
2660 * If the activity cannot be found, NameNotFoundException is thrown.
2662 * @param activityName Name of the activity whose icon is to be retrieved.
2664 * @return Returns the image of the icon, or the default activity icon if
2665 * it could not be found. Does not return null.
2666 * @throws NameNotFoundException Thrown if the resources for the given
2667 * activity could not be loaded.
2669 * @see #getActivityIcon(Intent)
2671 public abstract Drawable getActivityIcon(ComponentName activityName)
2672 throws NameNotFoundException;
2675 * Retrieve the icon associated with an Intent. If intent.getClassName() is
2676 * set, this simply returns the result of
2677 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
2678 * component and returns the icon associated with the resolved component.
2679 * If intent.getClassName() cannot be found or the Intent cannot be resolved
2680 * to a component, NameNotFoundException is thrown.
2682 * @param intent The intent for which you would like to retrieve an icon.
2684 * @return Returns the image of the icon, or the default activity icon if
2685 * it could not be found. Does not return null.
2686 * @throws NameNotFoundException Thrown if the resources for application
2687 * matching the given intent could not be loaded.
2689 * @see #getActivityIcon(ComponentName)
2691 public abstract Drawable getActivityIcon(Intent intent)
2692 throws NameNotFoundException;
2695 * Retrieve the banner associated with an activity. Given the full name of
2696 * an activity, retrieves the information about it and calls
2697 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
2698 * banner. If the activity cannot be found, NameNotFoundException is thrown.
2700 * @param activityName Name of the activity whose banner is to be retrieved.
2701 * @return Returns the image of the banner, or null if the activity has no
2703 * @throws NameNotFoundException Thrown if the resources for the given
2704 * activity could not be loaded.
2705 * @see #getActivityBanner(Intent)
2707 public abstract Drawable getActivityBanner(ComponentName activityName)
2708 throws NameNotFoundException;
2711 * Retrieve the banner associated with an Intent. If intent.getClassName()
2712 * is set, this simply returns the result of
2713 * getActivityBanner(intent.getClassName()). Otherwise it resolves the
2714 * intent's component and returns the banner associated with the resolved
2715 * component. If intent.getClassName() cannot be found or the Intent cannot
2716 * be resolved to a component, NameNotFoundException is thrown.
2718 * @param intent The intent for which you would like to retrieve a banner.
2719 * @return Returns the image of the banner, or null if the activity has no
2721 * @throws NameNotFoundException Thrown if the resources for application
2722 * matching the given intent could not be loaded.
2723 * @see #getActivityBanner(ComponentName)
2725 public abstract Drawable getActivityBanner(Intent intent)
2726 throws NameNotFoundException;
2729 * Return the generic icon for an activity that is used when no specific
2732 * @return Drawable Image of the icon.
2734 public abstract Drawable getDefaultActivityIcon();
2737 * Retrieve the icon associated with an application. If it has not defined
2738 * an icon, the default app icon is returned. Does not return null.
2740 * @param info Information about application being queried.
2742 * @return Returns the image of the icon, or the default application icon
2743 * if it could not be found.
2745 * @see #getApplicationIcon(String)
2747 public abstract Drawable getApplicationIcon(ApplicationInfo info);
2750 * Retrieve the icon associated with an application. Given the name of the
2751 * application's package, retrieves the information about it and calls
2752 * getApplicationIcon() to return its icon. If the application cannot be
2753 * found, NameNotFoundException is thrown.
2755 * @param packageName Name of the package whose application icon is to be
2758 * @return Returns the image of the icon, or the default application icon
2759 * if it could not be found. Does not return null.
2760 * @throws NameNotFoundException Thrown if the resources for the given
2761 * application could not be loaded.
2763 * @see #getApplicationIcon(ApplicationInfo)
2765 public abstract Drawable getApplicationIcon(String packageName)
2766 throws NameNotFoundException;
2769 * Retrieve the banner associated with an application.
2771 * @param info Information about application being queried.
2772 * @return Returns the image of the banner or null if the application has no
2774 * @see #getApplicationBanner(String)
2776 public abstract Drawable getApplicationBanner(ApplicationInfo info);
2779 * Retrieve the banner associated with an application. Given the name of the
2780 * application's package, retrieves the information about it and calls
2781 * getApplicationIcon() to return its banner. If the application cannot be
2782 * found, NameNotFoundException is thrown.
2784 * @param packageName Name of the package whose application banner is to be
2786 * @return Returns the image of the banner or null if the application has no
2788 * @throws NameNotFoundException Thrown if the resources for the given
2789 * application could not be loaded.
2790 * @see #getApplicationBanner(ApplicationInfo)
2792 public abstract Drawable getApplicationBanner(String packageName)
2793 throws NameNotFoundException;
2796 * Retrieve the logo associated with an activity. Given the full name of an
2797 * activity, retrieves the information about it and calls
2798 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
2799 * logo. If the activity cannot be found, NameNotFoundException is thrown.
2801 * @param activityName Name of the activity whose logo is to be retrieved.
2802 * @return Returns the image of the logo or null if the activity has no logo
2804 * @throws NameNotFoundException Thrown if the resources for the given
2805 * activity could not be loaded.
2806 * @see #getActivityLogo(Intent)
2808 public abstract Drawable getActivityLogo(ComponentName activityName)
2809 throws NameNotFoundException;
2812 * Retrieve the logo associated with an Intent. If intent.getClassName() is
2813 * set, this simply returns the result of
2814 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's
2815 * component and returns the logo associated with the resolved component.
2816 * If intent.getClassName() cannot be found or the Intent cannot be resolved
2817 * to a component, NameNotFoundException is thrown.
2819 * @param intent The intent for which you would like to retrieve a logo.
2821 * @return Returns the image of the logo, or null if the activity has no
2824 * @throws NameNotFoundException Thrown if the resources for application
2825 * matching the given intent could not be loaded.
2827 * @see #getActivityLogo(ComponentName)
2829 public abstract Drawable getActivityLogo(Intent intent)
2830 throws NameNotFoundException;
2833 * Retrieve the logo associated with an application. If it has not specified
2834 * a logo, this method returns null.
2836 * @param info Information about application being queried.
2838 * @return Returns the image of the logo, or null if no logo is specified
2839 * by the application.
2841 * @see #getApplicationLogo(String)
2843 public abstract Drawable getApplicationLogo(ApplicationInfo info);
2846 * Retrieve the logo associated with an application. Given the name of the
2847 * application's package, retrieves the information about it and calls
2848 * getApplicationLogo() to return its logo. If the application cannot be
2849 * found, NameNotFoundException is thrown.
2851 * @param packageName Name of the package whose application logo is to be
2854 * @return Returns the image of the logo, or null if no application logo
2855 * has been specified.
2857 * @throws NameNotFoundException Thrown if the resources for the given
2858 * application could not be loaded.
2860 * @see #getApplicationLogo(ApplicationInfo)
2862 public abstract Drawable getApplicationLogo(String packageName)
2863 throws NameNotFoundException;
2866 * Retrieve text from a package. This is a low-level API used by
2867 * the various package manager info structures (such as
2868 * {@link ComponentInfo} to implement retrieval of their associated
2869 * labels and other text.
2871 * @param packageName The name of the package that this text is coming from.
2873 * @param resid The resource identifier of the desired text. Cannot be 0.
2874 * @param appInfo Overall information about <var>packageName</var>. This
2875 * may be null, in which case the application information will be retrieved
2876 * for you if needed; if you already have this information around, it can
2877 * be much more efficient to supply it here.
2879 * @return Returns a CharSequence holding the requested text. Returns null
2880 * if the text could not be found for any reason.
2882 public abstract CharSequence getText(String packageName, int resid,
2883 ApplicationInfo appInfo);
2886 * Retrieve an XML file from a package. This is a low-level API used to
2887 * retrieve XML meta data.
2889 * @param packageName The name of the package that this xml is coming from.
2891 * @param resid The resource identifier of the desired xml. Cannot be 0.
2892 * @param appInfo Overall information about <var>packageName</var>. This
2893 * may be null, in which case the application information will be retrieved
2894 * for you if needed; if you already have this information around, it can
2895 * be much more efficient to supply it here.
2897 * @return Returns an XmlPullParser allowing you to parse out the XML
2898 * data. Returns null if the xml resource could not be found for any
2901 public abstract XmlResourceParser getXml(String packageName, int resid,
2902 ApplicationInfo appInfo);
2905 * Return the label to use for this application.
2907 * @return Returns the label associated with this application, or null if
2908 * it could not be found for any reason.
2909 * @param info The application to get the label of.
2911 public abstract CharSequence getApplicationLabel(ApplicationInfo info);
2914 * Retrieve the resources associated with an activity. Given the full
2915 * name of an activity, retrieves the information about it and calls
2916 * getResources() to return its application's resources. If the activity
2917 * cannot be found, NameNotFoundException is thrown.
2919 * @param activityName Name of the activity whose resources are to be
2922 * @return Returns the application's Resources.
2923 * @throws NameNotFoundException Thrown if the resources for the given
2924 * application could not be loaded.
2926 * @see #getResourcesForApplication(ApplicationInfo)
2928 public abstract Resources getResourcesForActivity(ComponentName activityName)
2929 throws NameNotFoundException;
2932 * Retrieve the resources for an application. Throws NameNotFoundException
2933 * if the package is no longer installed.
2935 * @param app Information about the desired application.
2937 * @return Returns the application's Resources.
2938 * @throws NameNotFoundException Thrown if the resources for the given
2939 * application could not be loaded (most likely because it was uninstalled).
2941 public abstract Resources getResourcesForApplication(ApplicationInfo app)
2942 throws NameNotFoundException;
2945 * Retrieve the resources associated with an application. Given the full
2946 * package name of an application, retrieves the information about it and
2947 * calls getResources() to return its application's resources. If the
2948 * appPackageName cannot be found, NameNotFoundException is thrown.
2950 * @param appPackageName Package name of the application whose resources
2951 * are to be retrieved.
2953 * @return Returns the application's Resources.
2954 * @throws NameNotFoundException Thrown if the resources for the given
2955 * application could not be loaded.
2957 * @see #getResourcesForApplication(ApplicationInfo)
2959 public abstract Resources getResourcesForApplication(String appPackageName)
2960 throws NameNotFoundException;
2963 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
2964 throws NameNotFoundException;
2967 * Retrieve overall information about an application package defined
2968 * in a package archive file
2970 * @param archiveFilePath The path to the archive file
2971 * @param flags Additional option flags. Use any combination of
2972 * {@link #GET_ACTIVITIES},
2973 * {@link #GET_GIDS},
2974 * {@link #GET_CONFIGURATIONS},
2975 * {@link #GET_INSTRUMENTATION},
2976 * {@link #GET_PERMISSIONS},
2977 * {@link #GET_PROVIDERS},
2978 * {@link #GET_RECEIVERS},
2979 * {@link #GET_SERVICES},
2980 * {@link #GET_SIGNATURES}, to modify the data returned.
2982 * @return Returns the information about the package. Returns
2983 * null if the package could not be successfully parsed.
2985 * @see #GET_ACTIVITIES
2987 * @see #GET_CONFIGURATIONS
2988 * @see #GET_INSTRUMENTATION
2989 * @see #GET_PERMISSIONS
2990 * @see #GET_PROVIDERS
2991 * @see #GET_RECEIVERS
2992 * @see #GET_SERVICES
2993 * @see #GET_SIGNATURES
2996 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
2997 final PackageParser parser = new PackageParser();
2998 final File apkFile = new File(archiveFilePath);
3000 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3001 if ((flags & GET_SIGNATURES) != 0) {
3002 parser.collectCertificates(pkg, 0);
3003 parser.collectManifestDigest(pkg);
3005 PackageUserState state = new PackageUserState();
3006 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3007 } catch (PackageParserException e) {
3013 * @hide Install a package. Since this may take a little while, the result
3014 * will be posted back to the given observer. An installation will
3015 * fail if the calling context lacks the
3016 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3017 * the package named in the package file's manifest is already
3018 * installed, or if there's no space available on the device.
3019 * @param packageURI The location of the package file to install. This can
3020 * be a 'file:' or a 'content:' URI.
3021 * @param observer An observer callback to get notified when the package
3022 * installation is complete.
3023 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3024 * will be called when that happens. This parameter must not be
3026 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3027 * {@link #INSTALL_REPLACE_EXISTING},
3028 * {@link #INSTALL_ALLOW_TEST}.
3029 * @param installerPackageName Optional package name of the application that
3030 * is performing the installation. This identifies which market
3031 * the package came from.
3032 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3033 * String)} instead. This method will continue to be supported
3034 * but the older observer interface will not get additional
3038 public abstract void installPackage(
3039 Uri packageURI, IPackageInstallObserver observer, int flags,
3040 String installerPackageName);
3044 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3045 * with an extra verification file provided.
3047 * @param packageURI The location of the package file to install. This can
3048 * be a 'file:' or a 'content:' URI.
3049 * @param observer An observer callback to get notified when the package
3050 * installation is complete.
3051 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3052 * will be called when that happens. This parameter must not be
3054 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3055 * {@link #INSTALL_REPLACE_EXISTING},
3056 * {@link #INSTALL_ALLOW_TEST}.
3057 * @param installerPackageName Optional package name of the application that
3058 * is performing the installation. This identifies which market
3059 * the package came from.
3060 * @param verificationURI The location of the supplementary verification
3061 * file. This can be a 'file:' or a 'content:' URI. May be
3063 * @param manifestDigest an object that holds the digest of the package
3064 * which can be used to verify ownership. May be {@code null}.
3065 * @param encryptionParams if the package to be installed is encrypted,
3066 * these parameters describing the encryption and authentication
3067 * used. May be {@code null}.
3069 * @deprecated Use {@link #installPackageWithVerification(Uri,
3070 * PackageInstallObserver, int, String, Uri, ManifestDigest,
3071 * ContainerEncryptionParams)} instead. This method will
3072 * continue to be supported but the older observer interface
3073 * will not get additional failure details.
3076 public abstract void installPackageWithVerification(Uri packageURI,
3077 IPackageInstallObserver observer, int flags, String installerPackageName,
3078 Uri verificationURI, ManifestDigest manifestDigest,
3079 ContainerEncryptionParams encryptionParams);
3083 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3084 * with an extra verification information provided.
3086 * @param packageURI The location of the package file to install. This can
3087 * be a 'file:' or a 'content:' URI.
3088 * @param observer An observer callback to get notified when the package
3089 * installation is complete.
3090 * {@link IPackageInstallObserver#packageInstalled(String, int)}
3091 * will be called when that happens. This parameter must not be
3093 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3094 * {@link #INSTALL_REPLACE_EXISTING},
3095 * {@link #INSTALL_ALLOW_TEST}.
3096 * @param installerPackageName Optional package name of the application that
3097 * is performing the installation. This identifies which market
3098 * the package came from.
3099 * @param verificationParams an object that holds signal information to
3100 * assist verification. May be {@code null}.
3101 * @param encryptionParams if the package to be installed is encrypted,
3102 * these parameters describing the encryption and authentication
3103 * used. May be {@code null}.
3105 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3106 * PackageInstallObserver, int, String, VerificationParams,
3107 * ContainerEncryptionParams)} instead. This method will
3108 * continue to be supported but the older observer interface
3109 * will not get additional failure details.
3112 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3113 IPackageInstallObserver observer, int flags, String installerPackageName,
3114 VerificationParams verificationParams,
3115 ContainerEncryptionParams encryptionParams);
3117 // Package-install variants that take the new, expanded form of observer interface.
3118 // Note that these *also* take the original observer type and will redundantly
3119 // report the same information to that observer if supplied; but it is not required.
3124 * Install a package. Since this may take a little while, the result will
3125 * be posted back to the given observer. An installation will fail if the calling context
3126 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3127 * package named in the package file's manifest is already installed, or if there's no space
3128 * available on the device.
3130 * @param packageURI The location of the package file to install. This can be a 'file:' or a
3132 * @param observer An observer callback to get notified when the package installation is
3133 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3134 * called when that happens. This parameter must not be null.
3135 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3136 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3137 * @param installerPackageName Optional package name of the application that is performing the
3138 * installation. This identifies which market the package came from.
3140 public abstract void installPackage(
3141 Uri packageURI, PackageInstallObserver observer,
3142 int flags, String installerPackageName);
3146 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3147 * with an extra verification file provided.
3149 * @param packageURI The location of the package file to install. This can
3150 * be a 'file:' or a 'content:' URI.
3151 * @param observer An observer callback to get notified when the package installation is
3152 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3153 * called when that happens. This parameter must not be null.
3154 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3155 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3156 * @param installerPackageName Optional package name of the application that
3157 * is performing the installation. This identifies which market
3158 * the package came from.
3159 * @param verificationURI The location of the supplementary verification
3160 * file. This can be a 'file:' or a 'content:' URI. May be
3162 * @param manifestDigest an object that holds the digest of the package
3163 * which can be used to verify ownership. May be {@code null}.
3164 * @param encryptionParams if the package to be installed is encrypted,
3165 * these parameters describing the encryption and authentication
3166 * used. May be {@code null}.
3169 public abstract void installPackageWithVerification(Uri packageURI,
3170 PackageInstallObserver observer, int flags, String installerPackageName,
3171 Uri verificationURI, ManifestDigest manifestDigest,
3172 ContainerEncryptionParams encryptionParams);
3176 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3177 * with an extra verification information provided.
3179 * @param packageURI The location of the package file to install. This can
3180 * be a 'file:' or a 'content:' URI.
3181 * @param observer An observer callback to get notified when the package installation is
3182 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3183 * called when that happens. This parameter must not be null.
3184 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3185 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3186 * @param installerPackageName Optional package name of the application that
3187 * is performing the installation. This identifies which market
3188 * the package came from.
3189 * @param verificationParams an object that holds signal information to
3190 * assist verification. May be {@code null}.
3191 * @param encryptionParams if the package to be installed is encrypted,
3192 * these parameters describing the encryption and authentication
3193 * used. May be {@code null}.
3197 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3198 PackageInstallObserver observer, int flags, String installerPackageName,
3199 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3202 * If there is already an application with the given package name installed
3203 * on the system for other users, also install it for the calling user.
3207 public abstract int installExistingPackage(String packageName)
3208 throws NameNotFoundException;
3211 * Allows a package listening to the
3212 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3213 * broadcast} to respond to the package manager. The response must include
3214 * the {@code verificationCode} which is one of
3215 * {@link PackageManager#VERIFICATION_ALLOW} or
3216 * {@link PackageManager#VERIFICATION_REJECT}.
3218 * @param id pending package identifier as passed via the
3219 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3220 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3221 * or {@link PackageManager#VERIFICATION_REJECT}.
3222 * @throws SecurityException if the caller does not have the
3223 * PACKAGE_VERIFICATION_AGENT permission.
3225 public abstract void verifyPendingInstall(int id, int verificationCode);
3228 * Allows a package listening to the
3229 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3230 * broadcast} to extend the default timeout for a response and declare what
3231 * action to perform after the timeout occurs. The response must include
3232 * the {@code verificationCodeAtTimeout} which is one of
3233 * {@link PackageManager#VERIFICATION_ALLOW} or
3234 * {@link PackageManager#VERIFICATION_REJECT}.
3236 * This method may only be called once per package id. Additional calls
3237 * will have no effect.
3239 * @param id pending package identifier as passed via the
3240 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3241 * @param verificationCodeAtTimeout either
3242 * {@link PackageManager#VERIFICATION_ALLOW} or
3243 * {@link PackageManager#VERIFICATION_REJECT}. If
3244 * {@code verificationCodeAtTimeout} is neither
3245 * {@link PackageManager#VERIFICATION_ALLOW} or
3246 * {@link PackageManager#VERIFICATION_REJECT}, then
3247 * {@code verificationCodeAtTimeout} will default to
3248 * {@link PackageManager#VERIFICATION_REJECT}.
3249 * @param millisecondsToDelay the amount of time requested for the timeout.
3250 * Must be positive and less than
3251 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3252 * {@code millisecondsToDelay} is out of bounds,
3253 * {@code millisecondsToDelay} will be set to the closest in
3254 * bounds value; namely, 0 or
3255 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3256 * @throws SecurityException if the caller does not have the
3257 * PACKAGE_VERIFICATION_AGENT permission.
3259 public abstract void extendVerificationTimeout(int id,
3260 int verificationCodeAtTimeout, long millisecondsToDelay);
3263 * Change the installer associated with a given package. There are limitations
3264 * on how the installer package can be changed; in particular:
3266 * <li> A SecurityException will be thrown if <var>installerPackageName</var>
3267 * is not signed with the same certificate as the calling application.
3268 * <li> A SecurityException will be thrown if <var>targetPackage</var> already
3269 * has an installer package, and that installer package is not signed with
3270 * the same certificate as the calling application.
3273 * @param targetPackage The installed package whose installer will be changed.
3274 * @param installerPackageName The package name of the new installer. May be
3275 * null to clear the association.
3277 public abstract void setInstallerPackageName(String targetPackage,
3278 String installerPackageName);
3281 * Attempts to delete a package. Since this may take a little while, the result will
3282 * be posted back to the given observer. A deletion will fail if the calling context
3283 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
3284 * named package cannot be found, or if the named package is a "system package".
3285 * (TODO: include pointer to documentation on "system packages")
3287 * @param packageName The name of the package to delete
3288 * @param observer An observer callback to get notified when the package deletion is
3289 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
3290 * called when that happens. observer may be null to indicate that no callback is desired.
3291 * @param flags - possible values: {@link #DELETE_KEEP_DATA},
3292 * {@link #DELETE_ALL_USERS}.
3297 public abstract void deletePackage(
3298 String packageName, IPackageDeleteObserver observer, int flags);
3301 * Retrieve the package name of the application that installed a package. This identifies
3302 * which market the package came from.
3304 * @param packageName The name of the package to query
3306 public abstract String getInstallerPackageName(String packageName);
3309 * Attempts to clear the user data directory of an application.
3310 * Since this may take a little while, the result will
3311 * be posted back to the given observer. A deletion will fail if the
3312 * named package cannot be found, or if the named package is a "system package".
3314 * @param packageName The name of the package
3315 * @param observer An observer callback to get notified when the operation is finished
3316 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3317 * will be called when that happens. observer may be null to indicate that
3318 * no callback is desired.
3322 public abstract void clearApplicationUserData(String packageName,
3323 IPackageDataObserver observer);
3325 * Attempts to delete the cache files associated with an application.
3326 * Since this may take a little while, the result will
3327 * be posted back to the given observer. A deletion will fail if the calling context
3328 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
3329 * named package cannot be found, or if the named package is a "system package".
3331 * @param packageName The name of the package to delete
3332 * @param observer An observer callback to get notified when the cache file deletion
3334 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3335 * will be called when that happens. observer may be null to indicate that
3336 * no callback is desired.
3340 public abstract void deleteApplicationCacheFiles(String packageName,
3341 IPackageDataObserver observer);
3344 * Free storage by deleting LRU sorted list of cache files across
3345 * all applications. If the currently available free storage
3346 * on the device is greater than or equal to the requested
3347 * free storage, no cache files are cleared. If the currently
3348 * available storage on the device is less than the requested
3349 * free storage, some or all of the cache files across
3350 * all applications are deleted (based on last accessed time)
3351 * to increase the free storage space on the device to
3352 * the requested value. There is no guarantee that clearing all
3353 * the cache files from all applications will clear up
3354 * enough storage to achieve the desired value.
3355 * @param freeStorageSize The number of bytes of storage to be
3356 * freed by the system. Say if freeStorageSize is XX,
3357 * and the current free storage is YY,
3358 * if XX is less than YY, just return. if not free XX-YY number
3359 * of bytes if possible.
3360 * @param observer call back used to notify when
3361 * the operation is completed
3366 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
3369 * Free storage by deleting LRU sorted list of cache files across
3370 * all applications. If the currently available free storage
3371 * on the device is greater than or equal to the requested
3372 * free storage, no cache files are cleared. If the currently
3373 * available storage on the device is less than the requested
3374 * free storage, some or all of the cache files across
3375 * all applications are deleted (based on last accessed time)
3376 * to increase the free storage space on the device to
3377 * the requested value. There is no guarantee that clearing all
3378 * the cache files from all applications will clear up
3379 * enough storage to achieve the desired value.
3380 * @param freeStorageSize The number of bytes of storage to be
3381 * freed by the system. Say if freeStorageSize is XX,
3382 * and the current free storage is YY,
3383 * if XX is less than YY, just return. if not free XX-YY number
3384 * of bytes if possible.
3385 * @param pi IntentSender call back used to
3386 * notify when the operation is completed.May be null
3387 * to indicate that no call back is desired.
3391 public abstract void freeStorage(long freeStorageSize, IntentSender pi);
3394 * Retrieve the size information for a package.
3395 * Since this may take a little while, the result will
3396 * be posted back to the given observer. The calling context
3397 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
3399 * @param packageName The name of the package whose size information is to be retrieved
3400 * @param userHandle The user whose size information should be retrieved.
3401 * @param observer An observer callback to get notified when the operation
3403 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
3404 * The observer's callback is invoked with a PackageStats object(containing the
3405 * code, data and cache sizes of the package) and a boolean value representing
3406 * the status of the operation. observer may be null to indicate that
3407 * no callback is desired.
3411 public abstract void getPackageSizeInfo(String packageName, int userHandle,
3412 IPackageStatsObserver observer);
3415 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
3416 * returns the size for the calling user.
3420 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
3421 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
3425 * @deprecated This function no longer does anything; it was an old
3426 * approach to managing preferred activities, which has been superseded
3427 * by (and conflicts with) the modern activity-based preferences.
3430 public abstract void addPackageToPreferred(String packageName);
3433 * @deprecated This function no longer does anything; it was an old
3434 * approach to managing preferred activities, which has been superseded
3435 * by (and conflicts with) the modern activity-based preferences.
3438 public abstract void removePackageFromPreferred(String packageName);
3441 * Retrieve the list of all currently configured preferred packages. The
3442 * first package on the list is the most preferred, the last is the
3445 * @param flags Additional option flags. Use any combination of
3446 * {@link #GET_ACTIVITIES},
3447 * {@link #GET_GIDS},
3448 * {@link #GET_CONFIGURATIONS},
3449 * {@link #GET_INSTRUMENTATION},
3450 * {@link #GET_PERMISSIONS},
3451 * {@link #GET_PROVIDERS},
3452 * {@link #GET_RECEIVERS},
3453 * {@link #GET_SERVICES},
3454 * {@link #GET_SIGNATURES}, to modify the data returned.
3456 * @return Returns a list of PackageInfo objects describing each
3457 * preferred application, in order of preference.
3459 * @see #GET_ACTIVITIES
3461 * @see #GET_CONFIGURATIONS
3462 * @see #GET_INSTRUMENTATION
3463 * @see #GET_PERMISSIONS
3464 * @see #GET_PROVIDERS
3465 * @see #GET_RECEIVERS
3466 * @see #GET_SERVICES
3467 * @see #GET_SIGNATURES
3469 public abstract List<PackageInfo> getPreferredPackages(int flags);
3472 * @deprecated This is a protected API that should not have been available
3473 * to third party applications. It is the platform's responsibility for
3474 * assigning preferred activities and this cannot be directly modified.
3476 * Add a new preferred activity mapping to the system. This will be used
3477 * to automatically select the given activity component when
3478 * {@link Context#startActivity(Intent) Context.startActivity()} finds
3479 * multiple matching activities and also matches the given filter.
3481 * @param filter The set of intents under which this activity will be
3483 * @param match The IntentFilter match category that this preference
3485 * @param set The set of activities that the user was picking from when
3486 * this preference was made.
3487 * @param activity The component name of the activity that is to be
3491 public abstract void addPreferredActivity(IntentFilter filter, int match,
3492 ComponentName[] set, ComponentName activity);
3495 * Same as {@link #addPreferredActivity(IntentFilter, int,
3496 ComponentName[], ComponentName)}, but with a specific userId to apply the preference
3500 public void addPreferredActivity(IntentFilter filter, int match,
3501 ComponentName[] set, ComponentName activity, int userId) {
3502 throw new RuntimeException("Not implemented. Must override in a subclass.");
3506 * @deprecated This is a protected API that should not have been available
3507 * to third party applications. It is the platform's responsibility for
3508 * assigning preferred activities and this cannot be directly modified.
3510 * Replaces an existing preferred activity mapping to the system, and if that were not present
3511 * adds a new preferred activity. This will be used
3512 * to automatically select the given activity component when
3513 * {@link Context#startActivity(Intent) Context.startActivity()} finds
3514 * multiple matching activities and also matches the given filter.
3516 * @param filter The set of intents under which this activity will be
3518 * @param match The IntentFilter match category that this preference
3520 * @param set The set of activities that the user was picking from when
3521 * this preference was made.
3522 * @param activity The component name of the activity that is to be
3527 public abstract void replacePreferredActivity(IntentFilter filter, int match,
3528 ComponentName[] set, ComponentName activity);
3531 * Remove all preferred activity mappings, previously added with
3532 * {@link #addPreferredActivity}, from the
3533 * system whose activities are implemented in the given package name.
3534 * An application can only clear its own package(s).
3536 * @param packageName The name of the package whose preferred activity
3537 * mappings are to be removed.
3539 public abstract void clearPackagePreferredActivities(String packageName);
3542 * Retrieve all preferred activities, previously added with
3543 * {@link #addPreferredActivity}, that are
3544 * currently registered with the system.
3546 * @param outFilters A list in which to place the filters of all of the
3547 * preferred activities, or null for none.
3548 * @param outActivities A list in which to place the component names of
3549 * all of the preferred activities, or null for none.
3550 * @param packageName An option package in which you would like to limit
3551 * the list. If null, all activities will be returned; if non-null, only
3552 * those activities in the given package are returned.
3554 * @return Returns the total number of registered preferred activities
3555 * (the number of distinct IntentFilter records, not the number of unique
3556 * activity components) that were found.
3558 public abstract int getPreferredActivities(List<IntentFilter> outFilters,
3559 List<ComponentName> outActivities, String packageName);
3562 * Ask for the set of available 'home' activities and the current explicit
3566 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
3569 * Set the enabled setting for a package component (activity, receiver, service, provider).
3570 * This setting will override any enabled state which may have been set by the component in its
3573 * @param componentName The component to enable
3574 * @param newState The new enabled state for the component. The legal values for this state
3576 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
3577 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
3579 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3580 * The last one removes the setting, thereby restoring the component's state to
3581 * whatever was set in it's manifest (or enabled, by default).
3582 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3584 public abstract void setComponentEnabledSetting(ComponentName componentName,
3585 int newState, int flags);
3589 * Return the enabled setting for a package component (activity,
3590 * receiver, service, provider). This returns the last value set by
3591 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
3592 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3593 * the value originally specified in the manifest has not been modified.
3595 * @param componentName The component to retrieve.
3596 * @return Returns the current enabled state for the component. May
3597 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3598 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3599 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
3600 * component's enabled state is based on the original information in
3601 * the manifest as found in {@link ComponentInfo}.
3603 public abstract int getComponentEnabledSetting(ComponentName componentName);
3606 * Set the enabled setting for an application
3607 * This setting will override any enabled state which may have been set by the application in
3608 * its manifest. It also overrides the enabled state set in the manifest for any of the
3609 * application's components. It does not override any enabled state set by
3610 * {@link #setComponentEnabledSetting} for any of the application's components.
3612 * @param packageName The package name of the application to enable
3613 * @param newState The new enabled state for the component. The legal values for this state
3615 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
3616 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
3618 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3619 * The last one removes the setting, thereby restoring the applications's state to
3620 * whatever was set in its manifest (or enabled, by default).
3621 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3623 public abstract void setApplicationEnabledSetting(String packageName,
3624 int newState, int flags);
3627 * Return the enabled setting for an application. This returns
3628 * the last value set by
3629 * {@link #setApplicationEnabledSetting(String, int, int)}; in most
3630 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3631 * the value originally specified in the manifest has not been modified.
3633 * @param packageName The package name of the application to retrieve.
3634 * @return Returns the current enabled state for the application. May
3635 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3636 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3637 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
3638 * application's enabled state is based on the original information in
3639 * the manifest as found in {@link ComponentInfo}.
3640 * @throws IllegalArgumentException if the named package does not exist.
3642 public abstract int getApplicationEnabledSetting(String packageName);
3645 * Puts the package in a blocked state, which is almost like an uninstalled state,
3646 * making the package unavailable, but it doesn't remove the data or the actual
3650 public abstract boolean setApplicationBlockedSettingAsUser(String packageName, boolean blocked,
3651 UserHandle userHandle);
3654 * Returns the blocked state of a package.
3655 * @see #setApplicationBlockedSettingAsUser(String, boolean, UserHandle)
3658 public abstract boolean getApplicationBlockedSettingAsUser(String packageName,
3659 UserHandle userHandle);
3662 * Return whether the device has been booted into safe mode.
3664 public abstract boolean isSafeMode();
3667 * Return the {@link KeySet} associated with the String alias for this
3670 * @param alias The alias for a given {@link KeySet} as defined in the
3671 * application's AndroidManifest.xml.
3673 public abstract KeySet getKeySetByAlias(String packageName, String alias);
3675 /** Return the signing {@link KeySet} for this application. */
3676 public abstract KeySet getSigningKeySet(String packageName);
3679 * Return whether the package denoted by packageName has been signed by all
3680 * of the keys specified by the {@link KeySet} ks. This will return true if
3681 * the package has been signed by additional keys (a superset) as well.
3682 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
3684 public abstract boolean isSignedBy(String packageName, KeySet ks);
3687 * Return whether the package denoted by packageName has been signed by all
3688 * of, and only, the keys specified by the {@link KeySet} ks. Compare to
3689 * {@link #isSignedBy(String packageName, KeySet ks)}.
3691 public abstract boolean isSignedByExactly(String packageName, KeySet ks);
3694 * Attempts to move package resources from internal to external media or vice versa.
3695 * Since this may take a little while, the result will
3696 * be posted back to the given observer. This call may fail if the calling context
3697 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
3698 * named package cannot be found, or if the named package is a "system package".
3700 * @param packageName The name of the package to delete
3701 * @param observer An observer callback to get notified when the package move is
3702 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
3703 * called when that happens. observer may be null to indicate that no callback is desired.
3704 * @param flags To indicate install location {@link #MOVE_INTERNAL} or
3705 * {@link #MOVE_EXTERNAL_MEDIA}
3709 public abstract void movePackage(
3710 String packageName, IPackageMoveObserver observer, int flags);
3713 * Returns the device identity that verifiers can use to associate their scheme to a particular
3714 * device. This should not be used by anything other than a package verifier.
3716 * @return identity that uniquely identifies current device
3719 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
3722 * Return interface that offers the ability to install, upgrade, and remove
3723 * applications on the device.
3725 public abstract PackageInstaller getInstaller();
3728 * Returns the data directory for a particular user and package, given the uid of the package.
3729 * @param uid uid of the package, including the userId and appId
3730 * @param packageName name of the package
3731 * @return the user-specific data directory for the package
3734 public static String getDataDirForUser(int userId, String packageName) {
3735 // TODO: This should be shared with Installer's knowledge of user directory
3736 return Environment.getDataDirectory().toString() + "/user/" + userId
3737 + "/" + packageName;
3741 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
3742 * user with id sourceUserId can also be be resolved by activities in the user with id
3743 * targetUserId if they match the specified intent filter.
3744 * @param filter the {@link IntentFilter} the intent has to match
3745 * @param removable if set to false, {@link clearCrossProfileIntentFilters} will not remove this
3746 * {@link CrossProfileIntentFilter}
3749 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
3750 int targetUserId, int flags);
3753 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
3754 * source, and have been set by the profile owner
3755 * @param sourceUserId
3758 public abstract void clearCrossProfileIntentFilters(int sourceUserId);
3761 * Forwards all intents for {@link packageName} for user {@link sourceUserId} to user
3762 * {@link targetUserId}.
3765 public abstract void addCrossProfileIntentsForPackage(String packageName,
3766 int sourceUserId, int targetUserId);
3770 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
3773 public abstract boolean isPackageAvailable(String packageName);