public
class
DevicePolicyManager
extends Object
java.lang.Object | |
↳ | android.app.admin.DevicePolicyManager |
Public interface for managing policies enforced on a device. Most clients of this class must be
registered with the system as a device
administrator. Additionally, a device administrator may be registered as either a profile or
device owner. A given method is accessible to all device administrators unless the documentation
for that method specifies that it is restricted to either device or profile owners. Any
application calling an api may only pass as an argument a device administrator component it
owns. Otherwise, a SecurityException
will be thrown.
For more information about managing policies for device administration, read the Device Administration developer guide.
Constants | |
---|---|
String |
ACTION_ADD_DEVICE_ADMIN
Activity action: ask the user to add a new device administrator to the system. |
String |
ACTION_DEVICE_OWNER_CHANGED
Broadcast action: sent when the device owner is set or changed. |
String |
ACTION_MANAGED_PROFILE_PROVISIONED
Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile has completed successfully. |
String |
ACTION_PROVISION_MANAGED_DEVICE
Activity action: Starts the provisioning flow which sets up a managed device. |
String |
ACTION_PROVISION_MANAGED_PROFILE
Activity action: Starts the provisioning flow which sets up a managed profile. |
String |
ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
Activity action: have the user enter a new password for the parent profile. |
String |
ACTION_SET_NEW_PASSWORD
Activity action: have the user enter a new password. |
String |
ACTION_START_ENCRYPTION
Activity action: begin the process of encrypting data on the device. |
String |
ACTION_SYSTEM_UPDATE_POLICY_CHANGED
Broadcast action: notify that a new local system update policy has been set by the device owner. |
int |
ENCRYPTION_STATUS_ACTIVATING
Result code for |
int |
ENCRYPTION_STATUS_ACTIVE
Result code for |
int |
ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY
Result code for |
int |
ENCRYPTION_STATUS_ACTIVE_PER_USER
Result code for |
int |
ENCRYPTION_STATUS_INACTIVE
Result code for |
int |
ENCRYPTION_STATUS_UNSUPPORTED
Result code for |
String |
EXTRA_ADD_EXPLANATION
An optional CharSequence providing additional explanation for why the admin is being added. |
String |
EXTRA_DEVICE_ADMIN
The ComponentName of the administrator component. |
String |
EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE
An |
String |
EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE
A |
String |
EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME
A ComponentName extra indicating the device admin receiver of the mobile device management application that will be set as the profile owner or device owner and active admin. |
String |
EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE
An int extra holding a minimum required version code for the device admin package. |
String |
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM
A String extra holding the URL-safe base64 encoded SHA-256 or SHA-1 hash (see notes below) of
the file at download location specified in
|
String |
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER
A String extra holding a http cookie header which should be used in the http request to the
url specified in |
String |
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION
A String extra holding a url that specifies the download location of the device admin package. |
String |
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME
This constant was deprecated
in API level 23.
Use |
String |
EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM
A String extra holding the URL-safe base64 encoded SHA-256 checksum of any signature of the
android package archive at the download location specified in |
String |
EXTRA_PROVISIONING_EMAIL_ADDRESS
A String extra that, holds the email address of the account which a managed profile is created for. |
String |
EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED
A Boolean extra that can be used by the mobile device management application to skip the
disabling of system apps during provisioning when set to |
String |
EXTRA_PROVISIONING_LOCALE
A String extra holding the |
String |
EXTRA_PROVISIONING_LOCAL_TIME
A Long extra holding the wall clock time (in milliseconds) to be set on the device's
|
String |
EXTRA_PROVISIONING_LOGO_URI
A |
String |
EXTRA_PROVISIONING_MAIN_COLOR
A integer extra indicating the predominant color to show during the provisioning. |
String |
EXTRA_PROVISIONING_SKIP_ENCRYPTION
A boolean extra indicating whether device encryption can be skipped as part of device owner or managed profile provisioning. |
String |
EXTRA_PROVISIONING_TIME_ZONE
A String extra holding the time zone |
String |
EXTRA_PROVISIONING_WIFI_HIDDEN
A boolean extra indicating whether the wifi network in |
String |
EXTRA_PROVISIONING_WIFI_PAC_URL
A String extra holding the proxy auto-config (PAC) URL for the wifi network in
|
String |
EXTRA_PROVISIONING_WIFI_PASSWORD
A String extra holding the password of the wifi network in
|
String |
EXTRA_PROVISIONING_WIFI_PROXY_BYPASS
A String extra holding the proxy bypass for the wifi network in
|
String |
EXTRA_PROVISIONING_WIFI_PROXY_HOST
A String extra holding the proxy host for the wifi network in
|
String |
EXTRA_PROVISIONING_WIFI_PROXY_PORT
An int extra holding the proxy port for the wifi network in
|
String |
EXTRA_PROVISIONING_WIFI_SECURITY_TYPE
A String extra indicating the security type of the wifi network in
|
String |
EXTRA_PROVISIONING_WIFI_SSID
A String extra holding the ssid of the wifi network that should be used during nfc device owner provisioning for downloading the mobile device management application. |
int |
FLAG_MANAGED_CAN_ACCESS_PARENT
Flag used by |
int |
FLAG_PARENT_CAN_ACCESS_MANAGED
Flag used by |
int |
KEYGUARD_DISABLE_FEATURES_ALL
Disable all current and future keyguard customizations. |
int |
KEYGUARD_DISABLE_FEATURES_NONE
Widgets are enabled in keyguard |
int |
KEYGUARD_DISABLE_FINGERPRINT
Disable fingerprint sensor on keyguard secure screens (e.g. |
int |
KEYGUARD_DISABLE_REMOTE_INPUT
Disable text entry into notifications on secure keyguard screens (e.g. |
int |
KEYGUARD_DISABLE_SECURE_CAMERA
Disable the camera on secure keyguard screens (e.g. |
int |
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
Disable showing all notifications on secure keyguard screens (e.g. |
int |
KEYGUARD_DISABLE_TRUST_AGENTS
Ignore trust agent state on secure keyguard screens (e.g. |
int |
KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS
Only allow redacted notifications on secure keyguard screens (e.g. |
int |
KEYGUARD_DISABLE_WIDGETS_ALL
Disable all keyguard widgets. |
String |
MIME_TYPE_PROVISIONING_NFC
This MIME type is used for starting the device owner provisioning. |
int |
PASSWORD_QUALITY_ALPHABETIC
Constant for |
int |
PASSWORD_QUALITY_ALPHANUMERIC
Constant for |
int |
PASSWORD_QUALITY_BIOMETRIC_WEAK
Constant for |
int |
PASSWORD_QUALITY_COMPLEX
Constant for |
int |
PASSWORD_QUALITY_NUMERIC
Constant for |
int |
PASSWORD_QUALITY_NUMERIC_COMPLEX
Constant for |
int |
PASSWORD_QUALITY_SOMETHING
Constant for |
int |
PASSWORD_QUALITY_UNSPECIFIED
Constant for |
int |
PERMISSION_GRANT_STATE_DEFAULT
Runtime permission state: The user can manage the permission through the UI. |
int |
PERMISSION_GRANT_STATE_DENIED
Runtime permission state: The permission is denied to the app and the user cannot manage the permission through the UI. |
int |
PERMISSION_GRANT_STATE_GRANTED
Runtime permission state: The permission is granted to the app and the user cannot manage the permission through the UI. |
int |
PERMISSION_POLICY_AUTO_DENY
Permission policy to always deny new permission requests for runtime permissions. |
int |
PERMISSION_POLICY_AUTO_GRANT
Permission policy to always grant new permission requests for runtime permissions. |
int |
PERMISSION_POLICY_PROMPT
Permission policy to prompt user for new permission requests for runtime permissions. |
int |
RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT
Flag for |
int |
RESET_PASSWORD_REQUIRE_ENTRY
Flag for |
int |
SKIP_SETUP_WIZARD
Flag used by |
int |
WIPE_EXTERNAL_STORAGE
Flag for |
int |
WIPE_RESET_PROTECTION_DATA
Flag for |
Public methods | |
---|---|
void
|
addCrossProfileIntentFilter(ComponentName admin, IntentFilter filter, int flags)
Called by the profile owner of a managed profile so that some intents sent in the managed profile can also be resolved in the parent, or vice versa. |
boolean
|
addCrossProfileWidgetProvider(ComponentName admin, String packageName)
Called by the profile owner of a managed profile to enable widget providers from a given package to be available in the parent profile. |
void
|
addPersistentPreferredActivity(ComponentName admin, IntentFilter filter, ComponentName activity)
Called by a profile owner or device owner to add a default intent handler activity for intents that match a certain intent filter. |
void
|
addUserRestriction(ComponentName admin, String key)
Called by a profile or device owner to set a user restriction specified by the key. |
void
|
clearCrossProfileIntentFilters(ComponentName admin)
Called by a profile owner of a managed profile to remove the cross-profile intent filters that go from the managed profile to the parent, or from the parent to the managed profile. |
void
|
clearDeviceOwnerApp(String packageName)
Clears the current device owner. |
void
|
clearPackagePersistentPreferredActivities(ComponentName admin, String packageName)
Called by a profile owner or device owner to remove all persistent intent handler preferences
associated with the given package that were set by |
void
|
clearProfileOwner(ComponentName admin)
Clears the active profile owner and removes all user restrictions. |
void
|
clearUserRestriction(ComponentName admin, String key)
Called by a profile or device owner to clear a user restriction specified by the key. |
UserHandle
|
createAndManageUser(ComponentName admin, String name, ComponentName profileOwner, PersistableBundle adminExtras, int flags)
Called by a device owner to create a user with the specified name and a given component of the calling package as profile owner. |
int
|
enableSystemApp(ComponentName admin, Intent intent)
Called by profile or device owners to re-enable system apps by intent that were disabled by default when the user was initialized. |
void
|
enableSystemApp(ComponentName admin, String packageName)
Called by profile or device owners to re-enable a system app that was disabled by default when the user was initialized. |
String[]
|
getAccountTypesWithManagementDisabled()
Gets the array of accounts for which account management is disabled by the profile owner. |
List<ComponentName>
|
getActiveAdmins()
Return a list of all currently active device administrators' component names. |
String
|
getAlwaysOnVpnPackage(ComponentName admin)
Called by a device or profile owner to read the name of the package administering an always-on VPN connection for the current user. |
Bundle
|
getApplicationRestrictions(ComponentName admin, String packageName)
Retrieves the application restrictions for a given target application running in the calling user. |
String
|
getApplicationRestrictionsManagingPackage(ComponentName admin)
Called by a profile owner or device owner to retrieve the application restrictions managing
package for the current user, or |
boolean
|
getAutoTimeRequired()
|
boolean
|
getBluetoothContactSharingDisabled(ComponentName admin)
Called by a profile owner of a managed profile to determine whether or not Bluetooth devices cannot access enterprise contacts. |
boolean
|
getCameraDisabled(ComponentName admin)
Determine whether or not the device's cameras have been disabled for this user, either by the calling admin, if specified, or all admins. |
String
|
getCertInstallerPackage(ComponentName admin)
Called by a profile owner or device owner to retrieve the certificate installer for the user. |
boolean
|
getCrossProfileCallerIdDisabled(ComponentName admin)
Called by a profile owner of a managed profile to determine whether or not caller-Id information has been disabled. |
boolean
|
getCrossProfileContactsSearchDisabled(ComponentName admin)
Called by a profile owner of a managed profile to determine whether or not contacts search has been disabled. |
List<String>
|
getCrossProfileWidgetProviders(ComponentName admin)
Called by the profile owner of a managed profile to query providers from which packages are available in the parent profile. |
int
|
getCurrentFailedPasswordAttempts()
Retrieve the number of times the user has failed at entering a password since that last successful password entry. |
CharSequence
|
getDeviceOwnerLockScreenInfo()
|
List<byte[]>
|
getInstalledCaCerts(ComponentName admin)
Returns all CA certificates that are currently trusted, excluding system CA certificates. |
int
|
getKeyguardDisabledFeatures(ComponentName admin)
Determine whether or not features have been disabled in keyguard either by the calling admin, if specified, or all admins that set retrictions on this user and its participating profiles. |
CharSequence
|
getLongSupportMessage(ComponentName admin)
Called by a device admin to get the long support message. |
int
|
getMaximumFailedPasswordsForWipe(ComponentName admin)
Retrieve the current maximum number of login attempts that are allowed before the device or profile is wiped, for a particular admin or all admins that set retrictions on this user and its participating profiles. |
long
|
getMaximumTimeToLock(ComponentName admin)
Retrieve the current maximum time to unlock for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getOrganizationColor(ComponentName admin)
Called by a profile owner of a managed profile to retrieve the color used for customization. |
CharSequence
|
getOrganizationName(ComponentName admin)
Called by a profile owner of a managed profile to retrieve the name of the organization under management. |
DevicePolicyManager
|
getParentProfileInstance(ComponentName admin)
Called by the profile owner of a managed profile to obtain a |
long
|
getPasswordExpiration(ComponentName admin)
Get the current password expiration time for a particular admin or all admins that set retrictions on this user and its participating profiles. |
long
|
getPasswordExpirationTimeout(ComponentName admin)
Get the password expiration timeout for the given admin. |
int
|
getPasswordHistoryLength(ComponentName admin)
Retrieve the current password history length for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPasswordMaximumLength(int quality)
Return the maximum password length that the device supports for a particular password quality. |
int
|
getPasswordMinimumLength(ComponentName admin)
Retrieve the current minimum password length for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPasswordMinimumLetters(ComponentName admin)
Retrieve the current number of letters required in the password for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPasswordMinimumLowerCase(ComponentName admin)
Retrieve the current number of lower case letters required in the password for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPasswordMinimumNonLetter(ComponentName admin)
Retrieve the current number of non-letter characters required in the password for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPasswordMinimumNumeric(ComponentName admin)
Retrieve the current number of numerical digits required in the password for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPasswordMinimumSymbols(ComponentName admin)
Retrieve the current number of symbols required in the password for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPasswordMinimumUpperCase(ComponentName admin)
Retrieve the current number of upper case letters required in the password for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPasswordQuality(ComponentName admin)
Retrieve the current minimum password quality for a particular admin or all admins that set retrictions on this user and its participating profiles. |
int
|
getPermissionGrantState(ComponentName admin, String packageName, String permission)
Returns the current grant state of a runtime permission for a specific application. |
int
|
getPermissionPolicy(ComponentName admin)
Returns the current runtime permission policy set by the device or profile owner. |
List<String>
|
getPermittedAccessibilityServices(ComponentName admin)
Returns the list of permitted accessibility services set by this device or profile owner. |
List<String>
|
getPermittedInputMethods(ComponentName admin)
Returns the list of permitted input methods set by this device or profile owner. |
boolean
|
getScreenCaptureDisabled(ComponentName admin)
Determine whether or not screen capture has been disabled by the calling admin, if specified, or all admins. |
CharSequence
|
getShortSupportMessage(ComponentName admin)
Called by a device admin to get the short support message. |
boolean
|
getStorageEncryption(ComponentName admin)
Called by an application that is administering the device to determine the requested setting for secure storage. |
int
|
getStorageEncryptionStatus()
Called by an application that is administering the device to determine the current encryption status of the device. |
SystemUpdatePolicy
|
getSystemUpdatePolicy()
Retrieve a local system update policy set previously by |
List<PersistableBundle>
|
getTrustAgentConfiguration(ComponentName admin, ComponentName agent)
Gets configuration for the given trust agent based on aggregating all calls to
|
Bundle
|
getUserRestrictions(ComponentName admin)
Called by a profile or device owner to get user restrictions set with
|
String
|
getWifiMacAddress(ComponentName admin)
Called by device owner to get the MAC address of the Wi-Fi device. |
boolean
|
hasCaCertInstalled(ComponentName admin, byte[] certBuffer)
Returns whether this certificate is installed as a trusted CA. |
boolean
|
hasGrantedPolicy(ComponentName admin, int usesPolicy)
Returns true if an administrator has been granted a particular device policy. |
boolean
|
installCaCert(ComponentName admin, byte[] certBuffer)
Installs the given certificate as a user CA. |
boolean
|
installKeyPair(ComponentName admin, PrivateKey privKey, Certificate[] certs, String alias, boolean requestAccess)
Called by a device or profile owner, or delegated certificate installer, to install a certificate chain and corresponding private key for the leaf certificate. |
boolean
|
installKeyPair(ComponentName admin, PrivateKey privKey, Certificate cert, String alias)
Called by a device or profile owner, or delegated certificate installer, to install a certificate and corresponding private key. |
boolean
|
isActivePasswordSufficient()
Determine whether the current password the user has set is sufficient to meet the policy requirements (e.g. |
boolean
|
isAdminActive(ComponentName admin)
Return true if the given administrator component is currently active (enabled) in the system. |
boolean
|
isApplicationHidden(ComponentName admin, String packageName)
Called by profile or device owners to determine if a package is hidden. |
boolean
|
isCallerApplicationRestrictionsManagingPackage()
Called by any application to find out whether it has been granted permission via
|
boolean
|
isDeviceOwnerApp(String packageName)
Used to determine if a particular package has been registered as a Device Owner app. |
boolean
|
isLockTaskPermitted(String pkg)
This function lets the caller know whether the given component is allowed to start the lock task mode. |
boolean
|
isManagedProfile(ComponentName admin)
Return if this user is a managed profile of another user. |
boolean
|
isMasterVolumeMuted(ComponentName admin)
Called by profile or device owners to check whether the master volume mute is on or off. |
boolean
|
isPackageSuspended(ComponentName admin, String packageName)
Called by device or profile owners to determine if a package is suspended. |
boolean
|
isProfileOwnerApp(String packageName)
Used to determine if a particular package is registered as the profile owner for the user. |
boolean
|
isProvisioningAllowed(String action)
Returns if provisioning a managed profile or device is possible or not. |
boolean
|
isSecurityLoggingEnabled(ComponentName admin)
Return whether security logging is enabled or not by the device owner. |
boolean
|
isUninstallBlocked(ComponentName admin, String packageName)
Check whether the user has been blocked by device policy from uninstalling a package. |
void
|
lockNow()
Make the device lock immediately, as if the lock screen timeout has expired at the point of this call. |
void
|
reboot(ComponentName admin)
Called by device owner to reboot the device. |
void
|
removeActiveAdmin(ComponentName admin)
Remove a current administration component. |
boolean
|
removeCrossProfileWidgetProvider(ComponentName admin, String packageName)
Called by the profile owner of a managed profile to disable widget providers from a given package to be available in the parent profile. |
boolean
|
removeKeyPair(ComponentName admin, String alias)
Called by a device or profile owner, or delegated certificate installer, to remove a certificate and private key pair installed under a given alias. |
boolean
|
removeUser(ComponentName admin, UserHandle userHandle)
Called by a device owner to remove a user and all associated data. |
boolean
|
requestBugreport(ComponentName admin)
Called by a device owner to request a bugreport. |
boolean
|
resetPassword(String password, int flags)
Force a new device unlock password (the password needed to access the entire device, not for individual accounts) on the user. |
List<SecurityLog.SecurityEvent>
|
retrievePreRebootSecurityLogs(ComponentName admin)
Called by device owners to retrieve device logs from before the device's last reboot. |
List<SecurityLog.SecurityEvent>
|
retrieveSecurityLogs(ComponentName admin)
Called by device owner to retrieve all new security logging entries since the last call to this API after device boots. |
void
|
setAccountManagementDisabled(ComponentName admin, String accountType, boolean disabled)
Called by a device owner or profile owner to disable account management for a specific type of account. |
void
|
setAlwaysOnVpnPackage(ComponentName admin, String vpnPackage, boolean lockdownEnabled)
Called by a device or profile owner to configure an always-on VPN connection through a specific application for the current user. |
boolean
|
setApplicationHidden(ComponentName admin, String packageName, boolean hidden)
Called by profile or device owners to hide or unhide packages. |
void
|
setApplicationRestrictions(ComponentName admin, String packageName, Bundle settings)
Sets the application restrictions for a given target application running in the calling user. |
void
|
setApplicationRestrictionsManagingPackage(ComponentName admin, String packageName)
Called by a profile owner or device owner to grant permission to a package to manage
application restrictions for the calling user via |
void
|
setAutoTimeRequired(ComponentName admin, boolean required)
Called by a device owner to set whether auto time is required. |
void
|
setBluetoothContactSharingDisabled(ComponentName admin, boolean disabled)
Called by a profile owner of a managed profile to set whether bluetooth devices can access enterprise contacts. |
void
|
setCameraDisabled(ComponentName admin, boolean disabled)
Called by an application that is administering the device to disable all cameras on the device, for this user. |
void
|
setCertInstallerPackage(ComponentName admin, String installerPackage)
Called by a profile owner or device owner to grant access to privileged certificate manipulation APIs to a third-party certificate installer app. |
void
|
setCrossProfileCallerIdDisabled(ComponentName admin, boolean disabled)
Called by a profile owner of a managed profile to set whether caller-Id information from the managed profile will be shown in the parent profile, for incoming calls. |
void
|
setCrossProfileContactsSearchDisabled(ComponentName admin, boolean disabled)
Called by a profile owner of a managed profile to set whether contacts search from the managed profile will be shown in the parent profile, for incoming calls. |
void
|
setDeviceOwnerLockScreenInfo(ComponentName admin, CharSequence info)
Sets the device owner information to be shown on the lock screen. |
void
|
setGlobalSetting(ComponentName admin, String setting, String value)
Called by device owners to update |
boolean
|
setKeyguardDisabled(ComponentName admin, boolean disabled)
Called by a device owner to disable the keyguard altogether. |
void
|
setKeyguardDisabledFeatures(ComponentName admin, int which)
Called by an application that is administering the device to disable keyguard customizations, such as widgets. |
void
|
setLockTaskPackages(ComponentName admin, String[] packages)
Sets which packages may enter lock task mode. |
void
|
setLongSupportMessage(ComponentName admin, CharSequence message)
Called by a device admin to set the long support message. |
void
|
setMasterVolumeMuted(ComponentName admin, boolean on)
Called by profile or device owners to set the master volume mute on or off. |
void
|
setMaximumFailedPasswordsForWipe(ComponentName admin, int num)
Setting this to a value greater than zero enables a built-in policy that will perform a device or profile wipe after too many incorrect device-unlock passwords have been entered. |
void
|
setMaximumTimeToLock(ComponentName admin, long timeMs)
Called by an application that is administering the device to set the maximum time for user activity until the device will lock. |
void
|
setOrganizationColor(ComponentName admin, int color)
Called by a profile owner of a managed profile to set the color used for customization. |
void
|
setOrganizationName(ComponentName admin, CharSequence title)
Called by a profile owner of a managed profile to set the name of the organization under management. |
String[]
|
setPackagesSuspended(ComponentName admin, String[] packageNames, boolean suspended)
Called by device or profile owners to suspend packages for this user. |
void
|
setPasswordExpirationTimeout(ComponentName admin, long timeout)
Called by a device admin to set the password expiration timeout. |
void
|
setPasswordHistoryLength(ComponentName admin, int length)
Called by an application that is administering the device to set the length of the password history. |
void
|
setPasswordMinimumLength(ComponentName admin, int length)
Called by an application that is administering the device to set the minimum allowed password length. |
void
|
setPasswordMinimumLetters(ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of letters required in the password. |
void
|
setPasswordMinimumLowerCase(ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of lower case letters required in the password. |
void
|
setPasswordMinimumNonLetter(ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of non-letter characters (numerical digits or symbols) required in the password. |
void
|
setPasswordMinimumNumeric(ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of numerical digits required in the password. |
void
|
setPasswordMinimumSymbols(ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of symbols required in the password. |
void
|
setPasswordMinimumUpperCase(ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of upper case letters required in the password. |
void
|
setPasswordQuality(ComponentName admin, int quality)
Called by an application that is administering the device to set the password restrictions it is imposing. |
boolean
|
setPermissionGrantState(ComponentName admin, String packageName, String permission, int grantState)
Sets the grant state of a runtime permission for a specific application. |
void
|
setPermissionPolicy(ComponentName admin, int policy)
Called by profile or device owners to set the default response for future runtime permission requests by applications. |
boolean
|
setPermittedAccessibilityServices(ComponentName admin, List<String> packageNames)
Called by a profile or device owner to set the permitted accessibility services. |
boolean
|
setPermittedInputMethods(ComponentName admin, List<String> packageNames)
Called by a profile or device owner to set the permitted input methods services. |
void
|
setProfileEnabled(ComponentName admin)
Sets the enabled state of the profile. |
void
|
setProfileName(ComponentName admin, String profileName)
Sets the name of the profile. |
void
|
setRecommendedGlobalProxy(ComponentName admin, ProxyInfo proxyInfo)
Set a network-independent global HTTP proxy. |
void
|
setRestrictionsProvider(ComponentName admin, ComponentName provider)
Designates a specific service component as the provider for making permission requests of a local or remote administrator of the user. |
void
|
setScreenCaptureDisabled(ComponentName admin, boolean disabled)
Called by a device/profile owner to set whether the screen capture is disabled. |
void
|
setSecureSetting(ComponentName admin, String setting, String value)
Called by profile or device owners to update |
void
|
setSecurityLoggingEnabled(ComponentName admin, boolean enabled)
Called by device owner to control the security logging feature. |
void
|
setShortSupportMessage(ComponentName admin, CharSequence message)
Called by a device admin to set the short support message. |
boolean
|
setStatusBarDisabled(ComponentName admin, boolean disabled)
Called by device owner to disable the status bar. |
int
|
setStorageEncryption(ComponentName admin, boolean encrypt)
Called by an application that is administering the device to request that the storage system be encrypted. |
void
|
setSystemUpdatePolicy(ComponentName admin, SystemUpdatePolicy policy)
Called by device owners to set a local system update policy. |
void
|
setTrustAgentConfiguration(ComponentName admin, ComponentName target, PersistableBundle configuration)
Sets a list of configuration features to enable for a TrustAgent component. |
void
|
setUninstallBlocked(ComponentName admin, String packageName, boolean uninstallBlocked)
Called by profile or device owners to change whether a user can uninstall a package. |
void
|
setUserIcon(ComponentName admin, Bitmap icon)
Called by profile or device owners to set the user's photo. |
boolean
|
switchUser(ComponentName admin, UserHandle userHandle)
Called by a device owner to switch the specified user to the foreground. |
void
|
uninstallAllUserCaCerts(ComponentName admin)
Uninstalls all custom trusted CA certificates from the profile. |
void
|
uninstallCaCert(ComponentName admin, byte[] certBuffer)
Uninstalls the given certificate from trusted user CAs, if present. |
void
|
wipeData(int flags)
Ask the user data be wiped. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
String ACTION_ADD_DEVICE_ADMIN
Activity action: ask the user to add a new device administrator to the system.
The desired policy is the ComponentName of the policy in the
EXTRA_DEVICE_ADMIN
extra field. This will invoke a UI to
bring the user through adding the device administrator to the system (or
allowing them to reject it).
You can optionally include the EXTRA_ADD_EXPLANATION
field to provide the user with additional explanation (in addition
to your component's description) about what is being added.
If your administrator is already active, this will ordinarily return immediately (without user intervention). However, if your administrator has been updated and is requesting additional uses-policy flags, the user will be presented with the new list. New policies will not be available to the updated administrator until the user has accepted the new list.
Constant Value: "android.app.action.ADD_DEVICE_ADMIN"
String ACTION_DEVICE_OWNER_CHANGED
Broadcast action: sent when the device owner is set or changed. This broadcast is sent only to the primary user.
See also:
Constant Value: "android.app.action.DEVICE_OWNER_CHANGED"
String ACTION_MANAGED_PROFILE_PROVISIONED
Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile has completed successfully.
The broadcast is limited to the primary profile, to the app specified in the provisioning
intent with action ACTION_PROVISION_MANAGED_PROFILE
.
This intent will contain the extra EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE
which
corresponds to the account requested to be migrated at provisioning time, if any.
Constant Value: "android.app.action.MANAGED_PROFILE_PROVISIONED"
String ACTION_PROVISION_MANAGED_DEVICE
Activity action: Starts the provisioning flow which sets up a managed device.
Must be started with startActivityForResult(Intent, int)
.
During device owner provisioning a device admin app is set as the owner of the device. A device owner has full control over the device. The device owner can not be modified by the user.
A typical use case would be a device that is owned by a company, but used by either an employee or client.
An intent with this action can be sent only on an unprovisioned device.
It is possible to check if provisioning is allowed or not by querying the method
isProvisioningAllowed(String)
.
The intent contains the following extras:
EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME
EXTRA_PROVISIONING_SKIP_ENCRYPTION
, optionalEXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED
, optionalEXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE
, optionalEXTRA_PROVISIONING_LOGO_URI
, optionalEXTRA_PROVISIONING_MAIN_COLOR
, optionalWhen device owner provisioning has completed, an intent of the type
ACTION_PROFILE_PROVISIONING_COMPLETE
is broadcast to the
device owner.
If provisioning fails, the device is factory reset.
A result code of RESULT_OK
implies that the synchronous part
of the provisioning flow was successful, although this doesn't guarantee the full flow will
succeed. Conversely a result code of RESULT_CANCELED
implies
that the user backed-out of provisioning, or some precondition for provisioning wasn't met.
Constant Value: "android.app.action.PROVISION_MANAGED_DEVICE"
String ACTION_PROVISION_MANAGED_PROFILE
Activity action: Starts the provisioning flow which sets up a managed profile.
A managed profile allows data separation for example for the usage of a device as a personal and corporate device. The user which provisioning is started from and the managed profile share a launcher.
This intent will typically be sent by a mobile device management application (MDM). Provisioning adds a managed profile and sets the MDM as the profile owner who has full control over the profile.
It is possible to check if provisioning is allowed or not by querying the method
isProvisioningAllowed(String)
.
In version LOLLIPOP
, this intent must contain the
extra EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME
.
As of M
, it should contain the extra
EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME
instead, although specifying only
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME
is still supported.
The intent may also contain the following extras:
EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE
, optional EXTRA_PROVISIONING_SKIP_ENCRYPTION
, optional, supported from
N
EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE
, optionalEXTRA_PROVISIONING_LOGO_URI
, optionalEXTRA_PROVISIONING_MAIN_COLOR
, optionalWhen managed provisioning has completed, broadcasts are sent to the application specified
in the provisioning intent. The
ACTION_PROFILE_PROVISIONING_COMPLETE
broadcast is sent in the
managed profile and the ACTION_MANAGED_PROFILE_PROVISIONED
broadcast is sent in
the primary profile.
If provisioning fails, the managedProfile is removed so the device returns to its previous state.
If launched with startActivityForResult(Intent, int)
a
result code of RESULT_OK
implies that the synchronous part of
the provisioning flow was successful, although this doesn't guarantee the full flow will
succeed. Conversely a result code of RESULT_CANCELED
implies
that the user backed-out of provisioning, or some precondition for provisioning wasn't met.
Constant Value: "android.app.action.PROVISION_MANAGED_PROFILE"
String ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
Activity action: have the user enter a new password for the parent profile.
If the intent is launched from within a managed profile, this will trigger
entering a new password for the parent of the profile. In all other cases
the behaviour is identical to ACTION_SET_NEW_PASSWORD
.
Constant Value: "android.app.action.SET_NEW_PARENT_PROFILE_PASSWORD"
String ACTION_SET_NEW_PASSWORD
Activity action: have the user enter a new password. This activity should
be launched after using setPasswordQuality(ComponentName, int)
,
or setPasswordMinimumLength(ComponentName, int)
to have the user
enter a new password that meets the current requirements. You can use
isActivePasswordSufficient()
to determine whether you need to
have the user select a new password in order to meet the current
constraints. Upon being resumed from this activity, you can check the new
password characteristics to see if they are sufficient.
If the intent is launched from within a managed profile with a profile
owner built against M
or before,
this will trigger entering a new password for the parent of the profile.
For all other cases it will trigger entering a new password for the user
or profile it is launched from.
See also:
Constant Value: "android.app.action.SET_NEW_PASSWORD"
String ACTION_START_ENCRYPTION
Activity action: begin the process of encrypting data on the device. This activity should
be launched after using setStorageEncryption(ComponentName, boolean)
to request encryption be activated.
After resuming from this activity, use getStorageEncryption(ComponentName)
to check encryption status. However, on some devices this activity may never return, as
it may trigger a reboot and in some cases a complete data wipe of the device.
Constant Value: "android.app.action.START_ENCRYPTION"
String ACTION_SYSTEM_UPDATE_POLICY_CHANGED
Broadcast action: notify that a new local system update policy has been set by the device
owner. The new policy can be retrieved by getSystemUpdatePolicy()
.
Constant Value: "android.app.action.SYSTEM_UPDATE_POLICY_CHANGED"
int ENCRYPTION_STATUS_ACTIVATING
Result code for getStorageEncryptionStatus()
:
indicating that encryption is not currently active, but is currently
being activated. This is only reported by devices that support
encryption of data and only when the storage is currently
undergoing a process of becoming encrypted. A device that must reboot and/or wipe data
to become encrypted will never return this value.
Constant Value: 2 (0x00000002)
int ENCRYPTION_STATUS_ACTIVE
Result code for setStorageEncryption(ComponentName, boolean)
and getStorageEncryptionStatus()
:
indicating that encryption is active.
Also see ENCRYPTION_STATUS_ACTIVE_PER_USER
.
Constant Value: 3 (0x00000003)
int ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY
Result code for getStorageEncryptionStatus()
:
indicating that encryption is active, but an encryption key has not
been set by the user.
Constant Value: 4 (0x00000004)
int ENCRYPTION_STATUS_ACTIVE_PER_USER
Result code for getStorageEncryptionStatus()
:
indicating that encryption is active and the encryption key is tied to the user or profile.
This value is only returned to apps targeting API level 24 and above. For apps targeting
earlier API levels, ENCRYPTION_STATUS_ACTIVE
is returned, even if the
encryption key is specific to the user or profile.
Constant Value: 5 (0x00000005)
int ENCRYPTION_STATUS_INACTIVE
Result code for setStorageEncryption(ComponentName, boolean)
and getStorageEncryptionStatus()
:
indicating that encryption is supported, but is not currently active.
Constant Value: 1 (0x00000001)
int ENCRYPTION_STATUS_UNSUPPORTED
Result code for setStorageEncryption(ComponentName, boolean)
and getStorageEncryptionStatus()
:
indicating that encryption is not supported.
Constant Value: 0 (0x00000000)
String EXTRA_ADD_EXPLANATION
An optional CharSequence providing additional explanation for why the admin is being added.
See also:
Constant Value: "android.app.extra.ADD_EXPLANATION"
String EXTRA_DEVICE_ADMIN
The ComponentName of the administrator component.
See also:
Constant Value: "android.app.extra.DEVICE_ADMIN"
String EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE
An Account
extra holding the account to migrate during managed
profile provisioning. If the account supplied is present in the primary user, it will be
copied, along with its credentials to the managed profile and removed from the primary user.
Use with ACTION_PROVISION_MANAGED_PROFILE
.
Constant Value: "android.app.extra.PROVISIONING_ACCOUNT_TO_MIGRATE"
String EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE
A Parcelable
extra of type PersistableBundle
that
allows a mobile device management application or NFC programmer application which starts
managed provisioning to pass data to the management application instance after provisioning.
If used with ACTION_PROVISION_MANAGED_PROFILE
it can be used by the application that
sends the intent to pass data to itself on the newly created profile.
If used with ACTION_PROVISION_MANAGED_DEVICE
it allows passing data to the same
instance of the app on the primary user.
Starting from M
, if used with
MIME_TYPE_PROVISIONING_NFC
as part of NFC managed device provisioning, the NFC
message should contain a stringified Properties
instance, whose string
properties will be converted into a PersistableBundle
and passed to the
management application after provisioning.
In both cases the application receives the data in
onProfileProvisioningComplete(Context, Intent)
via an intent with the action
ACTION_PROFILE_PROVISIONING_COMPLETE
. The bundle is not changed
during the managed provisioning.
Constant Value: "android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE"
String EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME
A ComponentName extra indicating the device admin receiver of the mobile device management application that will be set as the profile owner or device owner and active admin.
If an application starts provisioning directly via an intent with action
ACTION_PROVISION_MANAGED_PROFILE
or
ACTION_PROVISION_MANAGED_DEVICE
the package name of this
component has to match the package name of the application that started provisioning.
This component is set as device owner and active admin when device owner provisioning is
started by an intent with action ACTION_PROVISION_MANAGED_DEVICE
or by an NFC
message containing an NFC record with MIME type
MIME_TYPE_PROVISIONING_NFC
. For the NFC record, the component name must be
flattened to a string, via flattenToShortString()
.
See also:
Constant Value: "android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME"
String EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE
An int extra holding a minimum required version code for the device admin package. If the
device admin is already installed on the device, it will only be re-downloaded from
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION
if the version of the
installed package is less than this version code.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE"
String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM
A String extra holding the URL-safe base64 encoded SHA-256 or SHA-1 hash (see notes below) of
the file at download location specified in
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION
.
Either this extra or EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM
must be
present. The provided checksum must match the checksum of the file at the download
location. If the checksum doesn't match an error will be shown to the user and the user will
be asked to factory reset the device.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Note: for devices running LOLLIPOP
and LOLLIPOP_MR1
only SHA-1 hash is supported.
Starting from M
, this parameter accepts SHA-256 in
addition to SHA-1. Support for SHA-1 is likely to be removed in future OS releases.
Constant Value: "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM"
String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER
A String extra holding a http cookie header which should be used in the http request to the
url specified in EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER"
String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION
A String extra holding a url that specifies the download location of the device admin package. When not provided it is assumed that the device admin package is already installed.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION"
String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME
This constant was deprecated
in API level 23.
Use EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME
. This extra is still
supported, but only if there is only one device admin receiver in the package that requires
the permission BIND_DEVICE_ADMIN
.
A String extra holding the package name of the mobile device management application that will be set as the profile owner or device owner.
If an application starts provisioning directly via an intent with action
ACTION_PROVISION_MANAGED_PROFILE
this package has to match the package name of the
application that started provisioning. The package will be set as profile owner in that case.
This package is set as device owner when device owner provisioning is started by an NFC
message containing an NFC record with MIME type MIME_TYPE_PROVISIONING_NFC
.
When this extra is set, the application must have exactly one device admin receiver. This receiver will be set as the profile or device owner and active admin.
See also:
Constant Value: "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME"
String EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM
A String extra holding the URL-safe base64 encoded SHA-256 checksum of any signature of the
android package archive at the download location specified in EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION
.
The signatures of an android package archive can be obtained using
getPackageArchiveInfo(String, int)
with flag
GET_SIGNATURES
.
Either this extra or EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM
must be
present. The provided checksum must match the checksum of any signature of the file at
the download location. If the checksum does not match an error will be shown to the user and
the user will be asked to factory reset the device.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM"
String EXTRA_PROVISIONING_EMAIL_ADDRESS
A String extra that, holds the email address of the account which a managed profile is
created for. Used with ACTION_PROVISION_MANAGED_PROFILE
and
ACTION_PROFILE_PROVISIONING_COMPLETE
.
This extra is part of the EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE
.
If the ACTION_PROVISION_MANAGED_PROFILE
intent that starts managed provisioning
contains this extra, it is forwarded in the
ACTION_PROFILE_PROVISIONING_COMPLETE
intent to the mobile
device management application that was set as the profile owner during provisioning.
It is usually used to avoid that the user has to enter their email address twice.
Constant Value: "android.app.extra.PROVISIONING_EMAIL_ADDRESS"
String EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED
A Boolean extra that can be used by the mobile device management application to skip the
disabling of system apps during provisioning when set to true
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
or an intent with action
ACTION_PROVISION_MANAGED_DEVICE
that starts device owner provisioning.
Constant Value: "android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED"
String EXTRA_PROVISIONING_LOCALE
A String extra holding the Locale
that the device will be set to.
Format: xx_yy, where xx is the language code, and yy the country code.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_LOCALE"
String EXTRA_PROVISIONING_LOCAL_TIME
A Long extra holding the wall clock time (in milliseconds) to be set on the device's
AlarmManager
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_LOCAL_TIME"
String EXTRA_PROVISIONING_LOGO_URI
A Uri
extra pointing to a logo image. This image will be shown during the
provisioning. If this extra is not passed, a default image will be shown.
SCHEME_CONTENT
)SCHEME_ANDROID_RESOURCE
)It is the responsability of the caller to provide an image with a reasonable pixed density for the device.
If a content: URI is passed, the intent should have the flag
FLAG_GRANT_READ_URI_PERMISSION
and the uri should be added to the
ClipData
of the intent too.
Use in an intent with action ACTION_PROVISION_MANAGED_PROFILE
or
ACTION_PROVISION_MANAGED_DEVICE
Constant Value: "android.app.extra.PROVISIONING_LOGO_URI"
String EXTRA_PROVISIONING_MAIN_COLOR
A integer extra indicating the predominant color to show during the provisioning.
Refer to Color
for how the color is represented.
Use with ACTION_PROVISION_MANAGED_PROFILE
or
ACTION_PROVISION_MANAGED_DEVICE
.
Constant Value: "android.app.extra.PROVISIONING_MAIN_COLOR"
String EXTRA_PROVISIONING_SKIP_ENCRYPTION
A boolean extra indicating whether device encryption can be skipped as part of device owner or managed profile provisioning.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
or an intent with action
ACTION_PROVISION_MANAGED_DEVICE
that starts device owner provisioning.
From N
onwards, this is also supported for an
intent with action ACTION_PROVISION_MANAGED_PROFILE
.
Constant Value: "android.app.extra.PROVISIONING_SKIP_ENCRYPTION"
String EXTRA_PROVISIONING_TIME_ZONE
A String extra holding the time zone AlarmManager
that the device
will be set to.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_TIME_ZONE"
String EXTRA_PROVISIONING_WIFI_HIDDEN
A boolean extra indicating whether the wifi network in EXTRA_PROVISIONING_WIFI_SSID
is hidden or not.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_WIFI_HIDDEN"
String EXTRA_PROVISIONING_WIFI_PAC_URL
A String extra holding the proxy auto-config (PAC) URL for the wifi network in
EXTRA_PROVISIONING_WIFI_SSID
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_WIFI_PAC_URL"
String EXTRA_PROVISIONING_WIFI_PASSWORD
A String extra holding the password of the wifi network in
EXTRA_PROVISIONING_WIFI_SSID
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_WIFI_PASSWORD"
String EXTRA_PROVISIONING_WIFI_PROXY_BYPASS
A String extra holding the proxy bypass for the wifi network in
EXTRA_PROVISIONING_WIFI_SSID
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_WIFI_PROXY_BYPASS"
String EXTRA_PROVISIONING_WIFI_PROXY_HOST
A String extra holding the proxy host for the wifi network in
EXTRA_PROVISIONING_WIFI_SSID
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_WIFI_PROXY_HOST"
String EXTRA_PROVISIONING_WIFI_PROXY_PORT
An int extra holding the proxy port for the wifi network in
EXTRA_PROVISIONING_WIFI_SSID
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_WIFI_PROXY_PORT"
String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE
A String extra indicating the security type of the wifi network in
EXTRA_PROVISIONING_WIFI_SSID
and could be one of NONE
, WPA
or
WEP
.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE"
String EXTRA_PROVISIONING_WIFI_SSID
A String extra holding the ssid of the wifi network that should be used during nfc device owner provisioning for downloading the mobile device management application.
Use in an NFC record with MIME_TYPE_PROVISIONING_NFC
that starts device owner
provisioning via an NFC bump.
Constant Value: "android.app.extra.PROVISIONING_WIFI_SSID"
int FLAG_MANAGED_CAN_ACCESS_PARENT
Flag used by addCrossProfileIntentFilter(ComponentName, IntentFilter, int)
to allow activities in
the managed profile to access intents sent from the parent profile.
That is, when an app in the parent profile calls
startActivity(Intent)
, the intent can be resolved by a
matching activity in the managed profile.
Constant Value: 2 (0x00000002)
int FLAG_PARENT_CAN_ACCESS_MANAGED
Flag used by addCrossProfileIntentFilter(ComponentName, IntentFilter, int)
to allow activities in
the parent profile to access intents sent from the managed profile.
That is, when an app in the managed profile calls
startActivity(Intent)
, the intent can be resolved by a
matching activity in the parent profile.
Constant Value: 1 (0x00000001)
int KEYGUARD_DISABLE_FEATURES_ALL
Disable all current and future keyguard customizations.
Constant Value: 2147483647 (0x7fffffff)
int KEYGUARD_DISABLE_FEATURES_NONE
Widgets are enabled in keyguard
Constant Value: 0 (0x00000000)
int KEYGUARD_DISABLE_FINGERPRINT
Disable fingerprint sensor on keyguard secure screens (e.g. PIN/Pattern/Password).
Constant Value: 32 (0x00000020)
int KEYGUARD_DISABLE_REMOTE_INPUT
Disable text entry into notifications on secure keyguard screens (e.g. PIN/Pattern/Password).
Constant Value: 64 (0x00000040)
int KEYGUARD_DISABLE_SECURE_CAMERA
Disable the camera on secure keyguard screens (e.g. PIN/Pattern/Password)
Constant Value: 2 (0x00000002)
int KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
Disable showing all notifications on secure keyguard screens (e.g. PIN/Pattern/Password)
Constant Value: 4 (0x00000004)
int KEYGUARD_DISABLE_TRUST_AGENTS
Ignore trust agent state on secure keyguard screens (e.g. PIN/Pattern/Password).
Constant Value: 16 (0x00000010)
int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS
Only allow redacted notifications on secure keyguard screens (e.g. PIN/Pattern/Password)
Constant Value: 8 (0x00000008)
int KEYGUARD_DISABLE_WIDGETS_ALL
Disable all keyguard widgets. Has no effect.
Constant Value: 1 (0x00000001)
String MIME_TYPE_PROVISIONING_NFC
This MIME type is used for starting the device owner provisioning.
During device owner provisioning a device admin app is set as the owner of the device. A device owner has full control over the device. The device owner can not be modified by the user and the only way of resetting the device is if the device owner app calls a factory reset.
A typical use case would be a device that is owned by a company, but used by either an employee or client.
The NFC message must be sent to an unprovisioned device.
The NFC record must contain a serialized Properties
object which
contains the following properties:
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION
, optionalEXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER
, optionalEXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM
, optionalEXTRA_PROVISIONING_LOCAL_TIME
(convert to String), optionalEXTRA_PROVISIONING_TIME_ZONE
, optionalEXTRA_PROVISIONING_LOCALE
, optionalEXTRA_PROVISIONING_WIFI_SSID
, optionalEXTRA_PROVISIONING_WIFI_HIDDEN
(convert to String), optionalEXTRA_PROVISIONING_WIFI_SECURITY_TYPE
, optionalEXTRA_PROVISIONING_WIFI_PASSWORD
, optionalEXTRA_PROVISIONING_WIFI_PROXY_HOST
, optionalEXTRA_PROVISIONING_WIFI_PROXY_PORT
(convert to String), optionalEXTRA_PROVISIONING_WIFI_PROXY_BYPASS
, optionalEXTRA_PROVISIONING_WIFI_PAC_URL
, optionalEXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE
, optional, supported from
M
As of M
, the properties should contain
EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME
instead of
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME
, (although specifying only
EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME
is still supported).
Constant Value: "application/com.android.managedprovisioning"
int PASSWORD_QUALITY_ALPHABETIC
Constant for setPasswordQuality(ComponentName, int)
: the user must have entered a
password containing at least alphabetic (or other symbol) characters.
Note that quality constants are ordered so that higher values are more
restrictive.
Constant Value: 262144 (0x00040000)
int PASSWORD_QUALITY_ALPHANUMERIC
Constant for setPasswordQuality(ComponentName, int)
: the user must have entered a
password containing at least both> numeric and
alphabetic (or other symbol) characters. Note that quality constants are
ordered so that higher values are more restrictive.
Constant Value: 327680 (0x00050000)
int PASSWORD_QUALITY_BIOMETRIC_WEAK
Constant for setPasswordQuality(ComponentName, int)
: the policy allows for low-security biometric
recognition technology. This implies technologies that can recognize the identity of
an individual to about a 3 digit PIN (false detection is less than 1 in 1,000).
Note that quality constants are ordered so that higher values are more restrictive.
Constant Value: 32768 (0x00008000)
int PASSWORD_QUALITY_COMPLEX
Constant for setPasswordQuality(ComponentName, int)
: the user must have entered a
password containing at least a letter, a numerical digit and a special
symbol, by default. With this password quality, passwords can be
restricted to contain various sets of characters, like at least an
uppercase letter, etc. These are specified using various methods,
like setPasswordMinimumLowerCase(ComponentName, int)
. Note
that quality constants are ordered so that higher values are more
restrictive.
Constant Value: 393216 (0x00060000)
int PASSWORD_QUALITY_NUMERIC
Constant for setPasswordQuality(ComponentName, int)
: the user must have entered a
password containing at least numeric characters. Note that quality
constants are ordered so that higher values are more restrictive.
Constant Value: 131072 (0x00020000)
int PASSWORD_QUALITY_NUMERIC_COMPLEX
Constant for setPasswordQuality(ComponentName, int)
: the user must have entered a
password containing at least numeric characters with no repeating (4444)
or ordered (1234, 4321, 2468) sequences. Note that quality
constants are ordered so that higher values are more restrictive.
Constant Value: 196608 (0x00030000)
int PASSWORD_QUALITY_SOMETHING
Constant for setPasswordQuality(ComponentName, int)
: the policy requires some kind
of password or pattern, but doesn't care what it is. Note that quality constants
are ordered so that higher values are more restrictive.
Constant Value: 65536 (0x00010000)
int PASSWORD_QUALITY_UNSPECIFIED
Constant for setPasswordQuality(ComponentName, int)
: the policy has no requirements
for the password. Note that quality constants are ordered so that higher
values are more restrictive.
Constant Value: 0 (0x00000000)
int PERMISSION_GRANT_STATE_DEFAULT
Runtime permission state: The user can manage the permission through the UI.
Constant Value: 0 (0x00000000)
int PERMISSION_GRANT_STATE_DENIED
Runtime permission state: The permission is denied to the app and the user cannot manage the permission through the UI.
Constant Value: 2 (0x00000002)
int PERMISSION_GRANT_STATE_GRANTED
Runtime permission state: The permission is granted to the app and the user cannot manage the permission through the UI.
Constant Value: 1 (0x00000001)
int PERMISSION_POLICY_AUTO_DENY
Permission policy to always deny new permission requests for runtime permissions. Already granted or denied permissions are not affected by this.
Constant Value: 2 (0x00000002)
int PERMISSION_POLICY_AUTO_GRANT
Permission policy to always grant new permission requests for runtime permissions. Already granted or denied permissions are not affected by this.
Constant Value: 1 (0x00000001)
int PERMISSION_POLICY_PROMPT
Permission policy to prompt user for new permission requests for runtime permissions. Already granted or denied permissions are not affected by this.
Constant Value: 0 (0x00000000)
int RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT
Flag for resetPassword(String, int)
: don't ask for user credentials on device boot.
If the flag is set, the device can be booted without asking for user password.
The absence of this flag does not change the current boot requirements. This flag
can be set by the device owner only. If the app is not the device owner, the flag
is ignored. Once the flag is set, it cannot be reverted back without resetting the
device to factory defaults.
Constant Value: 2 (0x00000002)
int RESET_PASSWORD_REQUIRE_ENTRY
Flag for resetPassword(String, int)
: don't allow other admins to change
the password again until the user has entered it.
Constant Value: 1 (0x00000001)
int SKIP_SETUP_WIZARD
Flag used by createAndManageUser(ComponentName, String, ComponentName, PersistableBundle, int)
to skip setup wizard after creating a new user.
Constant Value: 1 (0x00000001)
int WIPE_EXTERNAL_STORAGE
Flag for wipeData(int)
: also erase the device's external
storage (such as SD cards).
Constant Value: 1 (0x00000001)
int WIPE_RESET_PROTECTION_DATA
Flag for wipeData(int)
: also erase the factory reset protection
data.
This flag may only be set by device owner admins; if it is set by
other admins a SecurityException
will be thrown.
Constant Value: 2 (0x00000002)
void addCrossProfileIntentFilter (ComponentName admin, IntentFilter filter, int flags)
Called by the profile owner of a managed profile so that some intents sent in the managed profile can also be resolved in the parent, or vice versa. Only activity intents are supported.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
filter |
IntentFilter :
The IntentFilter the intent has to match to be also resolved in the
other profile |
flags |
int :
FLAG_MANAGED_CAN_ACCESS_PARENT and
FLAG_PARENT_CAN_ACCESS_MANAGED are supported. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean addCrossProfileWidgetProvider (ComponentName admin, String packageName)
Called by the profile owner of a managed profile to enable widget providers from a given package to be available in the parent profile. As a result the user will be able to add widgets from the white-listed package running under the profile to a widget host which runs under the parent profile, for example the home screen. Note that a package may have zero or more provider components, where each component provides a different widget type.
Note: By default no widget provider package is white-listed.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
The package from which widget providers are white-listed. |
Returns | |
---|---|
boolean |
Whether the package was added. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner. |
void addPersistentPreferredActivity (ComponentName admin, IntentFilter filter, ComponentName activity)
Called by a profile owner or device owner to add a default intent handler activity for intents that match a certain intent filter. This activity will remain the default intent handler even if the set of potential event handlers for the intent filter changes and if the intent preferences are reset.
The default disambiguation mechanism takes over if the activity is not installed (anymore). When the activity is (re)installed, it is automatically reset as default intent handler for the filter.
The calling device admin must be a profile owner or device owner. If it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
filter |
IntentFilter :
The IntentFilter for which a default handler is added. |
activity |
ComponentName :
The Activity that is added as default intent handler. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void addUserRestriction (ComponentName admin, String key)
Called by a profile or device owner to set a user restriction specified by the key.
The calling device admin must be a profile or device owner; if it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
key |
String :
The key of the restriction. See the constants in UserManager
for the list of keys. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void clearCrossProfileIntentFilters (ComponentName admin)
Called by a profile owner of a managed profile to remove the cross-profile intent filters that go from the managed profile to the parent, or from the parent to the managed profile. Only removes those that have been set by the profile owner.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void clearDeviceOwnerApp (String packageName)
Clears the current device owner. The caller must be the device owner. This function should be used cautiously as once it is called it cannot be undone. The device owner can only be set as a part of device setup before setup completes.
Parameters | |
---|---|
packageName |
String :
The package name of the device owner. |
Throws | |
---|---|
SecurityException |
if the caller is not in packageName or packageName
does not own the current device owner component.
|
void clearPackagePersistentPreferredActivities (ComponentName admin, String packageName)
Called by a profile owner or device owner to remove all persistent intent handler preferences
associated with the given package that were set by addPersistentPreferredActivity(ComponentName, IntentFilter, ComponentName)
.
The calling device admin must be a profile owner. If it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
The name of the package for which preferences are removed. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void clearProfileOwner (ComponentName admin)
Clears the active profile owner and removes all user restrictions. The caller must be from the same package as the active profile owner for this user, otherwise a SecurityException will be thrown.
This doesn't work for managed profile owners.
Parameters | |
---|---|
admin |
ComponentName :
The component to remove as the profile owner. |
Throws | |
---|---|
SecurityException |
if admin is not an active profile owner.
|
void clearUserRestriction (ComponentName admin, String key)
Called by a profile or device owner to clear a user restriction specified by the key.
The calling device admin must be a profile or device owner; if it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
key |
String :
The key of the restriction. See the constants in UserManager
for the list of keys. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
UserHandle createAndManageUser (ComponentName admin, String name, ComponentName profileOwner, PersistableBundle adminExtras, int flags)
Called by a device owner to create a user with the specified name and a given component of
the calling package as profile owner. The UserHandle returned by this method should not be
persisted as user handles are recycled as users are removed and created. If you need to
persist an identifier for this user, use getSerialNumberForUser(UserHandle)
. The new
user will not be started in the background.
admin is the DeviceAdminReceiver
which is the device owner. profileOwner is also a
DeviceAdminReceiver in the same package as admin, and will become the profile owner and will
be registered as an active admin on the new user. The profile owner package will be installed
on the new user.
If the adminExtras are not null, they will be stored on the device until the user is started for the first time. Then the extras will be passed to the admin when onEnable is called.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
name |
String :
The user's name. |
profileOwner |
ComponentName :
Which DeviceAdminReceiver will be profile owner. Has to be in the
same package as admin, otherwise no user is created and an
IllegalArgumentException is thrown. |
adminExtras |
PersistableBundle :
Extras that will be passed to onEnable of the admin receiver on the new
user. |
flags |
int :
SKIP_SETUP_WIZARD is supported. |
Returns | |
---|---|
UserHandle |
the UserHandle object for the created user, or null if the
user could not be created. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
See also:
int enableSystemApp (ComponentName admin, Intent intent)
Called by profile or device owners to re-enable system apps by intent that were disabled by default when the user was initialized.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
intent |
Intent :
An intent matching the app(s) to be installed. All apps that resolve for this
intent will be re-enabled in the calling profile. |
Returns | |
---|---|
int |
int The number of activities that matched the intent and were installed. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void enableSystemApp (ComponentName admin, String packageName)
Called by profile or device owners to re-enable a system app that was disabled by default when the user was initialized.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
The package to be re-enabled in the calling profile. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
String[] getAccountTypesWithManagementDisabled ()
Gets the array of accounts for which account management is disabled by the profile owner.
Account management can be disabled/enabled by calling
setAccountManagementDisabled(ComponentName, String, boolean)
.
Returns | |
---|---|
String[] |
a list of account types for which account management has been disabled. |
List<ComponentName> getActiveAdmins ()
Return a list of all currently active device administrators' component
names. If there are no administrators null
may be
returned.
Returns | |
---|---|
List<ComponentName> |
String getAlwaysOnVpnPackage (ComponentName admin)
Called by a device or profile owner to read the name of the package administering an
always-on VPN connection for the current user. If there is no such package, or the always-on
VPN is provided by the system instead of by an application, null
will be returned.
Parameters | |
---|---|
admin |
ComponentName
|
Returns | |
---|---|
String |
Package name of VPN controller responsible for always-on VPN, or null if none
is set. |
Throws | |
---|---|
SecurityException |
if admin is not a device or a profile owner.
|
Bundle getApplicationRestrictions (ComponentName admin, String packageName)
Retrieves the application restrictions for a given target application running in the calling user.
The caller must be a profile or device owner on that user, or the package allowed to manage
application restrictions via setApplicationRestrictionsManagingPackage(ComponentName, String)
; otherwise a
security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if called by the application restrictions managing package. |
packageName |
String :
The name of the package to fetch restricted settings of. |
Returns | |
---|---|
Bundle |
Bundle of settings corresponding to what was set last time
setApplicationRestrictions(ComponentName, String, Bundle) was called, or an empty
Bundle if no restrictions have been set. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner. |
String getApplicationRestrictionsManagingPackage (ComponentName admin)
Called by a profile owner or device owner to retrieve the application restrictions managing
package for the current user, or null
if none is set.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
String |
The package name allowed to manage application restrictions on the current user, or
null if none is set. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean getAutoTimeRequired ()
Returns | |
---|---|
boolean |
true if auto time is required. |
boolean getBluetoothContactSharingDisabled (ComponentName admin)
Called by a profile owner of a managed profile to determine whether or not Bluetooth devices cannot access enterprise contacts.
The calling device admin must be a profile owner. If it is not, a security exception will be thrown.
This API works on managed profile only.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
boolean |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean getCameraDisabled (ComponentName admin)
Determine whether or not the device's cameras have been disabled for this user, either by the calling admin, if specified, or all admins.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to check whether any admins
have disabled the camera
|
Returns | |
---|---|
boolean |
String getCertInstallerPackage (ComponentName admin)
Called by a profile owner or device owner to retrieve the certificate installer for the user. null if none is set.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
String |
The package name of the current delegated certificate installer, or null if
none is set. |
Throws | |
---|---|
SecurityException |
if admin is not a device or a profile owner.
|
boolean getCrossProfileCallerIdDisabled (ComponentName admin)
Called by a profile owner of a managed profile to determine whether or not caller-Id information has been disabled.
The calling device admin must be a profile owner. If it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
boolean |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean getCrossProfileContactsSearchDisabled (ComponentName admin)
Called by a profile owner of a managed profile to determine whether or not contacts search has been disabled.
The calling device admin must be a profile owner. If it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
boolean |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
List<String> getCrossProfileWidgetProviders (ComponentName admin)
Called by the profile owner of a managed profile to query providers from which packages are available in the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
List<String> |
The white-listed package list. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner.
|
int getCurrentFailedPasswordAttempts ()
Retrieve the number of times the user has failed at entering a password since that last successful password entry.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to retrieve the number of failed
password attemts for the parent user.
The calling device admin must have requested USES_POLICY_WATCH_LOGIN
to be able to call this method; if it has not, a security exception will be thrown.
Returns | |
---|---|
int |
The number of times user has entered an incorrect password since the last correct password entry. |
Throws | |
---|---|
SecurityException |
if the calling application does not own an active administrator
that uses USES_POLICY_WATCH_LOGIN
|
CharSequence getDeviceOwnerLockScreenInfo ()
Returns | |
---|---|
CharSequence |
The device owner information. If it is not set returns null .
|
List<byte[]> getInstalledCaCerts (ComponentName admin)
Returns all CA certificates that are currently trusted, excluding system CA certificates. If a user has installed any certificates by other means than device policy these will be included too.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if calling from a delegated certificate installer. |
Returns | |
---|---|
List<byte[]> |
a List of byte[] arrays, each encoding one user CA certificate. |
Throws | |
---|---|
SecurityException |
if admin is not null and not a device or profile
owner.
|
int getKeyguardDisabledFeatures (ComponentName admin)
Determine whether or not features have been disabled in keyguard either by the calling admin, if specified, or all admins that set retrictions on this user and its participating profiles. Restrictions on profiles that have a separate challenge are not taken into account.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to check whether any
admins have disabled features in keyguard. |
Returns | |
---|---|
int |
bitfield of flags. See setKeyguardDisabledFeatures(ComponentName, int)
for a list.
|
CharSequence getLongSupportMessage (ComponentName admin)
Called by a device admin to get the long support message.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
CharSequence |
The message set by setLongSupportMessage(ComponentName, CharSequence) or
null if no message has been set. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator.
|
int getMaximumFailedPasswordsForWipe (ComponentName admin)
Retrieve the current maximum number of login attempts that are allowed before the device or profile is wiped, for a particular admin or all admins that set retrictions on this user and its participating profiles. Restrictions on profiles that have a separate challenge are not taken into account.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
the value for the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to aggregate
all admins.
|
Returns | |
---|---|
int |
long getMaximumTimeToLock (ComponentName admin)
Retrieve the current maximum time to unlock for a particular admin or all admins that set retrictions on this user and its participating profiles. Restrictions on profiles that have a separate challenge are not taken into account.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to aggregate
all admins. |
Returns | |
---|---|
long |
time in milliseconds for the given admin or the minimum value (strictest) of all admins if admin is null. Returns 0 if there are no restrictions. |
int getOrganizationColor (ComponentName admin)
Called by a profile owner of a managed profile to retrieve the color used for customization. This color is used as background color of the confirm credentials screen for that user.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
int |
The 24bit (0xRRGGBB) representation of the color to be used. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner.
|
CharSequence getOrganizationName (ComponentName admin)
Called by a profile owner of a managed profile to retrieve the name of the organization under management.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
CharSequence |
The organization name or null if none is set. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner.
|
DevicePolicyManager getParentProfileInstance (ComponentName admin)
Called by the profile owner of a managed profile to obtain a DevicePolicyManager
whose calls act on the parent profile.
The following methods are supported for the parent instance, all other methods will throw a SecurityException when called on the parent instance:
getPasswordQuality(ComponentName)
setPasswordQuality(ComponentName, int)
getPasswordMinimumLength(ComponentName)
setPasswordMinimumLength(ComponentName, int)
getPasswordMinimumUpperCase(ComponentName)
setPasswordMinimumUpperCase(ComponentName, int)
getPasswordMinimumLowerCase(ComponentName)
setPasswordMinimumLowerCase(ComponentName, int)
getPasswordMinimumLetters(ComponentName)
setPasswordMinimumLetters(ComponentName, int)
getPasswordMinimumNumeric(ComponentName)
setPasswordMinimumNumeric(ComponentName, int)
getPasswordMinimumSymbols(ComponentName)
setPasswordMinimumSymbols(ComponentName, int)
getPasswordMinimumNonLetter(ComponentName)
setPasswordMinimumNonLetter(ComponentName, int)
getPasswordHistoryLength(ComponentName)
setPasswordHistoryLength(ComponentName, int)
getPasswordExpirationTimeout(ComponentName)
setPasswordExpirationTimeout(ComponentName, long)
getPasswordExpiration(ComponentName)
isActivePasswordSufficient()
getCurrentFailedPasswordAttempts()
getMaximumFailedPasswordsForWipe(ComponentName)
setMaximumFailedPasswordsForWipe(ComponentName, int)
getMaximumTimeToLock(ComponentName)
setMaximumTimeToLock(ComponentName, long)
lockNow()
getKeyguardDisabledFeatures(ComponentName)
setKeyguardDisabledFeatures(ComponentName, int)
getTrustAgentConfiguration(ComponentName, ComponentName)
setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle)
Parameters | |
---|---|
admin |
ComponentName
|
Returns | |
---|---|
DevicePolicyManager |
a new instance of DevicePolicyManager that acts on the parent profile. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner.
|
long getPasswordExpiration (ComponentName admin)
Get the current password expiration time for a particular admin or all admins that set
retrictions on this user and its participating profiles. Restrictions on profiles that have
a separate challenge are not taken into account. If admin is null
, then a composite
of all expiration times is returned - which will be the minimum of all of them.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
the password expiration for the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to aggregate all admins. |
Returns | |
---|---|
long |
The password expiration time, in milliseconds since epoch. |
long getPasswordExpirationTimeout (ComponentName admin)
Get the password expiration timeout for the given admin. The expiration timeout is the
recurring expiration timeout provided in the call to
setPasswordExpirationTimeout(ComponentName, long)
for the given admin or the
aggregate of all participating policy administrators if admin
is null. Admins that
have set restrictions on profiles that have a separate challenge are not taken into account.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to aggregate all admins. |
Returns | |
---|---|
long |
The timeout for the given admin or the minimum of all timeouts |
int getPasswordHistoryLength (ComponentName admin)
Retrieve the current password history length for a particular admin or all admins that set retrictions on this user and its participating profiles. Restrictions on profiles that have a separate challenge are not taken into account.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to aggregate
all admins. |
Returns | |
---|---|
int |
The length of the password history |
int getPasswordMaximumLength (int quality)
Return the maximum password length that the device supports for a particular password quality.
Parameters | |
---|---|
quality |
int :
The quality being interrogated. |
Returns | |
---|---|
int |
Returns the maximum length that the user can enter. |
int getPasswordMinimumLength (ComponentName admin)
Retrieve the current minimum password length for a particular admin or all admins that set retrictions on this user and its participating profiles. Restrictions on profiles that have a separate challenge are not taken into account.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
user and its profiles or a particular one.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to aggregate
all admins.
|
Returns | |
---|---|
int |
int getPasswordMinimumLetters (ComponentName admin)
Retrieve the current number of letters required in the password
for a particular admin or all admins that set retrictions on this user
and its participating profiles. Restrictions on profiles that have
a separate challenge are not taken into account.
This is the same value as set by
setPasswordMinimumLetters(ComponentName, int)
and only applies when the password quality is
PASSWORD_QUALITY_COMPLEX
.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to
aggregate all admins. |
Returns | |
---|---|
int |
The minimum number of letters required in the password. |
int getPasswordMinimumLowerCase (ComponentName admin)
Retrieve the current number of lower case letters required in the password
for a particular admin or all admins that set retrictions on this user
and its participating profiles. Restrictions on profiles that have
a separate challenge are not taken into account.
This is the same value as set by
setPasswordMinimumLowerCase(ComponentName, int)
and only applies when the password quality is
PASSWORD_QUALITY_COMPLEX
.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to
aggregate all admins. |
Returns | |
---|---|
int |
The minimum number of lower case letters required in the password. |
int getPasswordMinimumNonLetter (ComponentName admin)
Retrieve the current number of non-letter characters required in the password
for a particular admin or all admins that set retrictions on this user
and its participating profiles. Restrictions on profiles that have
a separate challenge are not taken into account.
This is the same value as set by
setPasswordMinimumNonLetter(ComponentName, int)
and only applies when the password quality is
PASSWORD_QUALITY_COMPLEX
.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to
aggregate all admins. |
Returns | |
---|---|
int |
The minimum number of letters required in the password. |
int getPasswordMinimumNumeric (ComponentName admin)
Retrieve the current number of numerical digits required in the password
for a particular admin or all admins that set retrictions on this user
and its participating profiles. Restrictions on profiles that have
a separate challenge are not taken into account.
This is the same value as set by
setPasswordMinimumNumeric(ComponentName, int)
and only applies when the password quality is
PASSWORD_QUALITY_COMPLEX
.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to
aggregate all admins. |
Returns | |
---|---|
int |
The minimum number of numerical digits required in the password. |
int getPasswordMinimumSymbols (ComponentName admin)
Retrieve the current number of symbols required in the password
for a particular admin or all admins that set retrictions on this user
and its participating profiles. Restrictions on profiles that have
a separate challenge are not taken into account. This is the same value as
set by setPasswordMinimumSymbols(ComponentName, int)
and only applies when the password quality is
PASSWORD_QUALITY_COMPLEX
.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to
aggregate all admins. |
Returns | |
---|---|
int |
The minimum number of symbols required in the password. |
int getPasswordMinimumUpperCase (ComponentName admin)
Retrieve the current number of upper case letters required in the password
for a particular admin or all admins that set retrictions on this user and
its participating profiles. Restrictions on profiles that have a separate challenge
are not taken into account.
This is the same value as set by
setPasswordMinimumUpperCase(ComponentName, int)
and only applies when the password quality is
PASSWORD_QUALITY_COMPLEX
.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to
aggregate all admins. |
Returns | |
---|---|
int |
The minimum number of upper case letters required in the password. |
int getPasswordQuality (ComponentName admin)
Retrieve the current minimum password quality for a particular admin or all admins that set retrictions on this user and its participating profiles. Restrictions on profiles that have a separate challenge are not taken into account.
This method can be called on the DevicePolicyManager
instance
returned by getParentProfileInstance(ComponentName)
in order to retrieve
restrictions on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to aggregate
all admins.
|
Returns | |
---|---|
int |
int getPermissionGrantState (ComponentName admin, String packageName, String permission)
Returns the current grant state of a runtime permission for a specific application.
Parameters | |
---|---|
admin |
ComponentName :
Which profile or device owner this request is associated with. |
packageName |
String :
The application to check the grant state for. |
permission |
String :
The permission to check for. |
Returns | |
---|---|
int |
the current grant state specified by device policy. If the profile or device owner
has not set a grant state, the return value is
PERMISSION_GRANT_STATE_DEFAULT . This does not indicate whether or not the
permission is currently granted for the package.
If a grant state was set by the profile or device owner, then the return value will
be one of PERMISSION_GRANT_STATE_DENIED or
PERMISSION_GRANT_STATE_GRANTED , which indicates if the permission is
currently denied or granted. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner. |
int getPermissionPolicy (ComponentName admin)
Returns the current runtime permission policy set by the device or profile owner. The
default is PERMISSION_POLICY_PROMPT
.
Parameters | |
---|---|
admin |
ComponentName :
Which profile or device owner this request is associated with. |
Returns | |
---|---|
int |
the current policy for future permission requests. |
List<String> getPermittedAccessibilityServices (ComponentName admin)
Returns the list of permitted accessibility services set by this device or profile owner.
An empty list means no accessibility services except system services are allowed. Null means all accessibility services are allowed.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
List<String> |
List of accessiblity service package names. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
List<String> getPermittedInputMethods (ComponentName admin)
Returns the list of permitted input methods set by this device or profile owner.
An empty list means no input methods except system input methods are allowed. Null means all input methods are allowed.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
List<String> |
List of input method package names. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean getScreenCaptureDisabled (ComponentName admin)
Determine whether or not screen capture has been disabled by the calling admin, if specified, or all admins.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check, or null to check whether any admins
have disabled screen capture.
|
Returns | |
---|---|
boolean |
CharSequence getShortSupportMessage (ComponentName admin)
Called by a device admin to get the short support message.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
CharSequence |
The message set by setShortSupportMessage(ComponentName, CharSequence) or
null if no message has been set. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator.
|
boolean getStorageEncryption (ComponentName admin)
Called by an application that is administering the device to determine the requested setting for secure storage.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. If null,
this will return the requested encryption setting as an aggregate of all active
administrators. |
Returns | |
---|---|
boolean |
true if the admin(s) are requesting encryption, false if not. |
int getStorageEncryptionStatus ()
Called by an application that is administering the device to determine the current encryption status of the device.
Depending on the returned status code, the caller may proceed in different
ways. If the result is ENCRYPTION_STATUS_UNSUPPORTED
, the
storage system does not support encryption. If the
result is ENCRYPTION_STATUS_INACTIVE
, use ACTION_START_ENCRYPTION
to begin the process of encrypting or decrypting the
storage. If the result is ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY
, the
storage system has enabled encryption but no password is set so further action
may be required. If the result is ENCRYPTION_STATUS_ACTIVATING
,
ENCRYPTION_STATUS_ACTIVE
or ENCRYPTION_STATUS_ACTIVE_PER_USER
,
no further action is required.
Returns | |
---|---|
int |
current status of encryption. The value will be one of
ENCRYPTION_STATUS_UNSUPPORTED , ENCRYPTION_STATUS_INACTIVE ,
ENCRYPTION_STATUS_ACTIVATING , ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY ,
ENCRYPTION_STATUS_ACTIVE , or ENCRYPTION_STATUS_ACTIVE_PER_USER .
|
SystemUpdatePolicy getSystemUpdatePolicy ()
Retrieve a local system update policy set previously by setSystemUpdatePolicy(ComponentName, SystemUpdatePolicy)
.
Returns | |
---|---|
SystemUpdatePolicy |
The current policy object, or null if no policy is set.
|
List<PersistableBundle> getTrustAgentConfiguration (ComponentName admin, ComponentName agent)
Gets configuration for the given trust agent based on aggregating all calls to
setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle)
for
all device admins.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to retrieve the configuration set
on the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. If null,
this function returns a list of configurations for all admins that declare
KEYGUARD_DISABLE_TRUST_AGENTS . If any admin declares
KEYGUARD_DISABLE_TRUST_AGENTS but doesn't call
setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle)
for this or calls it with a null configuration, null is returned. |
agent |
ComponentName :
Which component to get enabled features for. |
Returns | |
---|---|
List<PersistableBundle> |
configuration for the given trust agent. |
Bundle getUserRestrictions (ComponentName admin)
Called by a profile or device owner to get user restrictions set with
addUserRestriction(ComponentName, String)
.
The target user may have more restrictions set by the system or other device owner / profile
owner. To get all the user restrictions currently set, use
getUserRestrictions()
.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
Bundle |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
String getWifiMacAddress (ComponentName admin)
Called by device owner to get the MAC address of the Wi-Fi device.
Parameters | |
---|---|
admin |
ComponentName :
Which device owner this request is associated with. |
Returns | |
---|---|
String |
the MAC address of the Wi-Fi device, or null when the information is not available.
(For example, Wi-Fi hasn't been enabled, or the device doesn't support Wi-Fi.)
The address will be in the |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
boolean hasCaCertInstalled (ComponentName admin, byte[] certBuffer)
Returns whether this certificate is installed as a trusted CA.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if calling from a delegated certificate installer. |
certBuffer |
byte :
encoded form of the certificate to look up. |
Returns | |
---|---|
boolean |
Throws | |
---|---|
SecurityException |
if admin is not null and not a device or profile
owner.
|
boolean hasGrantedPolicy (ComponentName admin, int usesPolicy)
Returns true if an administrator has been granted a particular device policy. This can be used to check whether the administrator was activated under an earlier set of policies, but requires additional policies after an upgrade.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. Must be an
active administrator, or an exception will be thrown. |
usesPolicy |
int :
Which uses-policy to check, as defined in DeviceAdminInfo . |
Returns | |
---|---|
boolean |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator.
|
boolean installCaCert (ComponentName admin, byte[] certBuffer)
Installs the given certificate as a user CA.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if calling from a delegated certificate installer. |
certBuffer |
byte :
encoded form of the certificate to install. |
Returns | |
---|---|
boolean |
false if the certBuffer cannot be parsed or installation is interrupted, true otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not null and not a device or profile
owner.
|
boolean installKeyPair (ComponentName admin, PrivateKey privKey, Certificate[] certs, String alias, boolean requestAccess)
Called by a device or profile owner, or delegated certificate installer, to install a certificate chain and corresponding private key for the leaf certificate. All apps within the profile will be able to access the certificate chain and use the private key, given direct user approval.
The caller of this API may grant itself access to the certificate and private key immediately, without user approval. It is a best practice not to request this unless strictly necessary since it opens up additional security vulnerabilities.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if calling from a delegated certificate installer. |
privKey |
PrivateKey :
The private key to install. |
certs |
Certificate :
The certificate chain to install. The chain should start with the leaf
certificate and include the chain of trust in order. This will be returned by
getCertificateChain(Context, String) . |
alias |
String :
The private key alias under which to install the certificate. If a certificate
with that alias already exists, it will be overwritten. |
requestAccess |
boolean :
true to request that the calling app be granted access to the
credentials immediately. Otherwise, access to the credentials will be gated by user
approval. |
Returns | |
---|---|
boolean |
true if the keys were installed, false otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not null and not a device or profile
owner. |
See also:
boolean installKeyPair (ComponentName admin, PrivateKey privKey, Certificate cert, String alias)
Called by a device or profile owner, or delegated certificate installer, to install a certificate and corresponding private key. All apps within the profile will be able to access the certificate and use the private key, given direct user approval.
Access to the installed credentials will not be granted to the caller of this API without direct user approval. This is for security - should a certificate installer become compromised, certificates it had already installed will be protected.
If the installer must have access to the credentials, call
installKeyPair(ComponentName, PrivateKey, Certificate[], String, boolean)
instead.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if calling from a delegated certificate installer. |
privKey |
PrivateKey :
The private key to install. |
cert |
Certificate :
The certificate to install. |
alias |
String :
The private key alias under which to install the certificate. If a certificate
with that alias already exists, it will be overwritten. |
Returns | |
---|---|
boolean |
true if the keys were installed, false otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not null and not a device or profile
owner.
|
boolean isActivePasswordSufficient ()
Determine whether the current password the user has set is sufficient to meet the policy requirements (e.g. quality, minimum length) that have been requested by the admins of this user and its participating profiles. Restrictions on profiles that have a separate challenge are not taken into account.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to determine if the password set on
the parent profile is sufficient.
Returns | |
---|---|
boolean |
Returns true if the password meets the current requirements, else false. |
Throws | |
---|---|
SecurityException |
if the calling application does not own an active administrator
that uses USES_POLICY_LIMIT_PASSWORD
|
boolean isAdminActive (ComponentName admin)
Return true if the given administrator component is currently active (enabled) in the system.
Parameters | |
---|---|
admin |
ComponentName :
The administrator component to check for. |
Returns | |
---|---|
boolean |
true if admin is currently enabled in the system, false
otherwise
|
boolean isApplicationHidden (ComponentName admin, String packageName)
Called by profile or device owners to determine if a package is hidden.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
The name of the package to retrieve the hidden status of. |
Returns | |
---|---|
boolean |
boolean true if the package is hidden, false otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean isCallerApplicationRestrictionsManagingPackage ()
Called by any application to find out whether it has been granted permission via
setApplicationRestrictionsManagingPackage(ComponentName, String)
to manage application restrictions
for the calling user.
This is done by comparing the calling Linux uid with the uid of the package specified by that method.
Returns | |
---|---|
boolean |
boolean isDeviceOwnerApp (String packageName)
Used to determine if a particular package has been registered as a Device Owner app.
A device owner app is a special device admin that cannot be deactivated by the user, once
activated as a device admin. It also cannot be uninstalled. To check whether a particular
package is currently registered as the device owner app, pass in the package name from
getPackageName()
to this method.
Parameters | |
---|---|
packageName |
String :
the package name of the app, to compare with the registered device owner
app, if any. |
Returns | |
---|---|
boolean |
whether or not the package is registered as the device owner app. |
boolean isLockTaskPermitted (String pkg)
This function lets the caller know whether the given component is allowed to start the lock task mode.
Parameters | |
---|---|
pkg |
String :
The package to check
|
Returns | |
---|---|
boolean |
boolean isManagedProfile (ComponentName admin)
Return if this user is a managed profile of another user. An admin can become the profile
owner of a managed profile with ACTION_PROVISION_MANAGED_PROFILE
and of a managed
user with createAndManageUser(ComponentName, String, ComponentName, PersistableBundle, int)
Parameters | |
---|---|
admin |
ComponentName :
Which profile owner this request is associated with. |
Returns | |
---|---|
boolean |
if this user is a managed profile of another user. |
boolean isMasterVolumeMuted (ComponentName admin)
Called by profile or device owners to check whether the master volume mute is on or off.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
boolean |
true if master volume is muted, false if it's not. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean isPackageSuspended (ComponentName admin, String packageName)
Called by device or profile owners to determine if a package is suspended.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
The name of the package to retrieve the suspended status of. |
Returns | |
---|---|
boolean |
true if the package is suspended or false if the package is not
suspended, could not be found or an error occurred. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner. |
PackageManager.NameNotFoundException |
if the package could not be found. |
boolean isProfileOwnerApp (String packageName)
Used to determine if a particular package is registered as the profile owner for the user. A profile owner is a special device admin that has additional privileges within the profile.
Parameters | |
---|---|
packageName |
String :
The package name of the app to compare with the registered profile owner. |
Returns | |
---|---|
boolean |
Whether or not the package is registered as the profile owner. |
boolean isProvisioningAllowed (String action)
Returns if provisioning a managed profile or device is possible or not.
Parameters | |
---|---|
action |
String :
One of ACTION_PROVISION_MANAGED_DEVICE ,
ACTION_PROVISION_MANAGED_PROFILE . |
Returns | |
---|---|
boolean |
if provisioning a managed profile or device is possible or not. |
Throws | |
---|---|
IllegalArgumentException |
if the supplied action is not valid. |
boolean isSecurityLoggingEnabled (ComponentName admin)
Return whether security logging is enabled or not by the device owner.
Can only be called by the device owner, otherwise a SecurityException
will be
thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which device owner this request is associated with. |
Returns | |
---|---|
boolean |
true if security logging is enabled by device owner, false otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
boolean isUninstallBlocked (ComponentName admin, String packageName)
Check whether the user has been blocked by device policy from uninstalling a package. Requires the caller to be the profile owner if checking a specific admin's policy.
Note: Starting from LOLLIPOP_MR1
, the
behavior of this API is changed such that passing null
as the admin
parameter
will return if any admin has blocked the uninstallation. Before L MR1, passing null
will cause a NullPointerException to be raised.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component whose blocking policy will be checked, or
null to check whether any admin has blocked the uninstallation. |
packageName |
String :
package to check. |
Returns | |
---|---|
boolean |
true if uninstallation is blocked. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void lockNow ()
Make the device lock immediately, as if the lock screen timeout has expired at the point of this call.
The calling device admin must have requested USES_POLICY_FORCE_LOCK
to be able to call this method; if it has not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to lock the parent profile.
Throws | |
---|---|
SecurityException |
if the calling application does not own an active administrator
that uses USES_POLICY_FORCE_LOCK
|
void reboot (ComponentName admin)
Called by device owner to reboot the device. If there is an ongoing call on the device,
throws an IllegalStateException
.
Parameters | |
---|---|
admin |
ComponentName :
Which device owner the request is associated with. |
Throws | |
---|---|
IllegalStateException |
if device has an ongoing call. |
SecurityException |
if admin is not a device owner. |
See also:
void removeActiveAdmin (ComponentName admin)
Remove a current administration component. This can only be called by the application that owns the administration component; if you try to remove someone else's component, a security exception will be thrown.
Note that the operation is not synchronous and the admin might still be active (as
indicated by getActiveAdmins()
) by the time this method returns.
Parameters | |
---|---|
admin |
ComponentName :
The administration compononent to remove. |
Throws | |
---|---|
SecurityException |
if the caller is not in the owner application of admin .
|
boolean removeCrossProfileWidgetProvider (ComponentName admin, String packageName)
Called by the profile owner of a managed profile to disable widget providers from a given
package to be available in the parent profile. For this method to take effect the package
should have been added via
addCrossProfileWidgetProvider(android.content.ComponentName, String)
.
Note: By default no widget provider package is white-listed.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
The package from which widget providers are no longer white-listed. |
Returns | |
---|---|
boolean |
Whether the package was removed. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner. |
boolean removeKeyPair (ComponentName admin, String alias)
Called by a device or profile owner, or delegated certificate installer, to remove a certificate and private key pair installed under a given alias.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if calling from a delegated certificate installer. |
alias |
String :
The private key alias under which the certificate is installed. |
Returns | |
---|---|
boolean |
true if the private key alias no longer exists, false otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not null and not a device or profile
owner.
|
boolean removeUser (ComponentName admin, UserHandle userHandle)
Called by a device owner to remove a user and all associated data. The primary user can not be removed.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
userHandle |
UserHandle :
the user to remove. |
Returns | |
---|---|
boolean |
true if the user was removed, false otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
boolean requestBugreport (ComponentName admin)
Called by a device owner to request a bugreport.
There must be only one user on the device, managed by the device owner. Otherwise a
SecurityException
will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Returns | |
---|---|
boolean |
true if the bugreport collection started successfully, or false if it
wasn't triggered because a previous bugreport operation is still active (either the
bugreport is still running or waiting for the user to share or decline) |
Throws | |
---|---|
SecurityException |
if admin is not a device owner, or if there are users other
than the one managed by the device owner.
|
boolean resetPassword (String password, int flags)
Force a new device unlock password (the password needed to access the entire device, not for individual accounts) on the user. This takes effect immediately.
Note: This API has been limited as of N
for
device admins that are not device owner and not profile owner.
The password can now only be changed if there is currently no password set. Device owner
and profile owner can still do this when user is unlocked and does not have a managed
profile.
The given password must be sufficient for the current password quality and length constraints
as returned by getPasswordQuality(ComponentName)
and
getPasswordMinimumLength(ComponentName)
; if it does not meet these constraints, then
it will be rejected and false returned. Note that the password may be a stronger quality
(containing alphanumeric characters when the requested quality is only numeric), in which
case the currently active quality will be increased to match.
Calling with a null or empty password will clear any existing PIN, pattern or password if the
current password constraints allow it. Note: This will not work in
N
and later for managed profiles, or for device admins
that are not device owner or profile owner. Once set, the password cannot be changed to null
or empty except by these admins.
The calling device admin must have requested
USES_POLICY_RESET_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
Parameters | |
---|---|
password |
String :
The new password for the user. Null or empty clears the password. |
flags |
int :
May be 0 or combination of RESET_PASSWORD_REQUIRE_ENTRY and
RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT . |
Returns | |
---|---|
boolean |
Returns true if the password was applied, or false if it is not acceptable for the current constraints or if the user has not been decrypted yet. |
Throws | |
---|---|
SecurityException |
if the calling application does not own an active administrator
that uses USES_POLICY_RESET_PASSWORD |
IllegalStateException |
if the calling user is locked or has a managed profile. |
List<SecurityLog.SecurityEvent> retrievePreRebootSecurityLogs (ComponentName admin)
Called by device owners to retrieve device logs from before the device's last reboot.
This API is not supported on all devices. Calling this API on unsupported devices
will result in null
being returned. The device logs are retrieved from a RAM region
which is not guaranteed to be corruption-free during power cycles, as a result be cautious
about data corruption when parsing.
There must be only one user on the device, managed by the device owner. Otherwise a
SecurityException
will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which device owner this request is associated with. |
Returns | |
---|---|
List<SecurityLog.SecurityEvent> |
Device logs from before the latest reboot of the system, or null if this API
is not supported on the device. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
List<SecurityLog.SecurityEvent> retrieveSecurityLogs (ComponentName admin)
Called by device owner to retrieve all new security logging entries since the last call to this API after device boots.
Access to the logs is rate limited and it will only return new logs after the device
owner has been notified via onSecurityLogsAvailable(Context, Intent)
.
There must be only one user on the device, managed by the device owner.
Otherwise a SecurityException
will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which device owner this request is associated with. |
Returns | |
---|---|
List<SecurityLog.SecurityEvent> |
the new batch of security logs which is a list of SecurityLog.SecurityEvent ,
or null if rate limitation is exceeded or if logging is currently disabled. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
void setAccountManagementDisabled (ComponentName admin, String accountType, boolean disabled)
Called by a device owner or profile owner to disable account management for a specific type of account.
The calling device admin must be a device owner or profile owner. If it is not, a security exception will be thrown.
When account management is disabled for an account type, adding or removing an account of that type will not be possible.
From N
the profile or device owner can still use
AccountManager
APIs to add or remove accounts when account
management for a specific type is disabled.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
accountType |
String :
For which account management is disabled or enabled. |
disabled |
boolean :
The boolean indicating that account management will be disabled (true) or
enabled (false). |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setAlwaysOnVpnPackage (ComponentName admin, String vpnPackage, boolean lockdownEnabled)
Called by a device or profile owner to configure an always-on VPN connection through a specific application for the current user. This connection is automatically granted and persisted after a reboot.
The designated package should declare a VpnService
in its manifest
guarded by BIND_VPN_SERVICE
, otherwise the call will
fail.
Parameters | |
---|---|
admin |
ComponentName
|
vpnPackage |
String :
The package name for an installed VPN app on the device, or null to
remove an existing always-on VPN configuration. |
lockdownEnabled |
boolean :
true to disallow networking when the VPN is not connected or
false otherwise. This carries the risk that any failure of the VPN provider
could break networking for all apps. This has no effect when clearing. |
Throws | |
---|---|
SecurityException |
if admin is not a device or a profile owner. |
PackageManager.NameNotFoundException |
if vpnPackage is not installed. |
UnsupportedOperationException |
if vpnPackage exists but does not support being
set as always-on, or if always-on VPN is not available.
|
boolean setApplicationHidden (ComponentName admin, String packageName, boolean hidden)
Called by profile or device owners to hide or unhide packages. When a package is hidden it is unavailable for use, but the data and actual package file remain.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
The name of the package to hide or unhide. |
hidden |
boolean :
true if the package should be hidden, false if it should be
unhidden. |
Returns | |
---|---|
boolean |
boolean Whether the hidden setting of the package was successfully updated. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setApplicationRestrictions (ComponentName admin, String packageName, Bundle settings)
Sets the application restrictions for a given target application running in the calling user.
The caller must be a profile or device owner on that user, or the package allowed to manage
application restrictions via setApplicationRestrictionsManagingPackage(ComponentName, String)
; otherwise a
security exception will be thrown.
The provided Bundle
consists of key-value pairs, where the types of values may be:
boolean
int
String
or String[]
M
, Bundle
or Bundle[]
If the restrictions are not available yet, but may be applied in the near future, the caller
can notify the target application of that by adding
KEY_RESTRICTIONS_PENDING
to the settings parameter.
The application restrictions are only made visible to the target application via
getApplicationRestrictions(String)
, in addition to the profile or device
owner, and the application restrictions managing package via
getApplicationRestrictions(ComponentName, String)
.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if called by the application restrictions managing package. |
packageName |
String :
The name of the package to update restricted settings for. |
settings |
Bundle :
A Bundle to be parsed by the receiving application, conveying a new
set of active restrictions. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner. |
void setApplicationRestrictionsManagingPackage (ComponentName admin, String packageName)
Called by a profile owner or device owner to grant permission to a package to manage
application restrictions for the calling user via setApplicationRestrictions(ComponentName, String, Bundle)
and
getApplicationRestrictions(ComponentName, String)
.
This permission is persistent until it is later cleared by calling this method with a
null
value or uninstalling the managing package.
The supplied application restriction managing package must be installed when calling this
API, otherwise an PackageManager.NameNotFoundException
will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
The package name which will be given access to application restrictions
APIs. If null is given the current package will be cleared. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner. |
PackageManager.NameNotFoundException |
if packageName is not found
|
void setAutoTimeRequired (ComponentName admin, boolean required)
Called by a device owner to set whether auto time is required. If auto time is required the user cannot set the date and time, but has to use network date and time.
Note: if auto time is required the user can still manually set the time zone.
The calling device admin must be a device owner. If it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
required |
boolean :
Whether auto time is set required or not. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
void setBluetoothContactSharingDisabled (ComponentName admin, boolean disabled)
Called by a profile owner of a managed profile to set whether bluetooth devices can access enterprise contacts.
The calling device admin must be a profile owner. If it is not, a security exception will be thrown.
This API works on managed profile only.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
disabled |
boolean :
If true, bluetooth devices cannot access enterprise contacts. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setCameraDisabled (ComponentName admin, boolean disabled)
Called by an application that is administering the device to disable all cameras on the device, for this user. After setting this, no applications running as this user will be able to access any cameras on the device.
If the caller is device owner, then the restriction will be applied to all users.
The calling device admin must have requested
USES_POLICY_DISABLE_CAMERA
to be able to call this method; if it has
not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
disabled |
boolean :
Whether or not the camera should be disabled. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or does not use
USES_POLICY_DISABLE_CAMERA .
|
void setCertInstallerPackage (ComponentName admin, String installerPackage)
Called by a profile owner or device owner to grant access to privileged certificate
manipulation APIs to a third-party certificate installer app. Granted APIs include
getInstalledCaCerts(ComponentName)
, hasCaCertInstalled(ComponentName, byte[])
, installCaCert(ComponentName, byte[])
,
uninstallCaCert(ComponentName, byte[])
, uninstallAllUserCaCerts(ComponentName)
and installKeyPair(ComponentName, PrivateKey, Certificate, String)
.
Delegated certificate installer is a per-user state. The delegated access is persistent until it is later cleared by calling this method with a null value or uninstallling the certificate installer.
Note:Starting from N
, if the caller
application's target SDK version is N
or newer, the
supplied certificate installer package must be installed when calling this API, otherwise an
IllegalArgumentException
will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
installerPackage |
String :
The package name of the certificate installer which will be given
access. If null is given the current package will be cleared. |
Throws | |
---|---|
SecurityException |
if admin is not a device or a profile owner.
|
void setCrossProfileCallerIdDisabled (ComponentName admin, boolean disabled)
Called by a profile owner of a managed profile to set whether caller-Id information from the managed profile will be shown in the parent profile, for incoming calls.
The calling device admin must be a profile owner. If it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
disabled |
boolean :
If true caller-Id information in the managed profile is not displayed. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setCrossProfileContactsSearchDisabled (ComponentName admin, boolean disabled)
Called by a profile owner of a managed profile to set whether contacts search from the managed profile will be shown in the parent profile, for incoming calls.
The calling device admin must be a profile owner. If it is not, a security exception will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
disabled |
boolean :
If true contacts search in the managed profile is not displayed. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setDeviceOwnerLockScreenInfo (ComponentName admin, CharSequence info)
Sets the device owner information to be shown on the lock screen.
If the device owner information is null
or empty then the device owner info is
cleared and the user owner info is shown on the lock screen if it is set.
If the device owner information contains only whitespaces then the message on the lock screen will be blank and the user will not be allowed to change it.
If the device owner information needs to be localized, it is the responsibility of the
DeviceAdminReceiver
to listen to the ACTION_LOCALE_CHANGED
broadcast
and set a new version of this string accordingly.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check. |
info |
CharSequence :
Device owner information which will be displayed instead of the user owner info. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
void setGlobalSetting (ComponentName admin, String setting, String value)
Called by device owners to update Settings.Global
settings. Validation that the value
of the setting is in the correct form for the setting type should be performed by the caller.
The settings that can be updated with this method are:
ADB_ENABLED
AUTO_TIME
AUTO_TIME_ZONE
DATA_ROAMING
USB_MASS_STORAGE_ENABLED
WIFI_SLEEP_POLICY
STAY_ON_WHILE_PLUGGED_IN
This setting is only available from
M
onwards and can only be set if
setMaximumTimeToLock(ComponentName, long)
is not used to set a timeout.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN
M
onwards.
Changing the following settings has no effect as of M
:
BLUETOOTH_ON
. Use
enable()
and
disable()
instead.DEVELOPMENT_SETTINGS_ENABLED
MODE_RINGER
. Use
setRingerMode(int)
instead.NETWORK_PREFERENCE
WIFI_ON
. Use
setWifiEnabled(boolean)
instead.Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
setting |
String :
The name of the setting to update. |
value |
String :
The value to update the setting to. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
boolean setKeyguardDisabled (ComponentName admin, boolean disabled)
Called by a device owner to disable the keyguard altogether.
Setting the keyguard to disabled has the same effect as choosing "None" as the screen lock type. However, this call has no effect if a password, pin or pattern is currently set. If a password, pin or pattern is set after the keyguard was disabled, the keyguard stops being disabled.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
disabled |
boolean :
true disables the keyguard, false reenables it. |
Returns | |
---|---|
boolean |
false if attempting to disable the keyguard while a lock password was in
place. true otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
void setKeyguardDisabledFeatures (ComponentName admin, int which)
Called by an application that is administering the device to disable keyguard customizations, such as widgets. After setting this, keyguard features will be disabled according to the provided feature list.
The calling device admin must have requested
USES_POLICY_DISABLE_KEYGUARD_FEATURES
to be able to call this method;
if it has not, a security exception will be thrown.
Calling this from a managed profile before version M
will throw a security exception. From version M
the
profile owner of a managed profile can set:
KEYGUARD_DISABLE_TRUST_AGENTS
, which affects the parent user, but only if there
is no separate challenge set on the managed profile.
KEYGUARD_DISABLE_FINGERPRINT
which affects the managed profile challenge if
there is one, or the parent user otherwise.
KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS
which affects notifications generated
by applications in the managed profile.
KEYGUARD_DISABLE_TRUST_AGENTS
and KEYGUARD_DISABLE_FINGERPRINT
can also be
set on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Requests to disable other features on a managed profile will be ignored.
The admin can check which features have been disabled by calling
getKeyguardDisabledFeatures(ComponentName)
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
which |
int :
KEYGUARD_DISABLE_FEATURES_NONE (default),
KEYGUARD_DISABLE_WIDGETS_ALL , KEYGUARD_DISABLE_SECURE_CAMERA ,
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS ,
KEYGUARD_DISABLE_TRUST_AGENTS ,
KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS ,
KEYGUARD_DISABLE_FINGERPRINT , KEYGUARD_DISABLE_FEATURES_ALL |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or does not user
USES_POLICY_DISABLE_KEYGUARD_FEATURES
|
void setLockTaskPackages (ComponentName admin, String[] packages)
Sets which packages may enter lock task mode.
Any packages that shares uid with an allowed package will also be allowed to activate lock
task. From M
removing packages from the lock task
package list results in locked tasks belonging to those packages to be finished. This
function can only be called by the device owner.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packages |
String :
The list of packages allowed to enter lock task mode |
Throws | |
---|---|
SecurityException |
if admin is not a device owner. |
void setLongSupportMessage (ComponentName admin, CharSequence message)
Called by a device admin to set the long support message. This will be displayed to the user in the device administators settings screen.
If the long support message needs to be localized, it is the responsibility of the
DeviceAdminReceiver
to listen to the ACTION_LOCALE_CHANGED
broadcast
and set a new version of this string accordingly.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
message |
CharSequence :
Long message to be displayed to the user in settings or null to clear the
existing message. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator.
|
void setMasterVolumeMuted (ComponentName admin, boolean on)
Called by profile or device owners to set the master volume mute on or off.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
on |
boolean :
true to mute master volume, false to turn mute off. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setMaximumFailedPasswordsForWipe (ComponentName admin, int num)
Setting this to a value greater than zero enables a built-in policy that will perform a
device or profile wipe after too many incorrect device-unlock passwords have been entered.
This built-in policy combines watching for failed passwords and wiping the device, and
requires that you request both USES_POLICY_WATCH_LOGIN
and
USES_POLICY_WIPE_DATA
}.
To implement any other policy (e.g. wiping data for a particular application only, erasing or
revoking credentials, or reporting the failure to a server), you should implement
onPasswordFailed(Context, android.content.Intent)
instead. Do not
use this API, because if the maximum count is reached, the device or profile will be wiped
immediately, and your callback will not be invoked.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set a value on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
num |
int :
The number of failed password attempts at which point the device or profile will
be wiped. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or does not use
both USES_POLICY_WATCH_LOGIN and
USES_POLICY_WIPE_DATA .
|
void setMaximumTimeToLock (ComponentName admin, long timeMs)
Called by an application that is administering the device to set the maximum time for user activity until the device will lock. This limits the length that the user can set. It takes effect immediately.
The calling device admin must have requested USES_POLICY_FORCE_LOCK
to be able to call this method; if it has not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
timeMs |
long :
The new desired maximum time to lock in milliseconds. A value of 0 means there
is no restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or it does not use
USES_POLICY_FORCE_LOCK
|
void setOrganizationColor (ComponentName admin, int color)
Called by a profile owner of a managed profile to set the color used for customization. This color is used as background color of the confirm credentials screen for that user. The default color is teal (#00796B).
The confirm credentials screen can be created using
createConfirmDeviceCredentialIntent(CharSequence, CharSequence)
.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
color |
int :
The 24bit (0xRRGGBB) representation of the color to be used. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner.
|
void setOrganizationName (ComponentName admin, CharSequence title)
Called by a profile owner of a managed profile to set the name of the organization under management.
If the organization name needs to be localized, it is the responsibility of the
DeviceAdminReceiver
to listen to the ACTION_LOCALE_CHANGED
broadcast
and set a new version of this string accordingly.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
title |
CharSequence :
The organization name or null to clear a previously set name. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner.
|
String[] setPackagesSuspended (ComponentName admin, String[] packageNames, boolean suspended)
Called by device or profile owners to suspend packages for this user.
A suspended package will not be able to start activities. Its notifications will be hidden, it will not show up in recents, will not be able to show toasts or dialogs or ring the device.
The package must already be installed. If the package is uninstalled while suspended the
package will no longer be suspended. The admin can block this by using
setUninstallBlocked(ComponentName, String, boolean)
.
Parameters | |
---|---|
admin |
ComponentName :
The name of the admin component to check. |
packageNames |
String :
The package names to suspend or unsuspend. |
suspended |
boolean :
If set to true than the packages will be suspended, if set to
false the packages will be unsuspended. |
Returns | |
---|---|
String[] |
an array of package names for which the suspended status is not set as requested in this method. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setPasswordExpirationTimeout (ComponentName admin, long timeout)
Called by a device admin to set the password expiration timeout. Calling this method will restart the countdown for password expiration for the given admin, as will changing the device password (for all admins).
The provided timeout is the time delta in ms and will be added to the current time. For example, to have the password expire 5 days from now, timeout would be 5 * 86400 * 1000 = 432000000 ms for timeout.
To disable password expiration, a value of 0 may be used for timeout.
The calling device admin must have requested
USES_POLICY_EXPIRE_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
Note that setting the password will automatically reset the expiration time for all active admins. Active admins do not need to explicitly call this method in that case.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
timeout |
long :
The limit (in ms) that a password can remain in effect. A value of 0 means
there is no restriction (unlimited). |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_EXPIRE_PASSWORD
|
void setPasswordHistoryLength (ComponentName admin, int length)
Called by an application that is administering the device to set the length of the password
history. After setting this, the user will not be able to enter a new password that is the
same as any password in the history. Note that the current password will remain until the
user has set a new one, so the change does not take place immediately. To prompt the user for
a new password, use ACTION_SET_NEW_PASSWORD
or
ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after setting this value. This constraint is
only imposed if the administrator has also requested either PASSWORD_QUALITY_NUMERIC
, PASSWORD_QUALITY_NUMERIC_COMPLEX
PASSWORD_QUALITY_ALPHABETIC
, or
PASSWORD_QUALITY_ALPHANUMERIC
with setPasswordQuality(ComponentName, int)
.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
length |
int :
The new desired length of password history. A value of 0 means there is no
restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_LIMIT_PASSWORD
|
void setPasswordMinimumLength (ComponentName admin, int length)
Called by an application that is administering the device to set the minimum allowed password
length. After setting this, the user will not be able to enter a new password that is not at
least as restrictive as what has been set. Note that the current password will remain until
the user has set a new one, so the change does not take place immediately. To prompt the user
for a new password, use ACTION_SET_NEW_PASSWORD
or
ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after setting this value. This constraint is
only imposed if the administrator has also requested either PASSWORD_QUALITY_NUMERIC
, PASSWORD_QUALITY_NUMERIC_COMPLEX
, PASSWORD_QUALITY_ALPHABETIC
,
PASSWORD_QUALITY_ALPHANUMERIC
, or PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
length |
int :
The new desired minimum password length. A value of 0 means there is no
restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_LIMIT_PASSWORD
|
void setPasswordMinimumLetters (ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of
letters required in the password. After setting this, the user will not be able to enter a
new password that is not at least as restrictive as what has been set. Note that the current
password will remain until the user has set a new one, so the change does not take place
immediately. To prompt the user for a new password, use ACTION_SET_NEW_PASSWORD
or
ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after setting this value. This constraint is
only imposed if the administrator has also requested PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
. The default value is 1.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
length |
int :
The new desired minimum number of letters required in the password. A value of
0 means there is no restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_LIMIT_PASSWORD
|
void setPasswordMinimumLowerCase (ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of lower
case letters required in the password. After setting this, the user will not be able to enter
a new password that is not at least as restrictive as what has been set. Note that the
current password will remain until the user has set a new one, so the change does not take
place immediately. To prompt the user for a new password, use
ACTION_SET_NEW_PASSWORD
or ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after
setting this value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with setPasswordQuality(ComponentName, int)
. The default value is 0.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
length |
int :
The new desired minimum number of lower case letters required in the password.
A value of 0 means there is no restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_LIMIT_PASSWORD
|
void setPasswordMinimumNonLetter (ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of
non-letter characters (numerical digits or symbols) required in the password. After setting
this, the user will not be able to enter a new password that is not at least as restrictive
as what has been set. Note that the current password will remain until the user has set a new
one, so the change does not take place immediately. To prompt the user for a new password,
use ACTION_SET_NEW_PASSWORD
or ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after
setting this value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with setPasswordQuality(ComponentName, int)
. The default value is 0.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
length |
int :
The new desired minimum number of letters required in the password. A value of
0 means there is no restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_LIMIT_PASSWORD
|
void setPasswordMinimumNumeric (ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of
numerical digits required in the password. After setting this, the user will not be able to
enter a new password that is not at least as restrictive as what has been set. Note that the
current password will remain until the user has set a new one, so the change does not take
place immediately. To prompt the user for a new password, use
ACTION_SET_NEW_PASSWORD
or ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after
setting this value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with setPasswordQuality(ComponentName, int)
. The default value is 1.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
length |
int :
The new desired minimum number of numerical digits required in the password. A
value of 0 means there is no restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_LIMIT_PASSWORD
|
void setPasswordMinimumSymbols (ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of
symbols required in the password. After setting this, the user will not be able to enter a
new password that is not at least as restrictive as what has been set. Note that the current
password will remain until the user has set a new one, so the change does not take place
immediately. To prompt the user for a new password, use ACTION_SET_NEW_PASSWORD
or
ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after setting this value. This constraint is
only imposed if the administrator has also requested PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
. The default value is 1.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
length |
int :
The new desired minimum number of symbols required in the password. A value of
0 means there is no restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_LIMIT_PASSWORD
|
void setPasswordMinimumUpperCase (ComponentName admin, int length)
Called by an application that is administering the device to set the minimum number of upper
case letters required in the password. After setting this, the user will not be able to enter
a new password that is not at least as restrictive as what has been set. Note that the
current password will remain until the user has set a new one, so the change does not take
place immediately. To prompt the user for a new password, use
ACTION_SET_NEW_PASSWORD
or ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after
setting this value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with setPasswordQuality(ComponentName, int)
. The default value is 0.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
length |
int :
The new desired minimum number of upper case letters required in the password.
A value of 0 means there is no restriction. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or admin
does not use USES_POLICY_LIMIT_PASSWORD
|
void setPasswordQuality (ComponentName admin, int quality)
Called by an application that is administering the device to set the password restrictions it
is imposing. After setting this, the user will not be able to enter a new password that is
not at least as restrictive as what has been set. Note that the current password will remain
until the user has set a new one, so the change does not take place immediately. To prompt
the user for a new password, use ACTION_SET_NEW_PASSWORD
or
ACTION_SET_NEW_PARENT_PROFILE_PASSWORD
after calling this method.
Quality constants are ordered so that higher values are more restrictive; thus the highest requested quality constant (between the policy set here, the user's preference, and any other considerations) is the one that is in effect.
The calling device admin must have requested
USES_POLICY_LIMIT_PASSWORD
to be able to call this method; if it has
not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set restrictions on the parent
profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
quality |
int :
The new desired quality. One of PASSWORD_QUALITY_UNSPECIFIED ,
PASSWORD_QUALITY_SOMETHING , PASSWORD_QUALITY_NUMERIC ,
PASSWORD_QUALITY_NUMERIC_COMPLEX , PASSWORD_QUALITY_ALPHABETIC ,
PASSWORD_QUALITY_ALPHANUMERIC or PASSWORD_QUALITY_COMPLEX . |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or if admin
does not use USES_POLICY_LIMIT_PASSWORD
|
boolean setPermissionGrantState (ComponentName admin, String packageName, String permission, int grantState)
Sets the grant state of a runtime permission for a specific application. The state can be
default
in which a user can manage it through the UI,
denied
, in which the permission is denied and the user
cannot manage it through the UI, and granted
in which
the permission is granted and the user cannot manage it through the UI. This might affect all
permissions in a group that the runtime permission belongs to. This method can only be called
by a profile or device owner.
default
does not revoke
the permission. It retains the previous grant, if any.
Permissions can be granted or revoked only for applications built with a
targetSdkVersion
of M
or later.
Parameters | |
---|---|
admin |
ComponentName :
Which profile or device owner this request is associated with. |
packageName |
String :
The application to grant or revoke a permission to. |
permission |
String :
The permission to grant or revoke. |
grantState |
int :
The permission grant state which is one of
PERMISSION_GRANT_STATE_DENIED , PERMISSION_GRANT_STATE_DEFAULT ,
PERMISSION_GRANT_STATE_GRANTED , |
Returns | |
---|---|
boolean |
whether the permission was successfully granted or revoked. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner. |
void setPermissionPolicy (ComponentName admin, int policy)
Called by profile or device owners to set the default response for future runtime permission
requests by applications. The policy can allow for normal operation which prompts the user to
grant a permission, or can allow automatic granting or denying of runtime permission requests
by an application. This also applies to new permissions declared by app updates. When a
permission is denied or granted this way, the effect is equivalent to setting the permission
grant state via setPermissionGrantState(ComponentName, String, String, int)
.
targetSdkVersion
of M
or later.
Parameters | |
---|---|
admin |
ComponentName :
Which profile or device owner this request is associated with. |
policy |
int :
One of the policy constants PERMISSION_POLICY_PROMPT ,
PERMISSION_POLICY_AUTO_GRANT and PERMISSION_POLICY_AUTO_DENY . |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner. |
boolean setPermittedAccessibilityServices (ComponentName admin, List<String> packageNames)
Called by a profile or device owner to set the permitted accessibility services. When set by a device owner or profile owner the restriction applies to all profiles of the user the device owner or profile owner is an admin for. By default the user can use any accessiblity service. When zero or more packages have been added, accessiblity services that are not in the list and not part of the system can not be enabled by the user.
Calling with a null value for the list disables the restriction so that all services can be used, calling with an empty list only allows the builtin system's services.
System accesibility services are always available to the user the list can't modify this.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageNames |
List :
List of accessibility service package names. |
Returns | |
---|---|
boolean |
true if setting the restriction succeeded. It fail if there is one or more non-system accessibility services enabled, that are not in the list. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean setPermittedInputMethods (ComponentName admin, List<String> packageNames)
Called by a profile or device owner to set the permitted input methods services. When set by a device owner or profile owner the restriction applies to all profiles of the user the device owner or profile owner is an admin for. By default the user can use any input method. When zero or more packages have been added, input method that are not in the list and not part of the system can not be enabled by the user. This method will fail if it is called for a admin that is not for the foreground user or a profile of the foreground user.
Calling with a null value for the list disables the restriction so that all input methods can be used, calling with an empty list disables all but the system's own input methods.
System input methods are always available to the user this method can't modify this.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageNames |
List :
List of input method package names. |
Returns | |
---|---|
boolean |
true if setting the restriction succeeded. It will fail if there are one or more non-system input methods currently enabled that are not in the packageNames list. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setProfileEnabled (ComponentName admin)
Sets the enabled state of the profile. A profile should be enabled only once it is ready to be used. Only the profile owner can call this.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
Throws | |
---|---|
SecurityException |
if admin is not a profile owner.
|
See also:
void setProfileName (ComponentName admin, String profileName)
Sets the name of the profile. In the device owner case it sets the name of the user which it is called from. Only a profile owner or device owner can call this. If this is never called by the profile or device owner, the name will be set to default values.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associate with. |
profileName |
String :
The name of the profile. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setRecommendedGlobalProxy (ComponentName admin, ProxyInfo proxyInfo)
Set a network-independent global HTTP proxy. This is not normally what you want for typical HTTP proxies - they are generally network dependent. However if you're doing something unusual like general internal filtering this may be useful. On a private network where the proxy is not accessible, you may break HTTP using this.
This method requires the caller to be the device owner.
This proxy is only a recommendation and it is possible that some apps will ignore it.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
proxyInfo |
ProxyInfo :
The a ProxyInfo object defining the new global HTTP proxy. A
null value will clear the global HTTP proxy. |
Throws | |
---|---|
SecurityException |
if admin is not the device owner.
|
See also:
void setRestrictionsProvider (ComponentName admin, ComponentName provider)
Designates a specific service component as the provider for making permission requests of a local or remote administrator of the user.
Only a profile owner can designate the restrictions provider.Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
provider |
ComponentName :
The component name of the service that implements
RestrictionsReceiver . If this param is null, it removes the restrictions
provider previously assigned. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setScreenCaptureDisabled (ComponentName admin, boolean disabled)
Called by a device/profile owner to set whether the screen capture is disabled. Disabling
screen capture also prevents the content from being shown on display devices that do not have
a secure video output. See FLAG_SECURE
for more details about
secure surfaces and secure displays.
The calling device admin must be a device or profile owner. If it is not, a security exception will be thrown.
From version M
disabling screen capture also blocks
assist requests for all activities of the relevant user.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
disabled |
boolean :
Whether screen capture is disabled or not. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setSecureSetting (ComponentName admin, String setting, String value)
Called by profile or device owners to update Settings.Secure
settings. Validation
that the value of the setting is in the correct form for the setting type should be performed
by the caller.
The settings that can be updated by a profile or device owner with this method are:
A device owner can additionally update the following settings:
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
setting |
String :
The name of the setting to update. |
value |
String :
The value to update the setting to. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setSecurityLoggingEnabled (ComponentName admin, boolean enabled)
Called by device owner to control the security logging feature. Logging can only be enabled on single user devices where the sole user is managed by the device owner.
Security logs contain various information intended for security auditing purposes.
See SecurityLog.SecurityEvent
for details.
There must be only one user on the device, managed by the device owner.
Otherwise a SecurityException
will be thrown.
Parameters | |
---|---|
admin |
ComponentName :
Which device owner this request is associated with. |
enabled |
boolean :
whether security logging should be enabled or not. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner. |
See also:
void setShortSupportMessage (ComponentName admin, CharSequence message)
Called by a device admin to set the short support message. This will be displayed to the user in settings screens where funtionality has been disabled by the admin. The message should be limited to a short statement such as "This setting is disabled by your administrator. Contact [email protected] for support." If the message is longer than 200 characters it may be truncated.
If the short support message needs to be localized, it is the responsibility of the
DeviceAdminReceiver
to listen to the ACTION_LOCALE_CHANGED
broadcast
and set a new version of this string accordingly.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
message |
CharSequence :
Short message to be displayed to the user in settings or null to clear the
existing message. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator.
|
boolean setStatusBarDisabled (ComponentName admin, boolean disabled)
Called by device owner to disable the status bar. Disabling the status bar blocks notifications, quick settings and other screen overlays that allow escaping from a single use device.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
disabled |
boolean :
true disables the status bar, false reenables it. |
Returns | |
---|---|
boolean |
false if attempting to disable the status bar failed. true otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner.
|
int setStorageEncryption (ComponentName admin, boolean encrypt)
Called by an application that is administering the device to request that the storage system be encrypted.
When multiple device administrators attempt to control device encryption, the most secure,
supported setting will always be used. If any device administrator requests device
encryption, it will be enabled; Conversely, if a device administrator attempts to disable
device encryption while another device administrator has enabled it, the call to disable will
fail (most commonly returning ENCRYPTION_STATUS_ACTIVE
).
This policy controls encryption of the secure (application data) storage area. Data written
to other storage areas may or may not be encrypted, and this policy does not require or
control the encryption of any other storage areas. There is one exception: If
isExternalStorageEmulated()
is true
, then the
directory returned by getExternalStorageDirectory()
must be
written to disk within the encrypted storage area.
Important Note: On some devices, it is possible to encrypt storage without requiring the user to create a device PIN or Password. In this case, the storage is encrypted, but the encryption key may not be fully secured. For maximum security, the administrator should also require (and check for) a pattern, PIN, or password.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
encrypt |
boolean :
true to request encryption, false to release any previous request |
Returns | |
---|---|
int |
the new request status (for all active admins) - will be one of
ENCRYPTION_STATUS_UNSUPPORTED , ENCRYPTION_STATUS_INACTIVE , or
ENCRYPTION_STATUS_ACTIVE . This is the value of the requests; Use
getStorageEncryptionStatus() to query the actual device state. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or does not use
USES_ENCRYPTED_STORAGE
|
void setSystemUpdatePolicy (ComponentName admin, SystemUpdatePolicy policy)
Called by device owners to set a local system update policy. When a new policy is set,
ACTION_SYSTEM_UPDATE_POLICY_CHANGED
is broadcasted.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. All
components in the device owner package can set system update policies and the most
recent policy takes effect. |
policy |
SystemUpdatePolicy :
the new policy, or null to clear the current policy. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner. |
See also:
void setTrustAgentConfiguration (ComponentName admin, ComponentName target, PersistableBundle configuration)
Sets a list of configuration features to enable for a TrustAgent component. This is meant to
be used in conjunction with KEYGUARD_DISABLE_TRUST_AGENTS
, which disables all trust
agents but those enabled by this function call. If flag
KEYGUARD_DISABLE_TRUST_AGENTS
is not set, then this call has no effect.
The calling device admin must have requested
USES_POLICY_DISABLE_KEYGUARD_FEATURES
to be able to call this method;
if not, a security exception will be thrown.
This method can be called on the DevicePolicyManager
instance returned by
getParentProfileInstance(ComponentName)
in order to set the configuration for
the parent profile.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
target |
ComponentName :
Component name of the agent to be enabled. |
configuration |
PersistableBundle :
TrustAgent-specific feature bundle. If null for any admin, agent will be
strictly disabled according to the state of the
KEYGUARD_DISABLE_TRUST_AGENTS flag.
If Consult documentation for the specific TrustAgent to determine legal options parameters. |
Throws | |
---|---|
SecurityException |
if admin is not an active administrator or does not use
USES_POLICY_DISABLE_KEYGUARD_FEATURES
|
void setUninstallBlocked (ComponentName admin, String packageName, boolean uninstallBlocked)
Called by profile or device owners to change whether a user can uninstall a package.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
packageName |
String :
package to change. |
uninstallBlocked |
boolean :
true if the user shouldn't be able to uninstall the package. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
void setUserIcon (ComponentName admin, Bitmap icon)
Called by profile or device owners to set the user's photo.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
icon |
Bitmap :
the bitmap to set as the photo. |
Throws | |
---|---|
SecurityException |
if admin is not a device or profile owner.
|
boolean switchUser (ComponentName admin, UserHandle userHandle)
Called by a device owner to switch the specified user to the foreground.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with. |
userHandle |
UserHandle :
the user to switch to; null will switch to primary. |
Returns | |
---|---|
boolean |
true if the switch was successful, false otherwise. |
Throws | |
---|---|
SecurityException |
if admin is not a device owner. |
See also:
void uninstallAllUserCaCerts (ComponentName admin)
Uninstalls all custom trusted CA certificates from the profile. Certificates installed by means other than device policy will also be removed, except for system CA certificates.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if calling from a delegated certificate installer. |
Throws | |
---|---|
SecurityException |
if admin is not null and not a device or profile
owner.
|
void uninstallCaCert (ComponentName admin, byte[] certBuffer)
Uninstalls the given certificate from trusted user CAs, if present.
Parameters | |
---|---|
admin |
ComponentName :
Which DeviceAdminReceiver this request is associated with, or
null if calling from a delegated certificate installer. |
certBuffer |
byte :
encoded form of the certificate to remove. |
Throws | |
---|---|
SecurityException |
if admin is not null and not a device or profile
owner.
|
void wipeData (int flags)
Ask the user data be wiped. Wiping the primary user will cause the device to reboot, erasing all user data while next booting up.
The calling device admin must have requested USES_POLICY_WIPE_DATA
to
be able to call this method; if it has not, a security exception will be thrown.
Parameters | |
---|---|
flags |
int :
Bit mask of additional options: currently supported flags are
WIPE_EXTERNAL_STORAGE and WIPE_RESET_PROTECTION_DATA . |
Throws | |
---|---|
SecurityException |
if the calling application does not own an active administrator
that uses USES_POLICY_WIPE_DATA
|