Add logs to detect negative changes in system clock.
This commit is contained in:
parent
3cb674f095
commit
f8220ca554
2 changed files with 19 additions and 0 deletions
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue