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
Change-Id: I587b993ef5515a075442e82ebafae88bebdffc20
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 6562bd3..8c21020 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -170,6 +170,8 @@
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";
@@ -1037,6 +1039,27 @@
}
/**
+ * @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 and store the lockout deadline, meaning the user can't attempt their unlock
* pattern until the deadline has passed.
* @return the chosen deadline.
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 574fd5a..11154d1 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 @@
"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 @@
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 @@
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 baaef19..f8cb38d 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java
@@ -44,7 +44,7 @@
public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKeyInputView>
extends KeyguardInputViewController<T> {
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 92e3641..559db76 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java
@@ -71,13 +71,17 @@
protected void onViewAttached() {
super.onViewAttached();
- for (NumPadKey button: mView.getButtons()) {
+ boolean showAnimations = !mLockPatternUtils
+ .isPinEnhancedPrivacyEnabled(KeyguardUpdateMonitor.getCurrentUser());
+ mPasswordEntry.setShowPassword(showAnimations);
+ for (NumPadKey button : mView.getButtons()) {
button.setOnTouchListener((v, event) -> {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mFalsingCollector.avoidGesture();
}
return false;
});
+ button.setAnimationEnabled(showAnimations);
}
mPasswordEntry.setOnKeyListener(mOnKeyListener);
mPasswordEntry.setUserActivityListener(this::onUserInput);
@@ -102,12 +106,9 @@
View okButton = mView.findViewById(R.id.key_enter);
if (okButton != null) {
okButton.setOnTouchListener(mActionButtonTouchListener);
- okButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mPasswordEntry.isEnabled()) {
- verifyPasswordAndUnlock();
- }
+ okButton.setOnClickListener(v -> {
+ if (mPasswordEntry.isEnabled()) {
+ verifyPasswordAndUnlock();
}
});
okButton.setOnHoverListener(mLiftToActivateListener);
@@ -118,7 +119,7 @@
protected void onViewDetached() {
super.onViewDetached();
- for (NumPadKey button: mView.getButtons()) {
+ for (NumPadKey button : mView.getButtons()) {
button.setOnTouchListener(null);
}
}
diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
index 3b0644e..7c7680a 100644
--- a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
+++ b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java
@@ -50,6 +50,7 @@
private int mDigit = -1;
private int mTextViewResId;
private PasswordTextView mTextView;
+ private boolean mAnimationsEnabled = true;
@Nullable
private NumPadAnimator mAnimator;
@@ -164,11 +165,11 @@
switch(event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
doHapticKeyClick();
- if (mAnimator != null) mAnimator.expand();
+ if (mAnimator != null && mAnimationsEnabled) mAnimator.expand();
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
- if (mAnimator != null) mAnimator.contract();
+ if (mAnimator != null && mAnimationsEnabled) mAnimator.contract();
break;
}
return super.onTouchEvent(event);
@@ -228,4 +229,11 @@
mAnimator.setProgress(progress);
}
}
+
+ /**
+ * Controls the animation when a key is pressed
+ */
+ public void setAnimationEnabled(boolean enabled) {
+ mAnimationsEnabled = enabled;
+ }
}
diff --git a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
index 8554e11..5400011 100644
--- a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
+++ b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java
@@ -30,7 +30,6 @@
import android.graphics.Typeface;
import android.os.PowerManager;
import android.os.SystemClock;
-import android.provider.Settings;
import android.text.InputType;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -100,7 +99,7 @@
private Interpolator mAppearInterpolator;
private Interpolator mDisappearInterpolator;
private Interpolator mFastOutSlowInInterpolator;
- private boolean mShowPassword;
+ private boolean mShowPassword = true;
private UserActivityListener mUserActivityListener;
private PinShapeInput mPinShapeInput;
private boolean mUsePinShapes = false;
@@ -158,8 +157,6 @@
mDrawPaint.setTypeface(Typeface.create(
context.getString(com.android.internal.R.string.config_headlineFontFamily),
0));
- mShowPassword = Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.TEXT_SHOW_PASSWORD, 1) == 1;
mAppearInterpolator = AnimationUtils.loadInterpolator(mContext,
android.R.interpolator.linear_out_slow_in);
mDisappearInterpolator = AnimationUtils.loadInterpolator(mContext,
@@ -441,6 +438,13 @@
addView(mPinShapeInput.getView());
}
+ /**
+ * Controls whether the last entered digit is briefly shown after being entered
+ */
+ public void setShowPassword(boolean enabled) {
+ mShowPassword = enabled;
+ }
+
private class CharState {
char whichChar;
ValueAnimator textAnimator;