From fa293158620d033e89b9d8d6625d93e354b3577d Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Mon, 17 Mar 2025 06:19:43 +0000 Subject: [PATCH] Update mIsFaceEnrollable after face enrollment Since face enrollment can be launched first, the mIsFaceEnrollable may be changed during the multiple enrollment process. We should update this whenever a face is enrolled. Bug: 370940762 Test: 1. no face and fingerprint enrolled 2. click the "Face" in "Device unlock" to launch the multiple enrollments 3. enroll a face and in fingerprint enrollment process, trigger back key 4. should return to "Device unlock" page Flag: com.android.settings.flags.biometrics_onboarding_education Change-Id: I21ed3d21cd81f1d5c121111e2353cf4a9eb5bce6 --- .../biometrics/BiometricEnrollActivity.java | 75 +++++++++++-------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java index 83f23bdcf7a..5fb3660889f 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java +++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java @@ -230,39 +230,9 @@ public class BiometricEnrollActivity extends InstrumentedActivity { + ", isSetupWizard: " + isSetupWizard + ", isMultiSensor: " + isMultiSensor); - if (mHasFeatureFace) { - final FaceManager faceManager = getSystemService(FaceManager.class); - final List faceProperties = - faceManager.getSensorPropertiesInternal(); - final int maxFacesEnrollableIfSUW = getApplicationContext().getResources() - .getInteger(R.integer.suw_max_faces_enrollable); - if (!faceProperties.isEmpty()) { - final FaceSensorPropertiesInternal props = faceProperties.get(0); - final int maxEnrolls = - isSetupWizard ? maxFacesEnrollableIfSUW : props.maxEnrollmentsPerUser; - final boolean isFaceStrong = - props.sensorStrength == SensorProperties.STRENGTH_STRONG; - mIsFaceEnrollable = - faceManager.getEnrolledFaces(mUserId).size() < maxEnrolls; - // If we expect strong bio only, check if face is strong - if (authenticators == Authenticators.BIOMETRIC_STRONG && !isFaceStrong) { - mIsFaceEnrollable = false; - } - - final boolean parentalConsent = isSetupWizard || (mParentalOptionsRequired - && !WizardManagerHelper.isUserSetupComplete(this)); - if (parentalConsent && isMultiSensor && mIsFaceEnrollable) { - // Exclude face enrollment from setup wizard if feature config not supported - // in setup wizard flow, we still allow user enroll faces through settings. - mIsFaceEnrollable = FeatureFactory.getFeatureFactory() - .getFaceFeatureProvider() - .isSetupWizardSupported(getApplicationContext()); - Log.d(TAG, "config_suw_support_face_enroll: " + mIsFaceEnrollable); - } - } - } updateFingerprintEnrollable(isSetupWizard); + updateFaceEnrollable(isSetupWizard); // TODO(b/195128094): remove this restriction // Consent can only be recorded when this activity is launched directly from the kids @@ -328,6 +298,44 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } } + private void updateFaceEnrollable(boolean isSetupWizard) { + if (mHasFeatureFace) { + final FaceManager faceManager = getSystemService(FaceManager.class); + final List faceProperties = + faceManager.getSensorPropertiesInternal(); + final int maxFacesEnrollableIfSUW = getApplicationContext().getResources() + .getInteger(R.integer.suw_max_faces_enrollable); + if (!faceProperties.isEmpty()) { + final FaceSensorPropertiesInternal props = faceProperties.get(0); + final int maxEnrolls = + isSetupWizard ? maxFacesEnrollableIfSUW : props.maxEnrollmentsPerUser; + final boolean isFaceStrong = + props.sensorStrength == SensorProperties.STRENGTH_STRONG; + mIsFaceEnrollable = + faceManager.getEnrolledFaces(mUserId).size() < maxEnrolls; + + final int authenticators = getIntent().getIntExtra( + EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_WEAK); + // If we expect strong bio only, check if face is strong + if (authenticators == Authenticators.BIOMETRIC_STRONG && !isFaceStrong) { + mIsFaceEnrollable = false; + } + + final boolean isMultiSensor = mHasFeatureFace && mHasFeatureFingerprint; + final boolean parentalConsent = isSetupWizard || (mParentalOptionsRequired + && !WizardManagerHelper.isUserSetupComplete(this)); + if (parentalConsent && isMultiSensor && mIsFaceEnrollable) { + // Exclude face enrollment from setup wizard if feature config not supported + // in setup wizard flow, we still allow user enroll faces through settings. + mIsFaceEnrollable = FeatureFactory.getFeatureFactory() + .getFaceFeatureProvider() + .isSetupWizardSupported(getApplicationContext()); + Log.d(TAG, "config_suw_support_face_enroll: " + mIsFaceEnrollable); + } + } + } + } + private void startEnrollWith(@Authenticators.Types int authenticators, boolean setupWizard) { // If the caller is not setup wizard, and the user has something enrolled, finish. // Allow parental consent flow to skip this check, since one modality could be consented @@ -575,6 +583,11 @@ public class BiometricEnrollActivity extends InstrumentedActivity { break; case REQUEST_SINGLE_ENROLL_FACE: mIsSingleEnrolling = false; + if (resultCode == BiometricEnrollBase.RESULT_FINISHED) { + // FaceEnrollIntroduction's visibility is determined by mIsFaceEnrollable. + // Keep this value up-to-date after a successful enrollment. + updateFaceEnrollable(WizardManagerHelper.isAnySetupWizard(getIntent())); + } if ((resultCode == BiometricEnrollBase.RESULT_SKIP || resultCode == BiometricEnrollBase.RESULT_FINISHED) && mIsFingerprintEnrollable && mLaunchFaceEnrollFirst) {