Don't auto-resume playback on Bluetooth/headset connect#147
Open
symonbaikov wants to merge 1 commit into
Open
Conversation
paroj
reviewed
May 31, 2026
Fixes issue paroj#133: DSub was resuming the queue whenever a Bluetooth device connected, even when the user had explicitly paused or stopped playback (and even when the service had been force-stopped). Three sources of the unwanted resume: 1. MediaButtonIntentReceiver synthesized a KEYCODE_MEDIA_PLAY when the broadcast arrived with a null KeyEvent — exactly what Android delivers to the last active media app on Bluetooth connect. The synthesis is removed; null events are now ignored. 2. MediaSession.Callback.onPlay() called downloadService.start() unconditionally. Likewise the KEYCODE_MEDIA_PLAY case in handleKeyEvent. Both are suppressed only when an audio output device was added in the last 3 seconds (tracked via AudioDeviceCallback). This catches the synthetic Bluetooth play without affecting explicit user taps in the notification, lockscreen, or Android Auto. 3. PAUSED_TEMP (transient audio focus loss, e.g. a phone call) continues to auto-resume as before. A new "Resume on Bluetooth connect" preference (default off) lets users restore the old behaviour if they want it.
38d3e0d to
472d576
Compare
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 issue #133: DSub was resuming the queue whenever a Bluetooth device connected, even when the user had explicitly paused or stopped playback (and even when the service had been force-stopped).
Three sources of the unwanted resume:
MediaButtonIntentReceiver synthesized a KEYCODE_MEDIA_PLAY when the broadcast arrived with a null KeyEvent — exactly what Android delivers to the last active media app on Bluetooth connect. The synthesis is removed; null events are now ignored.
MediaSession.Callback.onPlay() called downloadService.start() unconditionally. Likewise the KEYCODE_MEDIA_PLAY case in handleKeyEvent. Both are suppressed only when an audio output device was added in the last 3 seconds (tracked via AudioDeviceCallback). This catches the synthetic Bluetooth play without affecting explicit user taps in the notification, lockscreen, or Android Auto.
PAUSED_TEMP (transient audio focus loss, e.g. a phone call) continues to auto-resume as before.
A new "Resume on Bluetooth connect" preference (default off) lets users restore the old behaviour if they want it.