From 0a67bbf89f96d079393def3b60909edc6479c9ed Mon Sep 17 00:00:00 2001 From: Pavel Grafov Date: Wed, 10 Apr 2019 16:12:55 +0100 Subject: [PATCH] Allow user without a password to clear credentials 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 --- .../settings/security/CredentialStorage.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/security/CredentialStorage.java b/src/com/android/settings/security/CredentialStorage.java index 99937eee472..0ea37b5bc7f 100644 --- a/src/com/android/settings/security/CredentialStorage.java +++ b/src/com/android/settings/security/CredentialStorage.java @@ -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. } }