Merge "Run lock before fingerprint enroll" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-07-15 00:37:04 +00:00
committed by Android (Google) Code Review

View File

@@ -93,6 +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 =
"fingerprint_only_enrolling";
private static final String SAVED_STATE_ENROLL_ACTION_LOGGED = "enroll_action_logged"; private static final String SAVED_STATE_ENROLL_ACTION_LOGGED = "enroll_action_logged";
private static final String SAVED_STATE_PARENTAL_OPTIONS = "enroll_preferences"; private static final String SAVED_STATE_PARENTAL_OPTIONS = "enroll_preferences";
private static final String SAVED_STATE_GK_PW_HANDLE = "gk_pw_handle"; private static final String SAVED_STATE_GK_PW_HANDLE = "gk_pw_handle";
@@ -101,6 +103,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 mIsEnrollActionLogged; private boolean mIsEnrollActionLogged;
private boolean mHasFeatureFace = false; private boolean mHasFeatureFace = false;
private boolean mHasFeatureFingerprint = false; private boolean mHasFeatureFingerprint = false;
@@ -129,6 +132,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(
SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, false);
mIsEnrollActionLogged = savedInstanceState.getBoolean( mIsEnrollActionLogged = savedInstanceState.getBoolean(
SAVED_STATE_ENROLL_ACTION_LOGGED, false); SAVED_STATE_ENROLL_ACTION_LOGGED, false);
mParentalOptions = savedInstanceState.getBundle(SAVED_STATE_PARENTAL_OPTIONS); mParentalOptions = savedInstanceState.getBundle(SAVED_STATE_PARENTAL_OPTIONS);
@@ -302,7 +307,11 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
setOrConfirmCredentialsNow(); setOrConfirmCredentialsNow();
} }
} else if (canUseFingerprint) { } else if (canUseFingerprint) {
launchFingerprintOnlyEnroll(); if (mGkPwHandle != null) {
launchFingerprintOnlyEnroll();
} else {
setOrConfirmCredentialsNow();
}
} else if (canUseFace) { } else if (canUseFace) {
launchFaceOnlyEnroll(); launchFaceOnlyEnroll();
} else { // no modalities available } else { // no modalities available
@@ -320,6 +329,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_ENROLL_ACTION_LOGGED, mIsEnrollActionLogged); outState.putBoolean(SAVED_STATE_ENROLL_ACTION_LOGGED, mIsEnrollActionLogged);
if (mParentalOptions != null) { if (mParentalOptions != null) {
outState.putBundle(SAVED_STATE_PARENTAL_OPTIONS, mParentalOptions); outState.putBundle(SAVED_STATE_PARENTAL_OPTIONS, mParentalOptions);
@@ -432,11 +442,14 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
mConfirmingCredentials = false; mConfirmingCredentials = false;
final boolean isOk = final boolean isOk =
isSuccessfulConfirmOrChooseCredential(requestCode, resultCode); isSuccessfulConfirmOrChooseCredential(requestCode, resultCode);
// single modality enrollment requests confirmation directly // single face enrollment requests confirmation directly
// via BiometricEnrollBase#onCreate and should never get here // via BiometricEnrollBase#onCreate and should never get here
if (isOk && mHasFeatureFace && mHasFeatureFingerprint) { if (isOk && mHasFeatureFace && mHasFeatureFingerprint) {
updateGatekeeperPasswordHandle(data); updateGatekeeperPasswordHandle(data);
launchFaceAndFingerprintEnroll(); launchFaceAndFingerprintEnroll();
} else if (isOk && mHasFeatureFingerprint) {
updateGatekeeperPasswordHandle(data);
launchFingerprintOnlyEnroll();
} else { } else {
Log.d(TAG, "Unknown result for set/choose lock: " + resultCode); Log.d(TAG, "Unknown result for set/choose lock: " + resultCode);
setResult(resultCode); setResult(resultCode);
@@ -444,6 +457,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
} }
break; break;
case REQUEST_SINGLE_ENROLL: case REQUEST_SINGLE_ENROLL:
mFingerprintOnlyEnrolling = false;
finishOrLaunchHandToParent(resultCode); finishOrLaunchHandToParent(resultCode);
break; break;
default: default:
@@ -572,15 +586,18 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
} }
private void launchFingerprintOnlyEnroll() { private void launchFingerprintOnlyEnroll() {
final Intent intent; if (!mFingerprintOnlyEnrolling) {
// ChooseLockGeneric can request to start fingerprint enroll bypassing the intro screen. mFingerprintOnlyEnrolling = true;
if (getIntent().getBooleanExtra(EXTRA_SKIP_INTRO, false) final Intent intent;
&& this instanceof InternalActivity) { // ChooseLockGeneric can request to start fingerprint enroll bypassing the intro screen.
intent = BiometricUtils.getFingerprintFindSensorIntent(this, getIntent()); if (getIntent().getBooleanExtra(EXTRA_SKIP_INTRO, false)
} else { && this instanceof InternalActivity) {
intent = BiometricUtils.getFingerprintIntroIntent(this, getIntent()); intent = BiometricUtils.getFingerprintFindSensorIntent(this, getIntent());
} else {
intent = BiometricUtils.getFingerprintIntroIntent(this, getIntent());
}
launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL);
} }
launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL);
} }
private void launchFaceOnlyEnroll() { private void launchFaceOnlyEnroll() {