diff options
author | Brandon Maxwell <maxwelb@google.com> | 2015-11-12 02:22:26 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-11-12 02:22:26 +0000 |
commit | 6a7fc74a36540d9d1bc5f33a0cf2d9f6c33bb918 (patch) | |
tree | f99453d8b234905440fd151f67657aa64dd0496e /src | |
parent | 70fab4c5a59c5667c971985a421e9dffa2b3225e (diff) | |
parent | df052aeb01e532aeab8dfece46a94f355c350051 (diff) |
Merge "Blocking number suppresses voicemails in the same minute" into ub-contactsdialer-a-dev
am: df052aeb01
* commit 'df052aeb01e532aeab8dfece46a94f355c350051':
Blocking number suppresses voicemails in the same minute
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) { |