Add logs to detect negative changes in system clock.

fork-5.53.8
Greyson Parrelli 2022-08-10 14:38:05 -04:00 zatwierdzone przez Alex Hart
rodzic 3cb674f095
commit f8220ca554
2 zmienionych plików z 19 dodań i 0 usunięć

Wyświetl plik

@ -231,6 +231,16 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr
KeyCachingService.onAppForegrounded(this);
ApplicationDependencies.getShakeToReport().enable();
checkBuildExpiration();
long lastForegroundTime = SignalStore.misc().getLastForegroundTime();
long currentTime = System.currentTimeMillis();
long timeDiff = currentTime - lastForegroundTime;
if (timeDiff < 0) {
Log.w(TAG, "Time travel! The system clock has moved backwards. (currentTime: " + currentTime + " ms, lastForegroundTime: " + lastForegroundTime + " ms, diff: " + timeDiff + " ms)");
}
SignalStore.misc().setLastForegroundTime(currentTime);
});
Log.d(TAG, "onStart() took " + (System.currentTimeMillis() - startTime) + " ms");

Wyświetl plik

@ -25,6 +25,7 @@ public final class MiscellaneousValues extends SignalStoreValues {
private static final String LAST_GV2_PROFILE_CHECK_TIME = "misc.last_gv2_profile_check_time";
private static final String CDS_TOKEN = "misc.cds_token";
private static final String LAST_FCM_FOREGROUND_TIME = "misc.last_fcm_foreground_time";
private static final String LAST_FOREGROUND_TIME = "misc.last_foreground_time";
MiscellaneousValues(@NonNull KeyValueStore store) {
super(store);
@ -175,4 +176,12 @@ public final class MiscellaneousValues extends SignalStoreValues {
public void setLastFcmForegroundServiceTime(long time) {
putLong(LAST_FCM_FOREGROUND_TIME, time);
}
public long getLastForegroundTime() {
return getLong(LAST_FOREGROUND_TIME, 0);
}
public void setLastForegroundTime(long time) {
putLong(LAST_FOREGROUND_TIME, time);
}
}