Reputation: 33
As we know Android ICS provides Face Unlock option to lock the screen in Settings->Security->Screen lock.
Is there a way to programmatically enable Face Locking using DevicePolicyManager, like enabling password restriction from MDM?
I have gone through the DevicePolicyManager class in API Level 16, but could not find it. Is there any alternative to achieve this?
Thanks.
Upvotes: 2
Views: 1134
Reputation: 15782
Face Unlock is controlled by the PASSWORD_QUALITY_BIOMETRIC_WEAK
flag, and is used with setPasswordQuality
.
For example, this code will require that the user has a Face Unlock password (or better) set, and will prompt them to update their password if needed:
DevicePolicyManager mDPM = (DevicePolicyManager)
context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName mPolicyAdmin = new ComponentName(context, PolicyAdmin.class);
// Enforce Face Unlock or better for new passwords
mDPM.setPasswordQuality(mPolicyAdmin,
DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK);
// Prompt user to upgrade password if necessary
if (!mDPM.isActivePasswordSufficient()) {
Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);
}
Upvotes: 3