What I am doing
I need to remove (clear) Pattern/ Password/ Pin from device, for corporate policy. I am using resetPassword (String password, int flags)
of Device Admin API.
as
public boolean resetPassword(String newPassword) {
if(ActivityManager.isUserAMonkey()) {
// Don't trust monkeys to do the right thing!
AlertDialog.Builder builder = new AlertDialog.Builder(this.context);
builder.setMessage("You can't reset my password because you are a monkey!");
builder.setPositiveButton("I admit defeat", null);
builder.show();
return false;
}
boolean active = mDPM.isAdminActive(mDeviceAdmin);
if(active) {
return mDPM.resetPassword(newPassword.trim(), DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
}
return false;
}
By calling
resetPassword("");
Problem description
If Pattern lock is activated on device and OS version is 3.0, 3.1 or 3.2, and I call resetPassword("")
it gives me a security exception for
WRTITE_SECURE_SETTINGS
permission. But this permission can accessible by firmware applications.
This issue is discussed at following pages
Device Policy Manager - Reset Password - Android 3.0 Problems and Device Policy Manager - Reset Password - Android 3.0 Problems
So, My question is how can I clear the Pattern Lock on 3.0, 3.1 or 3.2 versions?