Feature for getSystemAvailableFeatures() and hasSystemFeature(String):
The device implements an optimized mode for virtual reality (VR) applications that handles
stereoscopic rendering of notifications, and disables most monocular system UI components
while a VR application has user focus.

Feature for getSystemAvailableFeatures() and
hasSystemFeature(String, int): If this feature is supported, the Vulkan native API
will enumerate at least one VkPhysicalDevice, and the feature version will indicate
what level of optional compute features are supported beyond the Vulkan 1.0 requirements.

Public constructors

Public methods

This method is deprecated.
This function no longer does anything; it was an old
approach to managing preferred activities, which has been superseded
by (and conflicts with) the modern activity-based preferences.

Like 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.

This method is deprecated.
This is a protected API that should not have been available
to third party applications. It is the platform's responsibility for
assigning preferred activities and this cannot be directly modified.
Add a new preferred activity mapping to the system. This will be used
to automatically select the given activity component when
Context.startActivity() finds
multiple matching activities and also matches the given filter.

If the target user is a managed profile of the calling user or the caller
is itself a managed profile, then this returns a badged copy of the given
drawable allowing the user to distinguish it from the original drawable.

This method is deprecated.
This function no longer does anything; it was an old
approach to managing preferred activities, which has been superseded
by (and conflicts with) the modern activity-based preferences.

Inherited methods

This method was deprecated
in API level 7.
This function no longer does anything; it was an old
approach to managing preferred activities, which has been superseded
by (and conflicts with) the modern activity-based preferences.

Like 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.

This method was deprecated
in API level 8.
This is a protected API that should not have been available
to third party applications. It is the platform's responsibility for
assigning preferred activities and this cannot be directly modified.
Add a new preferred activity mapping to the system. This will be used
to automatically select the given activity component when
Context.startActivity() finds
multiple matching activities and also matches the given filter.

If the target user is a managed profile of the calling user or the caller
is itself a managed profile, then this returns a badged copy of the given
drawable allowing the user to distinguish it from the original drawable.

This method was deprecated
in API level 7.
This function no longer does anything; it was an old
approach to managing preferred activities, which has been superseded
by (and conflicts with) the modern activity-based preferences.

Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.

Public constructors

MockPackageManager

Public methods

addPackageToPreferred

This method is deprecated.
This function no longer does anything; it was an old
approach to managing preferred activities, which has been superseded
by (and conflicts with) the modern activity-based preferences.

Parameters

packageName

String

addPermission

Add a new dynamic permission to the system. For this to work, your
package must have defined a permission tree through the
<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.

Parameters

info

PermissionInfo: Description of the permission to be added.

Returns

boolean

Returns true if a new permission was created, false if an
existing one was updated.

addPermissionAsync

Like 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.

Parameters

info

PermissionInfo

Returns

boolean

addPreferredActivity

This method is deprecated.
This is a protected API that should not have been available
to third party applications. It is the platform's responsibility for
assigning preferred activities and this cannot be directly modified.
Add a new preferred activity mapping to the system. This will be used
to automatically select the given activity component when
Context.startActivity() finds
multiple matching activities and also matches the given filter.

Parameters

filter

IntentFilter: The set of intents under which this activity will be
made preferred.

match

int: The IntentFilter match category that this preference
applies to.

set

ComponentName: The set of activities that the user was picking from when
this preference was made.

activity

ComponentName: The component name of the activity that is to be
preferred.

canRequestPackageInstalls

Checks whether the calling package is allowed to request package installs through package
installer. Apps are encouraged to call this API before launching the package installer via
intent ACTION_INSTALL_PACKAGE. Starting from Android O, the
user can explicitly choose what external sources they trust to install apps on the device.
If this API returns false, the install request will be blocked by the package installer and
a dialog will be shown to the user with an option to launch settings to change their
preference. An application must target Android O or higher and declare permission
REQUEST_INSTALL_PACKAGES in order to use this API.

Returns

boolean

true if the calling package is trusted by the user to request install packages on
the device, false otherwise.

checkSignatures

