diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java | 8 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java | 26 |
2 files changed, 33 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index ceb5ff9d0a8c..54886c3e2080 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -1937,6 +1937,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } } mGoingToSleep = true; + // Resetting assistant visibility state as the device is going to sleep now. + // TaskStackChangeListener gets triggered a little late when we transition to AoD, + // which results in face auth running once on AoD. + mAssistantVisible = false; + mLogger.d("Started going to sleep, mGoingToSleep=true, mAssistantVisible=false"); updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, FACE_AUTH_UPDATED_GOING_TO_SLEEP); } @@ -3330,7 +3335,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab /** * Handle {@link #MSG_KEYGUARD_RESET} */ - private void handleKeyguardReset() { + @VisibleForTesting + protected void handleKeyguardReset() { mLogger.d("handleKeyguardReset"); updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, FACE_AUTH_UPDATED_KEYGUARD_RESET); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index 7647ec8a83e8..d1650b776052 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -854,6 +854,32 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { } @Test + public void faceUnlockDoesNotRunWhenDeviceIsGoingToSleepWithAssistantVisible() { + mKeyguardUpdateMonitor.setKeyguardShowing(true, true); + mKeyguardUpdateMonitor.setAssistantVisible(true); + + verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); + mTestableLooper.processAllMessages(); + clearInvocations(mFaceManager); + + // Device going to sleep while assistant is visible + mKeyguardUpdateMonitor.handleStartedGoingToSleep(0); + mKeyguardUpdateMonitor.handleFinishedGoingToSleep(0); + mTestableLooper.moveTimeForward(DEFAULT_CANCEL_SIGNAL_TIMEOUT); + mTestableLooper.processAllMessages(); + + mKeyguardUpdateMonitor.handleKeyguardReset(); + + assertThat(mKeyguardUpdateMonitor.isFaceDetectionRunning()).isFalse(); + verify(mFaceManager, never()).authenticate(any(), + any(), + any(), + any(), + anyInt(), + anyBoolean()); + } + + @Test public void testIgnoresAuth_whenTrustAgentOnKeyguard_withoutBypass() { mKeyguardUpdateMonitor.dispatchStartedWakingUp(PowerManager.WAKE_REASON_POWER_BUTTON); mTestableLooper.processAllMessages(); |