Merge "Refactor BiometricUnlockController mode/state control" into tm-dev

This commit is contained in:
Bill Lin
2022-03-23 01:27:47 +00:00
committed by Android (Google) Code Review
2 changed files with 30 additions and 30 deletions

View File

@@ -537,27 +537,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
mPendingShowBouncer = false;
}
@Override
public void onStartedGoingToSleep(int why) {
resetMode();
mFadedAwayAfterWakeAndUnlock = false;
mPendingAuthenticated = null;
}
@Override
public void onFinishedGoingToSleep(int why) {
Trace.beginSection("BiometricUnlockController#onFinishedGoingToSleep");
if (mPendingAuthenticated != null) {
PendingAuthenticated pendingAuthenticated = mPendingAuthenticated;
// Post this to make sure it's executed after the device is fully locked.
mHandler.post(() -> onBiometricAuthenticated(pendingAuthenticated.userId,
pendingAuthenticated.biometricSourceType,
pendingAuthenticated.isStrongBiometric));
mPendingAuthenticated = null;
}
Trace.endSection();
}
public boolean hasPendingAuthentication() {
return mPendingAuthenticated != null
&& mUpdateMonitor
@@ -752,13 +731,34 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
@VisibleForTesting
final WakefulnessLifecycle.Observer mWakefulnessObserver =
new WakefulnessLifecycle.Observer() {
@Override
public void onFinishedWakingUp() {
if (mPendingShowBouncer) {
BiometricUnlockController.this.showBouncer();
}
}
};
@Override
public void onFinishedWakingUp() {
if (mPendingShowBouncer) {
BiometricUnlockController.this.showBouncer();
}
}
@Override
public void onStartedGoingToSleep() {
resetMode();
mFadedAwayAfterWakeAndUnlock = false;
mPendingAuthenticated = null;
}
@Override
public void onFinishedGoingToSleep() {
Trace.beginSection("BiometricUnlockController#onFinishedGoingToSleep");
if (mPendingAuthenticated != null) {
PendingAuthenticated pendingAuthenticated = mPendingAuthenticated;
// Post this to make sure it's executed after the device is fully locked.
mHandler.post(() -> onBiometricAuthenticated(pendingAuthenticated.userId,
pendingAuthenticated.biometricSourceType,
pendingAuthenticated.isStrongBiometric));
mPendingAuthenticated = null;
}
Trace.endSection();
}
};
private final ScreenLifecycle.Observer mScreenObserver =
new ScreenLifecycle.Observer() {

View File

@@ -408,7 +408,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
@Test
public void onFinishedGoingToSleep_authenticatesWhenPending() {
when(mUpdateMonitor.isGoingToSleep()).thenReturn(true);
mBiometricUnlockController.onFinishedGoingToSleep(-1);
mBiometricUnlockController.mWakefulnessObserver.onFinishedGoingToSleep();
verify(mHandler, never()).post(any());
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
@@ -416,7 +416,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
// value of isUnlockingWithBiometricAllowed()
mBiometricUnlockController.onBiometricAuthenticated(1 /* userId */,
BiometricSourceType.FACE, true /* isStrongBiometric */);
mBiometricUnlockController.onFinishedGoingToSleep(-1);
mBiometricUnlockController.mWakefulnessObserver.onFinishedGoingToSleep();
verify(mHandler).post(captor.capture());
captor.getValue().run();
}