Fix clearing password with DPM.resetPasswordWithToken()

Using resetPasswordWithToken() to clear password does not function
correctly before user unlock for the following two reasons:
1. it tries to remove keys from vold & keystore before they are unlocked,
    resulting in execution failure and data loss.
2. once lockscreen is cleared, it does not progress user unlock so
    the user is stuck in USER_LOCKED state.

This change fixes both of these issues.

Also make a small change to LockSettingsShellCommand so it no longer accepts
arbitray password if the device is not secured.

Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/locksettings/
Test: atest com.android.cts.devicepolicy.ManagedProfileTest#testClearPasswordWithTokenBeforeUnlock
Test: atest com.android.cts.devicepolicy.ManagedProfileTest#testResetPasswordWithTokenBeforeUnlock
Fix: 123514964
Bug: 124094969
Bug: 129669035
Change-Id: I38af4842b3cccea37f9e3e61d30bd3d2939e8ab8
3 files changed