summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrandon Maxwell <maxwelb@google.com>2015-11-11 16:36:16 -0800
committerBrandon Maxwell <maxwelb@google.com>2015-11-11 18:17:01 -0800
commit7d0a017b568ac0ca4133206872b503d4965e796e (patch)
tree17ca507ab56154de45e1897fbce5b09613fd539b /src
parent474954932457a94a0bed8e4d48ab01c9b006dff4 (diff)
Blocking number suppresses voicemails in the same minute
~ Modified FilteredNumbersUtil to check if a voicemail needs to be blocked by checking if the voicemail date matches the block date to the minute, rather than millisecond ~ Modified FilteredNumbersUtil#shouldBlockVoicemail to improve readability + Added tests to verify FilteredNumbersUtil#shouldBlockVoicemail Bug: 25346075 Change-Id: I9851a574f0d13b7f09c99438810454770c88aa8b
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/filterednumber/FilteredNumbersUtil.java29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
index 4cc8e7594..76d391357 100644
--- a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
+++ b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
@@ -35,6 +35,7 @@ import android.widget.Toast;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import com.android.contacts.common.testing.NeededForTesting;
import com.android.dialer.R;
@@ -247,21 +248,21 @@ public class FilteredNumbersUtil {
FilteredNumberColumns.NORMALIZED_NUMBER + "=?",
new String[] { normalizedNumber },
null);
-
- boolean shouldBlock = false;
- if (cursor != null) {
- try {
- if (cursor.moveToFirst()) {
- // Block if number is found and it was added before this voicemail was received.
- final long numberBlockedTimeMs = cursor.getLong(0);
- shouldBlock = cursor.getCount() > 0 && voicemailDateMs > numberBlockedTimeMs;
- }
- } finally {
- cursor.close();
- }
+ if (cursor == null) {
+ return false;
+ }
+ try {
+ /*
+ * Block if number is found and it was added before this voicemail was received.
+ * The VVM's date is reported with precision to the minute, even though its
+ * magnitude is in milliseconds, so we perform the comparison in minutes.
+ */
+ return cursor.moveToFirst() &&
+ TimeUnit.MINUTES.convert(voicemailDateMs, TimeUnit.MILLISECONDS) >=
+ TimeUnit.MINUTES.convert(cursor.getLong(0), TimeUnit.MILLISECONDS);
+ } finally {
+ cursor.close();
}
-
- return shouldBlock;
}
public static boolean hasRecentEmergencyCall(Context context) {