public class MockPackageManager extends PackageManager
PackageManager
class. All methods are non-functional and throw
UnsupportedOperationException
. Override it to provide the operations that you
need.PackageManager.NameNotFoundException
ACTION_CLEAN_EXTERNAL_STORAGE, COMPONENT_ENABLED_STATE_DEFAULT, COMPONENT_ENABLED_STATE_DISABLED, COMPONENT_ENABLED_STATE_DISABLED_USER, COMPONENT_ENABLED_STATE_ENABLED, DELETE_ALL_USERS, DELETE_FAILED_DEVICE_POLICY_MANAGER, DELETE_FAILED_INTERNAL_ERROR, DELETE_KEEP_DATA, DELETE_SUCCEEDED, DONT_KILL_APP, EXTRA_VERIFICATION_ID, EXTRA_VERIFICATION_INSTALL_FLAGS, EXTRA_VERIFICATION_INSTALLER_PACKAGE, EXTRA_VERIFICATION_INSTALLER_UID, EXTRA_VERIFICATION_PACKAGE_NAME, EXTRA_VERIFICATION_RESULT, EXTRA_VERIFICATION_URI, EXTRA_VERIFICATION_VERSION_CODE, FEATURE_AUDIO_LOW_LATENCY, FEATURE_BLUETOOTH, FEATURE_CAMERA, FEATURE_CAMERA_ANY, FEATURE_CAMERA_AUTOFOCUS, FEATURE_CAMERA_FLASH, FEATURE_CAMERA_FRONT, FEATURE_FAKETOUCH, FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT, FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND, FEATURE_LIVE_WALLPAPER, FEATURE_LOCATION, FEATURE_LOCATION_GPS, FEATURE_LOCATION_NETWORK, FEATURE_MICROPHONE, FEATURE_NFC, FEATURE_SCREEN_LANDSCAPE, FEATURE_SCREEN_PORTRAIT, FEATURE_SENSOR_ACCELEROMETER, FEATURE_SENSOR_BAROMETER, FEATURE_SENSOR_COMPASS, FEATURE_SENSOR_GYROSCOPE, FEATURE_SENSOR_LIGHT, FEATURE_SENSOR_PROXIMITY, FEATURE_SIP, FEATURE_SIP_VOIP, FEATURE_TELEPHONY, FEATURE_TELEPHONY_CDMA, FEATURE_TELEPHONY_GSM, FEATURE_TELEVISION, FEATURE_TOUCHSCREEN, FEATURE_TOUCHSCREEN_MULTITOUCH, FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT, FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND, FEATURE_USB_ACCESSORY, FEATURE_USB_HOST, FEATURE_WIFI, FEATURE_WIFI_DIRECT, GET_ACTIVITIES, GET_CONFIGURATIONS, GET_DISABLED_COMPONENTS, GET_GIDS, GET_INSTRUMENTATION, GET_INTENT_FILTERS, GET_META_DATA, GET_PERMISSIONS, GET_PROVIDERS, GET_RECEIVERS, GET_RESOLVED_FILTER, GET_SERVICES, GET_SHARED_LIBRARY_FILES, GET_SIGNATURES, GET_UNINSTALLED_PACKAGES, GET_URI_PERMISSION_PATTERNS, INSTALL_ALL_USERS, INSTALL_ALLOW_DOWNGRADE, INSTALL_ALLOW_TEST, INSTALL_EXTERNAL, INSTALL_FAILED_ALREADY_EXISTS, INSTALL_FAILED_CONFLICTING_PROVIDER, INSTALL_FAILED_CONTAINER_ERROR, INSTALL_FAILED_CPU_ABI_INCOMPATIBLE, INSTALL_FAILED_DEXOPT, INSTALL_FAILED_DUPLICATE_PACKAGE, INSTALL_FAILED_INSUFFICIENT_STORAGE, INSTALL_FAILED_INTERNAL_ERROR, INSTALL_FAILED_INVALID_APK, INSTALL_FAILED_INVALID_INSTALL_LOCATION, INSTALL_FAILED_INVALID_URI, INSTALL_FAILED_MEDIA_UNAVAILABLE, INSTALL_FAILED_MISSING_FEATURE, INSTALL_FAILED_MISSING_SHARED_LIBRARY, INSTALL_FAILED_NEWER_SDK, INSTALL_FAILED_NO_SHARED_USER, INSTALL_FAILED_OLDER_SDK, INSTALL_FAILED_PACKAGE_CHANGED, INSTALL_FAILED_REPLACE_COULDNT_DELETE, INSTALL_FAILED_SHARED_USER_INCOMPATIBLE, INSTALL_FAILED_TEST_ONLY, INSTALL_FAILED_UID_CHANGED, INSTALL_FAILED_UPDATE_INCOMPATIBLE, INSTALL_FAILED_VERIFICATION_FAILURE, INSTALL_FAILED_VERIFICATION_TIMEOUT, INSTALL_FAILED_VERSION_DOWNGRADE, INSTALL_FORWARD_LOCK, INSTALL_FROM_ADB, INSTALL_INTERNAL, INSTALL_PARSE_FAILED_BAD_MANIFEST, INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME, INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID, INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING, INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES, INSTALL_PARSE_FAILED_MANIFEST_EMPTY, INSTALL_PARSE_FAILED_MANIFEST_MALFORMED, INSTALL_PARSE_FAILED_NO_CERTIFICATES, INSTALL_PARSE_FAILED_NOT_APK, INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION, INSTALL_REPLACE_EXISTING, INSTALL_SUCCEEDED, MATCH_DEFAULT_ONLY, MAXIMUM_VERIFICATION_TIMEOUT, MOVE_EXTERNAL_MEDIA, MOVE_FAILED_DOESNT_EXIST, MOVE_FAILED_FORWARD_LOCKED, MOVE_FAILED_INSUFFICIENT_STORAGE, MOVE_FAILED_INTERNAL_ERROR, MOVE_FAILED_INVALID_LOCATION, MOVE_FAILED_OPERATION_PENDING, MOVE_FAILED_SYSTEM_PACKAGE, MOVE_INTERNAL, MOVE_SUCCEEDED, PERMISSION_DENIED, PERMISSION_GRANTED, SIGNATURE_FIRST_NOT_SIGNED, SIGNATURE_MATCH, SIGNATURE_NEITHER_SIGNED, SIGNATURE_NO_MATCH, SIGNATURE_SECOND_NOT_SIGNED, SIGNATURE_UNKNOWN_PACKAGE, VERIFICATION_ALLOW, VERIFICATION_ALLOW_WITHOUT_SUFFICIENT, VERIFICATION_REJECT
Constructor and Description |
---|
MockPackageManager() |
Modifier and Type | Method and Description |
---|---|
void |
addPackageToPreferred(String packageName) |
boolean |
addPermission(PermissionInfo info)
Add a new dynamic permission to the system.
|
boolean |
addPermissionAsync(PermissionInfo info)
Like
PackageManager.addPermission(PermissionInfo) but asynchronously
persists the package manager state after returning from the call,
allowing it to return quicker and batch a series of adds at the
expense of no guarantee the added permission will be retained if
the device is rebooted before it is written. |
void |
addPreferredActivity(IntentFilter filter,
int match,
ComponentName[] set,
ComponentName activity) |
String[] |
canonicalToCurrentPackageNames(String[] names)
Map from a packages canonical name to the current name in use on the device.
|
int |
checkPermission(String permName,
String pkgName)
Check whether a particular package has been granted a particular
permission.
|
int |
checkSignatures(int uid1,
int uid2)
Like
PackageManager.checkSignatures(String, String) , but takes UIDs of
the two packages to be checked. |
int |
checkSignatures(String pkg1,
String pkg2)
Compare the signatures of two packages to determine if the same
signature appears in both of them.
|
void |
clearApplicationUserData(String packageName,
IPackageDataObserver observer)
Attempts to clear the user data directory of an application.
|
void |
clearPackagePreferredActivities(String packageName)
Remove all preferred activity mappings, previously added with
PackageManager.addPreferredActivity(android.content.IntentFilter, int, android.content.ComponentName[], android.content.ComponentName) , from the
system whose activities are implemented in the given package name. |
String[] |
currentToCanonicalPackageNames(String[] names)
Map from the current package names in use on the device to whatever
the current canonical name of that package is.
|
void |
deleteApplicationCacheFiles(String packageName,
IPackageDataObserver observer)
Attempts to delete the cache files associated with an application.
|
void |
deletePackage(String packageName,
IPackageDeleteObserver observer,
int flags)
Attempts to delete a package.
|
void |
extendVerificationTimeout(int id,
int verificationCodeAtTimeout,
long millisecondsToDelay)
Allows a package listening to the
package verification
broadcast to extend the default timeout for a response and declare what
action to perform after the timeout occurs. |
void |
freeStorage(long idealStorageSize,
IntentSender pi)
Free storage by deleting LRU sorted list of cache files across
all applications.
|
void |
freeStorageAndNotify(long idealStorageSize,
IPackageDataObserver observer)
Free storage by deleting LRU sorted list of cache files across
all applications.
|
Drawable |
getActivityIcon(ComponentName activityName)
Retrieve the icon associated with an activity.
|
Drawable |
getActivityIcon(Intent intent)
Retrieve the icon associated with an Intent.
|
ActivityInfo |
getActivityInfo(ComponentName className,
int flags)
Retrieve all of the information we know about a particular activity
class.
|
Drawable |
getActivityLogo(ComponentName activityName)
Retrieve the logo associated with an activity.
|
Drawable |
getActivityLogo(Intent intent)
Retrieve the logo associated with an Intent.
|
List<PermissionGroupInfo> |
getAllPermissionGroups(int flags)
Retrieve all of the known permission groups in the system.
|
int |
getApplicationEnabledSetting(String packageName)
Return the the enabled setting for an application.
|
Drawable |
getApplicationIcon(ApplicationInfo info)
Retrieve the icon associated with an application.
|
Drawable |
getApplicationIcon(String packageName)
Retrieve the icon associated with an application.
|
ApplicationInfo |
getApplicationInfo(String packageName,
int flags)
Retrieve all of the information we know about a particular
package/application.
|
CharSequence |
getApplicationLabel(ApplicationInfo info)
Return the label to use for this application.
|
Drawable |
getApplicationLogo(ApplicationInfo info)
Retrieve the logo associated with an application.
|
Drawable |
getApplicationLogo(String packageName)
Retrieve the logo associated with an application.
|
int |
getComponentEnabledSetting(ComponentName componentName)
Return the the enabled setting for a package component (activity,
receiver, service, provider).
|
Drawable |
getDefaultActivityIcon()
Return the generic icon for an activity that is used when no specific
icon is defined.
|
Drawable |
getDrawable(String packageName,
int resid,
ApplicationInfo appInfo)
Retrieve an image from a package.
|
List<ApplicationInfo> |
getInstalledApplications(int flags)
Return a List of all application packages that are installed on the
device.
|
List<PackageInfo> |
getInstalledPackages(int flags)
Return a List of all packages that are installed
on the device.
|
List<PackageInfo> |
getInstalledPackages(int flags,
int userId)
Return a List of all packages that are installed on the device, for a specific user.
|
String |
getInstallerPackageName(String packageName)
Retrieve the package name of the application that installed a package.
|
InstrumentationInfo |
getInstrumentationInfo(ComponentName className,
int flags)
Retrieve all of the information we know about a particular
instrumentation class.
|
Intent |
getLaunchIntentForPackage(String packageName)
Return a "good" intent to launch a front-door activity in a package,
for use for example to implement an "open" button when browsing through
packages.
|
String |
getNameForUid(int uid)
Retrieve the official name associated with a user id.
|
PackageInfo |
getPackageArchiveInfo(String archiveFilePath,
int flags)
Retrieve overall information about an application package defined
in a package archive file
|
int[] |
getPackageGids(String packageName)
Return an array of all of the secondary group-ids that have been
assigned to a package.
|
PackageInfo |
getPackageInfo(String packageName,
int flags)
Retrieve overall information about an application package that is
installed on the system.
|
String[] |
getPackagesForUid(int uid)
Retrieve the names of all packages that are associated with a particular
user id.
|
void |
getPackageSizeInfo(String packageName,
int userHandle,
IPackageStatsObserver observer)
Retrieve the size information for a package.
|
PermissionGroupInfo |
getPermissionGroupInfo(String name,
int flags)
Retrieve all of the information we know about a particular group of
permissions.
|
PermissionInfo |
getPermissionInfo(String name,
int flags)
Retrieve all of the information we know about a particular permission.
|
int |
getPreferredActivities(List<IntentFilter> outFilters,
List<ComponentName> outActivities,
String packageName)
Retrieve all preferred activities, previously added with
PackageManager.addPreferredActivity(android.content.IntentFilter, int, android.content.ComponentName[], android.content.ComponentName) , that are
currently registered with the system. |
List<PackageInfo> |
getPreferredPackages(int flags)
Retrieve the list of all currently configured preferred packages.
|
ProviderInfo |
getProviderInfo(ComponentName className,
int flags)
Retrieve all of the information we know about a particular content
provider class.
|
ActivityInfo |
getReceiverInfo(ComponentName className,
int flags)
Retrieve all of the information we know about a particular receiver
class.
|
Resources |
getResourcesForActivity(ComponentName activityName)
Retrieve the resources associated with an activity.
|
Resources |
getResourcesForApplication(ApplicationInfo app)
Retrieve the resources for an application.
|
Resources |
getResourcesForApplication(String appPackageName)
Retrieve the resources associated with an application.
|
Resources |
getResourcesForApplicationAsUser(String appPackageName,
int userId) |
ServiceInfo |
getServiceInfo(ComponentName className,
int flags)
Retrieve all of the information we know about a particular service
class.
|
FeatureInfo[] |
getSystemAvailableFeatures()
Get a list of features that are available on the
system.
|
String[] |
getSystemSharedLibraryNames()
Get a list of shared libraries that are available on the
system.
|
CharSequence |
getText(String packageName,
int resid,
ApplicationInfo appInfo)
Retrieve text from a package.
|
int |
getUidForSharedUser(String sharedUserName)
Return the user id associated with a shared user name.
|
VerifierDeviceIdentity |
getVerifierDeviceIdentity()
Returns the device identity that verifiers can use to associate their scheme to a particular
device.
|
XmlResourceParser |
getXml(String packageName,
int resid,
ApplicationInfo appInfo)
Retrieve an XML file from a package.
|
void |
grantPermission(String packageName,
String permissionName)
Grant a permission to an application which the application does not
already have.
|
boolean |
hasSystemFeature(String name)
Check whether the given feature name is one of the available
features as returned by
PackageManager.getSystemAvailableFeatures() . |
int |
installExistingPackage(String packageName)
If there is already an application with the given package name installed
on the system for other users, also install it for the calling user.
|
void |
installPackage(Uri packageURI,
IPackageInstallObserver observer,
int flags,
String installerPackageName) |
void |
installPackageWithVerification(Uri packageURI,
IPackageInstallObserver observer,
int flags,
String installerPackageName,
Uri verificationURI,
ManifestDigest manifestDigest,
ContainerEncryptionParams encryptionParams)
Similar to
PackageManager.installPackage(Uri, IPackageInstallObserver, int, String) but
with an extra verification file provided. |
void |
installPackageWithVerificationAndEncryption(Uri packageURI,
IPackageInstallObserver observer,
int flags,
String installerPackageName,
VerificationParams verificationParams,
ContainerEncryptionParams encryptionParams)
Similar to
PackageManager.installPackage(Uri, IPackageInstallObserver, int, String) but
with an extra verification information provided. |
boolean |
isSafeMode()
Return whether the device has been booted into safe mode.
|
void |
movePackage(String packageName,
IPackageMoveObserver observer,
int flags)
Attempts to move package resources from internal to external media or vice versa.
|
List<ResolveInfo> |
queryBroadcastReceivers(Intent intent,
int flags)
Retrieve all receivers that can handle a broadcast of the given intent.
|
List<ResolveInfo> |
queryBroadcastReceivers(Intent intent,
int flags,
int userId)
Retrieve all receivers that can handle a broadcast of the given intent, for a specific
user.
|
List<ProviderInfo> |
queryContentProviders(String processName,
int uid,
int flags)
Retrieve content provider information.
|
List<InstrumentationInfo> |
queryInstrumentation(String targetPackage,
int flags)
Retrieve information about available instrumentation code.
|
List<ResolveInfo> |
queryIntentActivities(Intent intent,
int flags)
Retrieve all activities that can be performed for the given intent.
|
List<ResolveInfo> |
queryIntentActivitiesAsUser(Intent intent,
int flags,
int userId)
Retrieve all activities that can be performed for the given intent, for a specific user.
|
List<ResolveInfo> |
queryIntentActivityOptions(ComponentName caller,
Intent[] specifics,
Intent intent,
int flags)
Retrieve a set of activities that should be presented to the user as
similar options.
|
List<ResolveInfo> |
queryIntentServices(Intent intent,
int flags)
Retrieve all services that can match the given intent.
|
List<ResolveInfo> |
queryIntentServicesAsUser(Intent intent,
int flags,
int userId)
Retrieve all services that can match the given intent for a given user.
|
List<PermissionInfo> |
queryPermissionsByGroup(String group,
int flags)
Query for all of the permissions associated with a particular group.
|
void |
removePackageFromPreferred(String packageName) |
void |
removePermission(String name)
Removes a permission that was previously added with
PackageManager.addPermission(PermissionInfo) . |
void |
replacePreferredActivity(IntentFilter filter,
int match,
ComponentName[] set,
ComponentName activity) |
ResolveInfo |
resolveActivity(Intent intent,
int flags)
Determine the best action to perform for a given Intent.
|
ResolveInfo |
resolveActivityAsUser(Intent intent,
int flags,
int userId)
Determine the best action to perform for a given Intent for a given user.
|
ProviderInfo |
resolveContentProvider(String name,
int flags)
Find a single content provider by its base path name.
|
ResolveInfo |
resolveService(Intent intent,
int flags)
Determine the best service to handle for a given Intent.
|
void |
revokePermission(String packageName,
String permissionName)
Revoke a permission that was previously granted by
PackageManager.grantPermission(java.lang.String, java.lang.String) . |
void |
setApplicationEnabledSetting(String packageName,
int newState,
int flags)
Set the enabled setting for an application
This setting will override any enabled state which may have been set by the application in
its manifest.
|
void |
setComponentEnabledSetting(ComponentName componentName,
int newState,
int flags)
Set the enabled setting for a package component (activity, receiver, service, provider).
|
void |
setInstallerPackageName(String targetPackage,
String installerPackageName)
Change the installer associated with a given package.
|
void |
verifyPendingInstall(int id,
int verificationCode)
Allows a package listening to the
package verification
broadcast to respond to the package manager. |
addPreferredActivity, getDataDirForUser, getPackageSizeInfo
public PackageInfo getPackageInfo(String packageName, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if a package with the given name can
not be found on the system.
getPackageInfo
in class PackageManager
packageName
- The full name (i.e. com.google.apps.contacts) of the
desired package.flags
- Additional option flags. Use any combination of
PackageManager.GET_ACTIVITIES
, PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
, PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
, PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
, PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
, PackageManager.GET_UNINSTALLED_PACKAGES
to
modify the data returned.PackageManager.NameNotFoundException
PackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
,
PackageManager.GET_UNINSTALLED_PACKAGES
public String[] currentToCanonicalPackageNames(String[] names)
PackageManager
currentToCanonicalPackageNames
in class PackageManager
names
- Array of current names to be mapped.public String[] canonicalToCurrentPackageNames(String[] names)
PackageManager
canonicalToCurrentPackageNames
in class PackageManager
names
- Array of new names to be mapped.public Intent getLaunchIntentForPackage(String packageName)
PackageManager
Intent.CATEGORY_INFO
, next for a
main activity in the category Intent.CATEGORY_LAUNCHER
, or return
null if neither are found.
Throws PackageManager.NameNotFoundException
if a package with the given
name can not be found on the system.
getLaunchIntentForPackage
in class PackageManager
packageName
- The name of the package to inspect.public int[] getPackageGids(String packageName) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if a package with the given
name can not be found on the system.
getPackageGids
in class PackageManager
packageName
- The full name (i.e. com.google.apps.contacts) of the
desired package.PackageManager.NameNotFoundException
public PermissionInfo getPermissionInfo(String name, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if a permission with the given
name can not be found on the system.
getPermissionInfo
in class PackageManager
name
- The fully qualified name (i.e. com.google.permission.LOGIN)
of the permission you are interested in.flags
- Additional option flags. Use PackageManager.GET_META_DATA
to
retrieve any meta-data associated with the permission.PermissionInfo
containing information about the
permission.PackageManager.NameNotFoundException
public List<PermissionInfo> queryPermissionsByGroup(String group, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if the given group does not
exist.
queryPermissionsByGroup
in class PackageManager
group
- The fully qualified name (i.e. com.google.permission.LOGIN)
of the permission group you are interested in. Use null to
find all of the permissions not associated with a group.flags
- Additional option flags. Use PackageManager.GET_META_DATA
to
retrieve any meta-data associated with the permissions.PermissionInfo
containing information
about all of the permissions in the given group.PackageManager.NameNotFoundException
public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if a permission group with the given
name can not be found on the system.
getPermissionGroupInfo
in class PackageManager
name
- The fully qualified name (i.e. com.google.permission_group.APPS)
of the permission you are interested in.flags
- Additional option flags. Use PackageManager.GET_META_DATA
to
retrieve any meta-data associated with the permission group.PermissionGroupInfo
containing information
about the permission.PackageManager.NameNotFoundException
public List<PermissionGroupInfo> getAllPermissionGroups(int flags)
PackageManager
getAllPermissionGroups
in class PackageManager
flags
- Additional option flags. Use PackageManager.GET_META_DATA
to
retrieve any meta-data associated with the permission group.PermissionGroupInfo
containing
information about all of the known permission groups.public ApplicationInfo getApplicationInfo(String packageName, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if an application with the given
package name can not be found on the system.
getApplicationInfo
in class PackageManager
packageName
- The full name (i.e. com.google.apps.contacts) of an
application.flags
- Additional option flags. Use any combination of
PackageManager.GET_META_DATA
, PackageManager.GET_SHARED_LIBRARY_FILES
,
PackageManager.GET_UNINSTALLED_PACKAGES
to modify the data returned.ApplicationInfo
Returns ApplicationInfo object containing
information about the package.
If flag GET_UNINSTALLED_PACKAGES is set and if the package is not
found in the list of installed applications,
the application information is retrieved from the
list of uninstalled applications(which includes
installed applications as well as applications
with data directory ie applications which had been
deleted with DONT_DELTE_DATA flag set).PackageManager.NameNotFoundException
PackageManager.GET_META_DATA
,
PackageManager.GET_SHARED_LIBRARY_FILES
,
PackageManager.GET_UNINSTALLED_PACKAGES
public ActivityInfo getActivityInfo(ComponentName className, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if an activity with the given
class name can not be found on the system.
getActivityInfo
in class PackageManager
className
- The full component name (i.e.
com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
class.flags
- Additional option flags. Use any combination of
PackageManager.GET_META_DATA
, PackageManager.GET_SHARED_LIBRARY_FILES
,
to modify the data (in ApplicationInfo) returned.ActivityInfo
containing information about the activity.PackageManager.NameNotFoundException
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_META_DATA
,
PackageManager.GET_SHARED_LIBRARY_FILES
public ActivityInfo getReceiverInfo(ComponentName className, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if a receiver with the given
class name can not be found on the system.
getReceiverInfo
in class PackageManager
className
- The full component name (i.e.
com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
class.flags
- Additional option flags. Use any combination of
PackageManager.GET_META_DATA
, PackageManager.GET_SHARED_LIBRARY_FILES
,
to modify the data returned.ActivityInfo
containing information about the receiver.PackageManager.NameNotFoundException
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_META_DATA
,
PackageManager.GET_SHARED_LIBRARY_FILES
public ServiceInfo getServiceInfo(ComponentName className, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if a service with the given
class name can not be found on the system.
getServiceInfo
in class PackageManager
className
- The full component name (i.e.
com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
class.flags
- Additional option flags. Use any combination of
PackageManager.GET_META_DATA
, PackageManager.GET_SHARED_LIBRARY_FILES
,
to modify the data returned.PackageManager.NameNotFoundException
PackageManager.GET_META_DATA
,
PackageManager.GET_SHARED_LIBRARY_FILES
public ProviderInfo getProviderInfo(ComponentName className, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if a provider with the given
class name can not be found on the system.
getProviderInfo
in class PackageManager
className
- The full component name (i.e.
com.google.providers.media/com.google.providers.media.MediaProvider) of a
ContentProvider class.flags
- Additional option flags. Use any combination of
PackageManager.GET_META_DATA
, PackageManager.GET_SHARED_LIBRARY_FILES
,
to modify the data returned.PackageManager.NameNotFoundException
PackageManager.GET_META_DATA
,
PackageManager.GET_SHARED_LIBRARY_FILES
public List<PackageInfo> getInstalledPackages(int flags)
PackageManager
getInstalledPackages
in class PackageManager
flags
- Additional option flags. Use any combination of
PackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
,
PackageManager.GET_UNINSTALLED_PACKAGES
to modify the data returned.PackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
,
PackageManager.GET_UNINSTALLED_PACKAGES
public List<PackageInfo> getInstalledPackages(int flags, int userId)
PackageManager
getInstalledPackages
in class PackageManager
flags
- Additional option flags. Use any combination of
PackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
,
PackageManager.GET_UNINSTALLED_PACKAGES
to modify the data returned.userId
- The user for whom the installed packages are to be listedPackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
,
PackageManager.GET_UNINSTALLED_PACKAGES
public int checkPermission(String permName, String pkgName)
PackageManager
checkPermission
in class PackageManager
permName
- The name of the permission you are checking for,pkgName
- The name of the package you are checking against.PackageManager.PERMISSION_GRANTED
,
PackageManager.PERMISSION_DENIED
public boolean addPermission(PermissionInfo info)
PackageManager
<permission-tree>
tag in its manifest. A package can only add
permissions to trees that were defined by either its own package or
another with the same user id; a permission is in a tree if it
matches the name of the permission tree + ".": for example,
"com.foo.bar" is a member of the permission tree "com.foo".
It is good to make your permission tree name descriptive, because you are taking possession of that entire set of permission names. Thus, it must be under a domain you control, with a suffix that will not match any normal permissions that may be declared in any applications that are part of that domain.
New permissions must be added before any .apks are installed that use those permissions. Permissions you add through this method are remembered across reboots of the device. If the given permission already exists, the info you supply here will be used to update it.
addPermission
in class PackageManager
info
- Description of the permission to be added.PackageManager.removePermission(String)
public boolean addPermissionAsync(PermissionInfo info)
PackageManager
PackageManager.addPermission(PermissionInfo)
but asynchronously
persists the package manager state after returning from the call,
allowing it to return quicker and batch a series of adds at the
expense of no guarantee the added permission will be retained if
the device is rebooted before it is written.addPermissionAsync
in class PackageManager
public void removePermission(String name)
PackageManager
PackageManager.addPermission(PermissionInfo)
. The same ownership rules apply
-- you are only allowed to remove permissions that you are allowed
to add.removePermission
in class PackageManager
name
- The name of the permission to remove.PackageManager.addPermission(PermissionInfo)
public void grantPermission(String packageName, String permissionName)
PackageManager
grantPermission
in class PackageManager
packageName
- The name of the package that the permission will be
granted to.permissionName
- The name of the permission.public void revokePermission(String packageName, String permissionName)
PackageManager
PackageManager.grantPermission(java.lang.String, java.lang.String)
.revokePermission
in class PackageManager
packageName
- The name of the package that the permission will be
granted to.permissionName
- The name of the permission.public int checkSignatures(String pkg1, String pkg2)
PackageManager
checkSignatures
in class PackageManager
pkg1
- First package name whose signature will be compared.pkg2
- Second package name whose signature will be compared.PackageManager.SIGNATURE_MATCH
) if
all signatures match or < 0 if there is not a match (PackageManager.SIGNATURE_NO_MATCH
or PackageManager.SIGNATURE_UNKNOWN_PACKAGE
).PackageManager.checkSignatures(int, int)
,
PackageManager.SIGNATURE_MATCH
,
PackageManager.SIGNATURE_NO_MATCH
,
PackageManager.SIGNATURE_UNKNOWN_PACKAGE
public int checkSignatures(int uid1, int uid2)
PackageManager
PackageManager.checkSignatures(String, String)
, but takes UIDs of
the two packages to be checked. This can be useful, for example,
when doing the check in an IPC, where the UID is the only identity
available. It is functionally identical to determining the package
associated with the UIDs and checking their signatures.checkSignatures
in class PackageManager
uid1
- First UID whose signature will be compared.uid2
- Second UID whose signature will be compared.PackageManager.SIGNATURE_MATCH
) if
all signatures match or < 0 if there is not a match (PackageManager.SIGNATURE_NO_MATCH
or PackageManager.SIGNATURE_UNKNOWN_PACKAGE
).PackageManager.checkSignatures(String, String)
,
PackageManager.SIGNATURE_MATCH
,
PackageManager.SIGNATURE_NO_MATCH
,
PackageManager.SIGNATURE_UNKNOWN_PACKAGE
public String[] getPackagesForUid(int uid)
PackageManager
getPackagesForUid
in class PackageManager
uid
- The user id for which you would like to retrieve the
associated packages.public String getNameForUid(int uid)
PackageManager
getNameForUid
in class PackageManager
uid
- The user id for which you would like to retrieve a name.public int getUidForSharedUser(String sharedUserName)
PackageManager
getUidForSharedUser
in class PackageManager
sharedUserName
- The shared user name whose uid is to be retrieved.public List<ApplicationInfo> getInstalledApplications(int flags)
PackageManager
getInstalledApplications
in class PackageManager
flags
- Additional option flags. Use any combination of
PackageManager.GET_META_DATA
, PackageManager.GET_SHARED_LIBRARY_FILES
,
PackageManager.GET_UNINSTALLED_PACKAGES
to modify the data returned.PackageManager.GET_META_DATA
,
PackageManager.GET_SHARED_LIBRARY_FILES
,
PackageManager.GET_UNINSTALLED_PACKAGES
public ResolveInfo resolveActivity(Intent intent, int flags)
PackageManager
Intent.resolveActivity(android.content.pm.PackageManager)
finds an activity if a class has not
been explicitly specified.
Note: if using an implicit Intent (without an explicit ComponentName
specified), be sure to consider whether to set the PackageManager.MATCH_DEFAULT_ONLY
only flag. You need to do so to resolve the activity in the same way
that Context.startActivity(Intent)
and
Intent.resolveActivity(PackageManager)
do.
resolveActivity
in class PackageManager
intent
- An intent containing all of the desired specification
(action, data, type, category, and/or component).flags
- Additional option flags. The most important is
PackageManager.MATCH_DEFAULT_ONLY
, to limit the resolution to only
those activities that support the Intent.CATEGORY_DEFAULT
.PackageManager.MATCH_DEFAULT_ONLY
,
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId)
PackageManager
Intent.resolveActivity(android.content.pm.PackageManager)
finds an activity if a class has not
been explicitly specified.
Note: if using an implicit Intent (without an explicit ComponentName
specified), be sure to consider whether to set the PackageManager.MATCH_DEFAULT_ONLY
only flag. You need to do so to resolve the activity in the same way
that Context.startActivity(Intent)
and
Intent.resolveActivity(PackageManager)
do.
resolveActivityAsUser
in class PackageManager
intent
- An intent containing all of the desired specification
(action, data, type, category, and/or component).flags
- Additional option flags. The most important is
PackageManager.MATCH_DEFAULT_ONLY
, to limit the resolution to only
those activities that support the Intent.CATEGORY_DEFAULT
.userId
- The user id.PackageManager.MATCH_DEFAULT_ONLY
,
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public List<ResolveInfo> queryIntentActivities(Intent intent, int flags)
PackageManager
queryIntentActivities
in class PackageManager
intent
- The desired intent as per resolveActivity().flags
- Additional option flags. The most important is
PackageManager.MATCH_DEFAULT_ONLY
, to limit the resolution to only
those activities that support the Intent.CATEGORY_DEFAULT
.PackageManager.resolveActivity(android.content.Intent, int)
. If there are no matching activities, an empty
list is returned.PackageManager.MATCH_DEFAULT_ONLY
,
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, int flags, int userId)
PackageManager
queryIntentActivitiesAsUser
in class PackageManager
intent
- The desired intent as per resolveActivity().flags
- Additional option flags. The most important is
PackageManager.MATCH_DEFAULT_ONLY
, to limit the resolution to only
those activities that support the Intent.CATEGORY_DEFAULT
.PackageManager.resolveActivity(android.content.Intent, int)
. If there are no matching activities, an empty
list is returned.PackageManager.MATCH_DEFAULT_ONLY
,
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller, Intent[] specifics, Intent intent, int flags)
PackageManager
PackageManager.queryIntentActivities(android.content.Intent, int)
, except it
also allows you to supply a list of more explicit Intents that you would
like to resolve to particular options, and takes care of returning the
final ResolveInfo list in a reasonable order, with no duplicates, based
on those inputs.queryIntentActivityOptions
in class PackageManager
caller
- The class name of the activity that is making the
request. This activity will never appear in the output
list. Can be null.specifics
- An array of Intents that should be resolved to the
first specific results. Can be null.intent
- The desired intent as per resolveActivity().flags
- Additional option flags. The most important is
PackageManager.MATCH_DEFAULT_ONLY
, to limit the resolution to only
those activities that support the Intent.CATEGORY_DEFAULT
.PackageManager.MATCH_DEFAULT_ONLY
,
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags)
PackageManager
queryBroadcastReceivers
in class PackageManager
intent
- The desired intent as per resolveActivity().flags
- Additional option flags.PackageManager.MATCH_DEFAULT_ONLY
,
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags, int userId)
PackageManager
queryBroadcastReceivers
in class PackageManager
intent
- The desired intent as per resolveActivity().flags
- Additional option flags.userId
- The userId of the user being queried.PackageManager.MATCH_DEFAULT_ONLY
,
PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public ResolveInfo resolveService(Intent intent, int flags)
PackageManager
resolveService
in class PackageManager
intent
- An intent containing all of the desired specification
(action, data, type, category, and/or component).flags
- Additional option flags.PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public List<ResolveInfo> queryIntentServices(Intent intent, int flags)
PackageManager
queryIntentServices
in class PackageManager
intent
- The desired intent as per resolveService().flags
- Additional option flags.PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public List<ResolveInfo> queryIntentServicesAsUser(Intent intent, int flags, int userId)
PackageManager
queryIntentServicesAsUser
in class PackageManager
intent
- The desired intent as per resolveService().flags
- Additional option flags.userId
- The user id.PackageManager.GET_INTENT_FILTERS
,
PackageManager.GET_RESOLVED_FILTER
public ProviderInfo resolveContentProvider(String name, int flags)
PackageManager
resolveContentProvider
in class PackageManager
name
- The name of the provider to find.flags
- Additional option flags. Currently should always be 0.public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags)
PackageManager
Note: unlike most other methods, an empty result set is indicated by a null return instead of an empty list.
queryContentProviders
in class PackageManager
processName
- If non-null, limits the returned providers to only
those that are hosted by the given process. If null,
all content providers are returned.uid
- If processName is non-null, this is the required
uid owning the requested content providers.flags
- Additional option flags. Currently should always be 0.public InstrumentationInfo getInstrumentationInfo(ComponentName className, int flags) throws PackageManager.NameNotFoundException
PackageManager
Throws PackageManager.NameNotFoundException
if instrumentation with the
given class name can not be found on the system.
getInstrumentationInfo
in class PackageManager
className
- The full name (i.e.
com.google.apps.contacts.InstrumentList) of an
Instrumentation class.flags
- Additional option flags. Currently should always be 0.PackageManager.NameNotFoundException
public List<InstrumentationInfo> queryInstrumentation(String targetPackage, int flags)
PackageManager
queryInstrumentation
in class PackageManager
targetPackage
- If null, all instrumentation is returned; only the
instrumentation targeting this package name is
returned.flags
- Additional option flags. Currently should always be 0.public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo)
PackageManager
ComponentInfo
to implement retrieval of their associated
icon.getDrawable
in class PackageManager
packageName
- The name of the package that this icon is coming from.
Can not be null.resid
- The resource identifier of the desired image. Can not be 0.appInfo
- Overall information about packageName. This
may be null, in which case the application information will be retrieved
for you if needed; if you already have this information around, it can
be much more efficient to supply it here.public Drawable getActivityIcon(ComponentName activityName) throws PackageManager.NameNotFoundException
PackageManager
ComponentInfo.loadIcon()
to return its icon.
If the activity can not be found, NameNotFoundException is thrown.getActivityIcon
in class PackageManager
activityName
- Name of the activity whose icon is to be retrieved.PackageManager.NameNotFoundException
- Thrown if the resources for the given
activity could not be loaded.PackageManager.getActivityIcon(Intent)
public Drawable getActivityIcon(Intent intent) throws PackageManager.NameNotFoundException
PackageManager
getActivityIcon
in class PackageManager
intent
- The intent for which you would like to retrieve an icon.PackageManager.NameNotFoundException
- Thrown if the resources for application
matching the given intent could not be loaded.PackageManager.getActivityIcon(ComponentName)
public Drawable getDefaultActivityIcon()
PackageManager
getDefaultActivityIcon
in class PackageManager
public Drawable getApplicationIcon(ApplicationInfo info)
PackageManager
getApplicationIcon
in class PackageManager
info
- Information about application being queried.PackageManager.getApplicationIcon(String)
public Drawable getApplicationIcon(String packageName) throws PackageManager.NameNotFoundException
PackageManager
getApplicationIcon
in class PackageManager
packageName
- Name of the package whose application icon is to be
retrieved.PackageManager.NameNotFoundException
- Thrown if the resources for the given
application could not be loaded.PackageManager.getApplicationIcon(ApplicationInfo)
public Drawable getActivityLogo(ComponentName activityName) throws PackageManager.NameNotFoundException
PackageManager
ComponentInfo.loadLogo()
to return its logo.
If the activity can not be found, NameNotFoundException is thrown.getActivityLogo
in class PackageManager
activityName
- Name of the activity whose logo is to be retrieved.PackageManager.NameNotFoundException
- Thrown if the resources for the given
activity could not be loaded.PackageManager.getActivityLogo(Intent)
public Drawable getActivityLogo(Intent intent) throws PackageManager.NameNotFoundException
PackageManager
getActivityLogo
in class PackageManager
intent
- The intent for which you would like to retrieve a logo.PackageManager.NameNotFoundException
- Thrown if the resources for application
matching the given intent could not be loaded.PackageManager.getActivityLogo(ComponentName)
public Drawable getApplicationLogo(ApplicationInfo info)
PackageManager
getApplicationLogo
in class PackageManager
info
- Information about application being queried.PackageManager.getApplicationLogo(String)
public Drawable getApplicationLogo(String packageName) throws PackageManager.NameNotFoundException
PackageManager
getApplicationLogo
in class PackageManager
packageName
- Name of the package whose application logo is to be
retrieved.PackageManager.NameNotFoundException
- Thrown if the resources for the given
application could not be loaded.PackageManager.getApplicationLogo(ApplicationInfo)
public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo)
PackageManager
ComponentInfo
to implement retrieval of their associated
labels and other text.getText
in class PackageManager
packageName
- The name of the package that this text is coming from.
Can not be null.resid
- The resource identifier of the desired text. Can not be 0.appInfo
- Overall information about packageName. This
may be null, in which case the application information will be retrieved
for you if needed; if you already have this information around, it can
be much more efficient to supply it here.public XmlResourceParser getXml(String packageName, int resid, ApplicationInfo appInfo)
PackageManager
getXml
in class PackageManager
packageName
- The name of the package that this xml is coming from.
Can not be null.resid
- The resource identifier of the desired xml. Can not be 0.appInfo
- Overall information about packageName. This
may be null, in which case the application information will be retrieved
for you if needed; if you already have this information around, it can
be much more efficient to supply it here.public CharSequence getApplicationLabel(ApplicationInfo info)
PackageManager
getApplicationLabel
in class PackageManager
info
- The application to get the label ofpublic Resources getResourcesForActivity(ComponentName activityName) throws PackageManager.NameNotFoundException
PackageManager
getResourcesForActivity
in class PackageManager
activityName
- Name of the activity whose resources are to be
retrieved.PackageManager.NameNotFoundException
- Thrown if the resources for the given
application could not be loaded.PackageManager.getResourcesForApplication(ApplicationInfo)
public Resources getResourcesForApplication(ApplicationInfo app)
PackageManager
getResourcesForApplication
in class PackageManager
app
- Information about the desired application.public Resources getResourcesForApplication(String appPackageName) throws PackageManager.NameNotFoundException
PackageManager
getResourcesForApplication
in class PackageManager
appPackageName
- Package name of the application whose resources
are to be retrieved.PackageManager.NameNotFoundException
- Thrown if the resources for the given
application could not be loaded.PackageManager.getResourcesForApplication(ApplicationInfo)
public Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
getResourcesForApplicationAsUser
in class PackageManager
public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags)
PackageManager
getPackageArchiveInfo
in class PackageManager
archiveFilePath
- The path to the archive fileflags
- Additional option flags. Use any combination of
PackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
, to modify the data returned.PackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
public void installPackage(Uri packageURI, IPackageInstallObserver observer, int flags, String installerPackageName)
installPackage
in class PackageManager
packageURI
- The location of the package file to install. This can be a 'file:' or a
'content:' URI.observer
- An observer callback to get notified when the package installation is
complete. IPackageInstallObserver#packageInstalled(String, int)
will be
called when that happens. observer may be null to indicate that no callback is desired.flags
- - possible values: PackageManager.INSTALL_FORWARD_LOCK
,
PackageManager.INSTALL_REPLACE_EXISTING
, PackageManager.INSTALL_ALLOW_TEST
.installerPackageName
- Optional package name of the application that is performing the
installation. This identifies which market the package came from.public void setInstallerPackageName(String targetPackage, String installerPackageName)
PackageManager
setInstallerPackageName
in class PackageManager
targetPackage
- The installed package whose installer will be changed.installerPackageName
- The package name of the new installer. May be
null to clear the association.public void movePackage(String packageName, IPackageMoveObserver observer, int flags)
PackageManager
android.Manifest.permission#MOVE_PACKAGE
permission, if the
named package cannot be found, or if the named package is a "system package".movePackage
in class PackageManager
packageName
- The name of the package to deleteobserver
- An observer callback to get notified when the package move is
complete. android.content.pm.IPackageMoveObserver#packageMoved(boolean)
will be
called when that happens. observer may be null to indicate that no callback is desired.flags
- To indicate install location PackageManager.MOVE_INTERNAL
or
PackageManager.MOVE_EXTERNAL_MEDIA
public String getInstallerPackageName(String packageName)
PackageManager
getInstallerPackageName
in class PackageManager
packageName
- The name of the package to querypublic void clearApplicationUserData(String packageName, IPackageDataObserver observer)
PackageManager
clearApplicationUserData
in class PackageManager
packageName
- The name of the packageobserver
- An observer callback to get notified when the operation is finished
android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)
will be called when that happens. observer may be null to indicate that
no callback is desired.public void deleteApplicationCacheFiles(String packageName, IPackageDataObserver observer)
PackageManager
android.Manifest.permission#DELETE_CACHE_FILES
permission, if the
named package cannot be found, or if the named package is a "system package".deleteApplicationCacheFiles
in class PackageManager
packageName
- The name of the package to deleteobserver
- An observer callback to get notified when the cache file deletion
is complete.
android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)
will be called when that happens. observer may be null to indicate that
no callback is desired.public void freeStorageAndNotify(long idealStorageSize, IPackageDataObserver observer)
PackageManager
freeStorageAndNotify
in class PackageManager
idealStorageSize
- The number of bytes of storage to be
freed by the system. Say if freeStorageSize is XX,
and the current free storage is YY,
if XX is less than YY, just return. if not free XX-YY number
of bytes if possible.observer
- call back used to notify when
the operation is completedpublic void freeStorage(long idealStorageSize, IntentSender pi)
PackageManager
freeStorage
in class PackageManager
idealStorageSize
- The number of bytes of storage to be
freed by the system. Say if freeStorageSize is XX,
and the current free storage is YY,
if XX is less than YY, just return. if not free XX-YY number
of bytes if possible.pi
- IntentSender call back used to
notify when the operation is completed.May be null
to indicate that no call back is desired.public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags)
PackageManager
android.Manifest.permission#DELETE_PACKAGES
permission, if the
named package cannot be found, or if the named package is a "system package".
(TODO: include pointer to documentation on "system packages")deletePackage
in class PackageManager
packageName
- The name of the package to deleteobserver
- An observer callback to get notified when the package deletion is
complete. android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)
will be
called when that happens. observer may be null to indicate that no callback is desired.flags
- - possible values: PackageManager.DELETE_KEEP_DATA
,
PackageManager.DELETE_ALL_USERS
.public void addPackageToPreferred(String packageName)
addPackageToPreferred
in class PackageManager
public void removePackageFromPreferred(String packageName)
removePackageFromPreferred
in class PackageManager
public List<PackageInfo> getPreferredPackages(int flags)
PackageManager
getPreferredPackages
in class PackageManager
flags
- Additional option flags. Use any combination of
PackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
, to modify the data returned.PackageManager.GET_ACTIVITIES
,
PackageManager.GET_GIDS
,
PackageManager.GET_CONFIGURATIONS
,
PackageManager.GET_INSTRUMENTATION
,
PackageManager.GET_PERMISSIONS
,
PackageManager.GET_PROVIDERS
,
PackageManager.GET_RECEIVERS
,
PackageManager.GET_SERVICES
,
PackageManager.GET_SIGNATURES
public void setComponentEnabledSetting(ComponentName componentName, int newState, int flags)
PackageManager
setComponentEnabledSetting
in class PackageManager
componentName
- The component to enablenewState
- The new enabled state for the component. The legal values for this state
are:
PackageManager.COMPONENT_ENABLED_STATE_ENABLED
,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
and
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
The last one removes the setting, thereby restoring the component's state to
whatever was set in it's manifest (or enabled, by default).flags
- Optional behavior flags: PackageManager.DONT_KILL_APP
or 0.public int getComponentEnabledSetting(ComponentName componentName)
PackageManager
PackageManager.setComponentEnabledSetting(ComponentName, int, int)
; in most
cases this value will be PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
since
the value originally specified in the manifest has not been modified.getComponentEnabledSetting
in class PackageManager
componentName
- The component to retrieve.PackageManager.COMPONENT_ENABLED_STATE_ENABLED
,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
, or
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
. The last one means the
component's enabled state is based on the original information in
the manifest as found in ComponentInfo
.public void setApplicationEnabledSetting(String packageName, int newState, int flags)
PackageManager
PackageManager.setComponentEnabledSetting(android.content.ComponentName, int, int)
for any of the application's components.setApplicationEnabledSetting
in class PackageManager
packageName
- The package name of the application to enablenewState
- The new enabled state for the component. The legal values for this state
are:
PackageManager.COMPONENT_ENABLED_STATE_ENABLED
,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
and
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
The last one removes the setting, thereby restoring the applications's state to
whatever was set in its manifest (or enabled, by default).flags
- Optional behavior flags: PackageManager.DONT_KILL_APP
or 0.public int getApplicationEnabledSetting(String packageName)
PackageManager
PackageManager.setApplicationEnabledSetting(String, int, int)
; in most
cases this value will be PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
since
the value originally specified in the manifest has not been modified.getApplicationEnabledSetting
in class PackageManager
packageName
- The component to retrieve.PackageManager.COMPONENT_ENABLED_STATE_ENABLED
,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
, or
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
. The last one means the
application's enabled state is based on the original information in
the manifest as found in ComponentInfo
.public void addPreferredActivity(IntentFilter filter, int match, ComponentName[] set, ComponentName activity)
addPreferredActivity
in class PackageManager
filter
- The set of intents under which this activity will be
made preferred.match
- The IntentFilter match category that this preference
applies to.set
- The set of activities that the user was picking from when
this preference was made.activity
- The component name of the activity that is to be
preferred.public void replacePreferredActivity(IntentFilter filter, int match, ComponentName[] set, ComponentName activity)
replacePreferredActivity
in class PackageManager
filter
- The set of intents under which this activity will be
made preferred.match
- The IntentFilter match category that this preference
applies to.set
- The set of activities that the user was picking from when
this preference was made.activity
- The component name of the activity that is to be
preferred.public void clearPackagePreferredActivities(String packageName)
PackageManager
PackageManager.addPreferredActivity(android.content.IntentFilter, int, android.content.ComponentName[], android.content.ComponentName)
, from the
system whose activities are implemented in the given package name.
An application can only clear its own package(s).clearPackagePreferredActivities
in class PackageManager
packageName
- The name of the package whose preferred activity
mappings are to be removed.public void getPackageSizeInfo(String packageName, int userHandle, IPackageStatsObserver observer)
PackageManager
android.Manifest.permission#GET_PACKAGE_SIZE
permission.getPackageSizeInfo
in class PackageManager
packageName
- The name of the package whose size information is to be retrieveduserHandle
- The user whose size information should be retrieved.observer
- An observer callback to get notified when the operation
is complete.
android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)
The observer's callback is invoked with a PackageStats object(containing the
code, data and cache sizes of the package) and a boolean value representing
the status of the operation. observer may be null to indicate that
no callback is desired.public int getPreferredActivities(List<IntentFilter> outFilters, List<ComponentName> outActivities, String packageName)
PackageManager
PackageManager.addPreferredActivity(android.content.IntentFilter, int, android.content.ComponentName[], android.content.ComponentName)
, that are
currently registered with the system.getPreferredActivities
in class PackageManager
outFilters
- A list in which to place the filters of all of the
preferred activities, or null for none.outActivities
- A list in which to place the component names of
all of the preferred activities, or null for none.packageName
- An option package in which you would like to limit
the list. If null, all activities will be returned; if non-null, only
those activities in the given package are returned.public String[] getSystemSharedLibraryNames()
PackageManager
getSystemSharedLibraryNames
in class PackageManager
public FeatureInfo[] getSystemAvailableFeatures()
PackageManager
getSystemAvailableFeatures
in class PackageManager
public boolean hasSystemFeature(String name)
PackageManager
PackageManager.getSystemAvailableFeatures()
.hasSystemFeature
in class PackageManager
public boolean isSafeMode()
PackageManager
isSafeMode
in class PackageManager
public void installPackageWithVerification(Uri packageURI, IPackageInstallObserver observer, int flags, String installerPackageName, Uri verificationURI, ManifestDigest manifestDigest, ContainerEncryptionParams encryptionParams)
PackageManager
PackageManager.installPackage(Uri, IPackageInstallObserver, int, String)
but
with an extra verification file provided.installPackageWithVerification
in class PackageManager
packageURI
- The location of the package file to install. This can
be a 'file:' or a 'content:' URI.observer
- An observer callback to get notified when the package
installation is complete.
IPackageInstallObserver#packageInstalled(String, int)
will be called when that happens. observer may be null to
indicate that no callback is desired.flags
- - possible values: PackageManager.INSTALL_FORWARD_LOCK
,
PackageManager.INSTALL_REPLACE_EXISTING
, PackageManager.INSTALL_ALLOW_TEST
.installerPackageName
- Optional package name of the application that
is performing the installation. This identifies which market
the package came from.verificationURI
- The location of the supplementary verification
file. This can be a 'file:' or a 'content:' URI. May be
null
.manifestDigest
- an object that holds the digest of the package
which can be used to verify ownership. May be null
.encryptionParams
- if the package to be installed is encrypted,
these parameters describing the encryption and authentication
used. May be null
.public void installPackageWithVerificationAndEncryption(Uri packageURI, IPackageInstallObserver observer, int flags, String installerPackageName, VerificationParams verificationParams, ContainerEncryptionParams encryptionParams)
PackageManager
PackageManager.installPackage(Uri, IPackageInstallObserver, int, String)
but
with an extra verification information provided.installPackageWithVerificationAndEncryption
in class PackageManager
packageURI
- The location of the package file to install. This can
be a 'file:' or a 'content:' URI.observer
- An observer callback to get notified when the package
installation is complete.
IPackageInstallObserver#packageInstalled(String, int)
will be called when that happens. observer may be null to
indicate that no callback is desired.flags
- - possible values: PackageManager.INSTALL_FORWARD_LOCK
,
PackageManager.INSTALL_REPLACE_EXISTING
, PackageManager.INSTALL_ALLOW_TEST
.installerPackageName
- Optional package name of the application that
is performing the installation. This identifies which market
the package came from.verificationParams
- an object that holds signal information to
assist verification. May be null
.encryptionParams
- if the package to be installed is encrypted,
these parameters describing the encryption and authentication
used. May be null
.public int installExistingPackage(String packageName) throws PackageManager.NameNotFoundException
PackageManager
installExistingPackage
in class PackageManager
PackageManager.NameNotFoundException
public void verifyPendingInstall(int id, int verificationCode)
PackageManager
package verification
broadcast
to respond to the package manager. The response must include
the verificationCode
which is one of
PackageManager.VERIFICATION_ALLOW
or
PackageManager.VERIFICATION_REJECT
.verifyPendingInstall
in class PackageManager
id
- pending package identifier as passed via the
PackageManager.EXTRA_VERIFICATION_ID
Intent extraverificationCode
- either PackageManager.VERIFICATION_ALLOW
or PackageManager.VERIFICATION_REJECT
.public void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay)
PackageManager
package verification
broadcast
to extend the default timeout for a response and declare what
action to perform after the timeout occurs. The response must include
the verificationCodeAtTimeout
which is one of
PackageManager.VERIFICATION_ALLOW
or
PackageManager.VERIFICATION_REJECT
.
This method may only be called once per package id. Additional calls
will have no effect.extendVerificationTimeout
in class PackageManager
id
- pending package identifier as passed via the
PackageManager.EXTRA_VERIFICATION_ID
Intent extraverificationCodeAtTimeout
- either
PackageManager.VERIFICATION_ALLOW
or
PackageManager.VERIFICATION_REJECT
. If
verificationCodeAtTimeout
is neither
PackageManager.VERIFICATION_ALLOW
or
PackageManager.VERIFICATION_REJECT
, then
verificationCodeAtTimeout
will default to
PackageManager.VERIFICATION_REJECT
.millisecondsToDelay
- the amount of time requested for the timeout.
Must be positive and less than
PackageManager.MAXIMUM_VERIFICATION_TIMEOUT
. If
millisecondsToDelay
is out of bounds,
millisecondsToDelay
will be set to the closest in
bounds value; namely, 0 or
PackageManager.MAXIMUM_VERIFICATION_TIMEOUT
.public VerifierDeviceIdentity getVerifierDeviceIdentity()
PackageManager
getVerifierDeviceIdentity
in class PackageManager