From 9dc6815ebc98828287b7c74853a3b483d582bd79 Mon Sep 17 00:00:00 2001 From: Curtis Belmonte Date: Fri, 8 May 2020 17:12:13 -0700 Subject: [PATCH] Don't re-trigger face auth from notification shade Adds a condition to shouldListenForFace() that checks whether the notification shade is in the locked state. This should prevent it from re-triggering after previous authentication attempts (which seems to have happened in b/155223318). Test: atest KeyguardUpdateMonitorTest Test: Unable to repro issue. Manually verified that unlocking from notification shade still works. Fixes: 155223318 Change-Id: Ibddb10e8f14d7bcbaa45d8471cca02719f6f758f --- .../android/keyguard/KeyguardUpdateMonitor.java | 15 +++++++++++---- .../keyguard/KeyguardUpdateMonitorTest.java | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index b37400f691ae3..f771cc6796363 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -94,8 +94,10 @@ import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; +import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.TaskStackChangeListener; +import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.util.Assert; import com.android.systemui.util.RingerModeTracker; @@ -219,6 +221,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private final Context mContext; private final boolean mIsPrimaryUser; + private final StatusBarStateController mStatusBarStateController; HashMap mSimDatas = new HashMap<>(); HashMap mServiceStates = new HashMap(); @@ -1521,7 +1524,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab BroadcastDispatcher broadcastDispatcher, DumpManager dumpManager, RingerModeTracker ringerModeTracker, - @Background Executor backgroundExecutor) { + @Background Executor backgroundExecutor, + StatusBarStateController statusBarStateController) { mContext = context; mSubscriptionManager = SubscriptionManager.from(context); mDeviceProvisioned = isDeviceProvisionedInSettingsDb(); @@ -1529,6 +1533,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mBackgroundExecutor = backgroundExecutor; mBroadcastDispatcher = broadcastDispatcher; mRingerModeTracker = ringerModeTracker; + mStatusBarStateController = statusBarStateController; dumpManager.registerDumpable(getClass().getName(), this); mHandler = new Handler(mainLooper) { @@ -1855,8 +1860,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab boolean shouldListenForFace = shouldListenForFace(); if (mFaceRunningState == BIOMETRIC_STATE_RUNNING && !shouldListenForFace) { stopListeningForFace(); - } else if (mFaceRunningState != BIOMETRIC_STATE_RUNNING - && shouldListenForFace) { + } else if (mFaceRunningState != BIOMETRIC_STATE_RUNNING && shouldListenForFace) { startListeningForFace(); } } @@ -1894,7 +1898,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab * If face auth is allows to scan on this exact moment. */ public boolean shouldListenForFace() { - final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep; + final boolean statusBarShadeLocked = + mStatusBarStateController.getState() == StatusBarState.SHADE_LOCKED; + final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep + && !statusBarShadeLocked; final int user = getCurrentUser(); final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user); final boolean isLockDown = diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index c3106bb2e3f2e..b5609dde37c73 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -76,6 +76,8 @@ import com.android.keyguard.KeyguardUpdateMonitor.BiometricAuthenticated; import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dump.DumpManager; +import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.util.RingerModeTracker; @@ -141,6 +143,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { private RingerModeTracker mRingerModeTracker; @Mock private LiveData mRingerModeLiveData; + @Mock + private StatusBarStateController mStatusBarStateController; // Direct executor private Executor mBackgroundExecutor = Runnable::run; private TestableLooper mTestableLooper; @@ -417,6 +421,16 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); } + @Test + public void skipsAuthentication_whenStatusBarShadeLocked() { + when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE_LOCKED); + + mKeyguardUpdateMonitor.dispatchStartedWakingUp(); + mTestableLooper.processAllMessages(); + mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true); + verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt()); + } + @Test public void skipsAuthentication_whenEncryptedKeyguard() { when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn( @@ -715,7 +729,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { super(context, TestableLooper.get(KeyguardUpdateMonitorTest.this).getLooper(), mBroadcastDispatcher, mDumpManager, - mRingerModeTracker, mBackgroundExecutor); + mRingerModeTracker, mBackgroundExecutor, mStatusBarStateController); mStrongAuthTracker = KeyguardUpdateMonitorTest.this.mStrongAuthTracker; }