StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
Separate update channels: beta prerelease isolation and publish-time tie-breaker
David Nashash464d981a967a
diff --git a/README.md b/README.mdindex a60420a7..091317a0 100644--- a/README.md+++ b/README.md@@ -4,6 +4,7 @@<a href="https://github.com/Davidona/StreamVault-IPTV/releases/latest/download/StreamVault.apk"><img src="https://img.shields.io/badge/Download-StreamVault.apk-2ea44f?style=for-the-badge&logo=android" alt="Download StreamVault APK" /></a><a href="https://github.com/Davidona/StreamVault-IPTV/releases/latest"><img src="https://img.shields.io/github/v/release/Davidona/StreamVault-IPTV?display_name=tag&style=for-the-badge&color=0f766e" alt="Latest StreamVault release" /></a><a href="https://github.com/Davidona/StreamVault-IPTV/releases"><img src="https://img.shields.io/github/downloads/Davidona/StreamVault-IPTV/total?style=for-the-badge&color=8b5cf6" alt="Total Downloads" /></a>+ <a href="https://discord.gg/eGPBMygcb"><img src="https://img.shields.io/discord/1372516529950466078?style=for-the-badge&logo=discord&logoColor=white&label=Discord&color=5865F2" alt="Join the StreamVault Discord" /></a><a href="docs/CHANGELOG.md"><img src="https://img.shields.io/badge/Changelog-View-2563eb?style=for-the-badge" alt="View changelog" /></a><a href="https://github.com/Davidona/StreamVault-IPTV/actions/workflows/release.yml"><img src="https://img.shields.io/github/actions/workflow/status/Davidona/StreamVault-IPTV/release.yml?branch=master&style=for-the-badge&label=CI" alt="GitHub Actions status" /></a><a href="https://ko-fi.com/davidona"><img src="https://img.shields.io/badge/Support-Ko--fi-ff5f5f?style=for-the-badge&logo=kofi" alt="Support on Ko-fi" /></a>diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex bf35c2b0..22d08daa 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -62,6 +62,8 @@ android {testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"buildConfigField("String", "OFFICIAL_APPLICATION_ID", "\"com.streamvault.app\"")buildConfigField("String", "OFFICIAL_SIGNING_CERT_SHA256", "\"$officialSigningCertSha256\"")+ buildConfigField("String", "APP_UPDATE_CHANNEL", "\"stable\"")+ buildConfigField("long", "BUILD_TIMESTAMP_UTC", "0L")ndk {abiFilters += listOf("arm64-v8a", "armeabi-v7a")}@@ -101,6 +103,8 @@ android {initWith(getByName("release"))applicationIdSuffix = ".beta"versionNameSuffix = "-beta"+ buildConfigField("String", "APP_UPDATE_CHANNEL", "\"beta\"")+ buildConfigField("long", "BUILD_TIMESTAMP_UTC", "${System.currentTimeMillis()}L")isDebuggable = false// Keep beta close to release behavior but faster for CI/test distribution.isMinifyEnabled = falsediff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModels.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModels.ktindex 2160f67c..fb989791 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModels.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModels.kt@@ -3,7 +3,9 @@ package com.streamvault.app.ui.screens.settingsimport com.streamvault.app.BuildConfigimport com.streamvault.app.update.AppUpdateDownloadStateimport com.streamvault.app.update.AppUpdateDownloadStatus+import com.streamvault.app.update.AppUpdateChannelimport com.streamvault.app.update.GitHubReleaseInfo+import java.time.Instantimport kotlin.math.maxdata class AppUpdateUiModel(@@ -57,17 +59,57 @@ internal fun SettingsPreferenceSnapshot.toCachedAppUpdateUiModel(): AppUpdateUiMreleaseNotes = cachedAppUpdateReleaseNotes,publishedAt = cachedAppUpdatePublishedAt,isUpdateAvailable = versionName?.let {- isRemoteVersionNewer(cachedAppUpdateVersionCode, it)+ isRemoteVersionNewer(cachedAppUpdateVersionCode, it, cachedAppUpdatePublishedAt)} ?: false,lastCheckedAt = lastAppUpdateCheckAt)}-internal fun isRemoteVersionNewer(remoteVersionCode: Int?, remoteVersionName: String): Boolean {- if (remoteVersionCode != null && remoteVersionCode > BuildConfig.VERSION_CODE) {+internal fun isRemoteVersionNewer(+ remoteVersionCode: Int?,+ remoteVersionName: String,+ remotePublishedAt: String? = null+): Boolean {+ return isRemoteVersionNewerForBuild(+ remoteVersionCode = remoteVersionCode,+ remoteVersionName = remoteVersionName,+ remotePublishedAt = remotePublishedAt,+ currentVersionCode = BuildConfig.VERSION_CODE,+ currentVersionName = BuildConfig.VERSION_NAME,+ currentBuildTimestampUtc = BuildConfig.BUILD_TIMESTAMP_UTC,+ currentChannel = AppUpdateChannel.fromCurrentBuild()+ )+}++internal fun isRemoteVersionNewerForBuild(+ remoteVersionCode: Int?,+ remoteVersionName: String,+ remotePublishedAt: String?,+ currentVersionCode: Int,+ currentVersionName: String,+ currentBuildTimestampUtc: Long,+ currentChannel: AppUpdateChannel+): Boolean {+ val remoteDescriptor = parseAppVersionDescriptor(remoteVersionName)+ if (remoteDescriptor.channel != currentChannel) {+ return false+ }++ if (remoteVersionCode != null && remoteVersionCode > currentVersionCode) {return true}- return compareVersionNamesStatic(remoteVersionName, BuildConfig.VERSION_NAME) > 0++ val versionComparison = compareVersionNamesStatic(remoteDescriptor.baseVersionName, parseAppVersionDescriptor(currentVersionName).baseVersionName)+ if (versionComparison != 0) {+ return versionComparison > 0+ }++ if (currentChannel == AppUpdateChannel.Beta) {+ val remotePublishedAtMillis = remotePublishedAt.toEpochMillisOrNull() ?: return false+ return remotePublishedAtMillis > currentBuildTimestampUtc+ }++ return false}internal fun compareVersionNamesStatic(left: String, right: String): Int {@@ -82,4 +124,31 @@ internal fun compareVersionNamesStatic(left: String, right: String): Int {}}return 0+}++private data class ParsedAppVersionDescriptor(+ val baseVersionName: String,+ val channel: AppUpdateChannel+)++private fun parseAppVersionDescriptor(versionName: String): ParsedAppVersionDescriptor {+ val normalized = versionName.removePrefix("v").trim()+ val betaIndex = normalized.indexOf("-beta", ignoreCase = true)+ return if (betaIndex >= 0) {+ ParsedAppVersionDescriptor(+ baseVersionName = normalized.substring(0, betaIndex),+ channel = AppUpdateChannel.Beta+ )+ } else {+ ParsedAppVersionDescriptor(+ baseVersionName = normalized,+ channel = AppUpdateChannel.Stable+ )+ }+}++private fun String?.toEpochMillisOrNull(): Long? {+ val value = this?.trim().orEmpty()+ if (value.isEmpty()) return null+ return runCatching { Instant.parse(value).toEpochMilli() }.getOrNull()}\ No newline at end of filediff --git a/app/src/main/java/com/streamvault/app/update/GitHubReleaseChecker.kt b/app/src/main/java/com/streamvault/app/update/GitHubReleaseChecker.ktindex d5bec712..07c0064e 100644--- a/app/src/main/java/com/streamvault/app/update/GitHubReleaseChecker.kt+++ b/app/src/main/java/com/streamvault/app/update/GitHubReleaseChecker.kt@@ -1,5 +1,6 @@package com.streamvault.app.update+import com.streamvault.app.BuildConfigimport com.streamvault.domain.model.Resultimport kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.withContext@@ -13,6 +14,9 @@ import java.net.URIimport javax.inject.Injectimport javax.inject.Singleton+private const val GITHUB_RELEASES_LATEST_URL = "https://api.github.com/repos/Davidona/StreamVault-IPTV/releases/latest"+private const val GITHUB_RELEASES_LIST_URL = "https://api.github.com/repos/Davidona/StreamVault-IPTV/releases?per_page=20"+data class GitHubReleaseInfo(val versionName: String,val versionCode: Int?,@@ -27,15 +31,15 @@ class GitHubReleaseChecker @Inject constructor(private val okHttpClient: OkHttpClient) {private companion object {- private const val RELEASES_LATEST_URL = "https://api.github.com/repos/Davidona/StreamVault-IPTV/releases/latest"private const val MAX_RESPONSE_BYTES = 512 * 1024Lprivate val STRUCTURED_TAG_REGEX = Regex("""^v?(.+?)\+(\d+)$""", RegexOption.IGNORE_CASE)}suspend fun fetchLatestRelease(): Result<GitHubReleaseInfo> = withContext(Dispatchers.IO) {try {+ val updateChannel = AppUpdateChannel.fromCurrentBuild()val request = Request.Builder()- .url(RELEASES_LATEST_URL)+ .url(updateChannel.releaseApiUrl).header("Accept", "application/vnd.github+json").header("User-Agent", "StreamVault-Update-Checker").build()@@ -55,7 +59,14 @@ class GitHubReleaseChecker @Inject constructor(return@withContext Result.error("Update check failed: empty GitHub release response")}- val json = JSONObject(body)+ val json = selectReleaseJson(body, updateChannel)+ ?: return@withContext Result.error(+ if (updateChannel == AppUpdateChannel.Beta) {+ "Update check failed: no beta release found"+ } else {+ "Update check failed: latest release response was invalid"+ }+ )val parsedTag = parseTagVersionInfo(json.optString("tag_name"))if (parsedTag.versionName.isBlank()) {return@withContext Result.error("Update check failed: latest release tag is missing")@@ -67,7 +78,7 @@ class GitHubReleaseChecker @Inject constructor(if (releaseUrl.isBlank()) {return@withContext Result.error("Update check failed: latest release URL is not HTTPS")}- val downloadUrl = findApkAssetUrl(assets)+ val downloadUrl = findApkAssetUrl(assets, updateChannel)return@withContext Result.success(GitHubReleaseInfo(@@ -87,6 +98,27 @@ class GitHubReleaseChecker @Inject constructor(}}+ private fun selectReleaseJson(body: String, updateChannel: AppUpdateChannel): JSONObject? {+ return when (updateChannel) {+ AppUpdateChannel.Stable -> JSONObject(body)+ AppUpdateChannel.Beta -> {+ val releases = org.json.JSONArray(body)+ for (index in 0 until releases.length()) {+ val release = releases.optJSONObject(index) ?: continue+ if (release.optBoolean("draft")) continue+ if (!release.optBoolean("prerelease")) continue+ val tagName = release.optString("tag_name")+ if (!tagName.contains("-beta", ignoreCase = true)) continue+ val downloadUrl = findApkAssetUrl(release.optJSONArray("assets"), updateChannel)+ if (downloadUrl != null) {+ return release+ }+ }+ null+ }+ }+ }+private fun readResponseBodyCapped(body: ResponseBody): Result<String> {val contentLength = body.contentLength()if (contentLength > MAX_RESPONSE_BYTES) {@@ -115,7 +147,7 @@ class GitHubReleaseChecker @Inject constructor(return Result.success(output.toString(charset.name()))}- private fun findApkAssetUrl(assets: org.json.JSONArray?): String? {+ private fun findApkAssetUrl(assets: org.json.JSONArray?, updateChannel: AppUpdateChannel): String? {if (assets == null) return nullvar fallback: String? = nullfor (index in 0 until assets.length()) {@@ -123,11 +155,29 @@ class GitHubReleaseChecker @Inject constructor(val name = asset.optString("name")val url = asset.optString("browser_download_url").takeIf { it.isNotBlank() } ?: continueif (!isHttpsUrl(url)) continue- if (name.equals("StreamVault.apk", ignoreCase = true)) {- return url- }- if (fallback == null && name.endsWith(".apk", ignoreCase = true)) {- fallback = url+ when (updateChannel) {+ AppUpdateChannel.Stable -> {+ if (name.equals("StreamVault.apk", ignoreCase = true)) {+ return url+ }+ if (fallback == null &&+ name.endsWith(".apk", ignoreCase = true) &&+ !name.contains("beta", ignoreCase = true)+ ) {+ fallback = url+ }+ }+ AppUpdateChannel.Beta -> {+ if (name.equals("StreamVault-beta.apk", ignoreCase = true)) {+ return url+ }+ if (fallback == null &&+ name.endsWith(".apk", ignoreCase = true) &&+ name.contains("beta", ignoreCase = true)+ ) {+ fallback = url+ }+ }}}return fallback@@ -159,6 +209,25 @@ class GitHubReleaseChecker @Inject constructor(}}+enum class AppUpdateChannel(val id: String, val releaseApiUrl: String) {+ Stable(id = "stable", releaseApiUrl = GITHUB_RELEASES_LATEST_URL),+ Beta(id = "beta", releaseApiUrl = GITHUB_RELEASES_LIST_URL);++ companion object {+ fun fromCurrentBuild(): AppUpdateChannel {+ return fromBuildConfig(BuildConfig.APP_UPDATE_CHANNEL, BuildConfig.VERSION_NAME)+ }++ fun fromBuildConfig(channelId: String?, versionName: String): AppUpdateChannel {+ return when {+ channelId.equals(Beta.id, ignoreCase = true) -> Beta+ versionName.contains("-beta", ignoreCase = true) -> Beta+ else -> Stable+ }+ }+ }+}+private data class ParsedTagVersion(val versionName: String,val versionCode: Int?diff --git a/app/src/test/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModelsTest.kt b/app/src/test/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModelsTest.ktnew file mode 100644index 00000000..87e108f4--- /dev/null+++ b/app/src/test/java/com/streamvault/app/ui/screens/settings/SettingsAppUpdateModelsTest.kt@@ -0,0 +1,83 @@+package com.streamvault.app.ui.screens.settings++import com.google.common.truth.Truth.assertThat+import com.streamvault.app.update.AppUpdateChannel+import org.junit.Test++class SettingsAppUpdateModelsTest {++ @Test+ fun stableBuildIgnoresBetaRelease() {+ val result = isRemoteVersionNewerForBuild(+ remoteVersionCode = 12,+ remoteVersionName = "1.0.11-beta-deadbee",+ remotePublishedAt = "2026-05-14T10:00:00Z",+ currentVersionCode = 12,+ currentVersionName = "1.0.11",+ currentBuildTimestampUtc = 1_747_216_000_000L,+ currentChannel = AppUpdateChannel.Stable+ )++ assertThat(result).isFalse()+ }++ @Test+ fun betaBuildIgnoresStableRelease() {+ val result = isRemoteVersionNewerForBuild(+ remoteVersionCode = 12,+ remoteVersionName = "1.0.11",+ remotePublishedAt = "2026-05-14T10:00:00Z",+ currentVersionCode = 12,+ currentVersionName = "1.0.11-beta",+ currentBuildTimestampUtc = 1_747_216_000_000L,+ currentChannel = AppUpdateChannel.Beta+ )++ assertThat(result).isFalse()+ }++ @Test+ fun betaBuildAcceptsNewerBaseVersionBetaRelease() {+ val result = isRemoteVersionNewerForBuild(+ remoteVersionCode = 13,+ remoteVersionName = "1.0.12-beta-cafebad",+ remotePublishedAt = "2026-05-14T10:00:00Z",+ currentVersionCode = 12,+ currentVersionName = "1.0.11-beta",+ currentBuildTimestampUtc = 1_747_216_000_000L,+ currentChannel = AppUpdateChannel.Beta+ )++ assertThat(result).isTrue()+ }++ @Test+ fun betaBuildAcceptsSameVersionBetaReleaseWhenPublishedLater() {+ val result = isRemoteVersionNewerForBuild(+ remoteVersionCode = 12,+ remoteVersionName = "1.0.11-beta-deadbee",+ remotePublishedAt = "2026-05-14T12:30:00Z",+ currentVersionCode = 12,+ currentVersionName = "1.0.11-beta",+ currentBuildTimestampUtc = 0L,+ currentChannel = AppUpdateChannel.Beta+ )++ assertThat(result).isTrue()+ }++ @Test+ fun betaBuildRejectsSameVersionBetaReleaseWhenNotPublishedLater() {+ val result = isRemoteVersionNewerForBuild(+ remoteVersionCode = 12,+ remoteVersionName = "1.0.11-beta-deadbee",+ remotePublishedAt = "2026-05-14T08:00:00Z",+ currentVersionCode = 12,+ currentVersionName = "1.0.11-beta",+ currentBuildTimestampUtc = Long.MAX_VALUE,+ currentChannel = AppUpdateChannel.Beta+ )++ assertThat(result).isFalse()+ }+}\ No newline at end of filediff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex d545a0c7..1532dcad 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -35,6 +35,7 @@ All notable product changes are recorded in this document.- Fixed unsupported audio streams not retrying once in software when FFmpeg is available.- Fixed explicit `TextureView` live playback getting stuck on green or corrupted frames before first video render.- Fixed movie playback context and recovery so non-live titles no longer inherit stale live-channel state, external subtitle attachment resumes from the current position, and VOD retries preserve playback progress correctly.+- Fixed in-app updates crossing release channels: stable builds now only offer stable releases, beta builds now only offer beta prereleases, and same-version beta updates fall back to publish time to detect newer beta builds.- Fixed software nav bars overlapping the app on devices like Nexus 5X.- Fixed touch and mouse activation for TV plugin controls on non-TV devices.- Fixed `TvClickableSurface` and `TvIconButton` long-press behavior for home-screen actions.