diff options
author | Ellen Arteca <emarteca@google.com> | 2024-04-30 16:48:44 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-04-30 16:48:44 +0000 |
commit | f245247d35a8caffcb8a84ccfa11000365cdb2af (patch) | |
tree | f325c5039db15dbced0bf70cb9e11ccc830f9dec | |
parent | f902b3adf2f16ed868be771ea81db1ff6415b919 (diff) | |
parent | eec02e9f1025c853e8b605508818e3f36d5a339b (diff) | |
download | base-f245247d35a8caffcb8a84ccfa11000365cdb2af.tar.gz |
Merge "Wipe the LockscreenCredential in DPMS#resetPasswordInternal" into main
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index dd49260e160e..293f379199a6 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -5672,15 +5672,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { private boolean resetPasswordInternal(String password, long tokenHandle, byte[] token, int flags, CallerIdentity caller) { - final int callingUid = caller.getUid(); - final int userHandle = UserHandle.getUserId(callingUid); final boolean isPin = PasswordMetrics.isNumericOnly(password); - final LockscreenCredential newCredential; - if (isPin) { - newCredential = LockscreenCredential.createPin(password); - } else { - newCredential = LockscreenCredential.createPasswordOrNone(password); + try (LockscreenCredential newCredential = + isPin ? LockscreenCredential.createPin(password) : + LockscreenCredential.createPasswordOrNone(password)) { + return resetPasswordInternal(newCredential, tokenHandle, token, flags, caller); } + } + + private boolean resetPasswordInternal(LockscreenCredential newCredential, + long tokenHandle, byte[] token, int flags, CallerIdentity caller) { + final int callingUid = caller.getUid(); + final int userHandle = UserHandle.getUserId(callingUid); synchronized (getLockObject()) { final PasswordMetrics minMetrics = getPasswordMinimumMetricsUnchecked(userHandle); final int complexity = getAggregatedPasswordComplexityLocked(userHandle); |