diff options
author | Brandon Maxwell <maxwelb@google.com> | 2015-11-12 02:18:30 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-11-12 02:18:30 +0000 |
commit | df052aeb01e532aeab8dfece46a94f355c350051 (patch) | |
tree | 468998a1862b903298613534212a39ae558aa417 /src | |
parent | daf49992c272f54d3530f6f34cd6e65b4dddad88 (diff) | |
parent | 7d0a017b568ac0ca4133206872b503d4965e796e (diff) |
Merge "Blocking number suppresses voicemails in the same minute" into ub-contactsdialer-a-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/filterednumber/FilteredNumbersUtil.java | 29 |
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) { |