Replace timeout errors with Face not recognized.
Also cleans up some invereted asserts in the tests. Bug: 287011195 Test: atest AuthControllerTest Test: manual (use BP test app with coex, authenticated without face and verify error message) (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:504c55a3d1cb7381017624a0bcbde912165c816c) Merged-In: Ia97e7f92000c82d121afba16a70ee3db33911815 Change-Id: Ia97e7f92000c82d121afba16a70ee3db33911815
This commit is contained in:
committed by
Cherrypicker Worker
parent
f691806de3
commit
3e869b8f69
@@ -1086,7 +1086,8 @@ public class AuthController implements CoreStartable, CommandQueue.Callbacks,
|
||||
if (DEBUG) Log.d(TAG, "onBiometricError, lockout");
|
||||
mCurrentDialog.animateToCredentialUI(true /* isError */);
|
||||
} else if (isSoftError) {
|
||||
final String errorMessage = (error == BiometricConstants.BIOMETRIC_PAUSED_REJECTED)
|
||||
final String errorMessage = (error == BiometricConstants.BIOMETRIC_PAUSED_REJECTED
|
||||
|| error == BiometricConstants.BIOMETRIC_ERROR_TIMEOUT)
|
||||
? getNotRecognizedString(modality)
|
||||
: getErrorString(modality, error, vendorCode);
|
||||
if (DEBUG) Log.d(TAG, "onBiometricError, soft error: " + errorMessage);
|
||||
|
||||
@@ -191,6 +191,10 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
private ArgumentCaptor<IFaceAuthenticatorsRegisteredCallback> mFaceAuthenticatorsRegisteredCaptor;
|
||||
@Captor
|
||||
private ArgumentCaptor<BiometricStateListener> mBiometricStateCaptor;
|
||||
@Captor
|
||||
private ArgumentCaptor<Integer> mModalityCaptor;
|
||||
@Captor
|
||||
private ArgumentCaptor<String> mMessageCaptor;
|
||||
@Mock
|
||||
private Resources mResources;
|
||||
|
||||
@@ -478,17 +482,26 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
BiometricConstants.BIOMETRIC_PAUSED_REJECTED,
|
||||
0 /* vendorCode */);
|
||||
|
||||
ArgumentCaptor<Integer> modalityCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mDialog1).onAuthenticationFailed(modalityCaptor.capture(), messageCaptor.capture());
|
||||
verify(mDialog1).onAuthenticationFailed(mModalityCaptor.capture(), mMessageCaptor.capture());
|
||||
|
||||
assertEquals(modalityCaptor.getValue().intValue(), modality);
|
||||
assertEquals(messageCaptor.getValue(),
|
||||
assertEquals(mModalityCaptor.getValue().intValue(), modality);
|
||||
assertEquals(mMessageCaptor.getValue(),
|
||||
mContext.getString(R.string.biometric_not_recognized));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnAuthenticationFailedInvoked_whenFaceAuthRejected() throws RemoteException {
|
||||
public void testOnAuthenticationFailedInvoked_coex_whenFaceAuthRejected_withPaused() {
|
||||
testOnAuthenticationFailedInvoked_coex_whenFaceAuthRejected(
|
||||
BiometricConstants.BIOMETRIC_PAUSED_REJECTED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnAuthenticationFailedInvoked_coex_whenFaceAuthRejected_withTimeout() {
|
||||
testOnAuthenticationFailedInvoked_coex_whenFaceAuthRejected(
|
||||
BiometricConstants.BIOMETRIC_ERROR_TIMEOUT);
|
||||
}
|
||||
|
||||
private void testOnAuthenticationFailedInvoked_coex_whenFaceAuthRejected(int error) {
|
||||
final int modality = BiometricAuthenticator.TYPE_FACE;
|
||||
final int userId = 0;
|
||||
|
||||
@@ -496,16 +509,12 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
|
||||
showDialog(new int[] {1} /* sensorIds */, false /* credentialAllowed */);
|
||||
|
||||
mAuthController.onBiometricError(modality,
|
||||
BiometricConstants.BIOMETRIC_PAUSED_REJECTED,
|
||||
0 /* vendorCode */);
|
||||
mAuthController.onBiometricError(modality, error, 0 /* vendorCode */);
|
||||
|
||||
ArgumentCaptor<Integer> modalityCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mDialog1).onAuthenticationFailed(modalityCaptor.capture(), messageCaptor.capture());
|
||||
verify(mDialog1).onAuthenticationFailed(mModalityCaptor.capture(), mMessageCaptor.capture());
|
||||
|
||||
assertEquals(modalityCaptor.getValue().intValue(), modality);
|
||||
assertEquals(messageCaptor.getValue(),
|
||||
assertThat(mModalityCaptor.getValue().intValue()).isEqualTo(modality);
|
||||
assertThat(mMessageCaptor.getValue()).isEqualTo(
|
||||
mContext.getString(R.string.biometric_face_not_recognized));
|
||||
}
|
||||
|
||||
@@ -522,12 +531,10 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
BiometricConstants.BIOMETRIC_PAUSED_REJECTED,
|
||||
0 /* vendorCode */);
|
||||
|
||||
ArgumentCaptor<Integer> modalityCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mDialog1).onAuthenticationFailed(modalityCaptor.capture(), messageCaptor.capture());
|
||||
verify(mDialog1).onAuthenticationFailed(mModalityCaptor.capture(), mMessageCaptor.capture());
|
||||
|
||||
assertEquals(modalityCaptor.getValue().intValue(), modality);
|
||||
assertEquals(messageCaptor.getValue(),
|
||||
assertThat(mModalityCaptor.getValue().intValue()).isEqualTo(modality);
|
||||
assertThat(mMessageCaptor.getValue()).isEqualTo(
|
||||
mContext.getString(R.string.fingerprint_error_not_match));
|
||||
}
|
||||
|
||||
@@ -539,13 +546,11 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
final int vendorCode = 0;
|
||||
mAuthController.onBiometricError(modality, error, vendorCode);
|
||||
|
||||
ArgumentCaptor<Integer> modalityCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mDialog1).onAuthenticationFailed(modalityCaptor.capture(), messageCaptor.capture());
|
||||
verify(mDialog1).onAuthenticationFailed(mModalityCaptor.capture(), mMessageCaptor.capture());
|
||||
|
||||
assertEquals(modalityCaptor.getValue().intValue(), modality);
|
||||
assertEquals(messageCaptor.getValue(),
|
||||
FaceManager.getErrorString(mContext, error, vendorCode));
|
||||
assertThat(mModalityCaptor.getValue().intValue()).isEqualTo(modality);
|
||||
assertThat(mMessageCaptor.getValue()).isEqualTo(
|
||||
mContext.getString(R.string.biometric_not_recognized));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -555,12 +560,10 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
final String helpMessage = "help";
|
||||
mAuthController.onBiometricHelp(modality, helpMessage);
|
||||
|
||||
ArgumentCaptor<Integer> modalityCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mDialog1).onHelp(modalityCaptor.capture(), messageCaptor.capture());
|
||||
verify(mDialog1).onHelp(mModalityCaptor.capture(), mMessageCaptor.capture());
|
||||
|
||||
assertEquals(modalityCaptor.getValue().intValue(), modality);
|
||||
assertEquals(messageCaptor.getValue(), helpMessage);
|
||||
assertThat(mModalityCaptor.getValue().intValue()).isEqualTo(modality);
|
||||
assertThat(mMessageCaptor.getValue()).isEqualTo(helpMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -571,12 +574,10 @@ public class AuthControllerTest extends SysuiTestCase {
|
||||
final int vendorCode = 0;
|
||||
mAuthController.onBiometricError(modality, error, vendorCode);
|
||||
|
||||
ArgumentCaptor<Integer> modalityCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mDialog1).onError(modalityCaptor.capture(), messageCaptor.capture());
|
||||
verify(mDialog1).onError(mModalityCaptor.capture(), mMessageCaptor.capture());
|
||||
|
||||
assertEquals(modalityCaptor.getValue().intValue(), modality);
|
||||
assertEquals(messageCaptor.getValue(),
|
||||
assertThat(mModalityCaptor.getValue().intValue()).isEqualTo(modality);
|
||||
assertThat(mMessageCaptor.getValue()).isEqualTo(
|
||||
FaceManager.getErrorString(mContext, error, vendorCode));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user