Merge "Ensure the generation is not changed before put value to cache" am: 11ae580f81 am: 489f2c2c48

am: 848cde3beb

Change-Id: I52b5811ab3aab9bda73d1c4706858e3e8a70bef2
This commit is contained in:
xulicheng
2017-08-28 20:21:45 +00:00
committed by android-build-merger

View File

@@ -1750,6 +1750,10 @@ public final class Settings {
return true;
}
public int getCurrentGeneration() {
return mCurrentGeneration;
}
private int readCurrentGeneration() {
try {
return mArray.get(mIndex);
@@ -1858,6 +1862,7 @@ public final class Settings {
public String getStringForUser(ContentResolver cr, String name, final int userHandle) {
final boolean isSelf = (userHandle == UserHandle.myUserId());
int currentGeneration = -1;
if (isSelf) {
synchronized (NameValueCache.this) {
if (mGenerationTracker != null) {
@@ -1871,6 +1876,9 @@ public final class Settings {
} else if (mValues.containsKey(name)) {
return mValues.get(name);
}
if (mGenerationTracker != null) {
currentGeneration = mGenerationTracker.getCurrentGeneration();
}
}
}
} else {
@@ -1961,7 +1969,10 @@ public final class Settings {
});
}
}
mValues.put(name, value);
if (mGenerationTracker != null && currentGeneration ==
mGenerationTracker.getCurrentGeneration()) {
mValues.put(name, value);
}
}
} else {
if (LOCAL_LOGV) Log.i(TAG, "call-query of user " + userHandle
@@ -2002,7 +2013,10 @@ public final class Settings {
String value = c.moveToNext() ? c.getString(0) : null;
synchronized (NameValueCache.this) {
mValues.put(name, value);
if(mGenerationTracker != null &&
currentGeneration == mGenerationTracker.getCurrentGeneration()) {
mValues.put(name, value);
}
}
if (LOCAL_LOGV) {
Log.v(TAG, "cache miss [" + mUri.getLastPathSegment() + "]: " +