From 43ae8e25c687acd896f59cd2a9249b7a3ae7e037 Mon Sep 17 00:00:00 2001 From: Android Dialer Date: Fri, 9 Mar 2018 11:09:34 -0800 Subject: Add spam blocking setting in spam module. Test: InAppSpamTest,ApdlSpamTest,VisualVoicemailUpdateTaskTest PiperOrigin-RevId: 188509191 Change-Id: I8b9c07dcc1c7b3b80ffc914ec99f4e6d80d50985 --- .../app/calllog/VisualVoicemailUpdateTask.java | 58 +++++++++++++++++----- .../android/dialer/logging/dialer_impression.proto | 15 +++++- java/com/android/dialer/spam/Spam.java | 2 + java/com/android/dialer/spam/SpamStub.java | 5 ++ 4 files changed, 67 insertions(+), 13 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java index 2e12cecf7..6d2581f46 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java @@ -32,8 +32,12 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.logging.DialerImpression; +import com.android.dialer.logging.Logger; import com.android.dialer.notification.DialerNotificationManager; import com.android.dialer.phonenumbercache.ContactInfo; +import com.android.dialer.spam.Spam; +import com.android.dialer.spam.SpamComponent; import com.android.dialer.telecom.TelecomUtil; import java.util.ArrayList; import java.util.List; @@ -44,7 +48,7 @@ class VisualVoicemailUpdateTask implements Worker getExistingNotificationCount(context); @@ -166,13 +179,6 @@ class VisualVoicemailUpdateTask implements Worker filterBlockedNumbers( Context context, FilteredNumberAsyncQueryHandler queryHandler, List newCalls) { Assert.isWorkerThread(); - if (FilteredNumbersUtil.hasRecentEmergencyCall(context)) { - LogUtil.i( - "VisualVoicemailUpdateTask.filterBlockedNumbers", - "not filtering due to recent emergency call"); - return newCalls; - } - List result = new ArrayList<>(); for (NewCall newCall : newCalls) { if (queryHandler.getBlockedIdSynchronous(newCall.number, newCall.countryIso) != null) { @@ -190,6 +196,30 @@ class VisualVoicemailUpdateTask implements Worker filterSpamNumbers( + Context context, Spam spam, List newCalls) { + Assert.isWorkerThread(); + if (!spam.isSpamBlockingEnabled()) { + return newCalls; + } + + List result = new ArrayList<>(); + for (NewCall newCall : newCalls) { + Logger.get(context).logImpression(DialerImpression.Type.INCOMING_VOICEMAIL_SCREENED); + if (spam.checkSpamStatusSynchronous(newCall.number, newCall.countryIso)) { + LogUtil.i( + "VisualVoicemailUpdateTask.filterSpamNumbers", + "found voicemail from spam number, suppressing notification"); + Logger.get(context) + .logImpression(DialerImpression.Type.INCOMING_VOICEMAIL_AUTO_BLOCKED_AS_SPAM); + } else { + result.add(newCall); + } + } + return result; + } + /** Updates the voicemail notifications displayed. */ static void scheduleTask(@NonNull Context context, @NonNull Runnable callback) { Assert.isNotNull(context); @@ -204,7 +234,8 @@ class VisualVoicemailUpdateTask implements Worker