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: off works from any list, on only from a signed one

jesse-agent-2321467146b104e
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index dd214fa..195db1b 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. 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. 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.
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/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
index 6ba2ce1..3f7c92f 100644
--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
@@ -101,6 +101,8 @@ class AdbDeviceSource(
private val store = DeviceStore(File(appContext.filesDir, "devices.tsv"))
/** Launchers whose accessibility service a switch may turn on: only from a `data/` that passes its check. */
private val serviceLaunchers get() = SharedLists.serviceLaunchers
+ /** Launchers whose service may hold Home and is turned off on the way out: from `data/` signed or not. */
+ private val listedServiceLaunchers get() = SharedLists.listedServiceLaunchers
private val saved = ConcurrentHashMap<String, SavedDevice>()
/** Remembered TVs that haven't answered since launch: shown offline, not "connecting". */
private val restoring = ConcurrentHashMap.newKeySet<String>()
@@ -436,7 +438,7 @@ class AdbDeviceSource(
val names = appNames.names(key(deviceId), listed, LabelHelper(session, helperDex)::describe)
val keep = keep[key(deviceId)].orEmpty()
// Fire OS keeps Amazon's launcher the default; a launcher whose service is on holds Home instead.
- val held = if (fireOs(deviceId, FIRE_TV_LAUNCHER in system)) Actions(shell).fireServiceHolder(serviceLaunchers)?.first else null
+ val held = if (fireOs(deviceId, FIRE_TV_LAUNCHER in system)) Actions(shell).fireServiceHolder(listedServiceLaunchers)?.first else null
// On a launcher the user added, offer the way back to the one it replaced.
val own = homeOptions?.let { builtIns(system, disabled, it) }.orEmpty()
val back = homeOptions?.current?.takeIf { it !in system }
@@ -599,7 +601,7 @@ class AdbDeviceSource(
book.record(key, System.currentTimeMillis(), Action.Home, packageName, labelOf(packageName), Action.Enable.takeIf { previous.isNotEmpty() }, undoing, previous)
}
}
- return switchHome(actions, packageName, withService, serviceLaunchers, ::labelOf, ::reasonText) { pkg, undo, previous ->
+ return switchHome(actions, packageName, withService, serviceLaunchers, listedServiceLaunchers, ::labelOf, ::reasonText) { pkg, undo, previous ->
book.record(key, System.currentTimeMillis(), Action.Home, pkg, labelOf(packageName), undo, undoing, previous)
}
}
@@ -645,7 +647,7 @@ class AdbDeviceSource(
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 nothing = UiText(R.string.data_no_home_to_switch_back)
- if (fireOs(deviceId, FIRE_TV_LAUNCHER in system)) Actions(shell).fireServiceHolder(serviceLaunchers)?.let { held ->
+ if (fireOs(deviceId, FIRE_TV_LAUNCHER in system)) Actions(shell).fireServiceHolder(listedServiceLaunchers)?.let { held ->
val (added, _) = held
// Reverses the Make Home that turned the service on, so Restore leaves it alone.
val home = undoing ?: book.entries(key).filter { it.action == Action.Home && it.undoneAt == null && it.firstHomeService != null && it.packageName == added }.maxByOrNull { it.id }?.id
@@ -661,7 +663,7 @@ class AdbDeviceSource(
return when (val r = Actions(shell).homeBack(target.pkg, target.activity)) {
is HomeResult.Switched -> {
// Off with Home: it would keep sending Home to [added]. Undo, a switch, turns it on again.
- val service = added.takeIf { it in serviceLaunchers }?.let { Actions(shell).homeService(it) }?.takeIf { Actions(shell).serviceOn(it) }
+ val service = added.takeIf { it in listedServiceLaunchers }?.let { Actions(shell).homeService(it) }?.takeIf { Actions(shell).serviceOn(it) }
val off = service?.let { Actions(shell).setService(it, false) }
// Last: with its service still on, [added] could take Home straight back.
val left = Actions(shell).handOff(added, r.to)
@@ -737,12 +739,12 @@ class AdbDeviceSource(
val added = options?.takeIf { it.default }?.current?.takeIf { it !in system }
val to = added?.let { homeBackTarget(it, book.entries(key(deviceId)), own) }?.pkg?.takeIf { it in system } ?: own.firstOrNull()
// Fire OS keeps Amazon's launcher the default; a launcher whose service is on holds Home instead.
- val held = if (added == null && fireOs(deviceId, FIRE_TV_LAUNCHER in system)) Actions(shell).fireServiceHolder(serviceLaunchers)?.first else null
+ val held = if (added == null && fireOs(deviceId, FIRE_TV_LAUNCHER in system)) Actions(shell).fireServiceHolder(listedServiceLaunchers)?.first else null
ResetPlan(
turnOn = scan.turnOn.map { ResetApp(it, labelOf(it)) },
bringBack = scan.bringBack.map { ResetApp(it, labelOf(it)) },
home = when {
- added != null && to != null -> ResetHome(added, labelOf(added), to, labelOf(to), service = added in serviceLaunchers)
+ added != null && to != null -> ResetHome(added, labelOf(added), to, labelOf(to), service = added in listedServiceLaunchers)
held != null -> ResetHome(held, labelOf(held), FIRE_TV_LAUNCHER, labelOf(FIRE_TV_LAUNCHER), service = true, serviceOnly = true)
else -> null
},
@@ -819,7 +821,7 @@ class AdbDeviceSource(
is HomeResult.Refused -> throw UiTextException(reasonText(r.reason))
is HomeResult.Failed -> throw UiTextException(tvSaid(r.output))
}
- val service = home.from.takeIf { it in serviceLaunchers }?.let { actions.homeService(it) }?.takeIf { actions.serviceOn(it) }
+ val service = home.from.takeIf { it in listedServiceLaunchers }?.let { actions.homeService(it) }?.takeIf { actions.serviceOn(it) }
val off = service?.let { actions.setService(it, false) }
// Last, on Try again too: with its service still on, the added launcher could take Home straight back.
val left = actions.currentHome()?.let { actions.handOff(home.from, it) }?.let { notShown(home.toLabel, it.reason) }
@@ -1274,14 +1276,15 @@ class AdbDeviceSource(
* Makes [pkg] Home and hands [record] the entry's package, its Undo and what Undo reverses. Only
* a launcher the TV came with is ever turned off ([Actions.makeHome]). With [withService], a
* launcher in [serviceLaunchers] gets its accessibility service on to hold Home. A launcher the
- * user added that was Home stays on, and its service goes off, or it would take Home straight
- * back. The entry is recorded before a service step that didn't take throws, so Undo still works.
+ * user added that was Home stays on, and its service goes off if it's in [listedServiceLaunchers],
+ * or it would take Home straight back. The entry is recorded before a service step that didn't take throws, so Undo still works.
*/
internal suspend fun switchHome(
actions: Actions,
pkg: String,
withService: Boolean,
serviceLaunchers: Set<String>,
+ listedServiceLaunchers: Set<String>,
label: (String) -> String,
reason: (ProtectedReason) -> UiText,
record: (packageName: String, undo: Action?, previous: Map<String, String?>) -> HistoryEntry,
@@ -1291,7 +1294,7 @@ internal suspend fun switchHome(
val service = pkg.takeIf { withService && it in serviceLaunchers }?.let { actions.homeService(it) }?.takeUnless { actions.serviceOn(it) }
val on = service?.let { actions.grant(it) }
val was = r.from?.substringBefore('/')?.takeIf { r.kept }
- val old = was?.takeIf { it in serviceLaunchers }?.let { actions.homeService(it) }?.takeIf { actions.serviceOn(it) }
+ val old = was?.takeIf { it in listedServiceLaunchers }?.let { actions.homeService(it) }?.takeIf { actions.serviceOn(it) }
val off = old?.let { actions.setService(it, false) }
// Last, after both services: one still on could pull Home straight back. A launcher the
// TV came with is off now, which closed it already.
diff --git a/app/src/main/java/app/tellyscope/data/Launchers.kt b/app/src/main/java/app/tellyscope/data/Launchers.kt
index 98957f2..91ec427 100644
--- a/app/src/main/java/app/tellyscope/data/Launchers.kt
+++ b/app/src/main/java/app/tellyscope/data/Launchers.kt
@@ -16,7 +16,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
- * can read the screen, so [SharedLists] keeps it only while `data/` passes its signature check.
+ * can read the screen, so only while `data/` passes its signature check may it go on
+ * ([SharedLists.serviceLaunchers]); off works either way ([SharedLists.listedServiceLaunchers]).
*
* Installing it from an APK rather than the Play Store: [signers] are the SHA-256s of the only
* certificates it may be signed with (empty: never from an APK), [maxBytes] is past any real copy of
@@ -141,7 +142,12 @@ object SharedLists {
/** `data/`'s address while it fails its check, or null: installing a launcher from it asks first. */
val unverified get() = _state.value.unverified
/** Launchers whose accessibility service may go on ([KnownLauncher.accessibility]): none while `data/` fails its check. */
- val serviceLaunchers: Set<String> get() = launchers.filter { it.accessibility != null }.mapTo(HashSet()) { it.pkg }
+ val serviceLaunchers: Set<String> get() = if (unverified != null) emptySet() else listedServiceLaunchers
+ /**
+ * Every launcher with [KnownLauncher.accessibility], signed or not: for finding the one whose service holds Home and
+ * 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 }
@Volatile private var data: DeviceLists? = null
@Volatile private var source: DeviceLists? = null
@@ -176,10 +182,8 @@ object SharedLists {
val streaming = data("streaming")?.let(::parseStreaming)
val protected = source("protected")?.let(::parseProtected)
_state.update { now ->
- val kept = launchers?.ifEmpty { null } ?: now.launchers
now.copy(
- // Unsigned, a list can't say a launcher's accessibility service may go on.
- launchers = if (verified) kept else kept.map { it.copy(accessibility = null) },
+ launchers = launchers?.ifEmpty { null } ?: now.launchers,
labels = labels?.ifEmpty { null } ?: now.labels,
streaming = streaming?.ifEmpty { null } ?: now.streaming,
protected = protected?.ifEmpty { null } ?: now.protected,
diff --git a/app/src/main/java/app/tellyscope/ui/Recommended.kt b/app/src/main/java/app/tellyscope/ui/Recommended.kt
index 7125850..a07ad52 100644
--- a/app/src/main/java/app/tellyscope/ui/Recommended.kt
+++ b/app/src/main/java/app/tellyscope/ui/Recommended.kt
@@ -21,7 +21,7 @@ data class Recommended(
/** In the picker's order: the launchers on `launchers.json` that have an `about` line, in file order. */
val RECOMMENDED: List<Recommended> get() =
- SharedLists.launchers.mapNotNull { l -> l.about?.let { Recommended(l.pkg, l.name, it, l.accessibility != null, l) } }
+ SharedLists.launchers.mapNotNull { l -> l.about?.let { Recommended(l.pkg, l.name, it, l.pkg in SharedLists.serviceLaunchers, l) } }
fun launcherName(pkg: String) = RECOMMENDED.firstOrNull { it.pkg == pkg }?.name ?: AppNames.fallback(pkg)
diff --git a/app/src/test/java/app/tellyscope/DataSignatureTest.kt b/app/src/test/java/app/tellyscope/DataSignatureTest.kt
index 2ce902d..d1d7195 100644
--- a/app/src/test/java/app/tellyscope/DataSignatureTest.kt
+++ b/app/src/test/java/app/tellyscope/DataSignatureTest.kt
@@ -168,8 +168,8 @@ class DataSignatureTest {
assertNull(SharedLists.unverified)
}
- /** `accessibility` counts only while `data/` passes: unsigned, every launcher's is dropped and none may turn its service on. */
- @Test fun aLaunchersAccessibilityCountsOnlyWhenDataPasses() = runTest {
+ /** A launcher's service may go on only while `data/` passes; unsigned, it is still found and turned off. */
+ @Test fun aLaunchersAccessibilityGoesOnOnlyWhenDataPasses() = runTest {
val file = """{"schema":1,"launchers":[{"package":"com.good.home","name":"Good","accessibility":"1.0"}]}""".toByteArray()
val none = DeviceLists(tmp.newFolder()) { throw IOException("offline $it") }
val signedIndex = index(2026110301, file).let { withSigs(it, p256(it)) }
@@ -180,7 +180,7 @@ class DataSignatureTest {
SharedLists.load(lists(tmp.newFolder(), Served(mapOf("index.json" to index(2026110301, file), "launchers.json" to file))), none, fresh = true)
assertEquals(DATA_BASE, SharedLists.unverified)
assertEquals(emptySet<String>(), SharedLists.serviceLaunchers)
- assertNull(SharedLists.launchers.single().accessibility)
+ assertEquals(setOf("com.good.home"), SharedLists.listedServiceLaunchers)
}
/**
diff --git a/app/src/test/java/app/tellyscope/HomeSwitchTest.kt b/app/src/test/java/app/tellyscope/HomeSwitchTest.kt
index 9ca0875..4779467 100644
--- a/app/src/test/java/app/tellyscope/HomeSwitchTest.kt
+++ b/app/src/test/java/app/tellyscope/HomeSwitchTest.kt
@@ -9,10 +9,14 @@ import app.tellyscope.adb.AdbSession
import app.tellyscope.adb.RemoteEntry
import app.tellyscope.adb.ShellResult
import app.tellyscope.data.Action
+import app.tellyscope.data.DATA_BASE
+import app.tellyscope.data.DATA_KEYS
+import app.tellyscope.data.DeviceLists
import app.tellyscope.data.ActionFailed
import app.tellyscope.data.HistoryBook
import app.tellyscope.data.HistoryEntry
import app.tellyscope.data.ResetRecord
+import app.tellyscope.data.SharedLists
import app.tellyscope.data.UiText
import app.tellyscope.data.UiTextException
import app.tellyscope.data.fireHomeBack
@@ -24,15 +28,22 @@ import app.tellyscope.data.undoFireResetHome
import app.tellyscope.data.undoHomeSwitch
import java.io.File
import java.io.IOException
+import java.security.MessageDigest
import kotlinx.coroutines.test.runTest
import okio.Sink
import okio.Source
+import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
+import org.junit.Rule
import org.junit.Test
+import org.junit.rules.TemporaryFolder
+import org.junit.runner.RunWith
+import org.robolectric.RobolectricTestRunner
+import org.robolectric.annotation.Config
private const val TV_HOME = "com.google.android.tvlauncher"
private const val PROJECTIVY = "com.spocky.projengmenu"
@@ -82,12 +93,26 @@ private class LauncherTv(var home: String?) : AdbSession {
override fun close() = Unit
}
-/** The switch rule: only the TV's own launcher goes off, and Undo reverses exactly what the switch did. */
+/**
+ * The switch rule: only the TV's own launcher goes off, and Undo reverses exactly what the switch did.
+ * Under Robolectric for org.json: `grant` reads [SharedLists], seeded from the fixtures.
+ */
+@RunWith(RobolectricTestRunner::class)
+@Config(sdk = [35])
class HomeSwitchTest {
+ @get:Rule val tmp = TemporaryFolder()
private val book = HistoryBook()
- private suspend fun switch(tv: LauncherTv, pkg: String, withService: Boolean = true): HistoryEntry =
- switchHome(Actions(tv), pkg, withService, setOf(PROJECTIVY), { it }, { UiText.Raw(it.name) }) { from, undo, previous ->
+ @After fun reseed() = SharedLists.reseed()
+
+ private suspend fun switch(
+ tv: LauncherTv,
+ pkg: String,
+ withService: Boolean = true,
+ on: Set<String> = setOf(PROJECTIVY),
+ off: Set<String> = setOf(PROJECTIVY),
+ ): HistoryEntry =
+ switchHome(Actions(tv), pkg, withService, on, off, { it }, { UiText.Raw(it.name) }) { from, undo, previous ->
book.record("tv", 0, Action.Home, from, pkg, undo, previous = previous)
}
@@ -130,6 +155,23 @@ class HomeSwitchTest {
assertEquals(listOf(PROJECTIVY_SERVICE), tv.services)
}
+ /** Off doesn't wait for a signature: a service left on is the screen reader we guard against. */
+ @Test fun withDataUnverifiedSwitchingAwayStillTurnsTheServiceOff() = runTest {
+ val launchers = """{"schema":1,"launchers":[{"package":"$PROJECTIVY","name":"Projectivy Launcher","accessibility":"4.72"},{"package":"$FLAUNCHER","name":"FLauncher"}]}""".toByteArray()
+ val sha = MessageDigest.getInstance("SHA-256").digest(launchers).joinToString("") { "%02x".format(it) }
+ val index = """{"schema": 1, "version": 2026110301, "lists": {"launchers": {"file": "launchers.json", "sha256": "$sha"}}}""".toByteArray()
+ val served = mapOf("index.json" to index, "launchers.json" to launchers)
+ val data = DeviceLists(tmp.newFolder(), DATA_BASE, DATA_KEYS) { url -> served[url.removePrefix(DATA_BASE)] ?: throw IOException("404 $url") }
+ SharedLists.load(data, DeviceLists(tmp.newFolder()) { throw IOException("offline $it") }, fresh = true)
+ assertEquals(DATA_BASE, SharedLists.unverified)
+ assertEquals(emptySet<String>(), SharedLists.serviceLaunchers)
+
+ val tv = LauncherTv(home = PROJECTIVY).apply { services += PROJECTIVY_SERVICE }
+ switch(tv, FLAUNCHER, on = SharedLists.serviceLaunchers, off = SharedLists.listedServiceLaunchers)
+ assertEquals(FLAUNCHER, tv.home)
+ assertTrue(tv.services.isEmpty())
+ }
+
@Test fun switchingToAServiceLauncherTurnsItsServiceOnAndUndoOff() = runTest {
val tv = LauncherTv(home = TV_HOME)
val entry = switch(tv, PROJECTIVY)