Merge "Revert "Wipe the LockscreenCredential in DPMS#resetPasswordInternal"" into main am: 7a27431f65 am: fbfce4e308

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3068720

Change-Id: Ia6c015b1ea99d851ed53b9175a7313fbe62926b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index ff75736..d555f1a 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -5673,18 +5673,15 @@
 
     private boolean resetPasswordInternal(String password, long tokenHandle, byte[] token,
             int flags, CallerIdentity caller) {
-        final boolean isPin = PasswordMetrics.isNumericOnly(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);
+        final boolean isPin = PasswordMetrics.isNumericOnly(password);
+        final LockscreenCredential newCredential;
+        if (isPin) {
+            newCredential = LockscreenCredential.createPin(password);
+        } else {
+            newCredential = LockscreenCredential.createPasswordOrNone(password);
+        }
         synchronized (getLockObject()) {
             final PasswordMetrics minMetrics = getPasswordMinimumMetricsUnchecked(userHandle);
             final int complexity = getAggregatedPasswordComplexityLocked(userHandle);