Merge "Fix race condition" into rvc-dev

This commit is contained in:
Lucas Dupin
2020-03-04 05:46:29 +00:00
committed by Android (Google) Code Review
2 changed files with 8 additions and 4 deletions

View File

@@ -394,10 +394,11 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
public void onFinishedGoingToSleep(int why) { public void onFinishedGoingToSleep(int why) {
Trace.beginSection("BiometricUnlockController#onFinishedGoingToSleep"); Trace.beginSection("BiometricUnlockController#onFinishedGoingToSleep");
if (mPendingAuthenticated != null) { if (mPendingAuthenticated != null) {
PendingAuthenticated pendingAuthenticated = mPendingAuthenticated;
// Post this to make sure it's executed after the device is fully locked. // Post this to make sure it's executed after the device is fully locked.
mHandler.post(() -> onBiometricAuthenticated(mPendingAuthenticated.userId, mHandler.post(() -> onBiometricAuthenticated(pendingAuthenticated.userId,
mPendingAuthenticated.biometricSourceType, pendingAuthenticated.biometricSourceType,
mPendingAuthenticated.isStrongBiometric)); pendingAuthenticated.isStrongBiometric));
mPendingAuthenticated = null; mPendingAuthenticated = null;
} }
Trace.endSection(); Trace.endSection();

View File

@@ -48,6 +48,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
@@ -325,11 +326,13 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
mBiometricUnlockController.onFinishedGoingToSleep(-1); mBiometricUnlockController.onFinishedGoingToSleep(-1);
verify(mHandler, never()).post(any()); verify(mHandler, never()).post(any());
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
// the value of isStrongBiometric doesn't matter here since we only care about the returned // the value of isStrongBiometric doesn't matter here since we only care about the returned
// value of isUnlockingWithBiometricAllowed() // value of isUnlockingWithBiometricAllowed()
mBiometricUnlockController.onBiometricAuthenticated(1 /* userId */, mBiometricUnlockController.onBiometricAuthenticated(1 /* userId */,
BiometricSourceType.FACE, true /* isStrongBiometric */); BiometricSourceType.FACE, true /* isStrongBiometric */);
mBiometricUnlockController.onFinishedGoingToSleep(-1); mBiometricUnlockController.onFinishedGoingToSleep(-1);
verify(mHandler).post(any()); verify(mHandler).post(captor.capture());
captor.getValue().run();
} }
} }