diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 9feca3d2865af..3c119a622b664 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -748,6 +748,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private void handleFaceAuthenticated(int authUserId) { Trace.beginSection("KeyGuardUpdateMonitor#handlerFaceAuthenticated"); try { + if (mGoingToSleep) { + Log.d(TAG, "Aborted successful auth because device is going to sleep."); + return; + } final int userId; try { userId = ActivityManager.getService().getCurrentUser().id; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java index d67795210f0c2..aa78a5d63f7e1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -365,16 +365,23 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { private int calculateMode(BiometricSourceType biometricSourceType) { boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed(); boolean deviceDreaming = mUpdateMonitor.isDreaming(); - boolean faceStayingOnKeyguard = biometricSourceType == BiometricSourceType.FACE - && !mKeyguardBypassController.getBypassEnabled(); + boolean face = biometricSourceType == BiometricSourceType.FACE; + boolean faceStayingOnKeyguard = face && !mKeyguardBypassController.getBypassEnabled(); if (!mUpdateMonitor.isDeviceInteractive()) { if (!mStatusBarKeyguardViewManager.isShowing()) { return MODE_ONLY_WAKE; } else if (mDozeScrimController.isPulsing() && unlockingAllowed) { return faceStayingOnKeyguard ? MODE_NONE : MODE_WAKE_AND_UNLOCK_PULSING; - } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) { + } else if (!face && (unlockingAllowed || !mUnlockMethodCache.isMethodSecure())) { return MODE_WAKE_AND_UNLOCK; + } else if (face) { + if (!(mDozeScrimController.isPulsing() && !unlockingAllowed)) { + Log.wtf(TAG, "Face somehow arrived when the device was not interactive"); + } + // We could theoretically return MODE_NONE, but this means that the device + // would be not interactive, unlocked, and the user would not see the device state. + return MODE_ONLY_WAKE; } else { return MODE_SHOW_BOUNCER; } @@ -389,6 +396,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { return MODE_DISMISS_BOUNCER; } else if (unlockingAllowed) { return faceStayingOnKeyguard ? MODE_ONLY_WAKE : MODE_UNLOCK; + } else if (face) { + return MODE_NONE; } else if (!mStatusBarKeyguardViewManager.isBouncerShowing()) { return MODE_SHOW_BOUNCER; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt index c9dd4613b9462..124206a5a369d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt @@ -19,7 +19,6 @@ package com.android.systemui.statusbar.phone import android.content.Context import android.hardware.face.FaceManager import android.provider.Settings -import com.android.internal.annotations.VisibleForTesting import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.tuner.TunerService @@ -59,10 +58,4 @@ class KeyguardBypassController { } }, Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD) } - - @VisibleForTesting - constructor(bypassEnabled: Boolean, unlockMethodCache: UnlockMethodCache) { - this.bypassEnabled = bypassEnabled - this.unlockMethodCache = unlockMethodCache - } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java index 9b8d09e7aee85..eb3f56a19c9e8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java @@ -71,6 +71,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { private UnlockMethodCache mUnlockMethodCache; @Mock private Handler mHandler; + @Mock + private KeyguardBypassController mKeyguardBypassController; private BiometricUnlockController mBiometricUnlockController; @Before @@ -83,8 +85,9 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager); mDependency.injectTestDependency(StatusBarWindowController.class, mStatusBarWindowController); - mBiometricUnlockController = new TestableBiometricUnlockController( - false /* faceDismissesKeyguard */); + mBiometricUnlockController = new BiometricUnlockController(mContext, mDozeScrimController, + mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache, + mHandler, mUpdateMonitor, 0 /* wakeUpDelay */, mKeyguardBypassController); mBiometricUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); } @@ -139,9 +142,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { } @Test - public void onBiometricAuthenticated_whenFace_dismissingKeyguard() { - mBiometricUnlockController = new TestableBiometricUnlockController( - true /* faceDismissesKeyguard */); + public void onBiometricAuthenticated_whenFace_andBypass_dismissKeyguard() { + when(mKeyguardBypassController.getBypassEnabled()).thenReturn(true); mBiometricUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); when(mUpdateMonitor.isUnlockingWithBiometricAllowed()).thenReturn(true); @@ -184,14 +186,4 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { mBiometricUnlockController.onFinishedGoingToSleep(-1); verify(mHandler).post(any()); } - - private class TestableBiometricUnlockController extends BiometricUnlockController { - - TestableBiometricUnlockController(boolean faceDismissesKeyguard) { - super(mContext, mDozeScrimController, - mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache, - mHandler, mUpdateMonitor, 0 /* wakeUpDelay */, - new KeyguardBypassController(faceDismissesKeyguard, mUnlockMethodCache)); - } - } }