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.
Update: only offer an APK this build can install, and install after a background download
jesse-agent-232114e8ca30e20
diff --git a/app/src/main/java/app/tellyscope/data/UpdateCheck.kt b/app/src/main/java/app/tellyscope/data/UpdateCheck.ktindex 85176e4..d161f97 100644--- a/app/src/main/java/app/tellyscope/data/UpdateCheck.kt+++ b/app/src/main/java/app/tellyscope/data/UpdateCheck.kt@@ -100,8 +100,9 @@ fun newest(json: String, alpha: Boolean): Update? = runCatching {// A release build never offers an alpha; an alpha build offers both.if (parsed.alpha != null && !alpha) return@mapNotNull nullif (r.optBoolean("prerelease") && parsed.alpha == null) return@mapNotNull null- // Only an APK served from this repo's releases, of a plausible size.- val apk = r.optJSONArray("assets")?.let { a -> (0 until a.length()).map(a::getJSONObject) }.orEmpty()+ // Only an APK served from this repo's releases, of a plausible size, and only one this+ // build can update to: alpha and release builds are different packages with different keys.+ val apk = if ((parsed.alpha != null) != alpha) null else r.optJSONArray("assets")?.let { a -> (0 until a.length()).map(a::getJSONObject) }.orEmpty().singleOrNull { it.optString("name").endsWith(".apk") }?.takeIf { it.optString("browser_download_url").startsWith("$RELEASES/download/") && it.optLong("size") in 1..MAX_SELF_APK_BYTES }Update(version, r.optString("body").trim(), "$RELEASES/tag/v$version", apk?.optString("browser_download_url"), apk?.optLong("size") ?: 0)diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.ktindex 37a4ed4..842ee2d 100644--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt@@ -80,6 +80,7 @@ import kotlinx.coroutines.launchimport kotlinx.coroutines.sync.Muteximport kotlinx.coroutines.sync.withLockimport kotlinx.coroutines.withTimeoutOrNull+import java.io.Fileimport java.text.SimpleDateFormatimport java.util.Dateimport java.util.Locale@@ -483,6 +484,8 @@ class TellyscopeViewModel(private var launcherJob: Job? = nullprivate var updateJob: Job? = nullprivate var selfUpdateJob: Job? = null+ /** An update downloaded while the app was in the background, for the installer on return. */+ private var readyApk: File? = null/** The clock and the device refresh, every second. */private var tickJob: Job? = null/** In the background since [pause]; [resume] starts everything again. */@@ -1832,9 +1835,10 @@ class TellyscopeViewModel(_state.update { it.copy(updating = Updating.Failed) }return@launch}- // Android's own confirm takes over from here.+ // Android's own confirm takes over from here. Android 10+ blocks it from the background+ // without a word, so a download that ends there waits for the app to come back._state.update { it.copy(update = null, updating = null) }- runCatching { s.install(apk) }+ if (paused) readyApk = apk else runCatching { s.install(apk) }}}@@ -1843,8 +1847,12 @@ class TellyscopeViewModel(runCatching { selfUpdate?.openSettings() }}- /** Back in the app: if the user just allowed installs, the download starts without a second tap. */+ /**+ * Back in the app: a download that finished in the background goes to the installer now, and if+ * the user just allowed installs, the download starts without a second tap.+ */fun resumeUpdate() {+ readyApk?.let { apk -> readyApk = null; runCatching { selfUpdate?.install(apk) } }if (_state.value.updating == Updating.Allow && selfUpdate?.allowed() == true) startUpdate()}diff --git a/app/src/test/java/app/tellyscope/UpdateCheckTest.kt b/app/src/test/java/app/tellyscope/UpdateCheckTest.ktindex 03c0e4c..76f74f8 100644--- a/app/src/test/java/app/tellyscope/UpdateCheckTest.kt+++ b/app/src/test/java/app/tellyscope/UpdateCheckTest.kt@@ -83,6 +83,10 @@ class UpdateCheckTest {assertNull(newest(withAsset("https://example.com/Tellyscope-0.2.0.apk", 3_000_000), alpha = false)?.apk)assertNull(newest(withAsset(base + "Tellyscope-0.2.0.apk", 0), alpha = false)?.apk)assertNull(newest(releases(release("v0.2.0")), alpha = false)?.apk)+ // An alpha build is a different package: it's offered the release, but only its page.+ val offered = newest(withAsset(base + "Tellyscope-0.2.0.apk", 3_000_000), alpha = true)+ assertEquals("0.2.0", offered?.version)+ assertNull(offered?.apk)}@Test fun `nothing when the running version is the newest`() = runTest {