summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-02-06 20:25:22 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-02-06 20:25:22 +0000
commit148a3935f0be5ffae2e18258f6a5a68d4c608546 (patch)
tree5cf671862e841d79abc07356cfd7bcb1e46c92d7
parentca4d8a396e6d41716be75fc324c3bcb6aeb8ce3c (diff)
parentf3bafa2ebd3c75bf74688bfc16c64fe21c79b81a (diff)
Merge "Include the timestamp in the data returned by the Spam interface."
-rw-r--r--java/com/android/dialer/spam/Spam.java5
-rw-r--r--java/com/android/dialer/spam/SpamStatus.java40
-rw-r--r--java/com/android/dialer/spam/SpamStub.java19
3 files changed, 58 insertions, 6 deletions
diff --git a/java/com/android/dialer/spam/Spam.java b/java/com/android/dialer/spam/Spam.java
index a79205bc0..5924d56ab 100644
--- a/java/com/android/dialer/spam/Spam.java
+++ b/java/com/android/dialer/spam/Spam.java
@@ -46,10 +46,9 @@ public interface Spam {
* Checks if each of numbers in the given list is suspected of being a spam.
*
* @param dialerPhoneNumbers A set of {@link DialerPhoneNumber}.
- * @return A {@link ListenableFuture} of a map that maps each number to its spam status
- * (true/false).
+ * @return A {@link ListenableFuture} of a map that maps each number to its {@link SpamStatus}.
*/
- ListenableFuture<ImmutableMap<DialerPhoneNumber, Boolean>> batchCheckSpamStatus(
+ ListenableFuture<ImmutableMap<DialerPhoneNumber, SpamStatus>> batchCheckSpamStatus(
ImmutableSet<DialerPhoneNumber> dialerPhoneNumbers);
/**
diff --git a/java/com/android/dialer/spam/SpamStatus.java b/java/com/android/dialer/spam/SpamStatus.java
new file mode 100644
index 000000000..0b859d1c7
--- /dev/null
+++ b/java/com/android/dialer/spam/SpamStatus.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.spam;
+
+import com.google.common.base.Optional;
+
+/** An interface representing a number's spam status. */
+@SuppressWarnings("Guava")
+public interface SpamStatus {
+
+ /** Returns true if the number is spam. */
+ boolean isSpam();
+
+ /**
+ * Returns the timestamp (in milliseconds) indicating when the number's spam status entered the
+ * underlying data source.
+ *
+ * <p>{@code Optional.absent()} is returned if
+ *
+ * <ul>
+ * <li>the number's spam status doesn't exist in the underlying data source, or
+ * <li>the underlying data source can't provide a timestamp.
+ * </ul>
+ */
+ Optional<Long> getTimestampMillis();
+}
diff --git a/java/com/android/dialer/spam/SpamStub.java b/java/com/android/dialer/spam/SpamStub.java
index 91a56e868..b171d0db4 100644
--- a/java/com/android/dialer/spam/SpamStub.java
+++ b/java/com/android/dialer/spam/SpamStub.java
@@ -21,6 +21,7 @@ import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor;
import com.android.dialer.logging.ContactLookupResult;
import com.android.dialer.logging.ContactSource;
import com.android.dialer.logging.ReportingLocation;
+import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Futures;
@@ -69,14 +70,26 @@ public class SpamStub implements Spam {
}
@Override
- public ListenableFuture<ImmutableMap<DialerPhoneNumber, Boolean>> batchCheckSpamStatus(
+ public ListenableFuture<ImmutableMap<DialerPhoneNumber, SpamStatus>> batchCheckSpamStatus(
ImmutableSet<DialerPhoneNumber> dialerPhoneNumbers) {
return backgroundExecutorService.submit(
() -> {
- ImmutableMap.Builder<DialerPhoneNumber, Boolean> resultBuilder =
+ ImmutableMap.Builder<DialerPhoneNumber, SpamStatus> resultBuilder =
new ImmutableMap.Builder<>();
for (DialerPhoneNumber dialerPhoneNumber : dialerPhoneNumbers) {
- resultBuilder.put(dialerPhoneNumber, false);
+ resultBuilder.put(
+ dialerPhoneNumber,
+ new SpamStatus() {
+ @Override
+ public boolean isSpam() {
+ return false;
+ }
+
+ @Override
+ public Optional<Long> getTimestampMillis() {
+ return Optional.absent();
+ }
+ });
}
return resultBuilder.build();
});