From c91b1489e5ca2d259fe74ef957dacb62b2d689c8 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Sun, 27 Sep 2009 20:40:38 -0700 Subject: [PATCH] Don't send local changes of Drafts/Outbox to server (fixes #2149122) * Also, check that there's a valid serverId before doing any updates to a message Change-Id: I5cbfafcc20949b8a33ba08a12ea726168742205b --- .../exchange/adapter/EmailSyncAdapter.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/com/android/exchange/adapter/EmailSyncAdapter.java b/src/com/android/exchange/adapter/EmailSyncAdapter.java index ee4aae56a..a2bca3eca 100644 --- a/src/com/android/exchange/adapter/EmailSyncAdapter.java +++ b/src/com/android/exchange/adapter/EmailSyncAdapter.java @@ -544,6 +544,11 @@ public class EmailSyncAdapter extends AbstractSyncAdapter { public boolean sendLocalChanges(Serializer s) throws IOException { ContentResolver cr = mContext.getContentResolver(); + // Never upsync from these folders + if (mMailbox.mType == Mailbox.TYPE_DRAFTS || mMailbox.mType == Mailbox.TYPE_OUTBOX) { + return false; + } + // Find any of our deleted items Cursor c = cr.query(Message.DELETED_CONTENT_URI, Message.LIST_PROJECTION, MessageColumns.MAILBOX_KEY + '=' + mMailbox.mId, null, null); @@ -553,14 +558,16 @@ public class EmailSyncAdapter extends AbstractSyncAdapter { mDeletedIdList.clear(); try { while (c.moveToNext()) { - if (first) { + String serverId = c.getString(Message.LIST_SERVER_ID_COLUMN); + // Keep going if there's no serverId + if (serverId == null) { + continue; + } else if (first) { s.start(Tags.SYNC_COMMANDS); first = false; } // Send the command to delete this message - s.start(Tags.SYNC_DELETE) - .data(Tags.SYNC_SERVER_ID, c.getString(Message.LIST_SERVER_ID_COLUMN)) - .end(); // SYNC_DELETE + s.start(Tags.SYNC_DELETE).data(Tags.SYNC_SERVER_ID, serverId).end(); mDeletedIdList.add(c.getLong(Message.LIST_ID_COLUMN)); } } finally { @@ -591,7 +598,11 @@ public class EmailSyncAdapter extends AbstractSyncAdapter { if (!currentCursor.moveToFirst()) { continue; } - + // Keep going if there's no serverId + String serverId = currentCursor.getString(UPDATES_SERVER_ID_COLUMN); + if (serverId == null) { + continue; + } // If the message is now in the trash folder, it has been deleted by the user if (currentCursor.getLong(UPDATES_MAILBOX_KEY_COLUMN) == trashMailboxId) { if (first) { @@ -599,10 +610,7 @@ public class EmailSyncAdapter extends AbstractSyncAdapter { first = false; } // Send the command to delete this message - s.start(Tags.SYNC_DELETE) - .data(Tags.SYNC_SERVER_ID, - currentCursor.getString(UPDATES_SERVER_ID_COLUMN)) - .end(); // SYNC_DELETE + s.start(Tags.SYNC_DELETE).data(Tags.SYNC_SERVER_ID, serverId).end(); continue; }