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.

Update from inside the app, and read main's CHANGELOG on every build

jesse-agent-2329b30faf12681
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2deb4e7..18dda5b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,8 @@ until this file has a section for its version.
## Unreleased
- **New:** Spanish, Chinese, Japanese and Russian translations, machine-made; corrections welcome. [#272](../../pull/272)
-- **New:** Settings › What's new shows what changed in each version, and what an update brings. [#271](../../pull/271)
+- **New:** Settings › What's new shows each version's changes, and what an update brings. [#271](../../pull/271)
+- **New:** Update installs a new version from inside the app; Android asks first. [#271](../../pull/271)
- **Improved:** Tweaks shows the same TV-offline screen as Files. [#273](../../pull/273)
- **Fixed:** With the TV away, app rows grey out and won't open. [#273](../../pull/273)
- **Fixed:** Connect says when the phone has dropped off Wi-Fi, and Try again waits for Wi-Fi instead of failing at once. [#274](../../pull/274)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f4702a0..9faaa6d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -7,6 +7,8 @@
<!-- Android 17 blocks every connection to LAN addresses (and mDNS) for apps targeting 37
without this runtime permission. The UI must request it before the first scan. -->
<uses-permission android:name="android.permission.ACCESS_LOCAL_NETWORK" />
+ <!-- Update from inside the app: the release's APK goes to Android's installer, which asks first. -->
+ <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application
android:allowBackup="false"
@@ -24,6 +26,15 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <provider
+ android:name="androidx.core.content.FileProvider"
+ android:authorities="${applicationId}.updates"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/self_update_paths" />
+ </provider>
</application>
</manifest>
diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.kt
index 79b8bfd..da7e98d 100644
--- a/app/src/main/java/app/tellyscope/MainActivity.kt
+++ b/app/src/main/java/app/tellyscope/MainActivity.kt
@@ -45,6 +45,7 @@ import app.tellyscope.adb.Connector
import app.tellyscope.adb.StatsProfile
import app.tellyscope.data.AdbDeviceSource
import app.tellyscope.data.AndroidLauncherDownload
+import app.tellyscope.data.AndroidSelfUpdate
import app.tellyscope.data.AndroidPhoneStorage
import app.tellyscope.data.Device
import app.tellyscope.data.DeviceState
@@ -133,6 +134,7 @@ class MainActivity : ComponentActivity() {
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),
+ selfUpdate = if (scenario != null) null else AndroidSelfUpdate(applicationContext),
)
}
},
@@ -223,11 +225,19 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {
val saveScreenshot = rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("image/png"), vm::screenshotTo)
state.update?.let { u ->
- UpdateDialog(u, onGet = { vm.updateLater(); runCatching { browser.openUri(u.url) } }, onLater = vm::updateLater, onSkip = vm::skipUpdate)
+ UpdateDialog(
+ u, state.updating,
+ onUpdate = vm::startUpdate,
+ onRelease = { vm.updateLater(); runCatching { browser.openUri(u.url) } },
+ onCancel = vm::updateLater,
+ onOpenSettings = vm::openInstallSettings,
+ onBack = vm::backToOffer,
+ )
}
// On every return to the app, not just a cold start; the check itself enforces the interval.
- LifecycleEventEffect(Lifecycle.Event.ON_RESUME) { vm.checkForUpdate() }
+ // Back from Install unknown apps with it allowed, the update download starts.
+ LifecycleEventEffect(Lifecycle.Event.ON_RESUME) { vm.checkForUpdate(); vm.resumeUpdate() }
// In the background nothing reads the TVs or sweeps the LAN; back on screen, everything picks up again.
LifecycleEventEffect(Lifecycle.Event.ON_STOP) { vm.pause() }
LifecycleEventEffect(Lifecycle.Event.ON_START) { vm.resume() }
diff --git a/app/src/main/java/app/tellyscope/data/SelfUpdate.kt b/app/src/main/java/app/tellyscope/data/SelfUpdate.kt
new file mode 100644
index 0000000..d04cd49
--- /dev/null
+++ b/app/src/main/java/app/tellyscope/data/SelfUpdate.kt
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-3.0-only
+
+package app.tellyscope.data
+
+import android.content.Context
+import android.content.Intent
+import android.net.Uri
+import android.provider.Settings
+import androidx.core.content.FileProvider
+import app.tellyscope.adb.Progress
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ensureActive
+import kotlinx.coroutines.withContext
+import java.io.File
+import java.io.IOException
+import java.net.HttpURLConnection
+import java.net.URL
+
+/** Tellyscope is about 3 MB; anything far past that isn't it. */
+internal const val MAX_SELF_APK_BYTES = 64L shl 20
+
+/**
+ * Update from inside the app: the release's APK comes from GitHub and goes to Android's installer,
+ * which asks the user to confirm and refuses an APK not signed like the installed app.
+ */
+interface SelfUpdate {
+ /** "Install unknown apps" is on for this app. */
+ fun allowed(): Boolean
+
+ /** Android's Install unknown apps page for this app. */
+ fun openSettings()
+
+ suspend fun fetch(update: Update, onProgress: (Progress) -> Unit): File
+
+ /** Hands [apk] to Android's installer. */
+ fun install(apk: File)
+}
+
+class AndroidSelfUpdate(context: Context) : SelfUpdate {
+ private val ctx = context.applicationContext
+ private val dir get() = File(ctx.cacheDir, "update")
+
+ override fun allowed() = ctx.packageManager.canRequestPackageInstalls()
+
+ override fun openSettings() {
+ ctx.startActivity(
+ Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:${ctx.packageName}")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
+ )
+ }
+
+ override suspend fun fetch(update: Update, onProgress: (Progress) -> Unit): File = withContext(Dispatchers.IO) {
+ val url = update.apk ?: throw IOException("no APK in the release")
+ dir.deleteRecursively()
+ dir.mkdirs()
+ val file = File(dir, "tellyscope.apk")
+ val c = URL(url).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 > update.size) throw IOException("larger than the release says")
+ out.write(buf, 0, n)
+ onProgress(Progress(done, update.size))
+ }
+ if (done != update.size) throw IOException("download cut short")
+ }
+ }
+ } finally {
+ c.disconnect()
+ }
+ // The installer checks the signature; this only makes sure it's this app at the offered version.
+ @Suppress("DEPRECATION") // the flags overload is API 33+
+ val pkg = ctx.packageManager.getPackageArchiveInfo(file.path, 0)
+ if (pkg == null || pkg.packageName != ctx.packageName || pkg.versionName != update.version) throw IOException("not Tellyscope ${update.version}")
+ file
+ }
+
+ override fun install(apk: File) {
+ val uri = FileProvider.getUriForFile(ctx, "${ctx.packageName}.updates", apk)
+ ctx.startActivity(
+ Intent(Intent.ACTION_VIEW).setDataAndType(uri, "application/vnd.android.package-archive")
+ .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK),
+ )
+ }
+}
diff --git a/app/src/main/java/app/tellyscope/data/UpdateCheck.kt b/app/src/main/java/app/tellyscope/data/UpdateCheck.kt
index 0878ef1..85176e4 100644
--- a/app/src/main/java/app/tellyscope/data/UpdateCheck.kt
+++ b/app/src/main/java/app/tellyscope/data/UpdateCheck.kt
@@ -18,12 +18,12 @@ private const val RELEASES_API = "https://api.github.com/repos/man15h/tellyscope
private const val RELEASE_INTERVAL_MS = 30 * 60 * 1000L
private const val ALPHA_INTERVAL_MS = 5 * 60 * 1000L
-/** A newer Tellyscope than the one running. */
-data class Update(val version: String, val notes: String, val url: String)
+/** A newer Tellyscope than the one running. [apk] is its release's APK, [size] bytes; null when the release has none. */
+data class Update(val version: String, val notes: String, val url: String, val apk: String? = null, val size: Long = 0)
/**
* 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, last check and a skipped version live in [file].
+ * 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.
*/
class UpdateCheck(
@@ -39,10 +39,7 @@ class UpdateCheck(
get() = props().getProperty("off") != "true"
set(on) = save { if (on) remove("off") else setProperty("off", "true") }
- @Synchronized
- fun skip(version: String) = save { setProperty("skip", version) }
-
- /** The newest release past [current], unless it was skipped. Null when off, checked recently, or on any failure. */
+ /** The newest release past [current]. Null when off, checked recently, or on any failure. */
suspend fun check(): Update? = withContext(Dispatchers.IO) {
val p = props()
if (p.getProperty("off") == "true") return@withContext null
@@ -58,17 +55,17 @@ class UpdateCheck(
return@withContext null
}
save { setProperty("checked", now.toString()) }
- newest(text, alpha)?.takeIf { compareVersions(it.version, current) > 0 && it.version != p.getProperty("skip") }
+ newest(text, alpha)?.takeIf { compareVersions(it.version, current) > 0 }
}
/**
- * The released CHANGELOG sections past [current], newest first, read from the branch this build
- * updates from: `main`, or `dev` on alpha builds. Null on any failure. No interval: What's new
+ * The released CHANGELOG sections past [current], newest first, read from `main` on every build:
+ * 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) {
val text = try {
- fetch("https://raw.githubusercontent.com/$REPO/${if (alpha) "dev" else "main"}/${Changelog.ASSET}").decodeToString()
+ fetch("https://raw.githubusercontent.com/$REPO/main/${Changelog.ASSET}").decodeToString()
} catch (e: CancellationException) {
throw e
} catch (_: Exception) {
@@ -103,7 +100,11 @@ 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 null
if (r.optBoolean("prerelease") && parsed.alpha == null) return@mapNotNull null
- Update(version, r.optString("body").trim(), "$RELEASES/tag/v$version")
+ // 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()
+ .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)
}
.maxWithOrNull { a, b -> compareVersions(a.version, b.version) }
}.getOrNull()
diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
index 64776cc..37a4ed4 100644
--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
@@ -62,6 +62,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.SelfUpdate
import app.tellyscope.data.UpdateCheck
import app.tellyscope.data.UiText
import app.tellyscope.data.why
@@ -281,6 +282,13 @@ data class FilesUi(
data class TransferUi(val name: String, val toTv: Boolean, val folder: TvFolder, val progress: Progress? = null)
+/** The update dialog after Update: allow installs first, then the download, or why it stopped. */
+sealed interface Updating {
+ data object Allow : Updating
+ data class Downloading(val progress: Progress) : Updating
+ data object Failed : Updating
+}
+
data class UiState(
val scan: ScanUi = ScanUi(),
val devices: List<Device> = emptyList(),
@@ -299,6 +307,8 @@ data class UiState(
val alphaBuild: Boolean = false,
/** A newer release to offer; cleared once the user answers. */
val update: Update? = null,
+ /** How far Update has got with [update]; null while it is only offered. */
+ val updating: Updating? = null,
/** The newest release the last check found; unlike [update] it stays after Later, for What's new. */
val available: Update? = null,
/** What's new's CHANGELOG sections past the installed version, once [available] is set: empty until read, null if they couldn't be. */
@@ -408,6 +418,8 @@ class TellyscopeViewModel(
private val appFacts: AppFacts = AppFacts("unknown", "unknown phone"),
/** Projectivy from its developer's GitHub, for Fire OS. */
private val launcherDownload: LauncherDownload? = null,
+ /** Update from inside the app; null in screenshots and tests. */
+ private val selfUpdate: SelfUpdate? = null,
) : ViewModel() {
private val _state = MutableStateFlow(UiState(now = clock()))
@@ -470,6 +482,7 @@ class TellyscopeViewModel(
/** Watches the TV for a launcher's install from the Play Store. */
private var launcherJob: Job? = null
private var updateJob: Job? = null
+ private var selfUpdateJob: Job? = null
/** The clock and the device refresh, every second. */
private var tickJob: Job? = null
/** In the background since [pause]; [resume] starts everything again. */
@@ -1791,16 +1804,53 @@ class TellyscopeViewModel(
}
}
- /** "Get it" or "Later": the offer goes away until the next check. */
+ /** "Get new release" or "Cancel": the offer goes away until the next check, and a download stops. */
fun updateLater() {
- _state.update { it.copy(update = null) }
+ selfUpdateJob?.cancel()
+ _state.update { it.copy(update = null, updating = null) }
+ }
+
+ /**
+ * Update: downloads the release's APK and hands it to Android's installer. The first time,
+ * Android has to allow this app to install, so the dialog asks for that first.
+ */
+ fun startUpdate() {
+ val s = selfUpdate ?: return
+ val u = _state.value.update ?: return
+ if (!s.allowed()) {
+ _state.update { it.copy(updating = Updating.Allow) }
+ return
+ }
+ selfUpdateJob?.cancel()
+ _state.update { it.copy(updating = Updating.Downloading(Progress(0, u.size))) }
+ selfUpdateJob = viewModelScope.launch {
+ val apk = try {
+ s.fetch(u) { p -> _state.update { it.copy(updating = Updating.Downloading(p)) } }
+ } catch (e: CancellationException) {
+ throw e
+ } catch (_: Exception) {
+ _state.update { it.copy(updating = Updating.Failed) }
+ return@launch
+ }
+ // Android's own confirm takes over from here.
+ _state.update { it.copy(update = null, updating = null) }
+ runCatching { s.install(apk) }
+ }
+ }
+
+ /** "Open settings": Android's Install unknown apps page; back from it, [resumeUpdate] goes on. */
+ fun openInstallSettings() {
+ runCatching { selfUpdate?.openSettings() }
+ }
+
+ /** Back in the app: if the user just allowed installs, the download starts without a second tap. */
+ fun resumeUpdate() {
+ if (_state.value.updating == Updating.Allow && selfUpdate?.allowed() == true) startUpdate()
}
- /** "Skip this version": never offered again; a later release still is. */
- fun skipUpdate() {
- val version = _state.value.update?.version ?: return
- _state.update { it.copy(update = null, available = null) }
- viewModelScope.launch(Dispatchers.IO) { updates?.skip(version) }
+ /** "Cancel" on the Allow step: back to the offer. */
+ fun backToOffer() {
+ _state.update { it.copy(updating = null) }
}
/** What's new's Update card: the update check's offer again. */
diff --git a/app/src/main/java/app/tellyscope/ui/UpdateDialog.kt b/app/src/main/java/app/tellyscope/ui/UpdateDialog.kt
index fdee7a1..774bb8e 100644
--- a/app/src/main/java/app/tellyscope/ui/UpdateDialog.kt
+++ b/app/src/main/java/app/tellyscope/ui/UpdateDialog.kt
@@ -2,13 +2,20 @@
package app.tellyscope.ui
+import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
+import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
+import androidx.compose.material3.Icon
+import androidx.compose.material3.LinearWavyProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
@@ -23,27 +30,85 @@ import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import app.tellyscope.R
import app.tellyscope.data.Update
+import app.tellyscope.data.resolve
-/** A newer release is out. Get it opens its GitHub page; the app never downloads it itself. */
+/**
+ * A newer release is out. Update downloads its APK inside the app and hands it to Android's
+ * installer; Get new release opens its GitHub page instead. [updating] is how far Update got.
+ */
+@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
-fun UpdateDialog(update: Update, onGet: () -> Unit, onLater: () -> Unit, onSkip: () -> Unit) {
- AlertDialog(
- onDismissRequest = onLater,
- title = { Text(stringResource(R.string.update_title, update.version)) },
- text = {
- Column(Modifier.heightIn(max = 320.dp).verticalScroll(rememberScrollState())) {
- Text(boldSpans(dialogNotes(update.notes, stringResource(R.string.update_more_notes)).ifEmpty { stringResource(R.string.update_no_notes) }), style = MaterialTheme.typography.bodyMedium)
- }
- },
- // Three actions stack full width.
- confirmButton = {
- Column(Modifier.fillMaxWidth()) {
- Button(onClick = onGet, Modifier.fillMaxWidth()) { Text(stringResource(R.string.update_get)) }
- TextButton(onClick = onSkip, Modifier.fillMaxWidth()) { Text(stringResource(R.string.update_skip)) }
- TextButton(onClick = onLater, Modifier.fillMaxWidth()) { Text(stringResource(R.string.update_later)) }
- }
- },
- )
+fun UpdateDialog(
+ update: Update,
+ updating: Updating?,
+ onUpdate: () -> Unit,
+ onRelease: () -> Unit,
+ onCancel: () -> Unit,
+ onOpenSettings: () -> Unit,
+ onBack: () -> Unit,
+) {
+ when (updating) {
+ null -> AlertDialog(
+ onDismissRequest = onCancel,
+ title = { Text(stringResource(R.string.update_title, update.version)) },
+ text = {
+ Column(Modifier.heightIn(max = 320.dp).verticalScroll(rememberScrollState())) {
+ Text(boldSpans(dialogNotes(update.notes, stringResource(R.string.update_more_notes)).ifEmpty { stringResource(R.string.update_no_notes) }), style = MaterialTheme.typography.bodyMedium)
+ }
+ },
+ // Three actions stack full width; without an APK in the release, only its page is left.
+ confirmButton = {
+ Column(Modifier.fillMaxWidth()) {
+ if (update.apk != null) {
+ Button(onClick = onUpdate, Modifier.fillMaxWidth()) { Text(stringResource(R.string.update_install)) }
+ TextButton(onClick = onRelease, Modifier.fillMaxWidth()) { Text(stringResource(R.string.update_release)) }
+ } else {
+ Button(onClick = onRelease, Modifier.fillMaxWidth()) { Text(stringResource(R.string.update_release)) }
+ }
+ TextButton(onClick = onCancel, Modifier.fillMaxWidth()) { Text(stringResource(R.string.update_cancel)) }
+ }
+ },
+ )
+ Updating.Allow -> AlertDialog(
+ onDismissRequest = onBack,
+ icon = { Icon(SystemUpdate, contentDescription = null) },
+ title = { Text(stringResource(R.string.update_allow_title)) },
+ text = { Text(boldSpans(stringResource(R.string.update_allow_text)), style = MaterialTheme.typography.bodyMedium) },
+ confirmButton = { Button(onClick = onOpenSettings) { Text(stringResource(R.string.update_open_settings)) } },
+ dismissButton = { TextButton(onClick = onBack) { Text(stringResource(R.string.update_cancel)) } },
+ )
+ is Updating.Downloading -> AlertDialog(
+ onDismissRequest = onCancel,
+ title = { Text(stringResource(R.string.update_downloading, update.version)) },
+ text = {
+ val p = updating.progress
+ Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
+ val fraction = p.fraction
+ if (fraction != null) LinearWavyProgressIndicator(progress = { fraction }, Modifier.fillMaxWidth())
+ else LinearWavyProgressIndicator(Modifier.fillMaxWidth())
+ Text(
+ stringResource(R.string.update_of, Copy.bytes(p.done).resolve(), Copy.bytes(p.total ?: update.size).resolve()),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ },
+ confirmButton = { TextButton(onClick = onCancel) { Text(stringResource(R.string.update_cancel)) } },
+ )
+ Updating.Failed -> AlertDialog(
+ onDismissRequest = onCancel,
+ icon = { Icon(Icons.Default.Warning, contentDescription = null, tint = MaterialTheme.colorScheme.error) },
+ title = { Text(stringResource(R.string.update_failed_title, update.version)) },
+ text = { Text(stringResource(R.string.update_failed_text), style = MaterialTheme.typography.bodyMedium) },
+ confirmButton = { Button(onClick = onUpdate) { Text(stringResource(R.string.update_try_again)) } },
+ dismissButton = {
+ Row {
+ TextButton(onClick = onCancel) { Text(stringResource(R.string.update_cancel)) }
+ TextButton(onClick = onRelease) { Text(stringResource(R.string.update_release)) }
+ }
+ },
+ )
+ }
}
/**
diff --git a/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt b/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
index 64d5c03..ea8fd97 100644
--- a/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
+++ b/app/src/main/java/app/tellyscope/ui/WhatsNewScreen.kt
@@ -274,7 +274,7 @@ private fun symbol(name: String, path: String) = ImageVector.Builder(name, 24.dp
.clearGroup()
.build()
-private val SystemUpdate = symbol(
+internal 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",
)
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 42c8228..758c577 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -981,8 +981,8 @@
<string name="settings_title">Ajustes</string>
<string name="settings_back_to_tv">Volver a la página de la TV</string>
<string name="settings_check_updates">Buscar actualizaciones</string>
- <string name="settings_check_updates_alpha">En las versiones alfa, pregunta a GitHub cada 5 minutos si hay una versión nueva de Tellyscope. No se descarga nada.</string>
- <string name="settings_check_updates_release">Cada 30 minutos, pregunta a GitHub si hay una versión nueva de Tellyscope. No se descarga nada.</string>
+ <string name="settings_check_updates_alpha">En las versiones alfa, pregunta a GitHub cada 5 minutos si hay una versión nueva de Tellyscope. No se descarga nada hasta que tocas Actualizar.</string>
+ <string name="settings_check_updates_release">Cada 30 minutos, pregunta a GitHub si hay una versión nueva de Tellyscope. No se descarga nada hasta que tocas Actualizar.</string>
<string name="settings_key_haptics">Vibrar al pulsar teclas</string>
<string name="settings_key_haptics_text">Una vibración corta por cada tecla del control remoto.</string>
<string name="settings_report">Informar de un problema</string>
@@ -1140,9 +1140,17 @@
<string name="update_title">🎉 Ya está disponible Tellyscope %1$s</string>
<string name="update_no_notes">No hay notas de la versión.</string>
<string name="update_more_notes">…y más en GitHub</string>
- <string name="update_get">Descargar</string>
- <string name="update_skip">Omitir esta versión</string>
- <string name="update_later">Más tarde</string>
+ <string name="update_install">Actualizar</string>
+ <string name="update_release">Ver la nueva versión</string>
+ <string name="update_cancel">Cancelar</string>
+ <string name="update_allow_title">¿Permitir que Tellyscope instale actualizaciones?</string>
+ <string name="update_allow_text">Android lo pregunta una sola vez. En la siguiente pantalla, activa **Permitir de esta fuente** y vuelve aquí.\n\nAndroid sigue pidiéndote que confirmes cada actualización y solo acepta una firmada igual que el Tellyscope que tienes.</string>
+ <string name="update_open_settings">Abrir ajustes</string>
+ <string name="update_downloading">Descargando %1$s</string>
+ <string name="update_of">%1$s de %2$s</string>
+ <string name="update_failed_title">No se pudo descargar %1$s</string>
+ <string name="update_failed_text">Comprueba que el teléfono tiene conexión y vuelve a intentarlo, o descárgala desde la página de la versión en GitHub.</string>
+ <string name="update_try_again">Reintentar</string>
<string name="welcome_skip">Omitir</string>
<string name="welcome_title">Te damos la bienvenida a Tellyscope</string>
<string name="welcome_text">Mira qué se está ejecutando en tu Android TV y desactiva las apps que no necesitas. Todo desde tu teléfono, por Wi-Fi.</string>
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 1ffb648..a05f755 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -897,8 +897,8 @@
<string name="settings_title">設定</string>
<string name="settings_back_to_tv">テレビのページに戻る</string>
<string name="settings_check_updates">アップデートを確認</string>
- <string name="settings_check_updates_alpha">アルファ版では 5 分ごとに、新しい Tellyscope が公開されているかを GitHub に確認します。何もダウンロードされません。</string>
- <string name="settings_check_updates_release">30 分ごとに、新しい Tellyscope が公開されているかを GitHub に確認します。何もダウンロードされません。</string>
+ <string name="settings_check_updates_alpha">アルファ版では 5 分ごとに、新しい Tellyscope が公開されているかを GitHub に確認します。「アップデート」をタップするまで何もダウンロードされません。</string>
+ <string name="settings_check_updates_release">30 分ごとに、新しい Tellyscope が公開されているかを GitHub に確認します。「アップデート」をタップするまで何もダウンロードされません。</string>
<string name="settings_key_haptics">キーを押したときに振動</string>
<string name="settings_key_haptics_text">リモコンのキーごとに短く振動します。</string>
<string name="settings_report">問題を報告</string>
@@ -1052,9 +1052,17 @@
<string name="update_title">🎉 Tellyscope %1$s が公開されました</string>
<string name="update_no_notes">リリースノートはありません。</string>
<string name="update_more_notes">…その他は GitHub で</string>
- <string name="update_get">入手</string>
- <string name="update_skip">このバージョンをスキップ</string>
- <string name="update_later">後で</string>
+ <string name="update_install">アップデート</string>
+ <string name="update_release">新しいリリースを入手</string>
+ <string name="update_cancel">キャンセル</string>
+ <string name="update_allow_title">Tellyscope にアップデートのインストールを許可しますか?</string>
+ <string name="update_allow_text">Android が確認するのは一度だけです。次の画面で「**この提供元のアプリを許可**」をオンにして、ここに戻ってください。\n\nアップデートのたびに Android が確認を求めます。また、今お使いの Tellyscope と同じ署名のものしか受け付けません。</string>
+ <string name="update_open_settings">設定を開く</string>
+ <string name="update_downloading">%1$s をダウンロード中</string>
+ <string name="update_of">%1$s / %2$s</string>
+ <string name="update_failed_title">%1$s をダウンロードできませんでした</string>
+ <string name="update_failed_text">スマートフォンがオンラインか確認してもう一度お試しいただくか、GitHub のリリースページから入手してください。</string>
+ <string name="update_try_again">再試行</string>
<string name="welcome_skip">スキップ</string>
<string name="welcome_title">Tellyscope へようこそ</string>
<string name="welcome_text">Android TV で実行中のアプリを確認し、不要なアプリを無効にできます。すべてスマートフォンから Wi-Fi 経由で操作できます。</string>
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 893d3f0..f746b4b 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -1023,8 +1023,8 @@
<string name="settings_title">Настройки</string>
<string name="settings_back_to_tv">Назад к странице телевизора</string>
<string name="settings_check_updates">Проверять обновления</string>
- <string name="settings_check_updates_alpha">В альфа-сборках каждые 5 минут спрашивать у GitHub, вышла ли новая версия Tellyscope. Ничего не скачивается.</string>
- <string name="settings_check_updates_release">Каждые 30 минут спрашивать у GitHub, вышла ли новая версия Tellyscope. Ничего не скачивается.</string>
+ <string name="settings_check_updates_alpha">В альфа-сборках каждые 5 минут спрашивать у GitHub, вышла ли новая версия Tellyscope. Ничего не скачивается, пока вы не нажмёте «Обновить».</string>
+ <string name="settings_check_updates_release">Каждые 30 минут спрашивать у GitHub, вышла ли новая версия Tellyscope. Ничего не скачивается, пока вы не нажмёте «Обновить».</string>
<string name="settings_key_haptics">Вибрация при нажатии</string>
<string name="settings_key_haptics_text">Короткий отклик на каждую кнопку пульта.</string>
<string name="settings_report">Сообщить о проблеме</string>
@@ -1184,9 +1184,17 @@
<string name="update_title">🎉 Вышла версия Tellyscope %1$s</string>
<string name="update_no_notes">Нет описания изменений.</string>
<string name="update_more_notes">…и многое другое на GitHub</string>
- <string name="update_get">Скачать</string>
- <string name="update_skip">Пропустить эту версию</string>
- <string name="update_later">Позже</string>
+ <string name="update_install">Обновить</string>
+ <string name="update_release">Открыть новую версию</string>
+ <string name="update_cancel">Отмена</string>
+ <string name="update_allow_title">Разрешить Tellyscope устанавливать обновления?</string>
+ <string name="update_allow_text">Android спросит только один раз. На следующем экране включите **Разрешить установку из этого источника** и вернитесь сюда.\n\nAndroid всё равно попросит подтвердить каждое обновление и примет только версию с той же подписью, что у вашего Tellyscope.</string>
+ <string name="update_open_settings">Открыть настройки</string>
+ <string name="update_downloading">Загрузка %1$s</string>
+ <string name="update_of">%1$s из %2$s</string>
+ <string name="update_failed_title">Не удалось загрузить %1$s</string>
+ <string name="update_failed_text">Проверьте подключение телефона к сети и повторите попытку или скачайте версию со страницы релиза на GitHub.</string>
+ <string name="update_try_again">Повторить</string>
<string name="welcome_skip">Пропустить</string>
<string name="welcome_title">Добро пожаловать в Tellyscope</string>
<string name="welcome_text">Смотрите, что запущено на Android TV, и отключайте ненужные приложения. Все с телефона, по Wi-Fi.</string>
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 3eead4a..79aaa5f 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -897,8 +897,8 @@
<string name="settings_title">设置</string>
<string name="settings_back_to_tv">返回电视页面</string>
<string name="settings_check_updates">检查更新</string>
- <string name="settings_check_updates_alpha">在 alpha 版本中,每 5 分钟向 GitHub 查询是否有新版 Tellyscope。不会下载任何内容。</string>
- <string name="settings_check_updates_release">每 30 分钟向 GitHub 查询是否有新版 Tellyscope。不会下载任何内容。</string>
+ <string name="settings_check_updates_alpha">在 alpha 版本中,每 5 分钟向 GitHub 查询是否有新版 Tellyscope。在你点按“更新”之前不会下载任何内容。</string>
+ <string name="settings_check_updates_release">每 30 分钟向 GitHub 查询是否有新版 Tellyscope。在你点按“更新”之前不会下载任何内容。</string>
<string name="settings_key_haptics">按键时振动</string>
<string name="settings_key_haptics_text">按遥控器上的每个键时短暂振动一下。</string>
<string name="settings_report">报告问题</string>
@@ -1052,9 +1052,17 @@
<string name="update_title">🎉 Tellyscope %1$s 已发布</string>
<string name="update_no_notes">没有版本说明。</string>
<string name="update_more_notes">…更多内容请见 GitHub</string>
- <string name="update_get">获取</string>
- <string name="update_skip">跳过此版本</string>
- <string name="update_later">以后再说</string>
+ <string name="update_install">更新</string>
+ <string name="update_release">获取新版本</string>
+ <string name="update_cancel">取消</string>
+ <string name="update_allow_title">允许 Tellyscope 安装更新?</string>
+ <string name="update_allow_text">Android 只会询问一次。在下一个屏幕上开启“**允许来自此来源的应用**”,然后返回这里。\n\nAndroid 仍会要求你确认每次更新,并且只接受与你当前 Tellyscope 签名相同的版本。</string>
+ <string name="update_open_settings">打开设置</string>
+ <string name="update_downloading">正在下载 %1$s</string>
+ <string name="update_of">%1$s / %2$s</string>
+ <string name="update_failed_title">无法下载 %1$s</string>
+ <string name="update_failed_text">请检查手机是否联网后重试,或从 GitHub 版本页面获取。</string>
+ <string name="update_try_again">重试</string>
<string name="welcome_skip">跳过</string>
<string name="welcome_title">欢迎使用 Tellyscope</string>
<string name="welcome_text">查看 Android TV 上正在运行的内容,并停用你不需要的应用。全部通过 Wi-Fi 在手机上完成。</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4da14ef..aa3f4d5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1172,8 +1172,8 @@
<string name="settings_title">Settings</string>
<string name="settings_back_to_tv">Back to the TV\'s page</string>
<string name="settings_check_updates">Check for updates</string>
- <string name="settings_check_updates_alpha">Every 5 minutes on alpha builds, ask GitHub whether a newer Tellyscope is out. Nothing is downloaded.</string>
- <string name="settings_check_updates_release">Every 30 minutes, ask GitHub whether a newer Tellyscope is out. Nothing is downloaded.</string>
+ <string name="settings_check_updates_alpha">Every 5 minutes on alpha builds, ask GitHub whether a newer Tellyscope is out. Nothing is downloaded until you tap Update.</string>
+ <string name="settings_check_updates_release">Every 30 minutes, ask GitHub whether a newer Tellyscope is out. Nothing is downloaded until you tap Update.</string>
<string name="settings_key_haptics">Vibrate on key press</string>
<string name="settings_key_haptics_text">A short tick for each key on the Remote.</string>
<string name="settings_report">Report a problem</string>
@@ -1382,9 +1382,17 @@
<string name="update_no_notes">No release notes.</string>
<!-- Last line when the release notes are cut short. -->
<string name="update_more_notes">…and more on GitHub</string>
- <string name="update_get">Get it</string>
- <string name="update_skip">Skip this version</string>
- <string name="update_later">Later</string>
+ <string name="update_install">Update</string>
+ <string name="update_release">Get new release</string>
+ <string name="update_cancel">Cancel</string>
+ <string name="update_allow_title">Let Tellyscope install updates?</string>
+ <string name="update_allow_text">Android asks once. On the next screen, turn on **Allow from this source**, then come back here.\n\nAndroid still asks you to confirm every update, and only accepts one signed like the Tellyscope you have.</string>
+ <string name="update_open_settings">Open settings</string>
+ <string name="update_downloading">Downloading %1$s</string>
+ <string name="update_of">%1$s of %2$s</string>
+ <string name="update_failed_title">Couldn\'t download %1$s</string>
+ <string name="update_failed_text">Check the phone is online and try again, or get it from the GitHub release page.</string>
+ <string name="update_try_again">Try again</string>
<!-- Welcome -->
<string name="welcome_skip">Skip</string>
diff --git a/app/src/main/res/xml/self_update_paths.xml b/app/src/main/res/xml/self_update_paths.xml
new file mode 100644
index 0000000..7de99b5
--- /dev/null
+++ b/app/src/main/res/xml/self_update_paths.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- The downloaded update, shared only with Android's installer (SelfUpdate.kt). -->
+<paths>
+ <cache-path name="update" path="update/" />
+</paths>
diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
index 56ea2e1..c429f2c 100644
--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt
+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt
@@ -124,6 +124,8 @@ import app.tellyscope.ui.SettingsScreen
import app.tellyscope.ui.WhatsNewScreen
import app.tellyscope.data.Changelog
import app.tellyscope.data.Update
+import app.tellyscope.ui.Updating
+import app.tellyscope.ui.UpdateDialog
import app.tellyscope.ui.SHARE_TEXT
import app.tellyscope.data.RELEASES
import androidx.compose.ui.platform.UriHandler
@@ -727,6 +729,36 @@ class ScreenshotTest {
compose.onNodeWithText("Not installed").assertDoesNotExist()
}
+ /** 0.14.0 out with its APK; [updating] is how far Update got. */
+ private fun updateDialog(updating: Updating?, onUpdate: () -> Unit = {}) = @Composable {
+ val notes = changelog.first().changes.joinToString("\n") { "- **${it.kind}:** ${it.text}" }
+ UpdateDialog(
+ Update("0.14.0", notes, "", apk = "$RELEASES/download/v0.14.0/Tellyscope-0.14.0.apk", size = 3_040_000),
+ updating, onUpdate = onUpdate, onRelease = {}, onCancel = {}, onOpenSettings = {}, onBack = {},
+ )
+ }
+
+ @Test fun update_offer() {
+ var updates = 0
+ shot("99_update_offer", screen = true) { updateDialog(null) { updates++ }() }
+ compose.onNodeWithText("Get new release").assertExists()
+ compose.onNodeWithText("Skip this version").assertDoesNotExist()
+ compose.onNodeWithText("Update").performClick()
+ assertEquals(1, updates)
+ }
+
+ @Test fun update_offer_dark() = shot("99_update_offer", dark = true, screen = true) { updateDialog(null)() }
+
+ @Test fun update_allow() = shot("99_update_allow", screen = true) { updateDialog(Updating.Allow)() }
+
+ @Test fun update_downloading() = shot("99_update_downloading", screen = true) { updateDialog(Updating.Downloading(Progress(1_260_000, 3_040_000)))() }
+
+ @Test fun update_failed() {
+ shot("99_update_failed", screen = true) { updateDialog(Updating.Failed)() }
+ compose.onNodeWithText("Try again").assertExists()
+ compose.onNodeWithText("Cancel").assertExists()
+ }
+
@Test fun whatsNew_installedAndLinks() {
val opened = mutableListOf<String>()
shot("96_whats_new") { whatsNew(opened)() }
diff --git a/app/src/test/java/app/tellyscope/UpdateCheckTest.kt b/app/src/test/java/app/tellyscope/UpdateCheckTest.kt
index 7c28033..03c0e4c 100644
--- a/app/src/test/java/app/tellyscope/UpdateCheckTest.kt
+++ b/app/src/test/java/app/tellyscope/UpdateCheckTest.kt
@@ -3,6 +3,7 @@
package app.tellyscope
import androidx.compose.ui.text.font.FontWeight
+import app.tellyscope.data.RELEASES
import app.tellyscope.data.UpdateCheck
import app.tellyscope.data.compareVersions
import app.tellyscope.data.newest
@@ -72,6 +73,18 @@ class UpdateCheckTest {
assertTrue(u!!.url.endsWith("/tellyscope/releases/tag/v0.2.0"))
}
+ @Test fun `the release's one APK comes along, only from this repo's releases`() {
+ val base = RELEASES + "/download/v0.2.0/"
+ fun withAsset(url: String, size: Long) =
+ releases("""{"tag_name":"v0.2.0","prerelease":false,"draft":false,"body":"","assets":[{"name":"Tellyscope-0.2.0.apk","browser_download_url":"$url","size":$size}]}""")
+ val u = newest(withAsset(base + "Tellyscope-0.2.0.apk", 3_000_000), alpha = false)
+ assertEquals(base + "Tellyscope-0.2.0.apk", u?.apk)
+ assertEquals(3_000_000L, u?.size)
+ 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)
+ }
+
@Test fun `nothing when the running version is the newest`() = runTest {
val check = UpdateCheck(tmp.newFile(), "0.2.0", alpha = false, fetch = { releases(release("v0.2.0"), release("v0.1.0")).toByteArray() })
assertNull(check.check())
@@ -113,18 +126,6 @@ class UpdateCheckTest {
assertEquals("0.2.0", check.check()?.version)
}
- @Test fun `a skipped version stays skipped, a later one is offered`() = runTest {
- val file = tmp.newFile()
- var now = 0L
- var latest = "v0.2.0"
- val check = UpdateCheck(file, "0.1.0", alpha = false, clock = { now }) { releases(release(latest)).toByteArray() }
- check.skip("0.2.0")
- assertNull(check.check())
- now += day
- latest = "v0.2.1"
- assertEquals("0.2.1", UpdateCheck(file, "0.1.0", alpha = false, clock = { now }) { releases(release(latest)).toByteArray() }.check()?.version)
- }
-
@Test fun `on by default, and off means no request`() = runTest {
val file = tmp.newFile()
var calls = 0
@@ -136,16 +137,16 @@ class UpdateCheckTest {
assertEquals(0, calls)
}
- @Test fun `newer reads the branch's CHANGELOG and keeps only versions past the installed one`() = runTest {
+ @Test fun `newer reads main's CHANGELOG and keeps only releases past the installed one`() = runTest {
val urls = mutableListOf<String>()
val md = "# Changelog\n\n## Unreleased\n\n- **New:** Later.\n\n## 0.3.0 — 2026-10-30\n\n- **New:** Three.\n\n## 0.2.0 — 2026-10-29\n\n- **New:** Two.\n"
val newer = UpdateCheck(tmp.newFile(), "0.2.0", alpha = false) { urls += it; md.toByteArray() }.newer()
assertEquals(listOf("0.3.0"), newer?.map { it.version })
assertTrue(urls.single().endsWith("/main/CHANGELOG.md"))
- // An alpha reads dev, and its own section is its base version's.
+ // An alpha reads main too, and its own section is its base version's.
val alpha = UpdateCheck(tmp.newFile(), "0.2.0-alpha.4", alpha = true) { urls += it; md.toByteArray() }.newer()
assertEquals(listOf("0.3.0"), alpha?.map { it.version })
- assertTrue(urls.last().endsWith("/dev/CHANGELOG.md"))
+ assertTrue(urls.last().endsWith("/main/CHANGELOG.md"))
assertNull(UpdateCheck(tmp.newFile(), "0.2.0", alpha = false) { throw IOException("offline") }.newer())
}