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