summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-03 18:20:33 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-03 18:20:33 +0000
commitfe326622058c81cf261eda17f0e7d7d7e23a8322 (patch)
treed4e94de99e237078853df633f8136d46008db6d1
parent1bb8acbb3b3573e70e950fcf841fa6edc3f39f9b (diff)
parenteb54e4cf60a9b4e149c92b3ce65b0e323c8a7c8a (diff)
downloadplatform_packages_apps_Car_Dialer-fe326622058c81cf261eda17f0e7d7d7e23a8322.tar.gz
platform_packages_apps_Car_Dialer-fe326622058c81cf261eda17f0e7d7d7e23a8322.tar.bz2
platform_packages_apps_Car_Dialer-fe326622058c81cf261eda17f0e7d7d7e23a8322.zip
Merge "Fix no display name for saved contacts for HUN." into pi-car-dev am: 6ff9cd13ac am: eb54e4cf60
Change-Id: Id4c30b811060ddadf1d21fc7c7259f68253f548e
-rw-r--r--src/com/android/car/dialer/notification/InCallNotificationController.java46
-rw-r--r--src/com/android/car/dialer/notification/NotificationService.java12
2 files changed, 42 insertions, 16 deletions
diff --git a/src/com/android/car/dialer/notification/InCallNotificationController.java b/src/com/android/car/dialer/notification/InCallNotificationController.java
index e8a0cf16..e68b35b7 100644
--- a/src/com/android/car/dialer/notification/InCallNotificationController.java
+++ b/src/com/android/car/dialer/notification/InCallNotificationController.java
@@ -29,13 +29,12 @@ import android.text.TextUtils;
import androidx.annotation.StringRes;
-import com.android.car.dialer.Constants;
import com.android.car.dialer.R;
import com.android.car.dialer.log.L;
-import com.android.car.dialer.ui.activecall.InCallActivity;
import com.android.car.telephony.common.CallDetail;
-import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.CompletableFuture;
/** Controller that manages the heads up notification for incoming calls. */
@@ -81,6 +80,7 @@ public final class InCallNotificationController {
private final Context mContext;
private final NotificationManager mNotificationManager;
private final Notification.Builder mNotificationBuilder;
+ private final Set<String> mActiveInCallNotifications;
private CompletableFuture<Void> mNotificationFuture;
@TargetApi(26)
@@ -94,19 +94,14 @@ public final class InCallNotificationController {
NotificationManager.IMPORTANCE_HIGH);
mNotificationManager.createNotificationChannel(notificationChannel);
- Intent intent = new Intent(mContext, InCallActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(Constants.Intents.EXTRA_SHOW_INCOMING_CALL, true);
- PendingIntent fullscreenIntent = PendingIntent.getActivity(mContext, 0, intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
-
mNotificationBuilder = new Notification.Builder(mContext, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_phone)
.setContentText(mContext.getString(R.string.notification_incoming_call))
- .setFullScreenIntent(fullscreenIntent, /* highPriority= */true)
.setCategory(Notification.CATEGORY_CALL)
.setOngoing(true)
.setAutoCancel(false);
+
+ mActiveInCallNotifications = new HashSet<>();
}
@@ -121,8 +116,10 @@ public final class InCallNotificationController {
CallDetail callDetail = CallDetail.fromTelecomCallDetail(call.getDetails());
String number = callDetail.getNumber();
- String tag = call.getDetails().getTelecomCallId();
+ String callId = call.getDetails().getTelecomCallId();
+ mActiveInCallNotifications.add(callId);
mNotificationBuilder
+ .setFullScreenIntent(getFullscreenIntent(call), /* highPriority= */true)
.setLargeIcon((Icon) null)
.setContentTitle(number)
.setActions(
@@ -131,21 +128,20 @@ public final class InCallNotificationController {
getAction(call, R.string.decline_call,
NotificationService.ACTION_DECLINE_CALL));
mNotificationManager.notify(
- tag,
+ callId,
NOTIFICATION_ID,
mNotificationBuilder.build());
mNotificationFuture = NotificationUtils.getDisplayNameAndRoundedAvatar(mContext, number)
.thenAcceptAsync((pair) -> {
// Check that the notification hasn't already been dismissed
- if (Arrays.stream(mNotificationManager.getActiveNotifications()).anyMatch((n) ->
- n.getId() == NOTIFICATION_ID && TextUtils.equals(n.getTag(), tag))) {
+ if (mActiveInCallNotifications.contains(callId)) {
mNotificationBuilder
.setLargeIcon(pair.second)
.setContentTitle(pair.first);
mNotificationManager.notify(
- tag,
+ callId,
NOTIFICATION_ID,
mNotificationBuilder.build());
}
@@ -156,8 +152,26 @@ public final class InCallNotificationController {
public void cancelInCallNotification(Call call) {
L.d(TAG, "cancelInCallNotification");
if (call.getDetails() != null) {
- mNotificationManager.cancel(call.getDetails().getTelecomCallId(), NOTIFICATION_ID);
+ String callId = call.getDetails().getTelecomCallId();
+ cancelInCallNotification(callId);
+ }
+ }
+
+ /**
+ * Cancel the incoming call notification for the given call id. Any action that dismisses the
+ * notification needs to call this explicitly.
+ */
+ void cancelInCallNotification(String callId) {
+ if (TextUtils.isEmpty(callId)) {
+ return;
}
+ mActiveInCallNotifications.remove(callId);
+ mNotificationManager.cancel(callId, NOTIFICATION_ID);
+ }
+
+ private PendingIntent getFullscreenIntent(Call call) {
+ Intent intent = getIntent(NotificationService.ACTION_SHOW_FULLSCREEN_UI, call);
+ return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
private Notification.Action getAction(Call call, @StringRes int actionText,
diff --git a/src/com/android/car/dialer/notification/NotificationService.java b/src/com/android/car/dialer/notification/NotificationService.java
index 2f282907..f7b8a01c 100644
--- a/src/com/android/car/dialer/notification/NotificationService.java
+++ b/src/com/android/car/dialer/notification/NotificationService.java
@@ -25,6 +25,7 @@ import androidx.core.app.JobIntentService;
import com.android.car.dialer.Constants;
import com.android.car.dialer.telecom.UiCallManager;
+import com.android.car.dialer.ui.activecall.InCallActivity;
import com.android.car.telephony.common.TelecomUtils;
import java.util.List;
@@ -37,6 +38,7 @@ import java.util.List;
public class NotificationService extends JobIntentService {
static final String ACTION_ANSWER_CALL = "CD.ACTION_ANSWER_CALL";
static final String ACTION_DECLINE_CALL = "CD.ACTION_DECLINE_CALL";
+ static final String ACTION_SHOW_FULLSCREEN_UI = "CD.ACTION_SHOW_FULLSCREEN_UI";
static final String ACTION_CALL_BACK_MISSED = "CD.ACTION_CALL_BACK_MISSED";
static final String ACTION_MESSAGE_MISSED = "CD.ACTION_MESSAGE_MISSED";
static final String ACTION_READ_ALL_MISSED = "CD.ACTION_READ_ALL_MISSED";
@@ -62,9 +64,19 @@ public class NotificationService extends JobIntentService {
switch (action) {
case ACTION_ANSWER_CALL:
answerCall(callId);
+ InCallNotificationController.get().cancelInCallNotification(callId);
break;
case ACTION_DECLINE_CALL:
declineCall(callId);
+ InCallNotificationController.get().cancelInCallNotification(callId);
+ break;
+ case ACTION_SHOW_FULLSCREEN_UI:
+ Intent inCallActivityIntent = new Intent(getApplicationContext(),
+ InCallActivity.class);
+ inCallActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ inCallActivityIntent.putExtra(Constants.Intents.EXTRA_SHOW_INCOMING_CALL, true);
+ startActivity(inCallActivityIntent);
+ InCallNotificationController.get().cancelInCallNotification(callId);
break;
case ACTION_CALL_BACK_MISSED:
UiCallManager.get().placeCall(callId);