summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java44
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java7
-rw-r--r--src/com/android/dialer/calllog/CallLogQueryHandler.java11
-rw-r--r--src/com/android/dialer/calllog/DefaultVoicemailNotifier.java5
-rw-r--r--src/com/android/dialer/filterednumber/BlockedNumbersFragment.java59
-rw-r--r--src/com/android/dialer/filterednumber/FilteredNumbersUtil.java19
6 files changed, 26 insertions, 119 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;
}
diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
index 24fd1a64c..a2a716fe3 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
@@ -36,7 +36,6 @@ import android.widget.CompoundButton;
import android.widget.Switch;
import com.android.dialer.R;
-import com.android.dialer.calllog.CallLogQueryHandler;
import com.android.dialer.database.FilteredNumberContract;
import com.android.dialer.filterednumber.FilteredNumbersUtil.CheckForSendToVoicemailContactListener;
import com.android.dialer.filterednumber.FilteredNumbersUtil.ImportSendToVoicemailContactsListener;
@@ -44,14 +43,11 @@ import com.android.dialer.voicemail.VoicemailStatusHelper;
import com.android.dialer.voicemail.VoicemailStatusHelperImpl;
public class BlockedNumbersFragment extends ListFragment
- implements LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener,
- CallLogQueryHandler.Listener {
+ implements LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener {
private BlockedNumbersAdapter mAdapter;
- private CallLogQueryHandler mCallLogQueryHandler;
private VoicemailStatusHelper mVoicemailStatusHelper;
- private Switch mHideSettingSwitch;
private View mImportSettings;
private View mBlockedNumbersDisabledForEmergency;
@@ -69,25 +65,8 @@ public class BlockedNumbersFragment extends ListFragment
}
setListAdapter(mAdapter);
- mCallLogQueryHandler
- = new CallLogQueryHandler(getContext(), getContext().getContentResolver(), this);
mVoicemailStatusHelper = new VoicemailStatusHelperImpl();
- mHideSettingSwitch = (Switch) getActivity().findViewById(R.id.hide_blocked_calls_switch);
- mHideSettingSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- FilteredNumbersUtil.setShouldHideBlockedCalls(getActivity(), isChecked);
- }
- });
- getActivity().findViewById(R.id.hide_blocked_calls_setting).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(final View view) {
- mHideSettingSwitch.toggle();
- }
- });
-
mImportSettings = getActivity().findViewById(R.id.import_settings);
mBlockedNumbersDisabledForEmergency =
getActivity().findViewById(R.id.blocked_numbers_disabled_for_emergency);
@@ -132,9 +111,6 @@ public class BlockedNumbersFragment extends ListFragment
}
});
- mHideSettingSwitch.setChecked(FilteredNumbersUtil.shouldHideBlockedCalls(getContext()));
- mCallLogQueryHandler.fetchVoicemailStatus();
-
if (FilteredNumbersUtil.hasRecentEmergencyCall(getContext())) {
mBlockedNumbersDisabledForEmergency.setVisibility(View.VISIBLE);
} else {
@@ -199,37 +175,4 @@ public class BlockedNumbersFragment extends ListFragment
break;
}
}
-
- @Override
- public void onVoicemailStatusFetched(Cursor cursor) {
- Activity activity = getActivity();
- if (activity == null) {
- return;
- }
-
- final View hideSetting = activity.findViewById(R.id.hide_blocked_calls_setting);
- if (cursor == null) {
- hideSetting.setVisibility(View.GONE);
- return;
- }
-
- final boolean hasVisualVoicemailSource =
- mVoicemailStatusHelper.getNumberActivityVoicemailSources(cursor) > 0;
- if (hasVisualVoicemailSource) {
- hideSetting.setVisibility(View.VISIBLE);
- } else {
- hideSetting.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void onVoicemailUnreadCountFetched(Cursor cursor) {
- // Do nothing.
- }
-
- @Override
- public boolean onCallsFetched(Cursor cursor) {
- // Do nothing.
- return false;
- }
}
diff --git a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
index 83a85eb9c..fa6aa7ed5 100644
--- a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
+++ b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
@@ -52,7 +52,6 @@ public class FilteredNumbersUtil {
// 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;
- private static final String HIDE_BLOCKED_CALLS_PREF_KEY = "hide_blocked_calls";
// 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";
@@ -266,24 +265,6 @@ public class FilteredNumbersUtil {
return shouldBlock;
}
- public static boolean shouldHideBlockedCalls(Context context) {
- if (context == null) {
- return false;
- }
- return PreferenceManager.getDefaultSharedPreferences(context)
- .getBoolean(HIDE_BLOCKED_CALLS_PREF_KEY, false);
- }
-
- public static void setShouldHideBlockedCalls(Context context, boolean shouldHide) {
- if (context == null) {
- return;
- }
- PreferenceManager.getDefaultSharedPreferences(context)
- .edit()
- .putBoolean(HIDE_BLOCKED_CALLS_PREF_KEY, shouldHide)
- .apply();
- }
-
public static boolean hasRecentEmergencyCall(Context context) {
if (context == null) {
return false;