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.

Play build: updater and launcher download only in src/github

jesse-agent-232611e995689f2
diff --git a/README.md b/README.md
index d69a8c5..5c906f9 100644
--- a/README.md
+++ b/README.md
@@ -121,7 +121,7 @@ Modules: `:app` (the phone app, Kotlin and Jetpack Compose), `:adb` (pure Kotlin
./gradlew :app:installGithubDebug
```
-There are two builds of the same app, as Gradle flavors: `github`, the APK on GitHub releases, and `play`, the Play Store's. The Play build has no update check (Play updates it) and downloads nothing from GitHub: on Fire OS you download Projectivy in your browser and pick the file. The code checks `BuildConfig.PLAY`.
+There are two builds of the same app, as Gradle flavors: `github`, the APK on GitHub releases, and `play`, the Play Store's. The Play build has no update check (Play updates it) and downloads nothing from GitHub: on Fire OS you download Projectivy in your browser and pick the file. The update check and the Projectivy download live in `app/src/github` only, with stubs in `app/src/play`, and every Play build fails if its code names `api.github.com`. What differs on screen checks `BuildConfig.PLAY`. Unit tests run on the `github` build.
## Contributing
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 4e2b801..5e45bf9 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
import com.android.build.api.artifact.SingleArtifact
+import com.android.build.api.variant.HostTestBuilder
+import java.util.zip.ZipFile
import com.android.tools.r8.D8
import com.android.tools.r8.D8Command
import com.android.tools.r8.OutputMode
@@ -41,8 +43,9 @@ android {
}
// Two builds of one app: the same app ID and release key. github is the APK on GitHub releases;
- // play is the Play Store's AAB, with no in-app update and nothing downloaded from GitHub
- // (BuildConfig.PLAY, a constant, so R8 drops that code from it).
+ // play is the Play Store's AAB. The update check and the Projectivy download are in src/github
+ // only, so the Play build never compiles them (src/play has the stubs); BuildConfig.PLAY is for
+ // what differs on screen. checkPlayRelease*NoGitHubApi below proves it on every Play build.
flavorDimensions += "store"
productFlavors {
create("github") {
@@ -183,7 +186,34 @@ abstract class CheckApkSize : DefaultTask() {
}
}
+/**
+ * Fails the build when the Play build's code names GitHub's API. The update check and the Projectivy download,
+ * the only code that calls it, live in src/github; the debloat lists come from raw.githubusercontent.com.
+ */
+abstract class CheckNoGitHubApi : DefaultTask() {
+ @get:InputFiles abstract val archives: ConfigurableFileCollection
+
+ @TaskAction fun check() {
+ val files = archives.asFileTree.files.filter { it.extension == "apk" || it.extension == "aab" }
+ check(files.isNotEmpty()) { "no APK or AAB in ${archives.files}" }
+ for (f in files) {
+ ZipFile(f).use { zip ->
+ for (e in zip.entries().asSequence().filter { it.name.endsWith(".dex") }) {
+ val dex = zip.getInputStream(e).use { it.readBytes() }.decodeToString()
+ check("api.github.com" !in dex) { "${f.name}: ${e.name} names api.github.com, which only the GitHub build may call" }
+ }
+ }
+ logger.lifecycle("${f.name}: no api.github.com")
+ }
+ }
+}
+
androidComponents {
+ // The unit tests cover the GitHub build, which has every path; the Play build's differences are tested there
+ // through the same seams (a pick-only LauncherPick, no Updates), and its code is checked by CheckNoGitHubApi.
+ beforeVariants(selector().withFlavor("store" to "play")) { variant ->
+ variant.hostTests[HostTestBuilder.UNIT_TEST_TYPE]?.enable = false
+ }
onVariants { variant ->
variant.sources.assets?.addGeneratedSourceDirectory(dexLabelHelper, DexLabelHelper::outputDir)
variant.sources.assets?.addGeneratedSourceDirectory(bundleChangelog, BundleChangelog::outputDir)
@@ -195,6 +225,18 @@ androidComponents {
maxBytes = 3_500_000L
}
afterEvaluate { tasks.named("assemble$name") { finalizedBy(sizeCheck) } }
+ if (variant.flavorName == "play") {
+ val apkCheck = tasks.register<CheckNoGitHubApi>("check${name}ApkNoGitHubApi") {
+ archives.from(variant.artifacts.get(SingleArtifact.APK))
+ }
+ val bundleCheck = tasks.register<CheckNoGitHubApi>("check${name}BundleNoGitHubApi") {
+ archives.from(variant.artifacts.get(SingleArtifact.BUNDLE))
+ }
+ afterEvaluate {
+ tasks.named("assemble$name") { finalizedBy(apkCheck) }
+ tasks.named("bundle$name") { finalizedBy(bundleCheck) }
+ }
+ }
}
}
diff --git a/app/src/github/java/app/tellyscope/Store.kt b/app/src/github/java/app/tellyscope/Store.kt
new file mode 100644
index 0000000..1cc8b21
--- /dev/null
+++ b/app/src/github/java/app/tellyscope/Store.kt
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-3.0-only
+
+package app.tellyscope
+
+import android.content.Context
+import app.tellyscope.data.AndroidLauncherDownload
+import app.tellyscope.data.LauncherPick
+import app.tellyscope.data.UpdateCheck
+import app.tellyscope.data.Updates
+import java.io.File
+
+// What the GitHub build has that the Play build doesn't (app/src/play/…/Store.kt): its own update check,
+// and the Fire OS launcher downloaded from its developer's GitHub releases.
+
+/** Every 30 minutes, whether GitHub has a newer release than [version]. Alpha builds install as app.tellyscope.alpha. */
+internal fun updates(context: Context, version: String): Updates? =
+ UpdateCheck(File(context.filesDir, "updates.properties"), version, alpha = context.packageName.endsWith(".alpha"))
+
+/** Downloads a launcher, or checks a file the user picked. */
+internal fun launcherPick(context: Context): LauncherPick = AndroidLauncherDownload(context)
diff --git a/app/src/github/java/app/tellyscope/data/GitHubLauncherDownload.kt b/app/src/github/java/app/tellyscope/data/GitHubLauncherDownload.kt
new file mode 100644
index 0000000..bb585e7
--- /dev/null
+++ b/app/src/github/java/app/tellyscope/data/GitHubLauncherDownload.kt
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-3.0-only
+
+package app.tellyscope.data
+
+import android.content.Context
+import app.tellyscope.adb.Progress
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ensureActive
+import kotlinx.coroutines.withContext
+import org.json.JSONObject
+import java.io.File
+import java.io.IOException
+import java.net.HttpURLConnection
+import java.net.URL
+
+// A launcher downloaded from its developer's GitHub releases: the GitHub build only. The Play build
+// downloads no apps; it checks a file the user picked (AndroidLauncherPick).
+
+/** GitHub's API for [releases]' latest release: `https://github.com/<owner>/<repo>/releases` as the list gives it. */
+private fun latestApi(releases: String) =
+ "https://api.github.com/repos/" + releases.removePrefix("https://github.com/").removeSuffix("/releases") + "/releases/latest"
+
+/**
+ * The latest release from GitHub's API, or null unless it is a full release on [launcher]'s own
+ * repo with exactly one APK, served from that release.
+ */
+fun parseRelease(json: String, launcher: KnownLauncher): LauncherRelease? = runCatching {
+ val r = JSONObject(json)
+ val tag = r.getString("tag_name")
+ val assets = r.getJSONArray("assets")
+ val apk = (0 until assets.length()).map(assets::getJSONObject).singleOrNull { it.getString("name").endsWith(".apk") }
+ val url = apk?.getString("browser_download_url")
+ val size = apk?.getLong("size") ?: 0L
+ LauncherRelease(tag, r.getString("html_url"), url.orEmpty(), size).takeIf {
+ !r.optBoolean("draft") && !r.optBoolean("prerelease") && it.valid(launcher)
+ }
+}.getOrNull()
+
+/** On [launcher]'s own repo, its one APK served from that release, and about the right size. */
+private fun LauncherRelease.valid(launcher: KnownLauncher): Boolean {
+ val releases = launcher.releases ?: return false
+ return page == "$releases/tag/$version" && apk.startsWith("$releases/download/$version/") && size in 1..launcher.maxBytes
+}
+
+/** The tag github.com's `releases/latest` on [releases] redirects to, from its Location; null for anywhere else. */
+fun latestTag(location: String?, releases: String): String? =
+ location?.removePrefix("$releases/tag/")?.takeIf { it != location && it.isNotEmpty() && '/' !in it && '?' !in it }
+
+/** The release page's one APK, from its asset list's links: the full URL, or null unless there is exactly one. */
+fun pageApk(html: String, tag: String, releases: String): String? {
+ val path = releases.removePrefix("https://github.com") + "/download/$tag/"
+ return Regex("href=\"(${Regex.escape(path)}[^\"/?#]+\\.apk)\"").findAll(html).map { it.groupValues[1] }.distinct()
+ .singleOrNull()?.let { "https://github.com$it" }
+}
+
+class AndroidLauncherDownload(context: Context) : AndroidLauncherPick(context), LauncherDownload {
+ /**
+ * From GitHub's API, or, when that is rate-limited, from the release page it links to, which isn't.
+ * Throws [RateLimited] only when the page didn't answer either.
+ */
+ override suspend fun latest(launcher: KnownLauncher): LauncherRelease = withContext(Dispatchers.IO) {
+ val releases = launcher.releases ?: throw IOException("no releases page for ${launcher.pkg}")
+ val limited = try {
+ return@withContext parseRelease(api(releases), launcher) ?: throw IOException("no release of ${launcher.pkg}")
+ } catch (e: RateLimited) {
+ e
+ }
+ runCatching { fromPage(launcher, releases) }.getOrNull() ?: throw limited
+ }
+
+ private fun api(releases: String): String {
+ val c = URL(latestApi(releases)).openConnection() as HttpURLConnection
+ c.connectTimeout = 10_000
+ c.readTimeout = 10_000
+ try {
+ val code = c.responseCode
+ if ((code == 403 || code == 429) && c.getHeaderField("x-ratelimit-remaining") == "0") {
+ throw RateLimited(c.getHeaderField("x-ratelimit-reset")?.toLongOrNull()?.times(1000))
+ }
+ if (code != 200) throw IOException("HTTP $code")
+ return c.inputStream.use { it.readBytes() }.decodeToString()
+ } finally {
+ c.disconnect()
+ }
+ }
+
+ /** `releases/latest` redirects to the tag, whose asset list names the APK; its size comes from the download's own length. */
+ private suspend fun fromPage(launcher: KnownLauncher, releases: String): LauncherRelease? {
+ val c = URL("$releases/latest").openConnection() as HttpURLConnection
+ c.instanceFollowRedirects = false
+ c.connectTimeout = 10_000
+ c.readTimeout = 10_000
+ val tag = try {
+ latestTag(c.takeIf { it.responseCode in 301..302 }?.getHeaderField("Location"), releases)
+ } finally {
+ c.disconnect()
+ } ?: return null
+ val apk = pageApk(download("$releases/expanded_assets/$tag").decodeToString(), tag, releases) ?: return null
+ val head = URL(apk).openConnection() as HttpURLConnection
+ head.requestMethod = "HEAD"
+ head.connectTimeout = 10_000
+ head.readTimeout = 10_000
+ val size = try {
+ head.contentLengthLong.takeIf { head.responseCode == 200 } ?: return null
+ } finally {
+ head.disconnect()
+ }
+ return LauncherRelease(tag, "$releases/tag/$tag", apk, size).takeIf { it.valid(launcher) }
+ }
+
+ override suspend fun fetch(launcher: KnownLauncher, release: LauncherRelease, onProgress: (Progress) -> Unit): PickedApp = withContext(Dispatchers.IO) {
+ dir.deleteRecursively()
+ dir.mkdirs()
+ val file = File(dir, apkName(launcher))
+ val c = URL(release.apk).openConnection() as HttpURLConnection
+ c.connectTimeout = 10_000
+ c.readTimeout = 30_000
+ try {
+ if (c.responseCode != 200) throw IOException("HTTP ${c.responseCode}")
+ c.inputStream.use { input ->
+ file.outputStream().use { out ->
+ val buf = ByteArray(64 * 1024)
+ var done = 0L
+ while (true) {
+ ensureActive()
+ val n = input.read(buf).takeIf { it >= 0 } ?: break
+ done += n
+ if (done > release.size) throw IOException("larger than the release says")
+ out.write(buf, 0, n)
+ onProgress(Progress(done, release.size))
+ }
+ if (done != release.size) throw IOException("download cut short")
+ }
+ }
+ } finally {
+ c.disconnect()
+ }
+ read(file, launcher)
+ }
+}
diff --git a/app/src/main/java/app/tellyscope/data/UpdateCheck.kt b/app/src/github/java/app/tellyscope/data/UpdateCheck.kt
similarity index 90%
rename from app/src/main/java/app/tellyscope/data/UpdateCheck.kt
rename to app/src/github/java/app/tellyscope/data/UpdateCheck.kt
index 4a3f450..3a66c62 100644
--- a/app/src/main/java/app/tellyscope/data/UpdateCheck.kt
+++ b/app/src/github/java/app/tellyscope/data/UpdateCheck.kt
@@ -9,8 +9,6 @@ import org.json.JSONArray
import java.io.File
import java.util.Properties
-/** Where releases are published: the app's own GitHub repo. */
-const val RELEASES = "https://github.com/man15h/tellyscope/releases"
private val REPO = RELEASES.removePrefix("https://github.com/").removeSuffix("/releases")
private const val RELEASES_API = "https://api.github.com/repos/man15h/tellyscope/releases?per_page=20"
@@ -21,29 +19,26 @@ private const val ALPHA_INTERVAL_MS = 5 * 60 * 1000L
/** Tellyscope is about 3 MB; an APK far past that isn't it. */
private const val MAX_APK_BYTES = 64L shl 20
-/** A newer Tellyscope than the one running. [apk] is its release's APK link; null when the release has none this build can install. */
-data class Update(val version: String, val notes: String, val url: String, val apk: String? = null)
-
/**
* Asks GitHub, at most every 30 minutes (5 minutes on alpha builds), whether a newer release is out. No auth and no download: it
* only reads the release list. Off switch and last check live in [file].
- * Release builds look at full releases only; alpha builds at `-alpha` pre-releases too.
+ * Release builds look at full releases only; alpha builds at `-alpha` pre-releases too. GitHub build only.
*/
class UpdateCheck(
private val file: File,
/** The running versionName, alpha suffix included. */
private val current: String,
- val alpha: Boolean,
+ override val alpha: Boolean,
private val clock: () -> Long = System::currentTimeMillis,
private val fetch: suspend (String) -> ByteArray = ::download,
-) {
+) : Updates {
@get:Synchronized @set:Synchronized
- var enabled: Boolean
+ override var enabled: Boolean
get() = props().getProperty("off") != "true"
set(on) = save { if (on) remove("off") else setProperty("off", "true") }
/** The newest release past [current]. Null when off, checked recently, or on any failure. */
- suspend fun check(): Update? = withContext(Dispatchers.IO) {
+ override suspend fun check(): Update? = withContext(Dispatchers.IO) {
val p = props()
if (p.getProperty("off") == "true") return@withContext null
val last = p.getProperty("checked")?.toLongOrNull()
@@ -66,7 +61,7 @@ class UpdateCheck(
* What's new lists releases only, never alphas. Null on any failure. No interval: What's new
* asks only once the check has found an update.
*/
- suspend fun newer(): List<Changelog.Release>? = withContext(Dispatchers.IO) {
+ override suspend fun newer(): List<Changelog.Release>? = withContext(Dispatchers.IO) {
val text = try {
fetch("https://raw.githubusercontent.com/$REPO/main/${Changelog.ASSET}").decodeToString()
} catch (e: CancellationException) {
diff --git a/app/src/main/java/app/tellyscope/ui/UpdateDialog.kt b/app/src/github/java/app/tellyscope/ui/UpdateDialog.kt
similarity index 52%
rename from app/src/main/java/app/tellyscope/ui/UpdateDialog.kt
rename to app/src/github/java/app/tellyscope/ui/UpdateDialog.kt
index 6d4ac42..cbcb632 100644
--- a/app/src/main/java/app/tellyscope/ui/UpdateDialog.kt
+++ b/app/src/github/java/app/tellyscope/ui/UpdateDialog.kt
@@ -1,18 +1,28 @@
// SPDX-License-Identifier: GPL-3.0-only
+// The update and offline icons are the Material Symbols "system_update" and "cloud_off" (Apache-2.0), see NOTICE.
package app.tellyscope.ui
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
@@ -24,6 +34,9 @@ import androidx.compose.ui.unit.dp
import app.tellyscope.R
import app.tellyscope.data.Update
+// The GitHub build's update offer: this dialog and What's new's Update card. The Play build has empty
+// stubs (app/src/play), so none of it is in that app.
+
/**
* A newer release is out. Download APK opens the release's APK in the browser, which downloads it
* for Android's installer; Check release opens its GitHub page.
@@ -74,3 +87,40 @@ internal fun boldSpans(text: String): AnnotatedString = buildAnnotatedString {
if (i % 2 == 1 && i < parts.lastIndex) withStyle(SpanStyle(fontWeight = FontWeight.Bold)) { append(part) } else append(part)
}
}
+
+/** "Tellyscope 0.14.0 is out · You have 0.13.0." Update opens the update check's dialog again. */
+@Composable
+internal fun UpdateCard(available: Update, installed: String, onUpdate: () -> Unit) {
+ Card(Modifier.padding(top = 8.dp), colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primaryContainer)) {
+ Row(Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 12.dp), verticalAlignment = Alignment.CenterVertically) {
+ Icon(SystemUpdate, contentDescription = null, tint = MaterialTheme.colorScheme.onPrimaryContainer)
+ Spacer(Modifier.width(16.dp))
+ Column(Modifier.weight(1f)) {
+ Text(stringResource(R.string.whats_new_update_out, available.version), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.onPrimaryContainer)
+ Text(stringResource(R.string.whats_new_you_have, installed), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onPrimaryContainer)
+ }
+ Spacer(Modifier.width(12.dp))
+ Button(onClick = onUpdate) { Text(stringResource(R.string.whats_new_update)) }
+ }
+ }
+}
+
+/** An update is known, but its versions couldn't be read from GitHub. */
+@Composable
+internal fun NewerFailed() {
+ Row(Modifier.fillMaxWidth().padding(top = 8.dp, start = 4.dp), verticalAlignment = Alignment.CenterVertically) {
+ Icon(CloudOff, contentDescription = null, Modifier.size(20.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)
+ Spacer(Modifier.width(12.dp))
+ Text(stringResource(R.string.whats_new_newer_failed), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ }
+}
+
+private val SystemUpdate = symbol(
+ "SystemUpdate",
+ "M280-40q-33 0-56.5-23.5T200-120v-720q0-33 23.5-56.5T280-920h400q33 0 56.5 23.5T760-840v124q18 7 29 22t11 34v80q0 19-11 34t-29 22v404q0 33-23.5 56.5T680-40H280Zm0-80h400v-720H280v720Zm0 0v-720 720Zm200-200 160-160-56-56-64 62v-166h-80v166l-64-62-56 56 160 160Z",
+)
+
+private val CloudOff = symbol(
+ "CloudOff",
+ "M792-56 686-160H260q-92 0-156-64T40-380q0-77 47.5-137T210-594q3-8 6-15.5t6-16.5L56-792l56-56 736 736-56 56ZM260-240h346L284-562q-2 11-3 21t-1 21h-20q-58 0-99 41t-41 99q0 58 41 99t99 41Zm185-161Zm419 191-58-56q17-14 25.5-32.5T840-340q0-42-29-71t-71-29h-60v-80q0-83-58.5-141.5T480-720q-27 0-52 6.5T380-693l-58-58q35-24 74.5-36.5T480-800q117 0 198.5 81.5T760-520q69 8 114.5 59.5T920-340q0 39-15 72.5T864-210ZM593-479Z",
+)
diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.kt
index 3c92daf..a80dffb 100644
--- a/app/src/main/java/app/tellyscope/MainActivity.kt
+++ b/app/src/main/java/app/tellyscope/MainActivity.kt
@@ -44,7 +44,6 @@ import app.tellyscope.adb.AppFacts
import app.tellyscope.adb.Connector
import app.tellyscope.adb.StatsProfile
import app.tellyscope.data.AdbDeviceSource
-import app.tellyscope.data.AndroidLauncherDownload
import app.tellyscope.data.AndroidPhoneStorage
import app.tellyscope.data.Device
import app.tellyscope.data.DeviceState
@@ -53,7 +52,6 @@ import app.tellyscope.data.FoldBook
import app.tellyscope.data.SeenBook
import app.tellyscope.data.UiText
import app.tellyscope.data.KeyHaptics
-import app.tellyscope.data.UpdateCheck
import app.tellyscope.ui.AccessActions
import app.tellyscope.ui.AccessScreen
import app.tellyscope.ui.AdvancedScreen
@@ -126,15 +124,14 @@ class MainActivity : ComponentActivity() {
TellyscopeViewModel(
scenario?.let(::FakeDeviceSource) ?: AdbDeviceSource(applicationContext),
AndroidPhoneStorage(applicationContext),
- // Play updates the Play build itself, so it has no update check of its own.
- updates = if (scenario != null || BuildConfig.PLAY) null else updateCheck(),
+ // The Play build has none: Play updates it (Store.kt, per flavor).
+ updates = if (scenario != null) null else updates(applicationContext, installedVersion()),
folds = FoldBook(File(filesDir, "folds.properties")),
keyHaptics = KeyHaptics(File(filesDir, "remote.properties")),
gates = FoldBook(File(filesDir, "gates.properties")),
historySeen = SeenBook(File(filesDir, "history-seen.properties")),
appFacts = AppFacts(installedVersion(), "${Build.MANUFACTURER} ${Build.MODEL}, Android ${Build.VERSION.RELEASE}"),
- launcherDownload = if (scenario != null) null else AndroidLauncherDownload(applicationContext),
- play = BuildConfig.PLAY,
+ launcherDownload = if (scenario != null) null else launcherPick(applicationContext),
)
}
},
@@ -150,12 +147,6 @@ class MainActivity : ComponentActivity() {
@Suppress("DEPRECATION") // the flags overload is API 33+
private fun installedVersion() = packageManager.getPackageInfo(packageName, 0).versionName.orEmpty()
- private fun updateCheck(): UpdateCheck {
- val version = installedVersion()
- // Alpha builds install as app.tellyscope.alpha (app/build.gradle.kts).
- return UpdateCheck(File(filesDir, "updates.properties"), version, alpha = packageName.endsWith(".alpha"))
- }
-
/**
* Android 17 blocks LAN connections and mDNS for apps targeting 37 until the user grants
* ACCESS_LOCAL_NETWORK, so nothing scans until then. The view model is created inside
@@ -224,8 +215,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {
val saveFile = rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("application/octet-stream"), vm::saveTo)
val saveScreenshot = rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("image/png"), vm::screenshotTo)
- // Never in the Play build: the constant lets R8 drop the dialog from it.
- if (!BuildConfig.PLAY) state.update?.let { u ->
+ state.update?.let { u ->
UpdateDialog(
u,
onDownload = { vm.updateLater(); u.apk?.let { runCatching { browser.openUri(it) } } },
diff --git a/app/src/main/java/app/tellyscope/data/LauncherDownload.kt b/app/src/main/java/app/tellyscope/data/LauncherDownload.kt
index 06e8f1e..e6be78c 100644
--- a/app/src/main/java/app/tellyscope/data/LauncherDownload.kt
+++ b/app/src/main/java/app/tellyscope/data/LauncherDownload.kt
@@ -7,52 +7,18 @@ import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import androidx.core.content.pm.PackageInfoCompat
-import app.tellyscope.BuildConfig
import app.tellyscope.adb.ApkInfo
import app.tellyscope.adb.Progress
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.withContext
-import org.json.JSONObject
import java.io.File
import java.io.IOException
-import java.net.HttpURLConnection
-import java.net.URL
import java.security.MessageDigest
/** A launcher's latest release: [page] is shown before anything downloads, [apk] is its one APK. */
data class LauncherRelease(val version: String, val page: String, val apk: String, val size: Long)
-/** GitHub's API for [releases]' latest release: `https://github.com/<owner>/<repo>/releases` as the list gives it. */
-private fun latestApi(releases: String) =
- "https://api.github.com/repos/" + releases.removePrefix("https://github.com/").removeSuffix("/releases") + "/releases/latest"
-
-/**
- * The latest release from GitHub's API, or null unless it is a full release on [launcher]'s own
- * repo with exactly one APK, served from that release.
- */
-fun parseRelease(json: String, launcher: KnownLauncher): LauncherRelease? = runCatching {
- val r = JSONObject(json)
- val tag = r.getString("tag_name")
- val assets = r.getJSONArray("assets")
- val apk = (0 until assets.length()).map(assets::getJSONObject).singleOrNull { it.getString("name").endsWith(".apk") }
- val url = apk?.getString("browser_download_url")
- val size = apk?.getLong("size") ?: 0L
- LauncherRelease(tag, r.getString("html_url"), url.orEmpty(), size).takeIf {
- !r.optBoolean("draft") && !r.optBoolean("prerelease") && it.valid(launcher)
- }
-}.getOrNull()
-
-/** On [launcher]'s own repo, its one APK served from that release, and about the right size. */
-private fun LauncherRelease.valid(launcher: KnownLauncher): Boolean {
- val releases = launcher.releases ?: return false
- return page == "$releases/tag/$version" && apk.startsWith("$releases/download/$version/") && size in 1..launcher.maxBytes
-}
-
-/** The tag github.com's `releases/latest` on [releases] redirects to, from its Location; null for anywhere else. */
-fun latestTag(location: String?, releases: String): String? =
- location?.removePrefix("$releases/tag/")?.takeIf { it != location && it.isNotEmpty() && '/' !in it && '?' !in it }
-
/**
* The file [launcher] is saved as: its list name with spaces as `-` and only `[A-Za-z0-9._-]` kept,
* so no `/` or `..` path, at most 64 characters; its package name when nothing is left.
@@ -61,13 +27,6 @@ fun apkName(launcher: KnownLauncher): String =
launcher.name.replace(' ', '-').filter { it.isLetterOrDigit() && it.code < 128 || it in "._-" }.take(64)
.ifEmpty { launcher.pkg } + ".apk"
-/** The release page's one APK, from its asset list's links: the full URL, or null unless there is exactly one. */
-fun pageApk(html: String, tag: String, releases: String): String? {
- val path = releases.removePrefix("https://github.com") + "/download/$tag/"
- return Regex("href=\"(${Regex.escape(path)}[^\"/?#]+\\.apk)\"").findAll(html).map { it.groupValues[1] }.distinct()
- .singleOrNull()?.let { "https://github.com$it" }
-}
-
/**
* GitHub's API turned the lookup down: it allows 60 an hour per network without a login. [until] is
* when it takes them again, epoch millis, when it said.
@@ -77,111 +36,28 @@ class RateLimited(val until: Long?) : IOException("rate-limited")
/** The APK isn't the launcher it should be ([KnownLauncher.accepts]): another package, or not signed by its developer. */
class WrongApk : IOException("not the launcher")
+/** A launcher's APK the user downloaded and picked, checked before anything reaches the TV. Faked in tests. */
+interface LauncherPick {
+ /** Throws [WrongApk], or IOException when it can't be read. */
+ suspend fun open(uri: Uri, launcher: KnownLauncher): PickedApp
+}
+
/**
* Fire OS's way to its launcher: there's no Play Store, so Tellyscope fetches it from its developer's
- * [KnownLauncher.releases]. Faked in tests.
+ * [KnownLauncher.releases] (`AndroidLauncherDownload`, GitHub build only). Faked in tests.
*/
-interface LauncherDownload {
+interface LauncherDownload : LauncherPick {
/** Throws on no network, no [KnownLauncher.releases], or a release that doesn't parse. */
suspend fun latest(launcher: KnownLauncher): LauncherRelease
/** Downloads [release]'s APK and checks it. Throws [WrongApk], or IOException on a failed download. */
suspend fun fetch(launcher: KnownLauncher, release: LauncherRelease, onProgress: (Progress) -> Unit): PickedApp
-
- /** A file the user downloaded and picked, checked the same way. Throws [WrongApk], or IOException when it can't be read. */
- suspend fun open(uri: Uri, launcher: KnownLauncher): PickedApp
}
-class AndroidLauncherDownload(context: Context) : LauncherDownload {
- private val ctx = context.applicationContext
- private val dir get() = File(ctx.cacheDir, "launcher")
-
- /**
- * From GitHub's API, or, when that is rate-limited, from the release page it links to, which isn't.
- * Throws [RateLimited] only when the page didn't answer either.
- */
- override suspend fun latest(launcher: KnownLauncher): LauncherRelease = withContext(Dispatchers.IO) {
- // The Play build downloads no code from outside Play; R8 drops the rest.
- if (BuildConfig.PLAY) throw IOException("not in the Play build")
- val releases = launcher.releases ?: throw IOException("no releases page for ${launcher.pkg}")
- val limited = try {
- return@withContext parseRelease(api(releases), launcher) ?: throw IOException("no release of ${launcher.pkg}")
- } catch (e: RateLimited) {
- e
- }
- runCatching { fromPage(launcher, releases) }.getOrNull() ?: throw limited
- }
-
- private fun api(releases: String): String {
- val c = URL(latestApi(releases)).openConnection() as HttpURLConnection
- c.connectTimeout = 10_000
- c.readTimeout = 10_000
- try {
- val code = c.responseCode
- if ((code == 403 || code == 429) && c.getHeaderField("x-ratelimit-remaining") == "0") {
- throw RateLimited(c.getHeaderField("x-ratelimit-reset")?.toLongOrNull()?.times(1000))
- }
- if (code != 200) throw IOException("HTTP $code")
- return c.inputStream.use { it.readBytes() }.decodeToString()
- } finally {
- c.disconnect()
- }
- }
-
- /** `releases/latest` redirects to the tag, whose asset list names the APK; its size comes from the download's own length. */
- private suspend fun fromPage(launcher: KnownLauncher, releases: String): LauncherRelease? {
- val c = URL("$releases/latest").openConnection() as HttpURLConnection
- c.instanceFollowRedirects = false
- c.connectTimeout = 10_000
- c.readTimeout = 10_000
- val tag = try {
- latestTag(c.takeIf { it.responseCode in 301..302 }?.getHeaderField("Location"), releases)
- } finally {
- c.disconnect()
- } ?: return null
- val apk = pageApk(download("$releases/expanded_assets/$tag").decodeToString(), tag, releases) ?: return null
- val head = URL(apk).openConnection() as HttpURLConnection
- head.requestMethod = "HEAD"
- head.connectTimeout = 10_000
- head.readTimeout = 10_000
- val size = try {
- head.contentLengthLong.takeIf { head.responseCode == 200 } ?: return null
- } finally {
- head.disconnect()
- }
- return LauncherRelease(tag, "$releases/tag/$tag", apk, size).takeIf { it.valid(launcher) }
- }
-
- override suspend fun fetch(launcher: KnownLauncher, release: LauncherRelease, onProgress: (Progress) -> Unit): PickedApp = withContext(Dispatchers.IO) {
- if (BuildConfig.PLAY) throw IOException("not in the Play build")
- dir.deleteRecursively()
- dir.mkdirs()
- val file = File(dir, apkName(launcher))
- val c = URL(release.apk).openConnection() as HttpURLConnection
- c.connectTimeout = 10_000
- c.readTimeout = 30_000
- try {
- if (c.responseCode != 200) throw IOException("HTTP ${c.responseCode}")
- c.inputStream.use { input ->
- file.outputStream().use { out ->
- val buf = ByteArray(64 * 1024)
- var done = 0L
- while (true) {
- ensureActive()
- val n = input.read(buf).takeIf { it >= 0 } ?: break
- done += n
- if (done > release.size) throw IOException("larger than the release says")
- out.write(buf, 0, n)
- onProgress(Progress(done, release.size))
- }
- if (done != release.size) throw IOException("download cut short")
- }
- }
- } finally {
- c.disconnect()
- }
- read(file, launcher)
- }
+/** The pick and the check, which both builds have; the GitHub build's [LauncherDownload] adds the download. */
+open class AndroidLauncherPick(context: Context) : LauncherPick {
+ protected val ctx: Context = context.applicationContext
+ protected val dir get() = File(ctx.cacheDir, "launcher")
override suspend fun open(uri: Uri, launcher: KnownLauncher): PickedApp = withContext(Dispatchers.IO) {
dir.deleteRecursively()
@@ -206,7 +82,7 @@ class AndroidLauncherDownload(context: Context) : LauncherDownload {
}
/** The package manager checks the APK's signature while it reads the certificates. */
- private fun read(file: File, launcher: KnownLauncher): PickedApp {
+ protected fun read(file: File, launcher: KnownLauncher): PickedApp {
val pm = ctx.packageManager
val pkg = if (Build.VERSION.SDK_INT >= 28) {
@Suppress("DEPRECATION") // the flags overload is API 33+
diff --git a/app/src/main/java/app/tellyscope/data/Updates.kt b/app/src/main/java/app/tellyscope/data/Updates.kt
new file mode 100644
index 0000000..f89b09e
--- /dev/null
+++ b/app/src/main/java/app/tellyscope/data/Updates.kt
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-3.0-only
+
+package app.tellyscope.data
+
+/** Where releases are published: the app's own GitHub repo. */
+const val RELEASES = "https://github.com/man15h/tellyscope/releases"
+
+/** A newer Tellyscope than the one running. [apk] is its release's APK link; null when the release has none this build can install. */
+data class Update(val version: String, val notes: String, val url: String, val apk: String? = null)
+
+/**
+ * The app's own update check: `UpdateCheck`, in the GitHub build only (app/src/github). The Play build
+ * has none, since Play updates it.
+ */
+interface Updates {
+ /** An alpha build, which looks at `-alpha` pre-releases too. */
+ val alpha: Boolean
+ var enabled: Boolean
+
+ /** The newest release past the running one. Null when off, checked recently, or on any failure. */
+ suspend fun check(): Update?
+
+ /** The released CHANGELOG sections past the running one, newest first. Null on any failure. */
+ suspend fun newer(): List<Changelog.Release>?
+}
diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
index b50886d..c68cdbe 100644
--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
@@ -36,6 +36,7 @@ import app.tellyscope.data.HistoryEntry
import app.tellyscope.data.KeyHaptics
import app.tellyscope.data.KnownLauncher
import app.tellyscope.data.LauncherDownload
+import app.tellyscope.data.LauncherPick
import app.tellyscope.data.LauncherRelease
import app.tellyscope.data.NetworkInfo
import app.tellyscope.data.NotAnApp
@@ -62,7 +63,7 @@ import app.tellyscope.data.TvTweaks
import app.tellyscope.data.Update
import app.tellyscope.data.FoldBook
import app.tellyscope.data.SeenBook
-import app.tellyscope.data.UpdateCheck
+import app.tellyscope.data.Updates
import app.tellyscope.data.UiText
import app.tellyscope.data.WrongApk
import app.tellyscope.data.why
@@ -419,7 +420,7 @@ class TellyscopeViewModel(
private val storage: PhoneStorage? = null,
private val allowTimeoutMs: Long = 60_000,
private val clock: () -> Long = System::currentTimeMillis,
- private val updates: UpdateCheck? = null,
+ private val updates: Updates? = null,
private val folds: FoldBook? = null,
private val keyHaptics: KeyHaptics? = null,
/** App-wide prompts the user turned off: [DEBLOAT_GATE]. */
@@ -427,12 +428,13 @@ class TellyscopeViewModel(
private val historySeen: SeenBook? = null,
/** This build and phone, for reports. */
private val appFacts: AppFacts = AppFacts("unknown", "unknown phone"),
- /** A launcher's APK from its developer's GitHub, for Fire OS. */
- private val launcherDownload: LauncherDownload? = null,
+ /**
+ * A launcher's APK for Fire OS: a [LauncherDownload] from its developer's GitHub in the GitHub build. The Play
+ * build's only checks a file the user picked.
+ */
+ private val launcherDownload: LauncherPick? = null,
/** `data/`'s address while the launcher list fails its check, or null once it passes. */
private val unverified: () -> String? = { SharedLists.unverified },
- /** The Play build: nothing comes from GitHub, so on Fire OS the launcher is only ever a file the user picks. */
- private val play: Boolean = false,
) : ViewModel() {
private val _state = MutableStateFlow(UiState(now = clock()))
@@ -973,8 +975,11 @@ class TellyscopeViewModel(
private fun setFire(id: String, f: (FireInstall) -> FireInstall) =
updateDevice(id) { d -> d.copy(launcher = d.launcher?.let { l -> l.fire?.let { l.copy(fire = f(it)) } }) }
- /** Download directly is offered beside the Play Store: there's a way to download, as on Fire OS. Never in the Play build. */
- val directDownload get() = launcherDownload != null && !play
+ /** The download, when this build has one: never in the Play build. */
+ private val downloader get() = launcherDownload as? LauncherDownload
+
+ /** Download directly is offered beside the Play Store: there's a way to download, as on Fire OS. */
+ val directDownload get() = downloader != null
/** [pkg]'s entry on the launcher list, when it says how to check its APK: the only launchers installed from one. */
private fun apkLauncher(pkg: String?): KnownLauncher? =
@@ -986,7 +991,7 @@ class TellyscopeViewModel(
*/
fun checkLauncherApk(pkg: String) {
val id = _state.value.selectedId ?: return
- val download = launcherDownload ?: return
+ val download = downloader ?: return
val launcher = apkLauncher(pkg) ?: return
val store = _state.value.device.launcher?.let { it.fire?.store ?: true } ?: return
val list = unverified()
@@ -1014,7 +1019,7 @@ class TellyscopeViewModel(
val fire = flow.fire ?: return false
val list = unverified()
if (list == fire.list) return false
- if (play) setFire(id) { FireInstall(list = list) } else checkLauncherApk(flow.pkg)
+ if (downloader == null) setFire(id) { FireInstall(list = list) } else checkLauncherApk(flow.pkg)
return true
}
@@ -1030,7 +1035,7 @@ class TellyscopeViewModel(
*/
fun installLauncherApk() {
val id = _state.value.selectedId ?: return
- val download = launcherDownload ?: return
+ val download = downloader ?: return
val flow = _state.value.device.launcher ?: return
val launcher = apkLauncher(flow.pkg) ?: return
val release = flow.fire?.takeIf { it.step == FireInstall.Step.Confirm && !it.gated }?.release ?: return
@@ -1063,8 +1068,8 @@ class TellyscopeViewModel(
// The picker answers on its own timing: only from a step that offers it, never over a running install.
val fire = flow.fire ?: return
val step = fire.step
- // The Play build offers it from the start.
- val start = play && step == null
+ // With no download (the Play build), it's offered from the start.
+ val start = downloader == null && step == null
if (!start && step != FireInstall.Step.NoDownload && step != FireInstall.Step.WrongApk && step != FireInstall.Step.Refused) return
if (fire.gated || listChanged(id, flow)) return
launcherJob?.cancel()
diff --git a/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt b/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
index 64d5c03..f3a0c76 100644
--- a/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
+++ b/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
-// The What's new, update and offline icons are the Material Symbols "new_releases", "system_update" and "cloud_off"
-// (Apache-2.0), see NOTICE.
+// The What's new icon is the Material Symbols "new_releases" (Apache-2.0), see NOTICE. The update card is in
+// app/src/github (UpdateDialog.kt).
package app.tellyscope.ui
@@ -23,7 +23,6 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
-import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
@@ -85,7 +84,8 @@ fun rememberChangelog(): List<Release> {
*
* Once the update check has found [available], an Update card opens its offer again, and the
* [newer] sections from GitHub go on top with a Not installed chip. Null [newer] means they
- * couldn't be read: one grey line says so instead.
+ * couldn't be read: one grey line says so instead. The Play build has no update check, so
+ * [available] stays null there and its card is an empty stub.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -167,33 +167,6 @@ private fun VersionHeading(r: Release, isInstalled: Boolean, notInstalled: Boole
}
}
-/** "Tellyscope 0.14.0 is out · You have 0.13.0." Update opens the update check's dialog again. */
-@Composable
-private fun UpdateCard(available: Update, installed: String, onUpdate: () -> Unit) {
- Card(Modifier.padding(top = 8.dp), colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primaryContainer)) {
- Row(Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 12.dp), verticalAlignment = Alignment.CenterVertically) {
- Icon(SystemUpdate, contentDescription = null, tint = MaterialTheme.colorScheme.onPrimaryContainer)
- Spacer(Modifier.width(16.dp))
- Column(Modifier.weight(1f)) {
- Text(stringResource(R.string.whats_new_update_out, available.version), style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.onPrimaryContainer)
- Text(stringResource(R.string.whats_new_you_have, installed), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onPrimaryContainer)
- }
- Spacer(Modifier.width(12.dp))
- Button(onClick = onUpdate) { Text(stringResource(R.string.whats_new_update)) }
- }
- }
-}
-
-/** An update is known, but its versions couldn't be read from GitHub. */
-@Composable
-private fun NewerFailed() {
- Row(Modifier.fillMaxWidth().padding(top = 8.dp, start = 4.dp), verticalAlignment = Alignment.CenterVertically) {
- Icon(CloudOff, contentDescription = null, Modifier.size(20.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)
- Spacer(Modifier.width(12.dp))
- Text(stringResource(R.string.whats_new_newer_failed), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)
- }
-}
-
/** "29 Oct 2026" from the heading's ISO date; the date as written if it isn't one. */
private fun shortDate(iso: String): String =
runCatching { LocalDate.parse(iso).format(DateTimeFormatter.ofPattern("d MMM yyyy", Locale.getDefault())) }.getOrDefault(iso)
@@ -268,18 +241,8 @@ internal val NewReleases = symbol(
"m344-60-76-128-144-32 14-148-98-112 98-112-14-148 144-32 76-128 136 58 136-58 76 128 144 32-14 148 98 112-98 112 14 148-144 32-76 128-136-58-136 58Zm34-102 102-44 104 44 56-96 110-26-10-112 74-84-74-86 10-112-110-24-58-96-102 44-104-44-56 96-110 24 10 112-74 86 74 84-10 114 110 24 58 96Zm102-318Zm-42 142 226-226-56-58-170 170-86-84-56 56 142 142Z",
)
-private fun symbol(name: String, path: String) = ImageVector.Builder(name, 24.dp, 24.dp, 960f, 960f)
+internal fun symbol(name: String, path: String) = ImageVector.Builder(name, 24.dp, 24.dp, 960f, 960f)
.addGroup(translationY = 960f)
.addPath(PathParser().parsePathString(path).toNodes(), pathFillType = PathFillType.NonZero, fill = SolidColor(Color.Black))
.clearGroup()
.build()
-
-private val SystemUpdate = symbol(
- "SystemUpdate",
- "M280-40q-33 0-56.5-23.5T200-120v-720q0-33 23.5-56.5T280-920h400q33 0 56.5 23.5T760-840v124q18 7 29 22t11 34v80q0 19-11 34t-29 22v404q0 33-23.5 56.5T680-40H280Zm0-80h400v-720H280v720Zm0 0v-720 720Zm200-200 160-160-56-56-64 62v-166h-80v166l-64-62-56 56 160 160Z",
-)
-
-private val CloudOff = symbol(
- "CloudOff",
- "M792-56 686-160H260q-92 0-156-64T40-380q0-77 47.5-137T210-594q3-8 6-15.5t6-16.5L56-792l56-56 736 736-56 56ZM260-240h346L284-562q-2 11-3 21t-1 21h-20q-58 0-99 41t-41 99q0 58 41 99t99 41Zm185-161Zm419 191-58-56q17-14 25.5-32.5T840-340q0-42-29-71t-71-29h-60v-80q0-83-58.5-141.5T480-720q-27 0-52 6.5T380-693l-58-58q35-24 74.5-36.5T480-800q117 0 198.5 81.5T760-520q69 8 114.5 59.5T920-340q0 39-15 72.5T864-210ZM593-479Z",
-)
diff --git a/app/src/play/java/app/tellyscope/Store.kt b/app/src/play/java/app/tellyscope/Store.kt
new file mode 100644
index 0000000..8e24cad
--- /dev/null
+++ b/app/src/play/java/app/tellyscope/Store.kt
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-3.0-only
+
+package app.tellyscope
+
+import android.content.Context
+import app.tellyscope.data.AndroidLauncherPick
+import app.tellyscope.data.LauncherPick
+import app.tellyscope.data.Updates
+
+// The Play build's side of app/src/github/…/Store.kt: no update check and no downloads. Play updates the
+// app, and on Fire OS the user downloads the launcher in the browser and picks the file.
+
+@Suppress("UNUSED_PARAMETER")
+internal fun updates(context: Context, version: String): Updates? = null
+
+/** Checks a launcher file the user picked; downloads nothing. */
+internal fun launcherPick(context: Context): LauncherPick = AndroidLauncherPick(context)
diff --git a/app/src/play/java/app/tellyscope/ui/UpdateDialog.kt b/app/src/play/java/app/tellyscope/ui/UpdateDialog.kt
new file mode 100644
index 0000000..60c07e7
--- /dev/null
+++ b/app/src/play/java/app/tellyscope/ui/UpdateDialog.kt
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-3.0-only
+
+package app.tellyscope.ui
+
+import androidx.compose.runtime.Composable
+import app.tellyscope.data.Update
+
+// The Play build has no update check (Play updates it), so it never has an [Update] to offer. These
+// stand in for app/src/github's dialog and What's new card, and draw nothing.
+
+@Suppress("UNUSED_PARAMETER")
+@Composable
+fun UpdateDialog(update: Update, onDownload: () -> Unit, onRelease: () -> Unit, onCancel: () -> Unit) = Unit
+
+@Suppress("UNUSED_PARAMETER")
+@Composable
+internal fun UpdateCard(available: Update, installed: String, onUpdate: () -> Unit) = Unit
+
+@Composable
+internal fun NewerFailed() = Unit
diff --git a/app/src/test/java/app/tellyscope/FireOsTest.kt b/app/src/test/java/app/tellyscope/FireOsTest.kt
index da813ec..3abedef 100644
--- a/app/src/test/java/app/tellyscope/FireOsTest.kt
+++ b/app/src/test/java/app/tellyscope/FireOsTest.kt
@@ -17,6 +17,7 @@ import app.tellyscope.data.FakeDeviceSource
import app.tellyscope.data.HistoryEntry
import app.tellyscope.data.KnownLauncher
import app.tellyscope.data.LauncherDownload
+import app.tellyscope.data.LauncherPick
import app.tellyscope.data.LauncherRelease
import app.tellyscope.data.PickedApp
import app.tellyscope.data.ScanHit
@@ -239,10 +240,11 @@ class FireOsTest {
assertFalse(projectivy.copy(signers = emptySet()).accepts(PROJECTIVY, setOf(SIGNER)))
}
- /** [list]: the launcher list's address, as one that failed its check. [play]: the Play build. */
- private fun TestScope.opened(list: String? = null, play: Boolean = false): TellyscopeViewModel {
+ /** [list]: the launcher list's address, as one that failed its check. [pickOnly]: the Play build's, which checks a picked file and downloads nothing. */
+ private fun TestScope.opened(list: String? = null, pickOnly: Boolean = false): TellyscopeViewModel {
unverified = list
- val v = TellyscopeViewModel(source, clock = { 0L }, launcherDownload = download, unverified = { unverified }, play = play)
+ val pick = if (pickOnly) object : LauncherPick by download {} else download
+ val v = TellyscopeViewModel(source, clock = { 0L }, launcherDownload = pick, unverified = { unverified })
vm = v
runCurrent()
v.openLauncherFlow()
@@ -421,7 +423,7 @@ class FireOsTest {
}
@Test fun thePlayBuildPicksAFileFromTheStartAndDownloadsNothing() = with(test) {
- val v = opened(play = true)
+ val v = opened(pickOnly = true)
assertNull(v.state.value.device.launcher?.fire?.step)
v.pickedLauncherApk(Uri.parse("content://downloads/1"))
runCurrent()
@@ -432,11 +434,11 @@ class FireOsTest {
@Test fun thePlayBuildOffersNoDownloadDirectly() = with(test) {
source = FireTv(androidTv, listOf(store, tvHome))
- assertFalse(opened(play = true).directDownload)
+ assertFalse(opened(pickOnly = true).directDownload)
}
@Test fun inThePlayBuildFromAnUnverifiedListThePickWaitsForTheTick() = with(test) {
- val v = opened(list = UNVERIFIED, play = true)
+ val v = opened(list = UNVERIFIED, pickOnly = true)
assertEquals(true, v.state.value.device.launcher?.fire?.gated)
v.pickedLauncherApk(Uri.parse("content://downloads/1"))
runCurrent()