Skip to content

Android TV / Google TV support - #809

Draft
dmfrey wants to merge 50 commits into
music-assistant:mainfrom
dmfrey:claude/music-assistant-android-tv-95iu6l
Draft

dmfrey wants to merge 50 commits into
music-assistant:mainfrom
dmfrey:claude/music-assistant-android-tv-95iu6l

Conversation

@dmfrey

@dmfrey dmfrey commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Draft PR for #808 — opening early for visibility while the open question there gets settled,
not because this is ready to merge.

What's here

  1. Manifest changes for TV eligibility: camera/touchscreen/leanback declared optional, added
    the LEANBACK_LAUNCHER intent filter and an android:banner. Includes a fix for a manifest
    merger issue where ktor-client-webrtc's own implicit required="true" on the camera
    feature was silently overriding the app's required="false".
  2. MainActivity detects Configuration.UI_MODE_TYPE_TELEVISION and forces landscape instead
    of relying on phone-width heuristics.
  3. The WebRTC remote-pairing QR-scan button is hidden when there's no camera — a dead end on
    TV. The manual remote-ID field stays available either way.
  4. A partial fix for the D-pad-hijacks-the-volume-slider bug from #5162: the player-switcher
    dialog now claims initial D-pad focus when it opens.

All four have unit/Robolectric test coverage, and this has been run for real on a Google TV
emulator (not just Robolectric) — app launches via the leanback launcher, locks to landscape,
connects and logs into a real server, navigates via D-pad.

What's not here / known issues

  • The player-switcher D-pad fix is incomplete. Initial focus lands correctly, but D-pad
    DOWN doesn't move between rows in that dialog — it currently leaks focus to whatever's behind
    it instead. Likely a ReorderableItem (sh.calvin.reorderable) focus-traversal interaction
    I haven't tracked down yet.
  • Marked draft pending the open question in Android TV / Google TV support #808: whether a player switcher belongs in the TV
    nav at all, given a TV is one fixed playback target rather than several rooms/players to
    choose between. If the answer is "no," item 4 above and the bug in it are probably moot and
    this PR should drop that piece rather than fix it further.
  • Nav rail/bar focus order, playback control focus indication at 10-foot viewing distance, and
    search/library grid D-pad traversal are all out of scope here — none of them blocked basic TV
    usability the way manifest eligibility and the switcher bug did.

Closes #808 once the above is resolved one way or the other.

claude and others added 10 commits July 23, 2026 11:06
Makes the camera feature optional (it was implicitly required, which
blocks the Play Store listing on TV devices with no camera), declares
touchscreen and leanback as optional, adds a LEANBACK_LAUNCHER
intent-filter so the app shows up on the TV home screen, and adds the
required android:banner tile.

Adds a Robolectric test asserting these manifest properties via
PackageManager queries.
…t lock

MainActivity previously only locked orientation on compact (phone-width)
devices, leaving everything else free to rotate. TVs are always
landscape and never rotate, so detect UI_MODE_TYPE_TELEVISION and force
landscape explicitly rather than relying on width heuristics that don't
apply to TV screens.

Extracts the decision into a pure, unit-testable resolveOrientationLock()
function instead of inlining it in onCreate().
The only camera use in the app is the optional QR-scan shortcut for
entering a WebRTC remote-pairing ID; the manual text field is always
the primary path. Android TV / Google TV devices have no camera, so
offering a scanner there just leads to a dead end.

