am 985155fd: Merge "Fix regression re: bad folder sync key" into honeycomb

* commit '985155fddd4735fa46d67e0d28fba704f459b25c':
  Fix regression re: bad folder sync key
This commit is contained in:
Marc Blank 2011-01-19 08:35:33 -08:00 committed by Android Git Automerger
commit 260ca5935b

View File

@ -127,11 +127,16 @@ public class FolderSyncParser extends AbstractSyncParser {
if (status != Eas.FOLDER_STATUS_OK) {
mService.errorLog("FolderSync failed: " + status);
if (status == Eas.FOLDER_STATUS_INVALID_KEY) {
mAccount.mSyncKey = "0";
mService.errorLog("Bad sync key; RESET and delete all folders");
// Delete PIM data first
// Reset the sync key and save
mAccount.mSyncKey = "0";
ContentValues cv = new ContentValues();
cv.put(AccountColumns.SYNC_KEY, mAccount.mSyncKey);
mContentResolver.update(ContentUris.withAppendedId(Account.CONTENT_URI,
mAccount.mId), cv, null, null);
// Delete PIM data
ExchangeService.deleteAccountPIMData(mAccountId);
// Then, delete mailboxes
// And only then, delete mailboxes
mContentResolver.delete(Mailbox.CONTENT_URI, ALL_BUT_ACCOUNT_MAILBOX,
new String[] {Long.toString(mAccountId)});
// Stop existing syncs and reconstruct _main