summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-10-10 13:39:17 -0700
committerEric Erfanian <erfanian@google.com>2017-10-11 07:07:43 -0700
commit4aaaca7ad2b570b43f3446abe6b0b96194d441c3 (patch)
treeec7eb2710287ce1fd6ce77e74d0c53b4cf9e9f88 /java
parent090c66de862a6773b6e2bfb50d8bef06e7a8a52e (diff)
Ignore self-manged calls for missed call notification
If a PhoneAccount declared it is CAPABILITY_SELF_MANAGED, it should handle the in call UI and notifications itself, but might still write to call log with EXTRA_LOG_SELF_MANAGED_CALLS}. Bug: 66946794 Test: MissedCallNotifierTest PiperOrigin-RevId: 171727177 Change-Id: I34444857d432d6bb72983c0ba919bcfef885192b
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/app/calllog/MissedCallNotifier.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
index eb7fab8fc..8a986dc41 100644
--- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java
+++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
@@ -18,6 +18,7 @@ package com.android.dialer.app.calllog;
import android.app.Notification;
import android.app.Notification.Builder;
import android.app.PendingIntent;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -32,6 +33,9 @@ import android.support.annotation.WorkerThread;
import android.support.v4.os.BuildCompat;
import android.support.v4.os.UserManagerCompat;
import android.support.v4.util.Pair;
+import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;
@@ -57,6 +61,7 @@ import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.IntentUtil;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -113,6 +118,8 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> {
List<NewCall> newCalls = callLogNotificationsQueryHelper.getNewMissedCalls();
+ removeSelfManagedCalls(newCalls);
+
if ((newCalls != null && newCalls.isEmpty()) || count == 0) {
// No calls to notify about: clear the notification.
CallLogNotificationsQueryHelper.markAllMissedCallsInCallLogAsRead(context);
@@ -236,6 +243,39 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> {
}
}
+ /**
+ * Remove self-managed calls from {@code newCalls}. If a {@link PhoneAccount} declared it is
+ * {@link PhoneAccount#CAPABILITY_SELF_MANAGED}, it should handle the in call UI and notifications
+ * itself, but might still write to call log with {@link
+ * PhoneAccount#EXTRA_LOG_SELF_MANAGED_CALLS}.
+ */
+ private void removeSelfManagedCalls(@Nullable List<NewCall> newCalls) {
+ if (newCalls == null) {
+ return;
+ }
+ TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
+ Iterator<NewCall> iterator = newCalls.iterator();
+ while (iterator.hasNext()) {
+ NewCall call = iterator.next();
+ if (call.accountComponentName == null || call.accountId == null) {
+ continue;
+ }
+ PhoneAccountHandle phoneAccountHandle =
+ new PhoneAccountHandle(
+ ComponentName.unflattenFromString(call.accountComponentName), call.accountId);
+ PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
+ if (phoneAccount == null) {
+ continue;
+ }
+ if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)) {
+ LogUtil.i(
+ "MissedCallNotifier.removeSelfManagedCalls",
+ "ignoring self-managed call " + call.callsUri);
+ iterator.remove();
+ }
+ }
+ }
+
public static void cancelAllMissedCallNotifications(@NonNull Context context) {
NotificationManagerUtils.cancelAllInGroup(context, GROUP_KEY);
}