Refactoring

pull/189/head
M66B 4 years ago
parent f4544885fc
commit 65f91d622c

@ -1775,11 +1775,22 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
int recently = (lastLost + LOST_RECENTLY < now ? 1 : 2);
EntityLog.log(this, account.name + " backoff=" + backoff + " recently=" + recently);
if (backoff < CONNECT_BACKOFF_MAX)
state.setBackoff(backoff * 2);
else if (backoff == CONNECT_BACKOFF_MAX)
if (Helper.isCharging(this))
EntityLog.log(this, "Device is charging");
else
state.setBackoff(CONNECT_BACKOFF_ALARM_START * 60);
else if (backoff < CONNECT_BACKOFF_ALARM_MAX * 60)
state.setBackoff(backoff * 2);
if (backoff <= CONNECT_BACKOFF_MAX) {
// Short back-off period, keep device awake
try {
db.account().setAccountBackoff(account.id, System.currentTimeMillis() + backoff * 1000L * recently);
state.acquire(backoff * 1000L * recently, true);
long interval = backoff * 1000L * recently;
db.account().setAccountBackoff(account.id, System.currentTimeMillis() + interval);
state.acquire(interval, true);
} catch (InterruptedException ex) {
Log.w(account.name + " backoff " + ex.toString());
} finally {
@ -1825,16 +1836,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
am.cancel(pi);
}
}
if (backoff < CONNECT_BACKOFF_MAX)
state.setBackoff(backoff * 2);
else if (backoff == CONNECT_BACKOFF_MAX)
if (Helper.isCharging(this))
EntityLog.log(this, "Device is charging");
else
state.setBackoff(CONNECT_BACKOFF_ALARM_START * 60);
else if (backoff < CONNECT_BACKOFF_ALARM_MAX * 60)
state.setBackoff(backoff * 2);
}
currentThread = Thread.currentThread().getId();

Loading…
Cancel
Save