Adds a hasCamera() expect/actual (Android: PackageManager.hasSystemFeature,
iOS: always true) and gates the QR IconButton on it.
Reported upstream (music-assistant org discussion #5162): on Android TV,
a remote's up/down buttons unexpectedly move the now-playing volume
slider instead of navigating the player list when the switcher dialog
is open. Nothing in the dialog ever claimed keyboard/D-pad focus, so
there was nothing for the remote to move between.

Adds a focusGroup() to the player list and requests focus on it as soon
as the dialog opens, landing D-pad input on the first row.
Summarizes the 4 commits on this branch, why they exist, and how to
run the new tests and a manual QA pass locally. None of this has been
built or tested with a real Gradle run yet — the environment that
authored it had no network access to the Android Gradle Plugin.
This is a working note for verifying this branch locally, not project
documentation. Call that out explicitly so it doesn't get carried into
whatever PR eventually goes upstream.
android.hardware.camera was declared required="false" in the app's own
manifest, but ktor-client-webrtc bundles its own <uses-feature
android:name="android.hardware.camera"/> with no required attribute
(which defaults to true). The manifest merger takes the more
restrictive value across all merged manifests, so the library's
implicit required="true" was silently winning — confirmed by
inspecting the merged manifest output, where the feature came out
required="true" despite the app's own declaration.

This meant the TV eligibility fix in 986faae didn't actually take
effect: the built APK still hard-required a camera. Adds
tools:node="replace" on the app's declaration to force the override.
assertDoesNotExist doesn't exist in this project's pinned Compose UI
Test version (1.11.4) — the test didn't compile. Switched to
assertIsNotDisplayed(), matching the convention used elsewhere in this
suite; verified it correctly treats a selector matching zero nodes as
"not displayed" rather than requiring the node to exist.

The "shows the QR button" case also failed once compiling: the button
was scrolled out of the Robolectric test viewport, not actually
missing. Added .performScrollTo() before the assertion.
Documents what running this branch for real (Gradle 9.6.1 / AGP 9.2.1,
Google TV android-36 x86_64 emulator) surfaced: two real bugs found
and fixed (QrScanAvailabilityTest's assertions, and the manifest
merger issue fixed in 4acf03f), the D-pad focus fix's initial-focus
part confirmed working but row-to-row navigation still broken, and the
open question of whether the player switcher belongs on TV at all.
Per its own header: not project documentation, just a working note for
verifying this branch locally. Dropping it here means it nets out of
the diff against main, so it won't show up in the upstream PR.
* are left as the platform default (free rotation) — hence the nullable return.
*/
internal fun resolveOrientationLock(configuration: Configuration): Int? = when {
configuration.isTelevision() -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure everyone will be using TV in landscape?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No — landscape is actually mandatory for Android TV apps, not just a convention. Google's Android TV app quality guidelines require that no activity declare portrait, reversePortrait, sensorPortrait, userPortrait, or reverseLandscape — landscape-only is a Play Store TV listing requirement. Most TV box firmware forces landscape at the OS level regardless of what an app declares, too. So this isn't an assumption on my part, it's just implementing what's already required for this form factor.

@formatBCE formatBCE left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good code.

claude and others added 4 commits July 25, 2026 11:25
Adds .claude/testing.md covering the Robolectric/Compose test harness
conventions used across the suite (page objects, Qualifiers, Koin test
rule, PackageManager shadows, D-pad key-input testing) and the
dl.google.com build limitation in sandboxed sessions.

Notes in project.md that music-assistant/mobile-app (not
music-assistant/server) is the correct upstream for issues/PRs, and
points at the in-progress Android TV work on this branch.
Daniel ran the branch on an actual Google TV emulator and found two
real bugs (manifest merger silently re-requiring the camera feature
via ktor-client-webrtc's bundled uses-feature, and QrScanAvailabilityTest
not compiling/passing as written). Records both as durable project
knowledge rather than letting them live only in commit messages on a
feature branch, and fixes the dangling docs/ANDROID-TV.md reference
left over from before that file was removed.
Confirmed with Daniel: the .claude/*.md doc updates from this session
(testing.md, the WebRTC manifest-gotcha note in dependencies.md, and
the Android TV / upstream-relationship additions in project.md) should
get the same treatment as docs/ANDROID-TV.md — useful to keep on this
fork/branch, but never part of a PR diff, upstream or against this
repo's own main.
Per the previous commit's own note: these docs (testing conventions,
the manifest merger gotcha, the D-pad focus fix's incomplete status,
upstream repo relationship, and this contribution-hygiene rule itself)
are genuinely useful to keep in this branch's history for future
Claude Code sessions, but shouldn't appear in a PR diff — same
treatment as docs/ANDROID-TV.md got earlier. Reverting project.md and
dependencies.md to their main content and dropping the new
testing.md nets all three out of the diff against main.
dmfrey added 11 commits August 6, 2026 14:04
Compose's geometric focus search cannot move a TV remote between the
Server / Authentication / Local-player cards on this hardware, so the
connected settings screen now declares explicit directional links per
control (TvFocusFlow) across the whole chain: disconnect -> logout ->
player name -> codec -> custom connection -> enable local player, plus
the Exit App and Misc buttons. The flow adapts to whichever controls
exist (login form vs logged-in row, custom-connection fields).

The config form's links are extended the same way so the clipped Misc
and Exit App buttons stop stealing focus; a self-healing handler
re-lands D-pad on the primary target when a directional press arrives
while focus is off the declared chain.

Covers the connected screen with the same FocusProperties-links
mechanism already proven on the initial-config form, and adds on-device
regression tests for both the config-form chain and the player-switcher
dialog D-pad leak.
…way back from now playing

Player focus (queue-open layout):
- CompactPlayerItem now participates in a dedicated compact TvFocusFlow so the
  initial focus request always lands on the visible play/pause control; the
  queue-open layout hides FullPlayerItem (its former focus target)
- Initial focus retries until it actually lands, fixing the cold-start deep
  link race where the window lacks focus and the remote went dead
- PlayerControls builds its left/right focus links from the buttons actually
  rendered, so a missing prev no longer dead-ends LEFT from play

Return path from now playing (Android TV has no notification shade):
- Set MediaSession.setSessionActivity() via a shared openAppPendingIntent()
  so the home-screen now playing card routes a tap back into the app
- The players deep link now also opens the queue panel next to the transport
  controls as the useful landing; isQueueExpanded hoisted to MainNavRoot
- Collapse restores focus to the FloatingBar so the remote never goes dead

Settings / other:
- SettingsScreen restructured around TvPreferenceRow with explicit D-pad
  chains and dialog focus handling; TvFocusFlow preview-phase routing limited
  to text fields (buttons otherwise mis-land)
- Auth text fields get textField preview routing
- Tests: TvPreferenceRowDialogTest added, SettingsConfigDpadNavigationTest
  extended for the new row/dialog navigation
…cher focus

- Gate the on-screen keyboard behind explicit select (TvTextInputGuard) so
  D-pad focus traversal no longer auto-opens the IME in the login form
- Render login errors inline above the Login button so failures are visible
- Make the show/hide password eye reachable via D-pad from the field
- Wire the player-switcher pill, group icon, and header controls into the
  expanded player's D-pad chain in both full and queue-expanded layouts
…tton

Android TV: Material3 sliders show no focus change, so a D-pad-focused slider
reads as inert. Grow the thumb while focused on both the full-player seek
slider and the volume slider, and draw an explicit focus ring on the settings
connection-method and auth tabs whose default focus tint is too subtle.

The seek slider is wrapped in a Box that tracks hasFocus: the Slider applies
its own focusable() outside the passed modifier chain, so an onFocusChanged
attached to the slider (with tvFocus providing focusProperties) never fires.
The fixed height keeps the growing thumb from shifting the layout below.

Detail pages now land D-pad focus on the play button once the item loads,
retrying because this hardware can drop the first requestFocus and because the
grid is recreated when the tab-loading gate opens; the settings screen lands
on the auth tab row instead of Disconnect right after a successful connect.
Sync with music-assistant/mobile-app main (a69b397) to restore mergeability
of PR music-assistant#809. Resolves conflicts by keeping the Android TV additions (tvFocus
modifiers, SendspinSectionTv for TV devices, selectedItemModifier for the
bottom navigation bar, connection-error strings) alongside upstream's changes
(0.10.0 version bump with testInstrumentationRunner retained, bufferedAheadSecFlow
player pager param, buffer-size sendspin slider added to the non-TV settings
path, and NavigationBar wrapper for the nav rail).
CI runs detekt with autoCorrect disabled, so the autocorrected formatting
in the merged tree failed. Fix the findings explicitly:

- TvPreferenceRowDialogTest: split two semicolon-joined statements onto
  separate lines (Wrapping)
- SettingsConfigDpadNavigationTest: order ui.test imports before ui.unit
  (ImportOrdering)
- ItemDetailsScreen / SettingsScreen: drop unused imports (NoUnusedImports)
- SettingsScreen: extract the 150ms dialog-close focus delay and the
  directional-key wrapping into named constants / wrapped form
- MainNavRoot / PlayerControls / PlayersPager / SettingsScreen: lexicographic
  import order (ImportOrdering)
- TvTextInput: extract the confirm-key check so the tvSelectToEdit condition
  stays under the complexity threshold (ComplexCondition)
- TvPreferenceRow: name the focus retry count and delay (MagicNumber)
- tvFocus() now composes the focus modifier onto the receiver (then)
  instead of discarding it, so PlayerSelectionButton's clearAndSetSemantics
  content description survives on every device.
- Restore upstream's prefilled server host/port on phones; keep the
  placeholder-empty state only on TV.
- Only surface the friendly connect-failure messages on TV; phones keep
  showing the raw error like upstream.
@dmfrey
dmfrey marked this pull request as ready for review August 10, 2026 18:46
// (notification tap / TV now-playing card), where the queue
// alongside the transport is the useful landing.
playerExpanded = true
isQueueExpanded = true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't matter for landscape layout - queue there is always shown.

dmfrey added 6 commits August 12, 2026 10:49
focusGroup() and the onPreviewKeyEvent-based directional-key routing to
focusManager.moveFocus exist to keep a TV remote's up/down inside the dialog
instead of leaking to whatever's focused behind it. Neither applies on phone/iOS
(no D-pad), but both ran unconditionally. Gate them behind isTelevisionDevice(),
preserving the original modifier ordering so TV behavior is unchanged.

Part of slimming PR 809's shared-file footprint per maintainer feedback.
…inks.kt

configLinks and authLinks are ~115 lines of hand-written TvFocusFlow.Links
adjacency maps that were previously inlined at the top of SettingsScreen(),
computed unconditionally even on phone/iOS where they're unused. Move them
into pure top-level functions (buildConfigLinks, buildAuthLinks) in a new
file so they're independently readable and out of the way of the shared
composable's control flow. Pure relocation, no behavior change.

Part of slimming PR 809's shared-file footprint per maintainer feedback.
DirectConnectionContentTv, WebRTCConnectionContentTv, SendspinSectionTv, and the
TvEditorSpec/DIALOG_CLOSE_FOCUS_DELAY helpers they use are already fully separate
from their phone/iOS counterparts (called via an early branch at each call site),
so this is a pure file move with no logic changes. QrScanDialog (shared by both
the phone and TV WebRTC variants) is bumped from private to internal so the TV
file can still call it.

SettingsScreen.kt drops from 2108 to 1604 lines. Part of slimming PR 809's
shared-file footprint per maintainer feedback.
Android TV usability testing (finding 1) found the mini-player transport controls
and Now Playing screen were entirely unreachable via D-pad from Home, Library, or
Settings — only reachable by touch. Root cause: FloatingBar is placed via a custom
SubcomposeLayout as a separate overlay, not an ordinary sibling of the nav rail or
screen content, so default focus search never finds it, matching this app's
established pattern that geometric search alone is unreliable on this hardware.

Confirmed against official Android TV design guidance (a persistent bottom bar
should be an explicit focus stop with DOWN-in and UP-out links) and Jellyfin's own
reported navigation bug in this exact area (asymmetric up/down mapping), so this
adds a fully symmetric, explicit link instead:
- AdaptiveNavigationBarLayout: DOWN from the nav rail's last item -> floating bar
  (FocusProperties.down on the item's own node, since it's the actual focused leaf).
- CategoryRow: DOWN from a row's LazyRow -> floating bar, applied only by the
  caller's last visible row. Uses onPreviewKeyEvent on the LazyRow container rather
  than FocusProperties, since FocusProperties only governs the exact node it's
  attached to and each card is a separate composable (ArtistWithMenu, AlbumWithMenu,
  TrackWithMenu, etc.) -- onPreviewKeyEvent genuinely propagates through the
  ancestor chain regardless of which card is focused, the same mechanism already
  proven in SelectPlayerDialog.
- HomeScreen: threads a floatingBarFocusRequester down to only its last row.
- FloatingBar: UP (from any focused control inside it) -> the nav rail's currently
  selected item, via the same onPreviewKeyEvent-on-container approach, since the
  collapsed bar has multiple individually-focusable leaves.

All new parameters are optional and default to null (no-op), so this is additive
for phone/iOS. Verified with detekt and the full unit test suite; instrumentation
test sources still compile.
…ar buttons

Android TV usability testing (finding 2) reported focus seeming to "silently move"
without a visible ring until an unrelated keypress "revealed" it. Investigated with
a controlled test: two screenshots 2 seconds apart with no intervening input were
byte-identical, ruling out rendering/compositing lag as the cause. Cross-checked
against the accessibility tree's focused="true" node as ground truth (independent
of what's visually rendered) and confirmed these elements simply had no focus
indicator at all -- the "catches up" impression was the LazyColumn auto-scrolling
into a new row on a later press, not a ring appearing. Same root cause as finding 3.

CategoryRow's cards route through two shared wrapper composables
(BrowsableItemWithMenu, PlayableItemWithMenu), but the actual focusable/clickable
node is built several layers further down by a per-media-type/view-mode composable
(AlbumGridItem, TrackRowItem, etc.). Rather than touching every one of those,
tvFocusRing() gained a trackDescendants option: it already used onFocusChanged, and
FocusState.hasFocus (true for the node or any focused descendant) works from a
non-focusable wrapper where FocusState.isFocused would not. Applied once at each
wrapper's Box instead of duplicating across every card type.

Also added the existing (non-descendant) tvFocusRing() to nav rail items and the
Home top-bar's Edit-rows/Refresh buttons, which are themselves the focused leaf.

Verified live on a real Google TV device (not just the emulator): before this
change, the accessibility tree confirmed focus had genuinely landed on the "Edit
rows" button with zero visible difference from its unfocused sibling; after,
screenshots on the same hardware show a clear ring on the nav rail, the top-bar
button, and a Home content card. Verified with detekt and the full unit test suite.
Android TV follow-up eval (finding 3) found that pressing DPAD_UP while focus was
on the nav rail's last item (Settings) didn't just fail to move focus, it appeared
to lose it entirely -- the visual ring stayed frozen on stale content indefinitely.
The nav rail's own internal vertical navigation (Home/Library/Search/Settings) had
never been given explicit directional links, unlike every other TV screen in this
app -- it relied solely on Compose's default geometric search, which this codebase
has already established is unreliable on this hardware.

Give each nav item a stable per-item FocusRequester and wire explicit up/down
FocusProperties links between adjacent items, same pattern as TvFocusFlow elsewhere.
The last item's existing DOWN-to-floating-bar link is preserved (previously a
separate bottomLinkModifier, now folded into the same adjacency modifier).

Verified live on the real Google TV device with a proper focused-node XML parse
(not text-matching, which turned out to be unreliable for outer nodes with an
empty content-desc): pressing UP repeatedly from Settings now correctly walks
Settings -> Search -> Library -> Home, and the floating-bar DOWN/UP round trip
from Settings still works exactly as before. Verified with detekt and the full
unit test suite.
@dmfrey

dmfrey commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on the slimdown, plus some real fixes that came out of it.

Diff-size cleanup (what I said I'd do)

  • MainNavRoot.kt / SelectPlayerDialog.kt: the two TV-only focus effects/D-pad interception now gate behind isTelevisionDevice() instead of running unconditionally on every platform.
  • SettingsScreen.kt: pulled the ~115-line focus-adjacency-map builders into SettingsTvFocusLinks.kt (pure functions), and moved the already-forked *Tv composables into SettingsScreenTv.kt. Net: SettingsScreen.kt goes from 2205 → 1604 lines (-27%).
  • Went back through LoginSection/MiscSection/ConnectionMethodTabs looking for more to fork out and concluded they don't need it — LoginSection/MiscSection already use a safe nullable-flow pattern that's a true no-op on phone/iOS, and ConnectionMethodTabs has exactly one TV-specific line out of ~140. Didn't want to churn the diff further just for the sake of it.

Real bugs found by actually using the app on hardware, not just reading the diff

Ran hands-on usability passes on both a Google TV emulator and a real Chromecast with Google TV — screenshots, uiautomator focus-state ground truth, functional select-tests — and found three real D-pad navigation bugs the original PR hadn't surfaced:

  1. The persistent mini-player was entirely unreachable via D-pad from Home, Library, or Settings — only reachable by touch. Wired explicit DOWN/UP links between the nav rail, the last content row, and the floating bar.
  2. Several elements (content cards, nav rail icons, the Home top-bar buttons) had no visible focus indicator at all — D-pad navigation technically worked but looked exactly like a dead remote. Gave tvFocusRing() an opt-in "track descendant focus" mode so it can be applied once at a couple of shared wrapper composables instead of duplicated into every per-media-type card.
  3. The nav rail's own internal UP/DOWN traversal (Home/Library/Search/Settings) had never been given explicit directional links, unlike every other screen here — it relied solely on the same geometric-search-is-unreliable-on-this-hardware issue this PR already works around elsewhere. Pressing UP from the last item didn't just fail to move focus, it dropped it entirely. Added the same explicit-link pattern used throughout the rest of the app.

All three verified directly on the real device (not just the emulator) with before/after screenshots and functional tests, not just code review.

One known issue remains open and unresolved: a focus ring occasionally stays visually stuck for a moment exactly when D-pad DOWN crosses from the last content row into the floating bar (reachability itself works, confirmed functionally). Investigated it, including a fix attempt that didn't hold up under re-testing so I reverted it rather than ship something unverified. Minor/cosmetic, not a blocker.

Everything's verified with detekt + the full unit test suite, and CI is green. This should be ready for another look whenever you have time — taking it out of draft now.

@dmfrey
dmfrey marked this pull request as ready for review August 15, 2026 12:30
@dmfrey
dmfrey marked this pull request as draft August 15, 2026 12:42
dmfrey and others added 4 commits August 16, 2026 09:37
Pulls in dynamic radio station support, a CarPlay authoritative-state-refresh
fix, CarPlay "play from here" support, a supported-API-version bump, flaky
test stabilization, and translation updates. No file overlap with the TV work
on this branch, so this merged cleanly.
After submitting a search, focus had nowhere reliable to land in the
results and D-pad navigation stayed stuck on the nav rail.

Root cause: clearFocusOnScroll() -- added to dismiss a focused text
field's keyboard on phone/tablet touch-scroll -- also fires when a
D-pad focus grant triggers a "bring newly-focused item into view"
scroll inside a LazyRow/LazyColumn, since that scroll gets dispatched
through the same nested-scroll connection and is misclassified as
NestedScrollSource.UserInput on this Compose Multiplatform version.
That cleared focus immediately after every grant, in an infinite loop
that never settled (confirmed live via a temporary onFocusChanged log:
isFocused flipped true then false ~20ms later, every single attempt).

Fixed by:
- Making clearFocusOnScroll() a no-op on TV, where there's no touch
  scroll gesture for it to guard against, fixing every call site
  (Search, Library, Settings) rather than just the one reported.
- Threading a FocusRequester onto the actual focusable leaf of the
  first search result (CategoryRow's firstItemFocusRequester, merged
  into PlayableItemWithMenu/BrowsableItemWithMenu's contentModifier --
  not the outer wrapper Box, which is a silent no-op target) so
  SearchScreen can land focus there once results load, replacing an
  earlier relative moveFocus() attempt that broke when the on-screen
  TV keyboard's own dismissal left nothing reliable to move focus
  from.

Verified live on both the Google TV emulator and a real Chromecast
with Google TV: focus lands on the first result and RIGHT/DOWN
correctly move through the results grid.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lhdwnq1fix7oBfNP656uf8
# Conflicts:
#	androidApp/build.gradle.kts
#	androidApp/src/main/AndroidManifest.xml
#	androidApp/src/main/kotlin/io/music_assistant/client/MainActivity.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayerControls.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayerItems.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayersPager.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/settings/SettingsScreen.kt
…tion regression

The upstream merge added a "require encrypted connection" Sendspin
toggle to the phone/tablet settings body but had no TV equivalent,
leaving TV users unable to set it. Add the same toggle to
SendspinSectionTv, wired into the existing TV D-pad focus chain
(customToggle -> requireEncryption -> customHost/playerToggle
depending on whether custom connection is enabled).

While verifying this live, found a real regression from the same
merge: upstream's new "lock portrait on compact devices" feature in
MainActivity (compact-width heuristic, smallestScreenWidthDp <= 600)
doesn't account for TV hardware. This Google TV emulator's 1920x1080
@ 320dpi display has a 540dp smallest-width, under that threshold, so
the observer force-locked portrait moments after onCreate's TV
landscape lock, letterboxing the whole app into a narrow portrait
strip and silently breaking WindowClass.isWide() (and therefore the
nav rail) along with it. Fixed by excluding TV from the compact-device
check, matching resolveOrientationLock's existing "TV takes priority"
precedent.

Verified live on the Google TV emulator: nav rail/landscape layout
restored, the new toggle renders, D-pad reaches it via both focus-chain
variants (with and without custom connection enabled), and toggling it
via CENTER actually flips server state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lhdwnq1fix7oBfNP656uf8
@formatBCE

Copy link
Copy Markdown
Collaborator

@dmfrey I'm sorry you have to deal with constant changes - we're moving fast, and breaking stuff even faster... :)

Do you want to continue on this?

@dmfrey

dmfrey commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

I've been keeping up with the changes and make sure to incorporate them. I'll keep it going.

dmfrey and others added 6 commits September 14, 2026 14:44
Resolves conflicts across build.gradle.kts (version bump), the media
session manager (session-activity + playback-state init), overflow
menu wiring (TV focus vs. new onAddToPlaylist callback), and Settings
screen (local-network onboarding, server info card, TV-specific error
formatting). Also drops a stale ServerIdMismatchException branch that
upstream removed as part of its connection-history rework (music-assistant#932) but
that the three-way merge preserved as an unresolved reference.

Verified: composeApp/androidApp compile, Android unit tests pass, iOS
simulator Kotlin target compiles.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
detekt flagged AllInclusive, Bedtime, and MutableState as unused in
PlayersPager.kt after merging main: upstream's refactor relocated the
autoplay toggle and sleep-timer entry from the overflow menu into
PlayerBadgesRow, and replaced the ad-hoc per-dialog MutableState vars
with the new PlayerDialogRequest mechanism, leaving these imports
dead. No functional change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
The previous merge commit (7967295) intended to drop this branch —
upstream removed the ServerIdMismatchException class entirely in its
connection-history rework (music-assistant#932), see that commit's message — but the
fix never made it into the commit: it was applied to the working tree
after `git add`, and the commit was created without re-staging it.
CI (compile/build) caught the resulting unresolved reference.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
Upstream shipped a full sendspin/local-player architecture rewrite in
this sync: the sendspin protocol/audio stack moved into its own Gradle
module (sendspin/), the old Codec/Codecs/SendspinConfig classes were
deleted, and the manual "require encrypted connection" toggle was
removed entirely in favor of automatic silent pairing/encryption
negotiation -- no user-facing setting for it exists on main anymore.

Resolved conflicts in PlayerSelectionButton.kt, PlayerItems.kt, and
PlayersPager.kt (straightforward: adopt main's SendspinState ->
PlayerState rename, keep TV's tvFocus/TvFocusFlow additions).

SettingsScreen.kt's SendspinSection conflict was not mechanical: git's
3-way merge left the "else" (non-TV) branch as a mix of TV's own stale
Codecs.list/SendspinConfig.* references over main's otherwise-adopted
body. Reconstructed the function by hand from main's ground truth
(SettingsRepository.CODECS/BUFFER_MB_*), re-layering only the TV
additions that still apply: the isTelevisionDevice()/SendspinSectionTv
branch and the tvFocus(...) modifiers on each surviving field. Dropped
the require-encryption toggle block entirely, matching its removal
upstream.

That removal doesn't stop at SettingsScreen.kt: also had to clean up
SettingsScreenTv.kt (drop the sendspinRequireEncryption state/Row, the
now-unused string import, and switch Codec/Codecs.list to the new
AudioCodec/SettingsRepository.CODECS) and SettingsTvFocusLinks.kt
(remove the orphaned "requireEncryption" D-pad focus-chain node from
both buildAuthLinks branches, so customToggle links directly to the
next surviving row instead of a target with no composable behind it
anymore -- neither file conflicted in the merge itself, since main
doesn't touch them, but both silently referenced now-deleted symbols).

Verified: composeApp/androidApp compile, iOS simulator Kotlin target
compiles, detekt clean, full Android unit test suite passes (118
suites, 0 failures).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
…ant-android-tv-95iu6l

# Conflicts:
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/common/items/BrowsableItemWithMenu.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/common/items/CategoryRow.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/common/items/PlayableItemWithMenu.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/SelectPlayerDialog.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/item/ItemDetailsScreen.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/search/SearchScreen.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/settings/SettingsScreen.kt
The TV branch's androidTestImplementation deps (espresso-core,
androidx.test.ext:junit) transitively want newer versions of
concurrent-futures(-ktx) and error_prone_annotations than what
androidx.car.app (via guava) and androidx.camera already pull into the
app's own runtime classpath. AGP's consistent resolution then locks
the androidTest classpath to that older app-resolved version, which
conflicts outright with what espresso/test-junit require -- failing
`./gradlew :androidApp:lintDebug` (and hence the "build" CI job) with
"Could not resolve all files for configuration
:androidApp:debugAndroidTestRuntimeClasspath".

Constrain the app's own resolution of those three artifacts to the
newer, compatible versions so both classpaths agree.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
dmfrey and others added 8 commits October 19, 2026 09:16
…ant-android-tv-95iu6l

# Conflicts:
#	androidApp/build.gradle.kts
#	androidApp/src/main/AndroidManifest.xml
#	androidApp/src/main/kotlin/io/music_assistant/client/services/MediaNotificationManager.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/common/ClearFocusOnScroll.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/common/items/BrowsableItemWithMenu.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/common/items/CategoryRow.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/HomeScreen.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/MainNavRoot.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayerControls.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayerItems.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayersPager.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/item/ItemDetailsScreen.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/item/ItemHeader.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/settings/SettingsScreen.kt
Publishes the current player's track to the TV home screen's Watch Next
shelf via TvProvider, so there's a way back into the app once its
activity is gone (TV has no notification shade). Includes duration and
playback position so the shelf can render a resume progress bar.

Verified on a real Google TV device: the row writes successfully with
correct metadata (confirmed via logging) and no provider errors, but it
does not appear in the launcher's "Continue watching" shelf, unlike
other apps' entries. Ruled out TYPE_TRACK filtering (TYPE_MOVIE was
tested as a diagnostic, same result) and missing duration/position data.
Root cause unconfirmed; possibly launcher-side gating on sideloaded,
non-Play-Store builds. Implementation matches the public Jetpack API
(confirmed via tvprovider-1.1.0 bytecode inspection), so merging as-is
pending future verification against a production-signed build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
…ant-android-tv-95iu6l

# Conflicts:
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/common/items/BrowsableItemWithMenu.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayerControls.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayerItems.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/settings/SettingsScreen.kt
The upstream merge replaced the phone's Sendspin settings UI with a
draft/save/reset flow and new fields (hi-res audio, a seconds-based
buffer slider) that the old immediate-apply SendspinSectionTv didn't
know about, so it needed a rewrite rather than a mechanical port.

Verified live on a real Google TV device that the straightforward
inline port overflowed a 1080p screen once the new fields were added,
including in the pre-existing (unmerged) design -- D-pad focus walked
off the bottom of the non-scrolling form with no way back. Moved hi-res
audio, buffer size and the custom-connection fields into their own
dialog (SendspinAdvancedDialogTv), opened from a tune icon next to the
enable switch, which has room to grow independently of the rest of the
form and scrolls when its own content doesn't fit.

Known gap, left documented rather than silently claimed fixed: closing
that dialog doesn't reliably restore D-pad focus to the tune icon
(verified: requestFocus consistently returns false there, unlike every
other dialog-close restoration on this screen, even with force-clearing
focus first and retries spanning several seconds). Not a dead end --
the platform's own geometric fallback still finds a nearby focusable
node -- just not landing precisely back on the icon.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
…ant-android-tv-95iu6l

# Conflicts:
#	androidApp/build.gradle.kts
#	androidApp/src/test/kotlin/io/music_assistant/client/ui/compose/StreamFavoriteActionsTest.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/MainNavRoot.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayerItems.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayerSelectionButton.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/PlayersPager.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/home/players/SelectPlayerSheet.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/nav/AdaptiveNavigationBarLayout.kt
#	composeApp/src/commonMain/kotlin/io/music_assistant/client/ui/compose/settings/SettingsScreen.kt
A missing heightIn import (only referenced inside the conflicting hunk
before the merge) and our own D-pad focus regression test still naming
the pre-rename SelectPlayerDialog composable (upstream renamed it to
SelectPlayerSheet as part of converting it to a ModalBottomSheet).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
…ant-android-tv-95iu6l

Resolves conflicts from 99 new upstream commits, most notably the
re-added speaker-grouping button (PlayerSelectionButton), the new
lyrics side-panel/pageSplit layout and vertical-bar wrapping in
ExpandedPlayerPage, the track-waveform seek bar, long-lived-token
login, and item descriptions/genres/facts on the item page -- all
reconciled against this branch's TV D-pad focus wiring, which is
preserved and re-threaded through the restructured call sites
(including reordering the Settings TV focus chain to match the
TLS-toggle-before-port reordering upstream made).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci
DOWN from the sidebar attached its FocusRequester to FloatingBar's
outer Surface: a tap-to-expand target with no focus indication and no
link into the mini-player's own TvFocusFlow graph, so the remote
appeared dead. In the "nothing playing" state the next candidate, a
disabled transport button, isn't a valid Compose focus target either,
and SplitButtonDefaults.OutlinedLeadingButton silently drops an
externally-attached FocusRequester.

Thread the entry requester down to whichever control actually renders
first and can take focus (skipping disabled transport buttons, falling
back to the chip's trailing button which does accept external focus),
and add tvFocusRing() across the player bar's controls so Material3's
default focus tint is actually visible on a TV.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwsVpcBbWxSuBMCzvHj2ci

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android TV / Google TV support

4 participants