From f8f7dd3e14c223d39808996837e0d8cb4ec860df Mon Sep 17 00:00:00 2001 From: Hector Dearman Date: Thu, 19 Dec 2024 21:28:37 +0000 Subject: [PATCH] [distribution] Send version{Code,Name} when checking for updates (#319) --- distribution/CHANGELOG.md | 4 ++++ .../distribution/internal/DistributionInternal.kt | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/distribution/CHANGELOG.md b/distribution/CHANGELOG.md index 66ba1d4b..e96ce2a0 100644 --- a/distribution/CHANGELOG.md +++ b/distribution/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to build distribution will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +- Add version{Code,Name} when checking for updates. This prevents suggesting the current build as an update. [#319](https://github.com/EmergeTools/emerge-android/pull/319) + ## 0.0.2 - 2024-12-12 - Relax API response constraints [#310](https://github.com/EmergeTools/emerge-android/pull/310) diff --git a/distribution/distribution/src/main/kotlin/com/emergetools/distribution/internal/DistributionInternal.kt b/distribution/distribution/src/main/kotlin/com/emergetools/distribution/internal/DistributionInternal.kt index 86836963..cbfa0c34 100644 --- a/distribution/distribution/src/main/kotlin/com/emergetools/distribution/internal/DistributionInternal.kt +++ b/distribution/distribution/src/main/kotlin/com/emergetools/distribution/internal/DistributionInternal.kt @@ -206,6 +206,10 @@ private suspend fun doCheckForUpdate(context: Context, state: State): UpdateStat return UpdateStatus.Error("No API key available") } + val info = context.packageManager.getPackageInfo(applicationId, 0) + val version = info.versionName + val build = info.versionCode + val url = HttpUrl.Builder().apply { scheme("https") host("api.emergetools.com") @@ -214,6 +218,8 @@ private suspend fun doCheckForUpdate(context: Context, state: State): UpdateStat addQueryParameter("apiKey", apiKey) addQueryParameter("tag", state.tag) addQueryParameter("appId", applicationId) + addQueryParameter("version", version) + addQueryParameter("build", build.toString()) addQueryParameter("platform", "android") }.build()