Search in sources :

Example 1 with SpamStatus

use of com.android.dialer.spam.SpamStatus in project android_packages_apps_Dialer by MoKee.

the class SpamPhoneLookup method getMostRecentInfo.

@Override
public ListenableFuture<ImmutableMap<DialerPhoneNumber, SpamInfo>> getMostRecentInfo(ImmutableMap<DialerPhoneNumber, SpamInfo> existingInfoMap) {
    currentLastTimestampProcessed = null;
    ListenableFuture<ImmutableMap<DialerPhoneNumber, SpamStatus>> spamStatusMapFuture = spam.batchCheckSpamStatus(existingInfoMap.keySet());
    return Futures.transform(spamStatusMapFuture, spamStatusMap -> {
        ImmutableMap.Builder<DialerPhoneNumber, SpamInfo> mostRecentSpamInfo = new ImmutableMap.Builder<>();
        for (Entry<DialerPhoneNumber, SpamStatus> dialerPhoneNumberAndSpamStatus : spamStatusMap.entrySet()) {
            DialerPhoneNumber dialerPhoneNumber = dialerPhoneNumberAndSpamStatus.getKey();
            SpamStatus spamStatus = dialerPhoneNumberAndSpamStatus.getValue();
            mostRecentSpamInfo.put(dialerPhoneNumber, SpamInfo.newBuilder().setIsSpam(spamStatus.isSpam()).build());
            Optional<Long> timestampMillis = spamStatus.getTimestampMillis();
            if (timestampMillis.isPresent()) {
                currentLastTimestampProcessed = currentLastTimestampProcessed == null ? timestampMillis.get() : Math.max(timestampMillis.get(), currentLastTimestampProcessed);
            }
        }
        // triggering the bulk update flow repeatedly.
        if (currentLastTimestampProcessed == null) {
            currentLastTimestampProcessed = System.currentTimeMillis();
        }
        return mostRecentSpamInfo.build();
    }, lightweightExecutorService);
}
Also used : SpamInfo(com.android.dialer.phonelookup.PhoneLookupInfo.SpamInfo) SpamStatus(com.android.dialer.spam.SpamStatus) DialerPhoneNumber(com.android.dialer.DialerPhoneNumber) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

DialerPhoneNumber (com.android.dialer.DialerPhoneNumber)1 SpamInfo (com.android.dialer.phonelookup.PhoneLookupInfo.SpamInfo)1 SpamStatus (com.android.dialer.spam.SpamStatus)1 ImmutableMap (com.google.common.collect.ImmutableMap)1