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.

Accessibility: the list version is the minimum that has the service

jesse-agent-23212fefe4de205
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 344d57b..de4c41f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@ until this file has a section for its version.
- **Improved:** Launchers, app names and streaming services now come from Tellyscope's own repository. [#323](../../pull/323)
- **Improved:** The launcher list is signed. If Tellyscope can't verify it, installing a launcher shows the list and its signer, and asks you to confirm. [#322](../../pull/322)
-- **Improved:** Which launchers may turn on their accessibility service now comes from the signed launcher list. If Tellyscope can't verify the list, it turns on no launcher's accessibility service. [#328](../../pull/328)
+- **Improved:** Which launchers may turn on their accessibility service now comes from the signed launcher list. If Tellyscope can't verify the list, it turns on no launcher's accessibility service. Tellyscope also skips a copy of the launcher that is too old to have one. [#328](../../pull/328)
## 0.15.0 — 2026-11-03
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 195db1b..36f9ec9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -36,7 +36,7 @@ These lists live in this repository, in [`data/`](data/), and the app downloads
- `data/labels.json`: names shown for common TV apps when the TV can't tell us.
- `data/streaming.json`: the streaming services the Remote can have a button for. Each names a logo, which stays in tellyscope-devices' `logos/` with its source and licence in `SOURCES.md`.
-A launcher that keeps Home with its own accessibility service carries `"accessibility": "<version>"` in `data/launchers.json`, and only those may have that service turned on. An accessibility service can read the screen, so the field counts only while `data/` passes its signature check: while it fails, Tellyscope turns no launcher's service on, even when you've ticked that you trust the list. Turning one off, when you switch away from that launcher, Undo or Reset, works either way. Add the field only after checking the APK's manifest for a service with `BIND_ACCESSIBILITY_SERVICE`, with the version you checked as its value. `DataListsTest` names every such launcher on purpose, so add yours there too and a reviewer sees it.
+A launcher that keeps Home with its own accessibility service carries `"accessibility": "<version>"` in `data/launchers.json`, and only those may have that service turned on. An accessibility service can read the screen, so the field counts only while `data/` passes its signature check: while it fails, Tellyscope turns no launcher's service on, even when you've ticked that you trust the list. Turning one off, when you switch away from that launcher, Undo or Reset, works either way. Its value is the minimum version that has the service: Tellyscope offers it, and turns it on, only when the TV's copy of the launcher is that version or newer, and not when its version can't be read. Add the field only after checking that version's manifest for a service with `BIND_ACCESSIBILITY_SERVICE`. `DataListsTest` names every such launcher on purpose, so add yours there too and a reviewer sees it.
The tests use small fixtures in [`app/src/test/resources/fixtures/`](app/src/test/resources/fixtures/) that only check the code: change the real debloat lists in tellyscope-devices and the others in `data/`, not there. The app itself bundles none.
diff --git a/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt b/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
index 2601a13..237cb8f 100644
--- a/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
+++ b/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
@@ -187,6 +187,12 @@ class Actions(private val shell: AdbShell) {
suspend fun homeService(pkg: String): String? =
activitiesIn(shell.shell(Commands.A11Y_SERVICES).output).firstOrNull { it.substringBefore('/') == pkg }
+ /** [pkg]'s versionName as the TV has it installed; null when it isn't, or names none. */
+ suspend fun versionName(pkg: String): String? {
+ require(PACKAGE.matches(pkg)) { "not a package name: $pkg" }
+ return Sideload.parseInstalled(shell.shell("dumpsys package $pkg").output, pkg)?.versionName
+ }
+
suspend fun serviceOn(service: String): Boolean = HomeServices.has(shell.shell(Commands.A11Y_ON).output, service)
/**
diff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
index 3f7c92f..1020d64 100644
--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
@@ -443,8 +443,10 @@ class AdbDeviceSource(
val own = homeOptions?.let { builtIns(system, disabled, it) }.orEmpty()
val back = homeOptions?.current?.takeIf { it !in system }
?.let { homeBackTarget(it, book.entries(key(deviceId)), own) }
+ // Only launchers at their list's version or newer are offered the service.
+ val offered = serviceLaunchers.filterTo(HashSet()) { pkg -> listed.any { it.name == pkg } && Actions(shell).mayTurnOn(pkg) }
// Its service off, the TV's own launcher may still answer Home: the row offers Turn on.
- val serviceOff = back != null && homeOptions?.current?.takeIf { it in serviceLaunchers }
+ val serviceOff = back != null && homeOptions?.current?.takeIf { it in offered }
?.let { Actions(shell).homeService(it) }?.let { !Actions(shell).serviceOn(it) } == true
// The card stays until Got it, which notes it on the switch; the next switch shows it again.
val note = serviceOff && back?.reverses?.let { id -> book.entries(key(deviceId)).firstOrNull { it.id == id } }
@@ -478,7 +480,7 @@ class AdbDeviceSource(
answersHome = homeOptions?.let { p.name == it.current || p.name in it.others } == true,
builtInLauncher = p.name in system && (p.name == homeOptions?.current || p.name in own),
homeBack = back?.takeIf { p.name == homeOptions?.current }?.let { names[it.pkg]?.label ?: AppNames.fallback(it.pkg) },
- homeService = p.name in serviceLaunchers,
+ homeService = p.name in offered,
homeServiceOff = serviceOff && p.name == homeOptions?.current,
homeServiceNote = note && p.name == homeOptions?.current,
listKeep = p.name in keep,
@@ -536,7 +538,7 @@ class AdbDeviceSource(
override suspend fun homeServiceOn(deviceId: String, packageName: String): Unit = busy(deviceId, reread = true) {
val actions = Actions(session(deviceId))
val label = labels[packageName] ?: AppNames.fallback(packageName)
- val service = packageName.takeIf { it in serviceLaunchers }?.let { actions.homeService(it) }
+ val service = packageName.takeIf { actions.mayTurnOn(it) }?.let { actions.homeService(it) }
?: throw UiTextException(UiText(R.string.data_no_service, label))
if (!actions.grant(service)) throw UiTextException(serviceNotOn(label))
// Undo of the switch to it turns it off again, as if the switch had turned it on.
@@ -596,12 +598,13 @@ class AdbDeviceSource(
fireHomes -= deviceId
val key = key(deviceId)
val actions = Actions(session(deviceId))
- if (packageName in serviceLaunchers && fireOs(deviceId, actions.installed(FIRE_TV_LAUNCHER))) {
+ val offered = setOfNotNull(packageName.takeIf { actions.mayTurnOn(it) })
+ if (packageName in offered && fireOs(deviceId, actions.installed(FIRE_TV_LAUNCHER))) {
return fireServiceHome(actions, packageName, withService, ::labelOf) { previous ->
book.record(key, System.currentTimeMillis(), Action.Home, packageName, labelOf(packageName), Action.Enable.takeIf { previous.isNotEmpty() }, undoing, previous)
}
}
- return switchHome(actions, packageName, withService, serviceLaunchers, listedServiceLaunchers, ::labelOf, ::reasonText) { pkg, undo, previous ->
+ return switchHome(actions, packageName, withService, offered, listedServiceLaunchers, ::labelOf, ::reasonText) { pkg, undo, previous ->
book.record(key, System.currentTimeMillis(), Action.Home, pkg, labelOf(packageName), undo, undoing, previous)
}
}
@@ -1383,12 +1386,19 @@ internal suspend fun fireHomeBack(
}
/**
- * Turns accessibility [service] on, only for a launcher in [SharedLists.serviceLaunchers]. Every path
- * that turns one on comes here, so neither an unsigned list nor a saved record can name another;
+ * Whether [pkg]'s accessibility service may go on: it's in [SharedLists.serviceLaunchers], and the TV
+ * has its list version or newer ([hasServiceFrom]). Below that it isn't offered, and [grant] refuses.
+ */
+internal suspend fun Actions.mayTurnOn(pkg: String): Boolean =
+ pkg in SharedLists.serviceLaunchers && SharedLists.serviceFrom(pkg)?.let { hasServiceFrom(it, versionName(pkg)) } == true
+
+/**
+ * Turns accessibility [service] on, only when [mayTurnOn] says so. Every path that turns one on comes
+ * here, so neither an unsigned list, a saved record nor an older copy of the launcher can get one;
* false for any other, as for a TV that refused.
*/
internal suspend fun Actions.grant(service: String): Boolean =
- service.substringBefore('/') in SharedLists.serviceLaunchers && setService(service, true)
+ mayTurnOn(service.substringBefore('/')) && setService(service, true)
/**
* The rest of [switch]'s Undo once its old launcher is on again: Home back to that launcher, the
diff --git a/app/src/main/java/app/tellyscope/data/Launchers.kt b/app/src/main/java/app/tellyscope/data/Launchers.kt
index 91ec427..a5ef890 100644
--- a/app/src/main/java/app/tellyscope/data/Launchers.kt
+++ b/app/src/main/java/app/tellyscope/data/Launchers.kt
@@ -15,7 +15,8 @@ import kotlinx.coroutines.flow.update
*
* [accessibility]: it keeps Home with its own accessibility service, for TVs whose Home button opens
* their own launcher whatever the default is, so Make Home turns that service on, and Undo or a switch
- * away from it turns it off. The value is the version whose manifest was read. An accessibility service
+ * away from it turns it off. The value is the minimum version that has the service: an older copy, or
+ * one whose versionName can't be read, isn't offered it ([hasServiceFrom]). An accessibility service
* can read the screen, so only while `data/` passes its signature check may it go on
* ([SharedLists.serviceLaunchers]); off works either way ([SharedLists.listedServiceLaunchers]).
*
@@ -46,6 +47,26 @@ private val CHECKED = Regex("[0-9][0-9A-Za-z.+-]{0,31}")
// "." and ".." are not repo names; they would walk the URL out of the repo.
private val RELEASES_PAGE = Regex("https://github\\.com/[A-Za-z0-9-]+/(?!\\.\\.?/)[A-Za-z0-9._-]+/releases")
+/**
+ * Whether [installed], a launcher's versionName on the TV, is [minimum] or newer: [minimum] is its
+ * [KnownLauncher.accessibility], the first version with the service. Compared by their leading
+ * numbers, so `4.72-beta` counts as `4.72`; false when either has none, as for a TV that names no version.
+ */
+fun hasServiceFrom(minimum: String, installed: String?): Boolean {
+ val need = versionParts(minimum) ?: return false
+ val have = installed?.let(::versionParts) ?: return false
+ for (i in 0 until maxOf(need.size, have.size)) {
+ val c = have.getOrElse(i) { 0 }.compareTo(need.getOrElse(i) { 0 })
+ if (c != 0) return c > 0
+ }
+ return true
+}
+
+private val VERSION_PARTS = Regex("^\\d+(?:\\.\\d+)*")
+
+private fun versionParts(v: String): List<Long>? =
+ VERSION_PARTS.find(v)?.value?.split('.')?.map { it.toLongOrNull() ?: return null }
+
/** Empty unless it is schema 1; entries that can't be read or aren't package names are dropped. */
fun parseLaunchers(text: String): List<KnownLauncher> = try {
val o = jsonObject(text)
@@ -148,6 +169,8 @@ object SharedLists {
* turning that service off. Unsigned, the worst a list can do with it is turn off the service of a launcher that was Home.
*/
val listedServiceLaunchers: Set<String> get() = launchers.filter { it.accessibility != null }.mapTo(HashSet()) { it.pkg }
+ /** [pkg]'s [KnownLauncher.accessibility], the minimum version that has the service; null when it has none. */
+ fun serviceFrom(pkg: String): String? = launchers.firstOrNull { it.pkg == pkg }?.accessibility
@Volatile private var data: DeviceLists? = null
@Volatile private var source: DeviceLists? = null
diff --git a/app/src/test/java/app/tellyscope/DataListsTest.kt b/app/src/test/java/app/tellyscope/DataListsTest.kt
index a7186dc..8002366 100644
--- a/app/src/test/java/app/tellyscope/DataListsTest.kt
+++ b/app/src/test/java/app/tellyscope/DataListsTest.kt
@@ -65,7 +65,7 @@ class DataListsTest {
if (l.has("max_mb") && (l.opt("max_mb") as? Int)?.takeIf { it in 1..256 } == null) errors += "$where: 'max_mb' must be a whole number from 1 to 256"
if (l.has("releases") && !releases.matches(l.optString("releases"))) errors += "$where: 'releases' must be https://github.com/<owner>/<repo>/releases"
if (l.has("accessibility") && (l.opt("accessibility") as? String)?.takeIf(checked::matches) == null) {
- errors += "$where: 'accessibility' must be the version whose manifest you checked, like \"4.72\""
+ errors += "$where: 'accessibility' must be the minimum version that has the service, like \"4.72\""
}
if (l.has("fire_os") && l.opt("fire_os") != true) errors += "$where: 'fire_os' can only be true; leave it out otherwise"
if (l.opt("fire_os") == true) {
diff --git a/app/src/test/java/app/tellyscope/HomeSwitchTest.kt b/app/src/test/java/app/tellyscope/HomeSwitchTest.kt
index 4779467..b6271d7 100644
--- a/app/src/test/java/app/tellyscope/HomeSwitchTest.kt
+++ b/app/src/test/java/app/tellyscope/HomeSwitchTest.kt
@@ -23,6 +23,8 @@ import app.tellyscope.data.fireHomeBack
import app.tellyscope.data.fireServiceHolder
import app.tellyscope.data.fireServiceHome
import app.tellyscope.data.firstHomeService
+import app.tellyscope.data.grant
+import app.tellyscope.data.mayTurnOn
import app.tellyscope.data.switchHome
import app.tellyscope.data.undoFireResetHome
import app.tellyscope.data.undoHomeSwitch
@@ -56,6 +58,8 @@ private class LauncherTv(var home: String?) : AdbSession {
val enabled = activities.keys.toMutableSet()
val user = setOf(PROJECTIVY, FLAUNCHER)
val services = mutableListOf<String>()
+ /** The versionName `dumpsys package` gives; the list's Projectivy has its service from 4.72. */
+ val versions = mutableMapOf(PROJECTIVY to "4.72", FLAUNCHER to "0.18.0")
/** False: `am start` can't open a home screen, as on a TV that refuses it. */
var opens = true
val ran = mutableListOf<String>()
@@ -72,6 +76,9 @@ private class LauncherTv(var home: String?) : AdbSession {
command.startsWith("pm disable-user") -> ok("Package $pkg new state: disabled-user\n").also { enabled -= pkg }
command.startsWith("pm enable") -> ok("Package $pkg new state: enabled\n").also { enabled += pkg }
command.startsWith("cmd package query-services") -> ok("$PROJECTIVY_SERVICE\n")
+ command.startsWith("dumpsys package ") -> command.removePrefix("dumpsys package ").let { p ->
+ ok(versions[p]?.let { "Packages:\n Package [$p] (1a2b3c):\n versionCode=1 minSdk=21 targetSdk=34\n versionName=$it\n" }.orEmpty())
+ }
command.startsWith("settings get secure enabled_accessibility_services") -> ok(services.joinToString(":").ifEmpty { "null" } + "\n")
command.startsWith("settings put secure enabled_accessibility_services") -> ok("").also { services.clear(); services += quoted.split(':') }
command.startsWith("settings delete secure enabled_accessibility_services") -> ok("").also { services.clear() }
@@ -181,6 +188,29 @@ class HomeSwitchTest {
assertTrue(tv.services.isEmpty())
}
+ /** The list's version is a minimum: an older copy, or one with no readable version, gets no service. */
+ @Test fun belowTheListsVersionTheServiceStaysOff() = runTest {
+ for (version in listOf("4.71", "unknown", null)) {
+ val tv = LauncherTv(home = TV_HOME).apply { if (version == null) versions -= PROJECTIVY else versions[PROJECTIVY] = version }
+ assertFalse(version.toString(), Actions(tv).mayTurnOn(PROJECTIVY))
+ assertFalse(version.toString(), Actions(tv).grant(PROJECTIVY_SERVICE))
+ assertTrue(version.toString(), tv.services.isEmpty())
+ }
+ val tv = LauncherTv(home = TV_HOME).apply { versions[PROJECTIVY] = "4.80" }
+ assertTrue(Actions(tv).mayTurnOn(PROJECTIVY))
+ }
+
+ /** Undo goes through [grant] too: a copy downgraded below the list's version doesn't get the service back. */
+ @Test fun undoBelowTheListsVersionLeavesTheServiceOff() = runTest {
+ val tv = LauncherTv(home = PROJECTIVY).apply { services += PROJECTIVY_SERVICE }
+ val entry = switch(tv, FLAUNCHER)
+ assertTrue(tv.services.isEmpty())
+ tv.versions[PROJECTIVY] = "4.70"
+ undo(tv, entry)
+ assertEquals(PROJECTIVY, tv.home)
+ assertTrue(tv.services.isEmpty())
+ }
+
@Test fun withNoDefaultTheTvsOwnLauncherBecomesTheDefaultWithNothingTurnedOff() = runTest {
val tv = LauncherTv(home = null)
val entry = switch(tv, TV_HOME)
diff --git a/app/src/test/java/app/tellyscope/LaunchersTest.kt b/app/src/test/java/app/tellyscope/LaunchersTest.kt
index 3dca304..a4dd4e9 100644
--- a/app/src/test/java/app/tellyscope/LaunchersTest.kt
+++ b/app/src/test/java/app/tellyscope/LaunchersTest.kt
@@ -9,12 +9,14 @@ import app.tellyscope.data.DeviceLists
import app.tellyscope.data.LISTS_BASE
import app.tellyscope.data.KnownLauncher
import app.tellyscope.data.SharedLists
+import app.tellyscope.data.hasServiceFrom
import app.tellyscope.data.parseLabels
import app.tellyscope.data.parseLaunchers
import app.tellyscope.data.parseProtected
import app.tellyscope.ui.RECOMMENDED
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
@@ -135,4 +137,21 @@ class LaunchersTest {
SharedLists.reseed() // the seed lists, for the tests after this one
}
}
+
+ /** `"accessibility"` is the minimum version that has the service: equal and newer pass, older and junk don't. */
+ @Test fun theServiceVersionIsAMinimum() {
+ assertTrue(hasServiceFrom("4.72", "4.72"))
+ assertTrue(hasServiceFrom("4.72", "4.72.0"))
+ assertTrue(hasServiceFrom("4.72", "4.80"))
+ assertTrue(hasServiceFrom("4.72", "5.0"))
+ assertTrue(hasServiceFrom("1.0.175", "1.0.200-beta"))
+ assertFalse(hasServiceFrom("4.72", "4.71"))
+ assertFalse(hasServiceFrom("4.72", "4.7"))
+ assertFalse(hasServiceFrom("1.0.175", "1.0.99"))
+ assertFalse(hasServiceFrom("4.72", null))
+ assertFalse(hasServiceFrom("4.72", ""))
+ assertFalse(hasServiceFrom("4.72", "beta-4.72"))
+ assertFalse(hasServiceFrom("4.72", "99999999999999999999"))
+ assertFalse(hasServiceFrom("x", "4.72"))
+ }
}