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

Commit ea10cc0f authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Do not write if apply() did not change the file.

Bug: 33385963
Test: SharedPreferences CTS tests
Change-Id: I39955f8fbcdaa54faa539a3c503e12cb00808136
parent 31d6889f
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -592,20 +592,20 @@ final class SharedPreferencesImpl implements SharedPreferences {
        if (mFile.exists()) {
            boolean needsWrite = false;

            if (isFromSyncCommit) {
            // Only need to write if the disk state is older than this commit
            if (mDiskStateGeneration < mcr.memoryStateGeneration) {
                if (isFromSyncCommit) {
                    needsWrite = true;
                }
                } else {
                    synchronized (this) {
                    // No need to persist intermediate states. Just wait for the latest state to be
                    // persisted.
                        // No need to persist intermediate states. Just wait for the latest state to
                        // be persisted.
                        if (mCurrentMemoryStateGeneration == mcr.memoryStateGeneration) {
                            needsWrite = true;
                        }
                    }
                }
            }

            if (!needsWrite) {
                if (DEBUG) {