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.
Logged-out snackbar test flushes its state write; days are calendar days
jesse-agent-232fe2113faaf04
diff --git a/app/src/main/java/app/tellyscope/ui/Copy.kt b/app/src/main/java/app/tellyscope/ui/Copy.ktindex a94b105..87009d9 100644--- a/app/src/main/java/app/tellyscope/ui/Copy.kt+++ b/app/src/main/java/app/tellyscope/ui/Copy.kt@@ -13,8 +13,11 @@ import app.tellyscope.data.Snapshotimport app.tellyscope.data.TvSettingsimport app.tellyscope.data.sourceNameimport java.text.SimpleDateFormat+import java.time.Instantimport java.time.YearMonth+import java.time.ZoneIdimport java.time.format.DateTimeFormatter+import java.time.temporal.ChronoUnitimport java.util.Dateimport java.util.Locale@@ -219,7 +222,9 @@ object Copy {/** When the TV took the access back, on the logged-out page. */fun loggedOutAt(at: Long, now: Long): String {- val days = ((now - at) / 86_400_000).coerceAtLeast(0)+ // Calendar days, so 23:00 reads "yesterday" the next morning.+ val zone = ZoneId.systemDefault()+ val days = ChronoUnit.DAYS.between(Instant.ofEpochMilli(at).atZone(zone).toLocalDate(), Instant.ofEpochMilli(now).atZone(zone).toLocalDate())return when {now - at < 5 * 60_000 -> "Logged out just now"days == 0L -> "Logged out today, " + SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date(at))diff --git a/app/src/test/java/app/tellyscope/LoggedOutTest.kt b/app/src/test/java/app/tellyscope/LoggedOutTest.ktindex 95c12b1..11ce48e 100644--- a/app/src/test/java/app/tellyscope/LoggedOutTest.kt+++ b/app/src/test/java/app/tellyscope/LoggedOutTest.kt@@ -6,6 +6,7 @@ import androidx.compose.material3.SnackbarHostimport androidx.compose.material3.SnackbarHostStateimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.remember+import androidx.compose.runtime.snapshots.Snapshotimport androidx.compose.ui.test.junit4.v2.createComposeRuleimport androidx.compose.ui.test.onNodeWithTextimport androidx.compose.ui.test.performClick@@ -22,6 +23,8 @@ import org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config+import java.time.LocalDate+import java.time.ZoneId@RunWith(RobolectricTestRunner::class)@Config(sdk = [35])@@ -36,6 +39,13 @@ class LoggedOutTest {private val devices = mutableStateOf(listOf(tv("projector", "Projector"), tv("kitchen", "Kitchen")))private var viewed: String? = null+ /** The paused clock doesn't flush state writes, so tell the watch about this one before stepping. */+ private fun logOut(id: String) {+ devices.value = devices.value.map { if (it.id == id) tv(it.id, it.nickname!!, loggedOutAt = 1L) else it }+ Snapshot.sendApplyNotifications()+ compose.mainClock.advanceTimeBy(1_000)+ }+private fun watch(selected: String) {// The snackbar times out on the test clock, so step it by hand.compose.mainClock.autoAdvance = false@@ -49,8 +59,7 @@ class LoggedOutTest {@Test fun anotherTvLoggingOutSaysSoAndViewOpensIt() {watch(selected = "kitchen")- devices.value = listOf(tv("projector", "Projector", loggedOutAt = 1L), tv("kitchen", "Kitchen"))- compose.mainClock.advanceTimeBy(1_000)+ logOut("projector")compose.onNodeWithText(Copy.loggedOutOf("Projector")).assertExists()compose.onNodeWithText("View").performClick()compose.mainClock.advanceTimeBy(1_000)@@ -59,8 +68,7 @@ class LoggedOutTest {@Test fun theTvOnScreenGetsThePageNotASnackbar() {watch(selected = "projector")- devices.value = listOf(tv("projector", "Projector", loggedOutAt = 1L), tv("kitchen", "Kitchen"))- compose.mainClock.advanceTimeBy(1_000)+ logOut("projector")compose.onNodeWithText(Copy.loggedOutOf("Projector")).assertDoesNotExist()}@@ -85,5 +93,8 @@ class LoggedOutTest {assertEquals("Logged out just now", Copy.loggedOutAt(0L, 60_000L))assertEquals("Logged out yesterday", Copy.loggedOutAt(0L, 30 * hour))assertEquals("Logged out 3 days ago", Copy.loggedOutAt(0L, 80 * hour))+ // A day is a calendar day: 23:00 is "yesterday" at 09:00 the next morning, ten hours on.+ val lateEvening = LocalDate.of(2026, 10, 25).atTime(23, 0).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()+ assertEquals("Logged out yesterday", Copy.loggedOutAt(lateEvening, lateEvening + 10 * hour))}}