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.
Find your TV: count down to the next scan and add Rescan
jesse-agent-232fcfbee6f1dc3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f1466ea..12b7617 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -34,6 +34,7 @@ until this file has a section for its version.- **Fixed:** A Remote button's tap ripple stays inside the button. [#228](../../pull/228)- **Improved:** The Remote buttons list has more room at its sides. [#228](../../pull/228)- **Improved:** Lists and logos are checked before use, so a bad list source is refused. [#226](../../pull/226)+- **Improved:** Find your TV counts down to its next look every 10 seconds, and has a Rescan button. [#234](../../pull/234)## 0.12.0 — 2026-10-28diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.ktindex 75a8d8e..68d981a 100644--- a/app/src/main/java/app/tellyscope/MainActivity.kt+++ b/app/src/main/java/app/tellyscope/MainActivity.kt@@ -240,6 +240,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {if (st == DeviceState.Online || (st == DeviceState.NotAllowed && loggedOutAt == null)) rejoinId = null}+ LaunchedEffect(adding) { vm.addingTv(adding) }if (state.selected == null || adding) {BackHandler(enabled = adding) { adding = false }ScanScreen(diff --git a/app/src/main/java/app/tellyscope/ui/ScanScreen.kt b/app/src/main/java/app/tellyscope/ui/ScanScreen.ktindex 0e0ddd0..436e069 100644--- a/app/src/main/java/app/tellyscope/ui/ScanScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/ScanScreen.kt@@ -3,6 +3,9 @@package app.tellyscope.uiimport androidx.activity.compose.BackHandler+import androidx.compose.animation.core.LinearEasing+import androidx.compose.animation.core.animateFloatAsState+import androidx.compose.animation.core.tweenimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Column@@ -27,6 +30,7 @@ import androidx.compose.material3.AlertDialogimport androidx.compose.material3.Buttonimport androidx.compose.material3.Cardimport androidx.compose.material3.CardDefaults+import androidx.compose.material3.CircularProgressIndicatorimport androidx.compose.material3.ExperimentalMaterial3Apiimport androidx.compose.material3.ExperimentalMaterial3ExpressiveApiimport androidx.compose.material3.FilledTonalButton@@ -50,9 +54,11 @@ import androidx.compose.runtime.saveable.rememberSaveableimport androidx.compose.runtime.setValueimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResourceimport androidx.compose.ui.text.input.KeyboardTypeimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.unit.dp+import app.tellyscope.Rimport app.tellyscope.data.ScanHitimport app.tellyscope.ui.theme.SmallNumber@@ -132,7 +138,7 @@ fun ScanScreen(}BrandChips(brand, onPick = { brandName = it.name })GuideSteps(brand, step, onStep = { step = it }) {- FoundTvs(scan, onRescan, onPick = { hit ->+ FoundTvs(scan, now, onRescan, onPick = { hit ->val row = scan.rows[hit.ip] ?: RowState.Foundif (row == RowState.Found || row == RowState.NotAllowed) onConnect(hit)open = hit.ip@@ -166,7 +172,7 @@ fun ScanScreen(/** Step 3: what the scan has found so far, each a tap away from its connect screen. */@OptIn(ExperimentalMaterial3ExpressiveApi::class)@Composable-private fun FoundTvs(scan: ScanUi, onRescan: () -> Unit, onPick: (ScanHit) -> Unit) {+private fun FoundTvs(scan: ScanUi, now: Long, onRescan: () -> Unit, onPick: (ScanHit) -> Unit) {Column(Modifier.padding(top = 8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {scan.hits.forEach { hit ->val row = scan.rows[hit.ip] ?: RowState.Found@@ -211,7 +217,19 @@ private fun FoundTvs(scan: ScanUi, onRescan: () -> Unit, onPick: (ScanHit) -> Un)if (p != null) Text("${p.probed}/${p.total}", style = SmallNumber, color = MaterialTheme.colorScheme.onSurfaceVariant)}- // An empty scan starts again by itself; only a list that has something offers the button.+ // An empty scan starts again by itself; the ring empties until it does.+ scan.hits.isEmpty() && scan.nextScanAt != null -> {+ val left = (scan.nextScanAt - now).coerceIn(0L, RESCAN_EVERY_MS)+ // The clock ticks once a second; the ring glides between ticks.+ val ring by animateFloatAsState(left / RESCAN_EVERY_MS.toFloat(), tween(1_000, easing = LinearEasing), label = "next scan")+ CircularProgressIndicator(progress = { ring }, modifier = Modifier.size(32.dp))+ Spacer(Modifier.width(12.dp))+ Text(+ stringResource(R.string.scan_none_yet_in, ((left + 999) / 1_000).toInt().coerceAtLeast(1)),+ style = MaterialTheme.typography.bodyMedium.copy(fontFeatureSettings = "tnum"),+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }scan.hits.isEmpty() -> Text("No TV yet. Tellyscope looks again in a moment.",style = MaterialTheme.typography.bodyMedium,@@ -224,6 +242,12 @@ private fun FoundTvs(scan: ScanUi, onRescan: () -> Unit, onPick: (ScanHit) -> Un}}}+ // Until a TV turns up, Rescan stays in one place; it waits out a scan rather than throw its probes away.+ if (scan.hits.isEmpty()) FilledTonalButton(onClick = onRescan, enabled = !scan.scanning) {+ Icon(Icons.Default.Refresh, null, Modifier.size(18.dp))+ Spacer(Modifier.width(8.dp))+ Text(stringResource(R.string.scan_rescan))+ }}}diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.ktindex c505fdd..69cca82 100644--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt@@ -64,6 +64,7 @@ import kotlinx.coroutines.CancellationExceptionimport kotlinx.coroutines.CompletableDeferredimport kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.Job+import kotlinx.coroutines.channels.Channelimport kotlinx.coroutines.delayimport kotlinx.coroutines.flow.MutableStateFlowimport kotlinx.coroutines.flow.StateFlow@@ -94,6 +95,8 @@ data class ScanUi(val noLan: Boolean = false,val hits: List<ScanHit> = emptyList(),val rows: Map<String, RowState> = emptyMap(),+ /** Nothing found yet: when the next scan starts by itself. Null while a scan runs or once a TV turns up. */+ val nextScanAt: Long? = null,) {/** Off Wi-Fi with nothing found: the scan screen asks the user to join one instead of listing. */val offWifi get() = noLan && hits.isEmpty()@@ -344,6 +347,9 @@ const val ANSWERING = "request"/** How often Install a home screen asks the TV whether the launcher is in yet. */const val STORE_POLL_MS = 3_000L+/** An empty scan starts again after this long, unless Rescan is tapped first. */+const val RESCAN_EVERY_MS = 10_000L+/** How long it keeps asking before it says the launcher didn't arrive. */const val STORE_WAIT_MS = 10 * 60_000L@@ -403,6 +409,10 @@ class TellyscopeViewModel(private val typed = mutableMapOf<String, Int>()private var scanJob: Job? = null+ /** Rescan tapped while an empty scan waits: cuts the wait short. */+ private val scanNow = Channel<Unit>(Channel.CONFLATED)+ /** The add flow is open over a selected TV, so an empty scan keeps looking there too. */+ private var addingTv = falseprivate var sideloadJob: Job? = null/** File copies by TV: each dialog shows only on its own TV's page, and its Cancel stops only that copy. */private val transferJobs = mutableMapOf<String, Job>()@@ -510,10 +520,14 @@ class TellyscopeViewModel(scanOnResume = truereturn}- if (scanJob?.isActive == true) return+ if (scanJob?.isActive == true) {+ if (_state.value.scan.nextScanAt != null) scanNow.trySend(Unit)+ return+ }scanJob = viewModelScope.launch {- // Empty scan with no TV open: the guide is on screen; keep looking so the user never has to- // press anything. The retry stays in this job, as rescan() from here would see it still active.+ // Empty scan with the guide on screen: keep looking so the user never has to press anything.+ // The retry stays in this job, as rescan() from here would see it still active.+ val done = { _state.value.let { it.scan.hits.isNotEmpty() || (it.selected != null && !addingTv) } }while (true) {_state.update { it.copy(scan = it.scan.copy(scanning = true, noLan = false)) }source.scan().collect { e ->@@ -532,12 +546,26 @@ class TellyscopeViewModel(}}_state.update { it.copy(scan = it.scan.copy(scanning = false)) }- if (_state.value.let { it.scan.hits.isNotEmpty() || it.selected != null }) break- delay(15_000)+ if (done()) break+ scanNow.tryReceive() // drops a tap that raced the last wait's timeout+ _state.update { it.copy(scan = it.scan.copy(nextScanAt = clock() + RESCAN_EVERY_MS)) }+ try {+ withTimeoutOrNull(RESCAN_EVERY_MS) { scanNow.receive() }+ } finally {+ _state.update { it.copy(scan = it.scan.copy(nextScanAt = null)) }+ }+ if (done()) break}}}+ /** The add flow opened or closed over a selected TV. Closed, an empty scan stops waiting to look again. */+ fun addingTv(open: Boolean) {+ addingTv = open+ if (open) rescan()+ else if (_state.value.let { it.selected != null && it.scan.nextScanAt != null }) scanJob?.cancel()+ }+fun connect(hit: ScanHit) {// Wireless-debugging TVs that already know our key connect straight away;// the rest answer NeedsPairing and get the code field.diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xmlnew file mode 100644index 0000000..089861d--- /dev/null+++ b/app/src/main/res/values-hi/strings.xml@@ -0,0 +1,5 @@+<?xml version="1.0" encoding="utf-8"?>+<resources>+ <string name="scan_rescan">फिर से स्कैन करें</string>+ <string name="scan_none_yet_in">अभी कोई TV नहीं मिला। %1$d सेकंड में फिर से ढूंढा जाएगा</string>+</resources>diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 3175ecb..84512ec 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -1,3 +1,5 @@<resources><string name="app_name">Tellyscope</string>+ <string name="scan_rescan">Rescan</string>+ <string name="scan_none_yet_in">No TV yet. Looking again in %1$d s</string></resources>diff --git a/app/src/test/java/app/tellyscope/OffWifiTest.kt b/app/src/test/java/app/tellyscope/OffWifiTest.ktindex 8f6fdea..fa79cc7 100644--- a/app/src/test/java/app/tellyscope/OffWifiTest.kt+++ b/app/src/test/java/app/tellyscope/OffWifiTest.kt@@ -112,7 +112,7 @@ class OffWifiTest {}}- @Test fun anEmptyScanTriesAgainEvery15Seconds() {+ @Test fun anEmptyScanTriesAgainEvery10Seconds() {val dispatcher = StandardTestDispatcher()Dispatchers.setMain(dispatcher)val source = JoinsWifi()@@ -121,9 +121,9 @@ class OffWifiTest {with(TestScope(dispatcher)) {runCurrent()assertEquals(1, source.scans)- advanceTimeBy(15_001)+ advanceTimeBy(10_001)assertEquals(2, source.scans)- advanceTimeBy(15_001)+ advanceTimeBy(10_001)assertEquals(3, source.scans)}} finally {diff --git a/app/src/test/java/app/tellyscope/PauseTest.kt b/app/src/test/java/app/tellyscope/PauseTest.ktindex 23d123a..6446723 100644--- a/app/src/test/java/app/tellyscope/PauseTest.kt+++ b/app/src/test/java/app/tellyscope/PauseTest.kt@@ -111,7 +111,7 @@ class PauseTest {@Test fun theEmptyScanStopsInTheBackgroundAndStartsAgainAfter() = with(test) {val tv = Counted(tvs = false)open(tv)- assertTrue("scan" in tv.reads) // no TV, nothing found: it keeps looking every 15 s+ assertTrue("scan" in tv.reads) // no TV, nothing found: it keeps looking every 10 svm.pause()runCurrent()tv.reads.clear()diff --git a/app/src/test/java/app/tellyscope/RescanTest.kt b/app/src/test/java/app/tellyscope/RescanTest.ktnew file mode 100644index 0000000..f93cbc9--- /dev/null+++ b/app/src/test/java/app/tellyscope/RescanTest.kt@@ -0,0 +1,117 @@+// SPDX-License-Identifier: GPL-3.0-only++package app.tellyscope++import androidx.compose.ui.test.assertIsDisplayed+import androidx.compose.ui.test.assertIsEnabled+import androidx.compose.ui.test.assertIsNotEnabled+import androidx.compose.ui.test.junit4.createComposeRule+import androidx.compose.ui.test.onNodeWithText+import androidx.compose.ui.test.performClick+import androidx.compose.ui.test.performScrollTo+import androidx.lifecycle.viewModelScope+import app.tellyscope.data.Device+import app.tellyscope.data.DeviceSource+import app.tellyscope.data.FakeDeviceSource+import app.tellyscope.data.ScanEvent+import app.tellyscope.ui.RESCAN_EVERY_MS+import app.tellyscope.ui.ScanScreen+import app.tellyscope.ui.ScanUi+import app.tellyscope.ui.TellyscopeViewModel+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.ExperimentalCoroutinesApi+import kotlinx.coroutines.cancel+import kotlinx.coroutines.flow.flowOf+import kotlinx.coroutines.test.StandardTestDispatcher+import kotlinx.coroutines.test.TestScope+import kotlinx.coroutines.test.advanceTimeBy+import kotlinx.coroutines.test.resetMain+import kotlinx.coroutines.test.runCurrent+import kotlinx.coroutines.test.setMain+import org.junit.Assert.assertEquals+import org.junit.Assert.assertNull+import org.junit.Rule+import org.junit.Test+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.annotation.Config++/** A LAN with no TV on it: every scan ends empty. */+private class NoTv : DeviceSource by FakeDeviceSource(FakeDeviceSource.Scenario.Empty, clock = { 0L }) {+ var scans = 0++ override suspend fun known() = emptyList<Device>()++ override fun scan() = flowOf<ScanEvent>(ScanEvent.Done).also { scans++ }+}++@OptIn(ExperimentalCoroutinesApi::class)+@RunWith(RobolectricTestRunner::class)+@Config(sdk = [35])+class RescanTest {+ @get:Rule val compose = createComposeRule()++ /** The scan screen on its last step, Find your TV. */+ private fun show(scan: ScanUi, now: Long = 0L, onRescan: () -> Unit = {}) {+ compose.setContent { ScanScreen(scan, now, onRescan, {}, { _, _ -> }, {}, { null }) }+ repeat(2) { compose.onNodeWithText("Done, next").performScrollTo().performClick() }+ }++ @Test fun idleCountsDownToTheNextScanAndRescans() {+ var rescans = 0+ show(ScanUi(nextScanAt = 7_000), now = 600) { rescans++ }+ compose.onNodeWithText("No TV yet. Looking again in 7 s").assertIsDisplayed()+ compose.onNodeWithText("Rescan").performScrollTo().assertIsEnabled().performClick()+ assertEquals(1, rescans)+ }++ @Test fun rescanWaitsOutARunningScan() {+ show(ScanUi(scanning = true))+ compose.onNodeWithText("Looking for your TV…").assertIsDisplayed()+ compose.onNodeWithText("Rescan").performScrollTo().assertIsNotEnabled()+ }++ @Test fun rescanCutsTheWaitShort() {+ val dispatcher = StandardTestDispatcher()+ Dispatchers.setMain(dispatcher)+ val source = NoTv()+ val vm = TellyscopeViewModel(source, clock = { 0L })+ try {+ with(TestScope(dispatcher)) {+ runCurrent()+ assertEquals(1, source.scans)+ assertEquals(RESCAN_EVERY_MS, vm.state.value.scan.nextScanAt)++ vm.rescan()+ runCurrent()+ assertEquals(2, source.scans)++ // The wait starts over from the tapped scan, not the old one.+ advanceTimeBy(RESCAN_EVERY_MS - 1)+ assertEquals(2, source.scans)+ advanceTimeBy(2)+ assertEquals(3, source.scans)+ }+ } finally {+ vm.viewModelScope.cancel()+ Dispatchers.resetMain()+ }+ }++ @Test fun pausingClearsTheCountdown() {+ val dispatcher = StandardTestDispatcher()+ Dispatchers.setMain(dispatcher)+ val vm = TellyscopeViewModel(NoTv(), clock = { 0L })+ try {+ with(TestScope(dispatcher)) {+ runCurrent()+ vm.pause()+ runCurrent()+ assertNull(vm.state.value.scan.nextScanAt)+ }+ } finally {+ vm.viewModelScope.cancel()+ Dispatchers.resetMain()+ }+ }+}