diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 0bc0b287f1..887a4cc199 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1319,6 +1319,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences boolean first = true; while (state.isRunning()) { long idleTime = state.getIdleTime(); + boolean idleOk = (!first && account.poll_interval > 9 && + Math.abs(idleTime - account.poll_interval * 60 * 1000L) < 60 * 1000L); + if (BuildConfig.DEBUG) + EntityLog.log(ServiceSynchronize.this, account.name + + " first=" + first + + " ok=" + account.keep_alive_ok + + " interval=" + account.poll_interval + + " idle=" + idleTime + "/" + idleOk); try { if (!state.isRecoverable()) throw new StoreClosedException(iservice.getStore(), "Unrecoverable"); @@ -1349,10 +1357,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences Log.i(folder.name + " poll count=" + folder.poll_count); } } catch (Throwable ex) { - if (BuildConfig.DEBUG && - !first && !account.keep_alive_ok && - account.poll_interval > 9 && - Math.abs(idleTime - account.poll_interval * 60 * 1000L) < 60 * 1000L) { + if (BuildConfig.DEBUG && !account.keep_alive_ok && idleOk) { account.keep_alive_failed++; if (account.keep_alive_failed >= 3) { account.keep_alive_failed = 0; @@ -1363,15 +1368,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences EntityLog.log(ServiceSynchronize.this, account.name + " keep alive failed=" + account.keep_alive_failed + " keep alive interval=" + account.poll_interval + - " max idle=" + idleTime); + " max idle=" + idleTime + "/" + idleOk); } throw ex; } - if (BuildConfig.DEBUG && - !first && !account.keep_alive_ok && - account.poll_interval > 9 && - Math.abs(idleTime - account.poll_interval * 60 * 1000L) < 60 * 1000L) { + if (BuildConfig.DEBUG && !account.keep_alive_ok && idleOk) { account.keep_alive_ok = true; account.keep_alive_failed = 0; db.account().setAccountKeepAliveOk(account.id, true);