mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-16 11:42:16 -04:00
AppUtil: Compare timestamp for nightly builds
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import java.time.Instant
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
@@ -51,6 +52,7 @@ android {
|
||||
|
||||
testInstrumentationRunner = "com.aurora.store.HiltInstrumentationTestRunner"
|
||||
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
||||
buildConfigField("long", "TIMESTAMP", "${Instant.now().epochSecond}")
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
||||
@@ -36,7 +36,8 @@ data class SelfUpdate(
|
||||
@SerializedName("fdroid_build") var fdroidBuild: String = String(),
|
||||
@SerializedName("updated_on") var updatedOn: String = String(),
|
||||
val changelog: String = String(),
|
||||
val size: Long = 0L
|
||||
val size: Long = 0L,
|
||||
val timestamp: Long = 0L
|
||||
) {
|
||||
companion object {
|
||||
private const val BASE_URL = "https://gitlab.com/AuroraOSS/AuroraStore/-/raw/master"
|
||||
|
||||
@@ -123,7 +123,13 @@ class AppUtil @Inject constructor(
|
||||
val selfUpdate =
|
||||
gson.fromJson(String(response.responseBytes), SelfUpdate::class.java)
|
||||
|
||||
if (selfUpdate.versionCode > BuildConfig.VERSION_CODE) {
|
||||
val isUpdate = when (BuildConfig.BUILD_TYPE) {
|
||||
RELEASE -> selfUpdate.versionCode > BuildConfig.VERSION_CODE
|
||||
NIGHTLY -> selfUpdate.timestamp > BuildConfig.TIMESTAMP
|
||||
else -> false
|
||||
}
|
||||
|
||||
if (isUpdate) {
|
||||
if (CertUtil.isFDroidApp(context, BuildConfig.APPLICATION_ID)) {
|
||||
if (selfUpdate.fdroidBuild.isNotEmpty()) {
|
||||
return@withContext SelfUpdate.toApp(selfUpdate, context)
|
||||
|
||||
Reference in New Issue
Block a user