fix: Crash in SettingsCache.onChange for unreadable hidden keys (#7452)
SettingsCache observes hidden Settings keys — e.g.
hide_privatespace_entry_point, which ModelInitializer registers a
listener for. Since Android S, hidden settings keys are only readable
by system apps; a query from a third-party app throws
SecurityException.
3962597e6e fixed this for the read path by catching SecurityException
in getValue(), but the ContentObserver path was missed: when the system
writes such a key, onChange() calls updateValue() on the main-thread
handler and the launcher crashes.
Skip the cache update instead, mirroring the existing guard in
getValue().
Co-authored-by: caizhixing <17589399+caizhixing03@user.noreply.gitee.com>
This commit is contained in:
1 parent
c154f993c8
commit
8429fbe09d
1 file changed
+9
-1
@@ -111,7 +111,15 @@ public class SettingsCache extends ContentObserver {
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
// We use default of 1, but if we're getting an onChange call, can assume a non-default
|
||||
// value will exist
|
||||
boolean newVal = updateValue(uri, 1 /* Effectively Unused */);
|
||||
boolean newVal;
|
||||
try {
|
||||
newVal = updateValue(uri, 1 /* Effectively Unused */);
|
||||
} catch (SecurityException e) {
|
||||
// Hidden settings keys (e.g. hide_privatespace_entry_point) are not readable by
|
||||
// non-system apps on S+, skip the cache update instead of crashing.
|
||||
Log.d("LC_SettingsCache", "Key not readable, skip update for " + uri);
|
||||
return;
|
||||
}
|
||||
List<OnChangeListener> listeners = mListenerMap.get(uri);
|
||||
if (listeners == null) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user