use of com.android.voicemail.impl.Voicemail.Builder in project android_packages_apps_Dialer by LineageOS.
the class OmtpMessageReceiver method processSync.
/**
* A sync message has two purposes: to signal a new voicemail message, and to indicate the
* voicemails on the server have changed remotely (usually through the TUI). Save the new message
* to the voicemail provider if it is the former case and perform a full sync in the latter case.
*
* @param message The sync message to extract data from.
*/
private void processSync(PhoneAccountHandle phone, SyncMessage message) {
switch(message.getSyncTriggerEvent()) {
case OmtpConstants.NEW_MESSAGE:
if (!OmtpConstants.VOICE.equals(message.getContentType())) {
VvmLog.i(TAG, "Non-voice message of type '" + message.getContentType() + "' received, ignoring");
return;
}
Builder builder = Voicemail.createForInsertion(message.getTimestampMillis(), message.getSender()).setPhoneAccount(phone).setSourceData(message.getId()).setDuration(message.getLength()).setSourcePackage(mContext.getPackageName());
Voicemail voicemail = builder.build();
VoicemailsQueryHelper queryHelper = new VoicemailsQueryHelper(mContext);
if (queryHelper.isVoicemailUnique(voicemail)) {
Uri uri = VoicemailDatabaseUtil.insert(mContext, voicemail);
voicemail = builder.setId(ContentUris.parseId(uri)).setUri(uri).build();
SyncOneTask.start(mContext, phone, voicemail);
}
break;
case OmtpConstants.MAILBOX_UPDATE:
SyncTask.start(mContext, phone, OmtpVvmSyncService.SYNC_DOWNLOAD_ONLY);
break;
case OmtpConstants.GREETINGS_UPDATE:
// Not implemented in V1
break;
default:
VvmLog.e(TAG, "Unrecognized sync trigger event: " + message.getSyncTriggerEvent());
break;
}
}
Aggregations