Reaction: Don't auto-resume music after a manual pause#590
Merged
Conversation
Replaces the origin-tracking machinery with a simpler model that matches Apple's iOS/macOS behavior: auto-play strictly resumes a CAP-dispatched pause, gated by a sticky boolean cleared on inactive→active transitions. The original fire-on-cold-wear behavior is preserved as a per-device opt-in 'Start music on wear' setting.
…sleep Matches Apple's iOS/macOS behavior: stem-press pauses and sleep-detection pauses are explicit user intent, not eligible for auto-resume on next pod-in. sendPause gains a rememberForResume parameter (default false); only PlayPause's auto-pause branch passes true. New sendStop wrapper clears the auto-resume flag for stem-mapped MEDIA_STOP.
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.
What changed
Auto play now matches how AirPods behave on iPhone/Mac:
Long conversations still work normally — taking a pod out for 30 seconds (or 30 minutes) and putting it back in resumes whatever Auto pause stopped, no time limit.
Technical Context
(!isCurrentlyPlaying || wasRecentlyPausedByCap)was the bug —!isCurrentlyPlayingmatched any music-stopped state including a manual user pause, so pod re-insertion fired a play key over the user's intent.MediaControl.wasRecentlyPausedByCapis now a sticky boolean. Set whensendPause(rememberForResume = true)dispatches, cleared insendPlay, also cleared oninactive→activeplayback transitions viaAudioManager.AudioPlaybackCallback. Replaces the previous 15-second timer, which was too short for typical pod-out conversations and had a race where music starting from another source could leave a stale window that triggered a stray play key on the next pod-in.sendPause(rememberForResume: Boolean = false)— onlyPlayPause's auto-pause branch passestrue.SleepReactionandStemPressReaction(viasendPlayPause) keep the defaultfalse, so a stem-press pause or sleep-pause doesn't arm the auto-resume flag — and an explicitsendPause()that actually dispatches will clear a prior auto-resume flag, so a sleep-pause that happens after an ear-removal pause supersedes it.sendStop()for stem-mappedMEDIA_STOPclears the auto-resume flag — Stop is an explicit "stay stopped" intent.capPausedis set before the suspendingsendKey()dispatch — without that ordering, a playback config callback firing during dispatch could clear the flag and leave it stale-true.AudioPlaybackCallbackregistration usesnullfor the Handler (Android defaults to the main looper) so JVM unit tests with mockedAudioManagerdon't need Robolectric.ReactionConfig.startMusicOnWear: Boolean = false, persisted viaAppleDeviceProfile.@SerialName("reactionStartMusicOnWear"). Defaultfalsefor both new and legacy-migrated profiles, so the bug is fixed by default for all existing users.transition && (wasRecentlyPausedByCap || (startMusicOnWear && !isCurrentlyPlaying))— applied identically in normal mode, one-pod mode, and BLE-only autoplay confirmation.Review checklist