diff options
Diffstat (limited to 'java/com/android/dialer/blocking/FilteredNumbersUtil.java')
-rw-r--r-- | java/com/android/dialer/blocking/FilteredNumbersUtil.java | 15 |
1 files changed, 9 insertions, 6 deletions
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(); |