Run lock before single sensor enroll

Run setOrConfirmCredentialsNow() before enrolling for devices w/
single-sensor

Bug: 239105333
Test: atest BiometricEnrollActivityTest
Test: Manually test multi-sensor and single-sensor devices
Change-Id: I807418c842eb076974f839a0d08bae67d3bc51dc
This commit is contained in:
Milton Wu
2022-07-19 12:28:53 +00:00
parent bb3f1526f8
commit 81626fb1c8

View File

@@ -93,8 +93,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
public static final String EXTRA_PARENTAL_CONSENT_STATUS = "consent_status"; public static final String EXTRA_PARENTAL_CONSENT_STATUS = "consent_status";
private static final String SAVED_STATE_CONFIRMING_CREDENTIALS = "confirming_credentials"; private static final String SAVED_STATE_CONFIRMING_CREDENTIALS = "confirming_credentials";
private static final String SAVED_STATE_FINGERPRINT_ONLY_ENROLLING = private static final String SAVED_STATE_IS_SINGLE_ENROLLING =
"fingerprint_only_enrolling"; "is_single_enrolling";
private static final String SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW = private static final String SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW =
"pass_through_extras_from_chosen_lock_in_suw"; "pass_through_extras_from_chosen_lock_in_suw";
private static final String SAVED_STATE_ENROLL_ACTION_LOGGED = "enroll_action_logged"; private static final String SAVED_STATE_ENROLL_ACTION_LOGGED = "enroll_action_logged";
@@ -105,7 +105,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
private int mUserId = UserHandle.myUserId(); private int mUserId = UserHandle.myUserId();
private boolean mConfirmingCredentials; private boolean mConfirmingCredentials;
private boolean mFingerprintOnlyEnrolling; private boolean mIsSingleEnrolling;
private Bundle mPassThroughExtrasFromChosenLockInSuw = null; private Bundle mPassThroughExtrasFromChosenLockInSuw = null;
private boolean mIsEnrollActionLogged; private boolean mIsEnrollActionLogged;
private boolean mHasFeatureFace = false; private boolean mHasFeatureFace = false;
@@ -135,8 +135,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
if (savedInstanceState != null) { if (savedInstanceState != null) {
mConfirmingCredentials = savedInstanceState.getBoolean( mConfirmingCredentials = savedInstanceState.getBoolean(
SAVED_STATE_CONFIRMING_CREDENTIALS, false); SAVED_STATE_CONFIRMING_CREDENTIALS, false);
mFingerprintOnlyEnrolling = savedInstanceState.getBoolean( mIsSingleEnrolling = savedInstanceState.getBoolean(
SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, false); SAVED_STATE_IS_SINGLE_ENROLLING, false);
mPassThroughExtrasFromChosenLockInSuw = savedInstanceState.getBundle( mPassThroughExtrasFromChosenLockInSuw = savedInstanceState.getBundle(
SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW); SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW);
mIsEnrollActionLogged = savedInstanceState.getBoolean( mIsEnrollActionLogged = savedInstanceState.getBoolean(
@@ -305,20 +305,16 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
if (!setupWizard && authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) { if (!setupWizard && authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) {
launchCredentialOnlyEnroll(); launchCredentialOnlyEnroll();
finish(); finish();
} else if (canUseFace && canUseFingerprint) { } else if (canUseFace || canUseFingerprint) {
if (mGkPwHandle != null) { if (mGkPwHandle == null) {
launchFaceAndFingerprintEnroll();
} else {
setOrConfirmCredentialsNow(); setOrConfirmCredentialsNow();
} } else if (canUseFace && canUseFingerprint) {
} else if (canUseFingerprint) { launchFaceAndFingerprintEnroll();
if (mGkPwHandle != null) { } else if (canUseFingerprint) {
launchFingerprintOnlyEnroll(); launchFingerprintOnlyEnroll();
} else { } else {
setOrConfirmCredentialsNow(); launchFaceOnlyEnroll();
} }
} else if (canUseFace) {
launchFaceOnlyEnroll();
} else { // no modalities available } else { // no modalities available
if (mParentalOptionsRequired) { if (mParentalOptionsRequired) {
Log.d(TAG, "No consent for any modality: skipping enrollment"); Log.d(TAG, "No consent for any modality: skipping enrollment");
@@ -334,7 +330,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
protected void onSaveInstanceState(@NonNull Bundle outState) { protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putBoolean(SAVED_STATE_CONFIRMING_CREDENTIALS, mConfirmingCredentials); outState.putBoolean(SAVED_STATE_CONFIRMING_CREDENTIALS, mConfirmingCredentials);
outState.putBoolean(SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, mFingerprintOnlyEnrolling); outState.putBoolean(SAVED_STATE_IS_SINGLE_ENROLLING, mIsSingleEnrolling);
outState.putBundle(SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW, outState.putBundle(SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW,
mPassThroughExtrasFromChosenLockInSuw); mPassThroughExtrasFromChosenLockInSuw);
outState.putBoolean(SAVED_STATE_ENROLL_ACTION_LOGGED, mIsEnrollActionLogged); outState.putBoolean(SAVED_STATE_ENROLL_ACTION_LOGGED, mIsEnrollActionLogged);
@@ -455,14 +451,15 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
mConfirmingCredentials = false; mConfirmingCredentials = false;
final boolean isOk = final boolean isOk =
isSuccessfulConfirmOrChooseCredential(requestCode, resultCode); isSuccessfulConfirmOrChooseCredential(requestCode, resultCode);
// single face enrollment requests confirmation directly if (isOk && (mHasFeatureFace || mHasFeatureFingerprint)) {
// via BiometricEnrollBase#onCreate and should never get here
if (isOk && mHasFeatureFace && mHasFeatureFingerprint) {
updateGatekeeperPasswordHandle(data); updateGatekeeperPasswordHandle(data);
launchFaceAndFingerprintEnroll(); if (mHasFeatureFace && mHasFeatureFingerprint) {
} else if (isOk && mHasFeatureFingerprint) { launchFaceAndFingerprintEnroll();
updateGatekeeperPasswordHandle(data); } else if (mHasFeatureFingerprint) {
launchFingerprintOnlyEnroll(); launchFingerprintOnlyEnroll();
} else {
launchFaceOnlyEnroll();
}
} else { } else {
Log.d(TAG, "Unknown result for set/choose lock: " + resultCode); Log.d(TAG, "Unknown result for set/choose lock: " + resultCode);
setResult(resultCode, newResultIntent()); setResult(resultCode, newResultIntent());
@@ -470,7 +467,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
} }
break; break;
case REQUEST_SINGLE_ENROLL: case REQUEST_SINGLE_ENROLL:
mFingerprintOnlyEnrolling = false; mIsSingleEnrolling = false;
finishOrLaunchHandToParent(resultCode); finishOrLaunchHandToParent(resultCode);
break; break;
default: default:
@@ -611,8 +608,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
} }
private void launchFingerprintOnlyEnroll() { private void launchFingerprintOnlyEnroll() {
if (!mFingerprintOnlyEnrolling) { if (!mIsSingleEnrolling) {
mFingerprintOnlyEnrolling = true; mIsSingleEnrolling = true;
final Intent intent; final Intent intent;
// ChooseLockGeneric can request to start fingerprint enroll bypassing the intro screen. // ChooseLockGeneric can request to start fingerprint enroll bypassing the intro screen.
if (getIntent().getBooleanExtra(EXTRA_SKIP_INTRO, false) if (getIntent().getBooleanExtra(EXTRA_SKIP_INTRO, false)
@@ -626,8 +623,11 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
} }
private void launchFaceOnlyEnroll() { private void launchFaceOnlyEnroll() {
final Intent intent = BiometricUtils.getFaceIntroIntent(this, getIntent()); if (!mIsSingleEnrolling) {
launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL); mIsSingleEnrolling = true;
final Intent intent = BiometricUtils.getFaceIntroIntent(this, getIntent());
launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL);
}
} }
private void launchFaceAndFingerprintEnroll() { private void launchFaceAndFingerprintEnroll() {