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.

Restore: a first home with its service on turned nothing off

jesse-agent-232cf0048d89240
diff --git a/app/src/main/java/app/tellyscope/data/HistoryBook.kt b/app/src/main/java/app/tellyscope/data/HistoryBook.kt
index 9e641be..40f1261 100644
--- a/app/src/main/java/app/tellyscope/data/HistoryBook.kt
+++ b/app/src/main/java/app/tellyscope/data/HistoryBook.kt
@@ -205,12 +205,13 @@ fun builtInTarget(pkg: String, history: List<HistoryEntry>): HomeBackTarget {
}
/**
- * A home switch disables the old launcher, unless there was none to replace (then it offers no
- * undo, or one for its service only) or the old one was a launcher the user added, which stays
- * on ("kept").
+ * A home switch disables the old launcher, unless there was none to replace or the old one was a
+ * launcher the user added, which stays on ("kept"). With none to replace there's no "from"; its
+ * Undo, when it turned a service on, is for that service alone. An entry without [previous]
+ * predates that record and keeps counting.
*/
private val HistoryEntry.disables get() =
- action == Action.Disable || (action == Action.Home && undo != null && firstHomeService == null && previous?.get("kept") == null)
+ action == Action.Disable || (action == Action.Home && undo != null && previous?.get("kept") == null && previous?.let { it["from"] != null } != false)
/** The service a switch with no launcher to replace turned on: its Undo turns that off, and nothing else. */
val HistoryEntry.firstHomeService: String?
diff --git a/app/src/test/java/app/tellyscope/HistoryBookTest.kt b/app/src/test/java/app/tellyscope/HistoryBookTest.kt
index 01a8581..0a9dd72 100644
--- a/app/src/test/java/app/tellyscope/HistoryBookTest.kt
+++ b/app/src/test/java/app/tellyscope/HistoryBookTest.kt
@@ -161,6 +161,16 @@ class HistoryBookTest {
assertNull(switch.firstHomeService)
}
+ @Test fun aFirstHomeWithItsServiceOnLeavesNothingToRestore() {
+ // No default and the TV's own launcher off: Make Home on Projectivy with its service. Undo turns
+ // the service off; Restore must not list Projectivy, the launcher now on Home.
+ val book = HistoryBook()
+ val pkg = "com.spocky.projengmenu"
+ book.record("tv", 0L, Action.Home, pkg, "Projectivy Launcher", undo = Action.Enable, previous = mapOf("to" to "$pkg/.Home", "service" to "$pkg/.Service"))
+ assertEquals(emptyList<String>(), HistoryBook.leftDisabled(book.entries("tv")))
+ assertNull(book.openDisable("tv", pkg))
+ }
+
@Test fun restoreAllTurnsOnOnlyWhatTellyscopeDisabled() = runTest {
// The fake TV starts with TV Recommendations already disabled.
val source = FakeDeviceSource()