Harden car-arrival headset continuity after route flap (#36) #64

Merged
alexander merged 11 commits from mcp/issue-36-car-arrival-route-flap-v2 into main 2026-09-19 23:03:28 +02:00
Owner

Summary

Follow-up for #36 after the second physical Android Auto drive exposed a transient Bluetooth route-list flap during car binding.

The measured failure was:

  • playback was advancing through the headset;
  • Media3 paused with AUDIO_FOCUS_LOSS;
  • the first Android Auto controller bound within the bounded pairing window;
  • Android temporarily removed the active Bluetooth output and BookWave fell back to Automatic;
  • the same headset then reappeared, but PR #60's live-route revalidation had already lost the continuity evidence.

What changed

  • Capture the pause-time headset as the immutable continuity target.
  • Pair only the measured audio-focus-loss candidate with the first 0→1 car-controller bind.
  • Preserve the pause-time book generation and explicit-output-selection sequence.
  • Do not rediscover the target through live heardRoute after Android Auto begins mutating the route list.
  • Wait a bounded two seconds for that exact headset to reappear.
  • Reassert the same captured headset again if Android cleared the preferred route back to Automatic during settle.
  • Require the same generation/explicit intent, the exact headset to remain connected, and selectedId == target before play().
  • Keep deliberate pause, newer Play/output choice, another book generation, missing headset, speaker/car destination, AUDIO_BECOMING_NOISY, and later controller bindings excluded.
  • Preserve #11's normal route-heard ownership path for ordinary car binding.
  • Update R-106 and ADR-0029 with the second-drive evidence and the target-preserving recovery model.

Regression coverage

Added/updated tests for:

  • focus-loss candidate resolving to the pause-time headset;
  • live heardRoute disappearing without destroying the captured target;
  • stale generation / newer explicit intent rejection;
  • wrong secured output rejection;
  • pairing window measured at first car bind;
  • one-shot resume semantics;
  • Bluetooth disappearing and forcing Automatic during settle, then returning and being reasserted a second time;
  • headset never returning;
  • newer listener intent during settle aborting recovery.

Verification

Exact branch head:

e50748732dba86dc4e3ae3996548a95e8a4f82b8

Forgejo Actions run #153: success

Relevant checks passed:

  • :playback:compileDebugKotlin
  • :playback:detektDebug
  • :playback:detektDebugUnitTest
  • :playback:ktlintMainSourceSetCheck
  • :playback:ktlintTestSourceSetCheck
  • :playback:testDebugUnitTest
  • :playback:verifyDebug
  • aggregate build: BUILD SUCCESSFUL

Acceptance

This fixes the code path exposed by the 18:15 physical trace, but #36 should remain open until another real Android Auto drive confirms:

  • focus loss occurs;
  • the first car bind is paired;
  • the exact headset survives/reappears and is reasserted;
  • Playback resumed after the car took audio focus is logged;
  • playback continues without user intervention;
  • audio does not move to the phone speaker or car merely because the car connected.

Do not merge automatically; physical re-acceptance is still required.

## Summary Follow-up for #36 after the second physical Android Auto drive exposed a transient Bluetooth route-list flap during car binding. The measured failure was: - playback was advancing through the headset; - Media3 paused with `AUDIO_FOCUS_LOSS`; - the first Android Auto controller bound within the bounded pairing window; - Android temporarily removed the active Bluetooth output and BookWave fell back to Automatic; - the same headset then reappeared, but PR #60's live-route revalidation had already lost the continuity evidence. ## What changed - Capture the pause-time headset as the immutable continuity target. - Pair only the measured audio-focus-loss candidate with the first 0→1 car-controller bind. - Preserve the pause-time book generation and explicit-output-selection sequence. - Do not rediscover the target through live `heardRoute` after Android Auto begins mutating the route list. - Wait a bounded two seconds for that exact headset to reappear. - Reassert the same captured headset again if Android cleared the preferred route back to Automatic during settle. - Require the same generation/explicit intent, the exact headset to remain connected, and `selectedId == target` before `play()`. - Keep deliberate pause, newer Play/output choice, another book generation, missing headset, speaker/car destination, `AUDIO_BECOMING_NOISY`, and later controller bindings excluded. - Preserve #11's normal route-heard ownership path for ordinary car binding. - Update R-106 and ADR-0029 with the second-drive evidence and the target-preserving recovery model. ## Regression coverage Added/updated tests for: - focus-loss candidate resolving to the pause-time headset; - live `heardRoute` disappearing without destroying the captured target; - stale generation / newer explicit intent rejection; - wrong secured output rejection; - pairing window measured at first car bind; - one-shot resume semantics; - Bluetooth disappearing and forcing Automatic during settle, then returning and being reasserted a second time; - headset never returning; - newer listener intent during settle aborting recovery. ## Verification Exact branch head: `e50748732dba86dc4e3ae3996548a95e8a4f82b8` Forgejo Actions run **#153**: **success** Relevant checks passed: - `:playback:compileDebugKotlin` - `:playback:detektDebug` - `:playback:detektDebugUnitTest` - `:playback:ktlintMainSourceSetCheck` - `:playback:ktlintTestSourceSetCheck` - `:playback:testDebugUnitTest` - `:playback:verifyDebug` - aggregate build: `BUILD SUCCESSFUL` ## Acceptance This fixes the code path exposed by the 18:15 physical trace, but #36 should remain open until another real Android Auto drive confirms: - focus loss occurs; - the first car bind is paired; - the exact headset survives/reappears and is reasserted; - `Playback resumed after the car took audio focus` is logged; - playback continues without user intervention; - audio does not move to the phone speaker or car merely because the car connected. Do not merge automatically; physical re-acceptance is still required.
alexander deleted branch mcp/issue-36-car-arrival-route-flap-v2 2026-09-19 23:03:28 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
alexander/Audiobookshelf-Manager-Claude!64
No description provided.