summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2016-12-13 16:32:06 -0800
committergitbuildkicker <android-build@google.com>2017-01-12 19:04:30 -0800
commitc639cb67b4310b80aeddb4184dc191a24b23e9ca (patch)
treea732d24fb320c00d7e1cea576abe89be2960f78a
parent06276708d6e0a3d3cfa8dee7e7b4be06cde52469 (diff)
downloadbase-c639cb67b4310b80aeddb4184dc191a24b23e9ca.tar.gz
Do not write if apply() did not change the file.android-7.1.1_r21android-7.1.1_r20
Bug: 33385963 Test: SharedPreferences CTS tests Change-Id: I39955f8fbcdaa54faa539a3c503e12cb00808136 (cherry picked from commit 1f99f81bdc5e8430717def157f4abe1176d6a88e)
-rw-r--r--core/java/android/app/SharedPreferencesImpl.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/java/android/app/SharedPreferencesImpl.java b/core/java/android/app/SharedPreferencesImpl.java
index c5a8288b500f..f273cd8670f0 100644
--- a/core/java/android/app/SharedPreferencesImpl.java
+++ b/core/java/android/app/SharedPreferencesImpl.java
@@ -592,17 +592,17 @@ 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) {
+ // 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.
- if (mCurrentMemoryStateGeneration == mcr.memoryStateGeneration) {
- needsWrite = true;
+ } else {
+ synchronized (this) {
+ // No need to persist intermediate states. Just wait for the latest state to
+ // be persisted.
+ if (mCurrentMemoryStateGeneration == mcr.memoryStateGeneration) {
+ needsWrite = true;
+ }
}
}
}