diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-08-31 16:17:04 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-08-31 16:17:04 +0000 |
commit | c39ea3c55fac807c0b98aabdf56c70dc8a49036c (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/voicemail/impl/mail/internet/MimeMessage.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) | |
parent | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (diff) |
Merge "Update Dialer source to latest internal Google revision."
Diffstat (limited to 'java/com/android/voicemail/impl/mail/internet/MimeMessage.java')
-rw-r--r-- | java/com/android/voicemail/impl/mail/internet/MimeMessage.java | 24 |
1 files changed, 24 insertions, 0 deletions
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) { |