Don't re-sync when refreshing the IDLE connection.

The refreshing (done every 25 minutes) should be a cheap operation.
Instead, do a (quick) re-sync after idling failed.

Change-Id: Idfcc775417dc02417142e51ca546c9564c660aab
This commit is contained in:
Danny Baumann 2015-06-10 12:49:02 +02:00 committed by Steve Kondik
parent 3e3b7b77b6
commit d13071399f

View File

@ -266,6 +266,10 @@ public class ImapService extends Service {
ImapIdleFolderHolder holder = ImapIdleFolderHolder.getInstance();
holder.registerMailboxForIdle(mContext, account, mMailbox);
// Request a quick sync to make sure we didn't lose any new mails
// during the failure time
ImapService.requestSync(mContext, account, mMailbox.mId, false);
} catch (MessagingException ex) {
LogUtils.w(LOG_TAG, ex, "Failed to register mailbox for idle. Reschedule.");
reschedulePing(increasePingDelay());
@ -906,24 +910,12 @@ public class ImapService extends Service {
return;
}
Store remoteStore = null;
try {
// Since we were idling, just perform a full sync of the mailbox to ensure
// we have all the items before kick the connection
remoteStore = Store.getInstance(account, context);
synchronizeMailboxGeneric(context, account, remoteStore,
mailbox, false, true);
// Kick mailbox
ImapIdleFolderHolder holder = ImapIdleFolderHolder.getInstance();
holder.kickIdledMailbox(context, mailbox, account);
} catch (Exception e) {
LogUtils.e(Logging.LOG_TAG,"Failed to kick idled connection "
+ "for mailbox " + mailboxId, e);
} finally {
if (remoteStore != null) {
remoteStore.closeConnections();
}
}
}
});