From 16fea4dfc0707a7b95debaeb1a9cc93fe336f1bc Mon Sep 17 00:00:00 2001 From: Tony Mantler Date: Fri, 21 Feb 2014 11:14:48 -0800 Subject: [PATCH] Quit dropping inline attachments on the floor If we have image/* attachments with "Content-Disposition: inline" we would fetch the images immediately, then drop them on the floor instead of saving them to the DB. Add code to catch these attachments and save them. b/13132802 Change-Id: I5203bb1aa518aa46cdb3a38ead6f79af63b521ac --- src/com/android/email/LegacyConversions.java | 13 +++++++++++++ src/com/android/email/provider/Utilities.java | 1 + 2 files changed, 14 insertions(+) diff --git a/src/com/android/email/LegacyConversions.java b/src/com/android/email/LegacyConversions.java index eba35ba86..2c5d2ae17 100644 --- a/src/com/android/email/LegacyConversions.java +++ b/src/com/android/email/LegacyConversions.java @@ -21,6 +21,7 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; +import android.text.TextUtils; import com.android.emailcommon.Logging; import com.android.emailcommon.internet.MimeBodyPart; @@ -170,6 +171,18 @@ public class LegacyConversions { } } + public static void updateInlineAttachments(Context context, EmailContent.Message localMessage, + ArrayList inlineAttachments) throws MessagingException, IOException { + for (final Part inlinePart : inlineAttachments) { + final String disposition = MimeUtility.getHeaderParameter( + MimeUtility.unfoldAndDecode(inlinePart.getDisposition()), null); + if (!TextUtils.isEmpty(disposition)) { + // Treat inline parts as attachments + addOneAttachment(context, localMessage, inlinePart); + } + } + } + /** * Add a single attachment part to the message * diff --git a/src/com/android/email/provider/Utilities.java b/src/com/android/email/provider/Utilities.java index d66f73db4..b88dc1b03 100644 --- a/src/com/android/email/provider/Utilities.java +++ b/src/com/android/email/provider/Utilities.java @@ -137,6 +137,7 @@ public class Utilities { && loadStatus != EmailContent.Message.FLAG_LOADED_UNKNOWN) { // TODO(pwestbro): What should happen with unknown status? LegacyConversions.updateAttachments(context, localMessage, attachments); + LegacyConversions.updateInlineAttachments(context, localMessage, viewables); } else { EmailContent.Attachment att = new EmailContent.Attachment(); // Since we haven't actually loaded the attachment, we're just putting