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

Commit e2afc242 authored by Brian Carlstrom's avatar Brian Carlstrom
Browse files

KeyStore.reset changes

restore keystore reset behavior of removing master key.
otherwise after reboot keystore has is LOCKED and not UNINITIALIZED
	cmds/keystore/keystore.cpp

when removing password, reset the keystore, so it doesn't remain
locked with a now bogus password.

	core/java/com/android/internal/widget/LockPatternUtils.java

Change-Id: If5e0bb50b42599e9ca27a8b91d6cec12528419a1
parent aef1987f
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -392,10 +392,8 @@ public:
            return false;
        }
        while ((file = readdir(dir)) != NULL) {
            if (isKeyFile(file->d_name)) {
            unlink(file->d_name);
        }
        }
        closedir(dir);
        return true;
    }
+12 −2
Original line number Diff line number Diff line
@@ -397,13 +397,17 @@ public class LockPatternUtils {
            }
            raf.close();
            DevicePolicyManager dpm = getDevicePolicyManager();
            KeyStore keyStore = KeyStore.getInstance();
            if (pattern != null) {
                KeyStore.getInstance().password(patternToString(pattern));
                keyStore.password(patternToString(pattern));
                setBoolean(PATTERN_EVER_CHOSEN_KEY, true);
                setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
                dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, pattern
                        .size(), 0, 0, 0, 0, 0, 0);
            } else {
                if (keyStore.isEmpty()) {
                    keyStore.reset();
                }
                dpm.setActivePasswordState(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, 0, 0,
                        0, 0, 0, 0, 0);
            }
@@ -486,12 +490,13 @@ public class LockPatternUtils {
            }
            raf.close();
            DevicePolicyManager dpm = getDevicePolicyManager();
            KeyStore keyStore = KeyStore.getInstance();
            if (password != null) {
                // Update the encryption password.
                updateEncryptionPassword(password);

                // Update the keystore password
                KeyStore.getInstance().password(password);
                keyStore.password(password);

                int computedQuality = computePasswordQuality(password);
                setLong(PASSWORD_TYPE_KEY, Math.max(quality, computedQuality));
@@ -545,6 +550,11 @@ public class LockPatternUtils {
                }
                setString(PASSWORD_HISTORY_KEY, passwordHistory);
            } else {
                // Conditionally reset the keystore if empty. If
                // non-empty, we are just switching key guard type
                if (keyStore.isEmpty()) {
                    keyStore.reset();
                }
                dpm.setActivePasswordState(
                        DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, 0, 0, 0, 0, 0, 0, 0);
            }