@Override
public void onFinishedGoingToSleep(int why) {
Trace.beginSection("BiometricUnlockController#onFinishedGoingToSleep");
- if (mPendingAuthenticatedUserId != -1) {
-
+ BiometricSourceType pendingType = mPendingAuthenticatedBioSourceType;
+ int pendingUserId = mPendingAuthenticatedUserId;
+ if (pendingUserId != -1 && pendingType != null) {
// Post this to make sure it's executed after the device is fully locked.
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- onBiometricAuthenticated(mPendingAuthenticatedUserId,
- mPendingAuthenticatedBioSourceType);
- }
- });
+ mHandler.post(() -> onBiometricAuthenticated(pendingUserId, pendingType));
}
mPendingAuthenticatedUserId = -1;
mPendingAuthenticatedBioSourceType = null;
package com.android.systemui.statusbar.phone;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.eq;
private UnlockMethodCache mUnlockMethodCache;
@Mock
private TunerService mTunerService;
+ @Mock
+ private Handler mHandler;
private BiometricUnlockController mBiometricUnlockController;
@Before
verify(mStatusBarKeyguardViewManager, never()).animateCollapsePanels(anyFloat());
}
+ @Test
+ public void onFinishedGoingToSleep_authenticatesWhenPending() {
+ when(mUpdateMonitor.isGoingToSleep()).thenReturn(true);
+ mBiometricUnlockController.onFinishedGoingToSleep(-1);
+ verify(mHandler, never()).post(any());
+
+ mBiometricUnlockController.onBiometricAuthenticated(1 /* userId */,
+ BiometricSourceType.FACE);
+ mBiometricUnlockController.onFinishedGoingToSleep(-1);
+ verify(mHandler).post(any());
+ }
+
private class TestableBiometricUnlockController extends BiometricUnlockController {
TestableBiometricUnlockController(boolean faceDismissesKeyguard) {
super(mContext, mDozeScrimController,
mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
- new Handler(), mUpdateMonitor, mTunerService, 0 /* wakeUpDelay */,
+ mHandler, mUpdateMonitor, mTunerService, 0 /* wakeUpDelay */,
faceDismissesKeyguard);
mFaceDismissesKeyguard = faceDismissesKeyguard;
}