Improve FCM check clock skew handling.

This commit is contained in:
Cody Henthorne 2024-06-07 13:02:44 -04:00 committed by GitHub
parent 2fedb3a0ee
commit 543a85316e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -386,9 +386,11 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr
private void initializeFcmCheck() {
if (SignalStore.account().isRegistered()) {
long nextSetTime = SignalStore.account().getFcmTokenLastSetTime() + TimeUnit.HOURS.toMillis(6);
long lastSetTime = SignalStore.account().getFcmTokenLastSetTime();
long nextSetTime = lastSetTime + TimeUnit.HOURS.toMillis(6);
long now = System.currentTimeMillis();
if (SignalStore.account().getFcmToken() == null || nextSetTime <= System.currentTimeMillis()) {
if (SignalStore.account().getFcmToken() == null || nextSetTime <= now || lastSetTime > now) {
AppDependencies.getJobManager().add(new FcmRefreshJob());
}
}