@Implements(value=android.app.admin.DevicePolicyManager.class) public class ShadowDevicePolicyManager extends Object
Constructor and Description |
---|
ShadowDevicePolicyManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
__constructor__(Context context,
boolean parentInstance) |
protected void |
__constructor__(Context context,
Handler handler) |
protected void |
__constructor__(Context context,
IDevicePolicyManager service) |
boolean |
activateResetToken(ComponentName admin)
Activates reset token for given admin.
|
protected void |
addPersistentPreferredActivity(ComponentName admin,
IntentFilter filter,
ComponentName activity) |
protected void |
addUserRestriction(ComponentName admin,
String key) |
protected void |
clearPackagePersistentPreferredActivities(ComponentName admin,
String packageName) |
protected void |
clearProfileOwner(ComponentName admin) |
protected void |
clearUserRestriction(ComponentName admin,
String key) |
protected void |
enableSystemApp(ComponentName admin,
String packageName) |
void |
failSetApplicationHiddenFor(Collection<String> packagesToFail)
Set package names for witch
DevicePolicyManager.setApplicationHidden(android.content.ComponentName, java.lang.String, boolean) should fail. |
protected String[] |
getAccountTypesWithManagementDisabled() |
protected List<ComponentName> |
getActiveAdmins() |
protected Bundle |
getApplicationRestrictions(ComponentName admin,
String packageName) |
Bundle |
getApplicationRestrictions(String packageName)
Returns all application restrictions of the
packageName in a Bundle . |
protected boolean |
getAutoTimeRequired() |
protected boolean |
getCameraDisabled(ComponentName admin) |
protected String |
getDeviceOwner() |
protected int |
getKeyguardDisabledFeatures(ComponentName admin) |
String |
getLastSetPassword()
Retrieves last password set through
DevicePolicyManager.resetPassword(java.lang.String, int) or DevicePolicyManager.resetPasswordWithToken(android.content.ComponentName, java.lang.String, byte[], int) . |
protected int |
getMaximumFailedPasswordsForWipe(ComponentName admin) |
protected long |
getMaximumTimeToLock(ComponentName admin) |
protected int |
getOrganizationColor(ComponentName admin) |
protected CharSequence |
getOrganizationName(ComponentName admin)
Returns organization name.
|
protected long |
getPasswordExpiration(ComponentName admin) |
protected long |
getPasswordExpirationTimeout(ComponentName admin) |
protected int |
getPasswordHistoryLength(ComponentName admin) |
protected int |
getPasswordMinimumLength(ComponentName admin) |
protected int |
getPasswordMinimumLetters(ComponentName admin) |
protected int |
getPasswordMinimumLowerCase(ComponentName admin) |
protected int |
getPasswordMinimumNonLetter(ComponentName admin) |
protected int |
getPasswordMinimumNumeric(ComponentName admin) |
protected int |
getPasswordMinimumSymbols(ComponentName admin) |
protected int |
getPasswordMinimumUpperCase(ComponentName admin) |
protected int |
getPasswordQuality(ComponentName admin) |
protected int |
getPermissionGrantState(ComponentName admin,
String packageName,
String permission) |
protected List<String> |
getPermittedAccessibilityServices(ComponentName admin) |
protected List<String> |
getPermittedInputMethods(ComponentName admin) |
protected ComponentName |
getProfileOwner() |
protected String |
getProfileOwnerNameAsUser(int userId)
Returns the human-readable name of the profile owner for a user if set using
setProfileOwnerName(int, java.lang.String) , otherwise null . |
protected boolean |
getStorageEncryption(ComponentName admin) |
protected int |
getStorageEncryptionStatus() |
protected int |
getUserProvisioningState() |
long |
getWipeCalledTimes() |
void |
grantPolicy(ComponentName admin,
int usesPolicy)
Grants a particular device policy for an active ComponentName.
|
protected boolean |
hasGrantedPolicy(ComponentName admin,
int usesPolicy) |
protected boolean |
isActivePasswordSufficient() |
protected boolean |
isAdminActive(ComponentName who) |
protected boolean |
isApplicationHidden(ComponentName admin,
String packageName) |
boolean |
isDeviceManaged() |
protected boolean |
isDeviceOwnerApp(String packageName) |
protected boolean |
isPackageSuspended(ComponentName admin,
String packageName) |
boolean |
isPermissionGranted(String packageName,
String permission) |
protected boolean |
isProfileOwnerApp(String packageName) |
protected boolean |
isResetPasswordTokenActive(ComponentName admin) |
protected boolean |
isUninstallBlocked(ComponentName admin,
String packageName) |
protected void |
lockNow() |
protected void |
removeActiveAdmin(ComponentName admin) |
protected boolean |
resetPassword(String password,
int flags) |
protected boolean |
resetPasswordWithToken(ComponentName admin,
String password,
byte[] token,
int flags) |
protected void |
setAccountManagementDisabled(ComponentName admin,
String accountType,
boolean disabled) |
void |
setActiveAdmin(ComponentName componentName)
Sets the given
componentName as one of the active admins. |
void |
setActivePasswordSufficient(boolean sufficient)
Sets if the password meets the current requirements.
|
protected boolean |
setApplicationHidden(ComponentName admin,
String packageName,
boolean hidden) |
protected void |
setApplicationRestrictions(ComponentName admin,
String packageName,
Bundle applicationRestrictions) |
void |
setApplicationRestrictions(String packageName,
Bundle applicationRestrictions)
Sets the application restrictions of the
packageName . |
protected void |
setAutoTimeRequired(ComponentName admin,
boolean required) |
protected void |
setCameraDisabled(ComponentName admin,
boolean disabled) |
void |
setDeviceOwner(ComponentName admin)
Sets the admin as active admin and device owner.
|
protected void |
setKeyguardDisabledFeatures(ComponentName admin,
int which) |
protected void |
setMaximumFailedPasswordsForWipe(ComponentName admin,
int num) |
protected void |
setMaximumTimeToLock(ComponentName admin,
long timeMs) |
protected void |
setOrganizationColor(ComponentName admin,
int color) |
protected void |
setOrganizationName(ComponentName admin,
CharSequence name)
Sets organization name.
|
protected String[] |
setPackagesSuspended(ComponentName admin,
String[] packageNames,
boolean suspended) |
void |
setPasswordExpiration(ComponentName admin,
long timeout)
Sets the password expiration time for a particular admin.
|
protected void |
setPasswordExpirationTimeout(ComponentName admin,
long timeout) |
protected void |
setPasswordHistoryLength(ComponentName admin,
int length) |
protected void |
setPasswordMinimumLength(ComponentName admin,
int length) |
protected void |
setPasswordMinimumLetters(ComponentName admin,
int length) |
protected void |
setPasswordMinimumLowerCase(ComponentName admin,
int length) |
protected void |
setPasswordMinimumNonLetter(ComponentName admin,
int length) |
protected void |
setPasswordMinimumNumeric(ComponentName admin,
int length) |
protected void |
setPasswordMinimumSymbols(ComponentName admin,
int length) |
protected void |
setPasswordMinimumUpperCase(ComponentName admin,
int length) |
protected void |
setPasswordQuality(ComponentName admin,
int quality) |
protected boolean |
setPermissionGrantState(ComponentName admin,
String packageName,
String permission,
int grantState) |
protected boolean |
setPermittedAccessibilityServices(ComponentName admin,
List<String> packageNames)
Sets permitted accessibility services.
|
protected boolean |
setPermittedInputMethods(ComponentName admin,
List<String> packageNames)
Sets permitted input methods.
|
void |
setProfileOwner(ComponentName admin)
Sets the admin as active admin and profile owner.
|
void |
setProfileOwnerName(int userId,
String name) |
protected boolean |
setResetPasswordToken(ComponentName admin,
byte[] token) |
protected int |
setStorageEncryption(ComponentName admin,
boolean encrypt) |
void |
setStorageEncryptionStatus(int status)
Setter for
DevicePolicyManager.getStorageEncryptionStatus() . |
protected void |
setUninstallBlocked(ComponentName admin,
String packageName,
boolean uninstallBlocked) |
void |
setUserProvisioningState(int state)
Sets the user provisioning state.
|
boolean |
wasPackageEverHidden(String packageName)
Returns
true if the given packageName was ever hidden. |
boolean |
wasSystemAppEnabled(String packageName)
Returns
true if the given packageName was a system app and was enabled. |
protected void |
wipeData(int flags) |
@Implementation(maxSdk=23) protected void __constructor__(Context context, Handler handler)
@Implementation(minSdk=24, maxSdk=25) protected void __constructor__(Context context, boolean parentInstance)
@Implementation(minSdk=26) protected void __constructor__(Context context, IDevicePolicyManager service)
@Implementation(minSdk=18) protected boolean isDeviceOwnerApp(String packageName)
@Implementation(minSdk=21) protected boolean isProfileOwnerApp(String packageName)
@Implementation protected boolean isAdminActive(ComponentName who)
@Implementation protected List<ComponentName> getActiveAdmins()
@Implementation(minSdk=21) protected void addUserRestriction(ComponentName admin, String key)
@Implementation(minSdk=21) protected void clearUserRestriction(ComponentName admin, String key)
@Implementation(minSdk=21) protected boolean setApplicationHidden(ComponentName admin, String packageName, boolean hidden)
public void failSetApplicationHiddenFor(Collection<String> packagesToFail)
Set package names for witch DevicePolicyManager.setApplicationHidden(android.content.ComponentName, java.lang.String, boolean)
should fail.
packagesToFail
- collection of package names or null
to clear the packages.@Implementation(minSdk=21) protected boolean isApplicationHidden(ComponentName admin, String packageName)
public boolean wasPackageEverHidden(String packageName)
Returns true
if the given packageName
was ever hidden.
@Implementation(minSdk=21) protected void enableSystemApp(ComponentName admin, String packageName)
public boolean wasSystemAppEnabled(String packageName)
Returns true
if the given packageName
was a system app and was enabled.
@Implementation(minSdk=21) protected void setUninstallBlocked(ComponentName admin, String packageName, boolean uninstallBlocked)
@Implementation(minSdk=21) protected boolean isUninstallBlocked(ComponentName admin, String packageName)
@Implementation(minSdk=18) protected String getDeviceOwner()
setDeviceOwner(ComponentName)
@Implementation(minSdk=24) public boolean isDeviceManaged()
setDeviceOwner(ComponentName)
@Implementation(minSdk=21) protected ComponentName getProfileOwner()
setProfileOwner(ComponentName)
@Implementation(minSdk=21) protected String getProfileOwnerNameAsUser(int userId)
Returns the human-readable name of the profile owner for a user if set using setProfileOwnerName(int, java.lang.String)
, otherwise null
.
public void setDeviceOwner(ComponentName admin)
Sets the admin as active admin and device owner.
DevicePolicyManager.getDeviceOwner()
public void setProfileOwner(ComponentName admin)
Sets the admin as active admin and profile owner.
DevicePolicyManager.getProfileOwner()
public void setProfileOwnerName(int userId, String name)
public void setActiveAdmin(ComponentName componentName)
Sets the given componentName
as one of the active admins.
@Implementation protected void removeActiveAdmin(ComponentName admin)
@Implementation(minSdk=21) protected void clearProfileOwner(ComponentName admin)
@Implementation(minSdk=21) protected Bundle getApplicationRestrictions(ComponentName admin, String packageName)
public Bundle getApplicationRestrictions(String packageName)
Returns all application restrictions of the packageName
in a Bundle
.
@Implementation(minSdk=21) protected void setApplicationRestrictions(ComponentName admin, String packageName, Bundle applicationRestrictions)
public void setApplicationRestrictions(String packageName, Bundle applicationRestrictions)
Sets the application restrictions of the packageName
.
The new applicationRestrictions
always completely overwrites any existing ones.
@Implementation(minSdk=21) protected void setAccountManagementDisabled(ComponentName admin, String accountType, boolean disabled)
@Implementation(minSdk=21) protected String[] getAccountTypesWithManagementDisabled()
@Implementation(minSdk=24) protected void setOrganizationName(ComponentName admin, CharSequence name)
Sets organization name.
The API can only be called by profile owner since Android N and can be called by both of profile owner and device owner since Android O.
@Implementation(minSdk=24) protected String[] setPackagesSuspended(ComponentName admin, String[] packageNames, boolean suspended)
@Implementation(minSdk=24) protected boolean isPackageSuspended(ComponentName admin, String packageName) throws PackageManager.NameNotFoundException
@Implementation(minSdk=24) protected void setOrganizationColor(ComponentName admin, int color)
@Implementation(minSdk=24) protected CharSequence getOrganizationName(ComponentName admin)
Returns organization name.
The API can only be called by profile owner since Android N.
Android framework has a hidden API for getting the organization name for device owner since Android O. This method, however, is extended to return the organization name for device owners too to make testing of setOrganizationName(ComponentName, CharSequence)
easier for device owner cases.
@Implementation(minSdk=24) protected int getOrganizationColor(ComponentName admin)
@Implementation(minSdk=21) protected void setAutoTimeRequired(ComponentName admin, boolean required)
@Implementation(minSdk=21) protected boolean getAutoTimeRequired()
@Implementation(minSdk=21) protected boolean setPermittedAccessibilityServices(ComponentName admin, List<String> packageNames)
Sets permitted accessibility services.
The API can be called by either a profile or device owner.
This method does not check already enabled non-system accessibility services, so will always set the restriction and return true.
@Implementation(minSdk=21) protected List<String> getPermittedAccessibilityServices(ComponentName admin)
@Implementation(minSdk=21) protected boolean setPermittedInputMethods(ComponentName admin, List<String> packageNames)
Sets permitted input methods.
The API can be called by either a profile or device owner.
This method does not check already enabled non-system input methods, so will always set the restriction and return true.
@Implementation(minSdk=21) protected List<String> getPermittedInputMethods(ComponentName admin)
@Implementation protected int getStorageEncryptionStatus()
DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED
setStorageEncryptionStatus(int)
public void setStorageEncryptionStatus(int status)
Setter for DevicePolicyManager.getStorageEncryptionStatus()
.
@Implementation protected int setStorageEncryption(ComponentName admin, boolean encrypt)
@Implementation protected boolean getStorageEncryption(ComponentName admin)
@Implementation(minSdk=23) protected int getPermissionGrantState(ComponentName admin, String packageName, String permission)
@Implementation(minSdk=23) protected boolean setPermissionGrantState(ComponentName admin, String packageName, String permission, int grantState)
@Implementation protected void lockNow()
@Implementation protected void wipeData(int flags)
public long getWipeCalledTimes()
@Implementation protected void setPasswordQuality(ComponentName admin, int quality)
@Implementation protected int getPasswordQuality(ComponentName admin)
@Implementation protected boolean resetPassword(String password, int flags)
@Implementation(minSdk=26) protected boolean resetPasswordWithToken(ComponentName admin, String password, byte[] token, int flags)
@Implementation(minSdk=26) protected boolean isResetPasswordTokenActive(ComponentName admin)
@Implementation(minSdk=26) protected boolean setResetPasswordToken(ComponentName admin, byte[] token)
@Implementation protected void setPasswordMinimumLength(ComponentName admin, int length)
@Implementation protected int getPasswordMinimumLength(ComponentName admin)
@Implementation protected void setPasswordMinimumLetters(ComponentName admin, int length)
@Implementation protected int getPasswordMinimumLetters(ComponentName admin)
@Implementation protected void setPasswordMinimumLowerCase(ComponentName admin, int length)
@Implementation protected int getPasswordMinimumLowerCase(ComponentName admin)
@Implementation protected void setPasswordMinimumUpperCase(ComponentName admin, int length)
@Implementation protected int getPasswordMinimumUpperCase(ComponentName admin)
@Implementation protected void setPasswordMinimumNonLetter(ComponentName admin, int length)
@Implementation protected int getPasswordMinimumNonLetter(ComponentName admin)
@Implementation protected void setPasswordMinimumNumeric(ComponentName admin, int length)
@Implementation protected int getPasswordMinimumNumeric(ComponentName admin)
@Implementation protected void setPasswordMinimumSymbols(ComponentName admin, int length)
@Implementation protected int getPasswordMinimumSymbols(ComponentName admin)
@Implementation protected void setMaximumFailedPasswordsForWipe(ComponentName admin, int num)
@Implementation protected int getMaximumFailedPasswordsForWipe(ComponentName admin)
@Implementation protected void setCameraDisabled(ComponentName admin, boolean disabled)
@Implementation protected boolean getCameraDisabled(ComponentName admin)
@Implementation protected void setPasswordExpirationTimeout(ComponentName admin, long timeout)
@Implementation protected long getPasswordExpirationTimeout(ComponentName admin)
public void setPasswordExpiration(ComponentName admin, long timeout)
Sets the password expiration time for a particular admin.
admin
- which DeviceAdminReceiver this request is associated with.timeout
- the password expiration time, in milliseconds since epoch.@Implementation protected long getPasswordExpiration(ComponentName admin)
@Implementation protected void setMaximumTimeToLock(ComponentName admin, long timeMs)
@Implementation protected long getMaximumTimeToLock(ComponentName admin)
@Implementation protected void setPasswordHistoryLength(ComponentName admin, int length)
@Implementation protected int getPasswordHistoryLength(ComponentName admin)
public void setActivePasswordSufficient(boolean sufficient)
Sets if the password meets the current requirements.
sufficient
- indicates the password meets the current requirements@Implementation protected boolean isActivePasswordSufficient()
public String getLastSetPassword()
Retrieves last password set through DevicePolicyManager.resetPassword(java.lang.String, int)
or DevicePolicyManager.resetPasswordWithToken(android.content.ComponentName, java.lang.String, byte[], int)
.
public boolean activateResetToken(ComponentName admin)
Activates reset token for given admin.
admin
- Which DeviceAdminReceiver
this request is associated with.IllegalArgumentException
- if there is no token set for this admin.@Implementation(minSdk=21) protected void addPersistentPreferredActivity(ComponentName admin, IntentFilter filter, ComponentName activity)
@Implementation(minSdk=21) protected void clearPackagePersistentPreferredActivities(ComponentName admin, String packageName)
@Implementation(minSdk=17) protected void setKeyguardDisabledFeatures(ComponentName admin, int which)
@Implementation(minSdk=17) protected int getKeyguardDisabledFeatures(ComponentName admin)
public void setUserProvisioningState(int state)
Sets the user provisioning state.
state
- to store provisioning state@Implementation(minSdk=24) protected int getUserProvisioningState()
@Implementation protected boolean hasGrantedPolicy(ComponentName admin, int usesPolicy)
public void grantPolicy(ComponentName admin, int usesPolicy)
Grants a particular device policy for an active ComponentName.
admin
- the ComponentName which DeviceAdminReceiver this request is associated with. Must be an active administrator, or an exception will be thrown. This value must never be null.usesPolicy
- the uses-policy to check