Merge "Cancel side auth on power press" into tm-qpr-dev am: 28b3fee28a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20414320 Change-Id: I8ca6cb172b9b296908478c72f7d4af92a8631bb3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -92,6 +92,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
|||||||
private long mSideFpsLastAcquireStartTime;
|
private long mSideFpsLastAcquireStartTime;
|
||||||
private Runnable mAuthSuccessRunnable;
|
private Runnable mAuthSuccessRunnable;
|
||||||
private final Clock mClock;
|
private final Clock mClock;
|
||||||
|
private boolean mDidFinishSfps;
|
||||||
|
|
||||||
FingerprintAuthenticationClient(
|
FingerprintAuthenticationClient(
|
||||||
@NonNull Context context,
|
@NonNull Context context,
|
||||||
@@ -197,8 +198,9 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleLifecycleAfterAuth(boolean authenticated) {
|
protected void handleLifecycleAfterAuth(boolean authenticated) {
|
||||||
if (authenticated) {
|
if (authenticated && !mDidFinishSfps) {
|
||||||
mCallback.onClientFinished(this, true /* success */);
|
mCallback.onClientFinished(this, true /* success */);
|
||||||
|
mDidFinishSfps = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,11 +492,16 @@ class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession>
|
|||||||
if (mSensorProps.isAnySidefpsType()) {
|
if (mSensorProps.isAnySidefpsType()) {
|
||||||
Slog.i(TAG, "(sideFPS): onPowerPressed");
|
Slog.i(TAG, "(sideFPS): onPowerPressed");
|
||||||
mHandler.post(() -> {
|
mHandler.post(() -> {
|
||||||
|
if (mDidFinishSfps) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Slog.i(TAG, "(sideFPS): finishing auth");
|
Slog.i(TAG, "(sideFPS): finishing auth");
|
||||||
// Ignore auths after a power has been detected
|
// Ignore auths after a power has been detected
|
||||||
mHandler.removeMessages(MESSAGE_AUTH_SUCCESS);
|
mHandler.removeMessages(MESSAGE_AUTH_SUCCESS);
|
||||||
// Do not call onError() as that will send an additional callback to coex.
|
// Do not call onError() as that will send an additional callback to coex.
|
||||||
|
mDidFinishSfps = true;
|
||||||
onErrorInternal(BiometricConstants.BIOMETRIC_ERROR_POWER_PRESSED, 0, true);
|
onErrorInternal(BiometricConstants.BIOMETRIC_ERROR_POWER_PRESSED, 0, true);
|
||||||
|
stopHalOperation();
|
||||||
mSensorOverlays.hide(getSensorId());
|
mSensorOverlays.hide(getSensorId());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ public class FingerprintAuthenticationClientTest {
|
|||||||
@Test
|
@Test
|
||||||
public void fingerprintPowerIgnoresAuthInWindow() throws Exception {
|
public void fingerprintPowerIgnoresAuthInWindow() throws Exception {
|
||||||
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
||||||
|
when(mHal.authenticate(anyLong())).thenReturn(mCancellationSignal);
|
||||||
|
|
||||||
final FingerprintAuthenticationClient client = createClient(1);
|
final FingerprintAuthenticationClient client = createClient(1);
|
||||||
client.start(mCallback);
|
client.start(mCallback);
|
||||||
@@ -382,11 +383,13 @@ public class FingerprintAuthenticationClientTest {
|
|||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
|
||||||
verify(mCallback).onClientFinished(any(), eq(false));
|
verify(mCallback).onClientFinished(any(), eq(false));
|
||||||
|
verify(mCancellationSignal).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fingerprintAuthIgnoredWaitingForPower() throws Exception {
|
public void fingerprintAuthIgnoredWaitingForPower() throws Exception {
|
||||||
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
||||||
|
when(mHal.authenticate(anyLong())).thenReturn(mCancellationSignal);
|
||||||
|
|
||||||
final FingerprintAuthenticationClient client = createClient(1);
|
final FingerprintAuthenticationClient client = createClient(1);
|
||||||
client.start(mCallback);
|
client.start(mCallback);
|
||||||
@@ -397,11 +400,13 @@ public class FingerprintAuthenticationClientTest {
|
|||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
|
||||||
verify(mCallback).onClientFinished(any(), eq(false));
|
verify(mCallback).onClientFinished(any(), eq(false));
|
||||||
|
verify(mCancellationSignal).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fingerprintAuthSucceedsAfterPowerWindow() throws Exception {
|
public void fingerprintAuthFailsWhenAuthAfterPower() throws Exception {
|
||||||
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
when(mSensorProps.isAnySidefpsType()).thenReturn(true);
|
||||||
|
when(mHal.authenticate(anyLong())).thenReturn(mCancellationSignal);
|
||||||
|
|
||||||
final FingerprintAuthenticationClient client = createClient(1);
|
final FingerprintAuthenticationClient client = createClient(1);
|
||||||
client.start(mCallback);
|
client.start(mCallback);
|
||||||
@@ -415,7 +420,9 @@ public class FingerprintAuthenticationClientTest {
|
|||||||
mLooper.moveTimeForward(1000);
|
mLooper.moveTimeForward(1000);
|
||||||
mLooper.dispatchAll();
|
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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user