Car action still does not show as selected when the car is the output #34

Closed
opened 2026-09-18 08:47:28 +02:00 by alexander · 5 comments
Owner

Migrated from GitHub issue #126. Forgejo issue: #34. 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, after GitHub #78: "The selected car is still not displaying as selected." This is the fourth report of the same symptom, and three separate app-side causes have already been found and fixed for it. Tracked as docs/risks.md R-107.

What has been fixed already, and why none of it was enough

Cause Commit Was it real?
MediaSession.setMediaButtonPreferences(List) never refreshes the legacy PlaybackStateCompat, so a changed icon was not delivered to a car at all 5574f52 Yes — measured in media3-session 1.11.0 bytecode
The route was never re-read when a car bound: Android Auto activating an already-connected A2DP link fires no AudioDeviceCallback, so the icon was decided from a pre-drive route 2532bdc Yes — AudioOutputRouter.resettle added
A reported speaker could mask a reported dashboard, because current() took the first active output in AudioManager.getDevices enumeration order 2532bdc Yes
The lit indicator sat in the outermost 14% of the icon, where a host cropping into a circular button would lose it 2532bdc Unverified — moved inside the safe area

Each was a genuine defect. None of them closed the symptom.

What is settled and should not be re-litigated

  • There is no "selected" state for a media custom action. PlaybackStateCompat.CustomAction carries action / name / icon / extras and nothing else, and MediaConstants has no toggle key. Google's own guidance is to publish a different icon for the different state. Swapping the drawable under one action id is the documented mechanism, so the design is right.
  • The delivery chain is clean. After the per-controller republish through getMediaNotificationControllerInfo(), MediaSessionLegacyStub recomputes customLayout, rebuilds a fresh PlaybackStateCompat with CustomAction.Builder(action, displayName, iconResId), and broadcasts it with no equality check at any layer. A changed setCustomIconResId does reach the platform session on every republish.

The remaining candidates

  1. onCar is false on this device. Most likely. TYPE_BUS — the only type mapped to AudioOutputRole.Car — is the automotive HAL's own output and is not what a projecting phone exposes, so on projected Android Auto the only path that lights Car is the ambiguous-A2DP-dashboard case. If the phone reports the media route as a type OutputDevices.roleOf sends to Speaker/Other, or one kindOf drops entirely, both glyphs correctly stay dark.
  2. Below API 33 both glyphs are structurally dark. routedIds() returns null, isActive degenerates to id == chosen, and Car selects Automatic (null), so nothing is ever active. Check the test phone's API level before reading anything else.
  3. The host ignores or caches the icon per action id. No primary source either way. Media3 1.11 itself ships an AndroidAutoConnectionStateObserver and a needsButtonReservationWorkaroundForSeekbar branch inside the method that builds customLayout, which is direct evidence that the Android Auto host deviates from what the API implies.
  4. The indicator is drawn but not legible at the size the host renders.

The next step is a measurement, not a change

PlaybackService.republishOutputButtons now logs, on every recomputation:

"The car output actions were recomputed"
  api=<SDK_INT>  carBound=<true|false>  routeKnown=<true|false>
  outputs=<Role[*]+Role...>  (a trailing * marks the active one)
  onCar=<true|false>  onHeadset=<true|false>

One drive with that line separates candidates 1–3 definitively. Capture it while the car is connected and the book is playing through the car.

  • If onCar=true and the glyph is still unlit → candidate 3 or 4, and it is a host problem, not an app one.
  • If onCar=false → read outputs for which role the car's route actually got.
  • If api is below 33 → candidate 2, and the feature cannot work on that phone at all.

If it turns out to be the host

The cheapest probe is not two action ids — change the displayName alongside the icon and see whether the host redraws the label. That separates "the host ignored the new state object" from "the host redrew but the indicator is invisible".

Two distinct action ids stay a last resort: they require granting the second SessionCommand in onConnect (or createPlaybackStateCompat silently drops the button), require onCustomCommand to keep handling the old id forever because a cached host layout can send it, and change the action's identity in the phone notification and for every Media3 controller on every route change.

  • docs/risks.md R-107
  • ADR-0029 §8, which has been corrected three times on this surface and records why
  • Needs the same drive as R-10
