Skip to content

Commit 814304f

Browse files
committed
Select update APK by device ABI and flavor
Update the in-app updater to detect device architecture (ABI) and build flavor (GMS vs FOSS) and choose the appropriate APK from GitHub release assets. echomusicupdater.kt now determines targetVariant and targetAbi, searches assets for a matching variant+ABI, falls back to a universal variant or the first APK if needed, and computes apkSizeInMB/browser_download_url accordingly.
1 parent ba2abce commit 814304f

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

RELEASE_INFO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Echo Music v5.1.6 - Beta Release
22

33
- Migrated default Listen Together server to Echo Music Server on Hugging Face (wss://iad1tya-echomusic.hf.space/ws). To modify or verify the URL, navigate to Listen Together > Settings > Server URL.
4+
- Enhanced in-app updater to dynamically detect device architecture (ABI) and flavor (FOSS/GMS) to download the correct update APK from GitHub Releases.

app/src/main/kotlin/com/music/vivi/echomusic/updater/echomusicupdater.kt

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -683,17 +683,55 @@ suspend fun checkForUpdate(
683683

684684
var apkSizeInMB = ""
685685
var apkDownloadUrl = ""
686+
687+
var targetApkAsset: JSONObject? = null
688+
var fallbackApkAsset: JSONObject? = null
689+
690+
val isGms = BuildConfig.FLAVOR.lowercase().contains("gms")
691+
val targetVariant = if (isGms) "gms" else "foss"
692+
693+
val supportedAbis = Build.SUPPORTED_ABIS ?: emptyArray()
694+
val targetAbi = when {
695+
supportedAbis.contains("arm64-v8a") -> "arm64"
696+
supportedAbis.contains("armeabi-v7a") || supportedAbis.contains("armeabi") -> "armeabi"
697+
supportedAbis.contains("x86_64") -> "x86_64"
698+
else -> "universal"
699+
}
700+
686701
for (j in 0 until assets.length()) {
687702
val asset = assets.getJSONObject(j)
688-
val assetName = asset.getString("name")
689-
if (assetName.endsWith(".apk", ignoreCase = true)) {
690-
val apkSizeInBytes = asset.getLong("size")
691-
apkSizeInMB = String.format("%.1f", apkSizeInBytes / (1024.0 * 1024.0))
692-
apkDownloadUrl = asset.getString("browser_download_url")
693-
break
703+
val assetName = asset.getString("name").lowercase()
704+
if (assetName.endsWith(".apk")) {
705+
if (assetName.contains(targetVariant)) {
706+
if (assetName.contains(targetAbi)) {
707+
targetApkAsset = asset
708+
break
709+
}
710+
if (assetName.contains("universal")) {
711+
fallbackApkAsset = asset
712+
}
713+
}
694714
}
695715
}
696716

717+
val chosenAsset = targetApkAsset ?: fallbackApkAsset ?: run {
718+
var firstApk: JSONObject? = null
719+
for (j in 0 until assets.length()) {
720+
val asset = assets.getJSONObject(j)
721+
if (asset.getString("name").endsWith(".apk", ignoreCase = true)) {
722+
firstApk = asset
723+
break
724+
}
725+
}
726+
firstApk
727+
}
728+
729+
if (chosenAsset != null) {
730+
val apkSizeInBytes = chosenAsset.getLong("size")
731+
apkSizeInMB = String.format("%.1f", apkSizeInBytes / (1024.0 * 1024.0))
732+
apkDownloadUrl = chosenAsset.getString("browser_download_url")
733+
}
734+
697735
if (apkDownloadUrl.isNotEmpty()) {
698736
withContext(Dispatchers.Main) {
699737
onSuccess(displayTag, true, changelogList, apkSizeInMB, formattedReleaseDate, description, imageUrl, apkDownloadUrl)

0 commit comments

Comments
 (0)