From 37e2be2556b7e75f753936a74500577f8e717583 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Mon, 16 Apr 2012 13:44:38 -0700 Subject: [PATCH] Don't use SYNCED_MESSAGE_URI for POP3/Drafts/Outbox/Search Bug: 6330408 Change-Id: I84114d95fe4cf2a0137e2e9108ba349e58e21788 --- .../src/com/android/emailcommon/provider/Mailbox.java | 8 ++++++++ .../src/com/android/email/provider/EmailProvider.java | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/email2/emailcommon/src/com/android/emailcommon/provider/Mailbox.java b/email2/emailcommon/src/com/android/emailcommon/provider/Mailbox.java index adde91194..c7a1aecc4 100644 --- a/email2/emailcommon/src/com/android/emailcommon/provider/Mailbox.java +++ b/email2/emailcommon/src/com/android/emailcommon/provider/Mailbox.java @@ -518,6 +518,14 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns return false; } + public boolean uploadsToServer(Context context) { + if (mType == TYPE_DRAFTS || mType == TYPE_OUTBOX || mType == TYPE_SEARCH) { + return false; + } + String protocol = Account.getProtocol(context, mAccountKey); + return (!protocol.equals(HostAuth.SCHEME_POP3)); + } + /** * @return true if messages in a mailbox of a type can be replied/forwarded. */ diff --git a/email2/src/com/android/email/provider/EmailProvider.java b/email2/src/com/android/email/provider/EmailProvider.java index 91fe42f5f..22320d22a 100644 --- a/email2/src/com/android/email/provider/EmailProvider.java +++ b/email2/src/com/android/email/provider/EmailProvider.java @@ -3319,10 +3319,15 @@ outer: } private int uiUpdateMessage(Uri uri, ContentValues values) { - Uri ourUri = convertToEmailProviderUri(uri, Message.SYNCED_CONTENT_URI, true); - if (ourUri == null) return 0; + Context context = getContext(); Message msg = getMessageFromLastSegment(uri); if (msg == null) return 0; + Mailbox mailbox = Mailbox.restoreMailboxWithId(context, msg.mMailboxKey); + if (mailbox == null) return 0; + Uri ourBaseUri = + mailbox.uploadsToServer(context) ? Message.SYNCED_CONTENT_URI : Message.CONTENT_URI; + Uri ourUri = convertToEmailProviderUri(uri, ourBaseUri, true); + if (ourUri == null) return 0; ContentValues undoValues = new ContentValues(); ContentValues ourValues = convertUiMessageValues(msg, values); for (String columnName: ourValues.keySet()) { @@ -3339,7 +3344,7 @@ outer: } ContentProviderOperation op = ContentProviderOperation.newUpdate(convertToEmailProviderUri( - uri,Message.SYNCED_CONTENT_URI, false)) + uri, ourBaseUri, false)) .withValues(undoValues) .build(); addToSequence(uri, op);