Most visited

Recently visited

Added in API level 8

DevicePolicyManager

public class DevicePolicyManager
extends Object

java.lang.Object
   ↳ android.app.admin.DevicePolicyManager


公共接口用于管理设备上执行的策略。 大多数此类客户必须在系统中注册为device administrator 此外,设备管理员可以注册为配置文件或设备所有者。 所有设备管理员都可以访问给定的方法,除非该方法的文档指定它仅限于设备或配置文件所有者。 任何调用api的应用程序只能作为它拥有的设备管理员组件的参数传递。 否则,将会抛出SecurityException

Developer Guides

有关管理设备管理策略的更多信息,请阅读 Device Administration开发人员指南。

Summary

Constants

String ACTION_ADD_DEVICE_ADMIN

活动操作:要求用户将新设备管理员添加到系统。

String ACTION_DEVICE_OWNER_CHANGED

广播操作:当设备所有者被设置或更改时发送。

String ACTION_MANAGED_PROFILE_PROVISIONED

广播动作:发送此广播以指示管理的配置文件的配置已成功完成。

String ACTION_PROVISION_MANAGED_DEVICE

活动操作:启动设置受管设备的供应流程。

String ACTION_PROVISION_MANAGED_PROFILE

活动操作:启动设置托管配置文件的供应流程。

String ACTION_SET_NEW_PARENT_PROFILE_PASSWORD

活动操作:让用户输入父配置文件的新密码。

String ACTION_SET_NEW_PASSWORD

活动操作:让用户输入新密码。

String ACTION_START_ENCRYPTION

活动操作:开始加密设备上的数据。

String ACTION_SYSTEM_UPDATE_POLICY_CHANGED

广播操作:通知设备所有者已设置新的本地系统更新策略。

int ENCRYPTION_STATUS_ACTIVATING

getStorageEncryptionStatus()结果代码:表示加密当前未激活,但当前正在激活。

int ENCRYPTION_STATUS_ACTIVE

结果代码为 setStorageEncryption(ComponentName, boolean)getStorageEncryptionStatus() :表示加密处于活动状态。

int ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY

getStorageEncryptionStatus()结果代码:表示加密处于活动状态,但加密密钥尚未由用户设置。

int ENCRYPTION_STATUS_ACTIVE_PER_USER

getStorageEncryptionStatus()结果代码:表示加密处于活动状态,加密密钥与用户或配置文件相关联。

int ENCRYPTION_STATUS_INACTIVE

setStorageEncryption(ComponentName, boolean)getStorageEncryptionStatus()结果代码:表示支持加密,但当前未激活。

int ENCRYPTION_STATUS_UNSUPPORTED

setStorageEncryption(ComponentName, boolean)getStorageEncryptionStatus()结果代码:表示不支持加密。

String EXTRA_ADD_EXPLANATION

一个可选的CharSequence提供额外的解释为什么管理员被添加。

String EXTRA_DEVICE_ADMIN

管理员组件的ComponentName。

String EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE

Account额外持有帐户要在托管配置文件设置期间迁移。

String EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE

Parcelable类型的额外 PersistableBundle ,允许启动管理供应的移动设备管理应用程序或NFC编程器应用程序在配置后将数据传递到管理应用程序实例。

String EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME

ComponentName extra指示将设置为配置文件所有者或设备所有者和活动管理员的移动设备管理应用程序的设备管理接收器。

String EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE

一个int额外的值,用于保存设备管理包所需的最低版本号。

String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM

额外的字符串,用于保存位于 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION指定的下载位置的文件的URL安全base64编码的SHA-256或SHA-1哈希(请参阅下面的注释)。

String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER

一个额外的字符串,用于保存一个http cookie头,该头应该在http请求中用于 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION指定的url。

String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION

一个额外的字符串,其中包含指定设备管理包的下载位置的url。

String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME

此常数在API级别23中已弃用。请使用EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME 此额外功能仍受支持,但BIND_DEVICE_ADMIN是只有一个设备管理接收器需要BIND_DEVICE_ADMIN权限。

String EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM

额外的字符串,用于保存 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION指定的下载位置处的android包归档的任何签名的URL安全base64编码SHA-256校验和。

String EXTRA_PROVISIONING_EMAIL_ADDRESS

额外的一个字符串,用于保存为其创建托管配置文件的帐户的电子邮件地址。

String EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED

移动设备管理应用程序可以使用布尔值,用于在设置期间跳过禁用系统应用程序时设置为 true

String EXTRA_PROVISIONING_LOCALE

一个额外的 Locale ,用于保存设备将要设置的 Locale

String EXTRA_PROVISIONING_LOCAL_TIME

需要在设备的 AlarmManager上设置一个长时间额外的挂钟时间(以毫秒为单位)。

String EXTRA_PROVISIONING_LOGO_URI

一个 Uri额外指向一个标志图像。

String EXTRA_PROVISIONING_MAIN_COLOR

一个额外的整数,表示在配置过程中显示的主要颜色。

String EXTRA_PROVISIONING_SKIP_ENCRYPTION

一个额外的布尔值,指示是否可以跳过设备加密,作为设备所有者或托管配置文件设置的一部分。

String EXTRA_PROVISIONING_TIME_ZONE

额外的字符串,用于保存设备将设置为的时区 AlarmManager

String EXTRA_PROVISIONING_WIFI_HIDDEN

一个额外的布尔值,指示 EXTRA_PROVISIONING_WIFI_SSID的WiFi网络是否隐藏。

String EXTRA_PROVISIONING_WIFI_PAC_URL

额外的字符串,用于 EXTRA_PROVISIONING_WIFI_SSID WiFi网络的代理自动配置(PAC)URL。

String EXTRA_PROVISIONING_WIFI_PASSWORD

EXTRA_PROVISIONING_WIFI_SSID额外持有WiFi网络密码的 EXTRA_PROVISIONING_WIFI_SSID

String EXTRA_PROVISIONING_WIFI_PROXY_BYPASS

一个额外的字符串,用于保存 EXTRA_PROVISIONING_WIFI_SSID WiFi网络的代理旁路。

String EXTRA_PROVISIONING_WIFI_PROXY_HOST

一个额外的字符串,用于保存 EXTRA_PROVISIONING_WIFI_SSID的WiFi网络的代理主机。

String EXTRA_PROVISIONING_WIFI_PROXY_PORT

一个int额外的 EXTRA_PROVISIONING_WIFI_SSID WiFi网络的代理端口。

String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE

一个String额外指示WiFi网络的安全类型 EXTRA_PROVISIONING_WIFI_SSID ,可能是一个 NONEWPA或者 WEP

String EXTRA_PROVISIONING_WIFI_SSID

一个额外的字符串,用于保存nfc设备所有者配置期间应用于下载移动设备管理应用程序的wifi网络的ssid。

int FLAG_MANAGED_CAN_ACCESS_PARENT

addCrossProfileIntentFilter(ComponentName, IntentFilter, int)使用的标志允许受管配置文件中的活动访问从父配置文件发送的意图。

int FLAG_PARENT_CAN_ACCESS_MANAGED

addCrossProfileIntentFilter(ComponentName, IntentFilter, int)使用的标志允许父配置文件中的活动访问从管理配置文件发送的意图。

int KEYGUARD_DISABLE_FEATURES_ALL

禁用所有当前和未来的keyguard定制。

int KEYGUARD_DISABLE_FEATURES_NONE

小键盘在键盘锁中启用

int KEYGUARD_DISABLE_FINGERPRINT

