Debloat your Android TV, install apps, browse and transfer files on it, all from your phone. Just 3 MB, no tracking, no root, no PC.
Keep the clock off the TV page's root state
jesse-agent-232ed24364a65b7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7d70185..e1846c9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,7 @@ until this file has a section for its version.- **Improved:** Opening a TV reads its apps once, in one go, so Apps fills in sooner. [#173](../../pull/173)- **Improved:** Tellyscope stops polling your TV while it's in the background. [#172](../../pull/172)+- **Improved:** The TV's page no longer redraws every app each second. [#PR](../../pull/PR)## 0.10.0 — 2026-10-26diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.ktindex c9dd51a..c0f5427 100644--- a/app/src/main/java/app/tellyscope/MainActivity.kt+++ b/app/src/main/java/app/tellyscope/MainActivity.kt@@ -19,6 +19,7 @@ import androidx.compose.material3.SnackbarDurationimport androidx.compose.material3.SnackbarHostStateimport androidx.compose.material3.SnackbarResultimport androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProviderimport androidx.compose.runtime.DisposableEffectimport androidx.compose.runtime.LaunchedEffectimport androidx.compose.runtime.getValue@@ -59,6 +60,7 @@ import app.tellyscope.ui.DeviceTabsScreenimport app.tellyscope.ui.Doneimport app.tellyscope.ui.LauncherActionsimport app.tellyscope.ui.LauncherScreen+import app.tellyscope.ui.LocalNowimport app.tellyscope.ui.LoggedOutScreenimport app.tellyscope.ui.PermissionScreenimport app.tellyscope.ui.RemoteActions@@ -72,6 +74,7 @@ import app.tellyscope.ui.TellyscopeViewModelimport app.tellyscope.ui.UpdateDialogimport app.tellyscope.ui.WelcomeScreenimport app.tellyscope.ui.brands+import app.tellyscope.ui.clockimport app.tellyscope.ui.connectTitleimport app.tellyscope.ui.nameimport app.tellyscope.ui.theme.TellyscopeTheme@@ -119,7 +122,8 @@ class MainActivity : ComponentActivity() {}},)- TellyscopeApp(vm)+ val now = vm.now.collectAsStateWithLifecycle()+ CompositionLocalProvider(LocalNow provides now) { TellyscopeApp(vm) }}}}@@ -226,7 +230,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {BackHandler(enabled = adding) { adding = false }ScanScreen(scan = state.scan,- now = state.now,+ now = state.clock(),onRescan = vm::rescan,onConnect = vm::connect,onCode = vm::codeChanged,@@ -245,7 +249,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {ConnectScreen(hit = rejoining.hit,row = RowState.Waiting(rejoinSince),- now = state.now,+ now = state.clock(),brand = brands.first(),phoneKey = remember { Connector.fingerprint() },onCode = {},@@ -266,7 +270,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {LoggedOutScreen(device = selected,loggedOutAt = loggedOutAt,- now = state.now,+ now = state.clock(),onConnect = { rejoinId = selected.id; rejoinSince = System.currentTimeMillis(); vm.reconnect(selected.id) },onBack = back,)diff --git a/app/src/main/java/app/tellyscope/ui/AccessUi.kt b/app/src/main/java/app/tellyscope/ui/AccessUi.ktindex d89cebb..8a42f26 100644--- a/app/src/main/java/app/tellyscope/ui/AccessUi.kt+++ b/app/src/main/java/app/tellyscope/ui/AccessUi.kt@@ -303,7 +303,7 @@ fun AccessScreen(state: UiState, actions: AccessActions, snackbar: SnackbarHostS) { pad ->val body = Modifier.fillMaxSize().padding(pad)when (removal?.step) {- null, Removal.Step.Confirm -> AccessList(ui.access, state.now, device.state == DeviceState.Online, actions, body)+ null, Removal.Step.Confirm -> AccessList(ui.access, state.clock(), device.state == DeviceState.Online, actions, body)Removal.Step.Revoking -> Waiting(Copy.REVOKING, body)Removal.Step.Checking -> Waiting(Copy.CHECKING, body)Removal.Step.Manual -> ManualGuide(actions, body)diff --git a/app/src/main/java/app/tellyscope/ui/AdvancedScreen.kt b/app/src/main/java/app/tellyscope/ui/AdvancedScreen.ktindex 5cdc7d0..616804f 100644--- a/app/src/main/java/app/tellyscope/ui/AdvancedScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/AdvancedScreen.kt@@ -69,9 +69,11 @@ fun AdvancedScreen(val ui = state.deviceval snap = ui.snapshotval offline = device.state != DeviceState.Online- val labels = ui.apps.associate { it.packageName to it.label }- fun label(p: Proc) = p.packageName?.let { labels[it] ?: AppNames.fallback(it) } ?: Copy.ANDROID_SYSTEM- val byApp = snap?.procs.orEmpty().groupBy(::label)+ val procs = snap?.procs.orEmpty()+ val byApp = remember(ui.apps, procs) {+ val labels = ui.apps.associate { it.packageName to it.label }+ procs.groupBy { p -> p.packageName?.let { labels[it] ?: AppNames.fallback(it) } ?: Copy.ANDROID_SYSTEM }+ }Scaffold(snackbarHost = { SnackbarHost(snackbar) },@@ -104,7 +106,7 @@ fun AdvancedScreen(}if (snap != null) {// Offline: the last stats this phone saw, greyed and dated, rather than a grid of blanks.- item { Stats(snap, if (offline) state.now else null) }+ item { Stats(snap, if (offline) state.clock() else null) }} else {item {Text(diff --git a/app/src/main/java/app/tellyscope/ui/AppsTabs.kt b/app/src/main/java/app/tellyscope/ui/AppsTabs.ktindex 1dfb7cf..9f2981e 100644--- a/app/src/main/java/app/tellyscope/ui/AppsTabs.kt+++ b/app/src/main/java/app/tellyscope/ui/AppsTabs.kt@@ -28,8 +28,8 @@ enum class AppsTab(val label: String) { Running("Running"), Installed("Installeddata class AppsSplit(val apps: List<AppInfo>, val system: List<AppInfo>)/** Locked, as [AppRow] shows it: protected, and not offered as the new home screen or the way back. */-private fun locked(app: AppInfo, all: List<AppInfo>) =- app.protectedReason != null && (app.homeInstead == null || !app.enabled || homeLabel(all, app) == null) &&+private fun locked(app: AppInfo, installed: Set<String>) =+ app.protectedReason != null && (app.homeInstead == null || !app.enabled || app.homeInstead !in installed) &&(app.homeBack == null || !app.enabled) && !(app.homeFirst && app.enabled)/**@@ -40,13 +40,16 @@ private fun locked(app: AppInfo, all: List<AppInfo>) =*/internal fun splitApps(apps: List<AppInfo>, procs: List<Proc>, tab: AppsTab): AppsSplit {val running = procs.filter { it.ramMb > 0 }.mapNotNull { it.packageName }.toSet()+ // Worked out once per app up front, so the sort compares a lookup rather than searching every app each time.+ val installed = apps.mapTo(HashSet()) { it.packageName }+ val lock = apps.filter { locked(it, installed) }.mapTo(HashSet()) { it.packageName }val shown = when (tab) {AppsTab.Running -> apps.filter { it.packageName in running }AppsTab.Installed -> apps.filter { !it.system }AppsTab.BuiltIn -> apps.filter { it.system }- }.sortedWith(compareBy({ locked(it, apps) }, { !it.enabled }, { it.system }, { it.label }))+ }.sortedWith(compareBy({ it.packageName in lock }, { !it.enabled }, { it.system }, { it.label }))if (tab == AppsTab.Installed) return AppsSplit(shown, emptyList())- val (system, rest) = shown.partition { it.system && locked(it, apps) }+ val (system, rest) = shown.partition { it.system && it.packageName in lock }return AppsSplit(rest, system)}diff --git a/app/src/main/java/app/tellyscope/ui/Clock.kt b/app/src/main/java/app/tellyscope/ui/Clock.ktnew file mode 100644index 0000000..a9fa59e--- /dev/null+++ b/app/src/main/java/app/tellyscope/ui/Clock.kt@@ -0,0 +1,18 @@+// SPDX-License-Identifier: GPL-3.0-only+package app.tellyscope.ui++import androidx.compose.runtime.Composable+import androidx.compose.runtime.ReadOnlyComposable+import androidx.compose.runtime.State+import androidx.compose.runtime.staticCompositionLocalOf++/**+ * The ticking clock, from [TellyscopeViewModel.now]. It's a [State] so that only the composable+ * that reads it redraws each second, not the whole page. Null in screenshots and tests.+ */+val LocalNow = staticCompositionLocalOf<State<Long>?> { null }++/** Now, for "2 min ago" and countdowns; read it inside the item that shows the time. Falls back to [UiState.now]. */+@Composable+@ReadOnlyComposable+fun UiState.clock(): Long = LocalNow.current?.value ?: nowdiff --git a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt b/app/src/main/java/app/tellyscope/ui/DeviceTabs.ktindex a86b9b5..f111242 100644--- a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt+++ b/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt@@ -246,6 +246,22 @@ fun DeviceTabsScreen(}},) { pad ->+ // Worked out again only when what they're made from changes, not on every redraw of the page.+ val procs = ui.snapshot?.procs.orEmpty()+ val debloat = remember(ui.history, ui.apps, ui.lists) { debloatState(ui) }+ val found = if (tab == TvTab.Apps && searching) {+ remember(ui.apps, q) {+ ui.apps.filter { q.isEmpty() || it.label.lowercase().contains(q) || it.packageName.contains(q) }+ .sortedWith(compareBy({ !it.enabled }, { it.system }, { it.label }))+ }+ } else {+ emptyList()+ }+ val split = if (tab == TvTab.Apps && !searching) {+ remember(ui.apps, procs, appsTab) { splitApps(ui.apps, procs, appsTab) }+ } else {+ null+ }LazyColumn(Modifier.fillMaxSize().padding(pad),state = list,@@ -260,11 +276,11 @@ fun DeviceTabsScreen(TvTab.Overview -> {val restart = state.restarting[device.id]if (restart != null) {- item { RestartingCard(restart, state.now) }+ item { RestartingCard(restart, state.clock()) }} else if (device.state == DeviceState.NotAllowed) {item { NotAllowedCard(actions.reconnect) }} else if (offline) {- item { OfflineCard(device, state.now, actions.reconnect) }+ item { OfflineCard(device, state.clock(), actions.reconnect) }}// A switch that left the launcher's service off: Home may go back to the TV's own.ui.apps.firstOrNull { it.homeServiceNote }?.takeIf { !offline }?.let { a ->@@ -278,11 +294,10 @@ fun DeviceTabsScreen(if (live != null) {item { SystemWidget(live) }} else if (offline && used != null && total != null) {- item { SystemWidget(used, total, null, asOf = device.lastSeen?.let { Copy.ago(it, state.now) } ?: "the last visit") }+ item { SystemWidget(used, total, null, asOf = device.lastSeen?.let { Copy.ago(it, state.clock()) } ?: "the last visit") }} else if (offline) {item { Muted(Copy.noStats(device.state)) }}- val debloat = debloatState(ui)if (!offline) {item {ActionTiles(@@ -301,16 +316,12 @@ fun DeviceTabsScreen(item { AndroidCard(state, snap, offline, onUpdates = actions.checkUpdates) }}TvTab.Apps -> {- val procs = snap?.procs.orEmpty()fun rows(apps: List<AppInfo>) = items(apps, key = { it.packageName }) { app ->AppRow(app, procs, ui.pending, ui.busy == app.packageName, actions, homeLabel(ui.apps, app), locked = ui.busy != null)}if (searching) {// One flat list of every matching app, whichever button it sits under; each row says// whether it's running, off or protected.- val found = ui.apps- .filter { q.isEmpty() || it.label.lowercase().contains(q) || it.packageName.contains(q) }- .sortedWith(compareBy({ !it.enabled }, { it.system }, { it.label }))if (found.isEmpty()) item { EmptyLine(q) }rows(found)} else {@@ -324,16 +335,17 @@ fun DeviceTabsScreen(if (!offline && offerLauncher(ui.apps, ui.launcherCardHidden)) item(key = "launcherCard") {LauncherCard(ui.apps.firstOrNull { it.home }?.label, onNotNow = actions.hideLauncherCard, onChoose = actions.installLauncher)}- val split = splitApps(ui.apps, procs, appsTab)- if (split.apps.isEmpty() && split.system.isEmpty()) item {- // Away, the TV can't say what's running, rather than nothing is.- if (appsTab == AppsTab.Running && live == null) EmptyState(DeviceIcons.Tv, Copy.TV_OFFLINE, Copy.RUNNING_OFFLINE) else EmptyLine(q)- }- rows(split.apps)- if (split.system.isNotEmpty()) {- val folded = appsTab in state.foldedSystem- item(key = "system") { SystemHeader(split.system.size, folded) { actions.foldSystem(appsTab, it) } }- if (!folded) rows(split.system)+ if (split != null) {+ if (split.apps.isEmpty() && split.system.isEmpty()) item {+ // Away, the TV can't say what's running, rather than nothing is.+ if (appsTab == AppsTab.Running && live == null) EmptyState(DeviceIcons.Tv, Copy.TV_OFFLINE, Copy.RUNNING_OFFLINE) else EmptyLine(q)+ }+ rows(split.apps)+ if (split.system.isNotEmpty()) {+ val folded = appsTab in state.foldedSystem+ item(key = "system") { SystemHeader(split.system.size, folded) { actions.foldSystem(appsTab, it) } }+ if (!folded) rows(split.system)+ }}}}@@ -354,7 +366,7 @@ fun DeviceTabsScreen("Files you send land here.",)}- else -> item { FilesBlock(ui.files, state.now, actions) }+ else -> item { FilesBlock(ui.files, state.clock(), actions) }}}TvTab.Tweaks -> {@@ -362,7 +374,7 @@ fun DeviceTabsScreen(else item { Panel(Copy.TWEAKS) { TweaksBlock(ui, actions) } }item {Panel("Recent changes") {- HistoryList(ui.history, state.now, actions.undo, restoring = ui.busy == RESTORING, onRestoreAll = actions.restoreAll, busy = ui.busy != null)+ HistoryList(ui.history, state.clock(), actions.undo, restoring = ui.busy == RESTORING, onRestoreAll = actions.restoreAll, busy = ui.busy != null)}}}diff --git a/app/src/main/java/app/tellyscope/ui/RemoteScreen.kt b/app/src/main/java/app/tellyscope/ui/RemoteScreen.ktindex 2740ff2..fda5606 100644--- a/app/src/main/java/app/tellyscope/ui/RemoteScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/RemoteScreen.kt@@ -201,11 +201,11 @@ fun RemoteScreen(var confirmReboot by rememberSaveable { mutableStateOf(false) }if (confirmReboot) RebootDialog(onRestart = { confirmReboot = false; actions.reboot() }, onDismiss = { confirmReboot = false })// Hide keeps a restart in the top bar; the dialog comes back when the wait moves on, or on a tap there.- val stage = restart?.let { "${it.since}/${it.waitFrom}/${it.phase(state.now)}" }+ val stage = restart?.let { "${it.since}/${it.waitFrom}/${it.phase(state.clock())}" }var hidden by rememberSaveable { mutableStateOf<String?>(null) }if (restart != null && hidden != stage) {RestartDialog(- restart, state.now, name(device),+ restart, state.clock(), name(device),onHide = { hidden = stage },onRetry = actions.retryRestart,onStop = actions.stopWaiting,@@ -218,7 +218,7 @@ fun RemoteScreen(TopAppBar(title = {when {- restart != null && hidden == stage -> RestartStatus(late = restart.phase(state.now) != Restart.Phase.Waiting, onClick = { hidden = null })+ restart != null && hidden == stage -> RestartStatus(late = restart.phase(state.clock()) != Restart.Phase.Waiting, onClick = { hidden = null })// In place of the title, so the keys below never move.screenOff -> ScreenOffStatus()else -> Text("Remote")diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.ktindex 11fbea8..ed73e89 100644--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt@@ -203,6 +203,7 @@ data class UiState(val selectedId: String? = null,val device: DeviceUi = DeviceUi(),val query: String = "",+ /** When this state was made; it doesn't tick. Screens read the time with [clock]. */val now: Long = System.currentTimeMillis(),/** TVs asked to restart, by id. */val restarting: Map<String, Restart> = emptyMap(),@@ -298,6 +299,10 @@ class TellyscopeViewModel(private val _state = MutableStateFlow(UiState(now = clock()))val state: StateFlow<UiState> = _state.asStateFlow()+ /** The clock, every second. Apart from [state], so a tick redraws only what shows a time. */+ private val _now = MutableStateFlow(clock())+ val now: StateFlow<Long> = _now.asStateFlow()+/** One-shot "done, undo?" messages for the snackbar, with the TV they happened on. */private val _done = MutableStateFlow<Done?>(null)val done: StateFlow<Done?> = _done.asStateFlow()@@ -380,7 +385,7 @@ class TellyscopeViewModel(var tick = 0while (true) {delay(1_000)- _state.update { it.copy(now = clock()) }+ _now.value = clock()if (++tick % 3 == 0) refreshDevices()}}diff --git a/app/src/test/java/app/tellyscope/AppsTabsTest.kt b/app/src/test/java/app/tellyscope/AppsTabsTest.ktindex 5886c4a..8b44099 100644--- a/app/src/test/java/app/tellyscope/AppsTabsTest.kt+++ b/app/src/test/java/app/tellyscope/AppsTabsTest.kt@@ -62,6 +62,13 @@ class AppsTabsTest {assertEquals(listOf("gms", "launcher", "systemui"), names(split.system))}+ @Test fun `a protected launcher offered in place of an app the TV doesn't have stays locked`() {+ val gone = app("com.maker.home", system = true, locked = "launcher", home = "com.not.installed")+ val split = splitApps(apps + gone, procs, AppsTab.BuiltIn)+ assertEquals(listOf("assistant", "ota"), names(split.apps))+ assertEquals(listOf("gms", "home", "launcher", "systemui"), names(split.system))+ }+@Test fun `a fold is kept per tab across restarts, until it is opened again`() {val file = tmp.root.resolve("folds.properties")FoldBook(file).set(AppsTab.Running.name, true)