From d676ab6a982ad76bb29beef5894823e5c6f18a77 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 3 Nov 2009 18:11:02 -0800 Subject: [PATCH] Improved fix for #2189704 (sync loss) * The prior fix prevented looping in the case that a new sync key wasn't received. * Unfortunately, the prior fix tested for the looping condition (moreAvailable) before it would have been set. * The correct fix is to detect the looping condition after both the sync key and the moreAvailable flag are guaranteed to have been set Change-Id: I2eee4ddc123fb2a5ce4ef3bd4e7d0614fcfbdf36 --- .../exchange/adapter/AbstractSyncParser.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/com/android/exchange/adapter/AbstractSyncParser.java b/src/com/android/exchange/adapter/AbstractSyncParser.java index 4c73fd8f3..97dfb5011 100644 --- a/src/com/android/exchange/adapter/AbstractSyncParser.java +++ b/src/com/android/exchange/adapter/AbstractSyncParser.java @@ -87,6 +87,7 @@ public abstract class AbstractSyncParser extends Parser { public boolean parse() throws IOException { int status; boolean moreAvailable = false; + boolean newSyncKey = false; int interval = mMailbox.mSyncInterval; // If we're not at the top of the xml tree, throw an exception @@ -140,10 +141,8 @@ public abstract class AbstractSyncParser extends Parser { mAdapter.setSyncKey(newKey, true); cv.put(MailboxColumns.SYNC_KEY, newKey); mailboxUpdated = true; - } else if (moreAvailable) { - userLog("!! SyncKey hasn't changed, setting moreAvailable = false"); - moreAvailable = false; - } + newSyncKey = true; + } // If we were pushing (i.e. auto-start), now we'll become ping-triggered if (mMailbox.mSyncInterval == Mailbox.CHECK_INTERVAL_PUSH) { mMailbox.mSyncInterval = Mailbox.CHECK_INTERVAL_PING; @@ -153,6 +152,12 @@ public abstract class AbstractSyncParser extends Parser { } } + // If we don't have a new sync key, ignore moreAvailable (or we'll loop) + if (moreAvailable && !newSyncKey) { + userLog("!! SyncKey hasn't changed, setting moreAvailable = false"); + moreAvailable = false; + } + // Commit any changes commit();