Testing on Fishlake shows certain preferences are of 'null' type
in shared preferences. Avoid an NPE on porting a null. From testing,
this can happen with focus mode, best to just skip porting the key
and let the app use a default.
Bug:
17829562
Change-Id: I483cb5beb160d3fb7fc8a42aa5085531e3fccb63
(cherry picked from commit
d560aabf7baef81a14e78341af81994efc1d4f17)
Map<String, ?> entries = oldPrefs.getAll();
for (Map.Entry<String, ?> entry : entries.entrySet()) {
String key = entry.getKey();
- String value = entry.getValue().toString();
- newPrefs.edit().putString(key, value).apply();
+ Object value = entry.getValue();
+ if (value != null) {
+ newPrefs.edit().putString(key, String.valueOf(value)).apply();
+ } else {
+ Log.w(TAG, "skipped upgrade for null key " + key);
+ }
}
}