com.ardic.android.managers.afexadmin.IAfexAdminManager |
Provides a set of APIs for self activated AFEX device admin. All device administration operations provided by AFEX admin manager.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns activated device admin
ComponentName to be used for getting admin
configurations. | |||||||||||
Returns the active password quality.
| |||||||||||
Returns the lock view message icon.
| |||||||||||
Returns the lock view message text.
| |||||||||||
Returns the maximum letter sequence length allowed in the device password.
| |||||||||||
Returns the maximum numeric sequence length allowed in the device password.
| |||||||||||
Returns the maximum symbol sequence length allowed in the device password.
| |||||||||||
Returns a pattern for password match.
| |||||||||||
Determine whether the current password the user has set is sufficient to meet the policy
requirements (quality, minimum length) that have been requested.
| |||||||||||
Returns camera disabled state.
| |||||||||||
Returns lock screen status.
| |||||||||||
Returns password change enforced state.
| |||||||||||
Make the device lock immediately, as if the lock screen timeout has expired at the point of
this call.
| |||||||||||
Force a new device unlock password (the password needed to access the entire device, not for
individual accounts) on the user.
| |||||||||||
Called by an application that is administering the device to disable all cameras on the
device.
| |||||||||||
Sets the lock view message icon by the given bitmap icon.
| |||||||||||
Sets the lock view message text by the given text.
| |||||||||||
Setting this to a value greater than zero enables a built-in policy that will perform a
device wipe after too many incorrect device-unlock passwords have been entered.
| |||||||||||
Called by an application that is administering the device to set the maximum time for user
activity until the device will lock.
| |||||||||||
Sets password change state enforced.
| |||||||||||
Called by a device admin to set the password expiration timeout.
| |||||||||||
Called by an application that is administering the device to set the length of the password
history.
| |||||||||||
Sets the maximum letter sequence length allowed in the device.
| |||||||||||
Sets the maximum numeric sequence length allowed in the device.
| |||||||||||
Sets the maximum symbol sequence length allowed in the device.
| |||||||||||
Called by an application that is administering the device to set the minimum allowed password
length.
| |||||||||||
Called by an application that is administering the device to set the minimum number of
letters required in the password.
| |||||||||||
Called by an application that is administering the device to set the minimum number of lower
case letters required in the password.
| |||||||||||
Called by an application that is administering the device to set the minimum number of
non-letter characters (numerical digits or symbols) required in the password.
| |||||||||||
Called by an application that is administering the device to set the minimum number of
numerical digits required in the password.
| |||||||||||
Called by an application that is administering the device to set the minimum number of
symbols required in the password.
| |||||||||||
Called by an application that is administering the device to set the minimum number of upper
case letters required in the password.
| |||||||||||
Called by an application that is administering the device to set the password restrictions it
is imposing.
| |||||||||||
Sets a pattern for password match.
| |||||||||||
Called by an application that is administering the device to request that the storage system
be encrypted.
| |||||||||||
Starts by an application that is administering the device to request that the storage system
encryption to be started.
| |||||||||||
Validates password if password pattern is set.
| |||||||||||
Validates password if password sequence length is set.
| |||||||||||
Ask the user data be wiped.
|
Returns activated device admin ComponentName
to be used for getting admin
configurations.
Returns | |
---|---|
ComponentName |
Device admin ComponentName |
Throws | |
---|---|
AfexException |
Returns the active password quality.
Password quality can be:
PASSWORD_QUALITY_ALPHABETIC
PASSWORD_QUALITY_ALPHANUMERIC
PASSWORD_QUALITY_BIOMETRIC_WEAK
PASSWORD_QUALITY_COMPLEX
PASSWORD_QUALITY_NUMERIC
PASSWORD_QUALITY_SOMETHING
PASSWORD_QUALITY_UNSPECIFIED
Returns | |
---|---|
int |
Password quality. |
Throws | |
---|---|
AfexException |
Returns the lock view message icon.
Returns | |
---|---|
Bitmap |
Bitmap if lock icon exist else null |
Throws | |
---|---|
AfexException |
Returns the lock view message text.
Returns | |
---|---|
String |
String if lock message exist else null |
Throws | |
---|---|
AfexException |
Returns the maximum letter sequence length allowed in the device password.
Returns | |
---|---|
int |
The maximum allowed letter sequence length. A value of '0' specifies that no such letter sequence restrictions are applied. |
Throws | |
---|---|
AfexException |
Returns the maximum numeric sequence length allowed in the device password.
Returns | |
---|---|
int |
The maximum allowed numeric sequence length. A value of '0' specifies that no such numeric sequence restrictions are applied. |
Throws | |
---|---|
AfexException |
Returns the maximum symbol sequence length allowed in the device password.
Returns | |
---|---|
int |
The maximum allowed symbol sequence length. A value of '0' specifies that no such symbol sequence restrictions are applied. |
Throws | |
---|---|
AfexException |
Returns a pattern for password match.
Returns | |
---|---|
String |
Regex pattern. |
Throws | |
---|---|
|
AfexException |
AfexException |
See also:
Determine whether the current password the user has set is sufficient to meet the policy requirements (quality, minimum length) that have been requested.
Returns | |
---|---|
boolean |
true if the password meets the current requirements else false |
Throws | |
---|---|
AfexException |
Returns camera disabled state.
Returns | |
---|---|
boolean |
true if camera disabled else false |
Throws | |
---|---|
AfexException |
Returns lock screen status. Warning; If screenlock set to none, this api always returns false.
Returns | |
---|---|
boolean |
true if lock screen is locked state else false |
Throws | |
---|---|
AfexException |
Returns password change enforced state.
Returns | |
---|---|
boolean |
true if password change is enforced state else false |
Throws | |
---|---|
AfexException |
Make the device lock immediately, as if the lock screen timeout has expired at the point of this call.
Throws | |
---|---|
AfexException |
Force a new device unlock password (the password needed to access the entire device, not for individual accounts) on the user. This takes effect immediately.
The given password must be sufficient for the current password quality and length constraints
as returned by getPasswordQuality(ComponentName)
and
getPasswordMinimumLength(ComponentName)
; if it does not meet
these constraints, then it will be rejected and false
returned.
Note that the password may be a stronger quality (containing alphanumeric characters when the requested quality is only numeric), in which case the currently active quality will be increased to match.
To reject password entry try following code;
setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED); resetPassword("", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);Warning: If there is any installed certificates while resetting password by preceding way can not be applied and it returns false.
Parameters | |
---|---|
password |
String :
The new password for the user. |
flags |
int :
May be 0 or RESET_PASSWORD_REQUIRE_ENTRY . |
Returns | |
---|---|
boolean |
true if the password was applied, or false if it is not acceptable
for the current constraints. |
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to disable all cameras on the device. After setting this, no applications will be able to access any cameras on the device.
Parameters | |
---|---|
disabled |
boolean :
Whether or not the camera should be disabled. |
Throws | |
---|---|
AfexException |
Sets the lock view message icon by the given bitmap icon.
int width = 50, height = 50; Bitmap.Config config = Bitmap.Config.ARGB_8888; Bitmap bitmap = Bitmap.createBitmap(width, height, config); // this creates a // mutable bitmap bitmap.eraseColor(Color.RED); setLockViewIcon(bitmap);
Parameters | |
---|---|
icon |
Bitmap :
Bitmap to set lock icon or null to delete icon. |
Returns | |
---|---|
boolean |
true if the operation succeeds else false |
Throws | |
---|---|
AfexException |
Sets the lock view message text by the given text.
Parameters | |
---|---|
text |
String :
String to set lock message or null to delete message. |
Returns | |
---|---|
boolean |
true if the operation succeeds else false |
Throws | |
---|---|
AfexException |
Setting this to a value greater than zero enables a built-in policy that will perform a device wipe after too many incorrect device-unlock passwords have been entered.
This built-in policy combines watching for failed passwords and wiping the device, and
requires that you request both USES_POLICY_WATCH_LOGIN
and
USES_POLICY_WIPE_DATA
.
To implement any other policy (for example wiping data for a particular application only,
erasing or revoking credentials, or reporting the failure to a server), you should implement
onPasswordFailed(Context, android.content.Intent)
instead. Do not
use this API, because if the maximum count is reached, the device will be wiped immediately,
and your callback will not be invoked.
Parameters | |
---|---|
num |
int :
The number of failed password attempts at which point the device will wipe its
data. |
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to set the maximum time for user activity until the device will lock.
This limits the length that the user can set. It takes effect immediately.
Parameters | |
---|---|
timeMs |
long :
The new desired maximum time to lock in milliseconds. A value of 0 means there
is no restriction. |
Throws | |
---|---|
AfexException |
Sets password change state enforced.
Usage
Called by an application that is managing the device to enforce an existing password to be changed (or created if device has no password). Admin can use it to present user a password dialog to change or setup new password. If a password is already set in the device and admin wants to let user cancel the password dialog for a period of time, he can use setPasswordExpirationTimeout(int) to set the period (in minutes) that the user can keep using the device before changing existing password (Default value is 0 - no option to cancel). If device has no password set, user will be enforced to set a password and will be given no option to cancel and the password change timeout will be ignored in this case.IAfexAdminManager aam = AfexAdminManager.getInterface(getApplicationContext()); try { // Condition-1 // if Device has no password and password change timeout is 0. boolean result = aam.setPasswordChangeEnforced(true); if (true == result) { // if successful user will be enforced to create a password with // no option to cancel dialog. } // Condition-2 // if Device already has password and password change timeout is 0 . boolean result = aam.setPasswordChangeEnforced(true); if (true == result) { // if successful user will be enforced to change existing // password with no option to cancel dialog. } // Condition-3 // if Device has no password and we set password change timeout to // some positive value. aam.setPasswordExpirationTimeout(10 * 60 * 1000); // minute * second * millisecond boolean result = aam.setPasswordChangeEnforced(true); if (true == result) { // if successful user will be enforced to create a password with // no option to cancel dialog because password change timeout is // only used for password changes, not new passwords. } // Condition-4 // if Device already has password and we set password change timeout // to some positive value. aam.setPasswordExpirationTimeout(10); boolean result = aam.setPasswordChangeEnforced(true); if (true == result) { // if successful user will be enforced to change existing // password with the option to cancel it for the first time and // then after 10 minutes he will be prompted again with no // option to cancel. } } catch (AfexException e) { Log.w(TAG, "AfexException: " + e); }
Parameters | |
---|---|
state |
boolean :
true to enforce password change else false |
Returns | |
---|---|
boolean |
true if the operation succeeds else false |
Throws | |
---|---|
AfexException |
Called by a device admin to set the password expiration timeout.
Calling this method will restart the countdown for password expiration for the given admin, as will changing the device password (for all admins).
The provided timeout is the time delta in ms and will be added to the current time. For example, to have the password expire 5 days from now, timeout would be 5 * 86400 * 1000 = 432000000 ms for timeout.
To disable password expiration, a value of 0 may be used for timeout.
Parameters | |
---|---|
timeout |
long :
The limit (in ms) that a password can remain in effect. A value of 0 means
there is no restriction (unlimited). |
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to set the length of the password history.
After setting this, the user will not be able to enter a new password that is the same as any
password in the history. Note that the current password will remain until the user has set a
new one, so the change does not take place immediately. To prompt the user for a new
password, use ACTION_SET_NEW_PASSWORD
after setting this value.
This constraint is only imposed if the administrator has also requested either
PASSWORD_QUALITY_NUMERIC
,
PASSWORD_QUALITY_ALPHABETIC
,
PASSWORD_QUALITY_ALPHANUMERIC
with
setPasswordQuality(ComponentName, int)
.
Parameters | |
---|---|
length |
int :
The new desired length of password history. A value of 0 means there is no
restriction. |
Throws | |
---|---|
AfexException |
Sets the maximum letter sequence length allowed in the device. For instance, if the length value is '4' then "12ab", "12qwe", "12zxcv" would all be letter sequences of length '4' and will be allowed in the device password.
Parameters | |
---|---|
length |
int :
The maximum allowed letter sequence length. A value of '0' specifies that no
such letter sequence restrictions are applied. |
Returns | |
---|---|
boolean |
true if the operation succeeds else false
|
Throws | |
---|---|
AfexException |
Sets the maximum numeric sequence length allowed in the device. For instance, if the length value is '4' then "ab12", "ab987", "ab4444" would all be numeric sequences of length '4' and will be allowed in the device password.
Parameters | |
---|---|
length |
int :
The maximum allowed numeric sequence length. A value of '0' specifies that no
such numeric sequence restrictions are applied. |
Returns | |
---|---|
boolean |
true if the operation succeeds else false
|
Throws | |
---|---|
AfexException |
Sets the maximum symbol sequence length allowed in the device. For instance, if the length value is '4' then "12!@", "12%^&", "12()[]" would all be symbol sequences of length '4' and will be allowed in the device password.
Parameters | |
---|---|
length |
int :
The maximum allowed symbol sequence length. A value of '0' specifies that no
such symbol sequence restrictions are applied. |
Returns | |
---|---|
boolean |
true if the operation succeeds else false
|
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to set the minimum allowed password length.
After setting this, the user will not be able to enter a new password that is not at least as
restrictive as what has been set. Note that the current password will remain until the user
has set a new one, so the change does not take place immediately. To prompt the user for a
new password, use ACTION_SET_NEW_PASSWORD
after setting this
value. This constraint is only imposed if the administrator has also requested either
PASSWORD_QUALITY_NUMERIC
,
PASSWORD_QUALITY_ALPHABETIC
,
PASSWORD_QUALITY_ALPHANUMERIC
,
PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
.
Parameters | |
---|---|
length |
int :
The new desired minimum password length. A value of 0 means there is no
restriction. |
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to set the minimum number of letters required in the password.
After setting this, the user will not be able to enter a new password that is not at least as
restrictive as what has been set. Note that the current password will remain until the user
has set a new one, so the change does not take place immediately. To prompt the user for a
new password, use ACTION_SET_NEW_PASSWORD
after setting this
value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
. The default value is 1.
Parameters | |
---|---|
length |
int :
The new desired minimum number of letters required in the password. A value of
0 means there is no restriction. |
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to set the minimum number of lower case letters required in the password.
After setting this, the user will not be able to enter a new password that is not at least as
restrictive as what has been set. Note that the current password will remain until the user
has set a new one, so the change does not take place immediately. To prompt the user for a
new password, use ACTION_SET_NEW_PASSWORD
after setting this
value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
. The default value is 0.
Parameters | |
---|---|
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 | |
---|---|
AfexException |
Called by an application that is administering the device to set the minimum number of non-letter characters (numerical digits or symbols) required in the password.
After setting this, the user will not be able to enter a new password that is not at least as
restrictive as what has been set. Note that the current password will remain until the user
has set a new one, so the change does not take place immediately. To prompt the user for a
new password, use ACTION_SET_NEW_PASSWORD
after setting this
value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
. The default value is 0.
Parameters | |
---|---|
length |
int :
The new desired minimum number of letters required in the password. A value of
0 means there is no restriction. |
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to set the minimum number of numerical digits required in the password.
After setting this, the user will not be able to enter a new password that is not at least as
restrictive as what has been set. Note that the current password will remain until the user
has set a new one, so the change does not take place immediately. To prompt the user for a
new password, use ACTION_SET_NEW_PASSWORD
after setting this
value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
. The default value is 1.
Parameters | |
---|---|
length |
int :
The new desired minimum number of numerical digits required in the password. A
value of 0 means there is no restriction. |
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to set the minimum number of symbols required in the password.
After setting this, the user will not be able to enter a new password that is not at least as
restrictive as what has been set. Note that the current password will remain until the user
has set a new one, so the change does not take place immediately. To prompt the user for a
new password, use ACTION_SET_NEW_PASSWORD
after setting this
value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
. The default value is 1.
Parameters | |
---|---|
length |
int :
The new desired minimum number of symbols required in the password. A value of
0 means there is no restriction. |
Throws | |
---|---|
AfexException |
Called by an application that is administering the device to set the minimum number of upper case letters required in the password.
After setting this, the user will not be able to enter a new password that is not at least as
restrictive as what has been set. Note that the current password will remain until the user
has set a new one, so the change does not take place immediately. To prompt the user for a
new password, use ACTION_SET_NEW_PASSWORD
after setting this
value. This constraint is only imposed if the administrator has also requested
PASSWORD_QUALITY_COMPLEX
with
setPasswordQuality(ComponentName, int)
. The default value is 0.
Parameters | |
---|---|
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 | |
---|---|
AfexException |
Called by an application that is administering the device to set the password restrictions it is imposing.
After setting this, the user will not be able to enter a new password that is not at least as
restrictive as what has been set. Note that the current password will remain until the user
has set a new one, so the change does not take place immediately. To prompt the user for a
new password, use ACTION_SET_NEW_PASSWORD
after setting this
value.
Quality constants are ordered so that higher values are more restrictive; thus the highest requested quality constant (between the policy set here, the user's preference, and any other considerations) is the one that is in effect.
To reject password entry try following code;
setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED); resetPassword("", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
Parameters | |
---|---|
quality |
int :
The new desired quality. One of
PASSWORD_QUALITY_UNSPECIFIED ,
PASSWORD_QUALITY_SOMETHING ,
PASSWORD_QUALITY_NUMERIC ,
PASSWORD_QUALITY_ALPHABETIC ,
PASSWORD_QUALITY_ALPHANUMERIC ,
PASSWORD_QUALITY_COMPLEX . |
Throws | |
---|---|
AfexException |
Sets a pattern for password match. MDM that last set the password pattern will become the password pattern owner, meaning that only his patterns will used to match the new passwords. Forces user to enter password based on a regular expression. For example if regular expression is [a-zA-Z]{2,4}[\d]{2,4}. Admin can force user to enter at least 4 and at most 8 character password with first at least 2 and at most 4 alphabetic characters and next at least 2 and at most 4 numeric characters. Admin must take care when setting this pattern. Warning: If user sets required password pattern, other password restrictions disregarded while password checking. Pattern has higher priority than other password maximum and minimum sequences.
Parameters | |
---|---|
regex |
String :
The required pattern to be matched or null to reset pattern. |
Returns | |
---|---|
boolean |
true if the operation succeeds else false |
Throws | |
---|---|
|
AfexException |
AfexException |
See also:
Called by an application that is administering the device to request that the storage system be encrypted.
When multiple device administrators attempt to control device encryption, the most secure,
supported setting will always be used. If any device administrator requests device
encryption, it will be enabled; Conversely, if a device administrator attempts to disable
device encryption while another device administrator has enabled it, the call to disable will
fail (most commonly returning ENCRYPTION_STATUS_ACTIVE
).
This policy controls encryption of the secure (application data) storage area. Data written
to other storage areas may or may not be encrypted, and this policy does not require or
control the encryption of any other storage areas. There is one exception: If
isExternalStorageEmulated()
is true
, then the
directory returned by getExternalStorageDirectory()
must be
written to disk within the encrypted storage area.
Important Note: On some devices, it is possible to encrypt storage without requiring the user to create a device PIN or Password. In this case, the storage is encrypted, but the encryption key may not be fully secured. For maximum security, the administrator should also require (and check for) a pattern, PIN, or password.
Parameters | |
---|---|
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 | |
---|---|
AfexException |
Starts by an application that is administering the device to request that the storage system encryption to be started.
Returns | |
---|---|
boolean |
true if encryption started, false encryption is not supported. |
Throws | |
---|---|
AfexException |
Validates password if password pattern is set.
Warning : This api works on only Password Security mode. Which means password quality something of;
PASSWORD_QUALITY_ALPHABETIC
PASSWORD_QUALITY_ALPHANUMERIC
PASSWORD_QUALITY_COMPLEX
Parameters | |
---|---|
password |
String :
Password string |
Returns | |
---|---|
String |
empty
error |
Throws | |
---|---|
AfexException |
Validates password if password sequence length is set.
Warning : This api works on only Password Security mode. Which means password quality something of;
PASSWORD_QUALITY_ALPHABETIC
PASSWORD_QUALITY_ALPHANUMERIC
PASSWORD_QUALITY_COMPLEX
Parameters | |
---|---|
password |
String :
Password string |
Returns | |
---|---|
String |
empty
error |
Throws | |
---|---|
AfexException |
Ask the user data be wiped. This will cause the device to reboot, erasing all user data while next booting up.
External storage such as SD cards will be also erased if the flag
WIPE_EXTERNAL_STORAGE
is set.
Parameters | |
---|---|
flags |
int :
Bit mask of additional options: currently 0 and
WIPE_EXTERNAL_STORAGE are supported. |
Throws | |
---|---|
AfexException |