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.

Hide "Always allow" on the card when the TV's prompt has none

jesse-agent-232861ad6fde452
diff --git a/adb/src/main/kotlin/app/tellyscope/adb/ConnectionPrompt.kt b/adb/src/main/kotlin/app/tellyscope/adb/ConnectionPrompt.kt
index 1182721..ff085ca 100644
--- a/adb/src/main/kotlin/app/tellyscope/adb/ConnectionPrompt.kt
+++ b/adb/src/main/kotlin/app/tellyscope/adb/ConnectionPrompt.kt
@@ -2,7 +2,11 @@
package app.tellyscope.adb
/** Another device's "Allow debugging?" prompt on the TV, with the key fingerprint it shows. */
-data class ConnectionRequest(val fingerprint: String)
+data class ConnectionRequest(
+ val fingerprint: String,
+ /** The prompt has an "Always allow" tick-box; some builds leave it out. */
+ val canAlwaysAllow: Boolean = true,
+)
/**
* Answers the TV's own "Allow debugging?" prompt for another device, from the phone. Tellyscope
@@ -14,7 +18,7 @@ class ConnectionPrompt(private val shell: AdbShell) {
/** The prompt on screen now, or null. Cheap enough to poll: one `dumpsys window` line. */
suspend fun pending(): ConnectionRequest? {
if (showing() == null) return null
- return screen()?.let { ConnectionRequest(it.fingerprint) }
+ return screen()?.let { ConnectionRequest(it.fingerprint, canAlwaysAllow = it.always != null) }
}
/**
diff --git a/adb/src/test/kotlin/app/tellyscope/adb/ConnectionPromptTest.kt b/adb/src/test/kotlin/app/tellyscope/adb/ConnectionPromptTest.kt
index d464c94..5596428 100644
--- a/adb/src/test/kotlin/app/tellyscope/adb/ConnectionPromptTest.kt
+++ b/adb/src/test/kotlin/app/tellyscope/adb/ConnectionPromptTest.kt
@@ -28,6 +28,11 @@ class ConnectionPromptTest {
assertEquals(ConnectionRequest(fp), ConnectionPrompt(tv(dump())).pending())
}
+ @Test fun aPromptWithoutTheTickBoxSaysSo() = runTest {
+ val noBox = dump().lines().filterNot { "alwaysUse" in it }.joinToString("\n")
+ assertEquals(ConnectionRequest(fp, canAlwaysAllow = false), ConnectionPrompt(tv(noBox)).pending())
+ }
+
@Test fun noPromptNoDump() = runTest {
val sh = tv(dump(), focus = "mCurrentFocus=Window{1 u0 com.spocky.projengmenu/.ui.MainActivity}")
assertNull(ConnectionPrompt(sh).pending())
diff --git a/app/src/main/java/app/tellyscope/ui/RequestCard.kt b/app/src/main/java/app/tellyscope/ui/RequestCard.kt
index db37ca5..b939410 100644
--- a/app/src/main/java/app/tellyscope/ui/RequestCard.kt
+++ b/app/src/main/java/app/tellyscope/ui/RequestCard.kt
@@ -40,7 +40,8 @@ fun RequestCard(request: ConnectionRequest, busy: Boolean, answer: (allow: Boole
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)
- Row(
+ // 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,
) {
@@ -49,7 +50,7 @@ fun RequestCard(request: ConnectionRequest, busy: Boolean, answer: (allow: Boole
}
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
FilledTonalButton(onClick = { answer(false, false) }, enabled = !busy) { Text(Copy.REQUEST_DENY) }
- OutlinedButton(onClick = { answer(true, always) }, enabled = !busy) { Text(Copy.REQUEST_ALLOW) }
+ OutlinedButton(onClick = { answer(true, always && request.canAlwaysAllow) }, enabled = !busy) { Text(Copy.REQUEST_ALLOW) }
}
}
}