Merge "Don't reset the biometricUnlockState until the next time keyguard shows" into main
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 97fc35a..8b7b348 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
@@ -51,6 +51,9 @@
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.domain.interactor.BiometricUnlockInteractor;
+import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
+import com.android.systemui.keyguard.shared.model.KeyguardState;
+import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.res.R;
@@ -59,6 +62,7 @@
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
+import com.android.systemui.util.kotlin.JavaAdapter;
import com.android.systemui.util.time.SystemClock;
import dagger.Lazy;
@@ -286,7 +290,9 @@
VibratorHelper vibrator,
SystemClock systemClock,
Lazy<SelectedUserInteractor> selectedUserInteractor,
- BiometricUnlockInteractor biometricUnlockInteractor
+ BiometricUnlockInteractor biometricUnlockInteractor,
+ JavaAdapter javaAdapter,
+ KeyguardTransitionInteractor keyguardTransitionInteractor
) {
mPowerManager = powerManager;
mUpdateMonitor = keyguardUpdateMonitor;
@@ -317,10 +323,19 @@
mOrderUnlockAndWake = resources.getBoolean(
com.android.internal.R.bool.config_orderUnlockAndWake);
mSelectedUserInteractor = selectedUserInteractor;
-
+ javaAdapter.alwaysCollectFlow(
+ keyguardTransitionInteractor.getStartedKeyguardTransitionStep(),
+ this::consumeTransitionStepOnStartedKeyguardState);
dumpManager.registerDumpable(this);
}
+ @VisibleForTesting
+ protected void consumeTransitionStepOnStartedKeyguardState(TransitionStep transitionStep) {
+ if (transitionStep.getFrom() == KeyguardState.GONE) {
+ mBiometricUnlockInteractor.setBiometricUnlockState(MODE_NONE);
+ }
+ }
+
public void setKeyguardViewController(KeyguardViewController keyguardViewController) {
mKeyguardViewController = keyguardViewController;
}
@@ -773,7 +788,6 @@
for (BiometricUnlockEventsListener listener : mBiometricUnlockEventsListeners) {
listener.onResetMode();
}
- mBiometricUnlockInteractor.setBiometricUnlockState(MODE_NONE);
mNumConsecutiveFpFailures = 0;
mLastFpFailureUptimeMillis = 0;
}
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 6f65eb4..50f81ff 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
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.phone;
+import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_NONE;
import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK;
import static com.google.common.truth.Truth.assertThat;
@@ -26,6 +27,7 @@
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
@@ -51,6 +53,10 @@
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.domain.interactor.BiometricUnlockInteractor;
+import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
+import com.android.systemui.keyguard.shared.model.KeyguardState;
+import com.android.systemui.keyguard.shared.model.TransitionState;
+import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationMediaManager;
@@ -58,6 +64,7 @@
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
+import com.android.systemui.util.kotlin.JavaAdapter;
import com.android.systemui.util.time.FakeSystemClock;
import org.junit.Before;
@@ -158,7 +165,9 @@
mSessionTracker, mLatencyTracker, mScreenOffAnimationController, mVibratorHelper,
mSystemClock,
() -> mSelectedUserInteractor,
- mBiometricUnlockInteractor
+ mBiometricUnlockInteractor,
+ mock(JavaAdapter.class),
+ mock(KeyguardTransitionInteractor.class)
);
biometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
biometricUnlockController.addListener(mBiometricUnlockEventsListener);
@@ -462,6 +471,29 @@
}
@Test
+ public void biometricUnlockStateResetOnTransitionFromGone() {
+ mBiometricUnlockController.consumeTransitionStepOnStartedKeyguardState(
+ new TransitionStep(
+ KeyguardState.AOD,
+ KeyguardState.GONE,
+ .1f /* value */,
+ TransitionState.STARTED
+ )
+ );
+ verify(mBiometricUnlockInteractor, never()).setBiometricUnlockState(anyInt());
+
+ mBiometricUnlockController.consumeTransitionStepOnStartedKeyguardState(
+ new TransitionStep(
+ KeyguardState.GONE,
+ KeyguardState.AOD,
+ .1f /* value */,
+ TransitionState.STARTED
+ )
+ );
+ verify(mBiometricUnlockInteractor).setBiometricUnlockState(eq(MODE_NONE));
+ }
+
+ @Test
public void onFingerprintDetect_showBouncer() {
// WHEN fingerprint detect occurs
mBiometricUnlockController.onBiometricDetected(UserHandle.USER_CURRENT,