A car connecting stops the book instead of letting the headset carry on #36

Open
opened 2026-09-18 08:47:35 +02:00 by alexander · 9 comments
Owner

Migrated from GitHub issue #128. Forgejo issue: #36. GitHub source content synchronized on 2026-09-19. Migrated issue references below use Forgejo numbers where an equivalent issue exists; historical references without a Forgejo counterpart remain explicit GitHub links.

Reported from the car on 2026-09-08: "when listening to headset, then android auto starts, the music in the headset stops, I want it to continue." Reported once before, on 2026-09-07. Tracked as docs/risks.md R-106.

This is the oldest live defect on the Android Auto surface and the only one that actually interrupts listening, so it is the one worth doing properly.

Nothing in this app pauses the book

The pause is the platform's, through one of two mechanisms, and Media3 pauses for both and resumes neither:

  • ACTION_AUDIO_BECOMING_NOISY, broadcast when an A2DP sink is deactivated — which is exactly what a car taking the active A2DP slot does to a headset; or
  • a permanent audio-focus loss as the projection host starts.

HeadsetHold already handles the routing half correctly: it remembers the headset the book was coming out of and reasserts it when a car binds, so the book does not migrate to the car. What it does not do — and cannot, by design — is un-pause. The route is preserved; the playback is not.

An implementation exists and was deliberately withdrawn

CarArrivalContinuity was written for this, reviewed five times, found to contain seven defects across those rounds, and lifted back out of GitHub #78 rather than shipped unverified. It is preserved at commit 26f65f0 on claude/shelfplayer-android-auth-lk77fv.

The reason it was withdrawn is worth keeping in view: each round fixed the defect in front of it and the next round found another, and round 5 produced a resume onto the phone speaker — strictly worse than the pause it was fixing. Resuming playback is a decision that can be wrong in ways silence cannot, so it should not be shipped on inference.

What is needed before restarting it

Two measurements from a single drive, both of which the app already logs:

  1. Which mechanism pauses it. The PLAY_WHEN_READY_CHANGE_REASON_* word recorded for the pause says whether it was becoming-noisy or a focus loss. They need different handling and guessing between them is how round 5 happened.
  2. The interval between that pause and the car binding. This says whether the two can be correlated at all, or whether a resume would be firing blind.

The new "The car output actions were recomputed" line added in GitHub #78 gives the route state alongside it, so one drive now yields all three facts together.

Acceptance

  • Connecting a car while a book is playing on a headset leaves the book playing, in the headset.
  • It must never resume onto the phone speaker, and never onto the car, when the listener was on a headset — those are the failure modes that withdrew the first attempt.
  • Nothing resumes a book the listener had deliberately paused before the car arrived.
  • The behaviour is proven by a test that fails when the resume is removed, not by a green build.
  • docs/risks.md R-106
  • ADR-0029 §9, which records this as open and deferred
  • Prior implementation: 26f65f0
  • Interacts with #11 (HeadsetHold redesign) — worth deciding whether that lands first, since both touch the same state
