[Biometric Onboarding & Edu] Support check enrolled fingerprint

- Add a new PreferenceItem for check enrolled fingerprint
- Create a new DialogFragment for the check enrolled
  fingerprint with functions:
  - request an authentication to FingerprintManager
  - highlight the item when a authentication successes
  - show error text when authentication fails
  - close the authentication

Bug: 370940762
Test: atest FingerprintSettingsFragmentTest
Flag: com.android.settings.flags.biometrics_onboarding_education

Change-Id: I90637e4ec20ea46e6f530ffd7ba79df9c31eda6b
This commit is contained in:
Shawn Lin
2024-11-29 06:08:06 +00:00
parent ba8348c6a2
commit 4bfbb8782a
7 changed files with 596 additions and 1 deletions

View File

@@ -17,6 +17,7 @@
package com.android.settings.biometrics.fingerprint;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_POWER_BUTTON;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_REAR;
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL;
import static com.android.settings.biometrics.BiometricEnrollBase.BIOMETRIC_AUTH_REQUEST;
@@ -354,6 +355,48 @@ public class FingerprintSettingsFragmentTest {
assertThat(addPref.isEnabled()).isTrue();
}
@Test
@EnableFlags(com.android.settings.flags.Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
public void testCheckEnrolledShown_whenAtLeastOneFingerprintEnrolled_Udfps() {
final Fingerprint fingerprint = new Fingerprint("Test", 0, 0);
doReturn(List.of(fingerprint)).when(mFingerprintManager).getEnrolledFingerprints(anyInt());
setUpFragment(false, PRIMARY_USER_ID, TYPE_UDFPS_OPTICAL, 5);
shadowOf(Looper.getMainLooper()).idle();
final Preference checkEnrolledPerf =
mFragment.findPreference("key_fingerprint_check_enrolled");
assertThat(checkEnrolledPerf).isNotNull();
assertThat(checkEnrolledPerf.isVisible()).isTrue();
}
@Test
@EnableFlags(com.android.settings.flags.Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
public void testCheckEnrolledHide_whenNoFingerprintEnrolled_Udfps() {
doReturn(List.of()).when(mFingerprintManager).getEnrolledFingerprints(anyInt());
setUpFragment(false, PRIMARY_USER_ID, TYPE_UDFPS_OPTICAL, 5);
shadowOf(Looper.getMainLooper()).idle();
final Preference checkEnrolledPerf =
mFragment.findPreference("key_fingerprint_check_enrolled");
assertThat(checkEnrolledPerf).isNull();
}
@Test
@EnableFlags(com.android.settings.flags.Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
public void testCheckEnrolledHide_nonUdfps() {
final Fingerprint fingerprint = new Fingerprint("Test", 0, 0);
doReturn(List.of(fingerprint)).when(mFingerprintManager).getEnrolledFingerprints(anyInt());
setUpFragment(false, PRIMARY_USER_ID, TYPE_REAR, 5);
shadowOf(Looper.getMainLooper()).idle();
final Preference checkEnrolledPerf =
mFragment.findPreference("key_fingerprint_check_enrolled");
assertThat(checkEnrolledPerf).isNull();
}
private void setSensor(@FingerprintSensorProperties.SensorType int sensorType,
int maxFingerprints) {
final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();