fix: Grayscale feature crashing when reading the extra dim state - #171
Merged
Conversation
…den settings Since Android 12, hidden settings keys that are not marked @readable (like reduce_bright_colors_activated) throw a SecurityException when a third-party app reads them. GrapheneOS enforces this, so initializing the extra dim state in onStart() crashed the app as soon as the grayscale feature started. Reads now fall back to the default value if the key is not readable. Writing via WRITE_SECURE_SETTINGS is not affected. Fixes #170
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.
Fixes #170.
v2.5.0 started reading the extra dim state (
reduce_bright_colors_activated) inGrayscaleAppsFeature.onStart()to initialize the cached filter state. That key is a hidden setting without@Readable, and since Android 12 reading those throws a SecurityException for third-party apps. GrapheneOS enforces this, so the app crashed the moment the grayscale feature started, for one reporter even directly on app open, sinceonStart()runs as soon as the accessibility service connects.Reads of secure settings now go through a small helper that falls back to the default value when the key is not readable. Worst case we don't detect that extra dim was already on before DetoxDroid started, which is harmless. Writing the setting still works fine with WRITE_SECURE_SETTINGS, so the feature itself is unaffected.