From ca88e5fb187390f413dd8f581e171597dac84746 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Tue, 14 May 2019 16:11:08 -0700 Subject: [PATCH] Block face auth when lock icon is pressed It's necessary to lock the current user, until the next screen power cycle, to avoid unlocking the device accidentally. Fixes: 132129109 Test: atest KeyguardIndicationControllerTest Test: Unlock with biometrics, long press lock icon, swipe up Test: Unlock with biometrics, swipe up Change-Id: I23258a79531c21d0e63bd0a91db59d8950526197 --- .../android/keyguard/KeyguardUpdateMonitor.java | 14 +++++++++++++- .../statusbar/KeyguardIndicationController.java | 1 + .../KeyguardIndicationControllerTest.java | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index dd6ccb2b3a88b..ea8565e8d301d 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -238,6 +238,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private boolean mIsDreaming; private final DevicePolicyManager mDevicePolicyManager; private boolean mLogoutEnabled; + // If the user long pressed the lock icon, disabling face auth for the current session. + private boolean mLockIconPressed; /** * Short delay before restarting biometric authentication after a successful try @@ -1384,6 +1386,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } private void handleScreenTurnedOff() { + mLockIconPressed = false; mHardwareFingerprintUnavailableRetryCount = 0; mHardwareFaceUnavailableRetryCount = 0; final int count = mCallbacks.size(); @@ -1625,10 +1628,19 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. return (mBouncer || mAuthInterruptActive || awakeKeyguard || shouldListenForFaceAssistant()) && !mSwitchingUser && !getUserCanSkipBouncer(user) && !isFaceDisabled(user) - && !mKeyguardGoingAway && mFaceSettingEnabledForUser + && !mKeyguardGoingAway && mFaceSettingEnabledForUser && !mLockIconPressed && mUserManager.isUserUnlocked(user) && mIsPrimaryUser; } + /** + * Whenever the lock icon is long pressed, disabling trust agents. + * This means that we cannot auth passively (face) until the user presses power. + */ + public void onLockIconPressed() { + mLockIconPressed = true; + mUserFaceAuthenticated.put(getCurrentUser(), false); + updateFaceListeningState(); + } private void startListeningForFingerprint() { if (mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index a76c9dc9f40ab..fd76a79eab2ef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -189,6 +189,7 @@ public class KeyguardIndicationController implements StateListener, mLockscreenGestureLogger.write(MetricsProto.MetricsEvent.ACTION_LS_LOCK, 0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */); showTransientIndication(R.string.keyguard_indication_trust_disabled); + mKeyguardUpdateMonitor.onLockIconPressed(); mLockPatternUtils.requireCredentialEntry(KeyguardUpdateMonitor.getCurrentUser()); return true; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java index 6d9a77c58227d..daee55bd3d618 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java @@ -261,6 +261,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { longClickCaptor.getValue().onLongClick(mLockIcon); verify(mLockPatternUtils).requireCredentialEntry(anyInt()); + verify(mKeyguardUpdateMonitor).onLockIconPressed(); } @Test