From 7183e83b0b4afaf931821ce3b5fdac6ad5aba042 Mon Sep 17 00:00:00 2001 From: Avinash Vadlamudi Date: Mon, 10 Apr 2023 08:51:16 +0000 Subject: [PATCH] Store the PIN length to disk when Pin auto confirm feature is enabled Bug: 267222046 Test: Manual test Change-Id: I4f76e607ea7fb08d20a042e49c9669f8988aeff8 --- .../security/screenlock/ScreenLockSettings.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/security/screenlock/ScreenLockSettings.java b/src/com/android/settings/security/screenlock/ScreenLockSettings.java index b2ee76c7929..1c66b711382 100644 --- a/src/com/android/settings/security/screenlock/ScreenLockSettings.java +++ b/src/com/android/settings/security/screenlock/ScreenLockSettings.java @@ -107,12 +107,21 @@ public class ScreenLockSettings extends DashboardFragment public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (requestCode == AUTO_PIN_SETTING_ENABLING_REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { - mLockPatternUtils.setAutoPinConfirm(/* enabled= */ true, MY_USER_ID); + onAutoPinConfirmSettingChange(/* newState= */ true); } } else if (requestCode == AUTO_PIN_SETTING_DISABLING_REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { - mLockPatternUtils.setAutoPinConfirm(/* enabled= */ false, MY_USER_ID); + onAutoPinConfirmSettingChange(/* newState= */ false); } } } + + private void onAutoPinConfirmSettingChange(boolean newState) { + // update the auto pin confirm setting. + mLockPatternUtils.setAutoPinConfirm(newState, MY_USER_ID); + // store the pin length info to disk; If it fails, reset the setting to prev state. + if (!mLockPatternUtils.refreshStoredPinLength(MY_USER_ID)) { + mLockPatternUtils.setAutoPinConfirm(!newState, MY_USER_ID); + } + } }