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

Commit eefaf27d authored by Brian Carlstrom's avatar Brian Carlstrom Committed by Android (Google) Code Review
Browse files

Merge "KeyStore.reset changes"

parents fb771d1e e2afc242
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);
            }