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.

Show the connection request as a dialog, like the TV's own prompt

jesse-agent-23262ee30303de9
diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.kt
index ed08b3d..4518ab2 100644
--- a/app/src/main/java/app/tellyscope/MainActivity.kt
+++ b/app/src/main/java/app/tellyscope/MainActivity.kt
@@ -209,6 +209,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {
clearCaches = vm::clearCaches,
screenshot = { saveScreenshot.launch(Copy.screenshotName(System.currentTimeMillis())) },
answerRequest = vm::answerRequest,
+ dismissRequest = vm::dismissRequest,
),
)
}
diff --git a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
index 913a142..a824fe8 100644
--- a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
+++ b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
@@ -130,6 +130,8 @@ data class DeviceActions(
val screenshot: () -> Unit = {},
/** Allow or Deny on another device's debugging prompt, and whether to always allow it. */
val answerRequest: (allow: Boolean, always: Boolean) -> Unit = { _, _ -> },
+ /** Hides that prompt on the phone without answering it; the TV keeps asking. */
+ val dismissRequest: () -> Unit = {},
)
/** Off while the remote is made faster: the device page hides its Remote button. */
@@ -195,7 +197,6 @@ fun DeviceScreen(
// A reading from before the TV went away is stale: it doesn't speak for the TV now.
val live = snap?.takeIf { !offline }
item { TvCard(state, live, actions) }
- if (!offline) ui.request?.let { r -> item { RequestCard(r, ui.busy == ANSWERING, actions.answerRequest) } }
val restart = state.restarting[device.id]
if (restart != null) {
item { RestartingCard(restart, state.now) }
@@ -266,6 +267,7 @@ fun DeviceScreen(
HistoryList(ui.history, state.now, actions.undo, restoring = ui.busy == RESTORING, onRestoreAll = actions.restoreAll)
}
}
+ if (!offline) ui.request?.let { RequestDialog(it, ui.busy == ANSWERING, actions.answerRequest, actions.dismissRequest) }
ui.sideload?.let { SideloadDialog(it, actions) }
ui.transfer?.let { TransferDialog(it, actions.cancelTransfer) }
}
diff --git a/app/src/main/java/app/tellyscope/ui/RequestCard.kt b/app/src/main/java/app/tellyscope/ui/RequestCard.kt
deleted file mode 100644
index b939410..0000000
--- a/app/src/main/java/app/tellyscope/ui/RequestCard.kt
+++ /dev/null
@@ -1,57 +0,0 @@
-// SPDX-License-Identifier: GPL-3.0-only
-
-package app.tellyscope.ui
-
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.selection.toggleable
-import androidx.compose.material3.Card
-import androidx.compose.material3.CardDefaults
-import androidx.compose.material3.Checkbox
-import androidx.compose.material3.FilledTonalButton
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.material3.OutlinedButton
-import androidx.compose.material3.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.saveable.rememberSaveable
-import androidx.compose.runtime.setValue
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.semantics.Role
-import androidx.compose.ui.text.font.FontFamily
-import androidx.compose.ui.unit.dp
-import app.tellyscope.adb.ConnectionRequest
-
-/**
- * The TV's "Allow debugging?" prompt, answered from the phone. The fingerprint is always shown,
- * "Always allow" starts unticked for every new request, and Deny comes first.
- */
-@Composable
-fun RequestCard(request: ConnectionRequest, busy: Boolean, answer: (allow: Boolean, always: Boolean) -> Unit) {
- var always by rememberSaveable(request.fingerprint) { mutableStateOf(false) }
- Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.tertiaryContainer)) {
- Column(Modifier.fillMaxWidth().padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
- Text(Copy.REQUEST_TITLE, style = MaterialTheme.typography.titleMedium)
- Text(Copy.REQUEST_TEXT, style = MaterialTheme.typography.bodyMedium)
- // Eight pairs a line, so a pair is never split when comparing it with the other device.
- Text(request.fingerprint.split(':').chunked(8).joinToString("\n") { it.joinToString(":") }, style = MaterialTheme.typography.bodyMedium, fontFamily = FontFamily.Monospace)
- // No tick-box on the TV's prompt, none here: a tick that can't be applied would mislead.
- if (request.canAlwaysAllow) Row(
- Modifier.fillMaxWidth().toggleable(always, enabled = !busy, role = Role.Checkbox) { always = it },
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Checkbox(checked = always, onCheckedChange = null, enabled = !busy)
- Text(Copy.REQUEST_ALWAYS, Modifier.padding(start = 8.dp), style = MaterialTheme.typography.bodyMedium)
- }
- Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
- FilledTonalButton(onClick = { answer(false, false) }, enabled = !busy) { Text(Copy.REQUEST_DENY) }
- OutlinedButton(onClick = { answer(true, always && request.canAlwaysAllow) }, enabled = !busy) { Text(Copy.REQUEST_ALLOW) }
- }
- }
- }
-}
diff --git a/app/src/main/java/app/tellyscope/ui/RequestDialog.kt b/app/src/main/java/app/tellyscope/ui/RequestDialog.kt
new file mode 100644
index 0000000..90aad72
--- /dev/null
+++ b/app/src/main/java/app/tellyscope/ui/RequestDialog.kt
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-3.0-only
+
+package app.tellyscope.ui
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.selection.toggleable
+import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.Checkbox
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.unit.dp
+import app.tellyscope.adb.ConnectionRequest
+
+/**
+ * The TV's "Allow debugging?" prompt, answered from the phone, as a dialog like the TV's own. The
+ * fingerprint is always shown, "Always allow" starts unticked for every new request, and Deny is
+ * the safe choice. Dismissing answers nothing: the TV keeps asking, and this request stays hidden.
+ */
+@Composable
+fun RequestDialog(
+ request: ConnectionRequest,
+ busy: Boolean,
+ answer: (allow: Boolean, always: Boolean) -> Unit,
+ dismiss: () -> Unit,
+) {
+ var always by rememberSaveable(request.fingerprint) { mutableStateOf(false) }
+ AlertDialog(
+ onDismissRequest = { if (!busy) dismiss() },
+ title = { Text(Copy.REQUEST_TITLE) },
+ text = {
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ Text(Copy.REQUEST_TEXT)
+ // Eight pairs a line, so a pair is never split when comparing it with the other device.
+ Text(
+ request.fingerprint.split(':').chunked(8).joinToString("\n") { it.joinToString(":") },
+ style = MaterialTheme.typography.bodyLarge,
+ fontFamily = FontFamily.Monospace,
+ )
+ // No tick-box on the TV's prompt, none here: a tick that can't be applied would mislead.
+ if (request.canAlwaysAllow) Row(
+ Modifier.fillMaxWidth().toggleable(always, enabled = !busy, role = Role.Checkbox) { always = it },
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Checkbox(checked = always, onCheckedChange = null, enabled = !busy)
+ Text(Copy.REQUEST_ALWAYS, Modifier.padding(start = 8.dp))
+ }
+ }
+ },
+ confirmButton = {
+ TextButton(onClick = { answer(true, always && request.canAlwaysAllow) }, enabled = !busy) { Text(Copy.REQUEST_ALLOW) }
+ },
+ dismissButton = { TextButton(onClick = { answer(false, false) }, enabled = !busy) { Text(Copy.REQUEST_DENY) } },
+ )
+}
diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
index d443f60..fa17897 100644
--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
@@ -175,6 +175,8 @@ class TellyscopeViewModel(
private var mediumJob: Job? = null
private var listsJob: Job? = null
private var requestJob: Job? = null
+ /** The fingerprint the user waved away on the phone; its prompt stays hidden while the TV shows it. */
+ private var dismissedRequest: String? = null
init {
viewModelScope.launch {
@@ -685,7 +687,7 @@ class TellyscopeViewModel(
private suspend fun watchRequests(id: String) {
while (true) {
val request = try {
- source.connectionRequest(id)
+ source.connectionRequest(id)?.takeIf { it.fingerprint != dismissedRequest }
} catch (e: CancellationException) {
throw e
} catch (_: Exception) {
@@ -696,6 +698,12 @@ class TellyscopeViewModel(
}
}
+ fun dismissRequest() {
+ val id = _state.value.selectedId ?: return
+ dismissedRequest = _state.value.device.request?.fingerprint
+ updateDevice(id) { it.copy(request = null) }
+ }
+
/** The user's answer to [DeviceUi.request]; nothing is ever answered without it. */
fun answerRequest(allow: Boolean, always: Boolean) {
val id = _state.value.selectedId ?: return
diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
index 0ce27d0..89acf15 100644
--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt
+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
@@ -426,7 +426,7 @@ class ScreenshotTest {
}) { DeviceScreen(deviceState { copy(history = history) }, DeviceActions()) }
}
- @Test fun device_connectionRequest() = shot("17_device_request") {
+ @Test fun device_connectionRequest() = shot("17_device_request", screen = true) {
val request = ConnectionRequest("AB:CD:EF:01:23:45:67:89:AB:CD:EF:01:23:45:67:89")
DeviceScreen(deviceState { copy(request = request) }, DeviceActions())
}