Search in sources :

Example 1 with VoicemailFetchedCallback

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

the class OmtpVvmSyncService method download.

private boolean download(ImapHelper imapHelper, PhoneAccountHandle account) {
    List<Voicemail> serverVoicemails = imapHelper.fetchAllVoicemails();
    List<Voicemail> localVoicemails = mQueryHelper.getAllVoicemails(account);
    if (localVoicemails == null || serverVoicemails == null) {
        // Null value means the query failed.
        return false;
    }
    Map<String, Voicemail> remoteMap = buildMap(serverVoicemails);
    // by design (to make space).
    for (int i = 0; i < localVoicemails.size(); i++) {
        Voicemail localVoicemail = localVoicemails.get(i);
        Voicemail remoteVoicemail = remoteMap.remove(localVoicemail.getSourceData());
        // Do not delete voicemails that are archived marked as archived.
        if (remoteVoicemail == null) {
            mQueryHelper.deleteNonArchivedFromDatabase(localVoicemail);
        } else {
            if (remoteVoicemail.isRead() && !localVoicemail.isRead()) {
                mQueryHelper.markReadInDatabase(localVoicemail);
            }
            if (!TextUtils.isEmpty(remoteVoicemail.getTranscription()) && TextUtils.isEmpty(localVoicemail.getTranscription())) {
                LoggerUtils.logImpressionOnMainThread(mContext, DialerImpression.Type.VVM_TRANSCRIPTION_DOWNLOADED);
                mQueryHelper.updateWithTranscription(localVoicemail, remoteVoicemail.getTranscription());
            }
        }
    }
    // The leftover messages are messages that exist on the server but not locally.
    boolean prefetchEnabled = shouldPerformPrefetch(account, imapHelper);
    for (Voicemail remoteVoicemail : remoteMap.values()) {
        if (!TextUtils.isEmpty(remoteVoicemail.getTranscription())) {
            LoggerUtils.logImpressionOnMainThread(mContext, DialerImpression.Type.VVM_TRANSCRIPTION_DOWNLOADED);
        }
        Uri uri = VoicemailDatabaseUtil.insert(mContext, remoteVoicemail);
        if (prefetchEnabled) {
            VoicemailFetchedCallback fetchedCallback = new VoicemailFetchedCallback(mContext, uri, account);
            imapHelper.fetchVoicemailPayload(fetchedCallback, remoteVoicemail.getSourceData());
        }
    }
    return true;
}
Also used : Voicemail(com.android.voicemail.impl.Voicemail) VoicemailFetchedCallback(com.android.voicemail.impl.fetch.VoicemailFetchedCallback) Uri(android.net.Uri)

Example 2 with VoicemailFetchedCallback

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

the class OmtpVvmSyncService method syncOne.

private boolean syncOne(ImapHelper imapHelper, Voicemail voicemail, PhoneAccountHandle account) {
    if (shouldPerformPrefetch(account, imapHelper)) {
        VoicemailFetchedCallback callback = new VoicemailFetchedCallback(mContext, voicemail.getUri(), account);
        imapHelper.fetchVoicemailPayload(callback, voicemail.getSourceData());
    }
    return imapHelper.fetchTranscription(new TranscriptionFetchedCallback(mContext, voicemail), voicemail.getSourceData());
}
Also used : VoicemailFetchedCallback(com.android.voicemail.impl.fetch.VoicemailFetchedCallback)

Aggregations

VoicemailFetchedCallback (com.android.voicemail.impl.fetch.VoicemailFetchedCallback)2 Uri (android.net.Uri)1 Voicemail (com.android.voicemail.impl.Voicemail)1