use of com.android.dialer.spam.status.SpamStatus 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);
}
use of com.android.dialer.spam.status.SpamStatus in project android_packages_apps_Dialer by LineageOS.
the class CallList method onCallAdded.
public void onCallAdded(final Context context, final android.telecom.Call telecomCall, LatencyReport latencyReport) {
Trace.beginSection("CallList.onCallAdded");
if (telecomCall.getState() == Call.STATE_CONNECTING) {
MetricsComponent.get(context).metrics().startTimer(Metrics.ON_CALL_ADDED_TO_ON_INCALL_UI_SHOWN_OUTGOING);
} else if (telecomCall.getState() == Call.STATE_RINGING) {
MetricsComponent.get(context).metrics().startTimer(Metrics.ON_CALL_ADDED_TO_ON_INCALL_UI_SHOWN_INCOMING);
}
if (uiListeners != null) {
uiListeners.onCallAdded();
}
final DialerCall call = new DialerCall(context, this, telecomCall, latencyReport, true);
if (getFirstCall() != null) {
logSecondIncomingCall(context, getFirstCall(), call);
}
EnrichedCallManager manager = EnrichedCallComponent.get(context).getEnrichedCallManager();
manager.registerCapabilitiesListener(call);
manager.registerStateChangedListener(call);
Trace.beginSection("checkSpam");
call.addListener(new DialerCallListenerImpl(call));
LogUtil.d("CallList.onCallAdded", "callState=" + call.getState());
if (SpamComponent.get(context).spamSettings().isSpamEnabled()) {
String number = TelecomCallUtil.getNumber(telecomCall);
ListenableFuture<SpamStatus> futureSpamStatus = SpamComponent.get(context).spam().checkSpamStatus(number, call.getCountryIso());
Futures.addCallback(futureSpamStatus, new FutureCallback<SpamStatus>() {
@Override
public void onSuccess(@Nullable SpamStatus result) {
boolean isIncomingCall = call.getState() == DialerCallState.INCOMING || call.getState() == DialerCallState.CALL_WAITING;
boolean isSpam = result.isSpam();
call.setSpamStatus(result);
if (isIncomingCall) {
Logger.get(context).logCallImpression(isSpam ? DialerImpression.Type.INCOMING_SPAM_CALL : DialerImpression.Type.INCOMING_NON_SPAM_CALL, call.getUniqueCallId(), call.getTimeAddedMs());
}
onUpdateCall(call);
notifyGenericListeners();
}
@Override
public void onFailure(Throwable t) {
LogUtil.e("CallList.onFailure", "unable to query spam status", t);
}
}, DialerExecutorComponent.get(context).uiExecutor());
Trace.beginSection("updateUserMarkedSpamStatus");
Trace.endSection();
}
Trace.endSection();
Trace.beginSection("checkBlock");
FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(context);
filteredNumberAsyncQueryHandler.isBlockedNumber(new FilteredNumberAsyncQueryHandler.OnCheckBlockedListener() {
@Override
public void onCheckComplete(Integer id) {
if (id != null && id != FilteredNumberAsyncQueryHandler.INVALID_ID) {
call.setBlockedStatus(true);
// No need to update UI since it's only used for logging.
}
}
}, call.getNumber(), call.getCountryIso());
Trace.endSection();
if (call.getState() == DialerCallState.INCOMING || call.getState() == DialerCallState.CALL_WAITING) {
if (call.isActiveRttCall()) {
if (!call.isPhoneAccountRttCapable()) {
RttPromotion.setEnabled(context);
}
Logger.get(context).logCallImpression(DialerImpression.Type.INCOMING_RTT_CALL, call.getUniqueCallId(), call.getTimeAddedMs());
}
onIncoming(call);
} else {
if (call.isActiveRttCall()) {
Logger.get(context).logCallImpression(DialerImpression.Type.OUTGOING_RTT_CALL, call.getUniqueCallId(), call.getTimeAddedMs());
}
onUpdateCall(call);
notifyGenericListeners();
}
if (call.getState() != DialerCallState.INCOMING) {
// Only report outgoing calls
ShortcutUsageReporter.onOutgoingCallAdded(context, call.getNumber());
}
Trace.endSection();
}
Aggregations