diff options
Diffstat (limited to 'java/com/android/dialer/blocking')
3 files changed, 10 insertions, 53 deletions
diff --git a/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java b/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java index bd4156846..12a2086d4 100644 --- a/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java +++ b/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java @@ -201,7 +201,7 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { */ @TargetApi(VERSION_CODES.M) @Nullable - public Integer getBlockedIdSynchronousForCalllogOnly(@Nullable String number, String countryIso) { + public Integer getBlockedIdSynchronous(@Nullable String number, String countryIso) { Assert.isWorkerThread(); if (number == null) { return null; @@ -251,7 +251,7 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { blockedNumberCache.put(number, blockedId); return blockedId; } catch (SecurityException e) { - LogUtil.e("FilteredNumberAsyncQueryHandler.getBlockedIdSynchronousForCalllogOnly", null, e); + LogUtil.e("FilteredNumberAsyncQueryHandler.getBlockedIdSynchronous", null, e); return null; } } diff --git a/java/com/android/dialer/blocking/FilteredNumberProvider.java b/java/com/android/dialer/blocking/FilteredNumberProvider.java index 5d369038c..8ed781e73 100644 --- a/java/com/android/dialer/blocking/FilteredNumberProvider.java +++ b/java/com/android/dialer/blocking/FilteredNumberProvider.java @@ -26,12 +26,12 @@ import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; -import android.util.Log; -import com.android.contacts.common.GeoUtil; +import com.android.dialer.common.LogUtil; import com.android.dialer.database.Database; import com.android.dialer.database.DialerDatabaseHelper; import com.android.dialer.database.FilteredNumberContract; import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns; +import com.android.dialer.location.GeoUtil; /** Filtered number content provider. */ public class FilteredNumberProvider extends ContentProvider { @@ -39,7 +39,6 @@ public class FilteredNumberProvider extends ContentProvider { private static final int FILTERED_NUMBERS_TABLE = 1; private static final int FILTERED_NUMBERS_TABLE_ID = 2; private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); - private static final String TAG = FilteredNumberProvider.class.getSimpleName(); private DialerDatabaseHelper mDialerDatabaseHelper; @Override @@ -80,7 +79,7 @@ public class FilteredNumberProvider extends ContentProvider { c.setNotificationUri( getContext().getContentResolver(), FilteredNumberContract.FilteredNumber.CONTENT_URI); } else { - Log.d(TAG, "CURSOR WAS NULL"); + LogUtil.d("FilteredNumberProvider.query", "CURSOR WAS NULL"); } return c; } diff --git a/java/com/android/dialer/blocking/FilteredNumbersUtil.java b/java/com/android/dialer/blocking/FilteredNumbersUtil.java index cbef73ca5..a95e8d789 100644 --- a/java/com/android/dialer/blocking/FilteredNumbersUtil.java +++ b/java/com/android/dialer/blocking/FilteredNumbersUtil.java @@ -27,19 +27,17 @@ 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.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.widget.Toast; import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler.OnHasBlockedNumbersListener; import com.android.dialer.common.LogUtil; -import com.android.dialer.database.FilteredNumberContract.FilteredNumber; -import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; import com.android.dialer.notification.NotificationChannelManager; import com.android.dialer.notification.NotificationChannelManager.Channel; import com.android.dialer.util.PermissionsUtil; -import java.util.concurrent.TimeUnit; /** Utility to help with tasks related to filtered numbers. */ public class FilteredNumbersUtil { @@ -47,8 +45,9 @@ public class FilteredNumbersUtil { public static final String CALL_BLOCKING_NOTIFICATION_TAG = "call_blocking"; public static final int CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_NOTIFICATION_ID = R.id.notification_call_blocking_disabled_by_emergency_call; - // Pref key for storing the time of end of the last emergency call in milliseconds after epoch. - protected static final String LAST_EMERGENCY_CALL_MS_PREF_KEY = "last_emergency_call_ms"; + // Pref key for storing the time of end of the last emergency call in milliseconds after epoch.\ + @VisibleForTesting + public 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. protected static final String NOTIFIED_CALL_BLOCKING_DISABLED_BY_EMERGENCY_CALL_PREF_KEY = @@ -186,47 +185,6 @@ public class FilteredNumbersUtil { task.execute(); } - /** - * WARNING: This method should NOT be executed on the UI thread. Use {@code - * FilteredNumberAsyncQueryHandler} to asynchronously check if a number is blocked. - */ - public static boolean shouldBlockVoicemail( - Context context, String number, String countryIso, long voicemailDateMs) { - final String normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso); - if (TextUtils.isEmpty(normalizedNumber)) { - return false; - } - - if (hasRecentEmergencyCall(context)) { - return false; - } - - final Cursor cursor = - context - .getContentResolver() - .query( - FilteredNumber.CONTENT_URI, - new String[] {FilteredNumberColumns.CREATION_TIME}, - FilteredNumberColumns.NORMALIZED_NUMBER + "=?", - new String[] {normalizedNumber}, - null); - 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(); - } - } - public static long getLastEmergencyCallTimeMillis(Context context) { return PreferenceManager.getDefaultSharedPreferences(context) .getLong(LAST_EMERGENCY_CALL_MS_PREF_KEY, 0); @@ -292,7 +250,7 @@ public class FilteredNumbersUtil { context.getString(R.string.call_blocking_disabled_notification_text)) .setAutoCancel(true); - NotificationChannelManager.applyChannel(builder, context, Channel.MISC, null); + NotificationChannelManager.applyChannel(builder, context, Channel.DEFAULT, null); builder.setContentIntent( PendingIntent.getActivity( context, |