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

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

locksettings: move credentialTypeToString to LockPatternUtils

In preparation for using credentialTypeToString() from more places, move
it to LockPatternUtils.  Also change the strings returned to all
upper-case, as this looks better in the contexts where it will be used.

Bug: 268526331
Change-Id: Ic9ef28321bca793161182730d11a818378f8ab19
parent cec56be0
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -133,6 +133,21 @@ public class LockPatternUtils {
    })
    public @interface CredentialType {}

    public static String credentialTypeToString(int credentialType) {
        switch (credentialType) {
            case CREDENTIAL_TYPE_NONE:
                return "NONE";
            case CREDENTIAL_TYPE_PATTERN:
                return "PATTERN";
            case CREDENTIAL_TYPE_PIN:
                return "PIN";
            case CREDENTIAL_TYPE_PASSWORD:
                return "PASSWORD";
            default:
                return "UNKNOWN_" + credentialType;
        }
    }

    /**
     * Flag provided to {@link #verifyCredential(LockscreenCredential, int, int)} . If set, the
     * method will return a handle to the Gatekeeper Password in the
+2 −18
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import static android.os.UserHandle.USER_SYSTEM;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD_OR_PIN;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PATTERN;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PIN;
import static com.android.internal.widget.LockPatternUtils.CURRENT_LSKF_BASED_PROTECTOR_ID_KEY;
import static com.android.internal.widget.LockPatternUtils.EscrowTokenStateChangeCallback;
@@ -3077,21 +3076,6 @@ public class LockSettingsService extends ILockSettings.Stub {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(timestamp));
    }

    private static String credentialTypeToString(int credentialType) {
        switch (credentialType) {
            case CREDENTIAL_TYPE_NONE:
                return "None";
            case CREDENTIAL_TYPE_PATTERN:
                return "Pattern";
            case CREDENTIAL_TYPE_PIN:
                return "Pin";
            case CREDENTIAL_TYPE_PASSWORD:
                return "Password";
            default:
                return "Unknown " + credentialType;
        }
    }

    @Override
    protected void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) {
        if (!DumpUtils.checkDumpPermission(mContext, TAG, printWriter)) return;
@@ -3121,10 +3105,10 @@ public class LockSettingsService extends ILockSettings.Stub {
            } catch (RemoteException e) {
                // ignore.
            }
            // It's OK to dump the password type since anyone with physical access can just
            // It's OK to dump the credential type since anyone with physical access can just
            // observe it from the keyguard directly.
            pw.println("Quality: " + getKeyguardStoredQuality(userId));
            pw.println("CredentialType: " + credentialTypeToString(
            pw.println("CredentialType: " + LockPatternUtils.credentialTypeToString(
                    getCredentialTypeInternal(userId)));
            pw.println("SeparateChallenge: " + getSeparateProfileChallengeEnabledInternal(userId));
            pw.println(TextUtils.formatSimple("Metrics: %s",