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

Commit f8154f8e authored by Rubin Xu's avatar Rubin Xu Committed by android-build-merger
Browse files

Merge "Remove unnecessary disk access when loading synthetic password states" into pi-dev

am: ece60739

Change-Id: Ic443dc0cb20282a89a274835375037689ab6d8f4
parents e56af077 ece60739
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -484,6 +484,7 @@ class LockSettingsStorage {
    }

    public void writeSyntheticPasswordState(int userId, long handle, String name, byte[] data) {
        ensureSyntheticPasswordDirectoryForUser(userId);
        writeFile(getSynthenticPasswordStateFilePathForUser(userId, handle, name), data);
    }

@@ -541,14 +542,19 @@ class LockSettingsStorage {
        return new File(Environment.getDataSystemDeDirectory(userId) ,SYNTHETIC_PASSWORD_DIRECTORY);
    }

    @VisibleForTesting
    protected String getSynthenticPasswordStateFilePathForUser(int userId, long handle,
            String name) {
    /** Ensure per-user directory for synthetic password state exists */
    private void ensureSyntheticPasswordDirectoryForUser(int userId) {
        File baseDir = getSyntheticPasswordDirectoryForUser(userId);
        String baseName = String.format("%016x.%s", handle, name);
        if (!baseDir.exists()) {
            baseDir.mkdir();
        }
    }

    @VisibleForTesting
    protected String getSynthenticPasswordStateFilePathForUser(int userId, long handle,
            String name) {
        final File baseDir = getSyntheticPasswordDirectoryForUser(userId);
        final String baseName = String.format("%016x.%s", handle, name);
        return new File(baseDir, baseName).getAbsolutePath();
    }