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();
}
Aggregations