1

I am developing an app that can lock the device using the DeviceAdmin API. I want to receive ACTION_PASSWORD_FAILED broadcast (or DeviceAdminReceiver.onPasswordFailed() callback) every time the user enters a wrong password on the lock screen. What is important is that my the app does not use the system dialog for setting a lock password, instead using DevicePolicyManager.resetPassword(String, int).

The system does not send the broadcast if the entered password is shorter than the current minimum password length (as described in an edit to this question). This is the root of the problem.

I could set the minimum password length limit using DevicePolicyManager.setPasswordMinimumLength(ComponentName, int), but there's a catch. From the docs for this method:

Note that the current password will remain until the user has set a new one, so the change does not take place immediately.

Setting the limit before the password itself does not help either. From the docs for DevicePolicyManager.resetPassword(String, int), in regards to constraints set at the time of calling the method:

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.

This means that the minimum password length is being reset every time a new password have been set.

Is there a way to work around this issue and get broadcasts/callbacks for every failed unlock attempt regardless of password quality constraints?

Community
  • 1
  • 1
SpaceBison
  • 2,525
  • 1
  • 21
  • 38

0 Answers0