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.

DeviceLists keeps fetch last, so tests can pass it as a trailing lambda

jesse-agent-2327df185f8081a
diff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
index f8caee2..fdf10e6 100644
--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt
@@ -130,7 +130,7 @@ class AdbDeviceSource(
private val appNames = AppNames(File(appContext.filesDir, "app-names"))
private val lists = DeviceLists(File(appContext.filesDir, "lists"))
/** `data/`'s launcher, app name and streaming lists; never the user's source. */
- private val data = DeviceLists(File(appContext.filesDir, "data"), default = DATA_BASE)
+ private val data = DeviceLists(File(appContext.filesDir, "data"), DATA_BASE)
/** [historyKey] → the keep entries of that TV's list, once it has been looked up. */
private val keep = ConcurrentHashMap<String, Set<String>>()
diff --git a/app/src/main/java/app/tellyscope/data/DeviceLists.kt b/app/src/main/java/app/tellyscope/data/DeviceLists.kt
index c56c60b..4413a7b 100644
--- a/app/src/main/java/app/tellyscope/data/DeviceLists.kt
+++ b/app/src/main/java/app/tellyscope/data/DeviceLists.kt
@@ -263,9 +263,12 @@ fun suggest(list: DeviceList, apps: List<AppInfo>, sdk: Int?): List<SuggestedGro
*/
class DeviceLists(
private val dir: File,
+ private val default: String,
private val fetch: suspend (String) -> ByteArray = ::download,
- private val default: String = LISTS_BASE,
) {
+ /** The debloat list source, tellyscope-devices unless the user sets their own. [fetch] stays last, so it can trail. */
+ constructor(dir: File, fetch: suspend (String) -> ByteArray = ::download) : this(dir, LISTS_BASE, fetch)
+
private val lock = Mutex()
private var index: ListIndex? = null
private val picks = File(dir, "picks.tsv")
diff --git a/app/src/test/java/app/tellyscope/LaunchersTest.kt b/app/src/test/java/app/tellyscope/LaunchersTest.kt
index 2956989..4b822dd 100644
--- a/app/src/test/java/app/tellyscope/LaunchersTest.kt
+++ b/app/src/test/java/app/tellyscope/LaunchersTest.kt
@@ -107,7 +107,7 @@ class LaunchersTest {
val index = """{"schema":1,"devices":[],"lists":{"protected":{"file":"lists/protected.json","sha256":"${sha(file)}"}}}""".toByteArray()
val served = mapOf("index.json" to index, "lists/protected.json" to file)
try {
- SharedLists.load(DeviceLists(tmp.newFolder(), { throw IOException("offline") }, DATA_BASE), DeviceLists(tmp.newFolder()) { url -> served[url.removePrefix(LISTS_BASE)] ?: throw IOException("404 $url") }, fresh = true)
+ SharedLists.load(DeviceLists(tmp.newFolder(), DATA_BASE) { throw IOException("offline") }, DeviceLists(tmp.newFolder()) { url -> served[url.removePrefix(LISTS_BASE)] ?: throw IOException("404 $url") }, fresh = true)
assertEquals(ProtectedReason.TV_INPUTS_REMOTE, Protected.reason("org.droidtv.eum"))
assertEquals(ProtectedReason.SETTINGS, Protected.reason("com.android.settings"))
} finally {
@@ -125,7 +125,7 @@ class LaunchersTest {
val data = mapOf("index.json" to index(ours, "launchers.json"), "launchers.json" to ours)
try {
SharedLists.load(
- DeviceLists(tmp.newFolder(), { url -> data[url.removePrefix(DATA_BASE)] ?: throw IOException("404 $url") }, DATA_BASE),
+ DeviceLists(tmp.newFolder(), DATA_BASE) { url -> data[url.removePrefix(DATA_BASE)] ?: throw IOException("404 $url") },
DeviceLists(tmp.newFolder()) { url -> asked += url; source[url.removePrefix(LISTS_BASE)] ?: throw IOException("404 $url") },
fresh = true,
)
diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
index e2f7d27..104a22b 100644
--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt
+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
@@ -1266,7 +1266,7 @@ class ScreenshotTest {
runBlocking {
val online = DeviceLists(dir)
if (online.index() != null) names.forEach { online.logo(it) }
- SharedLists.load(DeviceLists(none, offline, DATA_BASE), DeviceLists(dir, offline))
+ SharedLists.load(DeviceLists(none, DATA_BASE, offline), DeviceLists(dir, offline))
}
try { body() } finally {
SharedLists.reseed()