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.

Fire TV: show a debugging prompt hidden behind the remote alert

jesse-agent-23234787e5fcf68
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 53fc11c..0da9944 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ until this file has a section for its version.
- **Fixed:** On Fire TV, Make Home sets Projectivy as Home through its accessibility service. [#235](../../pull/235)
- **Fixed:** The Projectivy install dialog on Fire TV closes when the install finishes. [#235](../../pull/235)
- **New:** On Android TV, Projectivy can also be downloaded directly, after a warning. [#236](../../pull/236)
+- **Fixed:** On Fire TV, a debugging prompt hidden behind the remote alert shows on the phone. [#237](../../pull/237)
## 0.13.0 — 2026-10-29
diff --git a/adb/src/main/kotlin/app/tellyscope/adb/ConnectionPrompt.kt b/adb/src/main/kotlin/app/tellyscope/adb/ConnectionPrompt.kt
index ff085ca..08e1020 100644
--- a/adb/src/main/kotlin/app/tellyscope/adb/ConnectionPrompt.kt
+++ b/adb/src/main/kotlin/app/tellyscope/adb/ConnectionPrompt.kt
@@ -6,6 +6,11 @@ data class ConnectionRequest(
val fingerprint: String,
/** The prompt has an "Always allow" tick-box; some builds leave it out. */
val canAlwaysAllow: Boolean = true,
+ /**
+ * Fire OS's "Unable to Detect Your Remote" alert holds focus over the prompt, so it can't be read:
+ * [fingerprint] is empty, and nothing can be answered until the alert closes.
+ */
+ val behindAlert: Boolean = false,
)
/**
@@ -15,10 +20,30 @@ data class ConnectionRequest(
*/
class ConnectionPrompt(private val shell: AdbShell) {
- /** The prompt on screen now, or null. Cheap enough to poll: one `dumpsys window` line. */
+ /**
+ * The prompt on screen now, or null. Cheap enough to poll: one `dumpsys window` read, and a
+ * screen dump only while a prompt is up, focused or under Amazon's alert ([ConnectionRequest.behindAlert]).
+ */
suspend fun pending(): ConnectionRequest? {
- if (showing() == null) return null
- return screen()?.let { ConnectionRequest(it.fingerprint, canAlwaysAllow = it.always != null) }
+ val windows = windows()
+ if (focused(windows) != null) return screen()?.let { ConnectionRequest(it.fingerprint, canAlwaysAllow = it.always != null) }
+ return if (alertOnTop(windows)) ConnectionRequest("", canAlwaysAllow = false, behindAlert = true) else null
+ }
+
+ /**
+ * Presses OK once on Amazon's alert, for the user who can't, as the remote it complains about
+ * isn't connected. Only while the alert still holds focus over the prompt, checked just before:
+ * once the prompt has focus, no key is ever sent, so this can't answer it. False when nothing was sent.
+ */
+ suspend fun closeAlert(): Boolean {
+ if (!alertOnTop()) return false
+ return shell.shell("input keyevent $KEY_OK").exitCode == 0
+ }
+
+ /** A system prompt is up but a bare `android` window holds focus, and that window is Amazon's alert. */
+ private suspend fun alertOnTop(windows: String = windows()): Boolean {
+ if (focused(windows) != null || !waiting(windows) || !ALERT_FOCUS.containsMatchIn(windows)) return false
+ return isAlert(dump())
}
/**
@@ -34,10 +59,14 @@ class ConnectionPrompt(private val shell: AdbShell) {
}
/** The focused window's package when it's the system's debugging prompt. */
- private suspend fun showing(): String? =
- focused(shell.shell("dumpsys window | grep -E 'mCurrentFocus|mFocusedWindow'").output)
+ private suspend fun showing(): String? = focused(windows())
+
+ /** The focus lines, and any debugging prompt in the window list, focused or not. */
+ private suspend fun windows() = shell.shell("dumpsys window | grep -E 'mCurrentFocus|mFocusedWindow|UsbDebugging'").output
+
+ private suspend fun screen(): Prompt? = parse(dump())
- private suspend fun screen(): Prompt? = parse(shell.shell("uiautomator dump $DUMP >/dev/null 2>&1; cat $DUMP; rm -f $DUMP").output)
+ private suspend fun dump() = shell.shell("uiautomator dump $DUMP >/dev/null 2>&1; cat $DUMP; rm -f $DUMP").output
private suspend fun tap(b: Bounds) = shell.shell("input tap ${(b.left + b.right) / 2} ${(b.top + b.bottom) / 2}").exitCode == 0
@@ -47,6 +76,8 @@ class ConnectionPrompt(private val shell: AdbShell) {
companion object {
private const val DUMP = "/data/local/tmp/tellyscope-ui.xml"
+ /** DPAD_CENTER: the remote's OK. */
+ private const val KEY_OK = 23
private val NODE = Regex("<node [^>]*>")
private val ATTR = Regex("([\\w-]+)=\"([^\"]*)\"")
private val BOUNDS = Regex("\\[(\\d+),(\\d+)]\\[(\\d+),(\\d+)]")
@@ -64,8 +95,22 @@ class ConnectionPrompt(private val shell: AdbShell) {
private val SYSTEM = setOf("com.android.systemui", "android", "com.android.tv.settings")
private val WINDOW = Regex("\\s([\\w.]+)/[\\w.$]*UsbDebugging[\\w.$]*")
+ private val FOCUS = Regex("mCurrentFocus|mFocusedWindow")
+ /** Fire OS's alert is a window of the system itself, `android`, with no activity. */
+ private val ALERT_FOCUS = Regex("mCurrentFocus=Window\\{\\S+ u\\d+ android}")
+ /** Its OK button, the one id that says it's the remote alert and not some other system window. */
+ private const val ALERT_OK = "amazon.fireos:id/ok_button"
+
/** The package of a focused `…/…UsbDebugging…` window in `dumpsys window`, if a system one. */
- fun focused(dumpsys: String): String? = WINDOW.find(dumpsys)?.groupValues?.get(1)?.takeIf { it in SYSTEM }
+ fun focused(dumpsys: String): String? =
+ dumpsys.lines().filter { FOCUS.containsMatchIn(it) }.firstNotNullOfOrNull { WINDOW.find(it)?.groupValues?.get(1)?.takeIf { p -> p in SYSTEM } }
+
+ /** A system debugging prompt in the window list, focused or not. */
+ fun waiting(dumpsys: String): Boolean = WINDOW.findAll(dumpsys).any { it.groupValues[1] in SYSTEM }
+
+ /** Amazon's "Unable to Detect Your Remote" alert in a `uiautomator dump`, drawn by the system. */
+ fun isAlert(xml: String): Boolean =
+ NODE.findAll(xml).any { n -> ATTR.findAll(n.value).associate { it.groupValues[1] to it.groupValues[2] }.let { it["resource-id"] == ALERT_OK && it["package"] == "android" } }
fun parse(xml: String): Prompt? {
val nodes = NODE.findAll(xml).map { n -> ATTR.findAll(n.value).associate { it.groupValues[1] to it.groupValues[2] } }
diff --git a/adb/src/test/kotlin/app/tellyscope/adb/ConnectionPromptTest.kt b/adb/src/test/kotlin/app/tellyscope/adb/ConnectionPromptTest.kt
index 5596428..7a72153 100644
--- a/adb/src/test/kotlin/app/tellyscope/adb/ConnectionPromptTest.kt
+++ b/adb/src/test/kotlin/app/tellyscope/adb/ConnectionPromptTest.kt
@@ -68,4 +68,45 @@ class ConnectionPromptTest {
assertFalse(ConnectionPrompt(sh).answer(ConnectionRequest(fp), allow = true, always = false))
assertFalse(sh.ran.any { it.startsWith("input") })
}
+
+ // Fire OS 8 on a Fire TV Stick 4K Max: its "Unable to Detect Your Remote" alert, a bare `android` window,
+ // holds focus while the debugging prompt waits under it.
+ private val alertFocus = "mCurrentFocus=Window{2 u0 android}\n" +
+ " Window #9 Window{1 u0 com.android.systemui/com.android.systemui.usb.UsbDebuggingActivity}:"
+ private val alert = """
+ <?xml version='1.0' encoding='UTF-8' standalone='yes' ?><hierarchy rotation="0">
+ <node index="0" text="" resource-id="amazon.fireos:id/auto_pair_troubleshoot_layout" package="android" bounds="[0,0][1920,1080]" />
+ <node index="1" text="Unable to Detect Your Remote" resource-id="amazon.fireos:id/troubleshoot_title" package="android" bounds="[600,300][1320,360]" />
+ <node index="2" text="OK" resource-id="amazon.fireos:id/ok_button" package="android" focused="true" bounds="[860,800][1060,860]" />
+ </hierarchy>
+ """.trimIndent()
+
+ @Test fun aPromptUnderAmazonsAlertSaysSoWithoutAFingerprint() = runTest {
+ assertEquals(ConnectionRequest("", canAlwaysAllow = false, behindAlert = true), ConnectionPrompt(tv(alert, alertFocus)).pending())
+ }
+
+ @Test fun okIsPressedOnceAndOnlyOnTheAlert() = runTest {
+ val sh = tv(alert, alertFocus)
+ assertTrue(ConnectionPrompt(sh).closeAlert())
+ assertEquals(listOf("input keyevent 23"), sh.ran.filter { it.startsWith("input") })
+ }
+
+ @Test fun noKeyOnceThePromptHasFocus() = runTest {
+ val sh = tv(dump())
+ assertFalse(ConnectionPrompt(sh).closeAlert())
+ assertFalse(sh.ran.any { it.startsWith("input") })
+ }
+
+ @Test fun anotherSystemWindowIsNotTheAlert() = runTest {
+ val sh = tv(alert.replace("amazon.fireos:id/ok_button", "android:id/button1"), alertFocus)
+ assertNull(ConnectionPrompt(sh).pending())
+ assertFalse(ConnectionPrompt(sh).closeAlert())
+ assertFalse(sh.ran.any { it.startsWith("input") })
+ }
+
+ @Test fun theAlertAloneIsNoPrompt() = runTest {
+ val sh = tv(alert, "mCurrentFocus=Window{2 u0 android}")
+ assertNull(ConnectionPrompt(sh).pending())
+ assertFalse(sh.ran.any { it.startsWith("uiautomator") })
+ }
}
diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.kt
index 47c1790..2bb541f 100644
--- a/app/src/main/java/app/tellyscope/MainActivity.kt
+++ b/app/src/main/java/app/tellyscope/MainActivity.kt
@@ -418,6 +418,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {
screenshot = { saveScreenshot.launch(Copy.screenshotName(System.currentTimeMillis())) },
answerRequest = vm::answerRequest,
dismissRequest = vm::dismissRequest,
+ closeAlert = vm::closeAlert,
foldSystem = vm::foldSystem,
showStats = vm::showStats,
whoHasAccess = { access = true },
diff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
index e0d1055..31ee5e1 100644
--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
@@ -958,6 +958,8 @@ class AdbDeviceSource(context: Context) : DeviceSource {
override suspend fun answerRequest(deviceId: String, request: ConnectionRequest, allow: Boolean, always: Boolean) =
ConnectionPrompt(session(deviceId)).answer(request, allow, always)
+ override suspend fun closeAlert(deviceId: String) = ConnectionPrompt(session(deviceId)).closeAlert()
+
override suspend fun facts(deviceId: String) = TvFacts.read(session(deviceId))
override suspend fun access(deviceId: String): TvAccess {
diff --git a/app/src/main/java/app/tellyscope/data/DeviceSource.kt b/app/src/main/java/app/tellyscope/data/DeviceSource.kt
index c19c215..027836a 100644
--- a/app/src/main/java/app/tellyscope/data/DeviceSource.kt
+++ b/app/src/main/java/app/tellyscope/data/DeviceSource.kt
@@ -214,6 +214,9 @@ interface DeviceSource {
*/
suspend fun answerRequest(deviceId: String, request: ConnectionRequest, allow: Boolean, always: Boolean): Boolean
+ /** Presses OK once on Fire OS's remote alert over that prompt ([ConnectionRequest.behindAlert]). False when nothing was sent. */
+ suspend fun closeAlert(deviceId: String): Boolean
+
/** What a report says about the TV: model, Android, the apps it came with. Throws if it's gone. */
suspend fun facts(deviceId: String): TvFacts
diff --git a/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt b/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt
index 117316d..8a00bc6 100644
--- a/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt
+++ b/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt
@@ -401,6 +401,8 @@ class FakeDeviceSource(
override suspend fun answerRequest(deviceId: String, request: ConnectionRequest, allow: Boolean, always: Boolean) = false
+ override suspend fun closeAlert(deviceId: String) = false
+
/** Addresses marked "It's mine", and TVs whose access was cleared, so the demo flow ends on Done. */
private val mine = mutableSetOf<String>()
private val revoked = mutableSetOf<String>()
diff --git a/app/src/main/java/app/tellyscope/ui/Copy.kt b/app/src/main/java/app/tellyscope/ui/Copy.kt
index eb0c07b..495dcb4 100644
--- a/app/src/main/java/app/tellyscope/ui/Copy.kt
+++ b/app/src/main/java/app/tellyscope/ui/Copy.kt
@@ -618,6 +618,11 @@ object Copy {
const val REQUEST_ALLOWED = "Allowed. That device can control the TV now."
const val REQUEST_DENIED = "Denied. That device can't connect."
const val REQUEST_GONE = "The TV's prompt had closed or changed, so nothing was pressed."
+ /** A prompt under Fire OS's remote alert: it can't be read until the alert closes. */
+ const val REQUEST_BEHIND_ALERT = "The TV's prompt is behind an Amazon alert, “Unable to Detect Your Remote”. Press OK on your TV remote to close it."
+ const val REQUEST_THEN = "Then the prompt shows here, so you can check its fingerprint."
+ const val REQUEST_WAITING = "Waiting for the TV's prompt"
+ const val PRESS_OK = "Press OK on the TV"
// Who has access
const val WARNING_TITLE = "Another computer is connected to this TV"
diff --git a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
index 262bb50..6db0f76 100644
--- a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
+++ b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
@@ -125,6 +125,8 @@ data class DeviceActions(
val answerRequest: (allow: Boolean, always: Boolean) -> Unit = { _, _ -> },
/** Hides that prompt on the phone without answering it; the TV keeps asking. */
val dismissRequest: () -> Unit = {},
+ /** Press OK on the TV, on Fire OS's remote alert over that prompt. */
+ val closeAlert: () -> Unit = {},
/** Folds an Apps tab's System section away, or opens it; remembered across restarts. */
val foldSystem: (AppsTab, Boolean) -> Unit = { _, _ -> },
/** The open tab's refresh rates; the TV's stats reads follow them. */
diff --git a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt b/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
index e41ae26..d13615e 100644
--- a/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
+++ b/app/src/main/java/app/tellyscope/ui/DeviceTabs.kt
@@ -412,7 +412,7 @@ fun DeviceTabsScreen(
}
item(key = "tail") { Spacer(Modifier.height(with(LocalDensity.current) { tail.toDp() }).testTag("tail")) }
}
- if (!offline) ui.request?.let { RequestDialog(it, ui.busy == ANSWERING, actions.answerRequest, actions.dismissRequest) }
+ if (!offline) ui.request?.let { RequestDialog(it, ui.busy == ANSWERING, actions.answerRequest, actions.dismissRequest, actions.closeAlert) }
ui.sideload?.let { SideloadDialog(it, actions) }
ui.transfer?.let { TransferDialog(it, actions.cancelTransfer) }
}
diff --git a/app/src/main/java/app/tellyscope/ui/RequestDialog.kt b/app/src/main/java/app/tellyscope/ui/RequestDialog.kt
index 493ab4c..cac078a 100644
--- a/app/src/main/java/app/tellyscope/ui/RequestDialog.kt
+++ b/app/src/main/java/app/tellyscope/ui/RequestDialog.kt
@@ -5,13 +5,19 @@ 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.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.selection.toggleable
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Checkbox
+import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
+import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
+import androidx.compose.material3.LoadingIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
@@ -31,6 +37,7 @@ 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.
+ * Under Fire OS's remote alert ([ConnectionRequest.behindAlert]) it waits instead, with no way to answer.
*/
@Composable
fun RequestDialog(
@@ -38,7 +45,9 @@ fun RequestDialog(
busy: Boolean,
answer: (allow: Boolean, always: Boolean) -> Unit,
dismiss: () -> Unit,
+ closeAlert: () -> Unit = {},
) {
+ if (request.behindAlert) return BehindAlertDialog(busy, closeAlert, dismiss)
var always by rememberSaveable(request.fingerprint) { mutableStateOf(false) }
AlertDialog(
onDismissRequest = { if (!busy) dismiss() },
@@ -69,3 +78,31 @@ fun RequestDialog(
dismissButton = { TextButton(onClick = { answer(false, false) }, enabled = !busy) { Text(Copy.REQUEST_DENY) } },
)
}
+
+/**
+ * The same dialog while the prompt is under Fire OS's alert: no fingerprint, so no Allow and no Deny.
+ * Press OK on the TV sends one OK to the alert, for when the remote it complains about isn't there.
+ * Close answers nothing.
+ */
+@OptIn(ExperimentalMaterial3ExpressiveApi::class)
+@Composable
+private fun BehindAlertDialog(busy: Boolean, closeAlert: () -> Unit, dismiss: () -> Unit) {
+ AlertDialog(
+ onDismissRequest = { if (!busy) dismiss() },
+ icon = { Icon(AccessIcons.Shield, contentDescription = null) },
+ title = { Text(Copy.REQUEST_TITLE) },
+ text = {
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ Text(Copy.REQUEST_BEHIND_ALERT)
+ Text(Copy.REQUEST_THEN)
+ Row(Modifier.padding(top = 8.dp), verticalAlignment = Alignment.CenterVertically) {
+ LoadingIndicator(Modifier.size(24.dp))
+ Spacer(Modifier.width(12.dp))
+ Text(Copy.REQUEST_WAITING, style = MaterialTheme.typography.bodyMedium)
+ }
+ }
+ },
+ confirmButton = { FilledTonalButton(onClick = closeAlert, enabled = !busy) { Text(Copy.PRESS_OK) } },
+ dismissButton = { TextButton(onClick = dismiss, enabled = !busy) { Text("Close") } },
+ )
+}
diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
index 8df3ea8..486d491 100644
--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
@@ -350,6 +350,9 @@ const val SCREENSHOT = "screenshot"
/** [DeviceUi.busy] value while the TV's connection prompt is being answered. */
const val ANSWERING = "request"
+/** How long Fire OS takes to hand focus from its closed alert to the prompt under it. */
+private const val ALERT_CLOSING_MS = 1_000L
+
/** How often Install a home screen asks the TV whether the launcher is in yet. */
const val STORE_POLL_MS = 3_000L
@@ -1423,15 +1426,44 @@ class TellyscopeViewModel(
*/
private suspend fun watchRequests(id: String) {
while (true) {
- val request = try {
- source.connectionRequest(id)?.takeIf { it.fingerprint != dismissedRequest }
+ readRequest(id)
+ delay(5_000)
+ }
+ }
+
+ private suspend fun readRequest(id: String) {
+ val request = try {
+ source.connectionRequest(id).also {
+ // A prompt under Amazon's alert has no fingerprint to hide it by: Close hides it until the alert is gone.
+ if (it == null && dismissedRequest == "") dismissedRequest = null
+ }?.takeIf { it.fingerprint != dismissedRequest }
+ } catch (e: CancellationException) {
+ throw e
+ } catch (_: Exception) {
+ null
+ }
+ updateDevice(id) { if (it.busy == ANSWERING) it else it.copy(request = request) }
+ }
+
+ /**
+ * Press OK on the TV, on a prompt under Fire OS's remote alert: one OK, sent only while the alert has focus.
+ * Then a fresh read, so the prompt itself, with its fingerprint, takes over without waiting for the next check.
+ */
+ fun closeAlert() {
+ val id = _state.value.selectedId ?: return
+ if (_state.value.device.request?.behindAlert != true) return
+ updateDevice(id) { it.copy(busy = ANSWERING) }
+ viewModelScope.launch {
+ try {
+ source.closeAlert(id)
} catch (e: CancellationException) {
throw e
} catch (_: Exception) {
- null
+ false
}
- updateDevice(id) { if (it.busy == ANSWERING) it else it.copy(request = request) }
- delay(5_000)
+ delay(ALERT_CLOSING_MS)
+ updateDevice(id) { it.copy(busy = null) }
+ readRequest(id)
}
}
diff --git a/app/src/test/java/app/tellyscope/StateAfterActionTest.kt b/app/src/test/java/app/tellyscope/StateAfterActionTest.kt
index 5d2a35b..8df866f 100644
--- a/app/src/test/java/app/tellyscope/StateAfterActionTest.kt
+++ b/app/src/test/java/app/tellyscope/StateAfterActionTest.kt
@@ -24,6 +24,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
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
@@ -64,8 +65,19 @@ private class HalfwayTv : DeviceSource by FakeDeviceSource(FakeDeviceSource.Scen
}
override suspend fun access(deviceId: String) = TvAccess(allowed = keys)
+
+ var alertOks = 0
+
+ /** Fire OS's alert closes, and the prompt under it shows. */
+ override suspend fun closeAlert(deviceId: String): Boolean {
+ alertOks++
+ request = ConnectionRequest("AA:BB")
+ return true
+ }
}
+private val behindAlert = ConnectionRequest("", canAlwaysAllow = false, behindAlert = true)
+
@OptIn(ExperimentalCoroutinesApi::class)
class StateAfterActionTest {
private val dispatcher = StandardTestDispatcher()
@@ -102,4 +114,35 @@ class StateAfterActionTest {
// Well before the next 10 s read of who has access.
assertEquals(listOf("AA:BB"), vm.state.value.device.access?.allowed?.map { it.fingerprint })
}
+
+ @Test fun pressOkOnTheTvThenThePromptItselfTakesOver() = with(test) {
+ source.request = behindAlert
+ vm = TellyscopeViewModel(source, clock = { 0L })
+ runCurrent()
+ assertEquals(true, vm.state.value.device.request?.behindAlert)
+ vm.closeAlert()
+ advanceTimeBy(1_001)
+ runCurrent()
+ assertEquals(1, source.alertOks)
+ // Before the next 5 s check.
+ assertEquals("AA:BB", vm.state.value.device.request?.fingerprint)
+ }
+
+ @Test fun closeHidesTheAlertStateOnlyWhileTheAlertIsUp() = with(test) {
+ source.request = behindAlert
+ vm = TellyscopeViewModel(source, clock = { 0L })
+ runCurrent()
+ vm.dismissRequest()
+ advanceTimeBy(5_001)
+ runCurrent()
+ assertNull(vm.state.value.device.request)
+ source.request = null
+ advanceTimeBy(5_000)
+ runCurrent()
+ source.request = behindAlert
+ advanceTimeBy(5_000)
+ runCurrent()
+ assertEquals(true, vm.state.value.device.request?.behindAlert)
+ assertEquals(0, source.alertOks)
+ }
}