|
|
|
@ -126,6 +126,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
private static final int CONNECT_BACKOFF_START = 8; // seconds
|
|
|
|
|
private static final int CONNECT_BACKOFF_MAX = 1024; // seconds (1024 sec ~ 17 min)
|
|
|
|
|
private static final long STORE_NOOP_INTERVAL = 9 * 60 * 1000L; // ms
|
|
|
|
|
private static final long STORE_CLOSE_TIMEOUT = 20 * 1000L; // ms
|
|
|
|
|
private static final int ATTACHMENT_AUTO_DOWNLOAD_SIZE = 32 * 1024; // bytes
|
|
|
|
|
|
|
|
|
|
static final String ACTION_SYNCHRONIZE_FOLDER = BuildConfig.APPLICATION_ID + ".SYNCHRONIZE_FOLDER";
|
|
|
|
@ -792,10 +793,25 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
for (EntityFolder folder : folders.keySet())
|
|
|
|
|
db.folder().setFolderState(folder.id, "closing");
|
|
|
|
|
try {
|
|
|
|
|
// This can take some time
|
|
|
|
|
istore.close();
|
|
|
|
|
} catch (MessagingException ex) {
|
|
|
|
|
Log.w(Helper.TAG, account.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
|
Thread t = new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
try {
|
|
|
|
|
EntityLog.log(ServiceSynchronize.this, account.name + " store closing");
|
|
|
|
|
istore.close();
|
|
|
|
|
EntityLog.log(ServiceSynchronize.this, account.name + " store closed");
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
Log.w(Helper.TAG, account.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
t.start();
|
|
|
|
|
try {
|
|
|
|
|
t.join(STORE_CLOSE_TIMEOUT);
|
|
|
|
|
} catch (InterruptedException ex) {
|
|
|
|
|
Log.w(Helper.TAG, account.name + " Close timeout");
|
|
|
|
|
t.interrupt();
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
EntityLog.log(this, account.name + " closed");
|
|
|
|
|
db.account().setAccountState(account.id, null);
|
|
|
|
|