Fix attachment loading for messages which have been forwarded
These attachments have a contentUri where the attachment ID is not equal to the ID of the actual attachment. b/13900073 Change-Id: Ic62b8165be2e80bc47eac40dc9eb5ac53c3cd6c5
This commit is contained in:
parent
021fb3cd78
commit
2aeb498d4e
|
@ -1373,14 +1373,16 @@ public abstract class EmailContent {
|
|||
// This must be used with an appended id: ContentUris.withAppendedId(MESSAGE_ID_URI, id)
|
||||
public static Uri MESSAGE_ID_URI;
|
||||
public static String ATTACHMENT_PROVIDER_URI_PREFIX;
|
||||
public static String ATTACHMENT_PROVIDER_AUTHORITY;
|
||||
public static boolean sUsingLegacyPrefix;
|
||||
|
||||
public static void initAttachment() {
|
||||
CONTENT_URI = Uri.parse(EmailContent.CONTENT_URI + "/attachment");
|
||||
MESSAGE_ID_URI = Uri.parse(
|
||||
EmailContent.CONTENT_URI + "/attachment/message");
|
||||
ATTACHMENT_PROVIDER_URI_PREFIX = "content://" + EmailContent.EMAIL_PACKAGE_NAME +
|
||||
ATTACHMENT_PROVIDER_AUTHORITY = EmailContent.EMAIL_PACKAGE_NAME +
|
||||
".attachmentprovider";
|
||||
ATTACHMENT_PROVIDER_URI_PREFIX = "content://" + ATTACHMENT_PROVIDER_AUTHORITY;
|
||||
sUsingLegacyPrefix =
|
||||
ATTACHMENT_PROVIDER_URI_PREFIX.equals(ATTACHMENT_PROVIDER_LEGACY_URI_PREFIX);
|
||||
}
|
||||
|
|
|
@ -3710,8 +3710,10 @@ public class EmailProvider extends ContentProvider {
|
|||
Attachment att = Attachment.restoreAttachmentWithId(getContext(), id);
|
||||
// MAKE SURE THESE VALUES STAY IN SYNC WITH GEN QUERY ATTACHMENTS
|
||||
ContentValues values = new ContentValues(2);
|
||||
values.put(AttachmentColumns.CONTENT_URI,
|
||||
AttachmentUtilities.getAttachmentUri(att.mAccountKey, id).toString());
|
||||
if (TextUtils.isEmpty(att.getContentUri())) {
|
||||
values.put(AttachmentColumns.CONTENT_URI,
|
||||
AttachmentUtilities.getAttachmentUri(att.mAccountKey, id).toString());
|
||||
}
|
||||
values.put(UIProvider.AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN, 1);
|
||||
StringBuilder sb = genSelect(getAttachmentMap(), uiProjection, values);
|
||||
sb.append(" FROM ")
|
||||
|
@ -4076,8 +4078,19 @@ public class EmailProvider extends ContentProvider {
|
|||
TextUtils.equals(att.mMimeType, MimeType.ANDROID_ARCHIVE)) {
|
||||
contentUri = att.getContentUri();
|
||||
} else {
|
||||
contentUri =
|
||||
AttachmentUtilities.getAttachmentUri(att.mAccountKey, id).toString();
|
||||
final String attUriString = att.getContentUri();
|
||||
final String authority;
|
||||
if (!TextUtils.isEmpty(attUriString)) {
|
||||
authority = Uri.parse(attUriString).getAuthority();
|
||||
} else {
|
||||
authority = null;
|
||||
}
|
||||
if (TextUtils.equals(authority, Attachment.ATTACHMENT_PROVIDER_AUTHORITY)) {
|
||||
contentUri = attUriString;
|
||||
} else {
|
||||
contentUri = AttachmentUtilities.getAttachmentUri(att.mAccountKey, id)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
return contentUri;
|
||||
|
||||
|
|
Loading…
Reference in New Issue