AppUtil: Check updates for nightly builds too

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-09-22 17:12:48 +05:30
parent d54f8696b8
commit 029a693ad3
2 changed files with 13 additions and 5 deletions

View File

@@ -37,7 +37,9 @@ class AppUtil @Inject constructor(
) {
private val TAG = AppUtil::class.java.simpleName
private val RELEASE = "release"
private val NIGHTLY = "nightly"
private val isExtendedUpdateEnabled get() = Preferences.getBoolean(
context, Preferences.PREFERENCE_UPDATES_EXTENDED
@@ -109,13 +111,17 @@ class AppUtil @Inject constructor(
private suspend fun getSelfUpdate(context: Context, gson: Gson): App? {
return withContext(Dispatchers.IO) {
@Suppress("KotlinConstantConditions") // False-positive for build type always not being release
if (BuildConfig.BUILD_TYPE != RELEASE) {
Log.i(TAG, "Self-updates are not available for this build!")
return@withContext null
val updateUrl = when (BuildConfig.BUILD_TYPE) {
RELEASE -> Constants.UPDATE_URL_STABLE
NIGHTLY -> Constants.UPDATE_URL_NIGHTLY
else -> {
Log.i(TAG, "Self-updates are not available for this build!")
return@withContext null
}
}
try {
val response = httpClient.get(Constants.UPDATE_URL, mapOf())
val response = httpClient.get(updateUrl, mapOf())
val selfUpdate =
gson.fromJson(String(response.responseBytes), SelfUpdate::class.java)