OSDN Git Service

Allow user without a password to clear credentials
authorPavel Grafov <pgrafov@google.com>
Wed, 10 Apr 2019 15:12:55 +0000 (16:12 +0100)
committerPavel Grafov <pgrafov@google.com>
Wed, 10 Apr 2019 16:53:32 +0000 (17:53 +0100)
Currently the code assumes that the user always has a pin or
password or pattern. If there's no password confirmKeyGuard() will
return false, so the acttivity will finish without doing anything.
With this change if there's no PIN/password/pattern, the credential
clearing task will be launched straightaway as the user presses "OK"
the confirmation prompt.

Bug: 127697771
Test: manual
Change-Id: Iac4af0abfc7430ed197e04f833bf203c3f66f52e

src/com/android/settings/security/CredentialStorage.java

index 99937ee..0ea37b5 100644 (file)
@@ -242,14 +242,20 @@ public final class CredentialStorage extends FragmentActivity {
 
         @Override
         public void onDismiss(DialogInterface dialog) {
-            if (mResetConfirmed) {
-                mResetConfirmed = false;
-                if (confirmKeyGuard(CONFIRM_CLEAR_SYSTEM_CREDENTIAL_REQUEST)) {
-                    // will return password value via onActivityResult
-                    return;
-                }
+            if (!mResetConfirmed) {
+                finish();
+                return;
             }
-            finish();
+
+            mResetConfirmed = false;
+            if (!mUtils.isSecure(UserHandle.myUserId())) {
+                // This task will call finish() in the end.
+                new ResetKeyStoreAndKeyChain().execute();
+            } else if (!confirmKeyGuard(CONFIRM_CLEAR_SYSTEM_CREDENTIAL_REQUEST)) {
+                Log.w(TAG, "Failed to launch credential confirmation for a secure user.");
+                finish();
+            }
+            // Confirmation result will be handled in onActivityResult if needed.
         }
     }