From aab514c942e8db9433f54652895e01516cdd588e Mon Sep 17 00:00:00 2001 From: Tony Mantler Date: Mon, 5 May 2014 13:25:51 -0700 Subject: [PATCH] Catch empty mime type and substitute application/octet-stream b/14564897 Change-Id: Id91dd18ef8b3fab449eb178bde73303107b78590 --- .../android/emailcommon/utility/AttachmentUtilities.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/emailcommon/src/com/android/emailcommon/utility/AttachmentUtilities.java b/emailcommon/src/com/android/emailcommon/utility/AttachmentUtilities.java index 25a998986..407a9034b 100644 --- a/emailcommon/src/com/android/emailcommon/utility/AttachmentUtilities.java +++ b/emailcommon/src/com/android/emailcommon/utility/AttachmentUtilities.java @@ -429,12 +429,16 @@ public class AttachmentUtilities { MediaScannerConnection.scanFile(context, new String[] {absolutePath}, null, null); + final String mimeType = TextUtils.isEmpty(attachment.mMimeType) ? + "application/octet-stream" : + attachment.mMimeType; + try { DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); long id = dm.addCompletedDownload(attachment.mFileName, attachment.mFileName, false /* do not use media scanner */, - attachment.mMimeType, absolutePath, size, + mimeType, absolutePath, size, true /* show notification */); contentUri = dm.getUriForDownloadedFile(id).toString(); } catch (final IllegalArgumentException e) {