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

@@ -33,7 +33,9 @@ object Constants {
const val EXODUS_SUBMIT_PAGE = "https://reports.exodus-privacy.eu.org/analysis/submit/#"
const val EXODUS_REPORT_URL = "https://reports.exodus-privacy.eu.org/reports/"
const val SHARE_URL = "https://play.google.com/store/apps/details?id="
const val UPDATE_URL = "https://gitlab.com/AuroraOSS/AuroraStore/raw/master/updates.json"
const val UPDATE_URL_STABLE = "https://gitlab.com/AuroraOSS/AuroraStore/raw/master/updates.json"
const val UPDATE_URL_NIGHTLY = "https://auroraoss.com/downloads/AuroraStore/Feeds/nightly_feed.json"
const val NOTIFICATION_CHANNEL_ALERT = "NOTIFICATION_CHANNEL_ALERT"
const val NOTIFICATION_CHANNEL_GENERAL = "NOTIFICATION_CHANNEL_GENERAL"

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)