diff options
Diffstat (limited to 'java/com/android/voicemail/impl/mail/internet')
-rw-r--r-- | java/com/android/voicemail/impl/mail/internet/MimeHeader.java | 1 | ||||
-rw-r--r-- | java/com/android/voicemail/impl/mail/internet/MimeMessage.java | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/java/com/android/voicemail/impl/mail/internet/MimeHeader.java b/java/com/android/voicemail/impl/mail/internet/MimeHeader.java index d41cdb3e4..8f0817650 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeHeader.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeHeader.java @@ -36,6 +36,7 @@ public class MimeHeader { public static final String HEADER_CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding"; public static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition"; public static final String HEADER_CONTENT_ID = "Content-ID"; + public static final String HEADER_CONTENT_DURATION = "Content-Duration"; /** Fields that should be omitted when writing the header using writeTo() */ private static final String[] WRITE_OMIT_FIELDS = { diff --git a/java/com/android/voicemail/impl/mail/internet/MimeMessage.java b/java/com/android/voicemail/impl/mail/internet/MimeMessage.java index 589720660..39378a092 100644 --- a/java/com/android/voicemail/impl/mail/internet/MimeMessage.java +++ b/java/com/android/voicemail/impl/mail/internet/MimeMessage.java @@ -15,7 +15,9 @@ */ package com.android.voicemail.impl.mail.internet; +import android.support.annotation.Nullable; import android.text.TextUtils; +import com.android.voicemail.impl.VvmLog; import com.android.voicemail.impl.mail.Address; import com.android.voicemail.impl.mail.Body; import com.android.voicemail.impl.mail.BodyPart; @@ -197,6 +199,28 @@ public class MimeMessage extends Message { } @Override + @Nullable + public Long getDuration() { + String durationHeader = null; + try { + durationHeader = getFirstHeader(MimeHeader.HEADER_CONTENT_DURATION); + } catch (MessagingException e) { + VvmLog.e("MimeMessage.getDuration", "cannot retrieve header: ", e); + return null; + } + if (durationHeader == null) { + VvmLog.w("MimeMessage.getDuration", "message missing Content-Duration header"); + return null; + } + try { + return Long.valueOf(durationHeader); + } catch (NumberFormatException e) { + VvmLog.w("MimeMessage.getDuration", "cannot parse duration " + durationHeader); + return null; + } + } + + @Override public String getContentType() throws MessagingException { final String contentType = getFirstHeader(MimeHeader.HEADER_CONTENT_TYPE); if (contentType == null) { |