Search in sources :

Example 6 with Voicemail

use of com.android.voicemail.impl.Voicemail in project android_packages_apps_Dialer by LineageOS.

the class ImapHelper method getVoicemailFromMessageStructure.

/**
 * Extract voicemail details from the message structure. Also fetch transcription if a
 * transcription exists.
 */
private Voicemail getVoicemailFromMessageStructure(MessageStructureWrapper messageStructureWrapper) throws MessagingException {
    Message messageDetails = messageStructureWrapper.messageStructure;
    TranscriptionFetchedListener listener = new TranscriptionFetchedListener();
    if (messageStructureWrapper.transcriptionBodyPart != null) {
        FetchProfile fetchProfile = new FetchProfile();
        fetchProfile.add(messageStructureWrapper.transcriptionBodyPart);
        mFolder.fetch(new Message[] { messageDetails }, fetchProfile, listener);
    }
    // Found an audio attachment, this is a valid voicemail.
    long time = messageDetails.getSentDate().getTime();
    String number = getNumber(messageDetails.getFrom());
    boolean isRead = Arrays.asList(messageDetails.getFlags()).contains(Flag.SEEN);
    Long duration = messageDetails.getDuration();
    Voicemail.Builder builder = Voicemail.createForInsertion(time, number).setPhoneAccount(mPhoneAccount).setSourcePackage(mContext.getPackageName()).setSourceData(messageDetails.getUid()).setIsRead(isRead).setTranscription(listener.getVoicemailTranscription());
    if (duration != null) {
        builder.setDuration(duration);
    }
    return builder.build();
}
Also used : FetchProfile(com.android.voicemail.impl.mail.FetchProfile) Message(com.android.voicemail.impl.mail.Message) MimeMessage(com.android.voicemail.impl.mail.internet.MimeMessage) Voicemail(com.android.voicemail.impl.Voicemail)

Aggregations

Voicemail (com.android.voicemail.impl.Voicemail)6 ArrayList (java.util.ArrayList)3 Cursor (android.database.Cursor)2 Uri (android.net.Uri)2 Message (com.android.voicemail.impl.mail.Message)2 MimeMessage (com.android.voicemail.impl.mail.internet.MimeMessage)2 TargetApi (android.annotation.TargetApi)1 Builder (com.android.voicemail.impl.Voicemail.Builder)1 VoicemailFetchedCallback (com.android.voicemail.impl.fetch.VoicemailFetchedCallback)1 FetchProfile (com.android.voicemail.impl.mail.FetchProfile)1 MessagingException (com.android.voicemail.impl.mail.MessagingException)1 VoicemailsQueryHelper (com.android.voicemail.impl.sync.VoicemailsQueryHelper)1