Replace HeadsetHold inference with route-heard ownership #11
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Origin
Follow-up from GitHub PR #78 review and
docs/risks.mdR-108. This is intentionally separate from GitHub #78: repeated local patches to inferred route state have already produced regressions, and another sticky guard would make the model worse rather than safer.Problem
The current headset-preservation path infers "this audiobook was actually being heard on this headset" from a combination of
heardAudio, the platform's currentisActiveoutput, BookWave's selected route, andHeadsetHoldmemory/release state.That is weaker than the fact the product actually cares about: which route was carrying the audiobook when playback occurred.
A known remaining failure illustrates it: play through earbuds, explicitly move the audiobook to the phone speaker using the phone/system output chooser, then connect a car. The old headset can remain remembered and be reasserted even though the listener deliberately stopped using it.
The final GitHub #78 review found the inverse ownership problem as well:
AudioOutputRoles.startTarget()can see a framework/system-policy route that differs from BookWave's explicitselectedIdand replace the explicit choice when playback starts.getAudioDevicesForAttributesdescribes a route for the audio attributes, not proof of the route carrying BookWave's actual track. With multiple candidate sinks, inferred system-policy state must therefore never outrank an explicit listener choice without stronger BookWave-track evidence.Classic A2DP ambiguity is not itself the bug. A2DP must remain semantically
Ambiguousunless Android/user/device evidence supplies a stronger role.Desired invariant
Preservation should be owned by an explicit, generation/book-bound record of the route that was actually carrying audio when the service observed playback, rather than by indirect proxies that must be cleared in every path.
onIsPlayingChanged(true)or a stronger Media3/platform boundary if one exists).getAudioDevicesForAttributesreports a different system-policy route. Explicit listener intent wins until evidence from BookWave's actual track shows that intent is no longer the route carrying playback.Regression cases
Device acceptance
JVM tests can prove ownership/generation/precedence rules, but the active-route observation is an Android/Media3 boundary. Final acceptance needs physical route sequences with a real headset and Android Auto/head unit, including the explicit speaker sequence above and, where possible, multiple simultaneously connected candidate outputs.
Relationship to GitHub #78
GitHub #78 should not grow this redesign. It records the bounded current limitations and leaves the tested behavior intact; this issue is where the stronger state model belongs. The final GitHub #78 P1 review finding about
startTarget()is intentionally captured here rather than patched with another inference guard in GitHub #78.