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.

Switch home back in one tap, and let list keeps warn instead of lock

jesse-agent-232c5ff4aa412b1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99aedad..fb49d31 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,7 @@ until this file has a section for its version.
- **Improved:** The TV's icon and name glide into the bar, Apps and Files pin their buttons, and empty pages say so. [#74](../../pull/74)
- **Improved:** Protected apps drop the lock icon; the line saying why stays. [#74](../../pull/74)
- **Fixed:** The upload icon draws properly again. [#74](../../pull/74)
+- **New:** Switch home back to the TV's own launcher in one tap; list keeps only warn. [#76](../../pull/76)
- **Fixed:** Welcome and pairing buttons no longer hide under the phone's navigation buttons. [#69](../../pull/69)
## 0.5.0 — 2026-10-24
diff --git a/README.md b/README.md
index efc99b4..536ea4c 100644
--- a/README.md
+++ b/README.md
@@ -70,7 +70,7 @@ Tellyscope needs a phone on Android 8.0 or newer, on the same Wi-Fi as the TV, a
- **Small and private.** Under 3 MB. No ads, no tracking, no accounts. It makes two internet requests: one fetches the debloat lists from this project's GitHub, or from your own fork if you point it there; the other asks GitHub every 30 minutes whether a newer version is out, and you can turn it off in Settings. Everything else stays on your Wi-Fi. Turning on Private DNS changes where the *TV* looks up addresses, not what the app sends.
- **Reversible.** Apps that came with the TV are only ever disabled, never uninstalled, so nothing is deleted. Apps you installed yourself can also be uninstalled, after a confirm that says it can't be undone. Every change goes into History, all but Uninstall with an Undo, and **Restore everything** turns back on all it turned off.
-- **Protected list.** Apps the TV needs to start, update, stay on Wi-Fi, show its home screen or take input can't be stopped or disabled. They sit in their own **System** section under Apps. There is no override.
+- **Protected list.** Apps the TV needs to start, update, stay on Wi-Fi, show its home screen or take input can't be stopped or disabled. They sit in their own **System** section under Apps. There is no override. Apps a TV's list only says to keep can still be changed, after a warning in the confirm.
- **You see it first.** Debloat shows every app it will turn off, and the confirm names each one before anything runs.
The full rules are under [Safety rules](#safety-rules).
@@ -85,7 +85,7 @@ Tellyscope is a phone app that talks to your Android TV, Google TV or Fire TV ov
- **The main jobs up front.** Big **Install app**, **Debloat** and **Send file** tiles sit right under the vitals. Debloat shows a count while the TV's list still has apps on, or while apps Tellyscope turned off are back on, often after a TV update. When there's nothing left, it opens Apps instead. Under **Suggested for this TV**, one line says how many of the list's apps are off. If any came back on, a red line says so. Below that are the TV's Android version, when it last updated, and **Check for updates**, which opens the TV's own update screen. The Apps tab has an **Install app** button, and Files has **Upload files**.
- **Advanced.** Every number in one place: memory, storage, CPU, temperature, uptime and screen state, CPU and RAM by app, processes, network and data used, and the TV's address.
- **Apps.** Every app on the TV with its real name and icon, under three buttons: **Running** (what's using memory now), **Installed** (only the apps you put on the TV) and **Built-in** (what came with it). The buttons stay pinned under the bar as you scroll. Stop, disable or turn back on any app that isn't protected; each button says what it will do and asks first. Apps you installed yourself also offer **Uninstall**, which asks in a dialog that names the app and says it can't be undone. On Running and Built-in, the protected apps sit last under **System**, which folds away with a tap and stays folded until you open it again. Search looks through every app.
-- **Another home screen.** With a second launcher such as Projectivy installed, its row in Apps offers **Set as default launcher**. Tellyscope makes it Home, checks that Home really opens it, and only then disables the old launcher, so the TV can't switch back by itself. One Undo in History turns the old launcher back on and makes it Home again. On Google TV, the Apps row and the Live tab are part of the old launcher and go with it.
+- **Another home screen.** With a second launcher such as Projectivy installed, its row in Apps offers **Set as default launcher**. Tellyscope makes it Home, checks that Home really opens it, and only then disables the old launcher, so the TV can't switch back by itself. One Undo in History turns the old launcher back on and makes it Home again. Later, the new launcher's row offers **Switch home back to** the one it replaced, or the TV's own if there was no switch: it's turned back on if it's off and made Home, and the added launcher stays, free to uninstall. Settings and other apps that only answer Home as a fallback are never offered as launchers. On Google TV, the Apps row and the Live tab are part of the old launcher and go with it.
- **Debloat.** It finds your TV among 230+ tested clean-up lists (adapted from [cleanyourtv](https://github.com/Gathin23/cleanyourtv)) and opens on every app it will turn off, with the model on top. With no list for the model, it shows apps from the maker's other lists, none ticked. With none for the maker either, you tick the TV's own apps by hand; the ones it needs aren't shown. **Not this TV?** searches every list. Your pick is remembered, and the TV's page then says how many of the list's apps are still on. Apps are pre-ticked only when the TV runs the Android version the list was tested on; untick anything you use, and you confirm before anything is disabled. If you'd rather not trust our lists, point the app at your own fork of them in Settings (see [CONTRIBUTING](CONTRIBUTING.md#using-your-own-lists)).
- **History.** Every change is listed with an Undo, and **Restore everything** turns back on what Tellyscope turned off. Undoing a **Turn on** asks first, since it disables the app again. History is kept per TV, across restarts.
- **Install apps.** Pick an APK, several split APKs or an `.apks`/`.xapk`/`.apkm` bundle on your phone. Before installing, Tellyscope shows the app's name, version and size and says whether it's new, an update, a reinstall or an older version. It won't install an older version over a newer one unless you tick the box. If the TV refuses, you get the reason in plain words.
@@ -108,7 +108,7 @@ Debloating a TV can break it if done carelessly. Tellyscope is built around thes
1. **Disable what came with the TV, never uninstall it.** Tellyscope uses `pm disable-user`, which is reversible from the app or with `pm enable`. Uninstall is offered only for apps `pm list packages -3` lists as installed by the user, and runs plain `pm uninstall` after a confirm that says it can't be undone. Tellyscope never runs `pm uninstall --user 0`, the form that removes a TV's own apps.
2. **Record before changing.** Before the first change on a TV, Tellyscope notes which apps were already off, so **Restore everything** turns back on only what Tellyscope turned off. Every change goes into the TV's history with an Undo. The history lives on the phone and is deleted if you uninstall Tellyscope; a disabled app still shows in the Apps list with **Turn on**.
-3. **Protected list.** Packages the TV needs to boot, install its updates, stay on Wi-Fi, show web pages, show the home screen or accept input are on a protected list. Tellyscope refuses to stop or disable them, and there is no override in the app. If the TV doesn't say which app is its home screen, Tellyscope refuses to stop or disable anything. The one exception is switching home screens: the old launcher is disabled only after another launcher has become Home and Home has been checked to open it, and the current home screen itself never can be. A TV's suggested list can protect more apps, never fewer.
+3. **Protected list.** Packages the TV needs to boot, install its updates, stay on Wi-Fi, show web pages, show the home screen or accept input are on a protected list. Tellyscope refuses to stop or disable them, and there is no override in the app. A TV's list can add keeps: those only warn in the confirm, and can be overridden. If the TV doesn't say which app is its home screen, Tellyscope refuses to stop or disable anything. The one exception is switching home screens: the old launcher is disabled only after another launcher has become Home and Home has been checked to open it, and the current home screen itself never can be. A TV's suggested list never protects fewer apps; its keeps add a warning, not a lock.
4. **No root, no exploits.** Only what ADB allows on a stock TV.
5. **Nothing left on the TV.** To show real app names and icons, Tellyscope copies a small helper to `/data/local/tmp`, runs it once and deletes it. The helper only reads through PackageManager: no writes, no permissions, no network.
diff --git a/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt b/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
index a60219f..eb0efba 100644
--- a/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
+++ b/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
@@ -93,6 +93,26 @@ class Actions(private val shell: AdbShell) {
return HomeResult.Switched(from, to)
}
+ /**
+ * Makes [pkg] Home again after another launcher took over: turns it on if it's off, then sets
+ * [activity], the one the switch away from it saved, or else its own home activity. The
+ * launcher that was Home stays on, so it can be made Home again or uninstalled.
+ */
+ suspend fun homeBack(pkg: String, activity: String? = null): HomeResult {
+ require(PACKAGE.matches(pkg)) { "not a package name: $pkg" }
+ require(activity == null || (ACTIVITY.matches(activity) && activity.substringBefore('/') == pkg)) { "not $pkg's activity: $activity" }
+ val from = currentHome() ?: return HomeResult.Refused(ProtectedReason.UNKNOWN_HOME)
+ if (from.substringBefore('/') == pkg) return HomeResult.Failed("it's already the home screen")
+ val on = exec("pm enable --user 0 $pkg", undo = null) { "enabled" in it }
+ if (on is ActionResult.Failed) return HomeResult.Failed(on.output)
+ val to = activity ?: launchers()[pkg] ?: return HomeResult.Failed("it has no home screen")
+ if (!setHome(to)) {
+ setHome(from)
+ return HomeResult.Failed("the TV kept the home screen it has")
+ }
+ return HomeResult.Switched(from, to)
+ }
+
/** Makes [activity] (`package/class`) the default home, then checks that Home opens it. */
suspend fun setHome(activity: String): Boolean {
require(ACTIVITY.matches(activity)) { "not an activity: $activity" }
@@ -104,10 +124,14 @@ class Actions(private val shell: AdbShell) {
private suspend fun currentHome(): String? =
activitiesIn(shell.shell(Commands.HOME_ACTIVITY).output).singleOrNull()?.takeUnless { it.startsWith("android/") }
- /** Every enabled launcher, package to its home activity. */
+ /**
+ * Every enabled launcher, package to its home activity. Apps protected for another reason
+ * aren't launchers, though they may answer Home: TV Settings has a fallback home screen.
+ */
private suspend fun launchers(): Map<String, String> =
activitiesIn(shell.shell(Commands.HOME_ACTIVITIES).output).filterNot { it.startsWith("android/") }
.associateBy { it.substringBefore('/') }
+ .filterKeys { Protected.reason(it).let { r -> r == null || r == ProtectedReason.HOME_SCREEN } }
private fun packagesIn(brief: String): Set<String> = activitiesIn(brief).map { it.substringBefore('/') }.toSet()
diff --git a/adb/src/test/kotlin/app/tellyscope/adb/ActionsTest.kt b/adb/src/test/kotlin/app/tellyscope/adb/ActionsTest.kt
index 3217cb6..85fed5e 100644
--- a/adb/src/test/kotlin/app/tellyscope/adb/ActionsTest.kt
+++ b/adb/src/test/kotlin/app/tellyscope/adb/ActionsTest.kt
@@ -123,6 +123,7 @@ class ActionsTest {
return FakeShell(mapOf(
"cmd package query-activities" to ok("com.google.android.tvlauncher/.MainActivity\ncom.spocky.projengmenu/.ui.home.MainActivity\n"),
"pm disable-user" to ok("Package com.google.android.tvlauncher new state: disabled-user\n"),
+ "pm enable" to ok("Package com.google.android.tvlauncher new state: enabled\n"),
)).apply {
answer = { cmd ->
when {
@@ -194,4 +195,37 @@ class ActionsTest {
assertTrue(Actions(sh).makeHome("com.google.android.tvlauncher") is HomeResult.Failed)
assertTrue(sh.ran.none { it.startsWith("pm ") || "set-home" in it })
}
+
+ @Test fun settingsIsNotALauncher() = runTest {
+ // TV Settings answers Home with its fallback screen; it's no launcher to offer.
+ val sh = FakeShell(mapOf(
+ home,
+ "cmd package query-activities" to ok("com.google.android.tvlauncher/.MainActivity\ncom.android.tv.settings/.FallbackHome\n"),
+ ))
+ assertEquals(emptySet(), Actions(sh).homeOptions()?.others)
+ assertTrue(Actions(sh).makeHome("com.android.tv.settings") is HomeResult.Failed)
+ assertTrue(sh.ran.none { it.startsWith("pm ") || "set-home" in it })
+ }
+
+ @Test fun homeBackTurnsTheOldLauncherOnAndLeavesTheNewOneOn() = runTest {
+ val sh = twoLaunchers()
+ Actions(sh).makeHome("com.spocky.projengmenu")
+ assertEquals(
+ HomeResult.Switched("com.spocky.projengmenu/.ui.home.MainActivity", "com.google.android.tvlauncher/.MainActivity"),
+ Actions(sh).homeBack("com.google.android.tvlauncher", "com.google.android.tvlauncher/.MainActivity"),
+ )
+ val on = sh.ran.indexOf("pm enable --user 0 com.google.android.tvlauncher 2>&1")
+ val set = sh.ran.indexOfLast { it == "cmd package set-home-activity --user 0 'com.google.android.tvlauncher/.MainActivity' 2>&1" }
+ assertTrue(on >= 0 && set > on)
+ assertTrue(sh.ran.none { it == "pm disable-user --user 0 com.spocky.projengmenu 2>&1" })
+ assertEquals("com.google.android.tvlauncher", Actions(sh).homeOptions()?.current)
+ }
+
+ @Test fun homeBackThatDoesNotTakePutsHomeBack() = runTest {
+ val sh = twoLaunchers()
+ Actions(sh).makeHome("com.spocky.projengmenu")
+ sh.answer.let { prev -> sh.answer = { if (it.startsWith("cmd package set-home-activity")) ok("Success\n") else prev(it) } }
+ assertTrue(Actions(sh).homeBack("com.google.android.tvlauncher", "com.google.android.tvlauncher/.MainActivity") is HomeResult.Failed)
+ assertTrue(Actions(sh).homeBack("com.spocky.projengmenu") is HomeResult.Failed) // already Home
+ }
}
diff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
index ebe0dbb..e2bd4c7 100644
--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
@@ -10,6 +10,7 @@ import android.net.NetworkCapabilities
import app.tellyscope.adb.ActionResult
import app.tellyscope.adb.ApkInfo
import app.tellyscope.adb.Files
+import app.tellyscope.adb.HomeOptions
import app.tellyscope.adb.HomeResult
import app.tellyscope.adb.InstallResult
import app.tellyscope.adb.Progress
@@ -315,6 +316,9 @@ class AdbDeviceSource(context: Context) : DeviceSource {
// Same key as history: a placeholder serial must not give two boxes one cache.
val names = appNames.names(key(deviceId), listed, LabelHelper(shell, helperDex)::describe)
val keep = keep[key(deviceId)].orEmpty()
+ // On a launcher the user added, offer the way back to the one it replaced.
+ val back = homeOptions?.current?.takeIf { it !in system }
+ ?.let { homeBackTarget(it, book.entries(key(deviceId)), builtIns(system, disabled, homeOptions)) }
return listed.map { p ->
val name = names.getValue(p.name)
labels[p.name] = name.label
@@ -325,19 +329,19 @@ class AdbDeviceSource(context: Context) : DeviceSource {
system = p.name in system,
enabled = p.name !in disabled,
// Same rule as Actions.run: no known launcher, nothing can be stopped or disabled.
- // A disabled app stays unprotected so Enable (always allowed) still shows.
- protectedReason = withKeep(
- when {
- home.isNotEmpty() -> Protected.reason(p.name, home)
- p.name in disabled -> null
- else -> ProtectedReason.UNKNOWN_HOME
- }?.let(::reasonText),
- p.name, enabled = p.name !in disabled, keep,
- ),
+ // A disabled app stays unprotected so Enable (always allowed) still shows, even
+ // for a built-in launcher that is off.
+ protectedReason = when {
+ p.name in disabled -> null
+ home.isNotEmpty() -> Protected.reason(p.name, home)
+ else -> ProtectedReason.UNKNOWN_HOME
+ }?.let(::reasonText),
version = "",
icon = name.icon,
- removable = p.name in userInstalled && p.name !in keep,
- homeInstead = homeOptions?.takeIf { p.name in it.others && it.current !in keep }?.current,
+ removable = p.name in userInstalled,
+ homeInstead = homeOptions?.takeIf { p.name in it.others }?.current,
+ homeBack = back?.takeIf { p.name == homeOptions?.current }?.let { names[it.pkg]?.label ?: AppNames.fallback(it.pkg) },
+ listKeep = p.name in keep,
)
}.sortedBy { it.label.lowercase() }
}
@@ -382,13 +386,9 @@ class AdbDeviceSource(context: Context) : DeviceSource {
// Before the first change on a TV, note what was already off: Restore must leave those alone.
val key = key(deviceId)
if (!book.hasBaseline(key)) book.setBaseline(key, disabledPackages(deviceId))
- // The list's keep entries add to the built-in protection in Actions.run; look it up if not yet.
- if (action == Action.Stop || action == Action.Disable || action == Action.Uninstall) {
- if (keepRefuses(action, packageName, keep[key] ?: resolve(deviceId).list?.keep.orEmpty())) {
- throw IllegalStateException(KEEP_REASON)
- }
- }
+ // The list's keep entries only warn, in the confirm; Actions.run holds the hard locks.
if (action == Action.Home) return makeHome(deviceId, packageName, undoing)
+ if (action == Action.HomeBack) return homeBack(deviceId, packageName, undoing)
val r = Actions(shell).run(AdbAction.valueOf(action.name.uppercase()), packageName)
return when (r) {
is ActionResult.Done -> {
@@ -413,10 +413,6 @@ class AdbDeviceSource(context: Context) : DeviceSource {
private suspend fun makeHome(deviceId: String, packageName: String, undoing: Long?): HistoryEntry {
val key = key(deviceId)
- val old = Actions(session(deviceId)).homeOptions()?.current
- if (old != null && keepRefuses(Action.Disable, old, keep[key] ?: resolve(deviceId).list?.keep.orEmpty())) {
- throw IllegalStateException(KEEP_REASON)
- }
return when (val r = Actions(session(deviceId)).makeHome(packageName)) {
is HomeResult.Switched -> book.record(
deviceId = key,
@@ -433,6 +429,44 @@ class AdbDeviceSource(context: Context) : DeviceSource {
}
}
+ /**
+ * Makes Home again the launcher that [added], now Home, replaced: the one the last switch saved,
+ * else the TV's own. [added] stays on; the entry's undo makes it Home again.
+ */
+ private suspend fun homeBack(deviceId: String, added: String, undoing: Long?): HistoryEntry {
+ val key = key(deviceId)
+ val shell = session(deviceId)
+ val system = Parsers.packages(shell.shell("pm list packages -s").output).map { it.name }.toSet()
+ val disabled = Parsers.packages(shell.shell("pm list packages -d").output).map { it.name }.toSet()
+ val options = Actions(shell).homeOptions()
+ val target = options?.current?.takeIf { it == added && it !in system }
+ ?.let { homeBackTarget(it, book.entries(key), builtIns(system, disabled, options)) }
+ ?: throw IllegalStateException("there's no home screen to switch back to")
+ return when (val r = Actions(shell).homeBack(target.pkg, target.activity)) {
+ is HomeResult.Switched -> book.record(
+ deviceId = key,
+ at = System.currentTimeMillis(),
+ action = Action.HomeBack,
+ packageName = added,
+ label = labels[target.pkg] ?: AppNames.fallback(target.pkg),
+ undo = Action.Home,
+ // The switch away from it is reversed now, so Restore leaves it alone.
+ undoing = undoing ?: target.reverses,
+ previous = mapOf("from" to r.from, "to" to r.to),
+ )
+ is HomeResult.Refused -> throw IllegalStateException(reasonText(r.reason))
+ is HomeResult.Failed -> throw IllegalStateException(r.output.ifEmpty { "the TV refused" })
+ }
+ }
+
+ /**
+ * The TV's own launchers, the ones to go back to: those that are on, then any that are off
+ * and named as one (an off app answers no Home query).
+ */
+ private fun builtIns(system: Set<String>, disabled: Set<String>, options: HomeOptions): List<String> =
+ (options.others.filter { it in system }.sorted() +
+ disabled.filter { it in system && Protected.reason(it) == ProtectedReason.HOME_SCREEN }.sorted()).distinct()
+
override suspend fun history(deviceId: String): List<HistoryEntry> = book.entries(key(deviceId))
override suspend fun restoreAll(deviceId: String): List<HistoryEntry> {
diff --git a/app/src/main/java/app/tellyscope/data/DeviceLists.kt b/app/src/main/java/app/tellyscope/data/DeviceLists.kt
index 5c129c4..21edc99 100644
--- a/app/src/main/java/app/tellyscope/data/DeviceLists.kt
+++ b/app/src/main/java/app/tellyscope/data/DeviceLists.kt
@@ -213,19 +213,6 @@ fun suggest(list: DeviceList, apps: List<AppInfo>, sdk: Int?): List<SuggestedGro
}.filter { it.packages.isNotEmpty() }
}
-const val KEEP_REASON = "this TV's list says it must stay on"
-
-/**
- * The list's keep entries add a reason; they never clear a built-in one. A keep entry that is
- * already off stays unprotected, so Enable still shows.
- */
-fun withKeep(builtIn: String?, pkg: String, enabled: Boolean, keep: Set<String>): String? =
- builtIn ?: KEEP_REASON.takeIf { enabled && pkg in keep }
-
-/** Stop, Disable and Uninstall are refused for keep entries; Enable and Open always run. */
-fun keepRefuses(action: Action, pkg: String, keep: Set<String>) =
- (action == Action.Stop || action == Action.Disable || action == Action.Uninstall) && pkg in keep
-
/**
* Fetches and caches the index and device files under [dir]. A failed fetch falls back to the
* cache; a device file is only used (and cached) when its sha256 matches the index. Hand picks
diff --git a/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt b/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt
index 66cc879..df35c29 100644
--- a/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt
+++ b/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt
@@ -203,13 +203,14 @@ class FakeDeviceSource(
Action.Disable -> list[i] = app.copy(enabled = false)
Action.Enable -> list[i] = app.copy(enabled = true)
Action.Uninstall -> list.removeAt(i)
- Action.Stop, Action.Open, Action.Change, Action.ClearCaches, Action.Home -> Unit
+ Action.Stop, Action.Open, Action.Change, Action.ClearCaches, Action.Home, Action.HomeBack -> Unit
}
val undo = when (action) {
Action.Stop -> Action.Open
Action.Disable -> Action.Enable
Action.Enable -> Action.Disable
Action.Home -> Action.Enable
+ Action.HomeBack -> Action.Home
Action.Open, Action.Uninstall, Action.Change, Action.ClearCaches -> null
}
return book.record(deviceId, clock(), action, packageName, app.label, undo, undoing)
diff --git a/app/src/main/java/app/tellyscope/data/HistoryBook.kt b/app/src/main/java/app/tellyscope/data/HistoryBook.kt
index ad89e2c..d73c1d2 100644
--- a/app/src/main/java/app/tellyscope/data/HistoryBook.kt
+++ b/app/src/main/java/app/tellyscope/data/HistoryBook.kt
@@ -154,6 +154,21 @@ class HistoryBook(private val file: File? = null) {
private const val VERSION = "v1"
+/** Where "Switch home back" goes: a launcher, its home activity if known, and the switch it reverses. */
+data class HomeBackTarget(val pkg: String, val activity: String?, val reverses: Long?)
+
+/**
+ * The launcher to make Home again while [current], a launcher the user added, is Home: the one
+ * the newest switch to [current] replaced, else the first of the TV's own [builtIns], on or off.
+ */
+fun homeBackTarget(current: String, history: List<HistoryEntry>, builtIns: List<String>): HomeBackTarget? {
+ val switch = history
+ .filter { it.action == Action.Home && it.undoneAt == null && it.previous?.get("to")?.substringBefore('/') == current }
+ .maxByOrNull { it.id }
+ switch?.previous?.get("from")?.let { return HomeBackTarget(it.substringBefore('/'), it, switch.id) }
+ return builtIns.firstOrNull { it != current }?.let { HomeBackTarget(it, null, null) }
+}
+
private val Action.disables get() = this == Action.Disable || this == Action.Home
/**
diff --git a/app/src/main/java/app/tellyscope/data/Model.kt b/app/src/main/java/app/tellyscope/data/Model.kt
index f7ba5a7..f47ac02 100644
--- a/app/src/main/java/app/tellyscope/data/Model.kt
+++ b/app/src/main/java/app/tellyscope/data/Model.kt
@@ -119,6 +119,10 @@ data class AppInfo(
val removable: Boolean = false,
/** Another launcher that can replace the current home screen, [homeInstead]: "Set as default launcher" is offered. */
val homeInstead: String? = null,
+ /** On the home screen the user added: the name of the launcher "Switch home back" returns to. */
+ val homeBack: String? = null,
+ /** This TV's list says to keep it: Stop, Disable and Uninstall still run, after a warning. */
+ val listKeep: Boolean = false,
)
data class Socket(val app: String, val remote: String, val state: String)
@@ -140,9 +144,12 @@ data class NetworkInfo(
* [HistoryEntry.previous] holds what Undo writes back. [ClearCaches] has no undo. [Home] makes a
* launcher the home screen and disables the old one: its entry's packageName is the old launcher,
* the label the new one's, and [HistoryEntry.previous] holds both home activities ("from", "to").
- * Its undo is [Enable], which also makes the old launcher Home again.
+ * Its undo is [Enable], which also makes the old launcher Home again. [HomeBack] makes the
+ * launcher a switch replaced (or the TV's own) Home again, turning it on if it's off, and leaves
+ * the added one on: its entry's packageName is the added launcher, the label the one now Home.
+ * Its undo is [Home], which switches to the added launcher again.
*/
-enum class Action { Stop, Disable, Enable, Open, Uninstall, Change, ClearCaches, Home }
+enum class Action { Stop, Disable, Enable, Open, Uninstall, Change, ClearCaches, Home, HomeBack }
data class HistoryEntry(
val id: Long,
diff --git a/app/src/main/java/app/tellyscope/ui/AppsTabs.kt b/app/src/main/java/app/tellyscope/ui/AppsTabs.kt
index 9e0285c..4bc0473 100644
--- a/app/src/main/java/app/tellyscope/ui/AppsTabs.kt
+++ b/app/src/main/java/app/tellyscope/ui/AppsTabs.kt
@@ -27,9 +27,10 @@ enum class AppsTab(val label: String) { Running("Running"), Installed("Installed
/** One Apps tab's list: the apps the user can change, then the [system] ones they can't, under their own header. */
data class AppsSplit(val apps: List<AppInfo>, val system: List<AppInfo>)
-/** Locked, as [AppRow] shows it: protected, and not offered as the new home screen. */
+/** Locked, as [AppRow] shows it: protected, and not offered as the new home screen or the way back. */
private fun locked(app: AppInfo, all: List<AppInfo>) =
- app.protectedReason != null && (app.homeInstead == null || !app.enabled || homeLabel(all, app) == null)
+ app.protectedReason != null && (app.homeInstead == null || !app.enabled || homeLabel(all, app) == null) &&
+ (app.homeBack == null || !app.enabled)
/**
* Splits the TV's apps for [tab]. Running: apps using RAM now. Installed: the user's own apps,
diff --git a/app/src/main/java/app/tellyscope/ui/Copy.kt b/app/src/main/java/app/tellyscope/ui/Copy.kt
index 3bdf30b..8b4a325 100644
--- a/app/src/main/java/app/tellyscope/ui/Copy.kt
+++ b/app/src/main/java/app/tellyscope/ui/Copy.kt
@@ -28,7 +28,7 @@ object Copy {
Action.Enable -> "Turn on"
Action.Open -> "Open"
Action.Uninstall -> "Uninstall"
- Action.Change, Action.ClearCaches, Action.Home -> error("$action has its own button")
+ Action.Change, Action.ClearCaches, Action.Home, Action.HomeBack -> error("$action has its own button")
}
fun confirm(action: Action) = when (action) {
@@ -38,6 +38,7 @@ object Copy {
Action.Open -> "Yes, open it"
Action.Uninstall -> "Yes, uninstall it"
Action.Home -> "Yes, switch home screen"
+ Action.HomeBack -> "Yes, switch back"
Action.Change, Action.ClearCaches -> error("$action isn't an app action")
}
@@ -52,7 +53,7 @@ object Copy {
Action.Enable -> "Turns $who back on."
Action.Open -> "Opens $who on the TV."
Action.Uninstall -> "Removes $who and everything saved in it. This can't be undone; to get it back, install it again."
- Action.Change, Action.ClearCaches, Action.Home -> error("$action isn't a one-app action")
+ Action.Change, Action.ClearCaches, Action.Home, Action.HomeBack -> error("$action isn't a one-app action")
}
}
@@ -66,8 +67,18 @@ object Copy {
Action.Change -> app
Action.ClearCaches -> "Cleared $app"
Action.Home -> "Set $app as the default launcher"
+ Action.HomeBack -> "Switched home back to $app"
}
+ /** Said in the confirm before Stop, Disable or Uninstall of an app the TV's list keeps. */
+ const val KEEP_WARNING = "This TV's list says to keep this."
+
+ fun homeBack(launcher: String) = "Switch home back to $launcher"
+
+ /** The way back keeps the added launcher, so it can be made Home again or uninstalled. */
+ fun explainHomeBack(added: String, back: String) =
+ "Makes $back open when you press Home again, turning it back on if it's off. $added stays on. Undo in History makes $added Home again."
+
/** Where the lists come from, for the Debloat screen and the snackbar after a change. */
fun listSource(custom: String?) =
if (custom == null) "Lists from tellyscope-devices, built from cleanyourtv" else "Lists from ${sourceName(custom)}"
diff --git a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
index 133d309..e9ba277 100644
--- a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
+++ b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt
@@ -355,7 +355,7 @@ fun UninstallDialog(app: AppInfo, onUninstall: () -> Unit, onDismiss: () -> Unit
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(Copy.uninstallTitle(app.label)) },
- text = { Text(Copy.explain(Action.Uninstall, app.label, app.packageName)) },
+ text = { Text(Copy.explain(Action.Uninstall, app.label, app.packageName) + if (app.listKeep) "\n\n${Copy.KEEP_WARNING}" else "") },
confirmButton = {
Button(
onClick = onUninstall,
@@ -380,7 +380,8 @@ internal fun AppRow(
var open by rememberSaveable(app.packageName) { mutableStateOf(false) }
// A launcher can be protected by its name and still be offered as the new home screen.
val home = app.homeInstead?.takeIf { app.enabled && homeLabel != null }
- val changeable = app.protectedReason == null || home != null
+ val back = app.homeBack?.takeIf { app.enabled }
+ val changeable = app.protectedReason == null || home != null || back != null
val ram = procs.filter { it.packageName == app.packageName }.sumOf { it.ramMb }
val status = when {
!app.enabled -> "Disabled"
@@ -414,12 +415,17 @@ internal fun AppRow(
if (app.removable) OutlinedButton(onClick = { actions.propose(app.packageName, Action.Uninstall) }) { Text(Copy.button(Action.Uninstall)) }
}
if (home != null) OutlinedButton(onClick = { actions.propose(app.packageName, Action.Home) }) { Text(Copy.MAKE_HOME) }
+ if (back != null) OutlinedButton(onClick = { actions.propose(app.packageName, Action.HomeBack) }) { Text(Copy.homeBack(back)) }
} else if (proposed == Action.Uninstall) {
UninstallDialog(app, onUninstall = actions.confirm, onDismiss = actions.cancel)
} else {
Text(
- if (proposed == Action.Home && home != null) Copy.explainHome(app.label, app.packageName, homeLabel!!, home)
- else Copy.explain(proposed, app.label, app.packageName),
+ when {
+ proposed == Action.Home && home != null -> Copy.explainHome(app.label, app.packageName, homeLabel!!, home)
+ proposed == Action.HomeBack && back != null -> Copy.explainHomeBack(app.label, back)
+ app.listKeep && proposed != Action.Enable -> Copy.explain(proposed, app.label, app.packageName) + "\n\n" + Copy.KEEP_WARNING
+ else -> Copy.explain(proposed, app.label, app.packageName)
+ },
style = MaterialTheme.typography.bodyMedium,
)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
diff --git a/app/src/test/java/app/tellyscope/DeviceListsTest.kt b/app/src/test/java/app/tellyscope/DeviceListsTest.kt
index b29c61d..0aa3850 100644
--- a/app/src/test/java/app/tellyscope/DeviceListsTest.kt
+++ b/app/src/test/java/app/tellyscope/DeviceListsTest.kt
@@ -2,18 +2,15 @@
package app.tellyscope
-import app.tellyscope.data.Action
import app.tellyscope.data.AppInfo
import app.tellyscope.data.DeviceList
import app.tellyscope.data.DeviceLists
-import app.tellyscope.data.KEEP_REASON
import app.tellyscope.data.LISTS_BASE
import app.tellyscope.data.ListEntry
import app.tellyscope.data.ListGroup
import app.tellyscope.data.ListIndex
import app.tellyscope.data.ListMatch
import app.tellyscope.data.ListPackage
-import app.tellyscope.data.keepRefuses
import app.tellyscope.data.matches
import app.tellyscope.data.merge
import app.tellyscope.data.SourceResult
@@ -23,7 +20,6 @@ import app.tellyscope.data.depth
import app.tellyscope.data.parseIndex
import app.tellyscope.data.parseList
import app.tellyscope.data.suggest
-import app.tellyscope.data.withKeep
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -182,7 +178,6 @@ class DeviceListsTest {
assertEquals(listOf("com.tcl.ads"), shown.map { it.pkg })
// No tested Android, so nothing starts ticked.
assertFalse(shown.single().ticked)
- assertEquals(KEEP_REASON, withKeep(null, "com.tcl.hdmi", enabled = true, merged.keep))
}
@Test fun onlyPackagesTheTvHasAndStillHasOnAreSuggested() = runTest {
@@ -209,21 +204,8 @@ class DeviceListsTest {
assertEquals(mapOf("com.a.one" to false, "com.a.two" to false), suggest(list.copy(sdk = null), apps, null).flatMap { it.packages }.associate { it.pkg to it.ticked })
}
- @Test fun keepOnlyAddsProtection() {
+ @Test fun keepIsNeverSuggested() {
val keep = setOf("com.acme.hdmi")
- assertEquals(KEEP_REASON, withKeep(null, "com.acme.hdmi", enabled = true, keep))
- // A built-in reason always survives, list or no list.
- assertEquals("this is your home screen", withKeep("this is your home screen", "com.acme.launcher", enabled = true, keep))
- assertEquals("this is your home screen", withKeep("this is your home screen", "com.acme.launcher", enabled = true, emptySet()))
- // Already off: Enable must still be offered.
- assertNull(withKeep(null, "com.acme.hdmi", enabled = false, keep))
-
- assertTrue(keepRefuses(Action.Disable, "com.acme.hdmi", keep))
- assertTrue(keepRefuses(Action.Stop, "com.acme.hdmi", keep))
- assertTrue(keepRefuses(Action.Uninstall, "com.acme.hdmi", keep))
- assertFalse(keepRefuses(Action.Enable, "com.acme.hdmi", keep))
- assertFalse(keepRefuses(Action.Disable, "com.acme.reporter", keep))
-
// A list that names a package in both keep and a group never suggests it.
val list = DeviceList("x", "X", null, 30, keep, listOf(ListGroup("Junk", listOf(ListPackage("com.acme.hdmi", null, false)))))
assertTrue(suggest(list, listOf(app("com.acme.hdmi")), 30).isEmpty())
diff --git a/app/src/test/java/app/tellyscope/HomeBackTest.kt b/app/src/test/java/app/tellyscope/HomeBackTest.kt
new file mode 100644
index 0000000..168e884
--- /dev/null
+++ b/app/src/test/java/app/tellyscope/HomeBackTest.kt
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-3.0-only
+
+package app.tellyscope
+
+import app.tellyscope.data.Action
+import app.tellyscope.data.HistoryEntry
+import app.tellyscope.data.HomeBackTarget
+import app.tellyscope.data.homeBackTarget
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
+import org.junit.Test
+
+class HomeBackTest {
+ private val stock = "com.google.android.tvlauncher"
+ private val added = "com.spocky.projengmenu"
+
+ private fun switch(id: Long, from: String, to: String, undoneAt: Long? = null) = HistoryEntry(
+ id, "tv", id, Action.Home, from.substringBefore('/'), "Projectivy", Action.Enable, undoneAt,
+ previous = mapOf("from" to from, "to" to to),
+ )
+
+ @Test fun goesBackToWhatTheSwitchReplaced() {
+ val history = listOf(
+ switch(1, "com.xgimi.home/.Main", "$added/.Home", undoneAt = 5),
+ switch(7, "$stock/.MainActivity", "$added/.Home"),
+ )
+ assertEquals(HomeBackTarget(stock, "$stock/.MainActivity", 7), homeBackTarget(added, history, listOf("com.xgimi.home")))
+ }
+
+ @Test fun withoutASwitchGoesToTheTvsOwnEvenWhenOff() {
+ // Projectivy was made Home on the TV itself: the stock launcher, now off, is the way back.
+ assertEquals(HomeBackTarget(stock, null, null), homeBackTarget(added, emptyList(), listOf(stock)))
+ // A switch that was undone, or one to another launcher, doesn't count.
+ val other = listOf(switch(3, "$stock/.MainActivity", "com.other.home/.Main"), switch(2, "$stock/.MainActivity", "$added/.Home", undoneAt = 4))
+ assertEquals(HomeBackTarget(stock, null, null), homeBackTarget(added, other, listOf(stock)))
+ }
+
+ @Test fun nothingToGoBackTo() {
+ assertNull(homeBackTarget(added, emptyList(), emptyList()))
+ assertNull(homeBackTarget(added, emptyList(), listOf(added)))
+ }
+}
diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
index 66848fe..5c78b2f 100644
--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt
+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
@@ -1049,6 +1049,68 @@ class ScreenshotTest {
compose.onNodeWithText("Yes, switch home screen").assertExists()
}
+ // Projectivy is Home now, made so on the TV itself; its row offers the way back to Google TV Home, which is off.
+ private fun homeBackState(confirming: Boolean = false) = deviceState {
+ val stock = AppInfo("com.google.android.tvlauncher", "Google TV Home", 0xFF1A73E8, true, false, null, "1.0.4")
+ val projectivy = { a: AppInfo -> a.copy(protectedReason = "this is your home screen", system = false, removable = true, homeBack = stock.label) }
+ copy(
+ apps = listOf(stock) + apps.map { if (it.packageName == "com.spocky.projengmenu") projectivy(it) else it },
+ pending = ("com.spocky.projengmenu" to Action.HomeBack).takeIf { confirming },
+ )
+ }
+ private fun homeBack(dark: Boolean) {
+ val back = { compose.onNode(hasScrollAction()).performScrollToNode(hasText(Copy.confirm(Action.HomeBack))); Unit }
+ shot("78_apps_home_back", dark, before = back) { DeviceTabsScreen(homeBackState(confirming = true), DeviceActions(), startTab = TvTab.Apps) }
+ compose.onNodeWithText(Copy.explainHomeBack("Projectivy Launcher", "Google TV Home")).assertExists()
+ }
+ @Test fun apps_homeBack() = homeBack(false)
+ @Test fun apps_homeBack_dark() = homeBack(true)
+
+ @Test fun apps_homeBackIsOfferedOnTheAddedLauncher() {
+ val proposed = mutableListOf<Pair<String, Action>>()
+ compose.mainClock.autoAdvance = false
+ compose.setContent { TellyscopeTheme(dynamic = false) { DeviceTabsScreen(homeBackState(), DeviceActions(propose = { pkg, a -> proposed += pkg to a }), startTab = TvTab.Apps) } }
+ compose.mainClock.advanceTimeBy(1_000)
+ compose.onNode(hasScrollAction()).performScrollToNode(hasText("Projectivy Launcher"))
+ compose.onNodeWithText("Projectivy Launcher").performClick()
+ compose.mainClock.advanceTimeBy(1_000)
+ compose.onNode(hasScrollAction()).performScrollToNode(hasText(Copy.homeBack("Google TV Home")))
+ compose.onNodeWithText(Copy.homeBack("Google TV Home")).performClick()
+ compose.mainClock.advanceTimeBy(1_000)
+ assertEquals(listOf("com.spocky.projengmenu" to Action.HomeBack), proposed)
+ // Still the home screen, so nothing that would turn it off.
+ compose.onAllNodesWithText("Disable").assertCountEquals(0)
+ }
+
+ // A keep from the TV's list only warns; a hard lock still offers nothing.
+ @Test fun apps_listKeepWarnsAndHardLockHolds() {
+ val proposed = mutableListOf<Pair<String, Action>>()
+ val kept = deviceState { copy(apps = apps.map { if (it.packageName == "com.xgimi.assistant") it.copy(listKeep = true) else it }) }
+ compose.mainClock.autoAdvance = false
+ compose.setContent { TellyscopeTheme(dynamic = false) { DeviceTabsScreen(kept, DeviceActions(propose = { pkg, a -> proposed += pkg to a }), startTab = TvTab.Apps) } }
+ compose.mainClock.advanceTimeBy(1_000)
+ val tap = { label: String ->
+ compose.onNode(hasScrollAction()).performScrollToNode(hasText(label))
+ compose.onNodeWithText(label).performClick()
+ compose.mainClock.advanceTimeBy(1_000)
+ }
+ tap("Built-in"); tap("XGIMI Assistant"); tap("Disable")
+ assertEquals(listOf("com.xgimi.assistant" to Action.Disable), proposed)
+ tap("Google Play services")
+ compose.onAllNodesWithText("Disable").assertCountEquals(1) // XGIMI Assistant's, still open
+ assertEquals(1, proposed.size)
+ }
+
+ @Test fun apps_listKeepConfirmSaysSo() {
+ val state = deviceState {
+ copy(apps = apps.map { if (it.packageName == "com.xgimi.assistant") it.copy(listKeep = true) else it }, pending = "com.xgimi.assistant" to Action.Disable)
+ }
+ shot("79_apps_keep_warning", before = { compose.onNode(hasScrollAction()).performScrollToNode(hasText(Copy.confirm(Action.Disable))); Unit }) {
+ DeviceTabsScreen(state, DeviceActions(), startTab = TvTab.Apps)
+ }
+ compose.onNodeWithText(Copy.KEEP_WARNING, substring = true).assertExists()
+ }
+
@Test fun readme_send() = shot("25_readme_send", screen = true) {
val t = TransferUi("family-trip-2025.mp4", toTv = true, folder = TvFolder.MOVIES, progress = Progress(486_000_000, 812_000_000))
DeviceTabsScreen(deviceState { copy(transfer = t) }, DeviceActions())