diff options
author | Svet Ganov <svetoslavganov@google.com> | 2016-07-06 12:16:53 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2016-07-06 18:45:58 -0700 |
commit | bd850641ae7cbd0ce56a3f7a69f30ce39ea0c579 (patch) | |
tree | bc4a9e7fd7aad388310056e6afa0c1a6d2092510 | |
parent | 60e8ddee376b26b9bd61eb4103e72c63df7bbe29 (diff) | |
download | base-bd850641ae7cbd0ce56a3f7a69f30ce39ea0c579.tar.gz |
Use proper lock when accessing the generation registry
We use 'this' for synchronization in NameValueCache but some code
that accesses the generation registry uses 'this' in a different
context ending up syncing on the wrong instance. This is why
sync on this is just a bad idea.
bug:29956424
Change-Id: Ide2d4f07a5f40cb3f0e8f50e4c8de216d15a31ee
-rwxr-xr-x | core/java/android/provider/Settings.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 293eb9ba80aa..9c567a95df74 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -1548,7 +1548,7 @@ public final class Settings { private IContentProvider lazyGetProvider(ContentResolver cr) { IContentProvider cp = null; - synchronized (this) { + synchronized (NameValueCache.this) { cp = mContentProvider; if (cp == null) { cp = mContentProvider = cr.acquireProvider(mUri.getAuthority()); @@ -1575,7 +1575,7 @@ public final class Settings { public String getStringForUser(ContentResolver cr, String name, final int userHandle) { final boolean isSelf = (userHandle == UserHandle.myUserId()); if (isSelf) { - synchronized (this) { + synchronized (NameValueCache.this) { if (mGenerationTracker != null) { if (mGenerationTracker.isGenerationChanged()) { if (DEBUG) { @@ -1608,7 +1608,7 @@ public final class Settings { args.putInt(CALL_METHOD_USER_KEY, userHandle); } boolean needsGenerationTracker = false; - synchronized (this) { + synchronized (NameValueCache.this) { if (isSelf && mGenerationTracker == null) { needsGenerationTracker = true; if (args == null) { @@ -1627,7 +1627,7 @@ public final class Settings { String value = b.getString(Settings.NameValueTable.VALUE); // Don't update our cache for reads of other users' data if (isSelf) { - synchronized (this) { + synchronized (NameValueCache.this) { if (needsGenerationTracker) { MemoryIntArray array = b.getParcelable( CALL_METHOD_TRACK_GENERATION_KEY); @@ -1644,7 +1644,7 @@ public final class Settings { } mGenerationTracker = new GenerationTracker(array, index, generation, () -> { - synchronized (this) { + synchronized (NameValueCache.this) { Log.e(TAG, "Error accessing generation" + " tracker - removing"); if (mGenerationTracker != null) { @@ -1685,7 +1685,7 @@ public final class Settings { } String value = c.moveToNext() ? c.getString(0) : null; - synchronized (this) { + synchronized (NameValueCache.this) { mValues.put(name, value); } if (LOCAL_LOGV) { |