BiometricEnrollIntro should use non-blocking generateChallenge

GenerateChallenge used to block when showing the credential screen.
Now that GenerateChallenge is moved to after the credential screen
is shown, we need to delay the next button instead. This is generally
non percievable to the user, but this is more robust against busy
system server.

Fixes: 161325267
Test: Enroll fingerprint/face device
Change-Id: I0fbbef8bf469e32bed251acf22556ad2ea8e2933
This commit is contained in:
Kevin Chyn
2020-07-30 14:04:20 -07:00
parent 7b0867c6d3
commit 66bfe45f99
3 changed files with 24 additions and 11 deletions

View File

@@ -101,7 +101,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
/**
* @return the challenge generated by the biometric hardware
*/
protected abstract long getChallenge();
protected abstract void getChallenge(GenerateChallengeCallback callback);
/**
* @return one of the ChooseLockSettingsHelper#EXTRA_KEY_FOR_* constants
@@ -125,6 +125,10 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
*/
public abstract void onClick(LinkSpan span);
protected interface GenerateChallengeCallback {
void onChallengeGenerated(long challenge);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -267,12 +271,15 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
return;
}
} else if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST) {
mConfirmingCredentials = false;
if (resultCode == RESULT_FINISHED) {
updatePasswordQuality();
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, getChallenge());
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
mConfirmingCredentials = false;
return;
getNextButton().setEnabled(false);
getChallenge((challenge -> {
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
getNextButton().setEnabled(true);
}));
} else {
setResult(resultCode, data);
finish();
@@ -280,8 +287,12 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
} else if (requestCode == CONFIRM_REQUEST) {
mConfirmingCredentials = false;
if (resultCode == RESULT_OK && data != null) {
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, getChallenge());
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getNextButton().setEnabled(false);
getChallenge((challenge -> {
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
getNextButton().setEnabled(true);
}));
} else {
setResult(resultCode, data);
finish();