From 4bd39ec1d5644a0c84bc9272cd6e637664862a09 Mon Sep 17 00:00:00 2001 From: maxwelb Date: Fri, 4 May 2018 14:29:39 -0700 Subject: Add ListenableFuture based APIs for checkSpamStatus Bug: 79171382 Test: Tap, manually verified incoming spam call PiperOrigin-RevId: 195472160 Change-Id: I0cda8f36b350a9fc03e098667e8bd83ad8b1d161 --- java/com/android/dialer/spam/Spam.java | 37 ++++++++++++++++++++++-------- java/com/android/dialer/spam/SpamStub.java | 18 ++++++++++++--- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/java/com/android/dialer/spam/Spam.java b/java/com/android/dialer/spam/Spam.java index 21d770ed3..9d0f2a796 100644 --- a/java/com/android/dialer/spam/Spam.java +++ b/java/com/android/dialer/spam/Spam.java @@ -40,6 +40,34 @@ public interface Spam { ListenableFuture> batchCheckSpamStatus( ImmutableSet dialerPhoneNumbers); + /** + * Checks if the given number is suspected of being spam. + * + * @param dialerPhoneNumber the phone number. + * @return the {@link SpamStatus} for the given number. + */ + ListenableFuture checkSpamStatus(DialerPhoneNumber dialerPhoneNumber); + + /** + * Checks if the given number is suspected of being spam. + * + *

See {@link #checkSpamStatus(DialerPhoneNumber)}. + * + * @param number the phone number. + * @param defaultCountryIso the default country to use if it's not part of the number. + * @return the {@link SpamStatus} for the given number. + */ + ListenableFuture checkSpamStatus(String number, @Nullable String defaultCountryIso); + + /** + * Checks if the given number is suspected of being a spam. + * + * @param number The phone number of the call. + * @param countryIso The country ISO of the call. + * @param listener The callback to be invoked after {@code Info} is fetched. + */ + void checkSpamStatus(String number, String countryIso, Listener listener); + /** * Called as an indication that the Spam implementation should check whether downloading a spam * list needs to occur or not. @@ -54,15 +82,6 @@ public interface Spam { */ ListenableFuture updateSpamListDownload(boolean isEnabledByUser); - /** - * Checks if the given number is suspected of being a spam. - * - * @param number The phone number of the call. - * @param countryIso The country ISO of the call. - * @param listener The callback to be invoked after {@code Info} is fetched. - */ - void checkSpamStatus(String number, String countryIso, Listener listener); - /** * @param number The number to check if the number is in the user's white list (non spam list) * @param countryIso The country ISO of the call. diff --git a/java/com/android/dialer/spam/SpamStub.java b/java/com/android/dialer/spam/SpamStub.java index cbeb3b9b6..cf5693c9f 100644 --- a/java/com/android/dialer/spam/SpamStub.java +++ b/java/com/android/dialer/spam/SpamStub.java @@ -16,6 +16,7 @@ package com.android.dialer.spam; +import android.support.annotation.Nullable; import com.android.dialer.DialerPhoneNumber; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; import com.android.dialer.logging.ContactLookupResult; @@ -53,9 +54,14 @@ public class SpamStub implements Spam { } @Override - public ListenableFuture updateSpamListDownload(boolean isEnabledByUser) { - // no-op - return Futures.immediateFuture(null); + public ListenableFuture checkSpamStatus(DialerPhoneNumber dialerPhoneNumber) { + return Futures.immediateFuture(SimpleSpamStatus.notSpam()); + } + + @Override + public ListenableFuture checkSpamStatus( + String number, @Nullable String defaultCountryIso) { + return Futures.immediateFuture(SimpleSpamStatus.notSpam()); } @Override @@ -63,6 +69,12 @@ public class SpamStub implements Spam { listener.onComplete(false); } + @Override + public ListenableFuture updateSpamListDownload(boolean isEnabledByUser) { + // no-op + return Futures.immediateFuture(null); + } + @Override public void checkUserMarkedNonSpamStatus(String number, String countryIso, Listener listener) { listener.onComplete(false); -- cgit v1.2.3