Search in sources :

Example 1 with SpamInfo

use of com.android.dialer.phonelookup.PhoneLookupInfo.SpamInfo in project android_packages_apps_Dialer by LineageOS.

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.status.SpamStatus) DialerPhoneNumber(com.android.dialer.DialerPhoneNumber) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with SpamInfo

use of com.android.dialer.phonelookup.PhoneLookupInfo.SpamInfo 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)2 SpamInfo (com.android.dialer.phonelookup.PhoneLookupInfo.SpamInfo)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 SpamStatus (com.android.dialer.spam.SpamStatus)1 SpamStatus (com.android.dialer.spam.status.SpamStatus)1