1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-25 17:27:00 +00:00

Simplification

This commit is contained in:
M66B 2020-10-26 18:56:34 +01:00
parent 874b8c245e
commit fff585490f

View file

@ -950,7 +950,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if ("Still here".equals(message) && !isTransient(account)) { if ("Still here".equals(message) && !isTransient(account)) {
long now = new Date().getTime(); long now = new Date().getTime();
if (now - start < STILL_THERE_THRESHOLD) if (now - start < STILL_THERE_THRESHOLD)
optimizeAccount(ServiceSynchronize.this, account, message); optimizeAccount(account, message);
} }
} else } else
try { try {
@ -1009,7 +1009,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 || account.poll_interval < OPTIMIZE_KEEP_ALIVE_INTERVAL) if (!capIdle || account.poll_interval < OPTIMIZE_KEEP_ALIVE_INTERVAL)
optimizeAccount(ServiceSynchronize.this, account, "IDLE"); optimizeAccount(account, "IDLE");
db.account().setAccountState(account.id, "connected"); db.account().setAccountState(account.id, "connected");
db.account().setAccountError(account.id, null); db.account().setAccountError(account.id, null);
@ -1807,16 +1807,16 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
return (!enabled || account.ondemand || (pollInterval > 0 && !account.poll_exempted)); return (!enabled || account.ondemand || (pollInterval > 0 && !account.poll_exempted));
} }
private void optimizeAccount(Context context, EntityAccount account, String reason) { private void optimizeAccount(EntityAccount account, String reason) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean auto_optimize = prefs.getBoolean("auto_optimize", false); boolean auto_optimize = prefs.getBoolean("auto_optimize", false);
if (!auto_optimize) if (!auto_optimize)
return; return;
DB db = DB.getInstance(context); DB db = DB.getInstance(this);
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); EntityLog.log(this, "Auto optimize account=" + account.name + " poll interval=" + pollInterval);
if (pollInterval == 0) { if (pollInterval == 0) {
try { try {
db.beginTransaction(); db.beginTransaction();