diff options
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 6562bd305c81..8c2102039333 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"; @@ -1037,6 +1039,27 @@ public class LockPatternUtils { } /** + * @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 574fd5a7ec13..11154d165109 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 baaef1983e9c..f8cb38d7488b 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<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 92e364110547..559db76748ed 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<T extends KeyguardPinB 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 @@ public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinB 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 @@ public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinB 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 3b0644eaab82..7c7680afe368 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java @@ -50,6 +50,7 @@ public class NumPadKey extends ViewGroup implements NumPadAnimationListener { private int mDigit = -1; private int mTextViewResId; private PasswordTextView mTextView; + private boolean mAnimationsEnabled = true; @Nullable private NumPadAnimator mAnimator; @@ -164,11 +165,11 @@ public class NumPadKey extends ViewGroup implements NumPadAnimationListener { 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 @@ public class NumPadKey extends ViewGroup implements NumPadAnimationListener { 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 8554e11a2f3c..540001135543 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.Rect; 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 @@ public class PasswordTextView extends FrameLayout { 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 @@ public class PasswordTextView extends FrameLayout { 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 @@ public class PasswordTextView extends FrameLayout { 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; |