fix: catch SecurityException reading hidden settings in ShutUpShortcut#454
Merged
sameerasw merged 2 commits intoMay 21, 2026
Conversation
show_key_presses and other @hide keys aren't @readable on Android 12+, so the backup pass in ShutUpShortcutActivity crashes before launchApp runs. WRITE_SECURE_SETTINGS only covers writes, which is why having Shizuku doesn't help. Reads now go through a try/catch helper that returns null on failure. Closes sameerasw#443
sanidhya-r
reviewed
May 21, 2026
sanidhya-r
left a comment
There was a problem hiding this comment.
Do you not need to throw the error? In this case if there are errors, they would fail silently
Contributor
Author
|
Hmmm 🤔 |
SecurityException is the only failure we know how to handle here. Other exceptions are real bugs and shouldn't fail silently.
Owner
|
Really appreciate it! Especially being able to fix and test on the affected devices is very good! I'll take a look and if all good, will merge and do a quick pre-release soon :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
SecurityException: Settings key: <show_key_presses> is not readablecrash on Android 12+ when launching a Shut Up shortcut. Reported in #443 on Pixel 7, Pixel 10 Pro, and a Samsung device, all running Android 16.Root cause
ShutUpShortcutActivity.applyShutUpSettings()reads a list of dev-options keys viaSettings.{System,Secure,Global}.getString()to back them up before flippingDEVELOPMENT_SETTINGS_ENABLEDoff.Since Android 12 (API 31), reading any
@hidesettings key that isn't annotated@ReadablethrowsSecurityException:WRITE_SECURE_SETTINGS(granted via Shizuku) covers writes, not reads, so the Shizuku permission doesn't help.show_key_presseshappens to be one of those non-@Readablehidden keys, and which keys get the annotation varies by OEM/build. That's why the crash reproduces on some Android 16 devices but not the maintainer's.Other keys in the same backup lists would crash the same way:
anr_show_background,secure_overlay_settings,mock_location,display_density_forced,disable_window_blurs,force_desktop_mode_on_external_displays, and others.Fix
Route every
Settings.*.getStringread inShutUpShortcutActivitythrough asafeReadSetting()helper that catchesSecurityExceptionand returnsnull. The existing?.let { … }callers then skip unreadable keys.DEVELOPMENT_SETTINGS_ENABLEDstill gets flipped off,launchApp(packageName)still runs, and behavior is unchanged for any key that is readable.Skipping the backup is harmless in practice: flipping
DEVELOPMENT_SETTINGS_ENABLEDalready resets the dev toggles, and those keys are system-managed defaults that couldn't have been restored anyway.AppFlowHandler.restoreShutUpSettings()already wraps each iteration intry/catch, so the restore path was never affected.Test plan
./gradlew :app:assembleDebug).Closes #443