summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/spam
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-06-19 11:26:01 -0700
committerEric Erfanian <erfanian@google.com>2017-06-19 11:30:45 -0700
commit2f1c7586bcce334ca69022eb8dc6d8965ceb6a05 (patch)
treebf00ada449ee3de31ec983a14e84159200aa18c2 /java/com/android/incallui/spam
parent3d0ca68e466482971a4cf46576c50cb2bd42bcb5 (diff)
Update AOSP Dialer source from internal google3 repository at
cl/159428781. Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/152373142 (4/06/2017) to cl/159428781 (6/19/2017). This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Our current goal is to do frequent drops (daily if possible) and eventually switched to an automated process. Change-Id: Ie60a84b3936efd0ea3d95d7c86bf96d2b1663030
Diffstat (limited to 'java/com/android/incallui/spam')
-rw-r--r--java/com/android/incallui/spam/SpamCallListListener.java53
1 files changed, 28 insertions, 25 deletions
diff --git a/java/com/android/incallui/spam/SpamCallListListener.java b/java/com/android/incallui/spam/SpamCallListListener.java
index 547337eda..b9c70ebd0 100644
--- a/java/com/android/incallui/spam/SpamCallListListener.java
+++ b/java/com/android/incallui/spam/SpamCallListListener.java
@@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.support.annotation.NonNull;
+import android.support.v4.os.BuildCompat;
import android.telecom.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
@@ -35,8 +36,7 @@ import com.android.dialer.location.GeoUtil;
import com.android.dialer.logging.ContactLookupResult;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
-import com.android.dialer.notification.NotificationChannelManager;
-import com.android.dialer.notification.NotificationChannelManager.Channel;
+import com.android.dialer.notification.NotificationChannelId;
import com.android.dialer.spam.Spam;
import com.android.incallui.R;
import com.android.incallui.call.CallList;
@@ -49,9 +49,8 @@ import java.util.Random;
* etc).
*/
public class SpamCallListListener implements CallList.Listener {
+ static final int NOTIFICATION_ID = 1;
- static final int NOTIFICATION_ID = R.id.notification_spam_call;
- private static final String TAG = "SpamCallListListener";
private final Context context;
private final Random random;
@@ -65,10 +64,6 @@ public class SpamCallListListener implements CallList.Listener {
this.random = rand;
}
- private static String pii(String pii) {
- return com.android.incallui.Log.pii(pii);
- }
-
@Override
public void onIncomingCall(final DialerCall call) {
String number = call.getNumber();
@@ -127,7 +122,6 @@ public class SpamCallListListener implements CallList.Listener {
if (call.isSpam()) {
maybeShowSpamCallNotification(call);
} else {
- LogUtil.d(TAG, "Showing not spam notification for number=" + pii(call.getNumber()));
maybeShowNonSpamCallNotification(call);
}
}
@@ -161,7 +155,7 @@ public class SpamCallListListener implements CallList.Listener {
if (callHistoryStatus == DialerCall.CALL_HISTORY_STATUS_PRESENT) {
return false;
} else if (callHistoryStatus == DialerCall.CALL_HISTORY_STATUS_UNKNOWN) {
- LogUtil.i(TAG, "DialerCall history status is unknown, returning false");
+ LogUtil.i("SpamCallListListener.shouldShowAfterCallNotification", "history status unknown");
return false;
}
@@ -171,7 +165,7 @@ public class SpamCallListListener implements CallList.Listener {
return false;
}
- LogUtil.i(TAG, "shouldShowAfterCallNotification, returning true");
+ LogUtil.i("SpamCallListListener.shouldShowAfterCallNotification", "returning true");
return true;
}
@@ -179,7 +173,7 @@ public class SpamCallListListener implements CallList.Listener {
* Creates a notification builder with properties common among the two after call notifications.
*/
private Notification.Builder createAfterCallNotificationBuilder(DialerCall call) {
- Builder builder =
+ Notification.Builder builder =
new Builder(context)
.setContentIntent(
createActivityPendingIntent(call, SpamNotificationActivity.ACTION_SHOW_DIALOG))
@@ -187,7 +181,9 @@ public class SpamCallListListener implements CallList.Listener {
.setPriority(Notification.PRIORITY_DEFAULT)
.setColor(context.getColor(R.color.dialer_theme_color))
.setSmallIcon(R.drawable.ic_call_end_white_24dp);
- NotificationChannelManager.applyChannel(builder, context, Channel.DEFAULT, null);
+ if (BuildCompat.isAtLeastO()) {
+ builder.setChannelId(NotificationChannelId.DEFAULT);
+ }
return builder;
}
@@ -234,21 +230,20 @@ public class SpamCallListListener implements CallList.Listener {
int thresholdForShowing = Spam.get(context).percentOfSpamNotificationsToShow();
if (thresholdForShowing == 0) {
LogUtil.d(
- TAG,
- "shouldThrottleSpamNotification, not showing - percentOfSpamNotificationsToShow is 0");
+ "SpamCallListListener.shouldThrottleSpamNotification",
+ "not showing - percentOfSpamNotificationsToShow is 0");
return true;
} else if (randomNumber < thresholdForShowing) {
LogUtil.d(
- TAG,
- "shouldThrottleSpamNotification, showing " + randomNumber + " < " + thresholdForShowing);
+ "SpamCallListListener.shouldThrottleSpamNotification",
+ "showing " + randomNumber + " < " + thresholdForShowing);
return false;
} else {
LogUtil.d(
- TAG,
- "shouldThrottleSpamNotification, not showing "
- + randomNumber
- + " >= "
- + thresholdForShowing);
+ "SpamCallListListener.shouldThrottleSpamNotification",
+ "not showing %d >= %d",
+ randomNumber,
+ thresholdForShowing);
return true;
}
}
@@ -257,15 +252,23 @@ public class SpamCallListListener implements CallList.Listener {
int randomNumber = random.nextInt(100);
int thresholdForShowing = Spam.get(context).percentOfNonSpamNotificationsToShow();
if (thresholdForShowing == 0) {
- LogUtil.d(TAG, "Not showing non spam notification: percentOfNonSpamNotificationsToShow is 0");
+ LogUtil.d(
+ "SpamCallListListener.shouldThrottleNonSpamNotification",
+ "not showing non spam notification: percentOfNonSpamNotificationsToShow is 0");
return true;
} else if (randomNumber < thresholdForShowing) {
LogUtil.d(
- TAG, "Showing non spam notification: " + randomNumber + " < " + thresholdForShowing);
+ "SpamCallListListener.shouldThrottleNonSpamNotification",
+ "showing non spam notification: %d < %d",
+ randomNumber,
+ thresholdForShowing);
return false;
} else {
LogUtil.d(
- TAG, "Not showing non spam notification:" + randomNumber + " >= " + thresholdForShowing);
+ "SpamCallListListener.shouldThrottleNonSpamNotification",
+ "not showing non spam notification: %d >= %d",
+ randomNumber,
+ thresholdForShowing);
return true;
}
}