summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Maxwell <maxwelb@google.com>2015-11-20 15:22:00 -0800
committerBrandon Maxwell <maxwelb@google.com>2015-11-30 11:42:02 -0800
commit2dd62788bbc6aa486899b18869a7fdfaec056314 (patch)
treea4d0fd20e62535c56894383aea80b62421bdb16c
parent9650e1bb0c9a61be7e9250bd0c47cb5a5d29efff (diff)
Checking for recent emergency call before deleting voiemail
Bug: 25818151 Change-Id: I6b8b5ebfe1c9555b8394ad7db652e23bbc216f83
-rw-r--r--src/com/android/dialer/filterednumber/FilteredNumbersUtil.java14
-rw-r--r--tests/src/com/android/dialer/filterednumber/FilteredNumbersUtilTest.java18
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)