From d88b2c704f6b710d4a5dd1ebe75263657b1b1018 Mon Sep 17 00:00:00 2001 From: maxwelb Date: Thu, 5 Apr 2018 17:28:46 -0700 Subject: Add Spam#updateSpamSync API to control when syncing the Apdl spam list is enabled Bug: 69072794 Test: Tap PiperOrigin-RevId: 191824966 Change-Id: Ia219074f32f77f308d88e9c29edb1e56c694bcc7 --- java/com/android/dialer/spam/Spam.java | 16 ++++++++++++++++ java/com/android/dialer/spam/SpamStub.java | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/java/com/android/dialer/spam/Spam.java b/java/com/android/dialer/spam/Spam.java index c22f541d8..21d770ed3 100644 --- a/java/com/android/dialer/spam/Spam.java +++ b/java/com/android/dialer/spam/Spam.java @@ -16,6 +16,8 @@ package com.android.dialer.spam; +import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.android.dialer.DialerPhoneNumber; @@ -38,6 +40,20 @@ public interface Spam { ListenableFuture> batchCheckSpamStatus( ImmutableSet dialerPhoneNumbers); + /** + * Called as an indication that the Spam implementation should check whether downloading a spam + * list needs to occur or not. + * + * @param isEnabledByUser true if spam is enabled by the user. Generally, this value should be + * passed as {@link SpamSettings#isSpamEnabled()}. In the scenario where the user toggles the + * spam setting isSpamEnabled returns stale data: the SharedPreferences will not have updated + * prior to executing {@link OnPreferenceChangeListener#onPreferenceChange(Preference, + * Object)}. For that case, use the new value provided in the onPreferenceChange callback. + * @return a future containing no value. It is only an indication of success or failure of the + * operation. + */ + ListenableFuture updateSpamListDownload(boolean isEnabledByUser); + /** * Checks if the given number is suspected of being a spam. * diff --git a/java/com/android/dialer/spam/SpamStub.java b/java/com/android/dialer/spam/SpamStub.java index 28f26d13b..8851fd09e 100644 --- a/java/com/android/dialer/spam/SpamStub.java +++ b/java/com/android/dialer/spam/SpamStub.java @@ -65,6 +65,12 @@ public class SpamStub implements Spam { }); } + @Override + public ListenableFuture updateSpamListDownload(boolean isEnabledByUser) { + // no-op + return Futures.immediateFuture(null); + } + @Override public void checkSpamStatus(String number, String countryIso, Listener listener) { listener.onComplete(false); -- cgit v1.2.3