Refactoring

This commit is contained in:
M66B 2020-03-31 12:33:33 +02:00
parent a564369efc
commit 5048b671f4
1 changed files with 11 additions and 9 deletions

View File

@ -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);