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

Commit c6cbdd23 authored by Eric Biggers's avatar Eric Biggers
Browse files

Use VerifyCredentialResponse#isMatched() instead of comparing response code

The large number of callers of
VerifyCredentialResponse#getResponseCode() makes it hard to see in code
search how the response codes are being used.  However, most of them
just check for RESPONSE_OK, and there's already a method for that:
isMatched().  Use that instead.  No functional change.

Bug: 423038471
Test: atest FrameworksServicesTests:com.android.server.locksettings
Flag: EXEMPT refactor
Change-Id: Iaf4be81afafc3d7a67faaf788424ebbe8ef35194
parent 51e0f914
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1285,7 +1285,7 @@ public class KeyguardManager {
            if (response == null) {
                return false;
            }
            return response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK;
            return response.isMatched();
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -518,7 +518,7 @@ public class LockPatternUtils {
                    credential, userId, wrapCallback(progressCallback));
            if (response == null) {
                return false;
            } else if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
            } else if (response.isMatched()) {
                return true;
            } else if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_RETRY) {
                throw new RequestThrottledException(response.getTimeout());
+1 −1
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ public class BiometricDeferredQueue {
            Slog.wtf(TAG, "VerifyChallenge failed, null response");
            return null;
        }
        if (response.getResponseCode() != VerifyCredentialResponse.RESPONSE_OK) {
        if (!response.isMatched()) {
            Slog.wtf(TAG, "VerifyChallenge failed, response: "
                    + response.getResponseCode());
            return null;
+6 −7
Original line number Diff line number Diff line
@@ -2502,7 +2502,7 @@ public class LockSettingsService extends ILockSettings.Stub {
                    getGateKeeperService(), protectorId, credential, userId, progressCallback);
            response = reportResultToSoftwareRateLimiter(authResult.response, lskfId, credential);

            if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
            if (response.isMatched()) {
                if ((flags & VERIFY_FLAG_WRITE_REPAIR_MODE_PW) != 0) {
                    if (!mSpManager.writeRepairModeCredentialLocked(protectorId, userId)) {
                        Slog.e(TAG, "Failed to write repair mode credential");
@@ -2514,7 +2514,7 @@ public class LockSettingsService extends ILockSettings.Stub {
                        authResult.syntheticPassword.deriveGkPassword());
            }
        }
        if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
        if (response.isMatched()) {
            Slogf.i(TAG, "Successfully verified lockscreen credential for user %d", userId);
            onCredentialVerified(authResult.syntheticPassword,
                    PasswordMetrics.computeForCredential(credential), userId);
@@ -2531,8 +2531,7 @@ public class LockSettingsService extends ILockSettings.Stub {
                requireStrongAuth(STRONG_AUTH_REQUIRED_AFTER_LOCKOUT, userId);
            }
        }
        final boolean success = response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK;
        notifyLockSettingsStateListeners(success, userId);
        notifyLockSettingsStateListeners(response.isMatched(), userId);
        return response;
    }

@@ -2596,7 +2595,7 @@ public class LockSettingsService extends ILockSettings.Stub {
                parentProfileId,
                null /* progressCallback */,
                flags);
        if (parentResponse.getResponseCode() != VerifyCredentialResponse.RESPONSE_OK) {
        if (!parentResponse.isMatched()) {
            // Failed, just return parent's response
            return parentResponse;
        }
@@ -3500,7 +3499,7 @@ public class LockSettingsService extends ILockSettings.Stub {
            Slog.w(TAG, "Invalid escrow token supplied");
            return false;
        }
        if (result.response.getResponseCode() != VerifyCredentialResponse.RESPONSE_OK) {
        if (!result.response.isMatched()) {
            // Most likely, an untrusted credential reset happened in the past which
            // changed the synthetic password
            Slog.e(TAG, "Obsolete token: synthetic password decrypted but it fails GK "
@@ -3542,7 +3541,7 @@ public class LockSettingsService extends ILockSettings.Stub {
                return false;
            }
            return doVerifyCredential(cred, userId, null /* progressCallback */, 0 /* flags */)
                    .getResponseCode() == VerifyCredentialResponse.RESPONSE_OK;
                    .isMatched();
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -1096,7 +1096,7 @@ public class RecoverableKeyStoreManager {

    private RemoteLockscreenValidationResult handleVerifyCredentialResponse(
            VerifyCredentialResponse response, int userId) {
        if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
        if (response.isMatched()) {
            mDatabase.setBadRemoteGuessCounter(userId, 0);
            mRemoteLockscreenValidationSessionStorage.finishSession(userId);
            return new RemoteLockscreenValidationResult.Builder()
Loading