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.
Connect: say when the TV can't be reached, and wait for Wi-Fi
jesse-agent-232ab062c4592e3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7090952..9795d77 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,7 @@ until this file has a section for its version.- **New:** Spanish, Chinese, Japanese and Russian translations, machine-made; corrections welcome. [#272](../../pull/272)- **Improved:** Tweaks shows the same TV-offline screen as Files. [#273](../../pull/273)- **Fixed:** With the TV away, app rows grey out and won't open. [#273](../../pull/273)+- **Fixed:** Connect says when the phone has dropped off Wi-Fi, and Try again waits for Wi-Fi instead of failing at once. [#000](../../pull/000)## 0.14.0 — 2026-10-30diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.ktindex d2fc5cd..d53eb07 100644--- a/app/src/main/java/app/tellyscope/MainActivity.kt+++ b/app/src/main/java/app/tellyscope/MainActivity.kt@@ -258,6 +258,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {onBack = if (adding) ({ adding = false }) else null,onOpenWifi = { context.openWifiSettings() },phoneKey = remember { Connector.fingerprint() },+ onLeave = vm::leaveConnect,)} else if (state.report != null) {BackHandler { vm.closeReport() }diff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.ktindex 9d3793c..891434c 100644--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt@@ -265,6 +265,8 @@ class AdbDeviceSource(context: Context) : DeviceSource {.distinct()}+ override fun onLan() = lanHosts().isNotEmpty()+override fun lanUp(): Flow<Unit> = callbackFlow {val cm = appContext.getSystemService(ConnectivityManager::class.java) ?: run { close(); return@callbackFlow }val callback = object : ConnectivityManager.NetworkCallback() {diff --git a/app/src/main/java/app/tellyscope/data/DeviceSource.kt b/app/src/main/java/app/tellyscope/data/DeviceSource.ktindex f5f0da6..6220adf 100644--- a/app/src/main/java/app/tellyscope/data/DeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/DeviceSource.kt@@ -33,6 +33,9 @@ interface DeviceSource {/** Emits whenever the phone is on a Wi-Fi or Ethernet network a [scan] can sweep. */fun lanUp(): Flow<Unit> = emptyFlow()+ /** Whether the phone is on such a network right now. */+ fun onLan(): Boolean = true+/** Classic connect. Suspends while the TV shows the Allow prompt; the caller owns the timeout. */suspend fun connect(hit: ScanHit): ConnectResultdiff --git a/app/src/main/java/app/tellyscope/ui/ConnectScreen.kt b/app/src/main/java/app/tellyscope/ui/ConnectScreen.ktindex 2bc32a7..224f1f3 100644--- a/app/src/main/java/app/tellyscope/ui/ConnectScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/ConnectScreen.kt@@ -29,6 +29,7 @@ import androidx.compose.material.icons.filled.Checkimport androidx.compose.material.icons.filled.Warningimport androidx.compose.material3.Buttonimport androidx.compose.material3.ExperimentalMaterial3Api+import androidx.compose.material3.FilledTonalButtonimport androidx.compose.material3.ExperimentalMaterial3ExpressiveApiimport androidx.compose.material3.Iconimport androidx.compose.material3.IconButton@@ -43,6 +44,7 @@ import androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.vector.ImageVectorimport androidx.compose.ui.semantics.contentDescriptionimport androidx.compose.ui.semantics.semanticsimport androidx.compose.ui.text.font.FontFamily@@ -77,6 +79,7 @@ fun ConnectScreen(onRetry: () -> Unit,onBack: () -> Unit,title: String? = null,+ onOpenWifi: () -> Unit = {},) {Scaffold(topBar = {@@ -92,7 +95,7 @@ fun ConnectScreen(verticalAlignment = Alignment.CenterVertically,) {when (row) {- RowState.NotAllowed -> {+ RowState.NotAllowed, is RowState.Unreachable -> {TextButton(onClick = onBack) { Text(stringResource(R.string.connect_back_to_tvs)) }Button(onClick = onRetry) { Text(stringResource(R.string.connect_try_again)) }}@@ -143,11 +146,7 @@ fun ConnectScreen(row.detail?.let { Details(listOf(stringResource(R.string.connect_from_tv) to it)) }}RowState.NotAllowed -> {- Surface(Modifier.size(64.dp), shape = CircleShape, color = MaterialTheme.colorScheme.errorContainer) {- Box(contentAlignment = Alignment.Center) {- Icon(Icons.Default.Warning, null, Modifier.size(32.dp), tint = MaterialTheme.colorScheme.onErrorContainer)- }- }+ ProblemIcon(Icons.Default.Warning)Text(stringResource(R.string.connect_no_answer), style = MaterialTheme.typography.headlineMedium)Text(stringResource(R.string.connect_not_accepted),@@ -194,6 +193,36 @@ fun ConnectScreen()}}+ // Reachable but refusing is No answer above; this is a TV that didn't answer at all.+ is RowState.Unreachable, RowState.WaitingForWifi -> {+ val offWifi = row != RowState.Unreachable(offWifi = false)+ ProblemIcon(if (offWifi) DeviceIcons.WifiOff else Icons.Default.Warning)+ Text(stringResource(R.string.connect_cant_reach), style = MaterialTheme.typography.headlineMedium)+ Text(+ stringResource(+ when {+ row == RowState.WaitingForWifi -> R.string.connect_off_wifi_waiting+ offWifi -> R.string.connect_off_wifi+ else -> R.string.connect_tv_silent+ },+ ),+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ if (offWifi) FilledTonalButton(onClick = onOpenWifi) { Text(stringResource(R.string.scan_open_wifi)) }+ if (row == RowState.WaitingForWifi) Row(verticalAlignment = Alignment.CenterVertically) {+ LoadingIndicator(Modifier.size(32.dp))+ Spacer(Modifier.width(12.dp))+ Text(stringResource(R.string.connect_waiting_wifi), color = MaterialTheme.colorScheme.onSurfaceVariant)+ }+ if (!offWifi) Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+ listOf(+ stringResource(R.string.connect_check_on),+ stringResource(R.string.connect_check_same_wifi),+ stringResource(R.string.connect_check_new_address),+ ).forEach { Text(stringResource(R.string.connect_bullet, it), style = MaterialTheme.typography.bodyMedium) }+ }+ }RowState.Found -> Connecting()}}@@ -201,6 +230,16 @@ fun ConnectScreen(}@OptIn(ExperimentalMaterial3ExpressiveApi::class)+/** The round error badge heading No answer and Can't reach the TV. */+@Composable+private fun ProblemIcon(icon: ImageVector) {+ Surface(Modifier.size(64.dp), shape = CircleShape, color = MaterialTheme.colorScheme.errorContainer) {+ Box(contentAlignment = Alignment.Center) {+ Icon(icon, null, Modifier.size(32.dp), tint = MaterialTheme.colorScheme.onErrorContainer)+ }+ }+}+@Composableprivate fun Connecting() {Text(stringResource(R.string.connect_connecting), style = MaterialTheme.typography.headlineMedium)diff --git a/app/src/main/java/app/tellyscope/ui/ScanScreen.kt b/app/src/main/java/app/tellyscope/ui/ScanScreen.ktindex 20b14e9..76836c8 100644--- a/app/src/main/java/app/tellyscope/ui/ScanScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/ScanScreen.kt@@ -82,6 +82,7 @@ fun ScanScreen(onBack: (() -> Unit)? = null,onOpenWifi: () -> Unit = {},phoneKey: String? = null,+ onLeave: (ScanHit) -> Unit = {},) {var adding by remember { mutableStateOf(false) }var help by remember { mutableStateOf(false) }@@ -94,7 +95,7 @@ fun ScanScreen(val openHit = scan.hits.firstOrNull { it.ip == open }if (openHit != null) {- BackHandler { open = null }+ BackHandler { onLeave(openHit); open = null }ConnectScreen(hit = openHit,row = scan.rows[openHit.ip] ?: RowState.Found,@@ -104,7 +105,8 @@ fun ScanScreen(onCode = { onCode(openHit, it) },onPair = { onPair(openHit) },onRetry = { onConnect(openHit) },- onBack = { open = null },+ onBack = { onLeave(openHit); open = null },+ onOpenWifi = onOpenWifi,)return}@@ -142,7 +144,7 @@ fun ScanScreen(GuideSteps(brand, step, onStep = { step = it }) {FoundTvs(scan, now, onRescan, onPick = { hit ->val row = scan.rows[hit.ip] ?: RowState.Found- if (row == RowState.Found || row == RowState.NotAllowed) onConnect(hit)+ if (row == RowState.Found || row == RowState.NotAllowed || row is RowState.Unreachable) onConnect(hit)open = hit.ip})}@@ -197,7 +199,7 @@ private fun FoundTvs(scan: ScanUi, now: Long, onRescan: () -> Unit, onPick: (ScaText(when (row) {RowState.Found -> stringResource(R.string.scan_connect)- RowState.NotAllowed -> stringResource(R.string.scan_try_again)+ RowState.NotAllowed, is RowState.Unreachable -> stringResource(R.string.scan_try_again)else -> stringResource(R.string.scan_continue)},)diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.ktindex e98c5b1..ea4bccc 100644--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt@@ -73,6 +73,7 @@ import kotlinx.coroutines.delayimport kotlinx.coroutines.flow.MutableStateFlowimport kotlinx.coroutines.flow.StateFlowimport kotlinx.coroutines.flow.asStateFlow+import kotlinx.coroutines.flow.firstOrNullimport kotlinx.coroutines.flow.updateimport kotlinx.coroutines.launchimport kotlinx.coroutines.sync.Mutex@@ -91,6 +92,10 @@ sealed interface RowState {/** [error] is the plain sentence; [detail] is what the TV said, shown under Details. */data class Code(val input: String = "", val busy: Boolean = false, val error: UiText? = null, val detail: String? = null) : RowStatedata object NotAllowed : RowState+ /** The TV didn't answer at all; [offWifi] when this phone isn't on Wi-Fi, which is why. */+ data class Unreachable(val offWifi: Boolean) : RowState+ /** Connect asked for while off Wi-Fi: it goes on by itself once the phone is back on. */+ data object WaitingForWifi : RowState}data class ScanUi(@@ -437,6 +442,7 @@ class TellyscopeViewModel(private val typed = mutableMapOf<String, Int>()private var scanJob: Job? = null+ private var wifiWait: 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. */@@ -595,6 +601,17 @@ class TellyscopeViewModel(}fun connect(hit: ScanHit) {+ wifiWait?.cancel()+ // Off Wi-Fi every try fails at once: wait for the network instead, then ask the TV.+ if (!source.onLan()) {+ setRow(hit.ip, RowState.WaitingForWifi)+ wifiWait = viewModelScope.launch {+ source.lanUp().firstOrNull() ?: return@launch+ wifiWait = null+ connect(hit)+ }+ return+ }// Wireless-debugging TVs that already know our key connect straight away;// the rest answer NeedsPairing and get the code field.setRow(hit.ip, RowState.Waiting(clock()))@@ -602,17 +619,26 @@ class TellyscopeViewModel(val r = withTimeoutOrNull(allowTimeoutMs) { source.connect(hit) }when {r is ConnectResult.Online -> online(r.device)+ // Wi-Fi dropped mid-connect: the TV never had a chance to answer.+ !source.onLan() -> setRow(hit.ip, RowState.Unreachable(offWifi = true))r == ConnectResult.NeedsPairing -> setRow(hit.ip, RowState.Code())// A wireless-debugging TV never shows the Allow box: whatever went wrong, the way in is the code.hit.kind == ScanKind.Wireless -> setRow(hit.ip, RowState.Code(error = if (r is ConnectResult.Unreachable) Copy.UNREACHABLE else Copy.PAIR_INSTEAD,detail = (r as? ConnectResult.Unreachable)?.message ?: (r as? ConnectResult.WrongCode)?.message,))+ r is ConnectResult.Unreachable -> setRow(hit.ip, RowState.Unreachable(offWifi = false))else -> setRow(hit.ip, RowState.NotAllowed)}}}+ /** The connect screen closed: stop waiting for Wi-Fi, so the TV isn't asked behind the user's back. */+ fun leaveConnect(hit: ScanHit) {+ wifiWait?.cancel()+ if (_state.value.scan.rows[hit.ip] == RowState.WaitingForWifi) setRow(hit.ip, RowState.Unreachable(offWifi = true))+ }+fun codeChanged(hit: ScanHit, input: String) {setRow(hit.ip, RowState.Code(input.filter(Char::isDigit).take(6)))}diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex eafe281..37d7d3f 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -1217,6 +1217,14 @@<string name="connect_check_awake">Is the TV on and awake?</string><string name="connect_check_denied">Was the box on the TV closed, or Deny pressed? Try again and it asks once more.</string><string name="connect_check_restart">Some TVs switch debugging off after a restart. Turn it back on.</string>+ <string name="connect_cant_reach">Can\'t reach the TV</string>+ <string name="connect_off_wifi">This phone isn\'t on Wi-Fi. Join the same Wi-Fi as the TV, then try again.</string>+ <string name="connect_off_wifi_waiting">This phone isn\'t on Wi-Fi. Join the same Wi-Fi as the TV. Tellyscope carries on as soon as you\'re on.</string>+ <string name="connect_waiting_wifi">Waiting for Wi-Fi…</string>+ <string name="connect_tv_silent">This phone is on Wi-Fi, but the TV didn\'t answer.</string>+ <string name="connect_check_on">Is the TV on? Some TVs drop off Wi-Fi when they sleep.</string>+ <string name="connect_check_same_wifi">Same Wi-Fi as the TV? A guest network keeps them apart.</string>+ <string name="connect_check_new_address">Did the TV get a new address? Go back to TVs and tap Rescan.</string><!-- One item of a bulleted list --><string name="connect_bullet">• %1$s</string><string name="connect_allow_title">Allow on your TV</string>diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.ktindex ba80116..838461a 100644--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt@@ -247,6 +247,14 @@ class ScreenshotTest {@Test fun connect_notAllowed_dark() = connect(unknown, RowState.NotAllowed, true, "03_connect_no_answer")+ @Test fun connect_offWifi() = connect(unknown, RowState.Unreachable(offWifi = true), false, "03_connect_off_wifi")++ @Test fun connect_offWifi_dark() = connect(unknown, RowState.Unreachable(offWifi = true), true, "03_connect_off_wifi")++ @Test fun connect_waitingForWifi() = connect(unknown, RowState.WaitingForWifi, false, "03_connect_waiting_wifi")++ @Test fun connect_tvSilent() = connect(unknown, RowState.Unreachable(offWifi = false), false, "03_connect_tv_silent")+private fun deviceState(device: DeviceUi.() -> DeviceUi = { this }): UiState = runBlocking {val d = Device(xgimi.ip, xgimi, DeviceState.Online, "XGIMI Horizon Pro", "XGIMI", "11", now)UiState(diff --git a/app/src/test/java/app/tellyscope/WirelessConnectTest.kt b/app/src/test/java/app/tellyscope/WirelessConnectTest.ktindex f0ed22c..0bd6612 100644--- a/app/src/test/java/app/tellyscope/WirelessConnectTest.kt+++ b/app/src/test/java/app/tellyscope/WirelessConnectTest.kt@@ -16,6 +16,8 @@ import kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.ExperimentalCoroutinesApiimport kotlinx.coroutines.awaitCancellationimport kotlinx.coroutines.cancel+import kotlinx.coroutines.flow.Flow+import kotlinx.coroutines.flow.MutableSharedFlowimport kotlinx.coroutines.test.StandardTestDispatcherimport kotlinx.coroutines.test.TestScopeimport kotlinx.coroutines.test.advanceTimeBy@@ -30,6 +32,12 @@ import org.junit.Test/** Every connect answers [result]; null hangs until the caller's timeout. */private class Answers : DeviceSource by FakeDeviceSource(FakeDeviceSource.Scenario.Empty, clock = { 0L }) {var result: ConnectResult? = null+ var lan = true+ val lanBack = MutableSharedFlow<Unit>(extraBufferCapacity = 1)++ override fun onLan() = lan++ override fun lanUp(): Flow<Unit> = lanBackoverride suspend fun known() = emptyList<Device>()@@ -95,4 +103,45 @@ class WirelessConnectTest {source.result = nullassertEquals(RowState.NotAllowed, connect(classic))}++ @Test fun classicUnreachableOnWifiIsCantReachNotNoAnswer() {+ source.result = ConnectResult.Unreachable("connection refused")+ assertEquals(RowState.Unreachable(offWifi = false), connect(classic))+ }++ @Test fun wifiDroppedMidConnectIsCantReachOffWifi() {+ source.result = null+ vm.connect(classic)+ test.runCurrent()+ source.lan = false+ test.advanceTimeBy(60_001)+ test.runCurrent()+ assertEquals(RowState.Unreachable(offWifi = true), vm.state.value.scan.rows[classic.ip])+ }++ @Test fun tryAgainOffWifiWaitsThenAsksTheTv() {+ source.lan = false+ vm.connect(classic)+ test.runCurrent()+ assertEquals(RowState.WaitingForWifi, vm.state.value.scan.rows[classic.ip])+ // No Allow countdown while there's no network: the wait has no limit.+ test.advanceTimeBy(120_000)+ test.runCurrent()+ assertEquals(RowState.WaitingForWifi, vm.state.value.scan.rows[classic.ip])+ source.lan = true+ source.lanBack.tryEmit(Unit)+ test.runCurrent()+ assertEquals(RowState.Waiting(0L), vm.state.value.scan.rows[classic.ip])+ }++ @Test fun leavingStopsTheWifiWait() {+ source.lan = false+ vm.connect(classic)+ test.runCurrent()+ vm.leaveConnect(classic)+ source.lan = true+ source.lanBack.tryEmit(Unit)+ test.runCurrent()+ assertEquals(RowState.Unreachable(offWifi = true), vm.state.value.scan.rows[classic.ip])+ }}