diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 0d156937bb..663459aa50 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -3,18 +3,9 @@ - diff --git a/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java b/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java index 2378c6fa0e..90b6cce073 100644 --- a/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java +++ b/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java @@ -496,8 +496,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback id = new LinkedHashMap<>(); @@ -3313,7 +3311,7 @@ class Core { account.partial_fetch = false; DB db = DB.getInstance(context); db.account().setAccountPartialFetch(account.id, account.partial_fetch); - state.error(new StoreClosedException(istore), session); + state.error(new StoreClosedException(istore)); } } @@ -4056,8 +4054,6 @@ class Core { } static class State { - private int session = -1; - private boolean active = false; private int backoff; private ConnectionHelper.NetworkState networkState; private Thread thread = new Thread(); @@ -4107,17 +4103,7 @@ class Core { return semaphore.tryAcquire(milliseconds, TimeUnit.MILLISECONDS); } - void error(Throwable ex, int session) { - if (!this.active || session != this.session) { - Log.i("Ignoring" + - " active=" + active + - " session=" + session + "/" + this.session + - " ex=" + ex); - return; - } - - active = false; - + void error(Throwable ex) { if (ex instanceof MessagingException && ("connection failure".equals(ex.getMessage()) || "Not connected".equals(ex.getMessage()) || // POP3 @@ -4148,18 +4134,12 @@ class Core { yield(); } - void reset(int run) { - session = run; - active = true; + void reset() { recoverable = true; lastActivity = null; resetBatches(); } - void setActive(boolean whether) { - this.active = whether; - } - void resetBatches() { synchronized (this) { for (FolderPriority key : sequence.keySet()) { @@ -4255,10 +4235,7 @@ class Core { } } - boolean batchCanRun(int session, long folder, int priority, long current) { - if (!this.active || session != this.session) - return false; - + boolean batchCanRun(long folder, int priority, long current) { synchronized (this) { FolderPriority key = new FolderPriority(folder, priority); boolean can = batch.get(key).equals(current); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index c980fd7727..73690d3eaf 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -35,7 +35,6 @@ import android.net.NetworkInfo; import android.net.NetworkRequest; import android.os.Build; import android.os.Bundle; -import android.os.OperationCanceledException; import android.os.PowerManager; import android.service.notification.StatusBarNotification; import android.text.TextUtils; @@ -905,13 +904,11 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences Log.w(account.name + " backoff " + ex.toString()); } - int run = 0; int errors = 0; state.setBackoff(CONNECT_BACKOFF_START); while (state.isRunning() && currentThread != null && currentThread.equals(thread)) { - final int session = ++run; - state.reset(session); + state.reset(); Log.i(account.name + " run thread=" + currentThread); final List cowners = new ArrayList<>(); @@ -1134,7 +1131,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences EntityLog.log( ServiceSynchronize.this, folder.name + " " + Log.formatThrowable(ex, false)); - state.error(ex, session); + state.error(ex); } finally { wlMessage.release(); } @@ -1163,7 +1160,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences EntityLog.log( ServiceSynchronize.this, folder.name + " " + Log.formatThrowable(ex, false)); - state.error(ex, session); + state.error(ex); } finally { wlMessage.release(); } @@ -1187,7 +1184,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences EntityLog.log( ServiceSynchronize.this, folder.name + " " + Log.formatThrowable(ex, false)); - state.error(ex, session); + state.error(ex); } finally { wlMessage.release(); } @@ -1210,7 +1207,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences EntityLog.log( ServiceSynchronize.this, folder.name + " " + Log.formatThrowable(ex, false)); - state.error(new FolderClosedException(ifolder, "IDLE"), session); + state.error(new FolderClosedException(ifolder, "IDLE")); } finally { Log.i(folder.name + " end idle"); } @@ -1346,8 +1343,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences Log.i(account.name + " folder " + folder.name + " flags=" + ifolder.getPermanentFlags()); } - Core.processOperations( - ServiceSynchronize.this, session, + Core.processOperations(ServiceSynchronize.this, account, folder, partition, iservice.getStore(), ifolder, @@ -1359,7 +1355,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences ServiceSynchronize.this, folder.name + " " + Log.formatThrowable(ex, false)); db.folder().setFolderError(folder.id, Log.formatThrowable(ex)); - state.error(new OperationCanceledException("Process"), session); + state.error(ex); } finally { if (shouldClose) { if (ifolder != null && ifolder.isOpen()) { @@ -1544,8 +1540,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences Log.i(account.name + " done state=" + state); } catch (Throwable ex) { - state.setActive(false); - Log.e(account.name, ex); EntityLog.log( ServiceSynchronize.this, @@ -1590,8 +1584,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences } } } finally { - state.setActive(false); - // Update state EntityLog.log(this, account.name + " closing"); db.account().setAccountState(account.id, "closing");