summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/blocking
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-05-31 08:53:10 -0700
committerEric Erfanian <erfanian@google.com>2017-05-31 08:53:10 -0700
commit83b20211c3be04a850de3674977deee8e448d17f (patch)
treea596b78feffa5d267b227762a2917da2e3eaf9c1 /java/com/android/dialer/blocking
parentd40e05b9e0d8331a01af64e37730d177b9b948d5 (diff)
Update Dialer to v10 RC45.
This release was created following the instructions at: go/dialer-aosp-release Subsequent dialer releases will follow as O bugs are fixed, until we reach our final RC. Version: 10 Candidate: RC45 Branch: dialer-android_release_branch/153304843.1 dialer-android_20170416.00/dialer-android_20170416.00_RC45 This release contains the following bug fixes since RC39: Bug: 38131932 38302993 38347350 38368993 38395481 62100344 Test: make, on device Change-Id: Ib4af5dcc58c684d51ea1f4628b301e40184b81b3
Diffstat (limited to 'java/com/android/dialer/blocking')
-rw-r--r--java/com/android/dialer/blocking/FilteredNumberCompat.java3
-rw-r--r--java/com/android/dialer/blocking/FilteredNumbersUtil.java15
2 files changed, 11 insertions, 7 deletions
diff --git a/java/com/android/dialer/blocking/FilteredNumberCompat.java b/java/com/android/dialer/blocking/FilteredNumberCompat.java
index 0ee85d897..9e0112762 100644
--- a/java/com/android/dialer/blocking/FilteredNumberCompat.java
+++ b/java/com/android/dialer/blocking/FilteredNumberCompat.java
@@ -275,7 +275,8 @@ public class FilteredNumberCompat {
&& safeBlockedNumbersContractCanCurrentUserBlockNumbers(context);
}
- static void setCanAttemptBlockOperationsForTest(boolean canAttempt) {
+ @VisibleForTesting(otherwise = VisibleForTesting.NONE)
+ public static void setCanAttemptBlockOperationsForTest(boolean canAttempt) {
canAttemptBlockOperationsForTest = canAttempt;
}
diff --git a/java/com/android/dialer/blocking/FilteredNumbersUtil.java b/java/com/android/dialer/blocking/FilteredNumbersUtil.java
index 3c001a2c2..cdcf1f78d 100644
--- a/java/com/android/dialer/blocking/FilteredNumbersUtil.java
+++ b/java/com/android/dialer/blocking/FilteredNumbersUtil.java
@@ -22,12 +22,12 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.os.AsyncTask;
-import android.preference.PreferenceManager;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
+import android.support.v4.os.UserManagerCompat;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.widget.Toast;
@@ -39,6 +39,7 @@ import com.android.dialer.notification.NotificationChannelManager;
import com.android.dialer.notification.NotificationChannelManager.Channel;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.PermissionsUtil;
+import java.util.concurrent.TimeUnit;
/** Utility to help with tasks related to filtered numbers. */
public class FilteredNumbersUtil {
@@ -54,7 +55,7 @@ public class FilteredNumbersUtil {
protected static final String NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY =
"notified_call_blocking_disabled_by_emergency_call";
// Disable incoming call blocking if there was a call within the past 2 days.
- private static final long RECENT_EMERGENCY_CALL_THRESHOLD_MS = 1000 * 60 * 60 * 24 * 2;
+ static final long RECENT_EMERGENCY_CALL_THRESHOLD_MS = TimeUnit.DAYS.toMillis(2);
/**
* Used for testing to specify the custom threshold value, in milliseconds for whether an
@@ -210,13 +211,15 @@ public class FilteredNumbersUtil {
return;
}
- PreferenceManager.getDefaultSharedPreferences(context)
+ DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context)
.edit()
.putLong(LAST_EMERGENCY_CALL_MS_PREF_KEY, System.currentTimeMillis())
.putBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, false)
.apply();
- maybeNotifyCallBlockingDisabled(context);
+ if (UserManagerCompat.isUserUnlocked(context)) {
+ maybeNotifyCallBlockingDisabled(context);
+ }
}
public static void maybeNotifyCallBlockingDisabled(final Context context) {
@@ -225,7 +228,7 @@ public class FilteredNumbersUtil {
return;
}
// Skip if the user has already received a notification for the most recent emergency call.
- if (PreferenceManager.getDefaultSharedPreferences(context)
+ if (DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context)
.getBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, false)) {
return;
}
@@ -265,7 +268,7 @@ public class FilteredNumbersUtil {
builder.build());
// Record that the user has been notified for this emergency call.
- PreferenceManager.getDefaultSharedPreferences(context)
+ DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context)
.edit()
.putBoolean(NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY, true)
.apply();