Fix face enroll introduction crash after 10mins

When requestGatekeeperHat() throws exception in FaceEnrollIntroduction
page, remove gk_pw_handle and recreate activity to trigger confirmLock.

Test: robotest for FaceEnrollIntroductionTest
Bug: 234437174
Change-Id: Ie1dd6f36e4deb3f776e3b39acd165fc47d04f526
This commit is contained in:
Milton Wu
2022-11-07 03:33:19 +00:00
parent e274c85474
commit a174486803
3 changed files with 203 additions and 11 deletions

View File

@@ -60,6 +60,17 @@ public class BiometricUtils {
* enrolled biometric of the same type.
*/
public static int REQUEST_ADD_ANOTHER = 7;
/**
* Gatekeeper credential not match exception, it throws if VerifyCredentialResponse is not
* matched in requestGatekeeperHat().
*/
public static class GatekeeperCredentialNotMatchException extends IllegalStateException {
public GatekeeperCredentialNotMatchException(String s) {
super(s);
}
};
/**
* Given the result from confirming or choosing a credential, request Gatekeeper to generate
* a HardwareAuthToken with the Gatekeeper Password together with a biometric challenge.
@@ -69,6 +80,8 @@ public class BiometricUtils {
* @param userId User ID that the credential/biometric operation applies to
* @param challenge Unique biometric challenge from FingerprintManager/FaceManager
* @return
* @throws GatekeeperCredentialNotMatchException if Gatekeeper response is not match
* @throws IllegalStateException if Gatekeeper Password is missing
*/
public static byte[] requestGatekeeperHat(@NonNull Context context, @NonNull Intent result,
int userId, long challenge) {
@@ -86,7 +99,7 @@ public class BiometricUtils {
final VerifyCredentialResponse response = utils.verifyGatekeeperPasswordHandle(gkPwHandle,
challenge, userId);
if (!response.isMatched()) {
throw new IllegalStateException("Unable to request Gatekeeper HAT");
throw new GatekeeperCredentialNotMatchException("Unable to request Gatekeeper HAT");
}
return response.getGatekeeperHAT();
}