> Migrated from [GitHub issue #126](https://github.com/AlexanderWilhelmsenBerg/Audiobookshelf-Manager-Claude/issues/126). Forgejo issue: #34. 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, after [GitHub #78](https://github.com/AlexanderWilhelmsenBerg/Audiobookshelf-Manager-Claude/issues/78): *"The selected car is still not displaying as selected."* This is the fourth report of the same symptom, and three separate app-side causes have already been found and fixed for it. Tracked as `docs/risks.md` R-107. ## What has been fixed already, and why none of it was enough | Cause | Commit | Was it real? | |---|---|---| | `MediaSession.setMediaButtonPreferences(List)` never refreshes the legacy `PlaybackStateCompat`, so a changed icon was not delivered to a car at all | `5574f52` | Yes — measured in media3-session 1.11.0 bytecode | | The route was never re-read when a car bound: Android Auto activating an already-connected A2DP link fires no `AudioDeviceCallback`, so the icon was decided from a pre-drive route | `2532bdc` | Yes — `AudioOutputRouter.resettle` added | | A reported speaker could mask a reported dashboard, because `current()` took the first active output in `AudioManager.getDevices` enumeration order | `2532bdc` | Yes | | The lit indicator sat in the outermost 14% of the icon, where a host cropping into a circular button would lose it | `2532bdc` | Unverified — moved inside the safe area | Each was a genuine defect. None of them closed the symptom. ## What is settled and should not be re-litigated - **There is no "selected" state for a media custom action.** `PlaybackStateCompat.CustomAction` carries action / name / icon / extras and nothing else, and `MediaConstants` has no toggle key. Google's own guidance is to publish a different icon for the different state. Swapping the drawable under one action id is the documented mechanism, so the *design* is right. - **The delivery chain is clean.** After the per-controller republish through `getMediaNotificationControllerInfo()`, `MediaSessionLegacyStub` recomputes `customLayout`, rebuilds a fresh `PlaybackStateCompat` with `CustomAction.Builder(action, displayName, iconResId)`, and broadcasts it with no equality check at any layer. A changed `setCustomIconResId` does reach the platform session on every republish. ## The remaining candidates 1. **`onCar` is false on this device.** Most likely. `TYPE_BUS` — the only type mapped to `AudioOutputRole.Car` — is the automotive HAL's own output and is not what a *projecting* phone exposes, so on projected Android Auto the only path that lights Car is the ambiguous-A2DP-dashboard case. If the phone reports the media route as a type `OutputDevices.roleOf` sends to `Speaker`/`Other`, or one `kindOf` drops entirely, both glyphs correctly stay dark. 2. **Below API 33 both glyphs are structurally dark.** `routedIds()` returns null, `isActive` degenerates to `id == chosen`, and Car selects Automatic (`null`), so nothing is ever active. **Check the test phone's API level before reading anything else.** 3. **The host ignores or caches the icon per action id.** No primary source either way. Media3 1.11 itself ships an `AndroidAutoConnectionStateObserver` and a `needsButtonReservationWorkaroundForSeekbar` branch inside the method that builds `customLayout`, which is direct evidence that the Android Auto host deviates from what the API implies. 4. **The indicator is drawn but not legible** at the size the host renders. ## The next step is a measurement, not a change `PlaybackService.republishOutputButtons` now logs, on every recomputation: ``` "The car output actions were recomputed" api=<SDK_INT> carBound=<true|false> routeKnown=<true|false> outputs=<Role[*]+Role...> (a trailing * marks the active one) onCar=<true|false> onHeadset=<true|false> ``` One drive with that line separates candidates 1–3 definitively. Capture it while the car is connected and the book is playing through the car. - If `onCar=true` and the glyph is still unlit → candidate 3 or 4, and it is a host problem, not an app one. - If `onCar=false` → read `outputs` for which role the car's route actually got. - If `api` is below 33 → candidate 2, and the feature cannot work on that phone at all. ## If it turns out to be the host The cheapest probe is **not** two action ids — change the `displayName` alongside the icon and see whether the host redraws the label. That separates "the host ignored the new state object" from "the host redrew but the indicator is invisible". Two distinct action ids stay a last resort: they require granting the second `SessionCommand` in `onConnect` (or `createPlaybackStateCompat` silently drops the button), require `onCustomCommand` to keep handling the old id forever because a cached host layout can send it, and change the action's identity in the phone notification and for every Media3 controller on every route change. ## Related - `docs/risks.md` R-107 - ADR-0029 §8, which has been corrected three times on this surface and records why - Needs the same drive as R-10
Author
Owner

Implemented in PR #61. The Car action now publishes a distinct active command identity plus the existing active glyph and a Playing in car label when onCar=true. Both active and inactive command IDs remain granted and handled for cached Android Auto layouts. Route computation and the existing redaction-safe diagnostic are unchanged. Physical Android Auto acceptance is still required before closing.

Implemented in PR #61. The Car action now publishes a distinct active command identity plus the existing active glyph and a `Playing in car` label when `onCar=true`. Both active and inactive command IDs remain granted and handled for cached Android Auto layouts. Route computation and the existing redaction-safe diagnostic are unchanged. Physical Android Auto acceptance is still required before closing.
Author
Owner

Physical re-test on PR #61 (2026-09-19) still showed Car unselected after pressing Car. This invalidated the cache-busting-only assumption. The branch now preserves Car as a distinct explicit semantic intent instead of collapsing it with generic Automatic (selectedId=null), and explicit-intent changes republish the media buttons immediately. A confirmed headset route still overrides the Car presentation so #11/#36 ownership remains intact. Re-test required before closing.

Physical re-test on PR #61 (2026-09-19) still showed Car unselected after pressing Car. This invalidated the cache-busting-only assumption. The branch now preserves Car as a distinct explicit semantic intent instead of collapsing it with generic Automatic (`selectedId=null`), and explicit-intent changes republish the media buttons immediately. A confirmed headset route still overrides the Car presentation so #11/#36 ownership remains intact. Re-test required before closing.
Author
Owner

Implementation moved from stale PR #61 to replacement PR #67, recreated from current main so it is fast-forward clean. #67 retains the explicit semantic Car intent, immediate republish, active action identity, and the tightened rule that a Car press may bridge only a no-route/built-in-speaker observation gap; definite headset and known Other routes veto the selected-state fallback. Physical car acceptance remains required.

Implementation moved from stale PR #61 to replacement PR #67, recreated from current `main` so it is fast-forward clean. #67 retains the explicit semantic Car intent, immediate republish, active action identity, and the tightened rule that a Car press may bridge only a no-route/built-in-speaker observation gap; definite headset and known Other routes veto the selected-state fallback. Physical car acceptance remains required.
Author
Owner

Physical acceptance — 2026-09-20

Owner re-tested the merged Android Auto output-state work on the projected head unit.

Result: the Car action/icon now visibly displays the selected state correctly when the car is the output.

This is physical confirmation that the original #34 symptom is no longer reproducing on the tested setup. No new app-side change is requested from this field report.

## Physical acceptance — 2026-09-20 Owner re-tested the merged Android Auto output-state work on the projected head unit. **Result:** the Car action/icon now visibly displays the selected state correctly when the car is the output. This is physical confirmation that the original #34 symptom is no longer reproducing on the tested setup. No new app-side change is requested from this field report.
Author
Owner

Canonical acceptance — 2026-09-24

Reviewed main: 88ae231ddc01897d83e24968bed5443ea861aedd
Merged implementation: PR #67, accepted head 20dae444aa5f8b4a41bd673d90f76b043027dc97, merge commit fea83c6abc1354e8d831a012881cc20f0afa81c0.

Evidence reconciliation

  • PR #67 is merged and its output-selection implementation remains present on current main.
  • Current AudioOutputRoles still treats Car as a positive semantic state rather than “not Headset”: explicit Car can bridge only the projected no-route/built-in-speaker gap, while a definite headset or known Other route vetoes the Car-selected glyph.
  • Current PlaybackService still republishes immediately when explicit output intent changes and still derives carRequested from ExplicitDestination.Car.
  • Current MediaButtonPublishing still republishes both globally and through Media3's media-notification controller so the legacy Android Auto PlaybackStateCompat is refreshed.
  • The active Car action keeps a distinct action identity for host cache busting, while both active/inactive identities remain accepted if a host sends a cached action.
  • Relevant JVM/Robolectric tests remain on main, including explicit-Car/no-route, headset/Other veto, route-role selection, active-action identity, and legacy republish coverage.
  • Later PR #89 touched the shared PlaybackService integration seam. Its exact head 200b3d9e2a715273fbe32495479eb896e8974b7e passed Forgejo run #270: verifyDebug, 2606 tests / 0 failures, ktlint, detekt, Android Lint and Room schema checks. Current-main push run #271 also passed at 88ae231d....

Existing physical evidence

The issue already records owner projected-head-unit acceptance on 2026-09-20:

“the Car action/icon visibly displayed the selected state correctly when the car was the output.”

That evidence corresponds to the PR #67 behavior that is still present on current main; no later change invalidated the mechanism. Repeating the same drive only for bookkeeping is unnecessary.

Acceptance matrix

  • PROVEN — automated: explicit Car semantic selection causes a selected Car presentation and is republished immediately.
  • PROVEN — automated: a definite Headset/Other route vetoes false Car selection.
  • PROVEN — automated: changed action state is pushed through the legacy/notification-controller path Android Auto consumes.
  • PROVEN — physical: projected Android Auto visibly showed Car selected when Car was the output (owner test, 2026-09-20).
  • PROVEN — automated: later shared-service changes retain the mechanism and the full current codebase passed the post-change regression gate.

Remaining physical steps: none.

Result

ACCEPTED — CLOSE

## Canonical acceptance — 2026-09-24 **Reviewed main:** `88ae231ddc01897d83e24968bed5443ea861aedd` **Merged implementation:** PR #67, accepted head `20dae444aa5f8b4a41bd673d90f76b043027dc97`, merge commit `fea83c6abc1354e8d831a012881cc20f0afa81c0`. ### Evidence reconciliation - PR #67 is merged and its output-selection implementation remains present on current `main`. - Current `AudioOutputRoles` still treats Car as a positive semantic state rather than “not Headset”: explicit Car can bridge only the projected no-route/built-in-speaker gap, while a definite headset or known Other route vetoes the Car-selected glyph. - Current `PlaybackService` still republishes immediately when explicit output intent changes and still derives `carRequested` from `ExplicitDestination.Car`. - Current `MediaButtonPublishing` still republishes both globally and through Media3's media-notification controller so the legacy Android Auto `PlaybackStateCompat` is refreshed. - The active Car action keeps a distinct action identity for host cache busting, while both active/inactive identities remain accepted if a host sends a cached action. - Relevant JVM/Robolectric tests remain on `main`, including explicit-Car/no-route, headset/Other veto, route-role selection, active-action identity, and legacy republish coverage. - Later PR #89 touched the shared `PlaybackService` integration seam. Its exact head `200b3d9e2a715273fbe32495479eb896e8974b7e` passed Forgejo run #270: `verifyDebug`, **2606 tests / 0 failures**, ktlint, detekt, Android Lint and Room schema checks. Current-main push run #271 also passed at `88ae231d...`. ### Existing physical evidence The issue already records owner projected-head-unit acceptance on **2026-09-20**: > “the Car action/icon visibly displayed the selected state correctly when the car was the output.” That evidence corresponds to the PR #67 behavior that is still present on current `main`; no later change invalidated the mechanism. Repeating the same drive only for bookkeeping is unnecessary. ### Acceptance matrix - **PROVEN — automated:** explicit Car semantic selection causes a selected Car presentation and is republished immediately. - **PROVEN — automated:** a definite Headset/Other route vetoes false Car selection. - **PROVEN — automated:** changed action state is pushed through the legacy/notification-controller path Android Auto consumes. - **PROVEN — physical:** projected Android Auto visibly showed Car selected when Car was the output (owner test, 2026-09-20). - **PROVEN — automated:** later shared-service changes retain the mechanism and the full current codebase passed the post-change regression gate. **Remaining physical steps:** none. ## Result **ACCEPTED — CLOSE**
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#34
No description provided.