diff options
author | Brandon Maxwell <maxwelb@google.com> | 2015-11-30 20:03:42 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-11-30 20:03:42 +0000 |
commit | 3077d7dc671015a1d8103003d5d6030c03fe267a (patch) | |
tree | 597e7ef8800d5067a3d4e2b61a236593415062e8 | |
parent | 4fe9c80fca12ab4bbacfb9be851a41f04486bf57 (diff) | |
parent | 2dd62788bbc6aa486899b18869a7fdfaec056314 (diff) |
Checking for recent emergency call before deleting voiemail
am: 2dd62788bb
* commit '2dd62788bbc6aa486899b18869a7fdfaec056314':
Checking for recent emergency call before deleting voiemail
-rw-r--r-- | src/com/android/dialer/filterednumber/FilteredNumbersUtil.java | 14 | ||||
-rw-r--r-- | tests/src/com/android/dialer/filterednumber/FilteredNumbersUtilTest.java | 18 |
2 files changed, 26 insertions, 6 deletions
diff --git a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java index 23ce8a8de..e3870ded9 100644 --- a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java +++ b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java @@ -31,10 +31,6 @@ import android.telephony.PhoneNumberUtils; import android.text.TextUtils; 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; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; @@ -44,6 +40,8 @@ import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; +import java.util.concurrent.TimeUnit; + /** * Utility to help with tasks related to filtered numbers. */ @@ -53,11 +51,11 @@ public class FilteredNumbersUtil { private static final long RECENT_EMERGENCY_CALL_THRESHOLD_MS = 1000 * 60 * 60 * 24 * 2; // Pref key for storing the time of end of the last emergency call in milliseconds after epoch. - private static final String LAST_EMERGENCY_CALL_MS_PREF_KEY = "last_emergency_call_ms"; + protected static final String LAST_EMERGENCY_CALL_MS_PREF_KEY = "last_emergency_call_ms"; // Pref key for storing whether a notification has been dispatched to notify the user that call // blocking has been disabled because of a recent emergency call. - private static final String NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY = + protected static final String NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY = "notified_call_blocking_disabled_by_emergency_call"; public static final String CALL_BLOCKING_NOTIFICATION_TAG = "call_blocking"; @@ -241,6 +239,10 @@ public class FilteredNumbersUtil { return false; } + if (hasRecentEmergencyCall(context)) { + return false; + } + final Cursor cursor = context.getContentResolver().query( FilteredNumber.CONTENT_URI, new String[] { diff --git a/tests/src/com/android/dialer/filterednumber/FilteredNumbersUtilTest.java b/tests/src/com/android/dialer/filterednumber/FilteredNumbersUtilTest.java index 180295cba..ccd95ab69 100644 --- a/tests/src/com/android/dialer/filterednumber/FilteredNumbersUtilTest.java +++ b/tests/src/com/android/dialer/filterednumber/FilteredNumbersUtilTest.java @@ -15,6 +15,7 @@ */ package com.android.dialer.filterednumber; +import android.preference.PreferenceManager; import android.test.AndroidTestCase; import com.android.contacts.common.test.mocks.ContactsMockContext; @@ -46,6 +47,12 @@ public class FilteredNumbersUtilTest extends AndroidTestCase { public void setUp() throws Exception { super.setUp(); mContext = new ContactsMockContext(getContext(), FilteredNumberContract.AUTHORITY); + + // Reset whether an emergency number was dialed + PreferenceManager.getDefaultSharedPreferences(mContext) + .edit() + .putLong(FilteredNumbersUtil.LAST_EMERGENCY_CALL_MS_PREF_KEY, 0) + .apply(); } public void testShouldBlockVoicemail_NotBlocked() { @@ -78,6 +85,17 @@ public class FilteredNumbersUtilTest extends AndroidTestCase { COUNTRY_ISO, EARLIER_TIME + 30000)); } + public void testShouldBlockVoicemail_AfterEmergencyCall() { + // Just called emergency services + PreferenceManager.getDefaultSharedPreferences(mContext) + .edit() + .putLong(FilteredNumbersUtil.LAST_EMERGENCY_CALL_MS_PREF_KEY, + System.currentTimeMillis()) + .apply(); + assertFalse(FilteredNumbersUtil.shouldBlockVoicemail(mContext, NORMALIZED_NUMBER, + COUNTRY_ISO, 0)); + } + private void setupShouldBlockVoicemailQuery(long creationTimeMs) { Query query = mContext.getContactsProvider().expectQuery(FilteredNumber.CONTENT_URI) .withProjection(FILTERED_NUMBER_PROJECTION) |