> Migrated from [GitHub issue #128](https://github.com/AlexanderWilhelmsenBerg/Audiobookshelf-Manager-Claude/issues/128). Forgejo issue: #36. GitHub source content synchronized on 2026-09-19. Migrated issue references below use Forgejo numbers where an equivalent issue exists; historical references without a Forgejo counterpart remain explicit GitHub links. Reported from the car on 2026-09-08: *"when listening to headset, then android auto starts, the music in the headset stops, I want it to continue."* Reported once before, on 2026-09-07. Tracked as `docs/risks.md` R-106. This is the oldest live defect on the Android Auto surface and the only one that actually interrupts listening, so it is the one worth doing properly. ## Nothing in this app pauses the book The pause is the platform's, through one of two mechanisms, and Media3 pauses for both and resumes neither: - **`ACTION_AUDIO_BECOMING_NOISY`**, broadcast when an A2DP sink is deactivated — which is exactly what a car taking the active A2DP slot does to a headset; or - **a permanent audio-focus loss** as the projection host starts. `HeadsetHold` already handles the *routing* half correctly: it remembers the headset the book was coming out of and reasserts it when a car binds, so the book does not migrate to the car. What it does not do — and cannot, by design — is un-pause. The route is preserved; the playback is not. ## An implementation exists and was deliberately withdrawn `CarArrivalContinuity` was written for this, reviewed five times, found to contain seven defects across those rounds, and lifted back out of [GitHub #78](https://github.com/AlexanderWilhelmsenBerg/Audiobookshelf-Manager-Claude/issues/78) rather than shipped unverified. **It is preserved at commit `26f65f0` on `claude/shelfplayer-android-auth-lk77fv`.** The reason it was withdrawn is worth keeping in view: each round fixed the defect in front of it and the next round found another, and round 5 produced a resume onto the *phone speaker* — strictly worse than the pause it was fixing. Resuming playback is a decision that can be wrong in ways silence cannot, so it should not be shipped on inference. ## What is needed before restarting it Two measurements from a single drive, both of which the app already logs: 1. **Which mechanism pauses it.** The `PLAY_WHEN_READY_CHANGE_REASON_*` word recorded for the pause says whether it was becoming-noisy or a focus loss. They need different handling and guessing between them is how round 5 happened. 2. **The interval between that pause and the car binding.** This says whether the two can be correlated at all, or whether a resume would be firing blind. The new `"The car output actions were recomputed"` line added in [GitHub #78](https://github.com/AlexanderWilhelmsenBerg/Audiobookshelf-Manager-Claude/issues/78) gives the route state alongside it, so one drive now yields all three facts together. ## Acceptance - Connecting a car while a book is playing on a headset leaves the book **playing, in the headset**. - It must never resume onto the phone speaker, and never onto the car, when the listener was on a headset — those are the failure modes that withdrew the first attempt. - Nothing resumes a book the listener had deliberately paused before the car arrived. - The behaviour is proven by a test that fails when the resume is removed, not by a green build. ## Related - `docs/risks.md` R-106 - ADR-0029 §9, which records this as open and deferred - Prior implementation: `26f65f0` - Interacts with #11 (`HeadsetHold` redesign) — worth deciding whether that lands first, since both touch the same state
Author
Owner

Physical acceptance record carried forward from #11

Device acceptance reported by the owner on 2026-09-19 after #11 / PR #59 was merged:

  • with audiobook playback using a headset, connecting the car / Android Auto keeps the audiobook routed to that headset;
  • the route-heard ownership redesign therefore satisfies the routing half of the #36 scenario on the tested physical setup.

This record should be included in the eventual #36 PR/merge evidence.

Scope of this evidence: it validates #11's route preservation/ownership behavior only. It does not identify the Media3 pause cause for #36 (for example becomingNoisy vs audioFocusLoss) and should not be used to infer that cause.

Merged prerequisite: PR #59, main 44cd4691ce9064392b8b8fb59338fc4c1e2a896e. Post-merge main Actions run #116 succeeded.

## Physical acceptance record carried forward from #11 Device acceptance reported by the owner on 2026-09-19 after #11 / PR #59 was merged: - with audiobook playback using a headset, connecting the car / Android Auto keeps the audiobook routed to that headset; - the route-heard ownership redesign therefore satisfies the routing half of the #36 scenario on the tested physical setup. This record should be included in the eventual #36 PR/merge evidence. Scope of this evidence: it validates #11's route preservation/ownership behavior only. It does not identify the Media3 pause cause for #36 (for example `becomingNoisy` vs `audioFocusLoss`) and should not be used to infer that cause. Merged prerequisite: PR #59, main `44cd4691ce9064392b8b8fb59338fc4c1e2a896e`. Post-merge main Actions run #116 succeeded.
Author
Owner

Physical evidence captured 2026-09-19

A physical drive after #11 / PR #59 provides the missing #36 cause/correlation evidence.

Car start / Android Auto arrival

  • 15:36:43 — playback starts with outputs=Speaker+Ambiguous*, onHeadset=true; the framework reports the Bluetooth/A2DP route active.
  • 15:37:25 — Media3 changes playWhenReady=false with reason=audioFocusLoss. This is direct cause evidence; it is not inferred from timing.
  • 15:37:27 — first Android Auto controller binding: controller=com.google.android.projection.gearhead.
  • 15:37:27 — #11 ownership accepts and reasserts the current-generation headset: A car connected and the book was held in the headset kind=bluetooth.
  • 15:37:27 — car-bound output diagnostics report outputs=Speaker+Ambiguous, onHeadset=true, with route observation temporarily unknown.
  • 15:37:35 — a second car-controller binding again reasserts the same headset ownership; manual Play follows with reason=userRequest.

Measured pause→first-car-bind interval: 2 seconds.

No user-request pause precedes the 15:37:25 stop; interval progress writes show playback was continuously advancing immediately beforehand. This establishes that the observed pause was system-caused.

The owner's physical observation also confirms #11's routing half: while wearing the headset, connecting Android Auto keeps the audiobook in that headset.

Car stop

  • 15:43:37 — another playWhenReady=false reason=audioFocusLoss was observed when stopping the car.
  • There is no corresponding new car-arrival binding in this excerpt, so this is recorded as useful separate evidence and is not treated as the #36 arrival trigger.

Implementation consequence

For the tested setup, #36 should correlate audio-focus-loss only with the first car-arrival transition, preserve the generation-bound headset ownership from #11, and must not generalize this evidence to every system pause or to becomingNoisy.

## Physical evidence captured 2026-09-19 A physical drive after #11 / PR #59 provides the missing #36 cause/correlation evidence. ### Car start / Android Auto arrival - 15:36:43 — playback starts with `outputs=Speaker+Ambiguous*`, `onHeadset=true`; the framework reports the Bluetooth/A2DP route active. - 15:37:25 — Media3 changes `playWhenReady=false` with **`reason=audioFocusLoss`**. This is direct cause evidence; it is not inferred from timing. - 15:37:27 — first Android Auto controller binding: `controller=com.google.android.projection.gearhead`. - 15:37:27 — #11 ownership accepts and reasserts the current-generation headset: `A car connected and the book was held in the headset kind=bluetooth`. - 15:37:27 — car-bound output diagnostics report `outputs=Speaker+Ambiguous`, `onHeadset=true`, with route observation temporarily unknown. - 15:37:35 — a second car-controller binding again reasserts the same headset ownership; manual Play follows with `reason=userRequest`. Measured pause→first-car-bind interval: **2 seconds**. No user-request pause precedes the 15:37:25 stop; interval progress writes show playback was continuously advancing immediately beforehand. This establishes that the observed pause was system-caused. The owner's physical observation also confirms #11's routing half: while wearing the headset, connecting Android Auto keeps the audiobook in that headset. ### Car stop - 15:43:37 — another `playWhenReady=false reason=audioFocusLoss` was observed when stopping the car. - There is no corresponding new car-arrival binding in this excerpt, so this is recorded as useful separate evidence and is not treated as the #36 arrival trigger. ### Implementation consequence For the tested setup, #36 should correlate **audio-focus-loss only** with the first car-arrival transition, preserve the generation-bound headset ownership from #11, and must not generalize this evidence to every system pause or to `becomingNoisy`.
Author
Owner

#36 implementation verification

PR #60 is open from mcp/issue-36-car-arrival-continuity at exact head 7f185ab895aa911b983d95d642d8c1dc4dcc1004.

The earlier verifyDebug failure was fixed without changing the continuity policy:

  • Detekt: reduced CarArrivalResumeGate.takeForCarArrival return count.
  • KtLint: normalized short parameter-list formatting.

Final production verification:

  • Forgejo Actions run #124 — success
  • verifyDebug — BUILD SUCCESSFUL in 7m 58s
  • playback:detektDebug — passed
  • playback:ktlintMainSourceSetCheck — passed
  • playback:testDebugUnitTest — passed

Mutation proof:

  • temporary mutation head 621b82d73102f4ad01425b4fb8bd02fa8b5b0102;
  • run #126 removed only the resume callback while leaving the policy decision in place;
  • CarArrivalResumeGateTest then failed the expected resume assertions, including the main measured focus-loss + car-arrival case;
  • the mutation run was cancelled after the proof and the temporary mutation branch was deleted.

PR #60 is mergeable and remains unmerged for owner review.

## #36 implementation verification PR #60 is open from `mcp/issue-36-car-arrival-continuity` at exact head `7f185ab895aa911b983d95d642d8c1dc4dcc1004`. The earlier verifyDebug failure was fixed without changing the continuity policy: - Detekt: reduced `CarArrivalResumeGate.takeForCarArrival` return count. - KtLint: normalized short parameter-list formatting. Final production verification: - Forgejo Actions run #124 — **success** - `verifyDebug` — **BUILD SUCCESSFUL in 7m 58s** - `playback:detektDebug` — passed - `playback:ktlintMainSourceSetCheck` — passed - `playback:testDebugUnitTest` — passed Mutation proof: - temporary mutation head `621b82d73102f4ad01425b4fb8bd02fa8b5b0102`; - run #126 removed only the resume callback while leaving the policy decision in place; - `CarArrivalResumeGateTest` then failed the expected resume assertions, including the main measured focus-loss + car-arrival case; - the mutation run was cancelled after the proof and the temporary mutation branch was deleted. PR #60 is mergeable and remains unmerged for owner review.
Author
Owner

Physical re-test after PR #60 — still reproduces

The 2026-09-19 18:15 drive reproduces #36 on merged main 62ec15362ca613854c111bd660727675af3081cb.

Measured sequence:

  • 18:15:09 — playWhenReady=false reason=audioFocusLoss.
  • 18:15:13 — first Android Auto controller bind: controller=com.google.android.projection.gearhead.
  • 18:15:13 — #11 begins reasserting Bluetooth and reports asked=bluetooth connected=true.
  • 18:15:13 — during Android Auto route churn, Android temporarily removes that Bluetooth output: The chosen audio output disconnected, so routing is automatic again kind=bluetooth; output snapshot collapses to Speaker.
  • 18:15:14 — the Bluetooth device appears again and #11 finishes the hold: A car connected and the book was held in the headset kind=bluetooth.
  • The #36 success log Playback resumed after the car took audio focus never appears.
  • Playback remains paused until a later reason=userRequest.

This exposes a post-#60 race: the pause candidate is valid and the #11 hold succeeds, but the current implementation re-reads RouteHeardOwnership.heardRoute after the transient device-list removal has retired it. The resume gate therefore rejects the candidate even though the same book generation and headset are still the intended continuity target.

There is also a timing-model issue: the six-second correlation window is currently measured after the asynchronous route reassert/settle, not at the actual first car-bind timestamp. The observed focus-loss→first-bind interval here is about four seconds.

Follow-up should preserve the narrow measured trigger while:

  1. pairing the focus loss to the first car-bind timestamp;
  2. using the stable loaded-book generation rather than requiring live heardRoute to survive Android Auto's transient output-list flap;
  3. requiring the same pause-time headset id;
  4. independently rejecting any newer explicit output-selection sequence;
  5. retaining existing cancellation on Play, non-focus pause, book/queue change, and no speaker/car destination.
## Physical re-test after PR #60 — still reproduces The 2026-09-19 18:15 drive reproduces #36 on merged main `62ec15362ca613854c111bd660727675af3081cb`. Measured sequence: - 18:15:09 — `playWhenReady=false reason=audioFocusLoss`. - 18:15:13 — first Android Auto controller bind: `controller=com.google.android.projection.gearhead`. - 18:15:13 — #11 begins reasserting Bluetooth and reports `asked=bluetooth connected=true`. - 18:15:13 — during Android Auto route churn, Android temporarily removes that Bluetooth output: `The chosen audio output disconnected, so routing is automatic again kind=bluetooth`; output snapshot collapses to `Speaker`. - 18:15:14 — the Bluetooth device appears again and #11 finishes the hold: `A car connected and the book was held in the headset kind=bluetooth`. - The #36 success log `Playback resumed after the car took audio focus` never appears. - Playback remains paused until a later `reason=userRequest`. This exposes a post-#60 race: the pause candidate is valid and the #11 hold succeeds, but the current implementation re-reads `RouteHeardOwnership.heardRoute` after the transient device-list removal has retired it. The resume gate therefore rejects the candidate even though the same book generation and headset are still the intended continuity target. There is also a timing-model issue: the six-second correlation window is currently measured after the asynchronous route reassert/settle, not at the actual first car-bind timestamp. The observed focus-loss→first-bind interval here is about four seconds. Follow-up should preserve the narrow measured trigger while: 1. pairing the focus loss to the first car-bind timestamp; 2. using the stable loaded-book generation rather than requiring live `heardRoute` to survive Android Auto's transient output-list flap; 3. requiring the same pause-time headset id; 4. independently rejecting any newer explicit output-selection sequence; 5. retaining existing cancellation on Play, non-focus pause, book/queue change, and no speaker/car destination.
Author
Owner

CI follow-up for the second physical-drive fix:

  • Run #138 on b49d53acc3ffb354106714acd05b7c2f52e8d282 failed only at :playback:detektDebug.
  • Exact violation: PlaybackService.kt:1148 — holdHeadsetAgainstCar had 5 return statements, exceeding the repository ReturnCount limit of 4.
  • KtLint passed; no behavioral/unit-test failure was reported before the Detekt gate stopped the build.
  • The control flow was mechanically collapsed without changing the route/resume policy.
  • New exact branch head: 4a60b729ffee61465cb10c5806b41317b284e379.
  • Full rerun: #139.
CI follow-up for the second physical-drive fix: - Run #138 on `b49d53acc3ffb354106714acd05b7c2f52e8d282` failed only at `:playback:detektDebug`. - Exact violation: `PlaybackService.kt:1148` — `holdHeadsetAgainstCar` had 5 return statements, exceeding the repository ReturnCount limit of 4. - KtLint passed; no behavioral/unit-test failure was reported before the Detekt gate stopped the build. - The control flow was mechanically collapsed without changing the route/resume policy. - New exact branch head: `4a60b729ffee61465cb10c5806b41317b284e379`. - Full rerun: #139.
alexander referenced this issue from a commit 2026-09-19 21:35:00 +02:00
Author
Owner

Physical re-test — 2026-09-20 around 19:34–19:38

The owner re-tested the merged car/headset continuity work on the projected Android Auto setup.

Observed behavior

  • Car entry: while listening through the headset, connecting/entering the car causes the audiobook to pause for a few seconds.
  • Car exit: leaving/stopping the car stops the audiobook.
  • The requested behavior remains: a car lifecycle transition must not interrupt an audiobook that should remain in the headset.

This means #36 is still reproduced physically and remains open.

Event-log evidence supplied with this drive

The supplied excerpt records the application/auth/sync lifecycle:

  • 19:34:17 — application starts; active profile session is restored.
  • 19:34:17 — initial authorize returns 401, refresh succeeds, authorize then succeeds, and foreground realtime ownership starts.
  • 19:34:18–19:34:21 — permissions/progress/bookmark/library refresh completes; progress refreshes report written=0.
  • 19:34:24 — foreground realtime ownership is released and the realtime connection closes.
  • 19:38:03 — foreground realtime ownership starts again; authorize succeeds and permissions refresh.
  • 19:38:04 — realtime connection is authenticated; progress refresh again reports written=0.

The excerpt does not contain a playWhenReady transition/reason, audioFocusLoss, Android Auto controller bind/disconnect, route/output diagnostics, or the #36 continuity-gate decision. It therefore does not independently identify the playback-stop mechanism and should not be used to attribute the pause/stop to sync or authentication.

The zero-write progress refreshes and successful auth/realtime transitions also provide no evidence that the sync lifecycle itself intentionally stopped playback.

Investigation status

Earlier physical evidence in this issue already measured playWhenReady=false reason=audioFocusLoss immediately before car arrival and exposed the Android Auto route-list flap/race during headset reassertion. The new drive confirms the user-visible defect remains after the merged work, including a car-exit stop as well as the short car-entry interruption, but this particular log slice does not narrow the lower-level cause further.

A future diagnostic capture should include the Playback-category lines around both car entry and exit, especially:

  • playWhenReady change reason;
  • first/last com.google.android.projection.gearhead controller bind/disconnect;
  • The car output actions were recomputed;
  • headset hold / chosen-output disconnect and reappearance;
  • #36 resume-gate arm/accept/reject/cancel/result logs.

Keep the existing narrow safety requirements: never resume a deliberately paused book, never resume onto speaker/car when headset continuity was intended, and preserve profile/book/generation/output-selection guards.

## Physical re-test — 2026-09-20 around 19:34–19:38 The owner re-tested the merged car/headset continuity work on the projected Android Auto setup. ### Observed behavior - **Car entry:** while listening through the headset, connecting/entering the car causes the audiobook to pause for a few seconds. - **Car exit:** leaving/stopping the car stops the audiobook. - The requested behavior remains: a car lifecycle transition must not interrupt an audiobook that should remain in the headset. This means #36 is **still reproduced physically** and remains open. ### Event-log evidence supplied with this drive The supplied excerpt records the application/auth/sync lifecycle: - 19:34:17 — application starts; active profile session is restored. - 19:34:17 — initial authorize returns 401, refresh succeeds, authorize then succeeds, and foreground realtime ownership starts. - 19:34:18–19:34:21 — permissions/progress/bookmark/library refresh completes; progress refreshes report `written=0`. - 19:34:24 — foreground realtime ownership is released and the realtime connection closes. - 19:38:03 — foreground realtime ownership starts again; authorize succeeds and permissions refresh. - 19:38:04 — realtime connection is authenticated; progress refresh again reports `written=0`. The excerpt does **not** contain a `playWhenReady` transition/reason, `audioFocusLoss`, Android Auto controller bind/disconnect, route/output diagnostics, or the #36 continuity-gate decision. It therefore does not independently identify the playback-stop mechanism and should not be used to attribute the pause/stop to sync or authentication. The zero-write progress refreshes and successful auth/realtime transitions also provide no evidence that the sync lifecycle itself intentionally stopped playback. ### Investigation status Earlier physical evidence in this issue already measured `playWhenReady=false reason=audioFocusLoss` immediately before car arrival and exposed the Android Auto route-list flap/race during headset reassertion. The new drive confirms the user-visible defect remains after the merged work, including a **car-exit stop** as well as the short car-entry interruption, but this particular log slice does not narrow the lower-level cause further. A future diagnostic capture should include the Playback-category lines around both car entry and exit, especially: - `playWhenReady` change reason; - first/last `com.google.android.projection.gearhead` controller bind/disconnect; - `The car output actions were recomputed`; - headset hold / chosen-output disconnect and reappearance; - #36 resume-gate arm/accept/reject/cancel/result logs. Keep the existing narrow safety requirements: never resume a deliberately paused book, never resume onto speaker/car when headset continuity was intended, and preserve profile/book/generation/output-selection guards.
Author
Owner

Physical re-test — 2026-09-22, car arrival and departure both still stop playback

Reproduced again on a real drive. The audiobook was intended to remain on the Bluetooth headset throughout the car lifecycle, but playback stopped completely both when starting the car / Android Auto and when stopping the car.

This capture contains the Playback-category evidence that was missing from the previous drive.

Car arrival: continuity chain is lost

Relevant sequence:

  • 06:56:49 — Android reports a Bluetooth route/device transition while a book is loaded.
  • 06:56:49 — playWhenReady=false reason=becomingNoisy.
  • 06:56:49 — output snapshots flap between Speaker+Ambiguous* onHeadset=true and Speaker* onHeadset=false.
  • 06:56:50 — playWhenReady=false reason=audioFocusLoss.
  • 06:56:50 — arrival continuity decision is rejected:
    source=audio-focus-loss phase=Arrival status=Rejected reason=NoQualifyingHeadset kind=none.
  • 06:56:55 — first Android Auto controller bind:
    controller=com.google.android.projection.gearhead firstArrival=true.
  • 06:56:55 — first-car-bind continuity decision is also rejected:
    source=first-car-bind phase=Arrival status=Rejected reason=NoPendingFocusLoss kind=none.
  • 06:57:04 — a later controller bind is explicitly ignored as a new arrival.
  • 06:57:04 — playback only resumes because of reason=userRequest.
  • 06:57:08 — headset is again recognized: onHeadset=true.

This is a concrete failure mode in the current arrival state machine. The system pause begins with becomingNoisy, route observation temporarily loses headset qualification, then the following audioFocusLoss cannot arm the arrival candidate. By the time the first car bind arrives, there is no pending focus-loss candidate to consume.

The headset route itself is not permanently lost; it is visible again immediately after the transition. The continuity correlation is what fails.

Car departure: focus-loss candidate arms but playback still stops

At the later car-stop transition:

  • 07:19:50 — playWhenReady=false reason=audioFocusLoss.
  • 07:19:50 — departure continuity logic records:
    source=audio-focus-loss phase=Departure status=Armed reason=FocusLossWaitingForBoundary kind=bluetooth.
  • Playback nevertheless remains stopped rather than continuing on the headset.

The supplied excerpt does not yet show a subsequent final-departure boundary decision after this arm, so the next investigation needs to determine whether the expected controller/route boundary never arrives, arrives in a shape the gate does not recognize, or is consumed/cancelled incorrectly.

Authentication noise is not the pause cause

Immediately after the 07:19:50 departure pause, position/session sync calls receive 401 responses and the session refreshes successfully at 07:19:56. Those failures affect progress synchronization, but the player log independently records reason=audioFocusLoss and the car lifecycle continuity decision at the moment playback stops. Do not attribute the playback interruption to authentication without separate evidence.

Updated implementation requirements

The next #36 fix should treat arrival and departure as two separately proven failing paths.

For arrival:

  1. Preserve enough headset/generation evidence across the transient Android route-list flap caused by car startup.
  2. Correlate the observed becomingNoisy + audioFocusLoss sequence with the first car bind without broadly resuming unrelated system pauses.
  3. Do not require the live route snapshot to still report a qualifying headset during the transient gap if the same stable headset/generation continuity target is otherwise proven.
  4. Continue to reject deliberate user pauses, book/queue changes, newer explicit output selections, speaker destinations, and car destinations.

For departure:

  1. Follow the armed FocusLossWaitingForBoundary candidate through controller disconnect / route boundary handling.
  2. Prove why the armed candidate does not produce continuity on the real device.
  3. Preserve the same safety rule: never turn an intentional pause into playback.

Acceptance remains

  • Starting/connecting the car while listening on a headset does not interrupt the audiobook; it continues in the headset.
  • Stopping/leaving the car likewise does not stop an audiobook that should continue in the headset.
  • No automatic resume onto phone speaker or car output.
  • No automatic resume after a deliberate user pause.
  • Regression tests must fail when the corresponding continuity behavior is removed, and physical Android Auto acceptance is still required.
## Physical re-test — 2026-09-22, car arrival and departure both still stop playback Reproduced again on a real drive. The audiobook was intended to remain on the Bluetooth headset throughout the car lifecycle, but playback stopped completely both when starting the car / Android Auto and when stopping the car. This capture contains the Playback-category evidence that was missing from the previous drive. ### Car arrival: continuity chain is lost Relevant sequence: - **06:56:49** — Android reports a Bluetooth route/device transition while a book is loaded. - **06:56:49** — `playWhenReady=false reason=becomingNoisy`. - **06:56:49** — output snapshots flap between `Speaker+Ambiguous* onHeadset=true` and `Speaker* onHeadset=false`. - **06:56:50** — `playWhenReady=false reason=audioFocusLoss`. - **06:56:50** — arrival continuity decision is rejected: `source=audio-focus-loss phase=Arrival status=Rejected reason=NoQualifyingHeadset kind=none`. - **06:56:55** — first Android Auto controller bind: `controller=com.google.android.projection.gearhead firstArrival=true`. - **06:56:55** — first-car-bind continuity decision is also rejected: `source=first-car-bind phase=Arrival status=Rejected reason=NoPendingFocusLoss kind=none`. - **06:57:04** — a later controller bind is explicitly ignored as a new arrival. - **06:57:04** — playback only resumes because of `reason=userRequest`. - **06:57:08** — headset is again recognized: `onHeadset=true`. This is a concrete failure mode in the current arrival state machine. The system pause begins with `becomingNoisy`, route observation temporarily loses headset qualification, then the following `audioFocusLoss` cannot arm the arrival candidate. By the time the first car bind arrives, there is no pending focus-loss candidate to consume. The headset route itself is not permanently lost; it is visible again immediately after the transition. The continuity correlation is what fails. ### Car departure: focus-loss candidate arms but playback still stops At the later car-stop transition: - **07:19:50** — `playWhenReady=false reason=audioFocusLoss`. - **07:19:50** — departure continuity logic records: `source=audio-focus-loss phase=Departure status=Armed reason=FocusLossWaitingForBoundary kind=bluetooth`. - Playback nevertheless remains stopped rather than continuing on the headset. The supplied excerpt does not yet show a subsequent final-departure boundary decision after this arm, so the next investigation needs to determine whether the expected controller/route boundary never arrives, arrives in a shape the gate does not recognize, or is consumed/cancelled incorrectly. ### Authentication noise is not the pause cause Immediately after the 07:19:50 departure pause, position/session sync calls receive 401 responses and the session refreshes successfully at 07:19:56. Those failures affect progress synchronization, but the player log independently records `reason=audioFocusLoss` and the car lifecycle continuity decision at the moment playback stops. Do not attribute the playback interruption to authentication without separate evidence. ### Updated implementation requirements The next #36 fix should treat arrival and departure as two separately proven failing paths. For **arrival**: 1. Preserve enough headset/generation evidence across the transient Android route-list flap caused by car startup. 2. Correlate the observed `becomingNoisy` + `audioFocusLoss` sequence with the first car bind without broadly resuming unrelated system pauses. 3. Do not require the live route snapshot to still report a qualifying headset during the transient gap if the same stable headset/generation continuity target is otherwise proven. 4. Continue to reject deliberate user pauses, book/queue changes, newer explicit output selections, speaker destinations, and car destinations. For **departure**: 1. Follow the armed `FocusLossWaitingForBoundary` candidate through controller disconnect / route boundary handling. 2. Prove why the armed candidate does not produce continuity on the real device. 3. Preserve the same safety rule: never turn an intentional pause into playback. ### Acceptance remains - Starting/connecting the car while listening on a headset does not interrupt the audiobook; it continues in the headset. - Stopping/leaving the car likewise does not stop an audiobook that should continue in the headset. - No automatic resume onto phone speaker or car output. - No automatic resume after a deliberate user pause. - Regression tests must fail when the corresponding continuity behavior is removed, and physical Android Auto acceptance is still required.
Author
Owner

Physical acceptance failed after PR #89 / APK 0.10.6.1-2272 — issue reopened

PR #89 is merged at 88ae231ddc01897d83e24968bed5443ea861aedd, and the tested APK 0.10.6.1-2272 was built from that exact commit. The 2026-09-24 physical drive therefore tests the merged #89 implementation, not an older APK.

Arrival still pauses

Observed sequence:

  • 13:31:35 — playWhenReady=false reason=audioFocusLoss.
  • 13:31:35 — continuity arms correctly:
    source=audio-focus-loss phase=Arrival status=Armed reason=FocusLossWaitingForBoundary kind=bluetooth.
  • 13:31:38 — first Gearhead controller bind:
    controller=com.google.android.projection.gearhead firstArrival=true.
  • 13:31:38 — the old first-controller fallback matches the candidate:
    source=first-car-bind phase=Arrival status=Ready reason=BoundaryMatchedFocusLoss kind=bluetooth.
  • 13:31:38 — exact Bluetooth route recovery is secured and BookWave issues Play.

User-visible result: roughly three seconds of interruption, so the stronger projection-start path added in #89 did not shorten this transition.

Departure still stops

At 13:51:29:

  • playWhenReady=false reason=audioFocusLoss;
  • source=audio-focus-loss phase=Departure status=Armed reason=FocusLossWaitingForBoundary kind=bluetooth.

There is no subsequent projection-disconnect continuity decision in the supplied trace. Playback later resumes through a userRequest / resume-freshness path, not through car-continuity recovery.

At 13:56:23, becomingNoisy and Bluetooth disconnect/routing fallback occur while diagnostics still report carBound=true, again demonstrating that the legacy MediaSession controller lifetime remains stale relative to the physical car transition.

Critical #89 reachability finding

The merged #89 code logs every AndroidAutoProjectionMonitor.Update as:

Android Auto projection state changed previous=... current=... carBound=...

The complete physical trace contains no such event at all.

Therefore the new projection monitor did not produce a usable state transition on this drive. Both entry and exit continued through fallback behavior. #89's state machine may be sound in unit tests, but its new external signal is not yet proven reachable on the physical device.

Current implementation manually queries the androidx.car.app.connection provider but the installed app manifest has no package-visibility <queries> declaration for that provider. This is a concrete candidate cause and should be verified/fixed rather than assumed. Strong preference for the next repair: use the supported AndroidX CarConnection implementation instead of maintaining a partial hand-copy of its provider/receiver contract, unless repository constraints require otherwise.

Required diagnostic expansion before/with the next repair

The next build should make projection reachability self-diagnosing. Do not log only successful state changes.

Projection monitor lifecycle

Log structured events for:

  1. monitor start

    • API level;
    • native-automotive feature yes/no;
    • whether the provider is resolvable/visible;
    • initial refresh requested.
  2. receiver event

    • action received;
    • whether a refresh was launched/coalesced.
  3. provider / CarConnection read result

    • trigger: initial or broadcast;
    • raw connection value when available;
    • mapped state: Unknown / NotConnected / Native / Projection;
    • read duration;
    • provider-visible/resolvable result.
  4. read failure

    • do not silently collapse every exception into Unknown;
    • log exception class / diagnostic reason such as provider-not-visible, security exception, missing column, empty cursor, invalid value;
    • still preserve the safety rule that failure maps to Unknown and never authorizes playback.
  5. monitor stop

    • last known state;
    • whether the receiver was registered.

Continuity coordinator snapshot

For every car lifecycle input — focus loss, projection edge, Gearhead bind/disconnect, noisy route event — log one compact state snapshot containing:

  • event source;
  • projection state;
  • projectionOwnsCarLifecycle;
  • carContinuitySessionEstablished;
  • controller binding count / carBound;
  • pending continuity phase/status, if any;
  • captured route kind/id fingerprint;
  • current generation;
  • explicit-selection sequence;
  • decision: armed / ready / rejected / ignored / cancelled;
  • reason.

This should make one physical trace answer, without inference:

  • Did Android report Projection at all?
  • Did BookWave receive the broadcast?
  • Could BookWave resolve/read the provider?
  • Which signal arrived first?
  • Why did the state machine ignore or accept it?
  • Was a stale Gearhead binding still counted after physical exit?

Correlation aid

Add a monotonic car-transition trace id (incremented when a new arrival/departure candidate begins) to all related lines. The current logs are good individually, but correlating focus, route, projection and controller events across several seconds is still more manual than necessary.

Acceptance requirement for the next repair

Do not close #36 merely because CI is green. Physical acceptance must show the projection signal itself becoming reachable.

For projected Android Auto, capture at least:

  • entry: a positive transition to Projection (or equivalent supported API state);
  • exit: a transition from Projection to NotConnected;
  • the continuity decision sourced from that projection edge;
  • exact-headset recovery with no route substitution;
  • no duplicate Play from a late Gearhead disconnect.

If those projection events are absent, the build is diagnostically incomplete even if fallback recovery still works.

Issue remains open pending implementation and physical acceptance.

## Physical acceptance failed after PR #89 / APK 0.10.6.1-2272 — issue reopened PR #89 is merged at `88ae231ddc01897d83e24968bed5443ea861aedd`, and the tested APK `0.10.6.1-2272` was built from that exact commit. The 2026-09-24 physical drive therefore tests the merged #89 implementation, not an older APK. ### Arrival still pauses Observed sequence: - **13:31:35** — `playWhenReady=false reason=audioFocusLoss`. - **13:31:35** — continuity arms correctly: `source=audio-focus-loss phase=Arrival status=Armed reason=FocusLossWaitingForBoundary kind=bluetooth`. - **13:31:38** — first Gearhead controller bind: `controller=com.google.android.projection.gearhead firstArrival=true`. - **13:31:38** — the old first-controller fallback matches the candidate: `source=first-car-bind phase=Arrival status=Ready reason=BoundaryMatchedFocusLoss kind=bluetooth`. - **13:31:38** — exact Bluetooth route recovery is secured and BookWave issues Play. User-visible result: roughly **three seconds of interruption**, so the stronger projection-start path added in #89 did not shorten this transition. ### Departure still stops At **13:51:29**: - `playWhenReady=false reason=audioFocusLoss`; - `source=audio-focus-loss phase=Departure status=Armed reason=FocusLossWaitingForBoundary kind=bluetooth`. There is no subsequent `projection-disconnect` continuity decision in the supplied trace. Playback later resumes through a `userRequest` / resume-freshness path, not through car-continuity recovery. At **13:56:23**, `becomingNoisy` and Bluetooth disconnect/routing fallback occur while diagnostics still report `carBound=true`, again demonstrating that the legacy MediaSession controller lifetime remains stale relative to the physical car transition. ### Critical #89 reachability finding The merged #89 code logs every `AndroidAutoProjectionMonitor.Update` as: `Android Auto projection state changed previous=... current=... carBound=...` The complete physical trace contains **no such event at all**. Therefore the new projection monitor did not produce a usable state transition on this drive. Both entry and exit continued through fallback behavior. #89's state machine may be sound in unit tests, but its new external signal is not yet proven reachable on the physical device. Current implementation manually queries the `androidx.car.app.connection` provider but the installed app manifest has no package-visibility `<queries>` declaration for that provider. This is a concrete candidate cause and should be verified/fixed rather than assumed. Strong preference for the next repair: use the supported AndroidX `CarConnection` implementation instead of maintaining a partial hand-copy of its provider/receiver contract, unless repository constraints require otherwise. ## Required diagnostic expansion before/with the next repair The next build should make projection reachability self-diagnosing. Do not log only successful state changes. ### Projection monitor lifecycle Log structured events for: 1. **monitor start** - API level; - native-automotive feature yes/no; - whether the provider is resolvable/visible; - initial refresh requested. 2. **receiver event** - action received; - whether a refresh was launched/coalesced. 3. **provider / CarConnection read result** - trigger: `initial` or `broadcast`; - raw connection value when available; - mapped state: Unknown / NotConnected / Native / Projection; - read duration; - provider-visible/resolvable result. 4. **read failure** - do not silently collapse every exception into `Unknown`; - log exception class / diagnostic reason such as provider-not-visible, security exception, missing column, empty cursor, invalid value; - still preserve the safety rule that failure maps to Unknown and never authorizes playback. 5. **monitor stop** - last known state; - whether the receiver was registered. ### Continuity coordinator snapshot For every car lifecycle input — focus loss, projection edge, Gearhead bind/disconnect, noisy route event — log one compact state snapshot containing: - event source; - projection state; - `projectionOwnsCarLifecycle`; - `carContinuitySessionEstablished`; - controller binding count / `carBound`; - pending continuity phase/status, if any; - captured route kind/id fingerprint; - current generation; - explicit-selection sequence; - decision: armed / ready / rejected / ignored / cancelled; - reason. This should make one physical trace answer, without inference: - Did Android report Projection at all? - Did BookWave receive the broadcast? - Could BookWave resolve/read the provider? - Which signal arrived first? - Why did the state machine ignore or accept it? - Was a stale Gearhead binding still counted after physical exit? ### Correlation aid Add a monotonic **car-transition trace id** (incremented when a new arrival/departure candidate begins) to all related lines. The current logs are good individually, but correlating focus, route, projection and controller events across several seconds is still more manual than necessary. ## Acceptance requirement for the next repair Do not close #36 merely because CI is green. Physical acceptance must show the projection signal itself becoming reachable. For projected Android Auto, capture at least: - entry: a positive transition to `Projection` (or equivalent supported API state); - exit: a transition from `Projection` to `NotConnected`; - the continuity decision sourced from that projection edge; - exact-headset recovery with no route substitution; - no duplicate Play from a late Gearhead disconnect. If those projection events are absent, the build is diagnostically incomplete even if fallback recovery still works. Issue remains open pending implementation and physical acceptance.
Author
Owner

Diagnostics implementation staged — car/projection lifecycle trace

Implementation branch: mcp/issues-36-88-android-auto-diagnostics
Current head: 70f9811f7fd92770865ce061540f9c7a1a708ac4
Base: main@68ac79ace9f9d38d450458ad28a1ffe4d0b632af
Base relation at handoff: 0 behind main.

This is deliberately a diagnostics/event-handler change, not a new continuity-policy fix.

Added for #36

  • New event-log category/filter: Android Auto.
  • One correlated auto-N trace can begin as early as becomingNoisy / audioFocusLoss and is reused by the following Gearhead bind/projection edge within the bounded transition window.
  • Car continuity decisions now carry a compact state snapshot:
    • projection state;
    • whether projection owns lifecycle;
    • established car-session state;
    • controller-bound state;
    • pending continuity Play;
    • book generation;
    • explicit-output selection sequence.
  • Route/output recomputation is mirrored into the active Android Auto trace, including route-known, output roles, onCar and onHeadset.
  • Media3 current-item transitions during the trace are recorded with a privacy-safe item fingerprint.

Projection observer is now self-diagnosing

The projection monitor no longer logs only a successful state transition. It records:

  • monitor start/stop;
  • API level / Automotive feature;
  • whether androidx.car.app.connection is resolvable/visible;
  • receiver registration state;
  • update broadcasts;
  • every initial/broadcast provider read;
  • raw value when available;
  • mapped Unknown / NotConnected / Native / Projection state;
  • reason such as null cursor, empty cursor, missing column, invalid value, security exception, or illegal argument;
  • read duration;
  • receiver registration/unregister failures.

Safety remains unchanged: unreadable/failed state is Unknown, never a manufactured disconnect and never authority to Play.

The generic exception handling was deliberately narrowed to repository-approved platform exception types.

CI / PR state

No CI has been started.

No PR has been opened yet because current .forgejo/workflows/pull-request.yml automatically launches the Quick gate on pull_request: opened. The owner explicitly asked to start CI manually, so opening a PR here would have started a run contrary to that instruction.

Physical acceptance remains required after a build is available.

## Diagnostics implementation staged — car/projection lifecycle trace Implementation branch: `mcp/issues-36-88-android-auto-diagnostics` Current head: `70f9811f7fd92770865ce061540f9c7a1a708ac4` Base: `main@68ac79ace9f9d38d450458ad28a1ffe4d0b632af` Base relation at handoff: 0 behind main. This is deliberately a diagnostics/event-handler change, not a new continuity-policy fix. ### Added for #36 - New event-log category/filter: **Android Auto**. - One correlated `auto-N` trace can begin as early as `becomingNoisy` / `audioFocusLoss` and is reused by the following Gearhead bind/projection edge within the bounded transition window. - Car continuity decisions now carry a compact state snapshot: - projection state; - whether projection owns lifecycle; - established car-session state; - controller-bound state; - pending continuity Play; - book generation; - explicit-output selection sequence. - Route/output recomputation is mirrored into the active Android Auto trace, including route-known, output roles, onCar and onHeadset. - Media3 current-item transitions during the trace are recorded with a privacy-safe item fingerprint. ### Projection observer is now self-diagnosing The projection monitor no longer logs only a successful state transition. It records: - monitor start/stop; - API level / Automotive feature; - whether `androidx.car.app.connection` is resolvable/visible; - receiver registration state; - update broadcasts; - every initial/broadcast provider read; - raw value when available; - mapped Unknown / NotConnected / Native / Projection state; - reason such as null cursor, empty cursor, missing column, invalid value, security exception, or illegal argument; - read duration; - receiver registration/unregister failures. Safety remains unchanged: unreadable/failed state is `Unknown`, never a manufactured disconnect and never authority to Play. The generic exception handling was deliberately narrowed to repository-approved platform exception types. ### CI / PR state No CI has been started. No PR has been opened yet because current `.forgejo/workflows/pull-request.yml` automatically launches the Quick gate on `pull_request: opened`. The owner explicitly asked to start CI manually, so opening a PR here would have started a run contrary to that instruction. Physical acceptance remains required after a build is available.
Sign in to join this conversation.
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#36
No description provided.