Revert "Return enrollment consent status to caller."

This reverts commit eb1dac69f0.

Reason for revert: Based on bisection, this CL is the root cause for bug 192420564, which breaks Setup Wizard.

Bug: 192420564
Change-Id: I8d9aee7fe2415e134fcc981b0548bd9ce300db55
This commit is contained in:
bsears
2021-06-30 14:53:13 +00:00
parent eb1dac69f0
commit c358adad56
3 changed files with 63 additions and 75 deletions

View File

@@ -71,7 +71,6 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
private static final int REQUEST_CHOOSE_OPTIONS = 3;
// prompt hand phone back to parent after enrollment
private static final int REQUEST_HANDOFF_PARENT = 4;
private static final int REQUEST_SINGLE_ENROLL = 5;
public static final int RESULT_SKIP = BiometricEnrollBase.RESULT_SKIP;
@@ -79,13 +78,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
// this only applies to fingerprint.
public static final String EXTRA_SKIP_INTRO = "skip_intro";
// Intent extra. If true, parental consent will be requested before user enrollment.
public static final String EXTRA_REQUIRE_PARENTAL_CONSENT = "require_consent";
// If EXTRA_REQUIRE_PARENTAL_CONSENT was used to start the activity then the result
// intent will include this extra containing a bundle of the form:
// "modality" -> consented (boolean).
public static final String EXTRA_PARENTAL_CONSENT_STATUS = "consent_status";
// TODO: temporary while waiting for team to add real flag
public static final String EXTRA_TEMP_REQUIRE_PARENTAL_CONSENT = "require_consent";
private static final String SAVED_STATE_CONFIRMING_CREDENTIALS = "confirming_credentials";
private static final String SAVED_STATE_ENROLL_ACTION_LOGGED = "enroll_action_logged";
@@ -195,7 +189,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
// TODO(b/188847063): replace with real flag when ready
mParentalOptionsRequired = intent.getBooleanExtra(
BiometricEnrollActivity.EXTRA_REQUIRE_PARENTAL_CONSENT, false);
BiometricEnrollActivity.EXTRA_TEMP_REQUIRE_PARENTAL_CONSENT, false);
if (mParentalOptionsRequired && mParentalOptions == null) {
mParentalConsentHelper = new ParentalConsentHelper(
@@ -207,6 +201,19 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
}
private void startEnroll() {
// TODO(b/188847063): This can be deleted, but log it now until it's wired up for real.
if (mParentalOptionsRequired) {
if (mParentalOptions == null) {
throw new IllegalStateException("consent options required, but not set");
}
Log.d(TAG, "consent for face: "
+ ParentalConsentHelper.hasFaceConsent(mParentalOptions));
Log.d(TAG, "consent for fingerprint: "
+ ParentalConsentHelper.hasFingerprintConsent(mParentalOptions));
} else {
Log.d(TAG, "startEnroll without requiring consent");
}
// Default behavior is to enroll BIOMETRIC_WEAK or above. See ACTION_BIOMETRIC_ENROLL.
final int authenticators = getIntent().getIntExtra(
EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_WEAK);
@@ -227,38 +234,21 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
}
}
boolean canUseFace = mHasFeatureFace;
boolean canUseFingerprint = mHasFeatureFingerprint;
if (mParentalOptionsRequired) {
if (mParentalOptions == null) {
throw new IllegalStateException("consent options required, but not set");
}
canUseFace = canUseFace
&& ParentalConsentHelper.hasFaceConsent(mParentalOptions);
canUseFingerprint = canUseFingerprint
&& ParentalConsentHelper.hasFingerprintConsent(mParentalOptions);
}
// This will need to be updated if the device has sensors other than BIOMETRIC_STRONG
if (!setupWizard && authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) {
launchCredentialOnlyEnroll();
} else if (canUseFace && canUseFingerprint) {
} else if (mHasFeatureFace && mHasFeatureFingerprint) {
if (mParentalOptionsRequired && mGkPwHandle != null) {
launchFaceAndFingerprintEnroll();
} else {
setOrConfirmCredentialsNow();
}
} else if (canUseFingerprint) {
} else if (mHasFeatureFingerprint) {
launchFingerprintOnlyEnroll();
} else if (canUseFace) {
} else if (mHasFeatureFace) {
launchFaceOnlyEnroll();
} else { // no modalities available
if (mParentalOptionsRequired) {
Log.d(TAG, "No consent for any modality: skipping enrollment");
setResult(RESULT_OK, newResultIntent());
} else {
Log.e(TAG, "Unknown state, finishing (was SUW: " + setupWizard + ")");
}
} else {
Log.e(TAG, "Unknown state, finishing (was SUW: " + setupWizard + ")");
finish();
}
}
@@ -285,7 +275,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
if (mParentalConsentHelper != null) {
handleOnActivityResultWhileConsenting(requestCode, resultCode, data);
} else {
handleOnActivityResultWhileEnrolling(requestCode, resultCode, data);
handleOnActivityResultWhileEnrollingMultiple(requestCode, resultCode, data);
}
}
@@ -315,10 +305,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
final boolean isStillPrompting = mParentalConsentHelper.launchNext(
this, REQUEST_CHOOSE_OPTIONS, resultCode, data);
if (!isStillPrompting) {
Log.d(TAG, "Enrollment consent options set, starting enrollment");
mParentalOptions = mParentalConsentHelper.getConsentResult();
mParentalConsentHelper = null;
startEnroll();
Log.d(TAG, "Enrollment options set, requesting handoff");
launchHandoffToParent();
}
} else {
Log.d(TAG, "Unknown or cancelled parental consent");
@@ -326,6 +314,18 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
finish();
}
break;
case REQUEST_HANDOFF_PARENT:
if (resultCode == RESULT_OK) {
Log.d(TAG, "Enrollment options set, starting enrollment");
mParentalOptions = mParentalConsentHelper.getConsentResult();
mParentalConsentHelper = null;
startEnroll();
} else {
Log.d(TAG, "Unknown or cancelled handoff");
setResult(RESULT_CANCELED);
finish();
}
break;
default:
Log.w(TAG, "Unknown consenting requestCode: " + requestCode + ", finishing");
finish();
@@ -333,13 +333,9 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
}
// handles responses while multi biometric enrollment is pending
private void handleOnActivityResultWhileEnrolling(
private void handleOnActivityResultWhileEnrollingMultiple(
int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_HANDOFF_PARENT) {
Log.d(TAG, "Enrollment complete, requesting handoff, result: " + resultCode);
setResult(RESULT_OK, newResultIntent());
finish();
} else if (mMultiBiometricEnrollHelper == null) {
if (mMultiBiometricEnrollHelper == null) {
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
switch (requestCode) {
@@ -359,37 +355,15 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
finish();
}
break;
case REQUEST_SINGLE_ENROLL:
finishOrLaunchHandToParent(resultCode);
break;
default:
Log.w(TAG, "Unknown enrolling requestCode: " + requestCode + ", finishing");
finish();
}
} else {
Log.d(TAG, "RequestCode: " + requestCode + " resultCode: " + resultCode);
BiometricUtils.removeGatekeeperPasswordHandle(this, mGkPwHandle);
finishOrLaunchHandToParent(resultCode);
mMultiBiometricEnrollHelper.onActivityResult(requestCode, resultCode, data);
}
}
private void finishOrLaunchHandToParent(int resultCode) {
if (mParentalOptionsRequired) {
launchHandoffToParent();
} else {
setResult(resultCode);
finish();
}
}
private Intent newResultIntent() {
final Intent intent = new Intent();
final Bundle consentStatus = mParentalOptions.deepCopy();
intent.putExtra(EXTRA_PARENTAL_CONSENT_STATUS, consentStatus);
Log.v(TAG, "Result consent status: " + consentStatus);
return intent;
}
private static boolean isSuccessfulConfirmOrChooseCredential(int requestCode, int resultCode) {
final boolean okChoose = requestCode == REQUEST_CHOOSE_LOCK
&& resultCode == ChooseLockPattern.RESULT_FINISHED;
@@ -410,8 +384,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
super.onStop();
if (mConfirmingCredentials
|| mParentalOptionsRequired
|| mMultiBiometricEnrollHelper != null) {
|| mMultiBiometricEnrollHelper != null
|| mParentalConsentHelper != null) {
return;
}
@@ -421,6 +395,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
}
}
private void setOrConfirmCredentialsNow() {
if (!mConfirmingCredentials) {
mConfirmingCredentials = true;
@@ -479,14 +454,21 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
}
}
// This should only be used to launch enrollment for single-sensor devices.
private void launchSingleSensorEnrollActivity(@NonNull Intent intent, int requestCode) {
/**
* This should only be used to launch enrollment for single-sensor devices, which use
* FLAG_ACTIVITY_FORWARD_RESULT path.
*
* @param intent Enrollment activity that should be started (e.g. FaceEnrollIntroduction.class,
* etc).
*/
private void launchSingleSensorEnrollActivity(@NonNull Intent intent) {
intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
byte[] hardwareAuthToken = null;
if (this instanceof InternalActivity) {
hardwareAuthToken = getIntent().getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
}
BiometricUtils.launchEnrollForResult(this, intent, requestCode, hardwareAuthToken,
BiometricUtils.launchEnrollForResult(this, intent, 0 /* requestCode */, hardwareAuthToken,
mGkPwHandle, mUserId);
}
@@ -495,7 +477,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
// If only device credential was specified, ask the user to only set that up.
intent = new Intent(this, ChooseLockGeneric.class);
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
launchSingleSensorEnrollActivity(intent, 0 /* requestCode */);
launchSingleSensorEnrollActivity(intent);
}
private void launchFingerprintOnlyEnroll() {
@@ -507,12 +489,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
} else {
intent = BiometricUtils.getFingerprintIntroIntent(this, getIntent());
}
launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL);
launchSingleSensorEnrollActivity(intent);
}
private void launchFaceOnlyEnroll() {
final Intent intent = BiometricUtils.getFaceIntroIntent(this, getIntent());
launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL);
launchSingleSensorEnrollActivity(intent);
}
private void launchFaceAndFingerprintEnroll() {