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.
Offer Uninstall for user-installed apps; fold protected apps away
jesse-agent-362e2dff881e5ec
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 14e7ae8..fe2085a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,9 @@ until this file has a section for its version.## Unreleased+- **New:** Uninstall apps you installed yourself; apps that came with the TV can only be disabled. [#33](../../pull/33)+- **Improved:** Apps that can't be changed fold into their own section below the list. [#33](../../pull/33)+## 0.1.0 — 2026-10-23- **New:** A new app icon: a telescope with a TV screen for a lens. [#28](../../pull/28)diff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.ktindex 8b30755..3dea1a1 100644--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt@@ -250,6 +250,7 @@ class AdbDeviceSource(context: Context) : DeviceSource {val home = Actions(shell).homePackages()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 userInstalled = Parsers.packages(shell.shell("pm list packages -3").output).map { it.name }.toSet()// Older pm rejects --show-versioncode and prints no packages; list again without it.val listed = Parsers.packages(shell.shell("pm list packages --show-versioncode").output).ifEmpty { Parsers.packages(shell.shell("pm list packages").output) }@@ -277,6 +278,7 @@ class AdbDeviceSource(context: Context) : DeviceSource {),version = "",icon = name.icon,+ removable = p.name in userInstalled && p.name !in keep,)}.sortedBy { it.label.lowercase() }}@@ -322,7 +324,7 @@ class AdbDeviceSource(context: Context) : DeviceSource {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) {+ 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)}@@ -488,5 +490,6 @@ class AdbDeviceSource(context: Context) : DeviceSource {ProtectedReason.SETUP_WIZARD -> "the TV may get stuck on restart without it"ProtectedReason.UPDATES -> "the TV gets its updates through this"ProtectedReason.UNKNOWN_HOME -> "this TV didn't say which app is its home screen, so Tellyscope won't change anything"+ ProtectedReason.CAME_WITH_TV -> "it came with the TV, so it can only be disabled"}}diff --git a/app/src/main/java/app/tellyscope/data/DeviceLists.kt b/app/src/main/java/app/tellyscope/data/DeviceLists.ktindex 27f029d..f4bc46f 100644--- a/app/src/main/java/app/tellyscope/data/DeviceLists.kt+++ b/app/src/main/java/app/tellyscope/data/DeviceLists.kt@@ -152,9 +152,9 @@ const val KEEP_REASON = "this TV's list says it must stay on"fun withKeep(builtIn: String?, pkg: String, enabled: Boolean, keep: Set<String>): String? =builtIn ?: KEEP_REASON.takeIf { enabled && pkg in keep }-/** Stop and Disable are refused for keep entries; Enable and Open always run. */+/** 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) && pkg in keep+ (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 thediff --git a/app/src/main/java/app/tellyscope/data/DeviceSource.kt b/app/src/main/java/app/tellyscope/data/DeviceSource.ktindex 6e67ba3..08fb2ea 100644--- a/app/src/main/java/app/tellyscope/data/DeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/DeviceSource.kt@@ -50,8 +50,8 @@ interface DeviceSource {suspend fun network(deviceId: String): NetworkInfo/**- * Runs an action and records it. Never uninstalls: there is no uninstall in [Action] on- * purpose. [undoing] is the history entry this reverses, which gets marked undone.+ * Runs an action and records it. Uninstall runs only on apps the user installed, and has no+ * undo. [undoing] is the history entry this reverses, which gets marked undone.*/suspend fun act(deviceId: String, action: Action, packageName: String, undoing: Long? = null): HistoryEntrydiff --git a/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt b/app/src/main/java/app/tellyscope/data/FakeDeviceSource.ktindex 72c92d8..7115d5d 100644--- a/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt@@ -198,13 +198,14 @@ class FakeDeviceSource(when (action) {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 -> Unit}val undo = when (action) {Action.Stop -> Action.OpenAction.Disable -> Action.EnableAction.Enable -> Action.Disable- Action.Open -> null+ Action.Open, Action.Uninstall -> null}return book.record(deviceId, clock(), action, packageName, app.label, undo, undoing)}@@ -321,8 +322,8 @@ class FakeDeviceSource(val baseApps = listOf(AppInfo("com.spocky.projengmenu", "Projectivy Launcher", 0xFF3D5AFE, false, true, "this is your home screen", "4.52"),AppInfo("com.google.android.youtube.tv", "YouTube", 0xFFC4302B, false, true, null, "4.40.303"),- AppInfo("com.netflix.ninja", "Netflix", 0xFFB20710, false, true, null, "11.2.0"),- AppInfo("org.jellyfin.androidtv", "Jellyfin", 0xFF7B5EA7, false, true, null, "0.17.4"),+ AppInfo("com.netflix.ninja", "Netflix", 0xFFB20710, false, true, null, "11.2.0", removable = true),+ AppInfo("org.jellyfin.androidtv", "Jellyfin", 0xFF7B5EA7, false, true, null, "0.17.4", removable = true),AppInfo("com.xgimi.assistant", "XGIMI Assistant", null, true, true, null, "2.1.8"),AppInfo("com.xgimi.ota", "XGIMI Updates", null, true, true, null, "1.4.0"),AppInfo("com.google.android.tvrecommendations", "TV Recommendations", null, true, false, null, "1.0"),diff --git a/app/src/main/java/app/tellyscope/data/HistoryBook.kt b/app/src/main/java/app/tellyscope/data/HistoryBook.ktindex fe54899..ca0c32a 100644--- a/app/src/main/java/app/tellyscope/data/HistoryBook.kt+++ b/app/src/main/java/app/tellyscope/data/HistoryBook.kt@@ -83,9 +83,9 @@ class HistoryBook(private val file: File? = null) {}companion object {- /** Packages whose last disable/enable in [history] was a disable. */+ /** Packages whose last disable/enable in [history] was a disable; an uninstall clears it. */fun leftDisabled(history: List<HistoryEntry>): List<String> =- history.filter { it.action == Action.Disable || it.action == Action.Enable }+ history.filter { it.action == Action.Disable || it.action == Action.Enable || it.action == Action.Uninstall }.sortedBy { it.id }.associate { it.packageName to it.action }.filterValues { it == Action.Disable }diff --git a/app/src/main/java/app/tellyscope/data/Model.kt b/app/src/main/java/app/tellyscope/data/Model.ktindex e9cabe5..5385060 100644--- a/app/src/main/java/app/tellyscope/data/Model.kt+++ b/app/src/main/java/app/tellyscope/data/Model.kt@@ -98,6 +98,8 @@ data class AppInfo(val version: String,/** The app's own icon as a PNG, from the TV; null shows the letter avatar. */val icon: ByteArray? = null,+ /** Installed by the user (`pm list packages -3`), so Uninstall is offered. Never for apps that came with the TV. */+ val removable: Boolean = false,)data class Socket(val app: String, val remote: String, val state: String)@@ -114,7 +116,7 @@ data class NetworkInfo(val traffic: List<AppTraffic>,)-enum class Action { Stop, Disable, Enable, Open }+enum class Action { Stop, Disable, Enable, Open, Uninstall }data class HistoryEntry(val id: Long,diff --git a/app/src/main/java/app/tellyscope/ui/Copy.kt b/app/src/main/java/app/tellyscope/ui/Copy.ktindex c7fb615..a19e499 100644--- a/app/src/main/java/app/tellyscope/ui/Copy.kt+++ b/app/src/main/java/app/tellyscope/ui/Copy.kt@@ -22,6 +22,7 @@ object Copy {Action.Disable -> "Disable"Action.Enable -> "Turn on"Action.Open -> "Open"+ Action.Uninstall -> "Uninstall"}fun confirm(action: Action) = when (action) {@@ -29,6 +30,7 @@ object Copy {Action.Disable -> "Yes, disable it"Action.Enable -> "Yes, turn it on"Action.Open -> "Yes, open it"+ Action.Uninstall -> "Yes, uninstall it"}/**@@ -41,6 +43,7 @@ object Copy {Action.Disable -> "Hides $who and stops it running. Nothing is deleted; you can turn it back on here."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."}}@@ -49,6 +52,7 @@ object Copy {Action.Disable -> "Disabled $app"Action.Enable -> "Turned on $app"Action.Open -> "Opened $app"+ Action.Uninstall -> "Uninstalled $app"}/**@@ -111,6 +115,10 @@ object Copy {else -> "Disabled $done of $of apps; the TV refused the rest. Undo any of them from History."}+ fun uninstallTitle(app: String) = "Uninstall $app?"++ const val CANT_CHANGE = "Can't be changed"+const val ANDROID_SYSTEM = AppNames.SYSTEM/** The word next to the status dot, so the state never rests on colour alone. */diff --git a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt b/app/src/main/java/app/tellyscope/ui/DeviceScreen.ktindex 71c7085..7960280 100644--- a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt@@ -38,6 +38,7 @@ import androidx.compose.material.icons.filled.Searchimport androidx.compose.material.icons.filled.Warningimport androidx.compose.material3.AlertDialogimport androidx.compose.material3.Button+import androidx.compose.material3.ButtonDefaultsimport androidx.compose.material3.Cardimport androidx.compose.material3.CardDefaultsimport androidx.compose.material3.Checkbox@@ -219,18 +220,30 @@ fun DeviceScreen(}}// An offline TV can't list anything: sections with nothing in them stay out of the way.+ // Protected apps can't be changed, so they wait in their own folded section below.+ val (locked, changeable) = ui.apps+ .filter { q.isEmpty() || it.label.lowercase().contains(q) || it.packageName.contains(q) }+ .sortedWith(compareBy({ !it.enabled }, { it.system }, { it.label }))+ .partition { it.protectedReason != null }if (!offline || ui.apps.isNotEmpty()) section(key = "apps",title = "Apps",- count = ui.apps.size,+ count = ui.apps.count { it.protectedReason == null },expandedByDefault = true,forceOpen = q.isNotEmpty(),) {- val apps = ui.apps- .filter { q.isEmpty() || it.label.lowercase().contains(q) || it.packageName.contains(q) }- .sortedWith(compareBy({ it.protectedReason != null }, { !it.enabled }, { it.system }, { it.label }))- if (apps.isEmpty()) EmptyLine(q)- apps.forEach { app ->+ if (changeable.isEmpty()) EmptyLine(q)+ changeable.forEach { app ->+ AppRow(app, snap?.procs.orEmpty(), ui.pending, ui.busy == app.packageName, actions)+ }+ }+ if (ui.apps.any { it.protectedReason != null } && (q.isEmpty() || locked.isNotEmpty())) section(+ key = "protected",+ title = Copy.CANT_CHANGE,+ count = ui.apps.count { it.protectedReason != null },+ forceOpen = q.isNotEmpty(),+ ) {+ locked.forEach { app ->AppRow(app, snap?.procs.orEmpty(), ui.pending, ui.busy == app.packageName, actions)}}@@ -667,6 +680,23 @@ fun AppIcon(app: AppInfo, modifier: Modifier = Modifier) {}}+/** Uninstall has no undo, so it asks in a dialog that names the app, not inline. */+@Composable+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)) },+ confirmButton = {+ Button(+ onClick = onUninstall,+ colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.error, contentColor = MaterialTheme.colorScheme.onError),+ ) { Text(Copy.confirm(Action.Uninstall)) }+ },+ dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } },+ )+}+@OptIn(ExperimentalMaterial3ExpressiveApi::class)@Composableprivate fun AppRow(@@ -710,7 +740,10 @@ private fun AppRow(if (app.enabled && ram > 0) OutlinedButton(onClick = { actions.propose(app.packageName, Action.Stop) }) { Text(Copy.button(Action.Stop)) }if (app.enabled) OutlinedButton(onClick = { actions.propose(app.packageName, Action.Disable) }) { Text(Copy.button(Action.Disable)) }else FilledTonalButton(onClick = { actions.propose(app.packageName, Action.Enable) }) { Text(Copy.button(Action.Enable)) }+ if (app.removable) OutlinedButton(onClick = { actions.propose(app.packageName, Action.Uninstall) }) { Text(Copy.button(Action.Uninstall)) }}+ } else if (proposed == Action.Uninstall) {+ UninstallDialog(app, onUninstall = actions.confirm, onDismiss = actions.cancel)} else {Text(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.ktindex 83934e4..c6f49bd 100644--- a/app/src/test/java/app/tellyscope/DeviceListsTest.kt+++ b/app/src/test/java/app/tellyscope/DeviceListsTest.kt@@ -147,6 +147,7 @@ class DeviceListsTest {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))diff --git a/app/src/test/java/app/tellyscope/HistoryBookTest.kt b/app/src/test/java/app/tellyscope/HistoryBookTest.ktindex 3c7b6b1..bb7bdd9 100644--- a/app/src/test/java/app/tellyscope/HistoryBookTest.kt+++ b/app/src/test/java/app/tellyscope/HistoryBookTest.kt@@ -71,6 +71,18 @@ class HistoryBookTest {assertEquals("Net flix", entries.single().label)}+ @Test fun uninstallHasNoUndoAndRestoreForgetsTheApp() = runTest {+ val source = FakeDeviceSource()+ val id = "tv"+ source.act(id, Action.Disable, "com.netflix.ninja")+ val gone = source.act(id, Action.Uninstall, "com.netflix.ninja")++ assertNull(gone.undo)+ assertTrue(source.apps(id).none { it.packageName == "com.netflix.ninja" })+ assertEquals(emptyList<String>(), HistoryBook.leftDisabled(source.history(id)))+ assertEquals(emptyList<String>(), source.restoreAll(id).map { it.packageName })+ }+@Test fun restoreAllTurnsOnOnlyWhatTellyscopeDisabled() = runTest {// The fake TV starts with TV Recommendations already disabled.val source = FakeDeviceSource()diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.ktindex 5b1971c..4fbc866 100644--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt@@ -16,6 +16,8 @@ import androidx.compose.ui.test.assertIsEnabledimport androidx.compose.ui.test.assertIsNotEnabledimport androidx.compose.ui.test.onNodeWithContentDescriptionimport androidx.compose.ui.test.onNodeWithText+import androidx.compose.ui.test.onAllNodesWithText+import androidx.compose.ui.test.assertCountEqualsimport androidx.compose.ui.test.onRootimport androidx.compose.ui.test.performClickimport app.tellyscope.adb.ApkInfo@@ -258,6 +260,40 @@ class ScreenshotTest {assertEquals(listOf(turnedOn), undone)}+ @Config(qualifiers = "w411dp-h2600dp-xxhdpi")+ @Test fun apps_uninstallOnlyForUserApps() {+ val proposed = mutableListOf<Pair<String, Action>>()+ val tap = { label: String ->+ compose.onNodeWithText(label).performClick()+ compose.mainClock.advanceTimeBy(1_000)+ }+ shot("26_apps_uninstall_offered", screen = true, before = { tap("Netflix"); tap("XGIMI Assistant"); Unit }) {+ DeviceScreen(deviceState(), DeviceActions(propose = { pkg, a -> proposed += pkg to a }))+ }+ // Netflix was installed by the user; XGIMI Assistant came with the TV and only gets Disable.+ compose.onAllNodesWithText("Uninstall").assertCountEquals(1)+ compose.onNodeWithText("Uninstall").performClick()+ assertEquals(listOf("com.netflix.ninja" to Action.Uninstall), proposed)+ }++ @Test fun apps_uninstallAsksInADialog() {+ val state = deviceState { copy(pending = "com.netflix.ninja" to Action.Uninstall) }+ shot("27_apps_uninstall_confirm", screen = true) { DeviceScreen(state, DeviceActions()) }+ compose.onNodeWithText("Uninstall Netflix?").assertExists()+ compose.onNodeWithText("can't be undone", substring = true).assertExists()+ compose.onNodeWithText("Yes, uninstall it").assertExists()+ }++ @Config(qualifiers = "w411dp-h2600dp-xxhdpi")+ @Test fun apps_protectedAreFoldedAway() {+ shot("28_apps_protected_folded", screen = true) { DeviceScreen(deviceState(), DeviceActions()) }+ compose.onNodeWithText("Can't be changed").assertExists()+ compose.onNodeWithText("System UI").assertDoesNotExist()+ compose.onNodeWithText("Can't be changed").performClick()+ compose.mainClock.advanceTimeBy(1_000)+ compose.onNodeWithText("System UI").assertExists()+ }+/** A real TV's app list: no per-process stats yet, so the apps sit right under the stat grid. */private fun appsState(apps: List<AppInfo>): UiState {val base = deviceState()