Compare the signatures of two packages to determine if the same
signature appears in both of them. If they do contain the same
signature, then they are allowed special privileges when working
with each other: they can share the same user-id, run instrumentation
against each other, etc.

checkSignatures

Like 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.

extendVerificationTimeout

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. The response must include
the verificationCodeAtTimeout which is one of
VERIFICATION_ALLOW or
VERIFICATION_REJECT.
This method may only be called once per package id. Additional calls
will have no effect.

getActivityBanner

Retrieve the banner associated with an Intent. If intent.getClassName()
is set, this simply returns the result of
getActivityBanner(intent.getClassName()). Otherwise it resolves the
intent's component and returns the banner associated with the resolved
component. If intent.getClassName() cannot be found or the Intent cannot
be resolved to a component, NameNotFoundException is thrown.

getActivityBanner

Retrieve the banner associated with an activity. Given the full name of
an activity, retrieves the information about it and calls
ComponentInfo.loadIcon() to return its
banner. If the activity cannot be found, NameNotFoundException is thrown.

getActivityIcon

Retrieve the icon associated with an Intent. If intent.getClassName() is
set, this simply returns the result of
getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
component and returns the icon associated with the resolved component.
If intent.getClassName() cannot be found or the Intent cannot be resolved
to a component, NameNotFoundException is thrown.

getActivityIcon

Retrieve the icon associated with an activity. Given the full name of
an activity, retrieves the information about it and calls
ComponentInfo.loadIcon() to return its icon.
If the activity cannot be found, NameNotFoundException is thrown.

getActivityLogo

Retrieve the logo associated with an Intent. If intent.getClassName() is
set, this simply returns the result of
getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's
component and returns the logo associated with the resolved component.
If intent.getClassName() cannot be found or the Intent cannot be resolved
to a component, NameNotFoundException is thrown.

getActivityLogo

Retrieve the logo associated with an activity. Given the full name of an
activity, retrieves the information about it and calls
ComponentInfo.loadLogo() to return its
logo. If the activity cannot be found, NameNotFoundException is thrown.

getApplicationBanner

Retrieve the banner associated with an application. Given the name of the
application's package, retrieves the information about it and calls
getApplicationIcon() to return its banner. If the application cannot be
found, NameNotFoundException is thrown.

Parameters

packageName

String: Name of the package whose application banner is to be
retrieved.

getApplicationIcon

Retrieve the icon associated with an application. Given the name of the
application's package, retrieves the information about it and calls
getApplicationIcon() to return its icon. If the application cannot be
found, NameNotFoundException is thrown.

Parameters

packageName

String: Name of the package whose application icon is to be
retrieved.

An ApplicationInfo containing information about the
package. If flag MATCH_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 i.e. applications
which had been deleted with DONT_DELETE_DATA flag set).

getApplicationLogo

Retrieve the logo associated with an application. Given the name of the
application's package, retrieves the information about it and calls
getApplicationLogo() to return its logo. If the application cannot be
found, NameNotFoundException is thrown.

Parameters

packageName

String: Name of the package whose application logo is to be
retrieved.

getDrawable

