Fix IMAP attachment upsync for forwarded messages

b/13883967

Change-Id: I496663144c41fa6353883bb77fa35fb14d1cfa07
This commit is contained in:
Tony Mantler 2014-04-07 16:26:04 -07:00
parent 021fb3cd78
commit 84dfa15541
2 changed files with 20 additions and 5 deletions

View File

@ -440,14 +440,26 @@ public class LegacyConversions {
// generated by unit tests or calendar invites
content = new ByteArrayInputStream(att.mContentBytes);
} else {
final Uri contentUri = Uri.parse(att.getCachedFileUri());
content = context.getContentResolver().openInputStream(contentUri);
String contentUriString = att.getCachedFileUri();
if (TextUtils.isEmpty(contentUriString)) {
contentUriString = att.getContentUri();
}
if (TextUtils.isEmpty(contentUriString)) {
content = null;
} else {
final Uri contentUri = Uri.parse(contentUriString);
content = context.getContentResolver().openInputStream(contentUri);
}
}
final String mimeType = att.mMimeType;
final Long contentSize = att.mSize;
final String contentId = att.mContentId;
final String filename = att.mFileName;
addAttachmentPart(mp, mimeType, contentSize, filename, contentId, content);
if (content != null) {
addAttachmentPart(mp, mimeType, contentSize, filename, contentId, content);
} else {
LogUtils.e(LogUtils.TAG, "Could not open attachment file for upsync");
}
} catch (final FileNotFoundException e) {
LogUtils.e(LogUtils.TAG, "File Not Found error on %s while upsyncing message",
att.getCachedFileUri());

View File

@ -1406,8 +1406,11 @@ public class ImapService extends Service {
FetchProfile fp2 = new FetchProfile();
fp2.add(FetchProfile.Item.ENVELOPE);
remoteFolder.fetch(new Message[] { remoteMessage2 }, fp2, null);
message.mServerTimeStamp = remoteMessage2.getInternalDate().getTime();
updateMessage = true;
final Date remoteDate = remoteMessage2.getInternalDate();
if (remoteDate != null) {
message.mServerTimeStamp = remoteMessage2.getInternalDate().getTime();
updateMessage = true;
}
}
} catch (MessagingException me) {
// skip it - we can live without this