Auto optimize fast keep alive

pull/183/head
M66B 5 years ago
parent 2055d51390
commit d5987b50df

@ -105,7 +105,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private static final long QUIT_DELAY = 5 * 1000L; // milliseconds private static final long QUIT_DELAY = 5 * 1000L; // milliseconds
private static final long STILL_THERE_THRESHOLD = 3 * 60 * 1000L; // milliseconds private static final long STILL_THERE_THRESHOLD = 3 * 60 * 1000L; // milliseconds
static final int DEFAULT_POLL_INTERVAL = 0; // minutes static final int DEFAULT_POLL_INTERVAL = 0; // minutes
private static final int STILL_THERE_POLL_INTERVAL = 15; // minutes private static final int OPTIMIZE_POLL_INTERVAL = 15; // minutes
private static final int CONNECT_BACKOFF_START = 8; // seconds private static final int CONNECT_BACKOFF_START = 8; // seconds
private static final int CONNECT_BACKOFF_MAX = 32; // seconds (totally ~1 minutes) private static final int CONNECT_BACKOFF_MAX = 32; // seconds (totally ~1 minutes)
private static final int CONNECT_BACKOFF_AlARM_START = 15; // minutes private static final int CONNECT_BACKOFF_AlARM_START = 15; // minutes
@ -952,7 +952,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
final boolean capIdle = iservice.hasCapability("IDLE"); final boolean capIdle = iservice.hasCapability("IDLE");
Log.i(account.name + " idle=" + capIdle); Log.i(account.name + " idle=" + capIdle);
if (!capIdle) if (!capIdle || account.poll_interval < OPTIMIZE_POLL_INTERVAL)
optimizeAccount(ServiceSynchronize.this, account, "IDLE"); optimizeAccount(ServiceSynchronize.this, account, "IDLE");
db.account().setAccountState(account.id, "connected"); db.account().setAccountState(account.id, "connected");
@ -1659,8 +1659,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
int pollInterval = prefs.getInt("poll_interval", DEFAULT_POLL_INTERVAL); int pollInterval = prefs.getInt("poll_interval", DEFAULT_POLL_INTERVAL);
EntityLog.log(context, "Auto optimize account=" + account.name + " poll interval=" + pollInterval);
if (pollInterval == 0) { if (pollInterval == 0) {
prefs.edit().putInt("poll_interval", STILL_THERE_POLL_INTERVAL).apply(); prefs.edit().putInt("poll_interval", OPTIMIZE_POLL_INTERVAL).apply();
try { try {
db.beginTransaction(); db.beginTransaction();
for (EntityAccount a : db.account().getAccounts()) for (EntityAccount a : db.account().getAccounts())

Loading…
Cancel
Save