Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +10 −19 Original line number Diff line number Diff line Loading @@ -17,11 +17,7 @@ package com.android.providers.settings; import java.io.FileNotFoundException; import java.io.UnsupportedEncodingException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; Loading @@ -47,6 +43,7 @@ import android.provider.MediaStore; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import android.util.LruCache; public class SettingsProvider extends ContentProvider { private static final String TAG = "SettingsProvider"; Loading Loading @@ -293,7 +290,7 @@ public class SettingsProvider extends ContentProvider { "" + (MAX_CACHE_ENTRIES + 1) /* limit */); try { synchronized (cache) { cache.clear(); cache.evictAll(); cache.setFullyMatchesDisk(true); // optimistic int rows = 0; while (c.moveToNext()) { Loading Loading @@ -359,8 +356,8 @@ public class SettingsProvider extends ContentProvider { // possibly with a null value, or null on failure. private Bundle lookupValue(String table, SettingsCache cache, String key) { synchronized (cache) { if (cache.containsKey(key)) { Bundle value = cache.get(key); if (value != null) { if (value != TOO_LARGE_TO_CACHE_MARKER) { return value; } Loading Loading @@ -725,13 +722,13 @@ public class SettingsProvider extends ContentProvider { * associated helper functions to keep cache coherent with the * database. */ private static final class SettingsCache extends LinkedHashMap<String, Bundle> { private static final class SettingsCache extends LruCache<String, Bundle> { private final String mCacheName; private boolean mCacheFullyMatchesDisk = false; // has the whole database slurped. public SettingsCache(String name) { super(MAX_CACHE_ENTRIES, 0.75f /* load factor */, true /* access ordered */); super(MAX_CACHE_ENTRIES); mCacheName = name; } Loading @@ -751,15 +748,9 @@ public class SettingsProvider extends ContentProvider { } @Override protected boolean removeEldestEntry(Map.Entry eldest) { if (size() <= MAX_CACHE_ENTRIES) { return false; } synchronized (this) { protected synchronized void entryEvicted(String key, Bundle value) { mCacheFullyMatchesDisk = false; } return true; } /** * Atomic cache population, conditional on size of value and if Loading @@ -772,7 +763,7 @@ public class SettingsProvider extends ContentProvider { Bundle bundle = (value == null) ? NULL_SETTING : Bundle.forPair("value", value); if (value == null || value.length() <= MAX_CACHE_ENTRY_SIZE) { synchronized (this) { if (!containsKey(key)) { if (get(key) == null) { put(key, bundle); } } Loading Loading @@ -826,7 +817,7 @@ public class SettingsProvider extends ContentProvider { return; } synchronized (cache) { cache.clear(); cache.evictAll(); cache.mCacheFullyMatchesDisk = false; } } Loading Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +10 −19 Original line number Diff line number Diff line Loading @@ -17,11 +17,7 @@ package com.android.providers.settings; import java.io.FileNotFoundException; import java.io.UnsupportedEncodingException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; Loading @@ -47,6 +43,7 @@ import android.provider.MediaStore; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import android.util.LruCache; public class SettingsProvider extends ContentProvider { private static final String TAG = "SettingsProvider"; Loading Loading @@ -293,7 +290,7 @@ public class SettingsProvider extends ContentProvider { "" + (MAX_CACHE_ENTRIES + 1) /* limit */); try { synchronized (cache) { cache.clear(); cache.evictAll(); cache.setFullyMatchesDisk(true); // optimistic int rows = 0; while (c.moveToNext()) { Loading Loading @@ -359,8 +356,8 @@ public class SettingsProvider extends ContentProvider { // possibly with a null value, or null on failure. private Bundle lookupValue(String table, SettingsCache cache, String key) { synchronized (cache) { if (cache.containsKey(key)) { Bundle value = cache.get(key); if (value != null) { if (value != TOO_LARGE_TO_CACHE_MARKER) { return value; } Loading Loading @@ -725,13 +722,13 @@ public class SettingsProvider extends ContentProvider { * associated helper functions to keep cache coherent with the * database. */ private static final class SettingsCache extends LinkedHashMap<String, Bundle> { private static final class SettingsCache extends LruCache<String, Bundle> { private final String mCacheName; private boolean mCacheFullyMatchesDisk = false; // has the whole database slurped. public SettingsCache(String name) { super(MAX_CACHE_ENTRIES, 0.75f /* load factor */, true /* access ordered */); super(MAX_CACHE_ENTRIES); mCacheName = name; } Loading @@ -751,15 +748,9 @@ public class SettingsProvider extends ContentProvider { } @Override protected boolean removeEldestEntry(Map.Entry eldest) { if (size() <= MAX_CACHE_ENTRIES) { return false; } synchronized (this) { protected synchronized void entryEvicted(String key, Bundle value) { mCacheFullyMatchesDisk = false; } return true; } /** * Atomic cache population, conditional on size of value and if Loading @@ -772,7 +763,7 @@ public class SettingsProvider extends ContentProvider { Bundle bundle = (value == null) ? NULL_SETTING : Bundle.forPair("value", value); if (value == null || value.length() <= MAX_CACHE_ENTRY_SIZE) { synchronized (this) { if (!containsKey(key)) { if (get(key) == null) { put(key, bundle); } } Loading Loading @@ -826,7 +817,7 @@ public class SettingsProvider extends ContentProvider { return; } synchronized (cache) { cache.clear(); cache.evictAll(); cache.mCacheFullyMatchesDisk = false; } } Loading