Merge "Revert "Return enrollment consent status to caller."" into sc-dev
This commit is contained in:
@@ -71,7 +71,6 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
private static final int REQUEST_CHOOSE_OPTIONS = 3;
|
private static final int REQUEST_CHOOSE_OPTIONS = 3;
|
||||||
// prompt hand phone back to parent after enrollment
|
// prompt hand phone back to parent after enrollment
|
||||||
private static final int REQUEST_HANDOFF_PARENT = 4;
|
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;
|
public static final int RESULT_SKIP = BiometricEnrollBase.RESULT_SKIP;
|
||||||
|
|
||||||
@@ -79,13 +78,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
// this only applies to fingerprint.
|
// this only applies to fingerprint.
|
||||||
public static final String EXTRA_SKIP_INTRO = "skip_intro";
|
public static final String EXTRA_SKIP_INTRO = "skip_intro";
|
||||||
|
|
||||||
// Intent extra. If true, parental consent will be requested before user enrollment.
|
// TODO: temporary while waiting for team to add real flag
|
||||||
public static final String EXTRA_REQUIRE_PARENTAL_CONSENT = "require_consent";
|
public static final String EXTRA_TEMP_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";
|
|
||||||
|
|
||||||
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_ENROLL_ACTION_LOGGED = "enroll_action_logged";
|
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
|
// TODO(b/188847063): replace with real flag when ready
|
||||||
mParentalOptionsRequired = intent.getBooleanExtra(
|
mParentalOptionsRequired = intent.getBooleanExtra(
|
||||||
BiometricEnrollActivity.EXTRA_REQUIRE_PARENTAL_CONSENT, false);
|
BiometricEnrollActivity.EXTRA_TEMP_REQUIRE_PARENTAL_CONSENT, false);
|
||||||
|
|
||||||
if (mParentalOptionsRequired && mParentalOptions == null) {
|
if (mParentalOptionsRequired && mParentalOptions == null) {
|
||||||
mParentalConsentHelper = new ParentalConsentHelper(
|
mParentalConsentHelper = new ParentalConsentHelper(
|
||||||
@@ -207,6 +201,19 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startEnroll() {
|
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.
|
// Default behavior is to enroll BIOMETRIC_WEAK or above. See ACTION_BIOMETRIC_ENROLL.
|
||||||
final int authenticators = getIntent().getIntExtra(
|
final int authenticators = getIntent().getIntExtra(
|
||||||
EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_WEAK);
|
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
|
// This will need to be updated if the device has sensors other than BIOMETRIC_STRONG
|
||||||
if (!setupWizard && authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) {
|
if (!setupWizard && authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) {
|
||||||
launchCredentialOnlyEnroll();
|
launchCredentialOnlyEnroll();
|
||||||
} else if (canUseFace && canUseFingerprint) {
|
} else if (mHasFeatureFace && mHasFeatureFingerprint) {
|
||||||
if (mParentalOptionsRequired && mGkPwHandle != null) {
|
if (mParentalOptionsRequired && mGkPwHandle != null) {
|
||||||
launchFaceAndFingerprintEnroll();
|
launchFaceAndFingerprintEnroll();
|
||||||
} else {
|
} else {
|
||||||
setOrConfirmCredentialsNow();
|
setOrConfirmCredentialsNow();
|
||||||
}
|
}
|
||||||
} else if (canUseFingerprint) {
|
} else if (mHasFeatureFingerprint) {
|
||||||
launchFingerprintOnlyEnroll();
|
launchFingerprintOnlyEnroll();
|
||||||
} else if (canUseFace) {
|
} else if (mHasFeatureFace) {
|
||||||
launchFaceOnlyEnroll();
|
launchFaceOnlyEnroll();
|
||||||
} else { // no modalities available
|
} else {
|
||||||
if (mParentalOptionsRequired) {
|
Log.e(TAG, "Unknown state, finishing (was SUW: " + setupWizard + ")");
|
||||||
Log.d(TAG, "No consent for any modality: skipping enrollment");
|
|
||||||
setResult(RESULT_OK, newResultIntent());
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "Unknown state, finishing (was SUW: " + setupWizard + ")");
|
|
||||||
}
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,7 +275,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
if (mParentalConsentHelper != null) {
|
if (mParentalConsentHelper != null) {
|
||||||
handleOnActivityResultWhileConsenting(requestCode, resultCode, data);
|
handleOnActivityResultWhileConsenting(requestCode, resultCode, data);
|
||||||
} else {
|
} else {
|
||||||
handleOnActivityResultWhileEnrolling(requestCode, resultCode, data);
|
handleOnActivityResultWhileEnrollingMultiple(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,10 +305,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
final boolean isStillPrompting = mParentalConsentHelper.launchNext(
|
final boolean isStillPrompting = mParentalConsentHelper.launchNext(
|
||||||
this, REQUEST_CHOOSE_OPTIONS, resultCode, data);
|
this, REQUEST_CHOOSE_OPTIONS, resultCode, data);
|
||||||
if (!isStillPrompting) {
|
if (!isStillPrompting) {
|
||||||
Log.d(TAG, "Enrollment consent options set, starting enrollment");
|
Log.d(TAG, "Enrollment options set, requesting handoff");
|
||||||
mParentalOptions = mParentalConsentHelper.getConsentResult();
|
launchHandoffToParent();
|
||||||
mParentalConsentHelper = null;
|
|
||||||
startEnroll();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Unknown or cancelled parental consent");
|
Log.d(TAG, "Unknown or cancelled parental consent");
|
||||||
@@ -326,6 +314,18 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
Log.w(TAG, "Unknown consenting requestCode: " + requestCode + ", finishing");
|
Log.w(TAG, "Unknown consenting requestCode: " + requestCode + ", finishing");
|
||||||
finish();
|
finish();
|
||||||
@@ -333,13 +333,9 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handles responses while multi biometric enrollment is pending
|
// handles responses while multi biometric enrollment is pending
|
||||||
private void handleOnActivityResultWhileEnrolling(
|
private void handleOnActivityResultWhileEnrollingMultiple(
|
||||||
int requestCode, int resultCode, Intent data) {
|
int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == REQUEST_HANDOFF_PARENT) {
|
if (mMultiBiometricEnrollHelper == null) {
|
||||||
Log.d(TAG, "Enrollment complete, requesting handoff, result: " + resultCode);
|
|
||||||
setResult(RESULT_OK, newResultIntent());
|
|
||||||
finish();
|
|
||||||
} else if (mMultiBiometricEnrollHelper == null) {
|
|
||||||
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
|
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
@@ -359,37 +355,15 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REQUEST_SINGLE_ENROLL:
|
|
||||||
finishOrLaunchHandToParent(resultCode);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
Log.w(TAG, "Unknown enrolling requestCode: " + requestCode + ", finishing");
|
Log.w(TAG, "Unknown enrolling requestCode: " + requestCode + ", finishing");
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "RequestCode: " + requestCode + " resultCode: " + resultCode);
|
mMultiBiometricEnrollHelper.onActivityResult(requestCode, resultCode, data);
|
||||||
BiometricUtils.removeGatekeeperPasswordHandle(this, mGkPwHandle);
|
|
||||||
finishOrLaunchHandToParent(resultCode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
private static boolean isSuccessfulConfirmOrChooseCredential(int requestCode, int resultCode) {
|
||||||
final boolean okChoose = requestCode == REQUEST_CHOOSE_LOCK
|
final boolean okChoose = requestCode == REQUEST_CHOOSE_LOCK
|
||||||
&& resultCode == ChooseLockPattern.RESULT_FINISHED;
|
&& resultCode == ChooseLockPattern.RESULT_FINISHED;
|
||||||
@@ -410,8 +384,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
super.onStop();
|
super.onStop();
|
||||||
|
|
||||||
if (mConfirmingCredentials
|
if (mConfirmingCredentials
|
||||||
|| mParentalOptionsRequired
|
|| mMultiBiometricEnrollHelper != null
|
||||||
|| mMultiBiometricEnrollHelper != null) {
|
|| mParentalConsentHelper != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,6 +395,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setOrConfirmCredentialsNow() {
|
private void setOrConfirmCredentialsNow() {
|
||||||
if (!mConfirmingCredentials) {
|
if (!mConfirmingCredentials) {
|
||||||
mConfirmingCredentials = true;
|
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;
|
byte[] hardwareAuthToken = null;
|
||||||
if (this instanceof InternalActivity) {
|
if (this instanceof InternalActivity) {
|
||||||
hardwareAuthToken = getIntent().getByteArrayExtra(
|
hardwareAuthToken = getIntent().getByteArrayExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||||
}
|
}
|
||||||
BiometricUtils.launchEnrollForResult(this, intent, requestCode, hardwareAuthToken,
|
BiometricUtils.launchEnrollForResult(this, intent, 0 /* requestCode */, hardwareAuthToken,
|
||||||
mGkPwHandle, mUserId);
|
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.
|
// If only device credential was specified, ask the user to only set that up.
|
||||||
intent = new Intent(this, ChooseLockGeneric.class);
|
intent = new Intent(this, ChooseLockGeneric.class);
|
||||||
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
|
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
|
||||||
launchSingleSensorEnrollActivity(intent, 0 /* requestCode */);
|
launchSingleSensorEnrollActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchFingerprintOnlyEnroll() {
|
private void launchFingerprintOnlyEnroll() {
|
||||||
@@ -507,12 +489,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
} else {
|
} else {
|
||||||
intent = BiometricUtils.getFingerprintIntroIntent(this, getIntent());
|
intent = BiometricUtils.getFingerprintIntroIntent(this, getIntent());
|
||||||
}
|
}
|
||||||
launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL);
|
launchSingleSensorEnrollActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchFaceOnlyEnroll() {
|
private void launchFaceOnlyEnroll() {
|
||||||
final Intent intent = BiometricUtils.getFaceIntroIntent(this, getIntent());
|
final Intent intent = BiometricUtils.getFaceIntroIntent(this, getIntent());
|
||||||
launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL);
|
launchSingleSensorEnrollActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchFaceAndFingerprintEnroll() {
|
private void launchFaceAndFingerprintEnroll() {
|
||||||
|
@@ -20,6 +20,7 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.hardware.face.FaceManager;
|
import android.hardware.face.FaceManager;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
@@ -106,4 +107,11 @@ public class MultiBiometricEnrollHelper {
|
|||||||
hardwareAuthToken, mGkPwHandle, mUserId);
|
hardwareAuthToken, mGkPwHandle, mUserId);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
Log.d(TAG, "RequestCode: " + requestCode + " resultCode: " + resultCode);
|
||||||
|
BiometricUtils.removeGatekeeperPasswordHandle(mActivity, mGkPwHandle);
|
||||||
|
mActivity.setResult(resultCode);
|
||||||
|
mActivity.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,6 @@ public class ParentalConsentHelper {
|
|||||||
|
|
||||||
private static final String KEY_FACE_CONSENT = "face";
|
private static final String KEY_FACE_CONSENT = "face";
|
||||||
private static final String KEY_FINGERPRINT_CONSENT = "fingerprint";
|
private static final String KEY_FINGERPRINT_CONSENT = "fingerprint";
|
||||||
private static final String KEY_IRIS_CONSENT = "iris";
|
|
||||||
|
|
||||||
private final boolean mRequireFace;
|
private final boolean mRequireFace;
|
||||||
private final boolean mRequireFingerprint;
|
private final boolean mRequireFingerprint;
|
||||||
@@ -154,7 +153,6 @@ public class ParentalConsentHelper {
|
|||||||
result.putBoolean(KEY_FACE_CONSENT, mConsentFace != null ? mConsentFace : false);
|
result.putBoolean(KEY_FACE_CONSENT, mConsentFace != null ? mConsentFace : false);
|
||||||
result.putBoolean(KEY_FINGERPRINT_CONSENT,
|
result.putBoolean(KEY_FINGERPRINT_CONSENT,
|
||||||
mConsentFingerprint != null ? mConsentFingerprint : false);
|
mConsentFingerprint != null ? mConsentFingerprint : false);
|
||||||
result.putBoolean(KEY_IRIS_CONSENT, false);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user