Retrieve an image from a package. This is a low-level API used by
the various package manager info structures (such as
ComponentInfo to implement retrieval of their associated
icon.

Parameters

packageName

String: The name of the package that this icon is coming from.
Cannot be null.

resid

int: The resource identifier of the desired image. Cannot be 0.

appInfo

ApplicationInfo: 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.

getInstalledApplications

Return a List of all application packages that are installed on the
device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
applications including those deleted with DONT_DELETE_DATA
(partially installed apps with data directory) will be returned.

A List of ApplicationInfo objects, one for each installed
application. In the unlikely case there are no installed
packages, an empty list is returned. If flag
MATCH_UNINSTALLED_PACKAGES is set, the application
information is retrieved from the list of uninstalled
applications (which includes installed applications as well as
applications with data directory i.e. applications which had been
deleted with DONT_DELETE_DATA flag set).

A List of PackageInfo objects, one for each installed package,
containing information about the package. In the unlikely case
there are no installed packages, an empty list is returned. If
flag MATCH_UNINSTALLED_PACKAGES is set, the package
information is retrieved from the list of uninstalled
applications (which includes installed applications as well as
applications with data directory i.e. applications which had been
deleted with DONT_DELETE_DATA flag set).

getLaunchIntentForPackage

Returns a "good" intent to launch a front-door activity in a package.
This is used, for example, to implement an "open" button when browsing
through packages. The current implementation looks first for a main
activity in the category CATEGORY_INFO, and next for a
main activity in the category CATEGORY_LAUNCHER. Returns
null if neither are found.

getLeanbackLaunchIntentForPackage

Return a "good" intent to launch a front-door Leanback activity in a
package, for use for example to implement an "open" button when browsing
through packages. The current implementation will look for a main
activity in the category CATEGORY_LEANBACK_LAUNCHER, or
return null if no main leanback activities are found.

getNameForUid

Retrieve the official name associated with a uid. This name is
guaranteed to never change, though it is possible for the underlying
uid to be changed. That is, if you are storing information about
uids in persistent storage, you should use the string returned
by this function instead of the raw uid.

A PackageInfo object containing information about the package. If
flag MATCH_UNINSTALLED_PACKAGES is set and if the package
is not found in the list of installed applications, the package
information is retrieved from the list of uninstalled
applications (which includes installed applications as well as
applications with data directory i.e. applications which had been
deleted with DONT_DELETE_DATA flag set).

getPackageInfo

Retrieve overall information about an application package that is
installed on the system. This method can be used for retrieving
information about packages for which multiple versions can be installed
at the time. Currently only packages hosting static shared libraries can
have multiple installed versions. The method can also be used to get info
for a package that has a single version installed by passing
VERSION_CODE_HIGHEST in the VersionedPackage
constructor.

A PackageInfo object containing information about the package. If
flag MATCH_UNINSTALLED_PACKAGES is set and if the package
is not found in the list of installed applications, the package
information is retrieved from the list of uninstalled
applications (which includes installed applications as well as
applications with data directory i.e. applications which had been
deleted with DONT_DELETE_DATA flag set).

getPackagesForUid

Retrieve the names of all packages that are associated with a particular
user id. In most cases, this will be a single package name, the package
that has been assigned that user id. Where there are multiple packages
sharing the same user id through the "sharedUserId" mechanism, all
packages with that id will be returned.

Parameters

uid

int: The user id for which you would like to retrieve the
associated packages.

A List of PackageInfo objects, one for each installed package
that holds any of the permissions that were provided, containing
information about the package. If no installed packages hold any
of the permissions, an empty list is returned. If flag
MATCH_UNINSTALLED_PACKAGES is set, the package
information is retrieved from the list of uninstalled
applications (which includes installed applications as well as
applications with data directory i.e. applications which had been
deleted with DONT_DELETE_DATA flag set).

getResourcesForActivity

Retrieve the resources associated with an activity. Given the full
name of an activity, retrieves the information about it and calls
getResources() to return its application's resources. If the activity
cannot be found, NameNotFoundException is thrown.

Parameters

activityName

ComponentName: Name of the activity whose resources are to be
retrieved.

getResourcesForApplication

Retrieve the resources associated with an application. Given the full
package name of an application, retrieves the information about it and
calls getResources() to return its application's resources. If the
appPackageName cannot be found, NameNotFoundException is thrown.

Parameters

appPackageName

String: Package name of the application whose resources
are to be retrieved.

getText

Retrieve text from a package. This is a low-level API used by
the various package manager info structures (such as
ComponentInfo to implement retrieval of their associated
labels and other text.

Parameters

packageName

String: The name of the package that this text is coming from.
Cannot be null.

resid

int: The resource identifier of the desired text. Cannot be 0.

appInfo

ApplicationInfo: 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.

getUserBadgedDrawableForDensity

If the target user is a managed profile of the calling user or the caller
is itself a managed profile, then this returns a badged copy of the given
drawable allowing the user to distinguish it from the original drawable.
The caller can specify the location in the bounds of the drawable to be
badged where the badge should be applied as well as the density of the
badge to be used.

If the original drawable is a BitmapDrawable and the backing bitmap is
mutable as per isMutable(), the badging
is performed in place and the original drawable is returned.

Parameters

drawable

Drawable: The drawable to badge.

user

UserHandle: The target user.

badgeLocation

Rect: Where in the bounds of the badged drawable to place
the badge. If it's null, the badge is applied on top of the entire
drawable being badged.

badgeDensity

int: The optional desired density for the badge as per
densityDpi. If it's not positive,
the density of the display is used.

getUserBadgedLabel

If the target user is a managed profile of the calling user or the caller
is itself a managed profile, then this returns a copy of the label with
badging for accessibility services like talkback. E.g. passing in "Email"
and it might return "Work Email" for Email in the work profile.

getXml

Retrieve an XML file from a package. This is a low-level API used to
retrieve XML meta data.

Parameters

packageName

String: The name of the package that this xml is coming from.
Cannot be null.

resid

int: The resource identifier of the desired xml. Cannot be 0.

appInfo

ApplicationInfo: 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.

hasSystemFeature

Check whether the given feature name and version is one of the available
features as returned by getSystemAvailableFeatures(). Since
features are defined to always be backwards compatible, this returns true
if the available feature version is greater than or equal to the
requested version.

Parameters

name

String

version

int

Returns

boolean

Returns true if the devices supports the feature, else false.

isPermissionRevokedByPolicy

Checks whether a particular permissions has been revoked for a
package by policy. Typically the device owner or the profile owner
may apply such a policy. The user cannot grant policy revoked
permissions, hence the only way for an app to get such a permission
is by a policy change.

A list of ProviderInfo objects containing one entry for
each provider either matching processName or, if
processName is null, all known content providers.
If there are no matching providers, null is returned.

int: Additional option flags to modify the data returned. The
most important is MATCH_DEFAULT_ONLY, to limit the
resolution to only those activities that support the
CATEGORY_DEFAULT. Or, set
MATCH_ALL to prevent any filtering of the results.

Returns a List of ResolveInfo objects containing one entry for
each matching activity, ordered from best to worst. In other
words, the first item is what would be returned by
resolveActivity(Intent, int). If there are no matching activities, an
empty list is returned.

queryIntentActivityOptions

Retrieve a set of activities that should be presented to the user as
similar options. This is like queryIntentActivities(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.

Parameters

caller

ComponentName: The class name of the activity that is making the request.
This activity will never appear in the output list. Can be
null.

specifics

Intent: An array of Intents that should be resolved to the first
specific results. Can be null.

intent

Intent: The desired intent as per resolveActivity().

flags

int: Additional option flags to modify the data returned. The
most important is MATCH_DEFAULT_ONLY, to limit the
resolution to only those activities that support the
CATEGORY_DEFAULT.

Returns a List of ResolveInfo objects containing one entry for
each matching activity. The list is ordered first by all of the
intents resolved in specifics and then any additional
activities that can handle intent but did not get
included by one of the specifics intents. If there are
no matching activities, an empty list is returned.

Returns a List of ResolveInfo objects containing one entry for
each matching service, ordered from best to worst. In other
words, the first item is what would be returned by
resolveService(Intent, int). If there are no matching services, an
empty list or null is returned.

removePackageFromPreferred

This method is deprecated.
This function no longer does anything; it was an old
approach to managing preferred activities, which has been superseded
by (and conflicts with) the modern activity-based preferences.

Returns a ResolveInfo object containing the final activity intent
that was determined to be the best action. Returns null if no
matching activity was found. If multiple matching activities are
found and there is no default set, returns a ResolveInfo object
containing something else, such as the activity resolver.

setApplicationEnabledSetting

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. It also overrides the enabled state set in the manifest for any of the
application's components. It does not override any enabled state set by
setComponentEnabledSetting(ComponentName, int, int) for any of the application's components.