Merge "Cancel side auth on power press"
This commit is contained in:
committed by
Android (Google) Code Review
commit
a3608b5624
@@ -94,6 +94,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
private long mSideFpsLastAcquireStartTime;
|
||||
private Runnable mAuthSuccessRunnable;
|
||||
private final Clock mClock;
|
||||
private boolean mDidFinishSfps;
|
||||
|
||||
FingerprintAuthenticationClient(
|
||||
@NonNull Context context,
|
||||
@@ -203,8 +204,9 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
|
||||
@Override
|
||||
protected void handleLifecycleAfterAuth(boolean authenticated) {
|
||||
if (authenticated) {
|
||||
if (authenticated && !mDidFinishSfps) {
|
||||
mCallback.onClientFinished(this, true /* success */);
|
||||
mDidFinishSfps = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,12 +506,16 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
if (mSensorProps.isAnySidefpsType()) {
|
||||
Slog.i(TAG, "(sideFPS): onPowerPressed");
|
||||
mHandler.post(() -> {
|
||||
if (mDidFinishSfps) {
|
||||
return;
|
||||
}
|
||||
Slog.i(TAG, "(sideFPS): finishing auth");
|
||||
// Ignore auths after a power has been detected
|
||||
mHandler.removeMessages(MESSAGE_AUTH_SUCCESS);
|
||||
// Do not call onError() as that will send an additional callback to coex.
|
||||
onErrorInternal(BiometricConstants.BIOMETRIC_ERROR_POWER_PRESSED,
|
||||
0, true);
|
||||
mDidFinishSfps = true;
|
||||
onErrorInternal(BiometricConstants.BIOMETRIC_ERROR_POWER_PRESSED, 0, true);
|
||||
stopHalOperation();
|
||||
mSensorOverlays.hide(getSensorId());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -373,6 +373,7 @@ public class FingerprintAuthenticationClientTest {
|
||||
@Test
|
||||
public void fingerprintPowerIgnoresAuthInWindow() throws Exception {
|
||||
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
||||
when(mHal.authenticate(anyLong())).thenReturn(mCancellationSignal);
|
||||
|
||||
final FingerprintAuthenticationClient client = createClient(1);
|
||||
client.start(mCallback);
|
||||
@@ -383,11 +384,13 @@ public class FingerprintAuthenticationClientTest {
|
||||
mLooper.dispatchAll();
|
||||
|
||||
verify(mCallback).onClientFinished(any(), eq(false));
|
||||
verify(mCancellationSignal).cancel();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fingerprintAuthIgnoredWaitingForPower() throws Exception {
|
||||
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
||||
when(mHal.authenticate(anyLong())).thenReturn(mCancellationSignal);
|
||||
|
||||
final FingerprintAuthenticationClient client = createClient(1);
|
||||
client.start(mCallback);
|
||||
@@ -398,11 +401,13 @@ public class FingerprintAuthenticationClientTest {
|
||||
mLooper.dispatchAll();
|
||||
|
||||
verify(mCallback).onClientFinished(any(), eq(false));
|
||||
verify(mCancellationSignal).cancel();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fingerprintAuthSucceedsAfterPowerWindow() throws Exception {
|
||||
public void fingerprintAuthFailsWhenAuthAfterPower() throws Exception {
|
||||
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
||||
when(mHal.authenticate(anyLong())).thenReturn(mCancellationSignal);
|
||||
|
||||
final FingerprintAuthenticationClient client = createClient(1);
|
||||
client.start(mCallback);
|
||||
@@ -416,7 +421,9 @@ public class FingerprintAuthenticationClientTest {
|
||||
mLooper.moveTimeForward(1000);
|
||||
mLooper.dispatchAll();
|
||||
|
||||
verify(mCallback).onClientFinished(any(), eq(true));
|
||||
verify(mCallback, never()).onClientFinished(any(), eq(true));
|
||||
verify(mCallback).onClientFinished(any(), eq(false));
|
||||
when(mHal.authenticateWithContext(anyLong(), any())).thenReturn(mCancellationSignal);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user