Skip to content

Catch SecurityException when setting stream volume to avoid DND crash - #72

Draft
yume-chan with Copilot wants to merge 2 commits into
mainfrom
copilot/nothing-phone-3-mute-crash-fix
Draft

Catch SecurityException when setting stream volume to avoid DND crash#72
yume-chan with Copilot wants to merge 2 commits into
mainfrom
copilot/nothing-phone-3-mute-crash-fix

Conversation

Copilot AI commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

On Nothing Phone 3 (Nothing OS 4.1 / Android 16 API 36), calling AudioManager.setStreamVolume() on the Ring stream while muted throws SecurityException: Not allowed to change Do Not Disturb state, crashing the app.

Changes

  • StreamVolumeSlider.kt: Wrap audioManager.setStreamVolume() in a try-catch for SecurityException; on failure, return early without invoking onChange so the UI stays consistent and the app survives gracefully.
volume = target
try {
    audioManager.setStreamVolume(streamType, target, 0)
} catch (_: SecurityException) {
    return@TrackSlider
}
onChange?.invoke()

Co-authored-by: yume-chan <1330321+yume-chan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix mute crash when changing ring volume Catch SecurityException when setting stream volume to avoid DND crash Sep 1, 2026
Copilot AI requested a review from yume-chan September 1, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Nothing Phone 3] [Nothing OS 4.1] Mute Crash

2 participants