From beeabf4b129056da25c25d3b82ff79bc6883c123 Mon Sep 17 00:00:00 2001 From: Andreas Miko Date: Wed, 8 Feb 2023 17:26:18 +0000 Subject: [PATCH] Add setting to disable PIN animation and password Test: Unit - atest SettingsRoboTests Test: Manual - Set PIN lock and enabled/disabled the setting to observe animation change during PIN entry Bug: b/204799468 Merged-In: I587b993ef5515a075442e82ebafae88bebdffc20 Change-Id: I587b993ef5515a075442e82ebafae88bebdffc20 --- .../internal/widget/LockPatternUtils.java | 23 +++++++++++++++++++ .../settings/SettingsBackupAgent.java | 9 ++++++++ .../KeyguardAbsKeyInputViewController.java | 2 +- .../KeyguardPinBasedInputViewController.java | 17 +++++++------- .../src/com/android/keyguard/NumPadKey.java | 12 ++++++++-- .../android/keyguard/PasswordTextView.java | 12 ++++++---- 6 files changed, 60 insertions(+), 15 deletions(-) diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 2dfe89397ea5e..5b2c441f95c9c 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -170,6 +170,8 @@ public class LockPatternUtils { private static final String LOCK_SCREEN_OWNER_INFO_ENABLED = Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED; + private static final String LOCK_PIN_ENHANCED_PRIVACY = "pin_enhanced_privacy"; + private static final String LOCK_SCREEN_DEVICE_OWNER_INFO = "lockscreen.device_owner_info"; private static final String ENABLED_TRUST_AGENTS = "lockscreen.enabledtrustagents"; @@ -998,6 +1000,27 @@ public class LockPatternUtils { return getString(Settings.Secure.LOCK_PATTERN_VISIBLE, userId) != null; } + /** + * @return Whether enhanced pin privacy is enabled. + */ + public boolean isPinEnhancedPrivacyEnabled(int userId) { + return getBoolean(LOCK_PIN_ENHANCED_PRIVACY, false, userId); + } + + /** + * Set whether enhanced pin privacy is enabled. + */ + public void setPinEnhancedPrivacyEnabled(boolean enabled, int userId) { + setBoolean(LOCK_PIN_ENHANCED_PRIVACY, enabled, userId); + } + + /** + * @return Whether enhanced pin privacy was ever chosen. + */ + public boolean isPinEnhancedPrivacyEverChosen(int userId) { + return getString(LOCK_PIN_ENHANCED_PRIVACY, userId) != null; + } + /** * Set whether the visible password is enabled for cryptkeeper screen. */ diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index d0055d7a55e1f..9f59fc3cd5386 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -182,6 +182,8 @@ public class SettingsBackupAgent extends BackupAgentHelper { "visible_pattern_enabled"; private static final String KEY_LOCK_SETTINGS_POWER_BUTTON_INSTANTLY_LOCKS = "power_button_instantly_locks"; + private static final String KEY_LOCK_SETTINGS_PIN_ENHANCED_PRIVACY = + "pin_enhanced_privacy"; // Name of the temporary file we use during full backup/restore. This is // stored in the full-backup tarfile as well, so should not be changed. @@ -709,6 +711,10 @@ public class SettingsBackupAgent extends BackupAgentHelper { out.writeUTF(KEY_LOCK_SETTINGS_POWER_BUTTON_INSTANTLY_LOCKS); out.writeUTF(powerButtonInstantlyLocks ? "1" : "0"); } + if (lockPatternUtils.isPinEnhancedPrivacyEverChosen(userId)) { + out.writeUTF(KEY_LOCK_SETTINGS_PIN_ENHANCED_PRIVACY); + out.writeUTF(lockPatternUtils.isPinEnhancedPrivacyEnabled(userId) ? "1" : "0"); + } // End marker out.writeUTF(""); out.flush(); @@ -961,6 +967,9 @@ public class SettingsBackupAgent extends BackupAgentHelper { case KEY_LOCK_SETTINGS_POWER_BUTTON_INSTANTLY_LOCKS: lockPatternUtils.setPowerButtonInstantlyLocks("1".equals(value), userId); break; + case KEY_LOCK_SETTINGS_PIN_ENHANCED_PRIVACY: + lockPatternUtils.setPinEnhancedPrivacyEnabled("1".equals(value), userId); + break; } } in.close(); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java index baaef1983e9cf..f8cb38d7488b9 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java @@ -44,7 +44,7 @@ import java.util.Map; public abstract class KeyguardAbsKeyInputViewController extends KeyguardInputViewController { private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - private final LockPatternUtils mLockPatternUtils; + protected final LockPatternUtils mLockPatternUtils; private final LatencyTracker mLatencyTracker; private final FalsingCollector mFalsingCollector; private final EmergencyButtonController mEmergencyButtonController; diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java index 8011efdc1ae7a..75fd8884152ca 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java @@ -71,13 +71,17 @@ public abstract class KeyguardPinBasedInputViewController { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { mFalsingCollector.avoidGesture(); } return false; }); + button.setAnimationEnabled(showAnimations); } mPasswordEntry.setOnKeyListener(mOnKeyListener); mPasswordEntry.setUserActivityListener(this::onUserInput); @@ -102,12 +106,9 @@ public abstract class KeyguardPinBasedInputViewController { + if (mPasswordEntry.isEnabled()) { + verifyPasswordAndUnlock(); } }); okButton.setOnHoverListener(mLiftToActivateListener); @@ -118,7 +119,7 @@ public abstract class KeyguardPinBasedInputViewController