diff options
author | Andrew Lee <anwlee@google.com> | 2015-10-30 10:56:00 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-10-30 11:04:07 -0700 |
commit | efc4d0f7d35fa9aa6395c3290ae04ef73671a428 (patch) | |
tree | 8699ffe9aa60c0d746149b84e8ee04580ea9f5c5 /src/com/android/dialer/calllog | |
parent | 72579fe971e0a0c3711438e8852d9659f48101c8 (diff) |
Always hide blocked calls.
- Remove setting for show/hide.
- Remove utilities and behaviors for show/hide.
~ Continue filtering blocked call types in call log (which may be
marked by other applications.)
~ Change behavior after blocking call; instead of keeping the call
log entry but changing the type to BLOCKED, delete it instead.
+ Default behavior is now to delete entries and visual voicemails of
blocked calls.
Bug: 25378068
Bug: 25106387
Change-Id: I8cbc419b25cce6ba39099857cffe4eb1df9d0bef
Diffstat (limited to 'src/com/android/dialer/calllog')
4 files changed, 25 insertions, 42 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java index 2fffaff8d..777156345 100644 --- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java +++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java @@ -46,7 +46,7 @@ public class CallLogAsyncTaskUtil { public enum Tasks { DELETE_VOICEMAIL, DELETE_CALL, - MARK_BLOCKED, + DELETE_BLOCKED_CALL, MARK_VOICEMAIL_READ, GET_CALL_DETAILS, } @@ -81,7 +81,7 @@ public class CallLogAsyncTaskUtil { static final int TRANSCRIPTION_COLUMN_INDEX = 11; } - private static class CallLogMarkBlockedQuery { + private static class CallLogDeleteBlockedCallQuery { static final String[] PROJECTION = new String[] { CallLog.Calls._ID, CallLog.Calls.DATE @@ -104,7 +104,7 @@ public class CallLogAsyncTaskUtil { // Try to identify if a call log entry corresponds to a number which was blocked. We match by // by comparing its creation time to the time it was added in the InCallUi and seeing if they // fall within a certain threshold. - private static final int MATCH_BLOCKED_CALL_THRESHOLD_MS = 1500; + private static final int MATCH_BLOCKED_CALL_THRESHOLD_MS = 3000; private static AsyncTaskExecutor sAsyncTaskExecutor; @@ -256,15 +256,16 @@ public class CallLogAsyncTaskUtil { } /** - * Marks last call made by the number the call type of the specified call as BLOCKED in the call log. + * Deletes the last call made by the number within a threshold of the call time added in the + * call log, assuming it is a blocked call for which no entry should be shown. * * @param context The context. - * @param number Number of which to mark the most recent call as BLOCKED. + * @param number Number of blocked call, for which to delete the call log entry. * @param timeAddedMs The time the number was added to InCall, in milliseconds. * @param listener The listener to invoke after looking up for a call log entry matching the * number and time added. */ - public static void markCallAsBlocked( + public static void deleteBlockedCall( final Context context, final String number, final long timeAddedMs, @@ -273,23 +274,30 @@ public class CallLogAsyncTaskUtil { initTaskExecutor(); } - sAsyncTaskExecutor.submit(Tasks.MARK_BLOCKED, new AsyncTask<Void, Void, Long>() { + sAsyncTaskExecutor.submit(Tasks.DELETE_BLOCKED_CALL, new AsyncTask<Void, Void, Long>() { @Override public Long doInBackground(Void... params) { // First, lookup the call log entry of the most recent call with this number. Cursor cursor = context.getContentResolver().query( TelecomUtil.getCallLogUri(context), - CallLogMarkBlockedQuery.PROJECTION, + CallLogDeleteBlockedCallQuery.PROJECTION, CallLog.Calls.NUMBER + "= ?", new String[] { number }, CallLog.Calls.DATE + " DESC LIMIT 1"); - // If found, return the call log entry id. + // If match is found, delete this call log entry and return the call log entry id. if (cursor.moveToFirst()) { - long creationTime = cursor.getLong(CallLogMarkBlockedQuery.DATE_COLUMN_INDEX); + long creationTime = + cursor.getLong(CallLogDeleteBlockedCallQuery.DATE_COLUMN_INDEX); if (timeAddedMs > creationTime && timeAddedMs - creationTime < MATCH_BLOCKED_CALL_THRESHOLD_MS) { - return cursor.getLong(CallLogMarkBlockedQuery.ID_COLUMN_INDEX); + long callLogEntryId = + cursor.getLong(CallLogDeleteBlockedCallQuery.ID_COLUMN_INDEX); + context.getContentResolver().delete( + TelecomUtil.getCallLogUri(context), + CallLog.Calls._ID + " IN (" + callLogEntryId + ")", + null); + return callLogEntryId; } } return (long) -1; @@ -300,20 +308,6 @@ public class CallLogAsyncTaskUtil { if (listener != null) { listener.onQueryFinished(callLogEntryId >= 0); } - - if (callLogEntryId < 0) { - return; - } - - // Then, update that call log entry to have type BLOCKED. - final ContentValues values = new ContentValues(); - values.put(CallLog.Calls.TYPE, AppCompatConstants.CALLS_BLOCKED_TYPE); - - context.getContentResolver().update( - TelecomUtil.getCallLogUri(context), - values, - CallLog.Calls._ID + "= ?", - new String[] { Long.toString(callLogEntryId) }); } }); } diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index f84ffd5da..3cf58bd28 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -125,7 +125,6 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis private boolean mRefreshDataRequired = true; private boolean mHasReadCallLogPermission = false; - private boolean mShouldHideBlockedCalls = false; // Exactly same variable is in Fragment as a package private. private boolean mMenuVisible = true; @@ -211,8 +210,6 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis resolver.registerContentObserver(Status.CONTENT_URI, true, mVoicemailStatusObserver); setHasOptionsMenu(true); - mShouldHideBlockedCalls = FilteredNumbersUtil.shouldHideBlockedCalls(getActivity()); - if (mCallTypeFilter == Calls.VOICEMAIL_TYPE) { mVoicemailPlaybackPresenter = VoicemailPlaybackPresenter .getInstance(activity, state); @@ -342,10 +339,6 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis mRefreshDataRequired = true; updateEmptyMessage(mCallTypeFilter); } - if (mShouldHideBlockedCalls != FilteredNumbersUtil.shouldHideBlockedCalls(getActivity())) { - mShouldHideBlockedCalls = !mShouldHideBlockedCalls; - mRefreshDataRequired = true; - } mHasReadCallLogPermission = hasReadCallLogPermission; refreshData(); diff --git a/src/com/android/dialer/calllog/CallLogQueryHandler.java b/src/com/android/dialer/calllog/CallLogQueryHandler.java index 01489c1dc..3efdce7df 100644 --- a/src/com/android/dialer/calllog/CallLogQueryHandler.java +++ b/src/com/android/dialer/calllog/CallLogQueryHandler.java @@ -191,13 +191,10 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { selectionArgs.add(Long.toString(newerThan)); } - final boolean shouldHideBlockedCalls = - FilteredNumbersUtil.shouldHideBlockedCalls(mContext); - if (shouldHideBlockedCalls) { - where.append(" AND "); - where.append("(" + Calls.TYPE + " != ?)"); - selectionArgs.add(Integer.toString(AppCompatConstants.CALLS_BLOCKED_TYPE)); - } + // Always hide blocked calls. + where.append(" AND "); + where.append("(" + Calls.TYPE + " != ?)"); + selectionArgs.add(Integer.toString(AppCompatConstants.CALLS_BLOCKED_TYPE)); final int limit = (mLogLimit == -1) ? NUM_LOGS_TO_DISPLAY : mLogLimit; final String selection = where.length() > 0 ? where.toString() : null; diff --git a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java index 1987b809d..635e87489 100644 --- a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java +++ b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java @@ -135,9 +135,8 @@ public class DefaultVoicemailNotifier { mContext, newCall.number, newCall.countryIso, newCall.dateMs)) { itr.remove(); - if (FilteredNumbersUtil.shouldHideBlockedCalls(mContext)) { - mContext.getContentResolver().delete(newCall.voicemailUri, null, null); - } + // Delete the voicemail. + mContext.getContentResolver().delete(newCall.voicemailUri, null, null); continue; } |