2/n: Add default implementation for multi-biometric enroll
1) Adds a layout for multi-biometric selection in BiometricEnrollActivity 2) Adds widgets for checkboxes 3) Shows ConfirmLock*/ChooseLock* for multi-biometric devices in BiometricEnrollActivity 4) finish()'s when loses foreground 5) Adds default string for ChooseLock* and multi-biometrics, e.g. "Set up Password + Biometrics", as well as associated plumbing to bring the user back to BiometricEnrollActivity once the credential is enrolled 6) When max templates enrolled, checkbox becomes disabled and description string is updated Bug: 162341940 Bug: 152242790 Fixes: 161742393 No effect on existing devices with the following: Test: adb shell am start -a android.settings.BIOMETRIC_ENROLL Test: SUW Test: make -j RunSettingsRoboTests Exempt-From-Owner-Approval: Biometric-related change to EncryptionInterstitial Change-Id: I855460d50228ace24d4ec5fbe330f02ab406cc02
This commit is contained in:
@@ -23,6 +23,8 @@ import static org.robolectric.RuntimeEnvironment.application;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorProperties;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
@@ -53,6 +55,8 @@ import org.robolectric.shadows.ShadowActivity;
|
||||
import org.robolectric.shadows.ShadowActivity.IntentForResult;
|
||||
import org.robolectric.shadows.ShadowKeyguardManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {
|
||||
ShadowFingerprintManager.class,
|
||||
@@ -69,6 +73,14 @@ public class SetupFingerprintEnrollIntroductionTest {
|
||||
Shadows.shadowOf(application.getPackageManager())
|
||||
.setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
|
||||
|
||||
final FingerprintSensorProperties prop = new FingerprintSensorProperties(0 /* sensorId */,
|
||||
FingerprintSensorProperties.TYPE_REAR,
|
||||
true /* resetLockoutRequiresHardwareAuthToken */,
|
||||
5 /* maxTemplatesAllowed */);
|
||||
final ArrayList<FingerprintSensorProperties> props = new ArrayList<>();
|
||||
props.add(prop);
|
||||
ShadowFingerprintManager.setSensorProperties(props);
|
||||
|
||||
FakeFeatureFactory.setupForTest();
|
||||
|
||||
final Intent intent = new Intent();
|
||||
|
@@ -46,7 +46,7 @@ public class SetupSkipDialogTest {
|
||||
@Test
|
||||
public void frpMessages_areShownCorrectly_whenNotSupported() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(false, false, false, false, false);
|
||||
SetupSkipDialog.newInstance(false, false, false, false, false, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -61,7 +61,7 @@ public class SetupSkipDialogTest {
|
||||
@Test
|
||||
public void frpMessages_areShownCorrectly_whenSupported() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, false, false, false);
|
||||
SetupSkipDialog.newInstance(true, false, false, false, false, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -76,7 +76,7 @@ public class SetupSkipDialogTest {
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPinSetupForFace_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, false, false, true);
|
||||
SetupSkipDialog.newInstance(true, false, false, false, true, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -85,13 +85,14 @@ public class SetupSkipDialogTest {
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pin_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
assertThat(getSkipDialogMessage(false, true, false))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPasswordSetupForFace_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, true, false, true);
|
||||
SetupSkipDialog.newInstance(true, false, true, false, true, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -100,13 +101,14 @@ public class SetupSkipDialogTest {
|
||||
assertThat(mActivity.getString(R.string.lock_screen_password_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
assertThat(getSkipDialogMessage(false, true, false))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPatternSetupForFace_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, true, false, false, true);
|
||||
SetupSkipDialog.newInstance(true, true, false, false, true, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -115,13 +117,14 @@ public class SetupSkipDialogTest {
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pattern_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
assertThat(getSkipDialogMessage(false, true, false))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPinSetupForFingerprint_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, false, true, false);
|
||||
SetupSkipDialog.newInstance(true, false, false, true, false, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -130,13 +133,14 @@ public class SetupSkipDialogTest {
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pin_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(true)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
assertThat(getSkipDialogMessage(true, false, false))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPasswordSetupForFingerprint_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, true, true, false);
|
||||
SetupSkipDialog.newInstance(true, false, true, true, false, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -145,13 +149,14 @@ public class SetupSkipDialogTest {
|
||||
assertThat(mActivity.getString(R.string.lock_screen_password_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(true)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
assertThat(getSkipDialogMessage(true, false, false))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPatternSetupForFingerprint_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, true, false, true, false);
|
||||
SetupSkipDialog.newInstance(true, true, false, true, false, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -160,13 +165,71 @@ public class SetupSkipDialogTest {
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pattern_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(true)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
assertThat(getSkipDialogMessage(true, false, false))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
public String getSkipDialogMessage(boolean isFingerprintSupported) {
|
||||
return String.format(
|
||||
mActivity.getString(isFingerprintSupported ?
|
||||
R.string.fingerprint_lock_screen_setup_skip_dialog_text :
|
||||
R.string.face_lock_screen_setup_skip_dialog_text));
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPinSetupForBiometrics_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, false, false, false, true);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pin_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false, false, true))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPasswordSetupForBiometrics_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, true, false, false, true);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_password_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false, false, true))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPatternSetupForBiometrics_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, true, false, false, false, true);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pattern_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false, false, true))
|
||||
.isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
public String getSkipDialogMessage(boolean forFingerprint, boolean forFace,
|
||||
boolean forBiometrics) {
|
||||
final int resId;
|
||||
if (forFingerprint) {
|
||||
resId = R.string.fingerprint_lock_screen_setup_skip_dialog_text;
|
||||
} else if (forFace) {
|
||||
resId = R.string.face_lock_screen_setup_skip_dialog_text;
|
||||
} else if (forBiometrics) {
|
||||
resId = R.string.biometrics_lock_screen_setup_skip_dialog_text;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return String.format(mActivity.getString(resId));
|
||||
}
|
||||
}
|
||||
|
@@ -18,22 +18,30 @@ package com.android.settings.testutils.shadow;
|
||||
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorProperties;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Implements(FingerprintManager.class)
|
||||
public class ShadowFingerprintManager extends org.robolectric.shadows.ShadowFingerprintManager {
|
||||
|
||||
private static List<FingerprintSensorProperties> sFingerprintSensorProperties;
|
||||
|
||||
public static void setSensorProperties(List<FingerprintSensorProperties> props) {
|
||||
sFingerprintSensorProperties = props;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected List<Fingerprint> getEnrolledFingerprints(int userId) {
|
||||
return getEnrolledFingerprints();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected long generateChallengeBlocking() {
|
||||
return 0L;
|
||||
protected List<FingerprintSensorProperties> getSensorProperties() {
|
||||
return sFingerprintSensorProperties;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user