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.
Restore turns launchers back on newest first, ending on the TV's Home
jesse-agent-821f93fd644ff82
diff --git a/app/src/main/java/app/tellyscope/data/HistoryBook.kt b/app/src/main/java/app/tellyscope/data/HistoryBook.ktindex 0ac3847..23424fa 100644--- a/app/src/main/java/app/tellyscope/data/HistoryBook.kt+++ b/app/src/main/java/app/tellyscope/data/HistoryBook.kt@@ -108,14 +108,16 @@ class HistoryBook(private val file: File? = null) {companion object {/*** Packages whose last disable/enable in [history] was a disable (a home switch disables the- * old launcher); an uninstall clears it.+ * old launcher); an uninstall clears it. Newest disable first: undoing a switch makes Home+ * the launcher it replaced, so after L→A→B, Restore undoes A→B, then L→A, and ends on L.*/fun leftDisabled(history: List<HistoryEntry>): List<String> =history.filter { it.disables || it.action == Action.Enable || it.action == Action.Uninstall }.sortedBy { it.id }.associate { it.packageName to it }.filterValues { it.disables }- .keys.sorted()+ .values.sortedByDescending { it.id }+ .map { it.packageName }}private fun save() {diff --git a/app/src/test/java/app/tellyscope/HistoryBookTest.kt b/app/src/test/java/app/tellyscope/HistoryBookTest.ktindex 1e7dfd7..897936e 100644--- a/app/src/test/java/app/tellyscope/HistoryBookTest.kt+++ b/app/src/test/java/app/tellyscope/HistoryBookTest.kt@@ -193,6 +193,24 @@ class HistoryBookTest {assertTrue(disable.undoneAt != null)}+ @Test fun restoreAfterTwoSwitchesEndsOnTheTvsOwnHome() = runTest {+ // L→A→B, where L sorts before A: alphabetical order undid L→A first and ended on A.+ val own = "com.google.android.tvlauncher"+ val first = "me.efesser.launcher"+ val book = HistoryBook(tmp.root.resolve("history.tsv"))+ book.record(tv, 1_000, Action.Home, own, "A", Action.Enable, previous = mapOf("from" to "$own/.Main", "to" to "$first/.Main"))+ book.record(tv, 2_000, Action.Home, first, "B", Action.Enable, previous = mapOf("from" to "$first/.Main", "to" to "com.spocky.projengmenu/.Main"))+ // As the source does: turning on a launcher a switch turned off makes it Home again.+ var home = "com.spocky.projengmenu/.Main"+ restoreEach(book.restorable(tv)) { pkg ->+ val switch = book.openDisable(tv, pkg)!!+ book.entries(tv).single { it.id == switch }.previous?.get("from")?.let { home = it }+ book.record(tv, 3_000, Action.Enable, pkg, pkg, null, undoing = switch)+ }+ assertEquals("$own/.Main", home)+ assertTrue(book.restorable(tv).isEmpty())+ }+@Test fun aStoppedRestoreSaysHowFarItGot() = runTest {var calls = 0val e = runCatching {