Android TV
Status: The Android TV app (app/tv, libre flavour only), with CE screens beside upstream’s, D-pad focus helpers, the TV Compose player, Watch Next, theme music, and the screensaver. As of 2026-11-25 (main).
Start here
Section titled “Start here”- New TV screens and components live in
app/tv/src/main/java/dev/jdtech/jellyfin/ce/next to upstream’spresentation/files (TV ADR 0001).NavigationRoot(app/tv/src/main/java/dev/jdtech/jellyfin/NavigationRoot.kt) andNavigationRoutes.ktpoint each route at its CE screen (MainScreen,LibraryScreen,CollectionScreen,MovieScreen,ShowScreen,SeasonScreen,PersonScreen,TvPlayerScreen,TvProfilePinGateScreen,TvProfilePinScreen,TvExternalRatingsScreen,HomeRowsScreen,AboutScreen,LicensesScreen,DeviceProfileScreen). MainScreen(app/tv/.../ce/presentation/main/MainScreen.kt, TV ADR 0002) replaces the upstream top tab bar with a collapsed-to-railModalNavigationDrawerfor profile switching, Search, Home, Favorites, libraries, and Settings, retaining per-destination state withSaveableStateProvider.- D-pad focus restore, focus rings, and overscan margins live in
app/tv/.../ce/ui/focus/(FocusPosition,RestoreFocus,EphyraFocus,FocusHandOff,DirectionKeyClock,NoBringIntoView, TV ADR 0003) andTvSafeArea(app/tv/.../ce/ui/TvSafeArea.kt). TvPlayerScreen(app/tv/.../ce/presentation/player/TvPlayerScreen.kt, TV ADR 0004) wraps Media3PlayerViewover the sharedPlayerViewModel, paired withTvPlayerKeyHandler,TvProgressReports,TvResumeOnReturn,TvUpNextCard, andTvTrickplayThumbnail.- Launcher and ambient integrations live in
app/tv/.../ce/watchnext/(WatchNextSync,WatchNextPublisher,WatchNextPlanner,WatchNextRemovedReceiver),app/tv/.../ce/presentation/screensaver/(ScreensaverService,ScreensaverScreen), andapp/tv/.../ce/thememusic/(ThemeMusicSession,ExoThemeMusicPlayer). - Test fast:
./gradlew :app:tv:testLibreDebugUnitTestand./gradlew :app:tv:compileLibreDebugKotlin.
What it does
Section titled “What it does”When Room cannot open the saved database, the launcher shows the recovery message while WorkManager clears this app’s visible Watch Next programs. Cleanup retries if TvProvider is unavailable. Hidden rows and dismissal history stay available for the next sync after a compatible build opens the database.
App shell, packaging, and startup: app/tv builds only the libre flavour (app/tv/build.gradle.kts, without player/cast or Google Play Services), requires android.software.leanback, and supports minSdk = Versions.MIN_SDK (28, Android 9 / Fire OS 7, #675). Phone and TV share applicationId = "nl.midasvo.findroid.ce" (with .debug / .staging suffixes, TV ADR 0005), while release builds set EphyraVersion.TV_CODE (EphyraVersion.CODE + 1) so Play Store and F-Droid rank the Leanback APK above phone, and beta builds share 1_000_000 + betaBuild. AppVariantModule provides AppVariant.TV so shared ViewModels such as SettingsViewModel hide phone-only features (downloads, touch gestures, file editors) without inspecting device hardware (TV ADR 0007, TV ADR 0008). On startup, BaseApplication runs preference migrations, sets Coil’s memory cache to 30% of memory class capped at 96 MB and defaults imageCacheSize to 100 MB (TV_IMAGE_CACHE_SIZE_MB, #155/#160) so Home hero backdrop prefetching does not evict posters, plants WarningTree in non-debug builds so player errors still reach logcat, and starts WatchNextSync and ServerSessionKeeper. MainActivity declares android:configChanges="keyboard|keyboardHidden|navigation" in app/tv/src/main/AndroidManifest.xml so Bluetooth remotes disconnecting/reconnecting on standby do not relaunch the activity (#1008), records D-pad key presses in DirectionKeyClock, reads incoming WatchNextLink intents, and triggers watchNextSync.requestSync() in onStop().
Manifest and permissions: the merged manifest asks for INTERNET, ACCESS_LOCAL_NETWORK, ACCESS_NETWORK_STATE (from device) and WRITE_EPG_DATA (the Watch Next row), and nothing else. app/tv/src/main/AndroidManifest.xml removes what libraries merge in and the TV app does not use: WAKE_LOCK, FOREGROUND_SERVICE and WorkManager’s SystemForegroundService (only for foreground work, which no worker here does), tvprovider’s READ_EPG_DATA, and WorkManager’s DiagnosticsReceiver. It also removes RECEIVE_BOOT_COMPLETED and WorkManager’s RescheduleReceiver, so the app does not start at boot: after a reboot the Watch Next sync is scheduled again when the app is next opened, and the row keeps what it showed until then. The TV app posts no notifications, so it does not ask for POST_NOTIFICATIONS. Media3’s BluetoothValidationActivity (Bluetooth media buttons on Android 16 and 17) and profileinstaller’s ProfileInstallReceiver (baseline profiles) stay; the BLUETOOTH_PRIVILEGED and DUMP in the manifest guard those two and are not permissions the app asks for. TvManifestTest pins the list (#1045).
Drawer and CE screens: MainScreen pads drawer items with DrawerStartPadding (TvSafeArea.horizontal - 12.dp) and insets pages by ClosedDrawerWidth (80.dp) so icons, labels, and the 32 dp UserAvatar sit inside the 48 dp horizontal / 27 dp vertical TvSafeArea while the rail and focus pill may bleed into the overscan margin (#539, #567). Destinations switch on OK rather than focus; DrawerFocus distinguishes deliberate user D-pad moves (including cold-start keys from DirectionKeyClock) from focus falling into the drawer while a loading page rebuilds, using LocalRestoreFocusSuppressed so background reloads do not steal focus back from the drawer (#533). Back returns from other drawer destinations to Home, opens the drawer on Home, and finishes the activity when the drawer is already open (TV ADR 0002). Film screens (HomeScreen with focus-driven hero and background refresh, LibraryScreen with LetterJumpBar and PositionCounter, CollectionScreen, MovieScreen, ShowScreen, SeasonScreen, PersonScreen, SearchScreen, FavoritesScreen) consume the shared modes/film ViewModels and scope displayed state via shownTo(LocalServerSession.current.userId) so profile switches never flash the previous user’s items (#810, #866). Episodes open on their season page via EpisodeRoute (#130), and TvProfilePinGateScreen blocks NavDisplay (including Watch Next launches) until a locked profile’s PIN is entered (#299).
D-pad focus and text entry: CE screens use rememberFocusPosition(), focusPosition(), and RestoreFocus (which waits up to 60 frames, ignores stray focus gains such as initial window focus before restoration completes, resolves saved item IDs via FocusPosition.resolve(), skips restoration if LocalRestoreFocusSuppressed holds, and falls back to the default element halfway through) instead of LaunchedEffect(true) { requestFocus() } (TV ADR 0003). HandOffFocusWhenGone moves focus away when a focused button such as Restart disappears after a wake reload (#660, #1007). NoBringIntoView lets detail pages (MovieScreen, ShowScreen, PersonScreen) scroll themselves to the focused row (#407, #514). TvTextFieldEditing keeps text fields readOnly until OK is pressed so D-pad navigation does not open the IME on focus. EphyraFocus defines ephyraFocusedBorder (3 dp primary, 2 dp outside or -1.5.dp inside clipped containers), ephyraFocusedGlow, and EphyraFocusScale (1.06f, or 1f under reducedMotion()).
TV player (TvPlayerScreen): Hosts Media3 PlayerView (useController = false, subtitle styling applied to subtitleView) over the shared PlayerViewModel. TvPlayerKeyHandler keeps remote key logic in plain Kotlin: with controls hidden, Left/Right seek by playerTvSeekBackInc / playerTvSeekForwardInc (default 10 s / 30 s) and accelerate with video duration on hold via holdSeekMs (issuing a single seekTo on key-up), OK opens the controls (and pauses when playerTvOkPauses is enabled, consuming its matching key-up via okDown so it does not double-trigger Play/Pause, #459), Up/Down show controls, Back closes TvUpNextCard or the overlay before leaving the player, and media keys work whether controls are shown or hidden. TvProgressReports reports progress every 5 s (INTERVAL_MS) while STARTED and on ON_PAUSE (deduplicated within 1 s via MIN_GAP_MS, #458), TvResumeOnReturn restores playback on ON_RESUME only if playWhenReady was true before ON_PAUSE and neither Still Watching nor an error blocks it (#462), and TvBufferingIndicator, TvPlaybackProblem, TvSeekBar, TvTrickplayThumbnail, TvUpNextCard, TvSelectionDialog, and TvSubtitleDialog handle the overlay and error UI.
Watch Next, theme music, and screensaver: WatchNextSync runs WatchNextSyncWorker via WorkManager on start, playback stop (PlaybackEvents.stopped), MainActivity.onStop(), and every 3 hours while connected (after a reboot only once the app has been opened again, #1045). planWatchNext merges Continue Watching and Next Up (honouring hideSpoilers and MAX_WATCH_NEXT_PROGRAMS = 20), suppresses items the user dismissed via WatchNextRemovedReceiver until their position changes, and WatchNextPublisher publishes WatchNextProgram rows with a userId-scoped WatchNextLink so another user’s program never auto-plays (#138). ThemeMusicSession plays a show’s theme song through ExoThemeMusicPlayer once per visit to ShowScreen unless another app already has active audio, fading out on leave, playback, backgrounding, or screensaver (#141). ScreensaverService (DreamService, configured by ScreensaverSettingsActivity / ScreensaverSettingsScreen) cycles library backdrops and logos in ScreensaverScreen (ScreensaverItems) when signed in and wakes on any key event (#140).
Where the code is
Section titled “Where the code is”| Path | What |
|---|---|
app/tv/build.gradle.kts |
libre-only flavour, TV_CODE / beta versionCode, ephyra-*-tv-*.apk naming, Robolectric unit test config |
app/tv/.../MainActivity.kt, BaseApplication.kt |
D-pad clock, Watch Next intent & sync hooks, TV image cache sizing, WarningTree, startup migrations |
app/tv/.../NavigationRoot.kt, NavigationRoutes.kt |
Nav 3 graph pointing TV routes at CE screens, PIN gate, Watch Next launch stack |
app/tv/.../di/AppVariantModule.kt, TvDownloadsModule.kt |
Provides AppVariant.TV (ADR 0008) and no-op DownloadQueuePort.None / DownloadDeleter.None / SmartDownloadChecker.None bindings so app/tv does not link :downloads (#1048) |
app/tv/.../ce/presentation/main/MainScreen.kt, DrawerProfileItem.kt |
Side ModalNavigationDrawer, DrawerFocus, Back stack/drawer handling, per-destination state |
app/tv/.../ce/ui/focus/ |
FocusPosition, RestoreFocus, EphyraFocus, FocusHandOff, DirectionKeyClock, NoBringIntoView |
app/tv/.../ce/ui/ |
TvSafeArea, TvTextFieldEditing, QrCode, PersonCard, ItemInfoLine, components/ (TvLoadError, TvSortByDialog, TvOverviewText, UserAvatar) |
app/tv/.../ce/presentation/film/ |
CE TV HomeScreen, LibraryScreen, CollectionScreen, MovieScreen, ShowScreen, SeasonScreen, PersonScreen, SearchScreen, FavoritesScreen |
app/tv/.../ce/presentation/player/ |
TvPlayerScreen, TvPlayerKeyHandler, TvProgressReports, TvResumeOnReturn, TvBufferingIndicator, TvSeekBar, TvTrickplayThumbnail, TvUpNextCard, dialogs |
app/tv/.../ce/presentation/pin/, ce/presentation/settings/ |
TvProfilePinGateScreen, TvProfilePinScreen, TvPinPad, TvSettingsLayout, HomeRowsScreen, TvExternalRatingsScreen, about/ (AboutScreen, DeviceProfileScreen, LicensesScreen) |
app/tv/.../ce/watchnext/ |
WatchNextSync, WatchNextPlanner, WatchNextPublisher, WatchNextStore, WatchNextLink, WatchNextRemovedReceiver |
app/tv/.../ce/presentation/screensaver/, ce/thememusic/ |
ScreensaverService, ScreensaverScreen, ScreensaverSettingsActivity, ThemeMusicSession, ExoThemeMusicPlayer |
scripts/tv-dpad.sh |
uinput D-pad driver for TV emulators (150 ms key holds) |
- R1, R2, R4, R10, R11: no Jellyfin SDK types,
JellyfinApi, orServerDatabaseDaoinapp/tv; use typed IDs (ItemId,MediaSourceId,UserId,ServerId) rather than bareStringIDs outside the adapter; no newFindroid*orJellyfin*types (existingFindroidThemeis allowlisted inarchitecture/baseline/). - CE screens go beside upstream’s (TV ADR 0001): put new TV screens and helpers under
app/tv/.../ce/and wire routes inNavigationRoot.kt; do not delete unused upstream TV files unless an upstream sync conflicts. - Focus restoration (TV ADR 0003): never add
LaunchedEffect(true) { focusRequester.requestFocus() }in a CE screen; userememberFocusPosition()/focusPosition()/RestoreFocus, show visible focus (ring/scale), and return dialog focus to the element that opened the dialog. - No downloads on TV, and the variant decides (TV ADR 0007, TV ADR 0008): keep downloads and offline UI out of TV; gate UI differences with
AppVariant.TVrather thanFEATURE_LEANBACK(which stays reserved for hardware checks such as decoders, tunneling, and refresh rate). app/tvhas onlylibre(no Google Play Services or Cast); usece_string keys translated across all 36 languages (check-translations.py) and never edit upstreamvalues-<lang>/strings.xmlfiles.
How to test it
Section titled “How to test it”Fastest unit test and compile commands:
./gradlew :app:tv:testLibreDebugUnitTest./gradlew :app:tv:compileLibreDebugKotlinUnit tests in app/tv/src/test/ run on the JVM with Robolectric and androidx.compose.ui.test.junit4 (isIncludeAndroidResources = true):
- Drawer & focus restore:
MainScreenTest,MainFocusReturnTest,MainReturnLoadsTest,DrawerSafeAreaTest,FocusPositionTest,FocusRingTest,SafeAreaTest,CollectionFocusRestoreTest,FavoritesFocusRestoreTest,LibraryFocusRestoreTest,PersonFocusRestoreTest,SeasonFocusRestoreTest,WakeReloadFocusTest,LicensesFocusRestoreTest,UsersFocusRestoreTest. - Film & setup screens:
HomeRowUpdateTest,HeroImagesTest,DetailDownToRowTest,DetailOverviewTest,MovieResumeTest,MovieSpinnerTest,SeasonEmptyTest,SeasonWakeReloadTest,SearchErrorTest,TvCreditsTest,TvLoadErrorTest,TvSortByDialogTest,TvPinPadTest,LoginKeyboardTest,LoginServerButtonFocusTest. - TV player:
TvPlayerKeyHandlerTest,TvProgressReportsTest,TvResumeOnReturnTest,TvBufferingIndicatorTest,TvPlaybackProblemTest,TvQueueCaptionTest,TvTrickplayThumbnailTest. - Settings, Watch Next, theme music & screensaver:
SettingsCapabilitiesTest,SettingsTreeVariantTest,TvSettingsLayoutTest,TvSettingsNumberStepsTest,WatchNextPlannerTest,WatchNextSpoilersTest,ThemeMusicSessionTest,ScreensaverTest,ScreensaverItemsTest,ScreensaverSettingsScreenTest,TvImageCacheSizeTest,DeviceTransferRulesTest,TvManifestTest,RouteIdsSerializationTest.
For manual D-pad testing on a TV emulator (ce_tv_1080p, ce_tv_4k, or an adb serial):
scripts/tv-dpad.sh ce_tv_1080p down down okscripts/tv-dpad.sh registers a uinput device and holds each key for 150 ms instead of calling adb shell input keyevent, because virtual input keyevent keys do not move focus out of Compose text fields on login, search, and PIN screens and miss hold-key timing bugs.
What unit tests do not cover:
- Hardware playback on real TV boxes (tunneling, mono audio fallback #924, Dolby Vision/HDR, HDMI passthrough, display refresh-rate switching; see TV ADR 0004 and mpv-checklist.md).
- Real Android TV launcher
TvProviderWatch Next row rendering, dismissal broadcasts (WatchNextRemovedReceiver), and systemDreamServiceactivation (ScreensaverService/ScreensaverSettingsActivity). - Visual overscan safe-area alignment, software IME interaction on text fields, and end-to-end remote navigation across screens without
scripts/tv-dpad.shor a physical remote.
Before a PR
Section titled “Before a PR”./gradlew ktfmtCheck./gradlew :app:tv:testLibreDebugUnitTest./gradlew :app:tv:compileLibreDebugKotlin./gradlew :architecture:testpython .claude/skills/translate-strings/scripts/check-translations.py # when strings changedDecisions and history
Section titled “Decisions and history”- TV ADR 0001, TV ADR 0002, TV ADR 0003, TV ADR 0004 (#121, #125, #127): CE screens in
ce/next to upstream, collapsed-to-rail side drawer,FocusPosition/RestoreFocus, and Compose TV player overPlayerViewModel. - TV ADR 0005, TV ADR 0006, TV ADR 0007, TV ADR 0008 (#124/#143, #133, #173/#178): shared
applicationIdwith higher releaseversionCode(EphyraVersion.TV_CODE), TV beta/release APKs (ephyra-v*-libre-tv-*.apk), no downloads UI on TV, andAppVariant.TVfor shared ViewModels. - #128, #130, #134, #136, #137, #211: CE
SearchScreen,SeasonScreen(opening episodes in their season),TvTrickplayThumbnail,PersonScreen,FavoritesScreen, and TVAboutScreen(with bug-report QR code) /LicensesScreen/DeviceProfileScreen. - #138/#161, #140, #141: launcher Watch Next sync/dismissal/deep-link,
ScreensaverService, andShowScreentheme music (ThemeMusicSession). - #155/#160, #286/#582, #675: 100 MB TV image disk cache default + 30%/96 MB memory cache,
baselineprofile-tv, and API 28 (minSdk) support for Fire OS 7. - #458/#495, #486/#565, #865/#880:
TvProgressReportsperiodic &ON_PAUSEreporting,TvBufferingIndicator, and spoiler-free TV player queue/up-next captions. - #355, #531, #532, #533/#539/#540/#555, #810/#866/#873, #1007, #1008: D-pad audit,
DrawerFocus+TvSafeAreadrawer inset, profile lock polish, user-scopedshownTostate on profile switch,HandOffFocusWhenGonewhen wake reloads remove Restart, andMainActivityremoteconfigChanges+RestoreFocusprotection on recreation.
Pitfalls
Section titled “Pitfalls”adb shell input keyeventmisses TV focus bugs. Virtualinput keyeventkeys do not move focus out of Compose text fields on login, search, or PIN screens and flatten press/hold timing; always drive TV emulators withscripts/tv-dpad.sh(uinput).- Never read
drawerState.currentValueinMainScreenLayoutcomposition. The drawer opens and closes on every Left/Right move into the rail; readingdrawerState.currentValueduring composition recomposes the whole screen and its content on each move (#257). Read it only insideBackHandlerand callbacks. - Keep
DrawerFocusandLocalRestoreFocusSuppressedwired when changingMainScreen. Returning from Settings or profile switching triggers background reloads on Home; withoutLocalRestoreFocusSuppressed,RestoreFocussteals focus out of the drawer back onto Home (#533). Conversely,DrawerFocusreleases focus back to content if focus only drifted into the rail while a destination was reloading. - Filter shared ViewModel state by
LocalServerSession.current.userId(shownTo).MainScreenand its ViewModels survive user switches; withoutshownTo(userId), the previous user’s rows, libraries, search results, or favourites flash for a frame before reloading (#810, #866). - The setup screens reuse each other’s entry on the one TV back stack.
NavigationRoot.ktopens the server list from Users and Login, and the Users screen from Servers and Add server, withnavigateOrReuse: a route already on the stack is returned to and everything above it is popped (#1071). Settings and “ask who is watching” still push their Users screen withnavigate; a walk to the server list and back from there ends on that same Users screen. The setup guide’s pitfall has the rest (setup-and-servers.md). - Consuming OK-down in
TvPlayerKeyHandlermust also swallow its matching OK-up. Showing controls moves focus onto Play/Pause; letting OK-up through presses Play/Pause immediately (okDown+forgetOkPress(), #459). - Do not put
focusRestoreronLibraryScreenwithLetterJumpBaroranimateItem()in paged grids.focusRestorerintercepts programmatic focus requests after a letter jump and redirects them to the old card, soLibraryScreenusesfocusProperties { enter = ... }instead and avoidsanimateItem()in the paged grid (#257). - Respect
TvSafeAreaand focused card/button overhang. Focused cards scale (1.06f) and drawephyraFocusedBorder2 dp outside their bounds (useinside = truewhen clipped, as in drawer items or settings groups); buttons near the screen edge need room likeFOCUSED_BUTTON_OVERHANGso the focus ring is not cut off (#539). - A dependency can add a permission to the TV manifest without a line of ours changing. Libraries merge their own manifest in (work-runtime brought
WAKE_LOCKandFOREGROUND_SERVICE, tvproviderREAD_EPG_DATA).TvManifestTestfails when the list changes: add the permission there with its reason, or remove it in the manifest withtools:node="remove". A worker that callssetForegroundorsetExpeditedneedsWAKE_LOCK,FOREGROUND_SERVICEandSystemForegroundServiceback first, or it crashes (#1045). - A release build runs R8, and R8 removes what nothing reaches.
app/tv/proguard-rules.prokeeps the names of app classes and of the navigation routes, not the classes themselves (#1047, the same rules as the phone;docs/performance.mdhas the why). A class that is only created from a name in a string needs a rule of its own, and the unit tests and a debug build do not show when one is missing: build:app:tv:assembleLibreReleaseand open the screen on an emulator. - Use
testLibreDebugUnitTest, nottestDebugUnitTest.app/tvdeclares thelibreproduct flavour (app/tv/build.gradle.kts), so unflavoured Gradle task names failcheck-docs.pyand Gradle builds.
Source: docs/areas/tv.md · raw Markdown