1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 12:44:42 +00:00

Revert "Prevent multiple inits"

This reverts commit 62675805da.
This commit is contained in:
M66B 2020-04-05 13:54:18 +02:00
parent e4c275f982
commit 185efd00ef

View file

@ -36,7 +36,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
import android.os.SystemClock;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
@ -150,8 +149,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
iif.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
registerReceiver(connectionChangedReceiver, iif);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
DB db = DB.getInstance(this);
db.account().liveAccountState().observe(this, new Observer<List<TupleAccountState>>() {
@ -176,6 +173,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
});
liveAccountNetworkState.observeForever(new Observer<List<TupleAccountNetworkState>>() {
private boolean init = false;
private boolean fts = false;
private Integer lastQuitId = null;
private List<TupleAccountNetworkState> accountStates = new ArrayList<>();
@ -194,14 +192,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
coreStates.clear();
liveAccountNetworkState.removeObserver(this);
} else {
// Check init
long now = new Date().getTime();
long init = prefs.getLong("last_init", 0);
long boot = now - SystemClock.elapsedRealtime();
if (init < boot) {
EntityLog.log(ServiceSynchronize.this, "Boot=" + new Date(boot));
EntityLog.log(ServiceSynchronize.this, "Last init=" + new Date(init));
prefs.edit().putLong("last_init", now).apply();
if (!init) {
init = true;
init();
}
@ -476,6 +468,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}
});
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
final TwoStateOwner cowner = new TwoStateOwner(this, "liveUnseenNotify");