From 8429fbe09dca7a5e087916710ac0535d3fd948bb Mon Sep 17 00:00:00 2001 From: caizhixing Date: Fri, 30 Oct 2026 07:45:11 -0700 Subject: [PATCH] fix: Crash in SettingsCache.onChange for unreadable hidden keys (#7452) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- src/com/android/launcher3/util/SettingsCache.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/util/SettingsCache.java b/src/com/android/launcher3/util/SettingsCache.java index a4577ecc26..95737348dc 100644 --- a/src/com/android/launcher3/util/SettingsCache.java +++ b/src/com/android/launcher3/util/SettingsCache.java @@ -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 listeners = mListenerMap.get(uri); if (listeners == null) { return;