summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Diya Bera <diyab@google.com> 2023-11-16 14:18:06 -0800
committer Diya Bera <diyab@google.com> 2023-11-20 11:38:21 -0800
commit371a05afdb93fc36f9907ddd965ac59fedd196e9 (patch)
tree44f2e78adc915af1e9ad1c534dea58306aa08337
parentbe10ee5a41e3a05f516ab28ab635a42ebdf136b1 (diff)
Start fingerprint after face fails quickly
Flag: NONE Test: atest AuthControllerTest AuthSessionTest Bug: 303839389 Change-Id: I77afe09f7cc6e8cb5b04b76b97bb91eb81457e15
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java16
-rw-r--r--services/core/java/com/android/server/biometrics/AuthSession.java2
-rw-r--r--services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java41
4 files changed, 59 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
index 57e252dd9929..8fe42b536b1e 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
@@ -100,7 +100,6 @@ import javax.inject.Inject;
import javax.inject.Provider;
import kotlin.Unit;
-
import kotlinx.coroutines.CoroutineScope;
/**
@@ -1099,6 +1098,7 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
// TODO(b/141025588): Create separate methods for handling hard and soft errors.
final boolean isSoftError = (error == BiometricConstants.BIOMETRIC_PAUSED_REJECTED
|| error == BiometricConstants.BIOMETRIC_ERROR_TIMEOUT
+ || error == BiometricConstants.BIOMETRIC_ERROR_RE_ENROLL
|| isCameraPrivacyEnabled);
if (mCurrentDialog != null) {
if (mCurrentDialog.isAllowDeviceCredentials() && isLockout) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java
index 11c5d3bb27b3..602f3dc29491 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java
@@ -475,6 +475,22 @@ public class AuthControllerTest extends SysuiTestCase {
}
@Test
+ public void testOnAuthenticationFailedInvoked_whenBiometricReEnrollRequired() {
+ showDialog(new int[] {1} /* sensorIds */, false /* credentialAllowed */);
+ final int modality = BiometricAuthenticator.TYPE_FACE;
+ mAuthController.onBiometricError(modality,
+ BiometricConstants.BIOMETRIC_ERROR_RE_ENROLL,
+ 0 /* vendorCode */);
+
+ verify(mDialog1).onAuthenticationFailed(mModalityCaptor.capture(),
+ mMessageCaptor.capture());
+
+ assertThat(mModalityCaptor.getValue()).isEqualTo(modality);
+ assertThat(mMessageCaptor.getValue()).isEqualTo(mContext.getString(
+ R.string.face_recalibrate_notification_content));
+ }
+
+ @Test
public void testOnAuthenticationFailedInvoked_coex_whenFaceAuthRejected_withPaused() {
testOnAuthenticationFailedInvoked_coex_whenFaceAuthRejected(
BiometricConstants.BIOMETRIC_PAUSED_REJECTED);
diff --git a/services/core/java/com/android/server/biometrics/AuthSession.java b/services/core/java/com/android/server/biometrics/AuthSession.java
index b9ccbfbf55e7..c5073001a672 100644
--- a/services/core/java/com/android/server/biometrics/AuthSession.java
+++ b/services/core/java/com/android/server/biometrics/AuthSession.java
@@ -576,7 +576,7 @@ public final class AuthSession implements IBinder.DeathRecipient {
}
void onDialogAnimatedIn(boolean startFingerprintNow) {
- if (mState != STATE_AUTH_STARTED) {
+ if (mState != STATE_AUTH_STARTED && mState != STATE_ERROR_PENDING_SYSUI) {
Slog.e(TAG, "onDialogAnimatedIn, unexpected state: " + mState);
return;
}
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java b/services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java
index 0f3daec263e0..74eb79d7554c 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java
@@ -28,6 +28,8 @@ import static com.android.server.biometrics.BiometricServiceStateProto.STATE_AUT
import static com.android.server.biometrics.BiometricServiceStateProto.STATE_AUTH_STARTED_UI_SHOWING;
import static com.android.server.biometrics.BiometricServiceStateProto.STATE_ERROR_PENDING_SYSUI;
+import static com.google.common.truth.Truth.assertThat;
+
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@@ -248,6 +250,45 @@ public class AuthSessionTest {
}
@Test
+ public void testOnErrorReceivedBeforeOnDialogAnimatedIn() throws RemoteException {
+ final int fingerprintId = 0;
+ final int faceId = 1;
+ setupFingerprint(fingerprintId, FingerprintSensorProperties.TYPE_REAR);
+ setupFace(faceId, true /* confirmationAlwaysRequired */,
+ mock(IBiometricAuthenticator.class));
+ final AuthSession session = createAuthSession(mSensors,
+ false /* checkDevicePolicyManager */,
+ Authenticators.BIOMETRIC_STRONG,
+ TEST_REQUEST_ID,
+ 0 /* operationId */,
+ 0 /* userId */);
+ session.goToInitialState();
+
+ for (BiometricSensor sensor : session.mPreAuthInfo.eligibleSensors) {
+ assertThat(sensor.getSensorState()).isEqualTo(BiometricSensor.STATE_WAITING_FOR_COOKIE);
+ session.onCookieReceived(
+ session.mPreAuthInfo.eligibleSensors.get(sensor.id).getCookie());
+ }
+ assertThat(session.allCookiesReceived()).isTrue();
+ assertThat(session.getState()).isEqualTo(STATE_AUTH_STARTED);
+
+ final BiometricSensor faceSensor = session.mPreAuthInfo.eligibleSensors.get(faceId);
+ final BiometricSensor fingerprintSensor = session.mPreAuthInfo.eligibleSensors.get(
+ fingerprintId);
+ final int cookie = faceSensor.getCookie();
+ session.onErrorReceived(0, cookie, BiometricConstants.BIOMETRIC_ERROR_RE_ENROLL, 0);
+
+ assertThat(faceSensor.getSensorState()).isEqualTo(BiometricSensor.STATE_STOPPED);
+ assertThat(session.getState()).isEqualTo(STATE_ERROR_PENDING_SYSUI);
+
+ session.onDialogAnimatedIn(true);
+
+ assertThat(session.getState()).isEqualTo(STATE_AUTH_STARTED_UI_SHOWING);
+ assertThat(fingerprintSensor.getSensorState()).isEqualTo(
+ BiometricSensor.STATE_AUTHENTICATING);
+ }
+
+ @Test
public void testCancelReducesAppetiteForCookies() throws Exception {
setupFace(0 /* id */, false /* confirmationAlwaysRequired */,
mock(IBiometricAuthenticator.class));