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.
Move the bundled lists into JSON contributors can edit
jesse-agent-232f883607c5851
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 6b9ae7e..d29e319 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -28,9 +28,12 @@ The per-TV lists behind **Debloat** and the Overview's list card live in the [teYou don't have to trust ours. Fork tellyscope-devices, edit the lists in your fork, and keep `index.json` on schema 1 with each file's sha256 updated. Then in the app open **Settings** (in the ⋮ menu at the top right), open **Advanced** at the bottom, tap **Use your own debloat lists**, and paste the raw address of the folder that holds `index.json`, for example `https://raw.githubusercontent.com/<you>/tellyscope-devices/main/`. Only HTTPS is accepted, and a source that doesn't serve a schema 1 index is refused without changing anything. Switching drops the cached lists. While your source is in use, the review step says where the list came from. The built-in protected list still wins over any list, and **Reset to default** goes back to tellyscope-devices.-## Launchers+## Bundled lists-[`app/src/main/assets/launchers.json`](app/src/main/assets/launchers.json) lists the third-party launchers Tellyscope knows. Set `"accessibility": true` only for a launcher that keeps Home with its own accessibility service: Make Home offers to turn that service on, and an accessibility service can read the screen. Check the APK's manifest for a service with `BIND_ACCESSIBILITY_SERVICE`, and put the version you checked in `"checked"`. The list ships with the app and is never fetched, so a custom list source can't add to it.+The lists the app ships with live in [`app/src/main/resources/lists/`](app/src/main/resources/lists/). Change one with a pull request, and the change reaches people with the next release. They are never fetched, so a custom debloat list source can't add to them. Each file is JSON on `"schema": 1`, and `LaunchersTest` checks that every entry reads.++- [`launchers.json`](app/src/main/resources/lists/launchers.json) lists the third-party launchers Tellyscope knows. Set `"accessibility": true` only for a launcher that keeps Home with its own accessibility service: Make Home offers to turn that service on, and an accessibility service can read the screen. Check the APK's manifest for a service with `BIND_ACCESSIBILITY_SERVICE`, and put the version you checked in `"checked"`. A launcher with an `"about"` line is offered in **Install a home screen**, in the file's order; keep that line short and plain.+- [`labels.json`](app/src/main/resources/lists/labels.json) holds the names shown for common TV apps when the TV can't tell us (old Android, or a maker that blocks it). Add a package to the right group with the name its own APK shows.## README screenshotsdiff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.ktindex 7ac0c4d..ed2e562 100644--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt@@ -85,9 +85,8 @@ class AdbDeviceSource(context: Context) : DeviceSource {@Volatile private var paused = falseprivate val hits = ConcurrentHashMap<String, ScanHit>()private val store = DeviceStore(File(appContext.filesDir, "devices.tsv"))- private val launchers by lazy { parseLaunchers(appContext.assets.open("launchers.json").bufferedReader().use { it.readText() }) }/** Launchers whose accessibility service a switch may turn on: only those `launchers.json` names. */- private val serviceLaunchers by lazy { launchers.filter { it.accessibility }.map { it.pkg }.toSet() }+ private val serviceLaunchers by lazy { BundledLists.launchers.filter { it.accessibility }.map { it.pkg }.toSet() }private val saved = ConcurrentHashMap<String, SavedDevice>()/** Remembered TVs that haven't answered since launch: shown offline, not "connecting". */private val restoring = ConcurrentHashMap.newKeySet<String>()@@ -421,7 +420,7 @@ class AdbDeviceSource(context: Context) : DeviceSource {icon = name.icon,removable = p.name in userInstalled,home = p.name == homeOptions?.takeIf { it.default }?.current,- listedLauncher = launchers.any { it.pkg == p.name },+ listedLauncher = BundledLists.launchers.any { it.pkg == p.name },homeInstead = homeOptions?.takeIf { p.name in it.others }?.current,homeFirst = homeOptions?.takeIf { it.current == null && p.name in it.others } != null,answersHome = homeOptions?.let { p.name == it.current || p.name in it.others } == true,@@ -629,7 +628,7 @@ class AdbDeviceSource(context: Context) : DeviceSource {override suspend fun openStore(deviceId: String, packageName: String): Boolean {// Only a launcher the bundled list names: the Store link is the one thing this opens.- if (launchers.none { it.pkg == packageName }) return false+ if (BundledLists.launchers.none { it.pkg == packageName }) return falsereturn Actions(session(deviceId)).openStore(packageName)}diff --git a/app/src/main/java/app/tellyscope/data/AppNames.kt b/app/src/main/java/app/tellyscope/data/AppNames.ktindex 2c5d415..3b894c4 100644--- a/app/src/main/java/app/tellyscope/data/AppNames.kt+++ b/app/src/main/java/app/tellyscope/data/AppNames.kt@@ -20,10 +20,10 @@ class AppName(val label: String, val icon: ByteArray?, val tileColor: Long? = nu/*** Real app names and icons per TV. The TV's own labels come from `describe` (the label helper) and* are cached in [dir], one file per TV, so the helper only runs again for new or updated apps. When- * the helper can't run, [KnownLabels] and then a humanised package id stand in, with no icon, and- * that TV isn't asked again until the app restarts. Each TV's file is read once per launch, off the- * main thread, and kept: every list after that gets the same icon arrays, so the screen doesn't- * decode them again.+ * the helper can't run, the bundled `labels.json` ([BundledLists.labels]) and then a humanised+ * package id stand in, with no icon, and that TV isn't asked again until the app restarts. Each+ * TV's file is read once per launch, off the main thread, and kept: every list after that gets the+ * same icon arrays, so the screen doesn't decode them again.*/class AppNames(private val dir: File) {/** One helper run at a time; a second caller then finds the first one's results cached. */@@ -81,7 +81,7 @@ class AppNames(private val dir: File) {* Bundled table first, then a humanised id that keeps the maker: `com.xgimi.assistant` →* "XGIMI Assistant", `com.google.android.youtube.tv` → "Youtube".*/- fun fallback(pkg: String): String = KnownLabels[pkg] ?: humanise(pkg)+ fun fallback(pkg: String): String = BundledLists.labels[pkg] ?: humanise(pkg)/** What native daemons and system uids are listed as, in place of an app name. */const val SYSTEM = "Android system"diff --git a/app/src/main/java/app/tellyscope/data/KnownLabels.kt b/app/src/main/java/app/tellyscope/data/KnownLabels.ktdeleted file mode 100644index e876cb7..0000000--- a/app/src/main/java/app/tellyscope/data/KnownLabels.kt+++ /dev/null@@ -1,53 +0,0 @@-// SPDX-License-Identifier: GPL-3.0-only--package app.tellyscope.data--/**- * Display names for common TV packages, used when the label helper can't run on a TV (old- * Android, an OEM block). Names only: no brand icons ship with the app, so these get a letter- * avatar. Add a package only with the name its own APK shows.- */-object KnownLabels {- operator fun get(pkg: String): String? = names[pkg]-- private val names = mapOf(- // Android and Google TV system apps- "android" to "Android System",- "com.android.systemui" to "System UI",- "com.android.tv.settings" to "Settings",- "com.android.vending" to "Google Play Store",- "com.android.chrome" to "Chrome",- "com.android.bluetooth" to "Bluetooth",- "com.android.shell" to "Shell",- "com.android.providers.downloads" to "Download Manager",- "com.android.packageinstaller" to "Package installer",- "com.google.android.packageinstaller" to "Package installer",- "com.google.android.gms" to "Google Play services",- "com.google.android.gsf" to "Google Services Framework",- "com.google.android.tvlauncher" to "Android TV Home",- "com.google.android.apps.tv.launcherx" to "Google TV Home",- "com.google.android.apps.mediashell" to "Chromecast built-in",- "com.google.android.tv.remote.service" to "Android TV Remote Service",- "com.google.android.inputmethod.latin" to "Gboard",- "com.google.android.tts" to "Speech Services by Google",- "com.google.android.play.games" to "Google Play Games",- "com.google.android.youtube.tv" to "YouTube",- "com.google.android.youtube.tvmusic" to "YouTube Music",- "com.google.android.youtube.tvkids" to "YouTube Kids",- // Streaming and media apps- "com.netflix.ninja" to "Netflix",- "com.amazon.amazonvideo.livingroom" to "Prime Video",- "com.disney.disneyplus" to "Disney+",- "com.apple.atve.androidtv.appletv" to "Apple TV",- "com.spotify.tv.android" to "Spotify",- "com.plexapp.android" to "Plex",- "org.jellyfin.androidtv" to "Jellyfin",- "org.xbmc.kodi" to "Kodi",- "org.videolan.vlc" to "VLC",- "tv.twitch.android.app" to "Twitch",- "com.crunchyroll.crunchyroid" to "Crunchyroll",- "com.teamsmart.videomanager.tv" to "SmartTube",- // Launchers- "com.spocky.projengmenu" to "Projectivy Launcher",- )-}diff --git a/app/src/main/java/app/tellyscope/data/Launchers.kt b/app/src/main/java/app/tellyscope/data/Launchers.ktindex 5b968a9..1887289 100644--- a/app/src/main/java/app/tellyscope/data/Launchers.kt+++ b/app/src/main/java/app/tellyscope/data/Launchers.kt@@ -5,12 +5,19 @@ package app.tellyscope.dataimport org.json.JSONObject/**- * A third-party launcher Tellyscope knows, from `assets/launchers.json`. [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. [checked] is the version whose manifest was read.+ * A third-party launcher Tellyscope knows, from the bundled `lists/launchers.json`. [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. [checked] is the version whose manifest was read. [about] is the line Install+ * a home screen shows; a launcher without one isn't offered there.*/-data class KnownLauncher(val pkg: String, val name: String, val accessibility: Boolean, val checked: String?)+data class KnownLauncher(+ val pkg: String,+ val name: String,+ val accessibility: Boolean,+ val checked: String?,+ val about: String? = null,+)/*** Bundled with the app, never fetched: an accessibility service can read the screen, so only a@@ -25,8 +32,42 @@ fun parseLaunchers(text: String): List<KnownLauncher> = try {name = l.getString("name"),accessibility = l.optBoolean("accessibility"),checked = l.optStringOrNull("checked"),+ about = l.optStringOrNull("about"),).takeIf { PACKAGE.matches(it.pkg) }}} catch (_: org.json.JSONException) {emptyList()}++/**+ * Package to display name, from the bundled `lists/labels.json`; its groups are only there for+ * people reading the file. Empty unless it is schema 1; names under something that isn't a package+ * are dropped.+ */+fun parseLabels(text: String): Map<String, String> = try {+ val o = JSONObject(text)+ if (o.optInt("schema") != 1) emptyMap() else buildMap {+ o.getJSONArray("groups").objectsOrSkip { it.getJSONObject("labels") }.forEach { labels ->+ for (pkg in labels.keys()) {+ if (pkg != "android" && !PACKAGE.matches(pkg)) continue+ labels.optStringOrNull(pkg)?.let { put(pkg, it) }+ }+ }+ }+} catch (_: org.json.JSONException) {+ emptyMap()+}++/**+ * The lists that ship with the app, from `app/src/main/resources/lists/`. Contributors change them+ * by pull request, and a change reaches people with the next release. Java resources rather than+ * assets, so they load without a Context, in the app and in tests alike.+ */+object BundledLists {+ val launchers: List<KnownLauncher> by lazy { parseLaunchers(read("launchers.json")) }+ val labels: Map<String, String> by lazy { parseLabels(read("labels.json")) }++ private fun read(name: String): String =+ checkNotNull(BundledLists::class.java.getResourceAsStream("/lists/$name")) { "lists/$name isn't bundled" }+ .bufferedReader().use { it.readText() }+}diff --git a/app/src/main/java/app/tellyscope/ui/Recommended.kt b/app/src/main/java/app/tellyscope/ui/Recommended.ktindex 4422592..4f0cac2 100644--- a/app/src/main/java/app/tellyscope/ui/Recommended.kt+++ b/app/src/main/java/app/tellyscope/ui/Recommended.kt@@ -3,6 +3,7 @@package app.tellyscope.uiimport app.tellyscope.data.AppNames+import app.tellyscope.data.BundledLists/*** A launcher Install a home screen offers, from the bundled `launchers.json`: its name and a line@@ -10,12 +11,9 @@ import app.tellyscope.data.AppNames*/data class Recommended(val pkg: String, val name: String, val about: String, val accessibility: Boolean)-/** In the picker's order. [Recommended.accessibility] matches `launchers.json`; a test holds them together. */-val RECOMMENDED = listOf(- Recommended("com.spocky.projengmenu", "Projectivy Launcher", "The most popular. Rows, wallpapers and icons you can change.", true),- Recommended("com.overdevs.at4k", "AT4K Launcher", "A clean home screen in the Google TV style, without the ads.", true),- Recommended("com.spauldhaliwal.dispatch", "Dispatch", "Minimal: a fast list of your apps and inputs.", true),- Recommended("me.efesser.flauncher", "FLauncher", "Simple: your apps in rows, nothing else.", false),-)+/** In the picker's order: the launchers on `launchers.json` that have an `about` line, in file order. */+val RECOMMENDED: List<Recommended> by lazy {+ BundledLists.launchers.mapNotNull { l -> l.about?.let { Recommended(l.pkg, l.name, it, l.accessibility) } }+}fun launcherName(pkg: String) = RECOMMENDED.firstOrNull { it.pkg == pkg }?.name ?: AppNames.fallback(pkg)diff --git a/app/src/main/resources/lists/labels.json b/app/src/main/resources/lists/labels.jsonnew file mode 100644index 0000000..d593d3b--- /dev/null+++ b/app/src/main/resources/lists/labels.json@@ -0,0 +1,55 @@+{+ "schema": 1,+ "groups": [+ {+ "name": "Android and Google TV system apps",+ "labels": {+ "android": "Android System",+ "com.android.systemui": "System UI",+ "com.android.tv.settings": "Settings",+ "com.android.vending": "Google Play Store",+ "com.android.chrome": "Chrome",+ "com.android.bluetooth": "Bluetooth",+ "com.android.shell": "Shell",+ "com.android.providers.downloads": "Download Manager",+ "com.android.packageinstaller": "Package installer",+ "com.google.android.packageinstaller": "Package installer",+ "com.google.android.gms": "Google Play services",+ "com.google.android.gsf": "Google Services Framework",+ "com.google.android.tvlauncher": "Android TV Home",+ "com.google.android.apps.tv.launcherx": "Google TV Home",+ "com.google.android.apps.mediashell": "Chromecast built-in",+ "com.google.android.tv.remote.service": "Android TV Remote Service",+ "com.google.android.inputmethod.latin": "Gboard",+ "com.google.android.tts": "Speech Services by Google",+ "com.google.android.play.games": "Google Play Games",+ "com.google.android.youtube.tv": "YouTube",+ "com.google.android.youtube.tvmusic": "YouTube Music",+ "com.google.android.youtube.tvkids": "YouTube Kids"+ }+ },+ {+ "name": "Streaming and media apps",+ "labels": {+ "com.netflix.ninja": "Netflix",+ "com.amazon.amazonvideo.livingroom": "Prime Video",+ "com.disney.disneyplus": "Disney+",+ "com.apple.atve.androidtv.appletv": "Apple TV",+ "com.spotify.tv.android": "Spotify",+ "com.plexapp.android": "Plex",+ "org.jellyfin.androidtv": "Jellyfin",+ "org.xbmc.kodi": "Kodi",+ "org.videolan.vlc": "VLC",+ "tv.twitch.android.app": "Twitch",+ "com.crunchyroll.crunchyroid": "Crunchyroll",+ "com.teamsmart.videomanager.tv": "SmartTube"+ }+ },+ {+ "name": "Launchers",+ "labels": {+ "com.spocky.projengmenu": "Projectivy Launcher"+ }+ }+ ]+}diff --git a/app/src/main/assets/launchers.json b/app/src/main/resources/lists/launchers.jsonsimilarity index 63%rename from app/src/main/assets/launchers.jsonrename to app/src/main/resources/lists/launchers.jsonindex a69ebe9..0dd64be 100644--- a/app/src/main/assets/launchers.json+++ b/app/src/main/resources/lists/launchers.json@@ -1,10 +1,10 @@{"schema": 1,"launchers": [- { "package": "com.spocky.projengmenu", "name": "Projectivy Launcher", "accessibility": true, "checked": "4.72" },- { "package": "com.overdevs.at4k", "name": "AT4K Launcher", "accessibility": true, "checked": "1.2" },- { "package": "com.spauldhaliwal.dispatch", "name": "Dispatch", "accessibility": true, "checked": "1.0.175" },- { "package": "me.efesser.flauncher", "name": "FLauncher", "accessibility": false, "checked": "0.18.0" },+ { "package": "com.spocky.projengmenu", "name": "Projectivy Launcher", "about": "The most popular. Rows, wallpapers and icons you can change.", "accessibility": true, "checked": "4.72" },+ { "package": "com.overdevs.at4k", "name": "AT4K Launcher", "about": "A clean home screen in the Google TV style, without the ads.", "accessibility": true, "checked": "1.2" },+ { "package": "com.spauldhaliwal.dispatch", "name": "Dispatch", "about": "Minimal: a fast list of your apps and inputs.", "accessibility": true, "checked": "1.0.175" },+ { "package": "me.efesser.flauncher", "name": "FLauncher", "about": "Simple: your apps in rows, nothing else.", "accessibility": false, "checked": "0.18.0" },{ "package": "com.wolf.firelauncher", "name": "Wolf Launcher", "accessibility": false, "checked": "0.1.9" },{ "package": "ca.dstudio.atvlauncher.free", "name": "ATV Launcher", "accessibility": false, "checked": "0.0.11" },{ "package": "net.i.akihiro.halauncher", "name": "HALauncher", "accessibility": false, "checked": "2.0.3.0" },diff --git a/app/src/test/java/app/tellyscope/AppNamesTest.kt b/app/src/test/java/app/tellyscope/AppNamesTest.ktindex 3ac16ba..8c94015 100644--- a/app/src/test/java/app/tellyscope/AppNamesTest.kt+++ b/app/src/test/java/app/tellyscope/AppNamesTest.kt@@ -15,7 +15,13 @@ import org.junit.Assert.assertSameimport org.junit.Ruleimport org.junit.Testimport org.junit.rules.TemporaryFolder+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.annotation.Config+/** The fallback names come from the bundled `labels.json`, read with Android's org.json: Robolectric. */+@RunWith(RobolectricTestRunner::class)+@Config(sdk = [35])class AppNamesTest {@get:Rule val tmp = TemporaryFolder()diff --git a/app/src/test/java/app/tellyscope/LaunchersTest.kt b/app/src/test/java/app/tellyscope/LaunchersTest.ktindex e7ff4da..368002b 100644--- a/app/src/test/java/app/tellyscope/LaunchersTest.kt+++ b/app/src/test/java/app/tellyscope/LaunchersTest.kt@@ -2,7 +2,9 @@package app.tellyscope+import app.tellyscope.data.BundledListsimport app.tellyscope.data.KnownLauncher+import app.tellyscope.data.parseLabelsimport app.tellyscope.data.parseLaunchersimport app.tellyscope.ui.RECOMMENDEDimport org.junit.Assert.assertEquals@@ -18,7 +20,7 @@ import java.io.File@Config(sdk = [35])class LaunchersTest {@Test fun theBundledListReadsWhole() {- val text = File("src/main/assets/launchers.json").readText()+ val text = File("src/main/resources/lists/launchers.json").readText()val launchers = parseLaunchers(text)assertEquals(Regex("\"package\"").findAll(text).count(), launchers.size) // nothing droppedassertEquals(launchers.size, launchers.map { it.pkg }.toSet().size)@@ -28,13 +30,33 @@ class LaunchersTest {)}- @Test fun theRecommendedOnesAreOnTheBundledListAsItSaysThem() {- val known = parseLaunchers(File("src/main/assets/launchers.json").readText()).associateBy { it.pkg }- RECOMMENDED.forEach { r ->- val k = known[r.pkg] ?: error("${r.pkg} isn't in launchers.json")- assertEquals(r.pkg, k.accessibility, r.accessibility)- assertEquals(k.name, r.name)- }+ @Test fun theRecommendedOnesAreTheLaunchersWithAnAboutLineInFileOrder() {+ assertEquals(BundledLists.launchers.filter { it.about != null }.map { it.pkg }, RECOMMENDED.map { it.pkg })+ assertEquals(+ listOf("com.spocky.projengmenu", "com.overdevs.at4k", "com.spauldhaliwal.dispatch", "me.efesser.flauncher"),+ RECOMMENDED.map { it.pkg },+ )+ }++ @Test fun theBundledLabelsReadWhole() {+ val text = File("src/main/resources/lists/labels.json").readText()+ val labels = parseLabels(text)+ // Every "key": "text" pair but the group names is a label: none dropped, none listed twice.+ val pairs = Regex("\"[^\"]+\"\\s*:\\s*\"").findAll(text).count()+ assertEquals(pairs - Regex("\"name\"\\s*:").findAll(text).count(), labels.size)+ assertEquals("Android System", labels["android"])+ assertEquals("Netflix", BundledLists.labels["com.netflix.ninja"])+ }++ @Test fun badLabelsAreDroppedAndOnlySchemaOneCounts() {+ val text = """{"schema":1,"groups":[+ {"name":"Good","labels":{"com.good.app":"Good","android":"Android System","not a package":"Bad"}},+ {"name":"No labels"},+ "not an object"+ ]}"""+ assertEquals(mapOf("com.good.app" to "Good", "android" to "Android System"), parseLabels(text))+ assertTrue(parseLabels(text.replace("\"schema\":1", "\"schema\":2")).isEmpty())+ assertTrue(parseLabels("{").isEmpty())}@Test fun badEntriesAreDroppedAndOnlySchemaOneCounts() {