am bc2a449a: am cb4d3ec1: Merge "Fix preference puts with "null" values."

* commit 'bc2a449a615b30efb81a1a0082a1bb0db515d0f5':
  Fix preference puts with "null" values.
This commit is contained in:
Narayan Kamath
2014-01-13 05:01:44 -08:00
committed by Android Git Automerger

View File

@@ -421,13 +421,15 @@ final class SharedPreferencesImpl implements SharedPreferences {
for (Map.Entry<String, Object> e : mModified.entrySet()) {
String k = e.getKey();
Object v = e.getValue();
if (v == this) { // magic value for a removal mutation
// "this" is the magic value for a removal mutation. In addition,
// setting a value to "null" for a given key is specified to be
// equivalent to calling remove on that key.
if (v == this || v == null) {
if (!mMap.containsKey(k)) {
continue;
}
mMap.remove(k);
} else {
boolean isSame = false;
if (mMap.containsKey(k)) {
Object existingValue = mMap.get(k);
if (existingValue != null && existingValue.equals(v)) {