Skip to content

Native Android client for Spotify, built with Jetpack Compose

Updater: pick this release's own APK; keep the install confirmation

liliapk44c9c33a8c82
diff --git a/base/app/src/main/java/com/music/spotui/data/api/AppUpdater.kt b/base/app/src/main/java/com/music/spotui/data/api/AppUpdater.kt
index f7be1ad0..4f1edbab 100644
--- a/base/app/src/main/java/com/music/spotui/data/api/AppUpdater.kt
+++ b/base/app/src/main/java/com/music/spotui/data/api/AppUpdater.kt
@@ -106,8 +106,9 @@ object AppUpdater {
val params = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL).apply {
setAppPackageName(context.packageName)
setSize(apk.length())
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
- setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED)
+ // User action stays required (the default): without the
+ // UPDATE_PACKAGES_WITHOUT_USER_ACTION permission a NOT_REQUIRED flag
+ // would be ignored anyway; the confirmation is the user's last check.
}
val id = installer.createSession(params)
installer.openSession(id).use { session ->
diff --git a/base/app/src/main/java/com/music/spotui/data/api/UpdateChecker.kt b/base/app/src/main/java/com/music/spotui/data/api/UpdateChecker.kt
index 9c034e36..4fc6dfcb 100644
--- a/base/app/src/main/java/com/music/spotui/data/api/UpdateChecker.kt
+++ b/base/app/src/main/java/com/music/spotui/data/api/UpdateChecker.kt
@@ -60,8 +60,12 @@ object UpdateChecker {
/** The release's APK download link (the CI uploads one `myspoti-<version>.apk`). */
internal fun apkAsset(release: JSONObject): String {
val assets = release.optJSONArray("assets") ?: return ""
- return (0 until assets.length()).map { assets.getJSONObject(it) }
- .firstOrNull { it.optString("name").endsWith(".apk", ignoreCase = true) }
+ val all = (0 until assets.length()).map { assets.getJSONObject(it) }
+ // This release's own APK first: a release carrying several APKs (both
+ // channels) must not hand a phone the other channel's build.
+ val want = "myspoti-${release.optString("tag_name").removePrefix("v")}.apk"
+ return (all.firstOrNull { it.optString("name") == want }
+ ?: all.firstOrNull { it.optString("name").endsWith(".apk", ignoreCase = true) })
?.optString("browser_download_url").orEmpty()
}