From f9bc323633be6cf6ff10b71fc3b57b96e5a02042 Mon Sep 17 00:00:00 2001 From: josephpv Date: Wed, 21 Feb 2024 19:57:09 +0000 Subject: [PATCH] To skip face enrollment for PS unlock setup based on intent extra For private space lock setup as part of both PS setup and separate lock form private space settings we need to show only traditional unlock factors and Fingerprint but not show Face enrolment even on devices where Face unlock is supported by hardware. Once LSKF is enrolled it should be followed by Fingerprint enrollment flow and after that Face enrollment should not be shown and exit lock setup flow. Currently for separate profile lock setup ACTION_SET_NEW_PASSWORD intent is used in private space setup. With this intent the options of LSKF+fingerprint+Face is shown in devices supporting both fingerprint and face hardware. After the LSKF ennrollment BiometricEnrollActivity is started which continues with fingerprint and Face enrollment. With this change we are passing an extra along with the intent to enroll fingerprint only. Based on the intent extra value if set even if hardware support exists the lock enrollment for the profile will support only LSKF and fingerprint enrollment but not start Face enrollment. User will still have the option to enroll Face from the dedicated settings entrypoint in private space settings. Recording link : b/323839067#comment4 Bug: 323839067 Test: Manual, verified option for face enrollment is shown or not shown based on the intent extra. When extra is not passed the behaviour will be default. Change-Id: Idf92084052e02df9ca89f288c618796750e563e6 --- .../settings/biometrics/BiometricEnrollActivity.java | 7 ++++++- .../android/settings/password/ChooseLockGeneric.java | 12 ++++++++++-- .../settings/password/ChooseLockSettingsHelper.java | 2 ++ .../settings/password/SetNewPasswordActivity.java | 3 +++ .../settings/password/SetNewPasswordController.java | 6 +++++- .../PrivateProfileContextHelperActivity.java | 2 ++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java index 73e1af1bc8a..c9616f1802c 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java +++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java @@ -87,6 +87,10 @@ public class BiometricEnrollActivity extends InstrumentedActivity { // this only applies to fingerprint. public static final String EXTRA_SKIP_INTRO = "skip_intro"; + // Intent extra. If true, support fingerprint enrollment only and skip other biometric + // enrollment methods like face unlock. + public static final String EXTRA_FINGERPRINT_ENROLLMENT_ONLY = "fingerprint_enrollment_only"; + // Intent extra. If true, parental consent will be requested before user enrollment. public static final String EXTRA_REQUIRE_PARENTAL_CONSENT = "require_consent"; @@ -194,7 +198,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity { final PackageManager pm = getApplicationContext().getPackageManager(); mHasFeatureFingerprint = pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT); - mHasFeatureFace = pm.hasSystemFeature(PackageManager.FEATURE_FACE); + mHasFeatureFace = pm.hasSystemFeature(PackageManager.FEATURE_FACE) + && !(intent.getBooleanExtra(EXTRA_FINGERPRINT_ENROLLMENT_ONLY, false)); // Default behavior is to enroll BIOMETRIC_WEAK or above. See ACTION_BIOMETRIC_ENROLL. final int authenticators = getIntent().getIntExtra( diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java index 178c3872c21..c693ec31de4 100644 --- a/src/com/android/settings/password/ChooseLockGeneric.java +++ b/src/com/android/settings/password/ChooseLockGeneric.java @@ -33,6 +33,7 @@ import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_C import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY; +import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_WRITE_REPAIR_MODE_PW; @@ -63,6 +64,7 @@ import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AlertDialog; @@ -167,7 +169,7 @@ public class ChooseLockGeneric extends SettingsActivity { private boolean mWaitingForActivityResult = false; private LockscreenCredential mUserPassword; private FingerprintManager mFingerprintManager; - private FaceManager mFaceManager; + @Nullable private FaceManager mFaceManager; private int mUserId; private boolean mIsManagedProfile; private ManagedLockPasswordProvider mManagedPasswordProvider; @@ -206,6 +208,7 @@ public class ChooseLockGeneric extends SettingsActivity { private int mExtraLockScreenTitleResId; private int mExtraLockScreenDescriptionResId; private boolean mWaitingForBiometricEnrollment = false; + private boolean mEnrollFingerPrintOnly = false; @Override public int getMetricsCategory() { @@ -225,8 +228,10 @@ public class ChooseLockGeneric extends SettingsActivity { } final Intent intent = activity.getIntent(); String chooseLockAction = intent.getAction(); + mEnrollFingerPrintOnly = + intent.getBooleanExtra(EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY, false); mFingerprintManager = Utils.getFingerprintManagerOrNull(activity); - mFaceManager = Utils.getFaceManagerOrNull(activity); + mFaceManager = !mEnrollFingerPrintOnly ? Utils.getFaceManagerOrNull(activity) : null; mDpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); mLockPatternUtils = new LockPatternUtils(activity); mIsSetNewPassword = ACTION_SET_NEW_PARENT_PROFILE_PASSWORD.equals(chooseLockAction) @@ -530,6 +535,9 @@ public class ChooseLockGeneric extends SettingsActivity { final Intent intent = new Intent(context, BiometricEnrollActivity.InternalActivity.class); intent.putExtra(BiometricEnrollActivity.EXTRA_SKIP_INTRO, true); + if (mEnrollFingerPrintOnly) { + intent.putExtra(BiometricEnrollActivity.EXTRA_FINGERPRINT_ENROLLMENT_ONLY, true); + } return intent; } diff --git a/src/com/android/settings/password/ChooseLockSettingsHelper.java b/src/com/android/settings/password/ChooseLockSettingsHelper.java index e74b7767faa..91875cc88d6 100644 --- a/src/com/android/settings/password/ChooseLockSettingsHelper.java +++ b/src/com/android/settings/password/ChooseLockSettingsHelper.java @@ -64,6 +64,8 @@ public final class ChooseLockSettingsHelper { public static final String EXTRA_KEY_FOR_FACE = "for_face"; // For the paths where multiple biometric sensors exist public static final String EXTRA_KEY_FOR_BIOMETRICS = "for_biometrics"; + // To support fingerprint enrollment only and skip other biometric enrollments like face. + public static final String EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY = "for_fingerprint_only"; // For the paths where setup biometrics in suw flow public static final String EXTRA_KEY_IS_SUW = "is_suw"; public static final String EXTRA_KEY_FOREGROUND_ONLY = "foreground_only"; diff --git a/src/com/android/settings/password/SetNewPasswordActivity.java b/src/com/android/settings/password/SetNewPasswordActivity.java index 9614d280009..0ba52eab132 100644 --- a/src/com/android/settings/password/SetNewPasswordActivity.java +++ b/src/com/android/settings/password/SetNewPasswordActivity.java @@ -27,6 +27,7 @@ import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_C import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY; +import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY; @@ -132,6 +133,8 @@ public class SetNewPasswordActivity extends Activity implements SetNewPasswordCo getIntent().getIntExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, -1)); intent.putExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION, getIntent().getIntExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION, -1)); + intent.putExtra(EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY, + getIntent().getBooleanExtra(EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY, false)); if (mCallerAppName != null) { intent.putExtra(EXTRA_KEY_CALLER_APP_NAME, mCallerAppName); } diff --git a/src/com/android/settings/password/SetNewPasswordController.java b/src/com/android/settings/password/SetNewPasswordController.java index aa8fe5168bc..96c0b8edf37 100644 --- a/src/com/android/settings/password/SetNewPasswordController.java +++ b/src/com/android/settings/password/SetNewPasswordController.java @@ -21,6 +21,7 @@ import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FACE; import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT; import static com.android.internal.util.Preconditions.checkNotNull; +import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; @@ -79,7 +80,10 @@ final class SetNewPasswordController { } // Create a wrapper of FingerprintManager for testing, see IFingerPrintManager for details. final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(context); - final FaceManager faceManager = Utils.getFaceManagerOrNull(context); + final FaceManager faceManager = + !intent.getBooleanExtra(EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY, false) + ? Utils.getFaceManagerOrNull(context) + : null; return new SetNewPasswordController(userId, context.getPackageManager(), fingerprintManager, faceManager, diff --git a/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java b/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java index f2a50dc1e34..416b2dd7105 100644 --- a/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java +++ b/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java @@ -22,6 +22,7 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_LOW; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION; import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE; +import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY; import static com.android.settings.privatespace.PrivateSpaceSetupActivity.ACCOUNT_LOGIN_ACTION; import static com.android.settings.privatespace.PrivateSpaceSetupActivity.EXTRA_ACTION_TYPE; import static com.android.settings.privatespace.PrivateSpaceSetupActivity.SET_LOCK_ACTION; @@ -85,6 +86,7 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity { private void createPrivateSpaceLock() { final Intent intent = new Intent(ACTION_SET_NEW_PASSWORD); intent.putExtra(EXTRA_PASSWORD_COMPLEXITY, PASSWORD_COMPLEXITY_LOW); + intent.putExtra(EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY, true); intent.putExtra( EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, R.string.private_space_lock_setup_title); intent.putExtra(