在键盘安全屏幕上禁用指纹传感器(例如,

int KEYGUARD_DISABLE_REMOTE_INPUT

禁用文本输入到安全键盘屏幕上的通知(例如,

int KEYGUARD_DISABLE_SECURE_CAMERA

禁用安全键盘屏幕上的相机(例如,

int KEYGUARD_DISABLE_SECURE_NOTIFICATIONS

禁用在安全键盘屏幕上显示所有通知(例如,

int KEYGUARD_DISABLE_TRUST_AGENTS

在安全键盘屏幕上忽略信任代理状态(例如,

int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS

只允许在安全键盘屏幕上进行编辑通知(例如,

int KEYGUARD_DISABLE_WIDGETS_ALL

禁用所有键盘控件。

String MIME_TYPE_PROVISIONING_NFC

此MIME类型用于启动设备所有者设置。

int PASSWORD_QUALITY_ALPHABETIC

常量 setPasswordQuality(ComponentName, int) :用户必须输入至少包含字母(或其他符号)字符的密码。

int PASSWORD_QUALITY_ALPHANUMERIC

常数 setPasswordQuality(ComponentName, int) :用户必须输入含有至少 两个>数字 字母(或其它符号)的字符的口令。

int PASSWORD_QUALITY_BIOMETRIC_WEAK

持续 setPasswordQuality(ComponentName, int) :该政策允许低安全性生物识别技术。

int PASSWORD_QUALITY_COMPLEX

用于 setPasswordQuality(ComponentName, int)常量:默认情况下,用户必须输入了至少包含字母,数字和特殊符号的密码。

int PASSWORD_QUALITY_NUMERIC

常量 setPasswordQuality(ComponentName, int) :用户必须输入至少包含数字字符的密码。

int PASSWORD_QUALITY_NUMERIC_COMPLEX

用于 setPasswordQuality(ComponentName, int)常量:用户必须输入的密码至少包含数字字符,且不含重复(4444)或有序(1234,4321,2468)序列。

int PASSWORD_QUALITY_SOMETHING

常量为 setPasswordQuality(ComponentName, int) :策略需要某种密码或模式,但不关心它是什么。

int PASSWORD_QUALITY_UNSPECIFIED

常量为 setPasswordQuality(ComponentName, int) :该策略对密码没有要求。

int PERMISSION_GRANT_STATE_DEFAULT

运行时权限状态:用户可以通过UI管理权限。

int PERMISSION_GRANT_STATE_DENIED

运行时权限状态:权限被拒绝给应用程序,用户无法通过UI管理权限。

int PERMISSION_GRANT_STATE_GRANTED

运行时权限状态:权限授予应用程序,用户无法通过UI管理权限。

int PERMISSION_POLICY_AUTO_DENY

权限策略始终拒绝运行时权限的新权限请求。

int PERMISSION_POLICY_AUTO_GRANT

权限策略始终为运行时权限授予新的权限请求。

int PERMISSION_POLICY_PROMPT

权限策略提示用户提供运行时权限的新权限请求。

int RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT

标记为 resetPassword(String, int) :请勿在设备引导时要求提供用户凭据。

int RESET_PASSWORD_REQUIRE_ENTRY

标记为 resetPassword(String, int) :不允许其他管理员在用户输入密码之前再次更改密码。

int SKIP_SETUP_WIZARD

创建新用户后,由 createAndManageUser(ComponentName, String, ComponentName, PersistableBundle, int)使用的标志跳过设置向导。

int WIPE_EXTERNAL_STORAGE

标记为 wipeData(int) :也会擦除设备的外部存储设备(如SD卡)。

int WIPE_RESET_PROTECTION_DATA

标记为 wipeData(int) :也擦除出厂重置保护数据。

Public methods

void addCrossProfileIntentFilter(ComponentName admin, IntentFilter filter, int flags)

由托管配置文件的配置文件所有者调用,以便在托管配置文件中发送的某些意向也可以在父级中解析,反之亦然。

boolean addCrossProfileWidgetProvider(ComponentName admin, String packageName)

由托管配置文件的配置文件所有者调用,以使来自给定包的小部件提供程序在父配置文件中可用。

void addPersistentPreferredActivity(ComponentName admin, IntentFilter filter, ComponentName activity)

由配置文件所有者或设备所有者调用,以便为与某个意图过滤器匹配的意图添加默认意图处理程序活动。

void addUserRestriction(ComponentName admin, String key)

由配置文件或设备所有者调用以设置由该密钥指定的用户限制。

void clearCrossProfileIntentFilters(ComponentName admin)

由受管配置文件的配置文件所有者调用,以删除从受管配置文件转到父配置文件或从父配置文件转到受管配置文件的跨配置文件意向过滤器。

void clearDeviceOwnerApp(String packageName)

清除当前设备所有者。

void clearPackagePersistentPreferredActivities(ComponentName admin, String packageName)

由配置文件所有者或设备所有者调用以删除与 addPersistentPreferredActivity(ComponentName, IntentFilter, ComponentName)设置的给定包关联的所有持久性意向处理程序首选项。

void clearProfileOwner(ComponentName admin)

清除活动配置文件所有者并删除所有用户限制。

void clearUserRestriction(ComponentName admin, String key)

由配置文件或设备所有者调用以清除由该密钥指定的用户限制。

UserHandle createAndManageUser(ComponentName admin, String name, ComponentName profileOwner, PersistableBundle adminExtras, int flags)

由设备所有者调用以创建具有指定名称和调用包的给定组件作为配置文件所有者的用户。

int enableSystemApp(ComponentName admin, Intent intent)

由配置文件或设备所有者调用以通过意图重新启用系统应用程序,这些应用程序在用户初始化时被默认禁用。

void enableSystemApp(ComponentName admin, String packageName)

由配置文件或设备所有者调用,以重新启用在初始化用户时默认禁用的系统应用程序。

String[] getAccountTypesWithManagementDisabled()

获取配置文件所有者禁用其帐户管理的帐户数组。

List<ComponentName> getActiveAdmins()

返回所有当前活动的设备管理员组件名称的列表。

String getAlwaysOnVpnPackage(ComponentName admin)

由设备或配置文件所有者调用以读取为当前用户管理始终在线的VPN连接的软件包名称。

Bundle getApplicationRestrictions(ComponentName admin, String packageName)

检索在主叫用户中运行的给定目标应用程序的应用程序限制。

String getApplicationRestrictionsManagingPackage(ComponentName admin)

由配置文件所有者或设备所有者调用以检索当前用户的应用程序限制管理包,如果没有设置,则 null

boolean getAutoTimeRequired()
boolean getBluetoothContactSharingDisabled(ComponentName admin)

由管理配置文件的配置文件所有者调用,以确定蓝牙设备是否无法访问企业联系人。

boolean getCameraDisabled(ComponentName admin)

确定设备的摄像头是否已被该用户禁用,或者由主叫管理员(如果指定)或所有管理员禁用。

String getCertInstallerPackage(ComponentName admin)

由配置文件所有者或设备所有者调用以检索用户的证书安装程序。

boolean getCrossProfileCallerIdDisabled(ComponentName admin)

由管理配置文件的配置文件所有者调用以确定是否已禁用呼叫者ID信息。

boolean getCrossProfileContactsSearchDisabled(ComponentName admin)

由受管配置文件的配置文件所有者调用以确定联系人搜索是否已被禁用。

List<String> getCrossProfileWidgetProviders(ComponentName admin)

由托管配置文件的配置文件所有者调用,以查询父配置文件中哪些包可用。

int getCurrentFailedPasswordAttempts()

检索自上次成功输入密码后用户输入密码失败的次数。

CharSequence getDeviceOwnerLockScreenInfo()
List<byte[]> getInstalledCaCerts(ComponentName admin)

返回当前信任的所有CA证书,不包括系统CA证书。

int getKeyguardDisabledFeatures(ComponentName admin)

确定Keyguard中的功能是否已由主叫管理员(如果已指定)或设置此用户及其参与配置文件的限制的所有管理员禁用。

CharSequence getLongSupportMessage(ComponentName admin)

由设备管理员调用以获取长期支持消息。

int getMaximumFailedPasswordsForWipe(ComponentName admin)

检索在设备或配置文件被擦除之前允许的当前最大登录尝试次数,针对特定管理员或所有管理员设置此用户及其参与配置文件的限制。

long getMaximumTimeToLock(ComponentName admin)

检索当前最大时间以解锁特定管理员或所有管理员,该管理员设置此用户及其参与配置文件的限制。

int getOrganizationColor(ComponentName admin)

由受管配置文件的配置文件所有者调用以检索用于自定义的颜色。

CharSequence getOrganizationName(ComponentName admin)

由管理配置文件的配置文件所有者调用以检索管理中的组织的名称。

DevicePolicyManager getParentProfileInstance(ComponentName admin)

由受管配置文件的配置文件所有者调用以获取其调用在父配置文件上的 DevicePolicyManager

long getPasswordExpiration(ComponentName admin)

获取特定管理员或所有管理员的当前密码到期时间,该管理员或设置此用户及其参与配置文件的限制的所有管理员。

long getPasswordExpirationTimeout(ComponentName admin)

获取给定管理员的密码到期超时。

int getPasswordHistoryLength(ComponentName admin)

检索特定管理员或所有管理员的当前密码历史记录长度,该管理员设置此用户及其参与配置文件的限制条件。

int getPasswordMaximumLength(int quality)

返回设备支持的特定密码质量的最大密码长度。

int getPasswordMinimumLength(ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的当前最小密码长度。

int getPasswordMinimumLetters(ComponentName admin)

检索特定管理员或设置此用户及其参与配置文件的限制的所有管理员的密码所需的当前字母数。

int getPasswordMinimumLowerCase(ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码所需的当前小写字母数。

int getPasswordMinimumNonLetter(ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码中所需的非字母字符的当前数目。

int getPasswordMinimumNumeric(ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码所需的当前数字位数。

int getPasswordMinimumSymbols(ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码中所需的当前符号数。

int getPasswordMinimumUpperCase(ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码中所需的当前大写字母数。

int getPasswordQuality(ComponentName admin)

为特定管理员或所有管理员检索当前的最低密码质量,这些管理员为此用户及其参与配置文件设置了限制。

int getPermissionGrantState(ComponentName admin, String packageName, String permission)

返回特定应用程序的运行时权限的当前授予状态。

int getPermissionPolicy(ComponentName admin)

返回设备或配置文件所有者设置的当前运行时权限策略。

List<String> getPermittedAccessibilityServices(ComponentName admin)

返回此设备或配置文件所有者设置的允许的辅助功能服务的列表。

List<String> getPermittedInputMethods(ComponentName admin)

返回此设备或配置文件所有者设置的允许输入方法的列表。

boolean getScreenCaptureDisabled(ComponentName admin)

确定屏幕捕获是否已被主叫管理员(如果指定)或所有管理员禁用。

CharSequence getShortSupportMessage(ComponentName admin)

由设备管理员调用以获取简短支持消息。

boolean getStorageEncryption(ComponentName admin)

由正在管理设备的应用程序调用以确定安全存储的请求设置。

int getStorageEncryptionStatus()

由正在管理设备的应用程序调用以确定设备的当前加密状态。

SystemUpdatePolicy getSystemUpdatePolicy()

检索先前由 setSystemUpdatePolicy(ComponentName, SystemUpdatePolicy)设置的本地系统更新策略。

List<PersistableBundle> getTrustAgentConfiguration(ComponentName admin, ComponentName agent)

基于将所有设备管理员的所有呼叫汇总到 setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle) ,获取给定信任代理程序的配置。

Bundle getUserRestrictions(ComponentName admin)

由配置文件或设备所有者调用以获取用 addUserRestriction(ComponentName, String)设置的用户限制。

String getWifiMacAddress(ComponentName admin)

由设备所有者调用以获取Wi-Fi设备的MAC地址。

boolean hasCaCertInstalled(ComponentName admin, byte[] certBuffer)

返回此证书是否作为受信任的CA安装。

boolean hasGrantedPolicy(ComponentName admin, int usesPolicy)

如果管理员已被授予特定设备策略,则返回true。

boolean installCaCert(ComponentName admin, byte[] certBuffer)

将给定证书安装为用户CA.

boolean installKeyPair(ComponentName admin, PrivateKey privKey, Certificate[] certs, String alias, boolean requestAccess)

由设备或配置文件所有者或委派证书安装程序调用以安装证书链和相应的叶证书的私钥。

boolean installKeyPair(ComponentName admin, PrivateKey privKey, Certificate cert, String alias)

由设备或配置文件所有者或委派的证书安装程序调用以安装证书和相应的专用密钥。

boolean isActivePasswordSufficient()

确定用户设置的当前密码是否足以满足政策要求(例如,

boolean isAdminActive(ComponentName admin)

如果给定的管理员组件当前处于活动状态(启用),则返回true。

boolean isApplicationHidden(ComponentName admin, String packageName)

由配置文件或设备所有者调用以确定包是否隐藏。

boolean isCallerApplicationRestrictionsManagingPackage()

由任何应用程序调用以确定是否已通过 setApplicationRestrictionsManagingPackage(ComponentName, String)授予权限来管理主叫用户的应用程序限制。

boolean isDeviceOwnerApp(String packageName)

用于确定某个包是否已注册为设备所有者应用程序。

boolean isLockTaskPermitted(String pkg)

该函数让调用者知道给定组件是否被允许启动锁定任务模式。

boolean isManagedProfile(ComponentName admin)

如果此用户是其他用户的托管个人资料,则返回。

boolean isMasterVolumeMuted(ComponentName admin)

由配置文件或设备所有者调用以检查主音量静音是打开还是关闭。

boolean isPackageSuspended(ComponentName admin, String packageName)

由设备或配置文件所有者调用以确定包是否被暂停。

boolean isProfileOwnerApp(String packageName)

用于确定特定包是否注册为用户的配置文件所有者。

boolean isProvisioningAllowed(String action)

如果设置托管配置文件或设备是可能的,则返回。

boolean isSecurityLoggingEnabled(ComponentName admin)

返回设备所有者是否启用安全日志记录。

boolean isUninstallBlocked(ComponentName admin, String packageName)

检查用户是否被设备策略阻止了卸载软件包。

void lockNow()

立即锁定设备,就好像锁定屏幕超时在此次呼叫时已过期一样。

void reboot(ComponentName admin)

由设备所有者调用重启设备。

void removeActiveAdmin(ComponentName admin)

删除当前的管理组件。

boolean removeCrossProfileWidgetProvider(ComponentName admin, String packageName)

由托管配置文件的配置文件所有者调用,以禁用来自给定包的小部件提供程序在父配置文件中可用。

boolean removeKeyPair(ComponentName admin, String alias)

由设备或配置文件所有者或委派证书安装程序调用,以移除安装在给定别名下的证书和私钥对。

boolean removeUser(ComponentName admin, UserHandle userHandle)

由设备所有者调用以删除用户和所有相关数据。

boolean requestBugreport(ComponentName admin)

由设备所有者调用以请求错误报告。

boolean resetPassword(String password, int flags)

强制用户使用新的设备解锁密码(访问整个设备所需的密码,而不是个人帐户)。

List<SecurityLog.SecurityEvent> retrievePreRebootSecurityLogs(ComponentName admin)

由设备所有者调用以从设备上次重新启动之前检索设备日志。

List<SecurityLog.SecurityEvent> retrieveSecurityLogs(ComponentName admin)

由设备所有者调用以检索自设备引导后上次调用此API以来所有新的安全日志条目。

void setAccountManagementDisabled(ComponentName admin, String accountType, boolean disabled)

由设备所有者或配置文件所有者调用以禁用特定类型帐户的帐户管理。

void setAlwaysOnVpnPackage(ComponentName admin, String vpnPackage, boolean lockdownEnabled)

由设备或配置文件所有者调用,通过当前用户的特定应用程序配置始终开启的VPN连接。

boolean setApplicationHidden(ComponentName admin, String packageName, boolean hidden)

由配置文件或设备所有者调用以隐藏或取消隐藏包。

void setApplicationRestrictions(ComponentName admin, String packageName, Bundle settings)

设置在主叫用户中运行的给定目标应用程序的应用程序限制。

void setApplicationRestrictionsManagingPackage(ComponentName admin, String packageName)

由配置文件所有者或设备所有者调用以授予包的权限,以通过 setApplicationRestrictions(ComponentName, String, Bundle)getApplicationRestrictions(ComponentName, String)管理主叫用户的应用程序限制。

void setAutoTimeRequired(ComponentName admin, boolean required)

由设备所有者调用以设置是否需要自动时间。

void setBluetoothContactSharingDisabled(ComponentName admin, boolean disabled)

由管理配置文件的配置文件所有者调用,以设置蓝牙设备是否可以访问企业联系人。

void setCameraDisabled(ComponentName admin, boolean disabled)

由正在管理该设备的应用程序调用,以禁用该设备上的所有摄像头。

void setCertInstallerPackage(ComponentName admin, String installerPackage)

由配置文件所有者或设备所有者调用,以将对特权证书操作API的访问权限授予第三方证书安装程序应用程序。

void setCrossProfileCallerIdDisabled(ComponentName admin, boolean disabled)

由受管配置文件的配置文件所有者调用,以设置来自受管配置文件的来电者ID信息是否将显示在父配置文件中,用于传入呼叫。

void setCrossProfileContactsSearchDisabled(ComponentName admin, boolean disabled)

由受管配置文件的配置文件所有者调用,以设置来自受管配置文件的联系人搜索是否将显示在父配置文件中,用于传入呼叫。

void setDeviceOwnerLockScreenInfo(ComponentName admin, CharSequence info)

设置设备所有者信息以显示在锁定屏幕上。

void setGlobalSetting(ComponentName admin, String setting, String value)

由设备所有者调用以更新 Settings.Global设置。

boolean setKeyguardDisabled(ComponentName admin, boolean disabled)

由设备所有者调用以完全禁用键盘锁。

void setKeyguardDisabledFeatures(ComponentName admin, int which)

由正在管理设备的应用程序调用以禁用keyguard自定义,例如小部件。

void setLockTaskPackages(ComponentName admin, String[] packages)

设置哪些包可以进入锁定任务模式。

void setLongSupportMessage(ComponentName admin, CharSequence message)

由设备管理员调用以设置长支持消息。

void setMasterVolumeMuted(ComponentName admin, boolean on)

由配置文件或设备所有者调用以设置主音量静音的开启或关闭。

void setMaximumFailedPasswordsForWipe(ComponentName admin, int num)

将其设置为大于零的值将启用内置策略,该策略将在输入了太多不正确的设备解锁密码后执行设备或配置文件擦除。

void setMaximumTimeToLock(ComponentName admin, long timeMs)

由正在管理设备的应用程序调用,以设置用户活动的最长时间,直到设备锁定。

void setOrganizationColor(ComponentName admin, int color)

由托管配置文件的配置文件所有者调用以设置用于自定义的颜色。

void setOrganizationName(ComponentName admin, CharSequence title)

由托管配置文件的配置文件所有者调用以设置正在管理的组织的名称。

String[] setPackagesSuspended(ComponentName admin, String[] packageNames, boolean suspended)

由设备或配置文件所有者调用以暂停此用户的包。

void setPasswordExpirationTimeout(ComponentName admin, long timeout)

由设备管理员调用以设置密码到期超时。

void setPasswordHistoryLength(ComponentName admin, int length)

由正在管理设备的应用程序调用以设置密码历史记录的长度。

void setPasswordMinimumLength(ComponentName admin, int length)

由正在管理设备的应用程序调用以设置允许的最小密码长度。

void setPasswordMinimumLetters(ComponentName admin, int length)

由正在管理设备的应用程序调用以设置密码中所需的最少字母数。

void setPasswordMinimumLowerCase(ComponentName admin, int length)

由正在管理设备的应用程序调用以设置密码中所需的最小数量的小写字母。

void setPasswordMinimumNonLetter(ComponentName admin, int length)

由正在管理设备的应用程序调用,以设置密码中所需的最小数量的非字母字符(数字或符号)。

void setPasswordMinimumNumeric(ComponentName admin, int length)

由正在管理设备的应用程序调用以设置密码中所需的最小数字位数。

void setPasswordMinimumSymbols(ComponentName admin, int length)

由正在管理设备的应用程序调用以设置密码中所需的最小符号数。

void setPasswordMinimumUpperCase(ComponentName admin, int length)

由正在管理设备的应用程序调用,以设置密码中所需的最小大写字母数。

void setPasswordQuality(ComponentName admin, int quality)

由正在管理设备的应用程序调用以设置它正在施加的密码限制。

boolean setPermissionGrantState(ComponentName admin, String packageName, String permission, int grantState)

为特定应用程序设置运行时权限的授予状态。

void setPermissionPolicy(ComponentName admin, int policy)

由配置文件或设备所有者调用以设置应用程序未来运行时权限请求的默认响应。

boolean setPermittedAccessibilityServices(ComponentName admin, List<String> packageNames)

由配置文件或设备所有者调用以设置允许的无障碍服务。

boolean setPermittedInputMethods(ComponentName admin, List<String> packageNames)

由配置文件或设备所有者调用以设置允许的输入法服务。

void setProfileEnabled(ComponentName admin)

设置配置文件的启用状态。

void setProfileName(ComponentName admin, String profileName)

设置配置文件的名称。

void setRecommendedGlobalProxy(ComponentName admin, ProxyInfo proxyInfo)

设置独立于网络的全局HTTP代理。

void setRestrictionsProvider(ComponentName admin, ComponentName provider)

指定一个特定的服务组件作为用户的本地或远程管理员的权限请求的提供者。

void setScreenCaptureDisabled(ComponentName admin, boolean disabled)

由设备/配置文件所有者调用以设置是否禁用屏幕捕获。

void setSecureSetting(ComponentName admin, String setting, String value)

由配置文件或设备所有者调用以更新 Settings.Secure设置。

void setSecurityLoggingEnabled(ComponentName admin, boolean enabled)

由设备所有者调用以控制安全日志记录功能。

void setShortSupportMessage(ComponentName admin, CharSequence message)

由设备管理员调用以设置短支持消息。

boolean setStatusBarDisabled(ComponentName admin, boolean disabled)

由设备所有者调用以禁用状态栏。

int setStorageEncryption(ComponentName admin, boolean encrypt)

由正在管理设备的应用程序调用以请求对存储系统进行加密。

void setSystemUpdatePolicy(ComponentName admin, SystemUpdatePolicy policy)

由设备所有者调用以设置本地系统更新策略。

void setTrustAgentConfiguration(ComponentName admin, ComponentName target, PersistableBundle configuration)

设置为TrustAgent组件启用的配置功能列表。

void setUninstallBlocked(ComponentName admin, String packageName, boolean uninstallBlocked)

由配置文件或设备所有者调用以更改用户是否可以卸载软件包。

void setUserIcon(ComponentName admin, Bitmap icon)

由个人资料或设备所有者调用以设置用户的照片。

boolean switchUser(ComponentName admin, UserHandle userHandle)

由设备所有者调用以将指定的用户切换到前景。

void uninstallAllUserCaCerts(ComponentName admin)

从配置文件中卸载所有自定义的可信CA证书。

void uninstallCaCert(ComponentName admin, byte[] certBuffer)

如果存在,请从受信任的用户CA卸载给定的证书。

void wipeData(int flags)

要求擦除用户数据。

Inherited methods

From class java.lang.Object

Constants

ACTION_ADD_DEVICE_ADMIN

Added in API level 8
String ACTION_ADD_DEVICE_ADMIN

活动操作:要求用户将新设备管理员添加到系统。 所需策略是EXTRA_DEVICE_ADMIN额外字段中策略的ComponentName。 这将调用UI以使用户通过添加设备管理员到系统(或允许他们拒绝它)。

您可以选择包含 EXTRA_ADD_EXPLANATION字段,以向用户提供有关正在添加的内容的附加说明(除了组件的说明)。

如果您的管理员已处于活动状态,则通常会立即返回(无需用户干预)。 但是,如果您的管理员已更新且正在请求更多使用策略标志,则用户将看到新列表。 在用户接受新列表之前,新策略不会提供给更新的管理员。

常量值:“android.app.action.ADD_DEVICE_ADMIN”

ACTION_DEVICE_OWNER_CHANGED

Added in API level 23
String ACTION_DEVICE_OWNER_CHANGED

广播操作:当设备所有者被设置或更改时发送。 该广播仅发送给主用户。

也可以看看:

常量值:“android.app.action.DEVICE_OWNER_CHANGED”

ACTION_MANAGED_PROFILE_PROVISIONED

Added in API level 23
String ACTION_MANAGED_PROFILE_PROVISIONED

广播动作:发送此广播以指示管理的配置文件的配置已成功完成。

广播仅限于主配置文件,限于采用操作 ACTION_PROVISION_MANAGED_PROFILE的配置意向中指定的应用程序。

该意图将包含额外的 EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE ,该额外的 EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE对应于在供应时请求迁移的账户(如果有的话)。

常量值:“android.app.action.MANAGED_PROFILE_PROVISIONED”

ACTION_PROVISION_MANAGED_DEVICE

Added in API level 23
String ACTION_PROVISION_MANAGED_DEVICE

活动操作:启动设置受管设备的供应流程。 必须以startActivityForResult(Intent, int)开始。

在设备所有者设置期间,设备管理员应用程序被设置为设备的所有者。 设备所有者可以完全控制设备。 设备所有者不能被用户修改。

一个典型的用例是一个由公司拥有的设备,但由员工或客户使用。

使用此操作的意图只能在未提供的设备上发送。 通过查询方法isProvisioningAllowed(String)可以检查是否允许isProvisioningAllowed(String)

意图包含以下额外内容:

当设备所有者配置完成后,类型 ACTION_PROFILE_PROVISIONING_COMPLETE的意图被广播给设备所有者。

如果设置失败,设备将恢复出厂设置。

结果代码RESULT_OK意味着供应流程的同步部分已成功,但这并不能保证完整的流程会成功。 相反,结果代码RESULT_CANCELED意味着用户退出配置或某种配置先决条件未得到满足。

常量值:“android.app.action.PROVISION_MANAGED_DEVICE”

ACTION_PROVISION_MANAGED_PROFILE

Added in API level 21
String ACTION_PROVISION_MANAGED_PROFILE

活动操作:启动设置托管配置文件的供应流程。

托管配置文件允许将数据分离,例如将设备用作个人和公司设备。 从哪个用户开始配置,并且管理的配置文件共享一个启动器。

这个意图通常会由移动设备管理应用程序(MDM)发送。 供应添加了托管配置文件,并将MDM设置为完全控制配置文件的配置文件所有者。

通过查询方法 isProvisioningAllowed(String)可以检查是否允许 isProvisioningAllowed(String)

在版本LOLLIPOP ,此意图必须包含额外的EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME M ,它应该包含额外的EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME ,但仍然只支持EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME

意图还可能包含以下附加内容:

当管理配置完成后,广播将发送到配置意向中指定的应用程序。 所述ACTION_PROFILE_PROVISIONING_COMPLETE广播在管理的个人资料发送和ACTION_MANAGED_PROFILE_PROVISIONED广播在主简档发送。

如果设置失败,managedProfile将被删除,以便设备返回到先前的状态。

如果使用startActivityForResult(Intent, int)启动,结果代码RESULT_OK意味着供应流程的同步部分成功,但这并不能保证完整的流程会成功。 相反,结果代码RESULT_CANCELED意味着用户退出配置,或者没有满足配置的一些先决条件。

常量值:“android.app.action.PROVISION_MANAGED_PROFILE”

ACTION_SET_NEW_PARENT_PROFILE_PASSWORD

Added in API level 24
String ACTION_SET_NEW_PARENT_PROFILE_PASSWORD

活动操作:让用户输入父配置文件的新密码。 如果意图从托管配置文件中启动,则会触发为配置文件父项输入新密码。 在所有其他情况下,行为与ACTION_SET_NEW_PASSWORD相同。

常量值:“android.app.action.SET_NEW_PARENT_PROFILE_PASSWORD”

ACTION_SET_NEW_PASSWORD

Added in API level 8
String ACTION_SET_NEW_PASSWORD

活动操作:让用户输入新密码。 在使用setPasswordQuality(ComponentName, int)setPasswordMinimumLength(ComponentName, int)让用户输入符合当前要求的新密码后,应启动此活动。 您可以使用isActivePasswordSufficient()来确定是否需要让用户选择新密码才能满足当前的限制。 从此活动恢复后,您可以检查新的密码特征以查看它们是否足够。 如果意图是从配置文件所有者根据M或以前构建的托管配置文件中M ,则会触发为配置文件的父级输入新密码。 对于所有其他情况,它将触发为用户或其启动的配置文件输入新密码。

也可以看看:

常量值:“android.app.action.SET_NEW_PASSWORD”

ACTION_START_ENCRYPTION

Added in API level 11
String ACTION_START_ENCRYPTION

活动操作:开始加密设备上的数据。 在使用setStorageEncryption(ComponentName, boolean)请求激活加密之后,应该启动此活动。 从此活动恢复后,请使用getStorageEncryption(ComponentName)检查加密状态。 但是,在某些设备上,此活动可能永远不会返回,因为它可能会触发重新启动,并且在某些情况下会完成设备的数据擦除。

常量值:“android.app.action.START_ENCRYPTION”

ACTION_SYSTEM_UPDATE_POLICY_CHANGED

Added in API level 23
String ACTION_SYSTEM_UPDATE_POLICY_CHANGED

广播操作:通知设备所有者已设置新的本地系统更新策略。 新政策可以通过getSystemUpdatePolicy()检索。

常量值:“android.app.action.SYSTEM_UPDATE_POLICY_CHANGED”

ENCRYPTION_STATUS_ACTIVATING

Added in API level 11
int ENCRYPTION_STATUS_ACTIVATING

getStorageEncryptionStatus()结果代码:表示加密当前未激活,但当前正在激活。 只有支持数据加密的设备才会报告,并且只有当存储当前正在进行加密处理时才会报告。 必须重新启动和/或擦除数据才能加密的设备永远不会返回此值。

常量值:2(0x00000002)

ENCRYPTION_STATUS_ACTIVE

Added in API level 11
int ENCRYPTION_STATUS_ACTIVE

结果代码为 setStorageEncryption(ComponentName, boolean)getStorageEncryptionStatus() :表示加密处于活动状态。

另见 ENCRYPTION_STATUS_ACTIVE_PER_USER

常量值:3(0x00000003)

ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY

Added in API level 23
int ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY

getStorageEncryptionStatus()结果代码:表示加密处于活动状态,但加密密钥尚未由用户设置。

常量值:4(0x00000004)

ENCRYPTION_STATUS_ACTIVE_PER_USER

Added in API level 24
int ENCRYPTION_STATUS_ACTIVE_PER_USER

getStorageEncryptionStatus()结果代码:表示加密处于活动状态,加密密钥与用户或配置文件相关联。

该值仅返回到API级别为24以及更高的应用。 对于定位较早API级别的应用,即使加密密钥特定于用户或配置文件,也会返回ENCRYPTION_STATUS_ACTIVE

常量值:5(0x00000005)

ENCRYPTION_STATUS_INACTIVE

Added in API level 11
int ENCRYPTION_STATUS_INACTIVE

结果代码为 setStorageEncryption(ComponentName, boolean)getStorageEncryptionStatus() :表示支持加密,但当前未激活。

常数值:1(0x00000001)

ENCRYPTION_STATUS_UNSUPPORTED

Added in API level 11
int ENCRYPTION_STATUS_UNSUPPORTED

setStorageEncryption(ComponentName, boolean)getStorageEncryptionStatus()结果代码:表示不支持加密。

常量值:0(0x00000000)

EXTRA_ADD_EXPLANATION

Added in API level 8
String EXTRA_ADD_EXPLANATION

一个可选的CharSequence提供额外的解释为什么管理员被添加。

也可以看看:

常量值:“android.app.extra.ADD_EXPLANATION”

EXTRA_DEVICE_ADMIN

Added in API level 8
String EXTRA_DEVICE_ADMIN

管理员组件的ComponentName。

也可以看看:

常量值:“android.app.extra.DEVICE_ADMIN”

EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE

Added in API level 22
String EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE

一个Account额外持有帐户要在托管配置文件设置期间迁移。 如果提供的帐户存在于主要用户中,则会将其复制到凭证中并从主要用户中删除。 ACTION_PROVISION_MANAGED_PROFILE使用。

常量值:“android.app.extra.PROVISIONING_ACCOUNT_TO_MIGRATE”

EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE

Added in API level 21
String EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE

Parcelable类型为 Parcelable额外 PersistableBundle ,允许启动管理供应的移动设备管理应用程序或NFC编程器应用程序在供应之后将数据传递到管理应用程序实例。

如果与ACTION_PROVISION_MANAGED_PROFILE一起使用,则可以由发送意图在新创建的配置文件中将数据传递给自己的应用程序使用。 如果与ACTION_PROVISION_MANAGED_DEVICE使用,它允许将数据传递给主用户上相同的应用程序实例。 从开始M ,如果与使用MIME_TYPE_PROVISIONING_NFC作为NFC的一部分管理的设备配置中,NFC消息应包含一个字符串化Properties实例,其字符串属性将被转换成一个PersistableBundle供应之后,并传递到管理应用程序。

在这两种情况下,应用程序onProfileProvisioningComplete(Context, Intent)通过动作ACTION_PROFILE_PROVISIONING_COMPLETE收到onProfileProvisioningComplete(Context, Intent)的数据。 在管理供应期间,捆绑包不会更改。

常量值:“android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE”

EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME

Added in API level 23
String EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME

ComponentName extra指示将设置为配置文件所有者或设备所有者和活动管理员的移动设备管理应用程序的设备管理接收器。

如果应用程序直接通过动作 ACTION_PROVISION_MANAGED_PROFILEACTION_PROVISION_MANAGED_DEVICE开始供应,则此组件的软件包名称必须与开始供应的应用程序的软件包名称匹配。

当设备所有者设置由具有操作ACTION_PROVISION_MANAGED_DEVICE的意图或包含具有MIME类型MIME_TYPE_PROVISIONING_NFC的NFC记录的NFC消息启动时,此组件被设置为设备所有者和活动管理员。 对于NFC记录,组件名称必须通过flattenToShortString()为一个字符串。

也可以看看:

常量值:“android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME”

EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE

Added in API level 23
String EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE

一个int额外的值,用于保存设备管理包所需的最低版本号。 如果设备管理器已安装在设备上,则只有在安装的软件包版本低于此版本代码时才会从EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION重新下载设备管理器。

通过 MIME_TYPE_PROVISIONING_NFC在NFC记录中使用,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE”

EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM

Added in API level 21
String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM

额外的字符串,用于保存位于 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION指定的下载位置的文件的URL安全base64编码的SHA-256或SHA-1哈希(请参阅下面的注释)。

这个额外的或者EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM必须存在。 提供的校验和必须与下载位置处文件的校验和相匹配。 如果校验和不匹配,则会向用户显示错误,并要求用户重置设备。

MIME_TYPE_PROVISIONING_NFC一起使用的NFC记录通过NFC凸点启动设备所有者配置。

注意:对于运行LOLLIPOPLOLLIPOP_MR1设备,仅支持SHA-1散列。 M开始,此参数接受除SHA-1之外的SHA-256。 未来的操作系统版本可能会删除对SHA-1的支持。

常量值:“android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM”

EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER

Added in API level 21
String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER

一个额外的字符串,用于保存一个http cookie头,该头应该在http请求中用于 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION指定的url。

MIME_TYPE_PROVISIONING_NFC一起使用的NFC记录,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER”

EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION

Added in API level 21
String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION

一个额外的字符串,其中包含指定设备管理包的下载位置的url。 如果未提供,则假定设备管理包已安装。

MIME_TYPE_PROVISIONING_NFC一起使用的NFC记录,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION”

EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME

Added in API level 21
String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME

此常数在API级别23中已弃用。
使用EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME 只有当包中只有一个设备管理员接收器需要权限BIND_DEVICE_ADMIN ,才支持该额外BIND_DEVICE_ADMIN

额外字符串,用于保存将设置为配置文件所有者或设备所有者的移动设备管理应用程序的包名称。

如果应用程序直接通过动作ACTION_PROVISION_MANAGED_PROFILE开始供应, ACTION_PROVISION_MANAGED_PROFILE此软件包必须与开始供应的应用程序的软件包名称匹配。 在这种情况下,该包将被设置为配置文件所有者。

当包含NFC记录的NFC消息启动设备所有者配置时,此包将被设置为设备所有者,其中包含MIME类型为 MIME_TYPE_PROVISIONING_NFC的NFC记录。

当这个额外设置时,应用程序必须只有一个设备管理员接收器。 此接收器将设置为配置文件或设备所有者和活动管理员。

也可以看看:

常量值:“android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME”

EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM

Added in API level 23
String EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM

额外的字符串,用于保存 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION指定的下载位置处的android包归档的任何签名的URL安全base64编码SHA-256校验和。

可以使用 getPackageArchiveInfo(String, int)GET_SIGNATURES标志获取android包归档的签名。

这个额外的或者EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM必须存在。 提供的校验和必须与下载位置文件的任何签名的校验和相匹配。 如果校验和不匹配,则会向用户显示错误,并要求用户重置设备。

MIME_TYPE_PROVISIONING_NFC的NFC记录一起 MIME_TYPE_PROVISIONING_NFC ,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM”

EXTRA_PROVISIONING_EMAIL_ADDRESS

Added in API level 21
String EXTRA_PROVISIONING_EMAIL_ADDRESS

额外的一个字符串,用于保存为其创建托管配置文件的帐户的电子邮件地址。 ACTION_PROVISION_MANAGED_PROFILEACTION_PROFILE_PROVISIONING_COMPLETE

这额外是 EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE一部分。

如果启动管理配置的ACTION_PROVISION_MANAGED_PROFILE意图包含此额外信息,则它会以ACTION_PROFILE_PROVISIONING_COMPLETE意图转发到在配置期间设置为配置文件所有者的移动设备管理应用程序。 它通常用于避免用户必须输入两次他们的电子邮件地址。

常量值:“android.app.extra.PROVISIONING_EMAIL_ADDRESS”

EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED

Added in API level 22
String EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED

移动设备管理应用程序可以使用一个布尔值,用于在设置期间跳过禁用系统应用程序时设置为 true

在带有 MIME_TYPE_PROVISIONING_NFC的NFC记录中使用,或使用启动设备所有者配置的操作 ACTION_PROVISION_MANAGED_DEVICE的意图。

常量值:“android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED”

EXTRA_PROVISIONING_LOCALE

Added in API level 21
String EXTRA_PROVISIONING_LOCALE

一个额外的Locale ,用于保存设备将要设置的Locale 格式:xx_yy,其中xx是语言代码,yy是国家/地区代码。

MIME_TYPE_PROVISIONING_NFC的NFC记录一起 MIME_TYPE_PROVISIONING_NFC ,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_LOCALE”

EXTRA_PROVISIONING_LOCAL_TIME

Added in API level 21
String EXTRA_PROVISIONING_LOCAL_TIME

需要在设备的 AlarmManager上设置一个额外的长时间(以毫秒为单位)。

通过 MIME_TYPE_PROVISIONING_NFC在NFC记录中使用,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_LOCAL_TIME”

EXTRA_PROVISIONING_LOGO_URI

Added in API level 24
String EXTRA_PROVISIONING_LOGO_URI

额外指向徽标图像的Uri 该图像将在配置期间显示。 如果这个额外的不通过,一个默认的图像将被显示。

The following URI schemes are accepted:

调用者的责任是为设备提供合理的像素密度的图像。

如果传递了content:URI,意图应该有标志 FLAG_GRANT_READ_URI_PERMISSION ,并且uri也应该被添加到意图的 ClipData

用于采取行动 ACTION_PROVISION_MANAGED_PROFILEACTION_PROVISION_MANAGED_DEVICE的意图

常量值:“android.app.extra.PROVISIONING_LOGO_URI”

EXTRA_PROVISIONING_MAIN_COLOR

Added in API level 24
String EXTRA_PROVISIONING_MAIN_COLOR

一个额外的整数,表示在配置过程中显示的主要颜色。 有关如何表示颜色,请参阅Color

ACTION_PROVISION_MANAGED_PROFILEACTION_PROVISION_MANAGED_DEVICE

常量值:“android.app.extra.PROVISIONING_MAIN_COLOR”

EXTRA_PROVISIONING_SKIP_ENCRYPTION

Added in API level 23
String EXTRA_PROVISIONING_SKIP_ENCRYPTION

一个额外的布尔值,指示是否可以跳过设备加密,作为设备所有者或托管配置文件设置的一部分。

用于带有 MIME_TYPE_PROVISIONING_NFC的NFC记录或用于启动设备所有者设置的操作 ACTION_PROVISION_MANAGED_DEVICE的意图。

N开始,对于采取措施 ACTION_PROVISION_MANAGED_PROFILE的意图,也支持此操作。

常量值:“android.app.extra.PROVISIONING_SKIP_ENCRYPTION”

EXTRA_PROVISIONING_TIME_ZONE

Added in API level 21
String EXTRA_PROVISIONING_TIME_ZONE

额外的字符串,用于保存设备将设置为的时区 AlarmManager

MIME_TYPE_PROVISIONING_NFC一起使用的NFC记录,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_TIME_ZONE”

EXTRA_PROVISIONING_WIFI_HIDDEN

Added in API level 21
String EXTRA_PROVISIONING_WIFI_HIDDEN

一个额外的布尔值,指示 EXTRA_PROVISIONING_WIFI_SSID的WiFi网络是否隐藏。

通过 MIME_TYPE_PROVISIONING_NFC在NFC记录中使用,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_WIFI_HIDDEN”

EXTRA_PROVISIONING_WIFI_PAC_URL

Added in API level 21
String EXTRA_PROVISIONING_WIFI_PAC_URL

一个额外的字符串,用于 EXTRA_PROVISIONING_WIFI_SSID WiFi网络的代理自动配置(PAC)URL。

通过 MIME_TYPE_PROVISIONING_NFC与NFC记录一起 MIME_TYPE_PROVISIONING_NFC ,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_WIFI_PAC_URL”

EXTRA_PROVISIONING_WIFI_PASSWORD

Added in API level 21
String EXTRA_PROVISIONING_WIFI_PASSWORD

EXTRA_PROVISIONING_WIFI_SSID额外持有WiFi网络密码的 EXTRA_PROVISIONING_WIFI_SSID

MIME_TYPE_PROVISIONING_NFC一起使用的NFC记录通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_WIFI_PASSWORD”

EXTRA_PROVISIONING_WIFI_PROXY_BYPASS

Added in API level 21
String EXTRA_PROVISIONING_WIFI_PROXY_BYPASS

EXTRA_PROVISIONING_WIFI_SSID额外持有WiFi网络代理旁路的 EXTRA_PROVISIONING_WIFI_SSID

通过 MIME_TYPE_PROVISIONING_NFC在NFC记录中使用,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_WIFI_PROXY_BYPASS”

EXTRA_PROVISIONING_WIFI_PROXY_HOST

Added in API level 21
String EXTRA_PROVISIONING_WIFI_PROXY_HOST

EXTRA_PROVISIONING_WIFI_SSID额外持有WiFi网络的代理主机的 EXTRA_PROVISIONING_WIFI_SSID

MIME_TYPE_PROVISIONING_NFC一起使用的NFC记录,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_WIFI_PROXY_HOST”

EXTRA_PROVISIONING_WIFI_PROXY_PORT

Added in API level 21
String EXTRA_PROVISIONING_WIFI_PROXY_PORT

一个int额外的保存 EXTRA_PROVISIONING_WIFI_SSID的WiFi网络的代理端口。

MIME_TYPE_PROVISIONING_NFC一起使用的NFC记录,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_WIFI_PROXY_PORT”

EXTRA_PROVISIONING_WIFI_SECURITY_TYPE

Added in API level 21
String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE

一个String额外指示WiFi网络的安全类型 EXTRA_PROVISIONING_WIFI_SSID ,可能是一个 NONEWPA或者 WEP

MIME_TYPE_PROVISIONING_NFC一起使用的NFC记录,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE”

EXTRA_PROVISIONING_WIFI_SSID

Added in API level 21
String EXTRA_PROVISIONING_WIFI_SSID

一个额外的字符串,用于保存nfc设备所有者配置期间应用于下载移动设备管理应用程序的wifi网络的ssid。

通过 MIME_TYPE_PROVISIONING_NFC在NFC记录中使用,通过NFC凸点启动设备所有者配置。

常量值:“android.app.extra.PROVISIONING_WIFI_SSID”

FLAG_MANAGED_CAN_ACCESS_PARENT

Added in API level 21
int FLAG_MANAGED_CAN_ACCESS_PARENT

addCrossProfileIntentFilter(ComponentName, IntentFilter, int)使用的标志允许受管配置文件中的活动访问从父配置文件发送的意图。 也就是说,当父配置文件中的应用程序调用startActivity(Intent) ,可以通过托管配置文件中的匹配活动来解析意图。

常量值:2(0x00000002)

FLAG_PARENT_CAN_ACCESS_MANAGED

Added in API level 21
int FLAG_PARENT_CAN_ACCESS_MANAGED

addCrossProfileIntentFilter(ComponentName, IntentFilter, int)使用的标志允许父配置文件中的活动访问从管理配置文件发送的意图。 也就是说,当托管配置文件中的应用程序调用startActivity(Intent) ,可以通过父配置文件中的匹配活动来解析意图。

常数值:1(0x00000001)

KEYGUARD_DISABLE_FEATURES_ALL

Added in API level 17
int KEYGUARD_DISABLE_FEATURES_ALL

禁用所有当前和未来的keyguard定制。

常量值:2147483647(0x7fffffff)

KEYGUARD_DISABLE_FEATURES_NONE

Added in API level 17
int KEYGUARD_DISABLE_FEATURES_NONE

小键盘在键盘锁中启用

常量值:0(0x00000000)

KEYGUARD_DISABLE_FINGERPRINT

Added in API level 21
int KEYGUARD_DISABLE_FINGERPRINT

禁用键盘安全屏幕上的指纹传感器(例如PIN /图案/密码)。

常量值:32(0x00000020)

KEYGUARD_DISABLE_REMOTE_INPUT

Added in API level 24
int KEYGUARD_DISABLE_REMOTE_INPUT

禁止将文本输入到安全锁键盘屏幕上的通知中(例如PIN /图案/密码)。

常量值:64(0x00000040)

KEYGUARD_DISABLE_SECURE_CAMERA

Added in API level 17
int KEYGUARD_DISABLE_SECURE_CAMERA

禁用安全锁键盘屏幕上的相机(例如PIN /图案/密码)

常量值:2(0x00000002)

KEYGUARD_DISABLE_SECURE_NOTIFICATIONS

Added in API level 21
int KEYGUARD_DISABLE_SECURE_NOTIFICATIONS

禁用在安全键盘保护屏幕上显示所有通知(例如PIN /图案/密码)

常量值:4(0x00000004)

KEYGUARD_DISABLE_TRUST_AGENTS

Added in API level 21
int KEYGUARD_DISABLE_TRUST_AGENTS

忽略安全锁键盘屏幕上的信任代理状态(例如PIN /模式/密码)。

常量值:16(0x00000010)

KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS

Added in API level 21
int KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS

只允许在安全键盘屏幕上进行编辑通知(例如PIN /图案/密码)

常量值:8(0x00000008)

KEYGUARD_DISABLE_WIDGETS_ALL

Added in API level 17
int KEYGUARD_DISABLE_WIDGETS_ALL

禁用所有键盘控件。 没有效果。

常数值:1(0x00000001)

MIME_TYPE_PROVISIONING_NFC

Added in API level 21
String MIME_TYPE_PROVISIONING_NFC

此MIME类型用于启动设备所有者设置。

在设备所有者设置期间,设备管理员应用程序被设置为设备的所有者。 设备所有者可以完全控制设备。 设备所有者不能被用户修改,并且重置设备的唯一方式是设备所有者应用程序调用工厂重置。

一个典型的用例是一个由公司拥有的设备,但由员工或客户使用。

NFC消息必须发送给未提供的设备。

NFC记录必须包含一个序列化的 Properties对象,其中包含以下属性:

M ,属性应包含 EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME而不是 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME (尽管仅指定 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME仍受支持)。

常量值:“application / com.android.managedprovisioning”

PASSWORD_QUALITY_ALPHABETIC

Added in API level 8
int PASSWORD_QUALITY_ALPHABETIC

用于setPasswordQuality(ComponentName, int)常量:用户必须输入至少包含字母(或其他符号)字符的密码。 请注意质量常数是有序的,以便更高的值更具限制性。

常量值:262144(0x00040000)

PASSWORD_QUALITY_ALPHANUMERIC

Added in API level 8
int PASSWORD_QUALITY_ALPHANUMERIC

常数setPasswordQuality(ComponentName, int) :用户必须输入含有至少两个>数字字母(或其它符号)的字符的口令。 请注意质量常数是有序的,以便更高的值更具限制性。

常量值:327680(0x00050000)

PASSWORD_QUALITY_BIOMETRIC_WEAK

Added in API level 14
int PASSWORD_QUALITY_BIOMETRIC_WEAK

不变setPasswordQuality(ComponentName, int) :该政策允许低安全性生物特征识别技术。 这意味着可以识别个人身份的技术大约是3位数字的PIN(错误检测小于千分之一)。 请注意质量常数是有序的,以便更高的值更具限制性。

常量值:32768(0x00008000)

PASSWORD_QUALITY_COMPLEX

Added in API level 11
int PASSWORD_QUALITY_COMPLEX

用于setPasswordQuality(ComponentName, int)常量:默认情况下,用户必须输入了至少包含字母,数字和特殊符号的密码。 使用此密码质量,可以限制密码以包含各种字符集,如至少一个大写字母等。这些字符使用各种方法指定,如setPasswordMinimumLowerCase(ComponentName, int) 请注意质量常数是有序的,以便更高的值更具限制性。

常量值:393216(0x00060000)

PASSWORD_QUALITY_NUMERIC

Added in API level 8
int PASSWORD_QUALITY_NUMERIC

常量setPasswordQuality(ComponentName, int) :用户必须输入了至少包含数字字符的密码。 请注意质量常数是有序的,以便更高的值更具限制性。

常量值:131072(0x00020000)

PASSWORD_QUALITY_NUMERIC_COMPLEX

Added in API level 21
int PASSWORD_QUALITY_NUMERIC_COMPLEX

常量setPasswordQuality(ComponentName, int) :用户必须输入的密码至少包含数字字符,且不包含重复(4444)或已排序(1234,4321,2468)序列。 请注意质量常数是有序的,以便更高的值更具限制性。

常量值:196608(0x00030000)

PASSWORD_QUALITY_SOMETHING

Added in API level 8
int PASSWORD_QUALITY_SOMETHING

常量为setPasswordQuality(ComponentName, int) :策略需要某种密码或模式,但不关心它是什么。 请注意质量常数是有序的,以便更高的值更具限制性。

常量值:65536(0x00010000)

PASSWORD_QUALITY_UNSPECIFIED

Added in API level 8
int PASSWORD_QUALITY_UNSPECIFIED

常量为setPasswordQuality(ComponentName, int) :该策略对密码没有要求。 请注意质量常数是有序的,以便更高的值更具限制性。

常量值:0(0x00000000)

PERMISSION_GRANT_STATE_DEFAULT

Added in API level 23
int PERMISSION_GRANT_STATE_DEFAULT

运行时权限状态:用户可以通过UI管理权限。

常量值:0(0x00000000)

PERMISSION_GRANT_STATE_DENIED

Added in API level 23
int PERMISSION_GRANT_STATE_DENIED

运行时权限状态:权限被拒绝给应用程序,用户无法通过UI管理权限。

常量值:2(0x00000002)

PERMISSION_GRANT_STATE_GRANTED

Added in API level 23
int PERMISSION_GRANT_STATE_GRANTED

运行时权限状态:权限授予应用程序,用户无法通过UI管理权限。

常数值:1(0x00000001)

PERMISSION_POLICY_AUTO_DENY

Added in API level 23
int PERMISSION_POLICY_AUTO_DENY

权限策略始终拒绝运行时权限的新权限请求。 已经授予或拒绝的权限不受此影响。

常量值:2(0x00000002)

PERMISSION_POLICY_AUTO_GRANT

Added in API level 23
int PERMISSION_POLICY_AUTO_GRANT

权限策略始终为运行时权限授予新的权限请求。 已经授予或拒绝的权限不受此影响。

常数值:1(0x00000001)

PERMISSION_POLICY_PROMPT

Added in API level 23
int PERMISSION_POLICY_PROMPT

权限策略提示用户提供运行时权限的新权限请求。 已经授予或拒绝的权限不受此影响。

常量值:0(0x00000000)

RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT

Added in API level 23
int RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT

标记为resetPassword(String, int) :请勿在设备引导时要求提供用户凭据。 如果该标志已设置,则可以在不询问用户密码的情况下引导设备。 此标志的缺失不会改变当前的启动要求。 该标志只能由设备所有者设置。 如果该应用程序不是设备所有者,则该标志被忽略。 一旦该标志被设置,在不将设备重置为出厂默认设置的情况下它不能被恢复。

常量值:2(0x00000002)

RESET_PASSWORD_REQUIRE_ENTRY

Added in API level 8
int RESET_PASSWORD_REQUIRE_ENTRY

标志为 resetPassword(String, int) :不允许其他管理员在用户输入密码之前再次更改密码。

常数值:1(0x00000001)

SKIP_SETUP_WIZARD

Added in API level 24
int SKIP_SETUP_WIZARD

创建新用户后,由 createAndManageUser(ComponentName, String, ComponentName, PersistableBundle, int)使用的标志跳过设置向导。

常数值:1(0x00000001)

WIPE_EXTERNAL_STORAGE

Added in API level 9
int WIPE_EXTERNAL_STORAGE

标记为 wipeData(int) :也会擦除设备的外部存储设备(如SD卡)。

常数值:1(0x00000001)

WIPE_RESET_PROTECTION_DATA

Added in API level 22
int WIPE_RESET_PROTECTION_DATA

标志为 wipeData(int) :也擦除出厂重置保护数据。

该标志只能由设备所有者管理员设置; 如果它由其他管理员设置,则会引发SecurityException

常量值:2(0x00000002)

Public methods

addCrossProfileIntentFilter

Added in API level 21
void addCrossProfileIntentFilter (ComponentName admin, 
                IntentFilter filter, 
                int flags)

由托管配置文件的配置文件所有者调用,以便在托管配置文件中发送的某些意向也可以在父级中解析,反之亦然。 仅支持活动意图。

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.

addCrossProfileWidgetProvider

Added in API level 21
boolean addCrossProfileWidgetProvider (ComponentName admin, 
                String packageName)

由托管配置文件的配置文件所有者调用,以使来自给定包的小部件提供程序在父配置文件中可用。 因此,用户将能够将配置文件下运行的白名单软件包中的小部件添加到在父配置文件下运行的小部件主机,例如主屏幕。 请注意,包可能有零个或多个提供程序组件,其中每个组件都提供了不同的窗口小部件类型。

注意:默认情况下,没有任何小部件提供程序包是白名单。

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.

也可以看看:

addPersistentPreferredActivity

Added in API level 21
void addPersistentPreferredActivity (ComponentName admin, 
                IntentFilter filter, 
                ComponentName activity)

由配置文件所有者或设备所有者调用,以便为与某个意图过滤器匹配的意图添加默认意图处理程序活动。 即使意图过滤器的潜在事件处理程序集发生更改以及意向首选项已重置,此活动仍将保留为默认意图处理程序。

如果活动未安装(再),默认的消歧机制会接管。 活动(重新)安装后,会自动重置为筛选器的默认意向处理程序。

主叫设备管理员必须是个人资料所有者或设备所有者。 如果不是,则会引发安全异常。

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.

addUserRestriction

Added in API level 21
void addUserRestriction (ComponentName admin, 
                String key)

由配置文件或设备所有者调用以设置由该密钥指定的用户限制。

主叫设备管理员必须是个人资料或设备所有者; 如果不是,则会引发安全异常。

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.

clearCrossProfileIntentFilters

Added in API level 21
void clearCrossProfileIntentFilters (ComponentName admin)

由受管配置文件的配置文件所有者调用,以删除从受管配置文件转到父配置文件或从父配置文件转到受管配置文件的跨配置文件意向过滤器。 只删除已由配置文件所有者设置的配置。

Parameters
admin ComponentName: Which DeviceAdminReceiver this request is associated with.
Throws
SecurityException if admin is not a device or profile owner.

clearDeviceOwnerApp

Added in API level 21
void clearDeviceOwnerApp (String packageName)

清除当前设备所有者。 来电者必须是设备所有者。 这个函数应该谨慎使用,因为它被称为不能被撤消。 设备所有者只能在安装完成之前设置为设备设置的一部分。

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.

clearPackagePersistentPreferredActivities

Added in API level 21
void clearPackagePersistentPreferredActivities (ComponentName admin, 
                String packageName)

由配置文件所有者或设备所有者调用,以移除与由 addPersistentPreferredActivity(ComponentName, IntentFilter, ComponentName)设置的给定包关联的所有持久性意向处理程序首选项。

主叫设备管理员必须是个人资料所有者。 如果不是,则会引发安全异常。

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.

clearProfileOwner

Added in API level 24
void clearProfileOwner (ComponentName admin)

清除活动配置文件所有者并删除所有用户限制。 调用者必须来自与此用户的活动配置文件所有者相同的包,否则将引发SecurityException。

这对管理的配置文件所有者不起作用。

Parameters
admin ComponentName: The component to remove as the profile owner.
Throws
SecurityException if admin is not an active profile owner.

clearUserRestriction

Added in API level 21
void clearUserRestriction (ComponentName admin, 
                String key)

由配置文件或设备所有者调用以清除由该密钥指定的用户限制。

主叫设备管理员必须是个人资料或设备所有者; 如果不是,则会引发安全异常。

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.

createAndManageUser

Added in API level 24
UserHandle createAndManageUser (ComponentName admin, 
                String name, 
                ComponentName profileOwner, 
                PersistableBundle adminExtras, 
                int flags)

由设备所有者调用以创建具有指定名称和调用包的给定组件作为配置文件所有者的用户。 此方法返回的UserHandle不应该保留,因为用户句柄在用户被删除和创建时被回收。 如果您需要为该用户保留一个标识符,请使用getSerialNumberForUser(UserHandle) 新用户将不会在后台启动。

admin是设备所有者DeviceAdminReceiver profileOwner也是与Admin相同的软件包中的DeviceAdminReceiver,并且将成为配置文件所有者,并将作为新用户的活动管理员注册。 配置文件所有者包将安装在新用户上。

如果adminExtras不为空,它们将被存储在设备上,直到用户第一次启动。 然后,当onEnable被调用时,附加内容将被传递给管理员。

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.

也可以看看:

enableSystemApp

Added in API level 21
int enableSystemApp (ComponentName admin, 
                Intent intent)

由配置文件或设备所有者调用以通过意图重新启用系统应用程序,这些应用程序在用户初始化时被默认禁用。

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.

enableSystemApp

Added in API level 21
void enableSystemApp (ComponentName admin, 
                String packageName)

由配置文件或设备所有者调用,以重新启用在初始化用户时默认禁用的系统应用程序。

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.

getAccountTypesWithManagementDisabled

Added in API level 21
String[] getAccountTypesWithManagementDisabled ()

获取配置文件所有者禁用其帐户管理的帐户数组。

通过调用 setAccountManagementDisabled(ComponentName, String, boolean)可以禁用/启用帐户管理。

Returns
String[] a list of account types for which account management has been disabled.

也可以看看:

getActiveAdmins

Added in API level 8
List<ComponentName> getActiveAdmins ()

返回所有当前活动的设备管理员组件名称的列表。 如果没有管理员可以返回null

Returns
List<ComponentName>

getAlwaysOnVpnPackage

Added in API level 24
String getAlwaysOnVpnPackage (ComponentName admin)

由设备或配置文件所有者调用以读取为当前用户管理始终在线的VPN连接的软件包名称。 如果没有这样的软件包,或者系统提供永远在线的VPN而不是应用程序,则将返回null

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.

getApplicationRestrictions

Added in API level 21
Bundle getApplicationRestrictions (ComponentName admin, 
                String packageName)

检索在主叫用户中运行的给定目标应用程序的应用程序限制。

调用者必须是该用户的配置文件或设备所有者,或者该包允许通过setApplicationRestrictionsManagingPackage(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 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.

也可以看看:

getApplicationRestrictionsManagingPackage

Added in API level 24
String getApplicationRestrictionsManagingPackage (ComponentName admin)

由配置文件所有者或设备所有者调用以检索当前用户的应用程序限制管理包,如果没有设置,则 null

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.

getAutoTimeRequired

Added in API level 21
boolean getAutoTimeRequired ()

Returns
boolean true if auto time is required.

getBluetoothContactSharingDisabled

Added in API level 23
boolean getBluetoothContactSharingDisabled (ComponentName admin)

由管理配置文件的配置文件所有者调用,以确定蓝牙设备是否无法访问企业联系人。

主叫设备管理员必须是个人资料所有者。 如果不是,则会引发安全异常。

该API仅适用于托管配置文件。

Parameters
admin ComponentName: Which DeviceAdminReceiver this request is associated with.
Returns
boolean
Throws
SecurityException if admin is not a device or profile owner.

getCameraDisabled

Added in API level 14
boolean getCameraDisabled (ComponentName admin)

确定设备的摄像头是否已被该用户禁用,或者由主叫管理员(如果指定)或所有管理员禁用。

Parameters
admin ComponentName: The name of the admin component to check, or null to check whether any admins have disabled the camera
Returns
boolean

getCertInstallerPackage

Added in API level 23
String getCertInstallerPackage (ComponentName admin)

由配置文件所有者或设备所有者调用以检索用户的证书安装程序。 如果没有设置,则返回null。

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.

getCrossProfileCallerIdDisabled

Added in API level 21
boolean getCrossProfileCallerIdDisabled (ComponentName admin)

由管理配置文件的配置文件所有者调用以确定是否已禁用呼叫者ID信息。

主叫设备管理员必须是个人资料所有者。 如果不是,则会引发安全异常。

Parameters
admin ComponentName: Which DeviceAdminReceiver this request is associated with.
Returns
boolean
Throws
SecurityException if admin is not a device or profile owner.

getCrossProfileContactsSearchDisabled

Added in API level 24
boolean getCrossProfileContactsSearchDisabled (ComponentName admin)

由受管配置文件的配置文件所有者调用以确定联系人搜索是否已被禁用。

主叫设备管理员必须是个人资料所有者。 如果不是,则会引发安全异常。

Parameters
admin ComponentName: Which DeviceAdminReceiver this request is associated with.
Returns
boolean
Throws
SecurityException if admin is not a device or profile owner.

getCrossProfileWidgetProviders

Added in API level 21
List<String> getCrossProfileWidgetProviders (ComponentName admin)

由托管配置文件的配置文件所有者调用,以查询父配置文件中哪些包可用。

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.

也可以看看:

getCurrentFailedPasswordAttempts

Added in API level 8
int getCurrentFailedPasswordAttempts ()

检索自上次成功输入密码后用户输入密码失败的次数。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父用户未能密码attemts的数量。

主叫设备管理员必须要求USES_POLICY_WATCH_LOGIN能够调用此方法; 如果没有,则会抛出安全异常。

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

getDeviceOwnerLockScreenInfo

Added in API level 24
CharSequence getDeviceOwnerLockScreenInfo ()

Returns
CharSequence The device owner information. If it is not set returns null.

getInstalledCaCerts

Added in API level 21
List<byte[]> getInstalledCaCerts (ComponentName admin)

返回当前信任的所有CA证书,不包括系统CA证书。 如果用户通过设备策略以外的其他方式安装了任何证书,则这些证书也将包含在内。

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.

getKeyguardDisabledFeatures

Added in API level 17
int getKeyguardDisabledFeatures (ComponentName admin)

确定Keyguard中的功能是否已由主叫管理员(如果已指定)或设置此用户及其参与配置文件的限制的所有管理员禁用。 没有考虑对具有单独挑战的配置文件的限制。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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.

getLongSupportMessage

Added in API level 24
CharSequence getLongSupportMessage (ComponentName admin)

由设备管理员调用以获取长期支持消息。

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.

getMaximumFailedPasswordsForWipe

Added in API level 8
int getMaximumFailedPasswordsForWipe (ComponentName admin)

检索在设备或配置文件被擦除之前允许的当前最大登录尝试次数,针对特定管理员或所有管理员设置此用户及其参与配置文件的限制。 没有考虑对具有单独挑战的配置文件的限制。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父配置文件中的值。

Parameters
admin ComponentName: The name of the admin component to check, or null to aggregate all admins.
Returns
int

getMaximumTimeToLock

Added in API level 8
long getMaximumTimeToLock (ComponentName admin)

检索当前最大时间以解锁特定管理员或所有管理员,该管理员设置此用户及其参与配置文件的限制。 没有考虑对具有单独挑战的配置文件的限制。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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.

getOrganizationColor

Added in API level 24
int getOrganizationColor (ComponentName admin)

由受管配置文件的配置文件所有者调用以检索用于自定义的颜色。 该颜色用作该用户的确认凭证屏幕的背景颜色。

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.

getOrganizationName

Added in API level 24
CharSequence getOrganizationName (ComponentName admin)

由管理配置文件的配置文件所有者调用以检索管理中的组织的名称。

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.

getParentProfileInstance

Added in API level 24
DevicePolicyManager getParentProfileInstance (ComponentName admin)

由托管配置文件的配置文件所有者调用以获取其调用在父配置文件上的 DevicePolicyManager

父实例支持以下方法,所有其他方法在父实例上调用时将引发SecurityException:

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.

getPasswordExpiration

Added in API level 11
long getPasswordExpiration (ComponentName admin)

获取特定管理员或所有管理员的当前密码到期时间,该管理员或设置此用户及其参与配置文件的限制的所有管理员。 没有考虑对具有单独挑战的配置文件的限制。 如果管理员是null ,那么将返回所有到期时间的组合 - 这将是所有这些时间的最小值。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父配置文件中的密码过期。

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.

getPasswordExpirationTimeout

Added in API level 11
long getPasswordExpirationTimeout (ComponentName admin)

获取给定管理员的密码到期超时。 到期超时是在setPasswordExpirationTimeout(ComponentName, long)针对给定管理员的呼叫或所有参与策略管理员的聚合(如果admin为空)中提供的循环到期超时。 对具有单独挑战的配置文件设置了限制的管理员未被考虑在内。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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

getPasswordHistoryLength

Added in API level 11
int getPasswordHistoryLength (ComponentName admin)

检索特定管理员或所有管理员的当前密码历史记录长度,该管理员设置此用户及其参与配置文件的限制条件。 没有考虑对具有单独挑战的配置文件的限制。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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

getPasswordMaximumLength

Added in API level 8
int getPasswordMaximumLength (int quality)

返回设备支持的特定密码质量的最大密码长度。

Parameters
quality int: The quality being interrogated.
Returns
int Returns the maximum length that the user can enter.

getPasswordMinimumLength

Added in API level 8
int getPasswordMinimumLength (ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的当前最小密码长度。 没有考虑对具有单独挑战的配置文件的限制。

这种方法可以在被称为DevicePolicyManager通过返回的实例getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。 用户及其配置文件或特定用户。

Parameters
admin ComponentName: The name of the admin component to check, or null to aggregate all admins.
Returns
int

getPasswordMinimumLetters

Added in API level 11
int getPasswordMinimumLetters (ComponentName admin)

检索特定管理员或设置此用户及其参与配置文件的限制的所有管理员的密码所需的当前字母数。 没有考虑对具有单独挑战的配置文件的限制。 这与setPasswordMinimumLetters(ComponentName, int)设置的值相同,仅适用于密码质量为PASSWORD_QUALITY_COMPLEX

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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.

getPasswordMinimumLowerCase

Added in API level 11
int getPasswordMinimumLowerCase (ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码所需的当前小写字母数。 没有考虑对具有单独挑战的配置文件的限制。 这与setPasswordMinimumLowerCase(ComponentName, int)设置的值相同,仅适用于密码质量为PASSWORD_QUALITY_COMPLEX

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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.

getPasswordMinimumNonLetter

Added in API level 11
int getPasswordMinimumNonLetter (ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码中所需的非字母字符的当前数目。 没有考虑对具有单独挑战的配置文件的限制。 这与setPasswordMinimumNonLetter(ComponentName, int)设置的值相同,仅适用于密码质量为PASSWORD_QUALITY_COMPLEX

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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.

getPasswordMinimumNumeric

Added in API level 11
int getPasswordMinimumNumeric (ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码所需的当前数字位数。 没有考虑对具有单独挑战的配置文件的限制。 这与setPasswordMinimumNumeric(ComponentName, int)设置的值相同,仅适用于密码质量为PASSWORD_QUALITY_COMPLEX

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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.

getPasswordMinimumSymbols

Added in API level 11
int getPasswordMinimumSymbols (ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码中所需的当前符号数。 没有考虑对具有单独挑战的配置文件的限制。 这与setPasswordMinimumSymbols(ComponentName, int)设置的值相同,仅适用于密码质量为PASSWORD_QUALITY_COMPLEX

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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.

getPasswordMinimumUpperCase

Added in API level 11
int getPasswordMinimumUpperCase (ComponentName admin)

检索特定管理员或为此用户及其参与配置文件设置限制的所有管理员的密码中所需的当前大写字母数。 没有考虑对具有单独挑战的配置文件的限制。 这与setPasswordMinimumUpperCase(ComponentName, int)设置的值相同,仅适用于密码质量为PASSWORD_QUALITY_COMPLEX

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

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.

getPasswordQuality

Added in API level 8
int getPasswordQuality (ComponentName admin)

为特定管理员或所有管理员检索当前的最低密码质量,这些管理员为此用户及其参与配置文件设置了限制。 没有考虑对具有单独挑战的配置文件的限制。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便检索父轮廓限制。

Parameters
admin ComponentName: The name of the admin component to check, or null to aggregate all admins.
Returns
int

getPermissionGrantState

Added in API level 23
int getPermissionGrantState (ComponentName admin, 
                String packageName, 
                String permission)

返回特定应用程序的运行时权限的当前授予状态。

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.

也可以看看:

getPermissionPolicy

Added in API level 23
int getPermissionPolicy (ComponentName admin)

返回设备或配置文件所有者设置的当前运行时权限策略。 默认值是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.

getPermittedAccessibilityServices

Added in API level 21
List<String> getPermittedAccessibilityServices (ComponentName admin)

返回此设备或配置文件所有者设置的允许的辅助功能服务的列表。

一个空列表意味着除了系统服务被允许之外,没有辅助服务 空表示允许所有无障碍服务。

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.

getPermittedInputMethods

Added in API level 21
List<String> getPermittedInputMethods (ComponentName admin)

返回此设备或配置文件所有者设置的允许输入方法的列表。

一个空列表意味着除了系统输入方法被允许外,没有输入方法。 空表示允许所有输入方法。

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.

getScreenCaptureDisabled

Added in API level 21
boolean getScreenCaptureDisabled (ComponentName admin)

确定屏幕捕获是否已被主叫管理员(如果指定)或所有管理员禁用。

Parameters
admin ComponentName: The name of the admin component to check, or null to check whether any admins have disabled screen capture.
Returns
boolean

getShortSupportMessage

Added in API level 24
CharSequence getShortSupportMessage (ComponentName admin)

由设备管理员调用以获取简短支持消息。

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.

getStorageEncryption

Added in API level 11
boolean getStorageEncryption (ComponentName admin)

由正在管理设备的应用程序调用以确定安全存储的请求设置。

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.

getStorageEncryptionStatus

Added in API level 11
int getStorageEncryptionStatus ()

由正在管理设备的应用程序调用以确定设备的当前加密状态。

根据返回的状态码,呼叫者可能会以不同的方式继续。 如果结果为ENCRYPTION_STATUS_UNSUPPORTED ,则存储系统不支持加密。 如果结果为ENCRYPTION_STATUS_INACTIVE ,请使用ACTION_START_ENCRYPTION开始加密或解密存储的过程。 如果结果为ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY ,则存储系统已启用加密,但未设置密码,因此可能需要采取进一步的操作。 如果结果是ENCRYPTION_STATUS_ACTIVATINGENCRYPTION_STATUS_ACTIVE或者ENCRYPTION_STATUS_ACTIVE_PER_USER ,则不需要采取进一步的行动。

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.

getSystemUpdatePolicy

Added in API level 23
SystemUpdatePolicy getSystemUpdatePolicy ()

检索先前由 setSystemUpdatePolicy(ComponentName, SystemUpdatePolicy)设置的本地系统更新策略。

Returns
SystemUpdatePolicy The current policy object, or null if no policy is set.

getTrustAgentConfiguration

Added in API level 23
List<PersistableBundle> getTrustAgentConfiguration (ComponentName admin, 
                ComponentName agent)

基于将所有设备管理员的呼叫汇总到 setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle) ,获取给定信任代理程序的配置。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以获取配置父配置文件中设置。

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.

getUserRestrictions

Added in API level 24
Bundle getUserRestrictions (ComponentName admin)

由配置文件或设备所有者调用以获取用 addUserRestriction(ComponentName, String)设置的用户限制。

目标用户可能会有更多由系统或其他设备所有者/配置文件所有者设置的限制。 要获取当前设置的所有用户限制,请使用getUserRestrictions()

Parameters
admin ComponentName: Which DeviceAdminReceiver this request is associated with.
Returns
Bundle
Throws
SecurityException if admin is not a device or profile owner.

getWifiMacAddress

Added in API level 24
String getWifiMacAddress (ComponentName admin)

由设备所有者调用以获取Wi-Fi设备的MAC地址。

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

地址将采用 XX:XX:XX:XX:XX:XX格式。

Throws
SecurityException if admin is not a device owner.

hasCaCertInstalled

Added in API level 21
boolean hasCaCertInstalled (ComponentName admin, 
                byte[] certBuffer)

返回此证书是否作为受信任的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.

hasGrantedPolicy

Added in API level 11
boolean hasGrantedPolicy (ComponentName admin, 
                int usesPolicy)

如果管理员已被授予特定设备策略,则返回true。 这可用于检查管理员是否在先前的一组策略下激活,但在升级后需要额外的策略。

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.

installCaCert

Added in API level 21
boolean installCaCert (ComponentName admin, 
                byte[] certBuffer)

将给定证书安装为用户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.

installKeyPair

Added in API level 24
boolean installKeyPair (ComponentName admin, 
                PrivateKey privKey, 
                Certificate[] certs, 
                String alias, 
                boolean requestAccess)

由设备或配置文件所有者或委派证书安装程序调用以安装证书链和相应的叶证书的私钥。 在配置文件中的所有应用程序都可以访问证书链并使用私钥,只要用户直接批准。

该API的调用者可以在没有用户批准的情况下立即授予自己对证书和私钥的访问权限。 除非严格必要,否则最好不要这样做,因为这会带来额外的安全漏洞。

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.

也可以看看:

installKeyPair

Added in API level 21
boolean installKeyPair (ComponentName admin, 
                PrivateKey privKey, 
                Certificate cert, 
                String alias)

由设备或配置文件所有者或委派的证书安装程序调用以安装证书和相应的专用密钥。 只要用户直接批准,配置文件中的所有应用程序都将能够访问证书并使用私钥。

未经用户直接批准,访问已安装的凭证将不会被授予该API的调用者。 这是为了安全 - 如果证书安装程序受到威胁,它已经安装的证书将受到保护。

如果安装程序必须有权访问凭据,请调用 installKeyPair(ComponentName, PrivateKey, Certificate[], String, boolean)

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.

isActivePasswordSufficient

Added in API level 8
boolean isActivePasswordSufficient ()

确定用户设置的当前密码是否足以满足该用户的管理员及其参与配置文件请求的策略要求(例如质量,最小长度)。 没有考虑对具有单独挑战的配置文件的限制。

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以确定是否对父配置文件设置的密码就足够了。

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

isAdminActive

Added in API level 8
boolean isAdminActive (ComponentName admin)

如果给定的管理员组件当前处于活动状态(启用),则返回true。

Parameters
admin ComponentName: The administrator component to check for.
Returns
boolean true if admin is currently enabled in the system, false otherwise

isApplicationHidden

Added in API level 21
boolean isApplicationHidden (ComponentName admin, 
                String packageName)

由配置文件或设备所有者调用以确定包是否隐藏。

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.

isCallerApplicationRestrictionsManagingPackage

Added in API level 24
boolean isCallerApplicationRestrictionsManagingPackage ()

由任何应用程序调用以确定是否已通过 setApplicationRestrictionsManagingPackage(ComponentName, String)授予权限来管理主叫用户的应用程序限制。

这是通过将调用的Linux uid与该方法指定的包的uid进行比较来完成的。

Returns
boolean

isDeviceOwnerApp

Added in API level 18
boolean isDeviceOwnerApp (String packageName)

用于确定某个包是否已注册为设备所有者应用程序。 设备所有者应用是一种特殊的设备管理员,一旦作为设备管理员激活,就不能被用户停用。 它也不能被卸载。 要检查某个包是否当前已注册为设备所有者应用程序,请将包名称从getPackageName()给此方法。

This is useful for device admin apps that want to check whether they are also registered as the device owner app. The exact mechanism by which a device admin app is registered as a device owner app is defined by the setup process.

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.

isLockTaskPermitted

Added in API level 21
boolean isLockTaskPermitted (String pkg)

该函数让调用者知道给定组件是否被允许启动锁定任务模式。

Parameters
pkg String: The package to check
Returns
boolean

isManagedProfile

Added in API level 24
boolean isManagedProfile (ComponentName admin)

如果此用户是其他用户的托管个人资料,则返回。 管理员可以成为一个管理配置文件的配置文件所有者与ACTION_PROVISION_MANAGED_PROFILE ,并与托管用户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.

isMasterVolumeMuted

Added in API level 21
boolean isMasterVolumeMuted (ComponentName admin)

由配置文件或设备所有者调用以检查主音量静音是打开还是关闭。

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.

isPackageSuspended

Added in API level 24
boolean isPackageSuspended (ComponentName admin, 
                String packageName)

由设备或配置文件所有者调用以确定包是否被暂停。

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.

isProfileOwnerApp

Added in API level 21
boolean isProfileOwnerApp (String packageName)

用于确定特定包是否注册为用户的配置文件所有者。 个人资料所有者是一个特殊的设备管理员,拥有该个人资料中的其他特权

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.

isProvisioningAllowed

Added in API level 24
boolean isProvisioningAllowed (String action)

如果设置托管配置文件或设备是可能的,则返回。

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.

isSecurityLoggingEnabled

Added in API level 24
boolean isSecurityLoggingEnabled (ComponentName admin)

返回设备所有者是否启用安全日志记录。

只能由设备所有者调用,否则将引发 SecurityException

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.

isUninstallBlocked

Added in API level 21
boolean isUninstallBlocked (ComponentName admin, 
                String packageName)

检查用户是否被设备策略阻止了卸载软件包。 如果检查特定管理员的政策,则需要调用者成为配置文件所有者。

注意:LOLLIPOP_MR1开始,此API的行为已更改,因此如果任何管理员阻止了卸载,将传回null作为参数将返回admin 在L MR1之前,传递null将引发NullPointerException null

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.

lockNow

Added in API level 8
void lockNow ()

立即锁定设备,就好像锁定屏幕超时在此次呼叫时已过期一样。

主叫设备管理员必须要求USES_POLICY_FORCE_LOCK能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以锁定父轮廓。

Throws
SecurityException if the calling application does not own an active administrator that uses USES_POLICY_FORCE_LOCK

reboot

Added in API level 24
void reboot (ComponentName admin)

由设备所有者调用重启设备。 如果设备上有正在进行的呼叫, IllegalStateException引发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.

也可以看看:

removeActiveAdmin

Added in API level 8
void removeActiveAdmin (ComponentName admin)

删除当前的管理组件。 这只能由拥有管理组件的应用程序调用; 如果您尝试删除其他人的组件,则会引发安全异常。

请注意,该操作不同步,并且在此方法返回时管理员可能仍处于活动状态(如 getActiveAdmins() )。

Parameters
admin ComponentName: The administration compononent to remove.
Throws
SecurityException if the caller is not in the owner application of admin.

removeCrossProfileWidgetProvider

Added in API level 21
boolean removeCrossProfileWidgetProvider (ComponentName admin, 
                String packageName)

由托管配置文件的配置文件所有者调用,以禁用来自给定包的小部件提供程序在父配置文件中可用。 为使此方法生效,应该通过addCrossProfileWidgetProvider(android.content.ComponentName, String)添加addCrossProfileWidgetProvider(android.content.ComponentName, String)

注意:默认情况下,没有任何小部件提供程序包是白名单。

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.

也可以看看:

removeKeyPair

Added in API level 24
boolean removeKeyPair (ComponentName admin, 
                String 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.

removeUser

Added in API level 21
boolean removeUser (ComponentName admin, 
                UserHandle userHandle)

由设备所有者调用以删除用户和所有相关数据。 主要用户不能被删除。

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.

requestBugreport

Added in API level 24
boolean requestBugreport (ComponentName admin)

由设备所有者调用以请求错误报告。

设备所有者只能管理一位用户。 否则会抛出SecurityException

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.

resetPassword

Added in API level 8
boolean resetPassword (String password, 
                int flags)

强制用户使用新的设备解锁密码(访问整个设备所需的密码,而不是个人帐户)。 这会立即生效。

注意:对于不是设备所有者而不是设备所有者的设备管理员,此API限制为N 现在只有当前没有设置密码时才能更改密码。 设备所有者和配置文件所有者仍然可以在用户解锁并且没有托管配置文件时执行此操作。

给定的密码必须足以满足getPasswordQuality(ComponentName)getPasswordMinimumLength(ComponentName)返回的当前密码质量和长度限制; 如果它不符合这些限制条件,那么它将被拒绝并返回错误。 请注意,密码的质量可能更高(当请求质量仅为数字时,包含字母数字字符),在这种情况下,当前活动质量将会增加以匹配。

如果当前密码限制允许,使用空密码或空密码进行呼叫将清除任何现有PIN,模式或密码。 注意:这不适用于N及更高版本的托管配置文件或非设备所有者或配置文件所有者的设备管理员。 一旦设置,密码不能更改为空或空,除非由这些管理员。

主叫设备管理员必须要求USES_POLICY_RESET_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

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.

retrievePreRebootSecurityLogs

Added in API level 24
List<SecurityLog.SecurityEvent> retrievePreRebootSecurityLogs (ComponentName admin)

由设备所有者调用以从设备上次重新启动之前检索设备日志。

此API在所有设备上都不受支持。 在不支持的设备上调用此API将导致返回null 设备日志是从RAM区域检索的,因此在断电期间不能保证无损坏,因此请谨慎分析解析时的数据损坏情况。

设备所有者只能管理一位用户。 否则会抛出SecurityException

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.

retrieveSecurityLogs

Added in API level 24
List<SecurityLog.SecurityEvent> retrieveSecurityLogs (ComponentName admin)

由设备所有者调用以检索自设备引导后上次调用此API以来所有新的安全日志条目。

访问日志的速率是有限的,只有在设备所有者通过 onSecurityLogsAvailable(Context, Intent)收到通知后才能返回新的日志。

设备所有者只能管理一位用户。 否则会抛出SecurityException

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.

setAccountManagementDisabled

Added in API level 21
void setAccountManagementDisabled (ComponentName admin, 
                String accountType, 
                boolean disabled)

由设备所有者或配置文件所有者调用以禁用特定类型帐户的帐户管理。

主叫设备管理员必须是设备所有者或配置文件所有者。 如果不是,则会引发安全异常。

如果帐户类型的帐户管理被禁用,则添加或删除该类型的帐户将无法进行。

N配置文件或设备所有者仍然可以使用 AccountManager API在禁用特定类型的帐户管理时添加或删除帐户。

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.

setAlwaysOnVpnPackage

Added in API level 24
void setAlwaysOnVpnPackage (ComponentName admin, 
                String vpnPackage, 
                boolean lockdownEnabled)

由设备或配置文件所有者调用,通过当前用户的特定应用程序配置始终开启的VPN连接。 此连接自动授予并在重新启动后保留。

指定的软件包应该在 VpnService保护下 BIND_VPN_SERVICE ,否则呼叫将失败。

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.

setApplicationHidden

Added in API level 21
boolean setApplicationHidden (ComponentName admin, 
                String packageName, 
                boolean hidden)

由配置文件或设备所有者调用以隐藏或取消隐藏包。 当一个包被隐藏时,它不可用,但数据和实际的包文件仍然存在。

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.

setApplicationRestrictions

Added in API level 21
void setApplicationRestrictions (ComponentName admin, 
                String packageName, 
                Bundle settings)

设置在主叫用户中运行的给定目标应用程序的应用程序限制。

来电者必须是该用户的个人资料或设备所有者,或者该包允许通过setApplicationRestrictionsManagingPackage(ComponentName, String)管理应用程序限制; 否则会引发安全异常。

提供的 Bundle由键值对组成,值的类型可以是:

  • boolean
  • int
  • String or String[]
  • From M, Bundle or Bundle[]

如果限制尚不可用,但可能在不久的将来应用,则调用者可以通过将 KEY_RESTRICTIONS_PENDING添加到设置参数来通知目标应用程序。

除了配置文件或设备所有者以及通过 getApplicationRestrictions(ComponentName, String)管理包的应用程序限制之外,应用程序限制仅通过 getApplicationRestrictions(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.

也可以看看:

setApplicationRestrictionsManagingPackage

Added in API level 24
void setApplicationRestrictionsManagingPackage (ComponentName admin, 
                String packageName)

由配置文件所有者或设备所有者调用以授予包的权限,以通过 setApplicationRestrictions(ComponentName, String, Bundle)getApplicationRestrictions(ComponentName, String)管理主叫用户的应用程序限制。

此权限是持久性的,直到稍后通过调用具有 null值的此方法或卸载管理包来清除此权限。

调用此API时必须安装提供的应用程序限制管理包,否则将引发 PackageManager.NameNotFoundException

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

setAutoTimeRequired

Added in API level 21
void setAutoTimeRequired (ComponentName admin, 
                boolean required)

由设备所有者调用以设置是否需要自动时间。 如果需要自动时间,用户不能设置日期和时间,但必须使用网络日期和时间。

注意:如果需要自动时间,用户仍然可以手动设置时区。

主叫设备管理员必须是设备所有者。 如果不是,则会引发安全异常。

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.

setBluetoothContactSharingDisabled

Added in API level 23
void setBluetoothContactSharingDisabled (ComponentName admin, 
                boolean disabled)

由管理配置文件的配置文件所有者调用,以设置蓝牙设备是否可以访问企业联系人。

主叫设备管理员必须是个人资料所有者。 如果不是,则会引发安全异常。

该API仅适用于托管配置文件。

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.

setCameraDisabled

Added in API level 14
void setCameraDisabled (ComponentName admin, 
                boolean disabled)

由正在管理该设备的应用程序调用,以禁用该设备上的所有摄像头。 设置完成后,没有任何以该用户身份运行的应用程序将能够访问设备上的任何摄像头。

如果主叫方是设备所有者,则该限制将应用于所有用户。

主叫设备管理员必须要求USES_POLICY_DISABLE_CAMERA能够调用此方法; 如果没有,则会抛出安全异常。

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.

setCertInstallerPackage

Added in API level 23
void setCertInstallerPackage (ComponentName admin, 
                String installerPackage)

由配置文件所有者或设备所有者调用,以将对特权证书操作API的访问权限授予第三方证书安装程序应用程序。 诚然API包括getInstalledCaCerts(ComponentName)hasCaCertInstalled(ComponentName, byte[])installCaCert(ComponentName, byte[])uninstallCaCert(ComponentName, byte[])uninstallAllUserCaCerts(ComponentName)installKeyPair(ComponentName, PrivateKey, Certificate, String)

委派证书安装程序是按用户状态。 委托访问是持久性的,直到稍后通过使用空值调用此方法或卸载证书安装程序清除它。

注意:N开始,如果调用者应用程序的目标SDK版本是 N或更新,则在调用此API时必须安装提供的证书安装程序包,否则将引发 IllegalArgumentException

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.

setCrossProfileCallerIdDisabled

Added in API level 21
void setCrossProfileCallerIdDisabled (ComponentName admin, 
                boolean disabled)

由受管配置文件的配置文件所有者调用,以设置来自受管配置文件的来电者ID信息是否将显示在父配置文件中,用于传入呼叫。

主叫设备管理员必须是个人资料所有者。 如果不是,则会引发安全异常。

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.

setCrossProfileContactsSearchDisabled

Added in API level 24
void setCrossProfileContactsSearchDisabled (ComponentName admin, 
                boolean disabled)

由受管配置文件的配置文件所有者调用,以设置来自受管配置文件的联系人搜索是否将显示在父配置文件中,用于传入呼叫。

主叫设备管理员必须是个人资料所有者。 如果不是,则会引发安全异常。

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.

setDeviceOwnerLockScreenInfo

Added in API level 24
void setDeviceOwnerLockScreenInfo (ComponentName admin, 
                CharSequence info)

设置设备所有者信息以显示在锁定屏幕上。

如果设备所有者信息为 null或为空,则设备所有者信息将被清除,并且用户所有者信息会在锁定屏幕上显示(如果已设置)。

如果设备所有者信息仅包含空格,则锁定屏幕上的消息将为空,并且用户将不被允许更改它。

如果设备所有者信息需要本地化,则 DeviceAdminReceiver负责监听 ACTION_LOCALE_CHANGED广播并相应地设置此字符串的新版本。

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.

setGlobalSetting

Added in API level 21
void setGlobalSetting (ComponentName admin, 
                String setting, 
                String value)

由设备所有者调用以更新Settings.Global设置。 验证设置值的设置值是否正确,应由调用者执行。

可以使用此方法更新的设置是:

M更改以下设置 M

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.

setKeyguardDisabled

Added in API level 23
boolean setKeyguardDisabled (ComponentName admin, 
                boolean 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.

setKeyguardDisabledFeatures

Added in API level 17
void setKeyguardDisabledFeatures (ComponentName admin, 
                int which)

由正在管理设备的应用程序调用以禁用keyguard自定义,例如小部件。 设置完成后,根据提供的功能列表,Keyguard功能将被禁用。

主叫设备管理员必须要求USES_POLICY_DISABLE_KEYGUARD_FEATURES能够调用此方法; 如果没有,则会抛出安全异常。

在版本M之前从管理的配置文件调用此M将引发安全异常。 从版本M管理的配置文件的配置文件所有者可以设置:

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.

要求禁用托管配置文件中的其他功能将被忽略。

管理员可以通过调用 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

setLockTaskPackages

Added in API level 21
void setLockTaskPackages (ComponentName admin, 
                String[] packages)

设置哪些包可以进入锁定任务模式。

任何与uid共享包的软件包也将被允许激活锁定任务。 M从锁定任务包列表中删除包会导致属于这些包的锁定任务完成。 该功能只能由设备所有者调用。

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.

也可以看看:

setLongSupportMessage

Added in API level 24
void setLongSupportMessage (ComponentName admin, 
                CharSequence message)

由设备管理员调用以设置长支持消息。 这将在设备管理员设置屏幕中显示给用户。

如果需要对长期支持消息进行本地化,则 DeviceAdminReceiver负责监听 ACTION_LOCALE_CHANGED广播并相应地设置此字符串的新版本。

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.

也可以看看:

setMasterVolumeMuted

Added in API level 21
void setMasterVolumeMuted (ComponentName admin, 
                boolean on)

由配置文件或设备所有者调用以设置主音量静音的开启或关闭。

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.

setMaximumFailedPasswordsForWipe

Added in API level 8
void setMaximumFailedPasswordsForWipe (ComponentName admin, 
                int num)

将其设置为大于零的值将启用内置策略,该策略将在输入了太多不正确的设备解锁密码后执行设备或配置文件擦除。 该内置策略结合了查看失败的密码和擦除设备,并要求您同时请求USES_POLICY_WATCH_LOGINUSES_POLICY_WIPE_DATA }。

要实施任何其他策略(例如,仅擦除特定应用程序的数据,擦除或撤消证书或向服务器报告故障),应该实施onPasswordFailed(Context, android.content.Intent) 请勿使用此API,因为如果达到最大计数,设备或配置文件将立即被擦除,并且您的回调将不会被调用。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓的值。

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.

setMaximumTimeToLock

Added in API level 8
void setMaximumTimeToLock (ComponentName admin, 
                long timeMs)

由正在管理设备的应用程序调用,以设置用户活动的最长时间,直到设备锁定。 这限制了用户可以设置的长度。 它立即生效。

主叫设备管理员必须要求USES_POLICY_FORCE_LOCK能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setOrganizationColor

Added in API level 24
void setOrganizationColor (ComponentName admin, 
                int color)

由托管配置文件的配置文件所有者调用以设置用于自定义的颜色。 该颜色用作该用户的确认凭证屏幕的背景颜色。 默认颜色是蓝绿色(#00796B)。

确认凭证屏幕可以使用 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.

setOrganizationName

Added in API level 24
void setOrganizationName (ComponentName admin, 
                CharSequence title)

由托管配置文件的配置文件所有者调用以设置正在管理的组织的名称。

如果组织名称需要本地化,则 DeviceAdminReceiver负责监听 ACTION_LOCALE_CHANGED广播并相应地设置此字符串的新版本。

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.

setPackagesSuspended

Added in API level 24
String[] setPackagesSuspended (ComponentName admin, 
                String[] packageNames, 
                boolean suspended)

由设备或配置文件所有者调用以暂停此用户的包。

暂停的套餐将无法启动活动。 它的通知将被隐藏,它不会显示在最近的内容中,也不会显示吐司或对话框或者打开设备。

该软件包必须已安装。 如果程序包在挂起时被卸载,程序包将不再被挂起。 管理员可以通过使用setUninstallBlocked(ComponentName, String, boolean)来阻止此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.

setPasswordExpirationTimeout

Added in API level 11
void setPasswordExpirationTimeout (ComponentName admin, 
                long timeout)

由设备管理员调用以设置密码到期超时。 调用此方法将重新启动给定管理员的密码过期倒计时,同时将更改设备密码(对于所有管理员)。

提供的超时值是以毫秒为单位的时间增量,并将添加到当前时间。 例如,要从现在开始5天后密码过期,超时时间为5 * 86400 * 1000 = 432000000毫秒。

要禁用密码过期,可以使用值0来超时。

主叫设备管理员必须要求USES_POLICY_EXPIRE_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

请注意,设置密码将自动重置所有活动管理员的到期时间。 在这种情况下,主动管理员不需要显式调用此方法。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordHistoryLength

Added in API level 11
void setPasswordHistoryLength (ComponentName admin, 
                int length)

由正在管理设备的应用程序调用以设置密码历史记录的长度。 设置完成后,用户将无法输入与历史记录中任何密码相同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在设置此值后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD 这个约束只规定如果管理员还要求无论是PASSWORD_QUALITY_NUMERICPASSWORD_QUALITY_NUMERIC_COMPLEX PASSWORD_QUALITY_ALPHABETIC ,或PASSWORD_QUALITY_ALPHANUMERICsetPasswordQuality(ComponentName, int)

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordMinimumLength

Added in API level 8
void setPasswordMinimumLength (ComponentName admin, 
                int length)

由正在管理设备的应用程序调用以设置允许的最小密码长度。 设置完成后,用户将无法输入与已设置的限制不同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在设置此值后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD 如果管理员还要求这个约束只征收两种PASSWORD_QUALITY_NUMERICPASSWORD_QUALITY_NUMERIC_COMPLEXPASSWORD_QUALITY_ALPHABETICPASSWORD_QUALITY_ALPHANUMERIC ,或PASSWORD_QUALITY_COMPLEXsetPasswordQuality(ComponentName, int)

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordMinimumLetters

Added in API level 11
void setPasswordMinimumLetters (ComponentName admin, 
                int length)

由正在管理设备的应用程序调用以设置密码中所需的最少字母数。 设置完成后,用户将无法输入与已设置的限制不同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在设置此值后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD 只有在管理员还要求PASSWORD_QUALITY_COMPLEXsetPasswordQuality(ComponentName, int)才会施加此限制。 默认值是1。

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordMinimumLowerCase

Added in API level 11
void setPasswordMinimumLowerCase (ComponentName admin, 
                int length)

由正在管理设备的应用程序调用以设置密码中所需的最小数量的小写字母。 设置完成后,用户将无法输入与已设置的限制不同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在设置此值后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD 如果管理员还请求PASSWORD_QUALITY_COMPLEXsetPasswordQuality(ComponentName, int)则仅限此限制。 默认值是0。

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordMinimumNonLetter

Added in API level 11
void setPasswordMinimumNonLetter (ComponentName admin, 
                int length)

由正在管理设备的应用程序调用,以设置密码中所需的最小数量的非字母字符(数字或符号)。 设置完成后,用户将无法输入与已设置的限制不同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在设置此值后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD 如果管理员还请求PASSWORD_QUALITY_COMPLEXsetPasswordQuality(ComponentName, int)则仅限此限制。 默认值是0。

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordMinimumNumeric

Added in API level 11
void setPasswordMinimumNumeric (ComponentName admin, 
                int length)

由正在管理设备的应用程序调用以设置密码中所需的最小数字位数。 设置完成后,用户将无法输入与已设置的限制不同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在设置此值后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD 如果管理员还要求PASSWORD_QUALITY_COMPLEXsetPasswordQuality(ComponentName, int)则仅限此限制。 默认值是1。

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordMinimumSymbols

Added in API level 11
void setPasswordMinimumSymbols (ComponentName admin, 
                int length)

由正在管理设备的应用程序调用以设置密码中所需的最小符号数。 设置完成后,用户将无法输入与已设置的限制不同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在设置此值后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD 只有在管理员还要求PASSWORD_QUALITY_COMPLEXsetPasswordQuality(ComponentName, int)才会强制实施此限制。 默认值是1。

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordMinimumUpperCase

Added in API level 11
void setPasswordMinimumUpperCase (ComponentName admin, 
                int length)

由正在管理设备的应用程序调用,以设置密码中所需的最小大写字母数。 设置完成后,用户将无法输入与已设置的限制不同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在设置此值后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD 只有在管理员还要求PASSWORD_QUALITY_COMPLEXsetPasswordQuality(ComponentName, int)才会强制实施此限制。 默认值是0。

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPasswordQuality

Added in API level 8
void setPasswordQuality (ComponentName admin, 
                int quality)

由正在管理设备的应用程序调用以设置它正在施加的密码限制。 设置完成后,用户将无法输入与已设置的限制不同的新密码。 请注意,当前密码将保留到用户设置新密码为止,因此更改不会立即生效。 要提示用户输入新密码, ACTION_SET_NEW_PARENT_PROFILE_PASSWORD在调用此方法后使用ACTION_SET_NEW_PASSWORDACTION_SET_NEW_PARENT_PROFILE_PASSWORD

质量常数是有序的,以便更高的值更具限制性; 因此要求的最高质量常数(在此设置的策略,用户的偏好以及任何其他考虑因素之间)是有效的。

主叫设备管理员必须要求USES_POLICY_LIMIT_PASSWORD能够调用此方法; 如果没有,则会抛出安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父轮廓限制。

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

setPermissionGrantState

Added in API level 23
boolean setPermissionGrantState (ComponentName admin, 
                String packageName, 
                String permission, 
                int grantState)

为特定应用程序设置运行时权限的授予状态。 状态可以是default ,其中用户可以通过界面denied (其中权限被拒绝并且用户无法通过UI进行管理)和granted (其中授予权限并且用户无法通过UI。 这可能会影响运行时权限所属的组中的所有权限。 此方法只能由配置文件或设备所有者调用。

Setting the grant state to 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.

也可以看看:

setPermissionPolicy

Added in API level 23
void setPermissionPolicy (ComponentName admin, 
                int policy)

由配置文件或设备所有者调用以设置应用程序未来运行时权限请求的默认响应。 该策略可以允许正常操作,该操作提示用户授予权限,或者允许应用程序自动授予或拒绝运行时权限请求。 这也适用于由应用更新声明的新权限。 当以这种方式拒绝或授予权限时,效果等同于通过setPermissionGrantState(ComponentName, String, String, int)设置权限授予状态。

As this policy only acts on runtime permission requests, it only applies to applications built with a 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.

也可以看看:

setPermittedAccessibilityServices

Added in API level 21
boolean setPermittedAccessibilityServices (ComponentName admin, 
                List<String> packageNames)

由配置文件或设备所有者调用以设置允许的无障碍服务。 当由设备所有者或配置文件所有者设置时,限制适用于设备所有者或配置文件所有者是管理员的用户的所有配置文件。 默认情况下,用户可以使用任何可访问性服务。 当添加零个或多个软件包时,用户无法启用不在列表中但不属于系统一部分的可访问性服务。

使用列表的空值调用将禁用限制,以便可以使用所有服务,使用空列表进行调用只允许内置系统的服务。

系统可访问性服务始终对用户可用,列表无法修改此项。

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.

setPermittedInputMethods

Added in API level 21
boolean setPermittedInputMethods (ComponentName admin, 
                List<String> packageNames)

由配置文件或设备所有者调用以设置允许的输入法服务。 当由设备所有者或配置文件所有者设置时,限制适用于设备所有者或配置文件所有者是管理员的用户的所有配置文件。 默认情况下,用户可以使用任何输入法。 当添加零个或多个软件包时,用户无法启用不在列表中而不在系统中的输入法。 如果调用的管理员不是前台用户或前台用户的配置文件,则此方法将失败。

使用列表的空值调用将禁用限制,以便可以使用所有输入方法,使用空列表调用将禁用除系统自己的输入方法以外的所有输入方法。

系统输入法始终可供用户使用,此方法无法修改此操作。

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.

setProfileEnabled

Added in API level 21
void setProfileEnabled (ComponentName admin)

设置配置文件的启用状态。 配置文件只有在准备好使用后才能启用。 只有配置文件所有者可以调用此。

Parameters
admin ComponentName: Which DeviceAdminReceiver this request is associated with.
Throws
SecurityException if admin is not a profile owner.

也可以看看:

setProfileName

Added in API level 21
void setProfileName (ComponentName admin, 
                String profileName)

设置配置文件的名称。 在设备所有者的情况下,它设置从中调用的用户的名称。 只有个人资料所有者或设备所有者可以调用此设置 如果配置文件或设备所有者永远不会调用此名称,则该名称将被设置为默认值。

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.

也可以看看:

setRecommendedGlobalProxy

Added in API level 21
void setRecommendedGlobalProxy (ComponentName admin, 
                ProxyInfo proxyInfo)

设置独立于网络的全局HTTP代理。 这通常不是您想要的典型HTTP代理 - 它们通常取决于网络。 但是,如果你正在做一些不寻常的事情,如一般的内部过滤,这可能是有用 在代理服务器无法访问的专用网络上,您可能会使用它来破坏HTTP。

此方法要求主叫方是设备所有者。

这个代理只是一个建议,有些应用程序可能会忽略它。

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.

也可以看看:

setRestrictionsProvider

Added in API level 21
void setRestrictionsProvider (ComponentName admin, 
                ComponentName provider)

指定一个特定的服务组件作为用户的本地或远程管理员的权限请求的提供者。

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.

setScreenCaptureDisabled

Added in API level 21
void setScreenCaptureDisabled (ComponentName admin, 
                boolean disabled)

由设备/配置文件所有者调用以设置是否禁用屏幕捕获。 禁用屏幕捕获还会阻止在没有安全视频输出的显示设备上显示内容。 有关安全表面和安全显示的更多详细信息,请参阅FLAG_SECURE

主叫设备管理员必须是设备或配置文件所有者。 如果不是,则会引发安全异常。

从版本 M禁用屏幕捕获还会阻止相关用户的所有活动的协助请求。

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.

setSecureSetting

Added in API level 21
void setSecureSetting (ComponentName admin, 
                String setting, 
                String value)

由配置文件或设备所有者调用以更新Settings.Secure设置。 验证设置值的设置值是否正确,应由调用者执行。

配置文件或设备所有者可以使用此方法更新的设置是:

设备所有者可以另外更新以下设置:

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.

setSecurityLoggingEnabled

Added in API level 24
void setSecurityLoggingEnabled (ComponentName admin, 
                boolean enabled)

由设备所有者调用以控制安全日志记录功能。 日志只能在设备所有者管理唯一用户的单个用户设备上启用。

安全日志包含用于安全审计目的的各种信息。 详情请参阅SecurityLog.SecurityEvent

设备所有者只能管理一位用户。 否则会抛出SecurityException

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.

也可以看看:

setShortSupportMessage

Added in API level 24
void setShortSupportMessage (ComponentName admin, 
                CharSequence message)

由设备管理员调用以设置短支持消息。 这将在管理员禁用功能的设置屏幕中显示给用户。 该信息应限于简短的陈述,例如“此设置已被管理员禁用,请联系someone@example.com以获得支持。” 如果邮件超过200个字符,则可能会被截断。

如果短支持消息需要本地化,则 DeviceAdminReceiver负责监听 ACTION_LOCALE_CHANGED广播并相应地设置该字符串的新版本。

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.

也可以看看:

setStatusBarDisabled

Added in API level 23
boolean setStatusBarDisabled (ComponentName admin, 
                boolean disabled)

由设备所有者调用以禁用状态栏。 禁用状态栏会阻止通知,快速设置和其他屏幕覆盖图,以允许从单一使用设备转义。

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.

setStorageEncryption

Added in API level 11
int setStorageEncryption (ComponentName admin, 
                boolean encrypt)

由正在管理设备的应用程序调用以请求对存储系统进行加密。

当多个设备管理员试图控制设备加密时,将始终使用最安全,受支持的设置。 如果任何设备管理员请求设备加密,它将被启用; 相反,如果设备管理员尝试禁用设备加密,而其他设备管理员启用了该设备,则禁用的呼叫将失败(通常返回ENCRYPTION_STATUS_ACTIVE )。

此策略控制安全(应用程序数据)存储区域的加密。 写入其他存储区域的数据可能会或可能不会被加密,并且此策略不要求或控制任何其他存储区域的加密。 有一个例外:如果isExternalStorageEmulated()true ,则必须将getExternalStorageDirectory()返回的目录写入加密存储区域内的磁盘。

重要说明:在某些设备上,可以在不需要用户创建设备PIN或密码的情况下对存储进行加密。 在这种情况下,存储是加密的,但加密密钥可能不完全安全。 为了最大限度地提高安全性,管理员还应该要求(并检查)模式,PIN或密码。

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

setSystemUpdatePolicy

Added in API level 23
void setSystemUpdatePolicy (ComponentName admin, 
                SystemUpdatePolicy policy)

由设备所有者调用以设置本地系统更新策略。 当设置新政策时,广播ACTION_SYSTEM_UPDATE_POLICY_CHANGED

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.

也可以看看:

setTrustAgentConfiguration

Added in API level 23
void setTrustAgentConfiguration (ComponentName admin, 
                ComponentName target, 
                PersistableBundle configuration)

设置为TrustAgent组件启用的配置功能列表。 这意味着要与KEYGUARD_DISABLE_TRUST_AGENTS一起使用,它会禁用所有信任代理,但会禁用此函数调用所启用的那些代理。 如果未设置标志KEYGUARD_DISABLE_TRUST_AGENTS ,则此调用不起作用。

主叫设备管理员必须要求USES_POLICY_DISABLE_KEYGUARD_FEATURES能够调用此方法; 如果不是,则会引发安全异常。

这种方法可以在被称为 DevicePolicyManager通过返回的实例 getParentProfileInstance(ComponentName) ,以便设置父配置文件中的配置。

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.

如果设置了 KEYGUARD_DISABLE_TRUST_AGENTS且所有管理员的选项不为空,则由TrustAgent本身负责汇总所有设备管理员的值。

请咨询特定TrustAgent的文档以确定合法选项参数。

Throws
SecurityException if admin is not an active administrator or does not use USES_POLICY_DISABLE_KEYGUARD_FEATURES

setUninstallBlocked

Added in API level 21
void setUninstallBlocked (ComponentName admin, 
                String packageName, 
                boolean uninstallBlocked)

由配置文件或设备所有者调用以更改用户是否可以卸载软件包。

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.

setUserIcon

Added in API level 23
void setUserIcon (ComponentName admin, 
                Bitmap icon)

由个人资料或设备所有者调用以设置用户的照片。

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.

switchUser

Added in API level 21
boolean switchUser (ComponentName admin, 
                UserHandle userHandle)

由设备所有者调用以将指定的用户切换到前景。

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.

也可以看看:

uninstallAllUserCaCerts

Added in API level 21
void uninstallAllUserCaCerts (ComponentName admin)

从配置文件中卸载所有自定义的可信CA证书。 通过设备策略以外的方式安装的证书也将被删除,但系统CA证书除外。

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.

uninstallCaCert

Added in API level 21
void uninstallCaCert (ComponentName admin, 
                byte[] certBuffer)

如果存在,请从受信任的用户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 remove.
Throws
SecurityException if admin is not null and not a device or profile owner.

wipeData

Added in API level 8
void wipeData (int flags)

要求擦除用户数据。 擦除主要用户将导致设备重新启动,在下次启动时擦除所有用户数据。

主叫设备管理员必须要求USES_POLICY_WIPE_DATA能够调用此方法; 如果没有,则会抛出安全异常。

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

Hooray!