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

Commit 8881839d authored by Eric Biggers's avatar Eric Biggers
Browse files

LockSettingsService: define string constants for migration keys

Cleanup only; no change in behavior.

Bug: 296464083
Test: atest com.android.server.locksettings
Change-Id: I4aee0cabef5e2bef7834dd0b0d949284fcf3f072
parent 28dc9370
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -237,6 +237,10 @@ public class LockSettingsService extends ILockSettings.Stub {
    private static final String LSKF_LAST_CHANGED_TIME_KEY = "sp-handle-ts";
    private static final String USER_SERIAL_NUMBER_KEY = "serial-number";

    private static final String MIGRATED_FRP2 = "migrated_frp2";
    private static final String MIGRATED_KEYSTORE_NS = "migrated_keystore_namespace";
    private static final String MIGRATED_SP_CE_ONLY = "migrated_all_users_to_sp_and_bound_ce";

    // Duration that LockSettingsService will store the gatekeeper password for. This allows
    // multiple biometric enrollments without prompting the user to enter their password via
    // ConfirmLockPassword/ConfirmLockPattern multiple times. This needs to be at least the duration
@@ -903,14 +907,14 @@ public class LockSettingsService extends ILockSettings.Stub {
    }

    private void migrateOldData() {
        if (getString("migrated_keystore_namespace", null, 0) == null) {
        if (getString(MIGRATED_KEYSTORE_NS, null, 0) == null) {
            boolean success = true;
            synchronized (mSpManager) {
                success &= mSpManager.migrateKeyNamespace();
            }
            success &= migrateProfileLockKeys();
            if (success) {
                setString("migrated_keystore_namespace", "true", 0);
                setString(MIGRATED_KEYSTORE_NS, "true", 0);
                Slog.i(TAG, "Migrated keys to LSS namespace");
            } else {
                Slog.w(TAG, "Failed to migrate keys to LSS namespace");
@@ -930,9 +934,9 @@ public class LockSettingsService extends ILockSettings.Stub {
        // "migrated_frp" to "migrated_frp2" to cause migrateFrpCredential() to run again on devices
        // where it had run before.
        if (LockPatternUtils.frpCredentialEnabled(mContext)
                && !getBoolean("migrated_frp2", false, 0)) {
                && !getBoolean(MIGRATED_FRP2, false, 0)) {
            migrateFrpCredential();
            setBoolean("migrated_frp2", true, 0);
            setBoolean(MIGRATED_FRP2, true, 0);
        }
    }

@@ -1012,14 +1016,14 @@ public class LockSettingsService extends ILockSettings.Stub {
            // If this gets interrupted (e.g. by the device powering off), there shouldn't be a
            // problem since this will run again on the next boot, and setUserKeyProtection() is
            // okay with the key being already protected by the given secret.
            if (getString("migrated_all_users_to_sp_and_bound_ce", null, 0) == null) {
            if (getString(MIGRATED_SP_CE_ONLY, null, 0) == null) {
                for (UserInfo user : mUserManager.getAliveUsers()) {
                    removeStateForReusedUserIdIfNecessary(user.id, user.serialNumber);
                    synchronized (mSpManager) {
                        migrateUserToSpWithBoundCeKeyLocked(user.id);
                    }
                }
                setString("migrated_all_users_to_sp_and_bound_ce", "true", 0);
                setString(MIGRATED_SP_CE_ONLY, "true", 0);
            }

            mThirdPartyAppsStarted = true;