diff --git a/src/com/android/email/provider/AttachmentProvider.java b/src/com/android/email/provider/AttachmentProvider.java index 3b7818d74..309152cba 100644 --- a/src/com/android/email/provider/AttachmentProvider.java +++ b/src/com/android/email/provider/AttachmentProvider.java @@ -46,18 +46,18 @@ import java.util.List; /* * A simple ContentProvider that allows file access to Email's attachments. - * + * * The URI scheme is as follows. For raw file access: * content://com.android.email.attachmentprovider/acct#/attach#/RAW - * + * * And for access to thumbnails: * content://com.android.email.attachmentprovider/acct#/attach#/THUMBNAIL/width#/height# * * The on-disk (storage) schema is as follows. - * + * * Attachments are stored at: /account#.db_att/item# * Thumbnails are stored at: /thmb_account#_item# - * + * * Using the standard application context, account #10 and attachment # 20, this would be: * /data/data/com.android.email/databases/10.db_att/20 * /data/data/com.android.email/cache/thmb_10_20 @@ -178,6 +178,8 @@ public class AttachmentProvider extends ContentProvider { * Helper to convert unknown or unmapped attachments to something useful based on filename * extensions. Imperfect, but helps. * + * If the file extension is ".eml", return "message/rfc822", which is necessary for the email + * app to open it. * If the given mime type is non-empty and anything other than "application/octet-stream", * just return it. (This is the most common case.) * If the filename has a recognizable extension and it converts to a mime type, return that. @@ -189,6 +191,9 @@ public class AttachmentProvider extends ContentProvider { * @return A likely mime type for the attachment */ public static String inferMimeType(String fileName, String mimeType) { + if (fileName != null && fileName.toLowerCase().endsWith(".eml")) { + return "message/rfc822"; + } // If the given mime type appears to be non-empty and non-generic - return it if (!TextUtils.isEmpty(mimeType) && !"application/octet-stream".equalsIgnoreCase(mimeType)) { @@ -219,12 +224,12 @@ public class AttachmentProvider extends ContentProvider { /** * Open an attachment file. There are two "modes" - "raw", which returns an actual file, * and "thumbnail", which attempts to generate a thumbnail image. - * + * * Thumbnails are cached for easy space recovery and cleanup. - * + * * TODO: The thumbnail mode returns null for its failure cases, instead of throwing * FileNotFoundException, and should be fixed for consistency. - * + * * @throws FileNotFoundException */ @Override @@ -291,7 +296,7 @@ public class AttachmentProvider extends ContentProvider { /** * Returns a cursor based on the data in the attachments table, or null if the attachment * is not recorded in the table. - * + * * Supports REST Uri only, for a single row - selection, selection args, and sortOrder are * ignored (non-null values should probably throw an exception....) */ @@ -383,7 +388,7 @@ public class AttachmentProvider extends ContentProvider { /** * Resolve attachment id to content URI. Returns the resolved content URI (from the attachment * DB) or, if not found, simply returns the incoming value. - * + * * @param attachmentUri * @return resolved content URI * diff --git a/tests/src/com/android/email/provider/AttachmentProviderTests.java b/tests/src/com/android/email/provider/AttachmentProviderTests.java index 2b67a28f0..26b91e4c5 100644 --- a/tests/src/com/android/email/provider/AttachmentProviderTests.java +++ b/tests/src/com/android/email/provider/AttachmentProviderTests.java @@ -44,7 +44,7 @@ import java.io.IOException; /** * Tests of the Email Attachments provider. - * + * * You can run this entire test case with: * runtest -c com.android.email.provider.AttachmentProviderTests email */ @@ -270,11 +270,13 @@ public class AttachmentProviderTests extends ProviderTestCase2