Skip to content

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.

Remove all other access: Check again and Restart the TV

jesse-agent-2324f9f0f627fe7
diff --git a/README.md b/README.md
index 4375dcb..ba7fc5d 100644
--- a/README.md
+++ b/README.md
@@ -90,7 +90,7 @@ Tellyscope is a phone app that talks to your Android TV, Google TV or Fire TV ov
- **History.** Every change is listed with an Undo, and **Restore everything** turns back on what Tellyscope turned off. Undoing a **Turn on** asks first, since it disables the app again. History is kept per TV, across restarts.
- **Install apps.** Pick an APK, several split APKs or an `.apks`/`.xapk`/`.apkm` bundle on your phone. Before installing, Tellyscope shows the app's name, version and size and says whether it's new, an update, a reinstall or an older version. It won't install an older version over a newer one unless you tick the box. If the TV refuses, you get the reason in plain words.
- **TV tweaks.** **Block ads with Private DNS** sends the TV's address lookups to an ad-blocking DNS provider (AdGuard by default, or any other you type in). Tellyscope then checks the TV can still look addresses up, and puts the old setting back if not. It needs Android 9 or newer. **Faster animations** makes menus move at twice the speed. Both land in History with an Undo. **Clear caches** frees space by clearing every app's temporary files; app data and sign-ins stay. **Take screenshot** saves what the TV shows to your phone.
-- **Who has access.** ADB lets any allowed computer do everything Tellyscope can, so the TV's page warns, above its stats, when a computer other than this phone is connected, with **It's mine** for your own. **Who has access** in the **⋮** menu lists who is connected now and every computer the TV allows, with its key fingerprint and roughly when it was last seen. The TV doesn't say which key is behind which connection, so Tellyscope never pairs them up. **Remove all other access** clears the TV's allowed list, then reconnects so the TV asks to allow this phone again; on TVs that won't take the request, it opens Developer options and walks you through **Revoke USB debugging authorisations**. A computer that is already connected keeps its connection until it disconnects or the TV restarts, so if one is still there Tellyscope says so and offers **Restart the TV**. It says "Only this phone has access" only after checking the TV again.
+- **Who has access.** ADB lets any allowed computer do everything Tellyscope can, so the TV's page warns, above its stats, when a computer other than this phone is connected, with **It's mine** for your own. **Who has access** in the **⋮** menu lists who is connected now and every computer the TV allows, with its key fingerprint and roughly when it was last seen. The TV doesn't say which key is behind which connection, so Tellyscope never pairs them up. **Remove all other access** clears the TV's allowed list, then reconnects so the TV asks to allow this phone again; on TVs that won't take the request, it opens Developer options and walks you through **Revoke USB debugging authorisations**. A computer that is already connected keeps its connection until it disconnects or the TV restarts, so if one is still there Tellyscope says so and offers **Check again** and **Restart the TV**, which waits for the TV to come back and checks once more. It says "Only this phone has access" only after checking the TV again.
- **Connected devices.** The Overview lists what's paired with or plugged into the TV: Bluetooth remotes and headphones, USB keyboards and drives with their free space, HDMI-CEC devices such as a soundbar, and where the sound goes now.
- **Connection requests.** When another device asks to debug the TV, Tellyscope shows the TV's "Allow debugging?" prompt on your phone, with the device's key fingerprint, so you can **Allow** or **Deny** it without the remote. **Always allow this device** appears when the TV's own prompt offers it.
- **Files.** Send a file from your phone into the TV's Download or Movies folder, or save one from there to your phone. Two buttons under the TV pick the folder, and stay pinned under the bar as you scroll. An empty folder says so in the middle of the page. A file with the same name gets a " (1)" instead of being overwritten, and a cancelled copy leaves nothing half-written behind.
diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.kt
index 9d3bf44..da528ba 100644
--- a/app/src/main/java/app/tellyscope/MainActivity.kt
+++ b/app/src/main/java/app/tellyscope/MainActivity.kt
@@ -369,4 +369,6 @@ private fun accessActions(vm: TellyscopeViewModel, back: () -> Unit) = AccessAct
revokedByHand = vm::revokedByHand,
askAgain = vm::askTvAgain,
retry = vm::retryRemoval,
+ checkAgain = vm::checkAgain,
+ restart = vm::restartToRemove,
)
diff --git a/app/src/main/java/app/tellyscope/ui/AccessUi.kt b/app/src/main/java/app/tellyscope/ui/AccessUi.kt
index 3cd8c72..e998639 100644
--- a/app/src/main/java/app/tellyscope/ui/AccessUi.kt
+++ b/app/src/main/java/app/tellyscope/ui/AccessUi.kt
@@ -94,6 +94,9 @@ data class AccessActions(
val revokedByHand: () -> Unit = {},
val askAgain: () -> Unit = {},
val retry: () -> Unit = {},
+ /** A connection left open: read the TV again, or restart it to end the connection. */
+ val checkAgain: () -> Unit = {},
+ val restart: () -> Unit = {},
)
internal object AccessIcons {
@@ -307,10 +310,22 @@ fun AccessScreen(state: UiState, actions: AccessActions, snackbar: SnackbarHostS
body, Verdict.Done, Copy.DONE_TITLE, Copy.DONE_TEXT,
trust = true,
) { Button(onClick = { actions.close(); actions.back() }) { Text(Copy.backTo(name(device))) } }
- Removal.Step.StillConnected -> Outcome(body, Verdict.Still, Copy.STILL_TITLE, Copy.stillText(removal.still ?: Copy.UNNAMED_COMPUTER, name(device))) {
- OutlinedButton(onClick = actions.close) { Text(Copy.WHO_HAS_ACCESS) }
- Button(onClick = actions.retry) { Text(Copy.TRY_AGAIN) }
+ Removal.Step.StillConnected -> if (removal.open) {
+ // Only a restart ends an open connection, so it leads; Who has access steps down to a link.
+ Outcome(
+ body, Verdict.Still, Copy.STILL_TITLE, Copy.stillOpenText(removal.still ?: Copy.UNNAMED_COMPUTER, name(device)),
+ link = { TextButton(onClick = actions.close) { Text(Copy.WHO_HAS_ACCESS) } },
+ ) {
+ OutlinedButton(onClick = actions.checkAgain) { Text(Copy.CHECK_AGAIN) }
+ Button(onClick = actions.restart) { Text(Copy.RESTART_TV) }
+ }
+ } else {
+ Outcome(body, Verdict.Still, Copy.STILL_TITLE, Copy.stillText(removal.still ?: Copy.UNNAMED_COMPUTER, name(device))) {
+ OutlinedButton(onClick = actions.close) { Text(Copy.WHO_HAS_ACCESS) }
+ Button(onClick = actions.retry) { Text(Copy.TRY_AGAIN) }
+ }
}
+ Removal.Step.Restarting -> Waiting(Copy.RESTARTING_TO_CHECK, body)
Removal.Step.Unconfirmed -> Outcome(body, Verdict.Unknown, Copy.UNCONFIRMED_TITLE, Copy.UNCONFIRMED_TEXT) {
Button(onClick = actions.close) { Text(Copy.DONE) }
}
@@ -559,7 +574,15 @@ private enum class Verdict { Done, Still, Unknown }
/** C6, C6b and C6c: a cookie badge, what Tellyscope found, and where to go next. */
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
-private fun Outcome(modifier: Modifier, kind: Verdict, title: String, text: String, trust: Boolean = false, buttons: @Composable () -> Unit) {
+private fun Outcome(
+ modifier: Modifier,
+ kind: Verdict,
+ title: String,
+ text: String,
+ trust: Boolean = false,
+ link: (@Composable () -> Unit)? = null,
+ buttons: @Composable () -> Unit,
+) {
val c = MaterialTheme.colorScheme
val (bg, fg) = when (kind) {
Verdict.Done -> c.primaryContainer to c.onPrimaryContainer
@@ -585,5 +608,6 @@ private fun Outcome(modifier: Modifier, kind: Verdict, title: String, text: Stri
}
}
Row(Modifier.padding(top = 24.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { buttons() }
+ if (link != null) Box(Modifier.padding(top = 8.dp)) { link() }
}
}
diff --git a/app/src/main/java/app/tellyscope/ui/Copy.kt b/app/src/main/java/app/tellyscope/ui/Copy.kt
index a6487c8..f69622d 100644
--- a/app/src/main/java/app/tellyscope/ui/Copy.kt
+++ b/app/src/main/java/app/tellyscope/ui/Copy.kt
@@ -484,6 +484,11 @@ object Copy {
const val STILL_TITLE = "Another computer is still connected"
fun stillText(who: String, tv: String) =
"Tellyscope still sees $who on $tv. It may have connected again straight away. Turn it off or unplug it from the network, then try again."
+ fun stillOpenText(who: String, tv: String) =
+ "Tellyscope still sees $who on $tv. Its access is gone, but the TV keeps a connection open until it ends. Restart the TV to end it."
+ const val CHECK_AGAIN = "Check again"
+ const val RESTART_TV = "Restart the TV"
+ const val RESTARTING_TO_CHECK = "Restarting the TV…"
fun connectionFrom(address: String) = "a connection from $address"
const val TRY_AGAIN = "Try again"
const val UNCONFIRMED_TITLE = "Revoked on the TV"
diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
index 3346359..b6f08d5 100644
--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
@@ -120,7 +120,7 @@ data class DeviceUi(
* by hand in Developer options when the call isn't available: [Step.Manual]); Tellyscope then
* reconnects and the TV asks to allow this phone ([Step.Allow]). [Step.Done] only after a re-read
* shows nobody else; [Step.StillConnected] names who is left, [Step.Unconfirmed] means the TV
- * wouldn't say.
+ * wouldn't say. From there, [Step.Restarting] restarts the TV to end the connection, then checks again.
*/
data class Removal(
val step: Step,
@@ -130,8 +130,10 @@ data class Removal(
val refused: Boolean = false,
/** Who is still there, for [Step.StillConnected]: "a connection from …", or a computer's name. */
val still: String? = null,
+ /** [still] is a connection left open, which only a restart ends; false when a computer was allowed again. */
+ val open: Boolean = false,
) {
- enum class Step { Confirm, Revoking, Manual, Allow, Checking, Done, StillConnected, Unconfirmed }
+ enum class Step { Confirm, Revoking, Manual, Allow, Checking, Done, StillConnected, Restarting, Unconfirmed }
}
data class SideloadUi(
@@ -256,11 +258,8 @@ const val ANSWERING = "request"
fun outcome(access: TvAccess?): Removal = when {
access?.connected == null || access.allowed == null -> Removal(Removal.Step.Unconfirmed)
access.onlyThisPhone -> Removal(Removal.Step.Done)
- else -> Removal(
- Removal.Step.StillConnected,
- still = access.others.firstOrNull()?.let { Copy.connectionFrom(it.address) }
- ?: access.allowed.firstOrNull { !it.phone }?.let { it.name ?: Copy.UNNAMED_COMPUTER },
- )
+ else -> access.others.firstOrNull()?.let { Removal(Removal.Step.StillConnected, still = Copy.connectionFrom(it.address), open = true) }
+ ?: Removal(Removal.Step.StillConnected, still = access.allowed.firstOrNull { !it.phone }?.let { it.name ?: Copy.UNNAMED_COMPUTER })
}
class TellyscopeViewModel(
@@ -1054,9 +1053,40 @@ class TellyscopeViewModel(
}
}
- /** "Try again" after another computer was still there: clear again, no need to ask twice. */
+ /** "Try again" after a computer was allowed again: clear again, no need to ask twice. */
fun retryRemoval() = removeAccess()
+ /** "Check again" after a connection was left open: reads the TV again, clears nothing. */
+ fun checkAgain() {
+ val id = _state.value.selectedId ?: return
+ removalJob?.cancel()
+ removalJob = viewModelScope.launch {
+ setRemoval(id, Removal(Removal.Step.Checking))
+ setRemoval(id, outcome(readAccess(id)))
+ }
+ }
+
+ /**
+ * "Restart the TV" after a connection was left open: a restart ends every connection.
+ * Waits for the TV to come back, as the Remote does, then checks again. A refused restart
+ * leaves the screen as it was, and the snackbar says why.
+ */
+ fun restartToRemove() {
+ val id = _state.value.selectedId ?: return
+ val before = _state.value.device.removal
+ removalJob?.cancel()
+ removalJob = viewModelScope.launch {
+ setRemoval(id, Removal(Removal.Step.Restarting))
+ if (!restart(id)) {
+ setRemoval(id, before)
+ return@launch
+ }
+ while (id in _state.value.restarting) delay(1_000)
+ setRemoval(id, Removal(Removal.Step.Checking))
+ setRemoval(id, outcome(readAccess(id)))
+ }
+ }
+
/** "Pick your TV": remember the choice for this TV and show its list. */
fun pickList(listId: String) {
val id = _state.value.selectedId ?: return
@@ -1283,19 +1313,23 @@ class TellyscopeViewModel(
fun reboot() {
val id = _state.value.selectedId ?: return
- viewModelScope.launch {
- val ok = try {
- source.reboot(id)
- } catch (e: CancellationException) {
- throw e
- } catch (_: Exception) {
- _notice.value = Copy.REMOTE_LOST
- return@launch
- }
- // A restart brings the picture back on by itself.
- if (ok) _state.update { it.copy(restarting = it.restarting + (id to Restart(clock())), screenOff = it.screenOff - id) }
- else _notice.value = Copy.REBOOT_REFUSED
+ viewModelScope.launch { restart(id) }
+ }
+
+ /** Asks the TV to restart and starts the wait for it; false, with the snackbar saying why, when it won't. */
+ private suspend fun restart(id: String): Boolean {
+ val ok = try {
+ source.reboot(id)
+ } catch (e: CancellationException) {
+ throw e
+ } catch (_: Exception) {
+ _notice.value = Copy.REMOTE_LOST
+ return false
}
+ // A restart brings the picture back on by itself.
+ if (ok) _state.update { it.copy(restarting = it.restarting + (id to Restart(clock())), screenOff = it.screenOff - id) }
+ else _notice.value = Copy.REBOOT_REFUSED
+ return ok
}
/** Retry once a restart runs late: the link tries the TV again, and the wait starts over for a minute. */
diff --git a/app/src/test/java/app/tellyscope/RemoveAccessTest.kt b/app/src/test/java/app/tellyscope/RemoveAccessTest.kt
index 6e8b795..dca510d 100644
--- a/app/src/test/java/app/tellyscope/RemoveAccessTest.kt
+++ b/app/src/test/java/app/tellyscope/RemoveAccessTest.kt
@@ -40,6 +40,7 @@ private class AccessTv : DeviceSource by FakeDeviceSource(FakeDeviceSource.Scena
var reconnects = 0
var devOptions = 0
var after = TvAccess()
+ var reboots = 0
override suspend fun known() = listOf(Device("tv", ScanHit("tv", 5555, ScanKind.Classic, "tv", null), state, null, null, null, 0L))
override fun live(deviceId: String) = emptyFlow<Snapshot>()
@@ -48,6 +49,7 @@ private class AccessTv : DeviceSource by FakeDeviceSource(FakeDeviceSource.Scena
override suspend fun revokeAll(deviceId: String): Boolean { revoked++; return revokes }
override suspend fun reconnect(deviceId: String) { reconnects++; readable = false }
override suspend fun openDeveloperOptions(deviceId: String): Boolean { devOptions++; return true }
+ override suspend fun reboot(deviceId: String): Boolean { reboots++; return true }
override fun phoneFingerprint() = "AA:BB"
}
@@ -148,11 +150,50 @@ class RemoveAccessTest {
tv.readable = true
advanceTimeBy(1_100)
assertEquals(Removal.Step.StillConnected, step)
+ assertTrue(vm.state.value.device.removal!!.open)
vm.closeRemoval()
runCurrent()
assertNull(step)
}
+ private val stillOpen get() = TvAccess(onlyPhone.connected!! + app.tellyscope.data.AccessClient("192.0.2.47", 2, app.tellyscope.data.AccessClient.Who.Other), emptyList())
+
+ @Test fun checkAgainReadsTheTvAndClearsNothing() = with(test) {
+ tv.after = stillOpen
+ start()
+ vm.askRemoveAccess()
+ vm.removeAccess()
+ runCurrent()
+ tv.readable = true
+ advanceTimeBy(1_100)
+ tv.after = onlyPhone
+ vm.checkAgain()
+ runCurrent()
+ assertEquals(Removal.Step.Done, step)
+ assertEquals(1, tv.revoked)
+ }
+
+ @Test fun restartingTheTvWaitsForItThenChecksAgain() = with(test) {
+ tv.after = stillOpen
+ start()
+ vm.askRemoveAccess()
+ vm.removeAccess()
+ runCurrent()
+ tv.readable = true
+ advanceTimeBy(1_100)
+ vm.restartToRemove()
+ runCurrent()
+ assertEquals(1, tv.reboots)
+ assertEquals(Removal.Step.Restarting, step)
+ tv.state = DeviceState.Offline
+ advanceTimeBy(3_100)
+ assertEquals(Removal.Step.Restarting, step)
+ tv.after = onlyPhone
+ tv.state = DeviceState.Online
+ advanceTimeBy(5_000)
+ assertEquals(Removal.Step.Done, step)
+ }
+
@Test fun stopWaitingLeavesTheFlow() = with(test) {
start()
vm.askRemoveAccess()
diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
index ec966a5..0a443d6 100644
--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt
+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
@@ -1496,7 +1496,7 @@ class ScreenshotTest {
@Test fun access_allow_dark() = accessScreen("97_remove_allow", true, allow)
@Test fun access_done() = accessScreen("98_remove_done", false, Removal(Removal.Step.Done))
@Test fun access_done_dark() = accessScreen("98_remove_done", true, Removal(Removal.Step.Done))
- private val still = Removal(Removal.Step.StillConnected, still = Copy.connectionFrom("192.0.2.47"))
+ private val still = Removal(Removal.Step.StillConnected, still = Copy.connectionFrom("192.0.2.47"), open = true)
@Test fun access_still() = accessScreen("99_remove_still", false, still)
@Test fun access_still_dark() = accessScreen("99_remove_still", true, still)
@Test fun access_unconfirmed() = accessScreen("99_remove_unconfirmed", false, Removal(Removal.Step.Unconfirmed))