Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9404903 authored by Rubin Xu's avatar Rubin Xu Committed by android-build-merger
Browse files

Merge "Clear Gatekeeper state before a new enrollment" into oc-dev

am: a5f08d34

Change-Id: I4d94dd962459c8a565eb2efc7d26afe80e14786b
parents 22343c42 a5f08d34
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -346,11 +346,14 @@ public class SyntheticPasswordManager {
        PasswordData pwd = PasswordData.create(credentialType);
        byte[] pwdToken = computePasswordToken(credential, pwd);

        // In case GK enrollment leaves persistent state around (in RPMB), this will nuke them
        // to prevent them from accumulating and causing problems.
        gatekeeper.clearSecureUserId(fakeUid(userId));
        GateKeeperResponse response = gatekeeper.enroll(fakeUid(userId), null, null,
                passwordTokenToGkInput(pwdToken));
        if (response.getResponseCode() != GateKeeperResponse.RESPONSE_OK) {
            Log.e(TAG, "Fail to enroll user password when creating SP for user " + userId);
            return 0;
            return DEFAULT_HANDLE;
        }
        pwd.passwordHandle = response.getPayload();
        long sid = sidFromPasswordHandle(pwd.passwordHandle);