summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/DefaultVoicemailNotifier.java19
-rw-r--r--src/com/android/dialer/filterednumber/BlockedNumberFragment.java8
-rw-r--r--src/com/android/dialer/filterednumber/FilteredNumbersUtil.java16
3 files changed, 34 insertions, 9 deletions
diff --git a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
index 594ceebee..1987b809d 100644
--- a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
+++ b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
@@ -131,8 +131,13 @@ public class DefaultVoicemailNotifier {
NewCall newCall = itr.next();
// Skip notifying for numbers which are blocked.
- if (FilteredNumbersUtil.isBlocked(mContext, newCall.number, newCall.countryIso)) {
+ if (FilteredNumbersUtil.shouldBlockVoicemail(
+ mContext, newCall.number, newCall.countryIso, newCall.dateMs)) {
itr.remove();
+
+ if (FilteredNumbersUtil.shouldHideBlockedCalls(mContext)) {
+ mContext.getContentResolver().delete(newCall.voicemailUri, null, null);
+ }
continue;
}
@@ -236,6 +241,7 @@ public class DefaultVoicemailNotifier {
public final String accountId;
public final String transcription;
public final String countryIso;
+ public final long dateMs;
public NewCall(
Uri callsUri,
@@ -245,7 +251,8 @@ public class DefaultVoicemailNotifier {
String accountComponentName,
String accountId,
String transcription,
- String countryIso) {
+ String countryIso,
+ long dateMs) {
this.callsUri = callsUri;
this.voicemailUri = voicemailUri;
this.number = number;
@@ -254,6 +261,7 @@ public class DefaultVoicemailNotifier {
this.accountId = accountId;
this.transcription = transcription;
this.countryIso = countryIso;
+ this.dateMs = dateMs;
}
}
@@ -284,7 +292,8 @@ public class DefaultVoicemailNotifier {
Calls.PHONE_ACCOUNT_COMPONENT_NAME,
Calls.PHONE_ACCOUNT_ID,
Calls.TRANSCRIPTION,
- Calls.COUNTRY_ISO
+ Calls.COUNTRY_ISO,
+ Calls.DATE
};
private static final int ID_COLUMN_INDEX = 0;
private static final int NUMBER_COLUMN_INDEX = 1;
@@ -294,6 +303,7 @@ public class DefaultVoicemailNotifier {
private static final int PHONE_ACCOUNT_ID_COLUMN_INDEX = 5;
private static final int TRANSCRIPTION_COLUMN_INDEX = 6;
private static final int COUNTRY_ISO_COLUMN_INDEX = 7;
+ private static final int DATE_COLUMN_INDEX = 8;
private final ContentResolver mContentResolver;
private final Context mContext;
@@ -345,7 +355,8 @@ public class DefaultVoicemailNotifier {
cursor.getString(PHONE_ACCOUNT_COMPONENT_NAME_COLUMN_INDEX),
cursor.getString(PHONE_ACCOUNT_ID_COLUMN_INDEX),
cursor.getString(TRANSCRIPTION_COLUMN_INDEX),
- cursor.getString(COUNTRY_ISO_COLUMN_INDEX));
+ cursor.getString(COUNTRY_ISO_COLUMN_INDEX),
+ cursor.getLong(DATE_COLUMN_INDEX));
}
}
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
index 728d8b287..06ae0e084 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
@@ -17,12 +17,14 @@ package com.android.dialer.filterednumber;
import android.app.ListFragment;
import android.app.LoaderManager;
+import android.content.Context;
import android.content.CursorLoader;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.CompoundButton;
+import android.widget.ListView;
import android.widget.Switch;
import android.view.LayoutInflater;
import android.view.View;
@@ -87,6 +89,12 @@ public class BlockedNumberFragment extends ListFragment implements
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ LayoutInflater inflater =
+ (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ ListView listView = (ListView) getActivity().findViewById(R.id.blocked_numbers_list);
+ listView.addHeaderView(inflater.inflate(R.layout.blocked_number_header, null));
+
getLoaderManager().initLoader(0, null, this);
}
diff --git a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
index 0e162acfa..ac3d16e34 100644
--- a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
+++ b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java
@@ -191,7 +191,8 @@ public class FilteredNumbersUtil {
* 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 isBlocked(Context context, String number, String countryIso) {
+ public static boolean shouldBlockVoicemail(
+ Context context, String number, String countryIso, long dateMs) {
final String normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso);
if (TextUtils.isEmpty(normalizedNumber)) {
return false;
@@ -199,21 +200,26 @@ public class FilteredNumbersUtil {
final Cursor cursor = context.getContentResolver().query(
FilteredNumber.CONTENT_URI,
- new String[] { FilteredNumberColumns._ID },
+ new String[] {
+ FilteredNumberColumns.CREATION_TIME
+ },
FilteredNumberColumns.NORMALIZED_NUMBER + "=?",
new String[] { normalizedNumber },
null);
- boolean isBlocked = false;
+ boolean shouldBlock = false;
if (cursor != null) {
try {
- isBlocked = cursor.getCount() > 0;
+ cursor.moveToFirst();
+
+ // Block if number is found and it was added before this voicemail was received.
+ shouldBlock = cursor.getCount() > 0 && dateMs > cursor.getLong(0);
} finally {
cursor.close();
}
}
- return isBlocked;
+ return shouldBlock;
}
public static boolean shouldHideBlockedCalls(Context context) {