summaryrefslogtreecommitdiffstats
path: root/provider_src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2015-06-10 10:22:47 +0200
committerSteve Kondik <steve@cyngn.com>2015-10-18 14:05:32 -0700
commitb9532055e2fdf25d4c6b4dc5fca4a491e878ee16 (patch)
tree459458946f943a322cf9012085263e73e8f473a3 /provider_src
parentc59103c933a8bcfe38772bc5506b97c60a8b07f1 (diff)
downloadandroid_packages_apps_Email-b9532055e2fdf25d4c6b4dc5fca4a491e878ee16.tar.gz
android_packages_apps_Email-b9532055e2fdf25d4c6b4dc5fca4a491e878ee16.tar.bz2
android_packages_apps_Email-b9532055e2fdf25d4c6b4dc5fca4a491e878ee16.zip
Simplify logic.
Make sure that either messages are fetched or a sync is initiated, and there can be no situation where neither happens. Change-Id: I73ec2482a5a86c54309634f434b7d8fd77d7c079
Diffstat (limited to 'provider_src')
-rw-r--r--provider_src/com/android/email/service/ImapService.java48
1 files changed, 25 insertions, 23 deletions
diff --git a/provider_src/com/android/email/service/ImapService.java b/provider_src/com/android/email/service/ImapService.java
index b1efa937a..879618f31 100644
--- a/provider_src/com/android/email/service/ImapService.java
+++ b/provider_src/com/android/email/service/ImapService.java
@@ -2770,9 +2770,9 @@ public class ImapService extends Service {
// the changes just perform a full sync
final long timeSinceLastFullSync = SystemClock.elapsedRealtime() -
mailbox.mLastFullSyncTime;
- final boolean fullSync = timeSinceLastFullSync >= FULL_SYNC_INTERVAL_MILLIS
+ final boolean forceSync = timeSinceLastFullSync >= FULL_SYNC_INTERVAL_MILLIS
|| timeSinceLastFullSync < 0;
- if (fullSync) {
+ if (forceSync) {
needSync = true;
fetchMessages.clear();
@@ -2788,31 +2788,33 @@ public class ImapService extends Service {
+ ": need sync " + needSync + ", " + msgToFetchSize + " fetch messages");
}
- boolean syncRequested = false;
- try {
- // Sync fetch messages only if we are not going to perform a full sync
- if (msgToFetchSize > 0 && msgToFetchSize < MAX_MESSAGES_TO_FETCH && !needSync) {
- processImapFetchChanges(context, account, mailbox, fetchMessages);
- }
- if (needSync || msgToFetchSize > MAX_MESSAGES_TO_FETCH) {
- // With idle we fetched as much as possible. If as resync is required, then
- // if should be a full sync
- requestSync(context, account, mailbox.mId, true);
- syncRequested = true;
+ if (msgToFetchSize > 0) {
+ if (!needSync && msgToFetchSize <= MAX_MESSAGES_TO_FETCH) {
+ try {
+ processImapFetchChanges(context, account, mailbox, fetchMessages);
+ } catch (MessagingException ex) {
+ LogUtils.w(LOG_TAG,
+ "Failed to process imap idle changes for mailbox " + mailbox.mId);
+ needSync = true;
+ }
+ } else {
+ needSync = true;
}
- } catch (MessagingException ex) {
- LogUtils.w(LOG_TAG, "Failed to process imap idle changes for mailbox " + mailbox.mId);
}
- // In case no sync happens, re-add idle status
- try {
- if (!syncRequested && account.getSyncInterval() == Account.CHECK_INTERVAL_PUSH) {
- final ImapIdleFolderHolder holder = ImapIdleFolderHolder.getInstance();
- holder.registerMailboxForIdle(context, account, mailbox);
+ if (needSync) {
+ requestSync(context, account, mailbox.mId, true);
+ } else {
+ // In case no sync happens, re-add idle status
+ try {
+ if (account.getSyncInterval() == Account.CHECK_INTERVAL_PUSH) {
+ final ImapIdleFolderHolder holder = ImapIdleFolderHolder.getInstance();
+ holder.registerMailboxForIdle(context, account, mailbox);
+ }
+ } catch (MessagingException ex) {
+ LogUtils.w(LOG_TAG, "Failed to readd imap idle after no sync " +
+ "for mailbox " + mailbox.mId);
}
- } catch (MessagingException ex) {
- LogUtils.w(LOG_TAG, "Failed to readd imap idle after no sync " +
- "for mailbox " + mailbox.mId);
}
}
}