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

Commit 5c38d15e authored by Eric Biggers's avatar Eric Biggers
Browse files

Make VerifyCredentialResponse#RESPONSE_* private

To help prevent bugs when checking a VerifyCredentialResponse, all
direct uses of the response code have been replaced with helper methods.
Therefore, the response code values no longer need to be public, nor
does the method to retrieve the response code.

Bug: 423038471
Test: atest FrameworksServicesTests:com.android.server.locksettings
Flag: EXEMPT refactor
Change-Id: If683f4c36e43f122eca08a09506bd03711dc5a0c
parent 764e8588
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -39,29 +39,29 @@ public final class VerifyCredentialResponse implements Parcelable {
     * Credential verification failed for a reason that isn't covered by one of the more specific
     * response codes.
     */
    public static final int RESPONSE_OTHER_ERROR = -1;
    private static final int RESPONSE_OTHER_ERROR = -1;

    /** Credential was successfully verified. */
    public static final int RESPONSE_OK = 0;
    private static final int RESPONSE_OK = 0;

    /**
     * Either the credential could not be verified because a timeout is still active, or the
     * credential was incorrect and there is a timeout before the next attempt will be allowed.
     * {@link #getTimeout()} gives the timeout.
     */
    public static final int RESPONSE_RETRY = 1;
    private static final int RESPONSE_RETRY = 1;

    /** Credential was shorter than the minimum length. */
    public static final int RESPONSE_CRED_TOO_SHORT = 2;
    private static final int RESPONSE_CRED_TOO_SHORT = 2;

    /** Credential was incorrect and was already tried recently. */
    public static final int RESPONSE_CRED_ALREADY_TRIED = 3;
    private static final int RESPONSE_CRED_ALREADY_TRIED = 3;

    /**
     * Credential was incorrect and none of {@link #RESPONSE_RETRY}, {@link
     * #RESPONSE_CRED_TOO_SHORT}, or {@link #RESPONSE_CRED_ALREADY_TRIED} applies.
     */
    public static final int RESPONSE_CRED_INCORRECT = 4;
    private static final int RESPONSE_CRED_INCORRECT = 4;

    @IntDef({
        RESPONSE_OTHER_ERROR,
@@ -250,10 +250,6 @@ public final class VerifyCredentialResponse implements Parcelable {
        return Duration.ofMillis(mTimeout);
    }

    public @ResponseCode int getResponseCode() {
        return mResponseCode;
    }

    /** Returns true if credential verification succeeded. */
    public boolean isMatched() {
        return mResponseCode == RESPONSE_OK;