From f8f56bce428bb2b89d1d572ccd2d604761dbbce8 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Thu, 20 Nov 2014 23:55:34 +0100 Subject: Fix DPM.resetPassword("") While we're at it, also fix some multi-user issues in LockPatternUtils. Bug: 17496766 Change-Id: I8e557ea640fa589817c8f8f818c91463585d5ea7 --- .../server/devicepolicy/DevicePolicyManagerService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'services/devicepolicy') diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 9e51849..6c56bfe 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -76,6 +76,7 @@ import android.security.Credentials; import android.security.IKeyChainService; import android.security.KeyChain; import android.security.KeyChain.KeyChainConnection; +import android.text.TextUtils; import android.util.Log; import android.util.PrintWriterPrinter; import android.util.Printer; @@ -2561,13 +2562,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return strictestAdmin; } - public boolean resetPassword(String password, int flags, int userHandle) { + public boolean resetPassword(String passwordOrNull, int flags, int userHandle) { if (!mHasFeature) { return false; } enforceCrossUserPermission(userHandle); enforceNotManagedProfile(userHandle, "reset the password"); + String password = passwordOrNull != null ? passwordOrNull : ""; + int quality; synchronized (this) { // This api can only be called by an active device admin, @@ -2671,7 +2674,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { long ident = Binder.clearCallingIdentity(); try { LockPatternUtils utils = new LockPatternUtils(mContext); - utils.saveLockPassword(password, quality, false, userHandle); + if (!TextUtils.isEmpty(password)) { + utils.saveLockPassword(password, quality, false, userHandle); + } else { + utils.clearLock(false, userHandle); + } boolean requireEntry = (flags & DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY) != 0; if (requireEntry) { utils.requireCredentialEntry(UserHandle.USER_ALL); -- cgit v1.1