mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Make build deprecation more resilient to clock skew.
This commit is contained in:
committed by
Alex Hart
parent
f572eb5322
commit
3ff218f9c6
@@ -19,12 +19,20 @@ public final class RemoteDeprecation {
|
||||
|
||||
private RemoteDeprecation() { }
|
||||
|
||||
/**
|
||||
* @return The amount of time (in milliseconds) until this client version expires, or -1 if
|
||||
* there's no pending expiration.
|
||||
*/
|
||||
public static long getTimeUntilDeprecation(long currentTime) {
|
||||
return getTimeUntilDeprecation(FeatureFlags.clientExpiration(), currentTime, BuildConfig.VERSION_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The amount of time (in milliseconds) until this client version expires, or -1 if
|
||||
* there's no pending expiration.
|
||||
*/
|
||||
public static long getTimeUntilDeprecation() {
|
||||
return getTimeUntilDeprecation(FeatureFlags.clientExpiration(), System.currentTimeMillis(), BuildConfig.VERSION_NAME);
|
||||
return getTimeUntilDeprecation(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -349,14 +349,14 @@ public class Util {
|
||||
* @return The amount of time (in ms) until this build of Signal will be considered 'expired'.
|
||||
* Takes into account both the build age as well as any remote deprecation values.
|
||||
*/
|
||||
public static long getTimeUntilBuildExpiry() {
|
||||
public static long getTimeUntilBuildExpiry(long currentTime) {
|
||||
if (SignalStore.misc().isClientDeprecated()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long buildAge = System.currentTimeMillis() - BuildConfig.BUILD_TIMESTAMP;
|
||||
long buildAge = currentTime - BuildConfig.BUILD_TIMESTAMP;
|
||||
long timeUntilBuildDeprecation = BUILD_LIFESPAN - buildAge;
|
||||
long timeUntilRemoteDeprecation = RemoteDeprecation.getTimeUntilDeprecation();
|
||||
long timeUntilRemoteDeprecation = RemoteDeprecation.getTimeUntilDeprecation(currentTime);
|
||||
|
||||
if (timeUntilRemoteDeprecation != -1) {
|
||||
long timeUntilDeprecation = Math.min(timeUntilBuildDeprecation, timeUntilRemoteDeprecation);
|
||||
|
||||
@@ -24,7 +24,7 @@ object VersionTracker {
|
||||
val lastVersionCode = TextSecurePreferences.getLastVersionCode(context)
|
||||
|
||||
if (currentVersionCode != lastVersionCode) {
|
||||
Log.i(TAG, "Upgraded from $lastVersionCode to $currentVersionCode")
|
||||
Log.i(TAG, "Upgraded from $lastVersionCode to $currentVersionCode. Clearing client deprecation.", true)
|
||||
SignalStore.misc().isClientDeprecated = false
|
||||
val jobChain = listOf(RemoteConfigRefreshJob(), RefreshAttributesJob())
|
||||
AppDependencies.jobManager.startChain(jobChain).enqueue()
|
||||
|
||||
Reference in New Issue
Block a user