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
|
import java.util.Properties
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@@ -51,6 +52,7 @@ android {
|
|||||||
|
|
||||||
testInstrumentationRunner = "com.aurora.store.HiltInstrumentationTestRunner"
|
testInstrumentationRunner = "com.aurora.store.HiltInstrumentationTestRunner"
|
||||||
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
||||||
|
buildConfigField("long", "TIMESTAMP", "${Instant.now().epochSecond}")
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ data class SelfUpdate(
|
|||||||
@SerializedName("fdroid_build") var fdroidBuild: String = String(),
|
@SerializedName("fdroid_build") var fdroidBuild: String = String(),
|
||||||
@SerializedName("updated_on") var updatedOn: String = String(),
|
@SerializedName("updated_on") var updatedOn: String = String(),
|
||||||
val changelog: String = String(),
|
val changelog: String = String(),
|
||||||
val size: Long = 0L
|
val size: Long = 0L,
|
||||||
|
val timestamp: Long = 0L
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
private const val BASE_URL = "https://gitlab.com/AuroraOSS/AuroraStore/-/raw/master"
|
private const val BASE_URL = "https://gitlab.com/AuroraOSS/AuroraStore/-/raw/master"
|
||||||
|
|||||||
@@ -123,7 +123,13 @@ class AppUtil @Inject constructor(
|
|||||||
val selfUpdate =
|
val selfUpdate =
|
||||||
gson.fromJson(String(response.responseBytes), SelfUpdate::class.java)
|
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 (CertUtil.isFDroidApp(context, BuildConfig.APPLICATION_ID)) {
|
||||||
if (selfUpdate.fdroidBuild.isNotEmpty()) {
|
if (selfUpdate.fdroidBuild.isNotEmpty()) {
|
||||||
return@withContext SelfUpdate.toApp(selfUpdate, context)
|
return@withContext SelfUpdate.toApp(selfUpdate, context)
|
||||||
|
|||||||
Reference in New Issue
Block a user