blob: 27d23c4ae2d75cd1335aa4af5fb01c219927a192 [file] [log] [blame]
Eric Erfanianccca3152017-02-22 16:32:36 -08001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.incallui;
18
Eric Erfanian90508232017-03-24 09:31:16 -070019import static android.telecom.Call.Details.PROPERTY_HIGH_DEF_AUDIO;
Eric Erfanianccca3152017-02-22 16:32:36 -080020import static com.android.contacts.common.compat.CallCompat.Details.PROPERTY_ENTERPRISE_CALL;
21import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST;
22import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_VIDEO_INCOMING_CALL;
23import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_VOICE_INCOMING_CALL;
24import static com.android.incallui.NotificationBroadcastReceiver.ACTION_DECLINE_INCOMING_CALL;
25import static com.android.incallui.NotificationBroadcastReceiver.ACTION_DECLINE_VIDEO_UPGRADE_REQUEST;
26import static com.android.incallui.NotificationBroadcastReceiver.ACTION_HANG_UP_ONGOING_CALL;
yuegb26c1ae2017-09-18 16:59:16 -070027import static com.android.incallui.NotificationBroadcastReceiver.ACTION_TURN_OFF_SPEAKER;
28import static com.android.incallui.NotificationBroadcastReceiver.ACTION_TURN_ON_SPEAKER;
Eric Erfanianccca3152017-02-22 16:32:36 -080029
Eric Erfaniand5e47f62017-03-15 14:41:07 -070030import android.Manifest;
Eric Erfanianccca3152017-02-22 16:32:36 -080031import android.app.Notification;
Eric Erfanianccca3152017-02-22 16:32:36 -080032import android.app.PendingIntent;
33import android.content.Context;
34import android.content.Intent;
Eric Erfanian83b20212017-05-31 08:53:10 -070035import android.content.res.Resources;
Eric Erfanianccca3152017-02-22 16:32:36 -080036import android.graphics.Bitmap;
Eric Erfanianccca3152017-02-22 16:32:36 -080037import android.graphics.drawable.BitmapDrawable;
38import android.graphics.drawable.Drawable;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070039import android.graphics.drawable.Icon;
Eric Erfanianccca3152017-02-22 16:32:36 -080040import android.media.AudioAttributes;
41import android.net.Uri;
42import android.os.Build.VERSION;
43import android.os.Build.VERSION_CODES;
wangqicf61ca02017-08-31 15:32:55 -070044import android.os.Trace;
Eric Erfanianccca3152017-02-22 16:32:36 -080045import android.support.annotation.ColorRes;
46import android.support.annotation.NonNull;
47import android.support.annotation.Nullable;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070048import android.support.annotation.RequiresPermission;
Eric Erfanianccca3152017-02-22 16:32:36 -080049import android.support.annotation.StringRes;
50import android.support.annotation.VisibleForTesting;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070051import android.support.v4.os.BuildCompat;
Eric Erfanianccca3152017-02-22 16:32:36 -080052import android.telecom.Call.Details;
yuegb26c1ae2017-09-18 16:59:16 -070053import android.telecom.CallAudioState;
Eric Erfanianccca3152017-02-22 16:32:36 -080054import android.telecom.PhoneAccount;
55import android.telecom.TelecomManager;
roldenburgc14610d2017-10-31 12:51:06 -070056import android.telecom.VideoProfile;
Eric Erfanianccca3152017-02-22 16:32:36 -080057import android.text.BidiFormatter;
58import android.text.Spannable;
59import android.text.SpannableString;
60import android.text.TextDirectionHeuristics;
61import android.text.TextUtils;
62import android.text.style.ForegroundColorSpan;
63import com.android.contacts.common.ContactsUtils;
64import com.android.contacts.common.ContactsUtils.UserType;
65import com.android.contacts.common.preference.ContactsPreferences;
Eric Erfanianccca3152017-02-22 16:32:36 -080066import com.android.contacts.common.util.ContactDisplayUtils;
Eric Erfanian2ca43182017-08-31 06:57:16 -070067import com.android.dialer.common.Assert;
Eric Erfanianccca3152017-02-22 16:32:36 -080068import com.android.dialer.common.LogUtil;
Eric Erfanian2ca43182017-08-31 06:57:16 -070069import com.android.dialer.configprovider.ConfigProviderBindings;
70import com.android.dialer.contactphoto.BitmapUtil;
Eric Erfaniand8046e52017-04-06 09:41:50 -070071import com.android.dialer.enrichedcall.EnrichedCallManager;
72import com.android.dialer.enrichedcall.Session;
Eric Erfanian2ca43182017-08-31 06:57:16 -070073import com.android.dialer.lettertile.LetterTileDrawable;
74import com.android.dialer.lettertile.LetterTileDrawable.ContactType;
Eric Erfaniand8046e52017-04-06 09:41:50 -070075import com.android.dialer.multimedia.MultimediaData;
Eric Erfanian2ca43182017-08-31 06:57:16 -070076import com.android.dialer.notification.NotificationChannelId;
Eric Erfanian90508232017-03-24 09:31:16 -070077import com.android.dialer.oem.MotorolaUtils;
calderwoodraa93df432018-05-23 12:59:03 -070078import com.android.dialer.theme.base.ThemeComponent;
Eric Erfanianccca3152017-02-22 16:32:36 -080079import com.android.dialer.util.DrawableConverter;
80import com.android.incallui.ContactInfoCache.ContactCacheEntry;
81import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback;
82import com.android.incallui.InCallPresenter.InCallState;
83import com.android.incallui.async.PausableExecutorImpl;
yuegb26c1ae2017-09-18 16:59:16 -070084import com.android.incallui.audiomode.AudioModeProvider;
Eric Erfanianccca3152017-02-22 16:32:36 -080085import com.android.incallui.call.CallList;
86import com.android.incallui.call.DialerCall;
Eric Erfanianccca3152017-02-22 16:32:36 -080087import com.android.incallui.call.DialerCallListener;
yueg01a964d2017-10-03 15:25:41 -070088import com.android.incallui.call.TelecomAdapter;
wangqibb94ca62018-04-27 14:34:04 -070089import com.android.incallui.call.state.DialerCallState;
Eric Erfanianccca3152017-02-22 16:32:36 -080090import com.android.incallui.ringtone.DialerRingtoneManager;
91import com.android.incallui.ringtone.InCallTonePlayer;
92import com.android.incallui.ringtone.ToneGeneratorFactory;
Eric Erfanian90508232017-03-24 09:31:16 -070093import com.android.incallui.videotech.utils.SessionModificationState;
Eric Erfanianccca3152017-02-22 16:32:36 -080094import java.util.Objects;
95
96/** This class adds Notifications to the status bar for the in-call experience. */
Eric Erfaniand8046e52017-04-06 09:41:50 -070097public class StatusBarNotifier
yuegb26c1ae2017-09-18 16:59:16 -070098 implements InCallPresenter.InCallStateListener,
99 EnrichedCallManager.StateChangedListener,
wangqic8cf79e2017-10-17 09:21:00 -0700100 ContactInfoCacheCallback {
Eric Erfanianccca3152017-02-22 16:32:36 -0800101
Eric Erfanian2ca43182017-08-31 06:57:16 -0700102 private static final int NOTIFICATION_ID = 1;
103
Eric Erfanianccca3152017-02-22 16:32:36 -0800104 // Notification types
105 // Indicates that no notification is currently showing.
106 private static final int NOTIFICATION_NONE = 0;
107 // Notification for an active call. This is non-interruptive, but cannot be dismissed.
Eric Erfanian10b34a52017-05-04 08:23:17 -0700108 private static final int NOTIFICATION_IN_CALL = 1;
Eric Erfanianccca3152017-02-22 16:32:36 -0800109 // Notification for incoming calls. This is interruptive and will show up as a HUN.
Eric Erfanian10b34a52017-05-04 08:23:17 -0700110 private static final int NOTIFICATION_INCOMING_CALL = 2;
111 // Notification for incoming calls in the case where there is already an active call.
112 // This is non-interruptive, but otherwise behaves the same as NOTIFICATION_INCOMING_CALL
113 private static final int NOTIFICATION_INCOMING_CALL_QUIET = 3;
Eric Erfanianccca3152017-02-22 16:32:36 -0800114
Eric Erfanianccca3152017-02-22 16:32:36 -0800115 private static final long[] VIBRATE_PATTERN = new long[] {0, 1000, 1000};
116
linyuh183cb712017-12-27 17:02:37 -0800117 private final Context context;
118 private final ContactInfoCache contactInfoCache;
119 private final DialerRingtoneManager dialerRingtoneManager;
120 @Nullable private ContactsPreferences contactsPreferences;
121 private int currentNotification = NOTIFICATION_NONE;
wangqibb94ca62018-04-27 14:34:04 -0700122 private int callState = DialerCallState.INVALID;
linyuh183cb712017-12-27 17:02:37 -0800123 private int videoState = VideoProfile.STATE_AUDIO_ONLY;
124 private int savedIcon = 0;
125 private String savedContent = null;
126 private Bitmap savedLargeIcon;
127 private String savedContentTitle;
yuegb26c1ae2017-09-18 16:59:16 -0700128 private CallAudioState savedCallAudioState;
linyuh183cb712017-12-27 17:02:37 -0800129 private Uri ringtone;
130 private StatusBarCallListener statusBarCallListener;
Eric Erfanianccca3152017-02-22 16:32:36 -0800131
Eric Erfaniand8046e52017-04-06 09:41:50 -0700132 public StatusBarNotifier(@NonNull Context context, @NonNull ContactInfoCache contactInfoCache) {
wangqic8cf79e2017-10-17 09:21:00 -0700133 Trace.beginSection("StatusBarNotifier.Constructor");
linyuh183cb712017-12-27 17:02:37 -0800134 this.context = Assert.isNotNull(context);
135 contactsPreferences = ContactsPreferencesFactory.newContactsPreferences(this.context);
136 this.contactInfoCache = contactInfoCache;
137 dialerRingtoneManager =
Eric Erfanianccca3152017-02-22 16:32:36 -0800138 new DialerRingtoneManager(
139 new InCallTonePlayer(new ToneGeneratorFactory(), new PausableExecutorImpl()),
140 CallList.getInstance());
linyuh183cb712017-12-27 17:02:37 -0800141 currentNotification = NOTIFICATION_NONE;
wangqic8cf79e2017-10-17 09:21:00 -0700142 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800143 }
144
145 /**
146 * Should only be called from a irrecoverable state where it is necessary to dismiss all
147 * notifications.
148 */
yueg01a964d2017-10-03 15:25:41 -0700149 static void clearAllCallNotifications() {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700150 LogUtil.e(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700151 "StatusBarNotifier.clearAllCallNotifications",
152 "something terrible happened, clear all InCall notifications");
Eric Erfanianccca3152017-02-22 16:32:36 -0800153
yueg01a964d2017-10-03 15:25:41 -0700154 TelecomAdapter.getInstance().stopForegroundNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -0800155 }
156
157 private static int getWorkStringFromPersonalString(int resId) {
158 if (resId == R.string.notification_ongoing_call) {
159 return R.string.notification_ongoing_work_call;
Eric Erfanianccca3152017-02-22 16:32:36 -0800160 } else if (resId == R.string.notification_incoming_call) {
161 return R.string.notification_incoming_work_call;
162 } else {
163 return resId;
164 }
165 }
166
167 /**
168 * Returns PendingIntent for answering a phone call. This will typically be used from Notification
169 * context.
170 */
171 private static PendingIntent createNotificationPendingIntent(Context context, String action) {
172 final Intent intent = new Intent(action, null, context, NotificationBroadcastReceiver.class);
173 return PendingIntent.getBroadcast(context, 0, intent, 0);
174 }
175
176 /** Creates notifications according to the state we receive from {@link InCallPresenter}. */
177 @Override
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700178 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
Eric Erfanianccca3152017-02-22 16:32:36 -0800179 public void onStateChange(InCallState oldState, InCallState newState, CallList callList) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700180 LogUtil.d("StatusBarNotifier.onStateChange", "%s->%s", oldState, newState);
wangqic8cf79e2017-10-17 09:21:00 -0700181 updateNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -0800182 }
183
Eric Erfaniand8046e52017-04-06 09:41:50 -0700184 @Override
185 public void onEnrichedCallStateChanged() {
186 LogUtil.enterBlock("StatusBarNotifier.onEnrichedCallStateChanged");
wangqic8cf79e2017-10-17 09:21:00 -0700187 updateNotification();
Eric Erfaniand8046e52017-04-06 09:41:50 -0700188 }
189
Eric Erfanianccca3152017-02-22 16:32:36 -0800190 /**
191 * Updates the phone app's status bar notification *and* launches the incoming call UI in response
192 * to a new incoming call.
193 *
194 * <p>If an incoming call is ringing (or call-waiting), the notification will also include a
195 * "fullScreenIntent" that will cause the InCallScreen to be launched, unless the current
196 * foreground activity is marked as "immersive".
197 *
198 * <p>(This is the mechanism that actually brings up the incoming call UI when we receive a "new
199 * ringing connection" event from the telephony layer.)
200 *
201 * <p>Also note that this method is safe to call even if the phone isn't actually ringing (or,
202 * more likely, if an incoming call *was* ringing briefly but then disconnected). In that case,
203 * we'll simply update or cancel the in-call notification based on the current phone state.
204 *
wangqic8cf79e2017-10-17 09:21:00 -0700205 * @see #updateInCallNotification()
Eric Erfanianccca3152017-02-22 16:32:36 -0800206 */
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700207 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
wangqic8cf79e2017-10-17 09:21:00 -0700208 public void updateNotification() {
209 updateInCallNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -0800210 }
211
212 /**
213 * Take down the in-call notification.
214 *
wangqic8cf79e2017-10-17 09:21:00 -0700215 * @see #updateInCallNotification()
Eric Erfanianccca3152017-02-22 16:32:36 -0800216 */
217 private void cancelNotification() {
linyuh183cb712017-12-27 17:02:37 -0800218 if (statusBarCallListener != null) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800219 setStatusBarCallListener(null);
220 }
linyuh183cb712017-12-27 17:02:37 -0800221 if (currentNotification != NOTIFICATION_NONE) {
yueg01a964d2017-10-03 15:25:41 -0700222 TelecomAdapter.getInstance().stopForegroundNotification();
linyuh183cb712017-12-27 17:02:37 -0800223 currentNotification = NOTIFICATION_NONE;
Eric Erfanianccca3152017-02-22 16:32:36 -0800224 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800225 }
226
227 /**
228 * Helper method for updateInCallNotification() and updateNotification(): Update the phone app's
229 * status bar notification based on the current telephony state, or cancels the notification if
230 * the phone is totally idle.
231 */
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700232 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
wangqic8cf79e2017-10-17 09:21:00 -0700233 private void updateInCallNotification() {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700234 LogUtil.d("StatusBarNotifier.updateInCallNotification", "");
Eric Erfanianccca3152017-02-22 16:32:36 -0800235
wangqic8cf79e2017-10-17 09:21:00 -0700236 final DialerCall call = getCallToShow(CallList.getInstance());
Eric Erfanianccca3152017-02-22 16:32:36 -0800237
238 if (call != null) {
wangqic8cf79e2017-10-17 09:21:00 -0700239 showNotification(call);
Eric Erfanianccca3152017-02-22 16:32:36 -0800240 } else {
241 cancelNotification();
242 }
243 }
244
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700245 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
wangqic8cf79e2017-10-17 09:21:00 -0700246 private void showNotification(final DialerCall call) {
wangqicf61ca02017-08-31 15:32:55 -0700247 Trace.beginSection("StatusBarNotifier.showNotification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800248 final boolean isIncoming =
wangqibb94ca62018-04-27 14:34:04 -0700249 (call.getState() == DialerCallState.INCOMING
250 || call.getState() == DialerCallState.CALL_WAITING);
Eric Erfanianccca3152017-02-22 16:32:36 -0800251 setStatusBarCallListener(new StatusBarCallListener(call));
252
253 // we make a call to the contact info cache to query for supplemental data to what the
254 // call provides. This includes the contact name and photo.
255 // This callback will always get called immediately and synchronously with whatever data
256 // it has available, and may make a subsequent call later (same thread) if it had to
257 // call into the contacts provider for more data.
linyuh183cb712017-12-27 17:02:37 -0800258 contactInfoCache.findInfo(call, isIncoming, this);
wangqicf61ca02017-08-31 15:32:55 -0700259 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800260 }
261
262 /** Sets up the main Ui for the notification */
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700263 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
Eric Erfanianccca3152017-02-22 16:32:36 -0800264 private void buildAndSendNotification(
265 CallList callList, DialerCall originalCall, ContactCacheEntry contactInfo) {
wangqicf61ca02017-08-31 15:32:55 -0700266 Trace.beginSection("StatusBarNotifier.buildAndSendNotification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800267 // This can get called to update an existing notification after contact information has come
268 // back. However, it can happen much later. Before we continue, we need to make sure that
269 // the call being passed in is still the one we want to show in the notification.
270 final DialerCall call = getCallToShow(callList);
271 if (call == null || !call.getId().equals(originalCall.getId())) {
wangqicf61ca02017-08-31 15:32:55 -0700272 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800273 return;
274 }
275
wangqicf61ca02017-08-31 15:32:55 -0700276 Trace.beginSection("prepare work");
Eric Erfanianccca3152017-02-22 16:32:36 -0800277 final int callState = call.getState();
yuegb26c1ae2017-09-18 16:59:16 -0700278 final CallAudioState callAudioState = AudioModeProvider.getInstance().getAudioState();
Eric Erfanianccca3152017-02-22 16:32:36 -0800279
wangqic8cf79e2017-10-17 09:21:00 -0700280 Trace.beginSection("read icon and strings");
Eric Erfanianccca3152017-02-22 16:32:36 -0800281 // Check if data has changed; if nothing is different, don't issue another notification.
282 final int iconResId = getIconToDisplay(call);
linyuh183cb712017-12-27 17:02:37 -0800283 Bitmap largeIcon = getLargeIconToDisplay(context, contactInfo, call);
twyend1d1d0c2017-10-05 17:34:43 -0700284 final CharSequence content = getContentString(call, contactInfo.userType);
Eric Erfanianccca3152017-02-22 16:32:36 -0800285 final String contentTitle = getContentTitle(contactInfo, call);
wangqic8cf79e2017-10-17 09:21:00 -0700286 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800287
288 final boolean isVideoUpgradeRequest =
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700289 call.getVideoTech().getSessionModificationState()
Eric Erfanian90508232017-03-24 09:31:16 -0700290 == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST;
Eric Erfanianccca3152017-02-22 16:32:36 -0800291 final int notificationType;
wangqibb94ca62018-04-27 14:34:04 -0700292 if (callState == DialerCallState.INCOMING
293 || callState == DialerCallState.CALL_WAITING
Eric Erfanianccca3152017-02-22 16:32:36 -0800294 || isVideoUpgradeRequest) {
linyuh183cb712017-12-27 17:02:37 -0800295 if (ConfigProviderBindings.get(context)
Eric Erfanian2ca43182017-08-31 06:57:16 -0700296 .getBoolean("quiet_incoming_call_if_ui_showing", true)) {
297 notificationType =
298 InCallPresenter.getInstance().isShowingInCallUi()
299 ? NOTIFICATION_INCOMING_CALL_QUIET
300 : NOTIFICATION_INCOMING_CALL;
301 } else {
302 boolean alreadyActive =
303 callList.getActiveOrBackgroundCall() != null
304 && InCallPresenter.getInstance().isShowingInCallUi();
305 notificationType =
306 alreadyActive ? NOTIFICATION_INCOMING_CALL_QUIET : NOTIFICATION_INCOMING_CALL;
307 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800308 } else {
309 notificationType = NOTIFICATION_IN_CALL;
310 }
wangqicf61ca02017-08-31 15:32:55 -0700311 Trace.endSection(); // prepare work
Eric Erfanianccca3152017-02-22 16:32:36 -0800312
313 if (!checkForChangeAndSaveData(
314 iconResId,
twyend1d1d0c2017-10-05 17:34:43 -0700315 content.toString(),
Eric Erfanianccca3152017-02-22 16:32:36 -0800316 largeIcon,
317 contentTitle,
318 callState,
roldenburgc14610d2017-10-31 12:51:06 -0700319 call.getVideoState(),
Eric Erfanianccca3152017-02-22 16:32:36 -0800320 notificationType,
yuegb26c1ae2017-09-18 16:59:16 -0700321 contactInfo.contactRingtoneUri,
322 callAudioState)) {
wangqicf61ca02017-08-31 15:32:55 -0700323 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800324 return;
325 }
326
327 if (largeIcon != null) {
328 largeIcon = getRoundedIcon(largeIcon);
329 }
330
331 // This builder is used for the notification shown when the device is locked and the user
332 // has set their notification settings to 'hide sensitive content'
333 // {@see Notification.Builder#setPublicVersion}.
linyuh183cb712017-12-27 17:02:37 -0800334 Notification.Builder publicBuilder = new Notification.Builder(context);
Eric Erfanianccca3152017-02-22 16:32:36 -0800335 publicBuilder
336 .setSmallIcon(iconResId)
calderwoodraa93df432018-05-23 12:59:03 -0700337 .setColor(ThemeComponent.get(context).theme().getColorPrimary())
Eric Erfanianccca3152017-02-22 16:32:36 -0800338 // Hide work call state for the lock screen notification
339 .setContentTitle(getContentString(call, ContactsUtils.USER_TYPE_CURRENT));
340 setNotificationWhen(call, callState, publicBuilder);
341
342 // Builder for the notification shown when the device is unlocked or the user has set their
343 // notification settings to 'show all notification content'.
344 final Notification.Builder builder = getNotificationBuilder();
345 builder.setPublicVersion(publicBuilder.build());
346
347 // Set up the main intent to send the user to the in-call screen
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700348 builder.setContentIntent(createLaunchPendingIntent(false /* isFullScreen */));
Eric Erfanianccca3152017-02-22 16:32:36 -0800349
Eric Erfanian10b34a52017-05-04 08:23:17 -0700350 LogUtil.i("StatusBarNotifier.buildAndSendNotification", "notificationType=" + notificationType);
351 switch (notificationType) {
352 case NOTIFICATION_INCOMING_CALL:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700353 if (BuildCompat.isAtLeastO()) {
354 builder.setChannelId(NotificationChannelId.INCOMING_CALL);
355 }
wangqic8cf79e2017-10-17 09:21:00 -0700356 // Set the intent as a full screen intent as well if a call is incoming
Eric Erfanian10b34a52017-05-04 08:23:17 -0700357 configureFullScreenIntent(builder, createLaunchPendingIntent(true /* isFullScreen */));
358 // Set the notification category and bump the priority for incoming calls
359 builder.setCategory(Notification.CATEGORY_CALL);
360 // This will be ignored on O+ and handled by the channel
Eric Erfanian10b34a52017-05-04 08:23:17 -0700361 builder.setPriority(Notification.PRIORITY_MAX);
linyuh183cb712017-12-27 17:02:37 -0800362 if (currentNotification != NOTIFICATION_INCOMING_CALL) {
Eric Erfanian10b34a52017-05-04 08:23:17 -0700363 LogUtil.i(
364 "StatusBarNotifier.buildAndSendNotification",
365 "Canceling old notification so this one can be noisy");
366 // Moving from a non-interuptive notification (or none) to a noisy one. Cancel the old
367 // notification (if there is one) so the fullScreenIntent or HUN will show
yueg01a964d2017-10-03 15:25:41 -0700368 TelecomAdapter.getInstance().stopForegroundNotification();
Eric Erfanian10b34a52017-05-04 08:23:17 -0700369 }
370 break;
371 case NOTIFICATION_INCOMING_CALL_QUIET:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700372 if (BuildCompat.isAtLeastO()) {
373 builder.setChannelId(NotificationChannelId.ONGOING_CALL);
374 }
Eric Erfanian10b34a52017-05-04 08:23:17 -0700375 break;
376 case NOTIFICATION_IN_CALL:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700377 if (BuildCompat.isAtLeastO()) {
378 publicBuilder.setColorized(true);
379 builder.setColorized(true);
380 builder.setChannelId(NotificationChannelId.ONGOING_CALL);
381 }
382 break;
383 default:
Eric Erfanian10b34a52017-05-04 08:23:17 -0700384 break;
Eric Erfanianccca3152017-02-22 16:32:36 -0800385 }
386
387 // Set the content
388 builder.setContentText(content);
389 builder.setSmallIcon(iconResId);
390 builder.setContentTitle(contentTitle);
391 builder.setLargeIcon(largeIcon);
yueg01a964d2017-10-03 15:25:41 -0700392 builder.setColor(InCallPresenter.getInstance().getThemeColorManager().getPrimaryColor());
Eric Erfanianccca3152017-02-22 16:32:36 -0800393
394 if (isVideoUpgradeRequest) {
395 builder.setUsesChronometer(false);
396 addDismissUpgradeRequestAction(builder);
397 addAcceptUpgradeRequestAction(builder);
398 } else {
yuegb26c1ae2017-09-18 16:59:16 -0700399 createIncomingCallNotification(call, callState, callAudioState, builder);
Eric Erfanianccca3152017-02-22 16:32:36 -0800400 }
401
402 addPersonReference(builder, contactInfo, call);
403
wangqicf61ca02017-08-31 15:32:55 -0700404 Trace.beginSection("fire notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800405 // Fire off the notification
406 Notification notification = builder.build();
407
linyuh183cb712017-12-27 17:02:37 -0800408 if (dialerRingtoneManager.shouldPlayRingtone(callState, contactInfo.contactRingtoneUri)) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800409 notification.flags |= Notification.FLAG_INSISTENT;
410 notification.sound = contactInfo.contactRingtoneUri;
411 AudioAttributes.Builder audioAttributes = new AudioAttributes.Builder();
412 audioAttributes.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC);
413 audioAttributes.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE);
414 notification.audioAttributes = audioAttributes.build();
linyuh183cb712017-12-27 17:02:37 -0800415 if (dialerRingtoneManager.shouldVibrate(context.getContentResolver())) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800416 notification.vibrate = VIBRATE_PATTERN;
417 }
418 }
linyuh183cb712017-12-27 17:02:37 -0800419 if (dialerRingtoneManager.shouldPlayCallWaitingTone(callState)) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700420 LogUtil.v("StatusBarNotifier.buildAndSendNotification", "playing call waiting tone");
linyuh183cb712017-12-27 17:02:37 -0800421 dialerRingtoneManager.playCallWaitingTone();
Eric Erfanianccca3152017-02-22 16:32:36 -0800422 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800423
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700424 LogUtil.i(
425 "StatusBarNotifier.buildAndSendNotification",
426 "displaying notification for " + notificationType);
427
yueg01a964d2017-10-03 15:25:41 -0700428 // If a notification exists, this will only update it.
429 TelecomAdapter.getInstance().startForegroundNotification(NOTIFICATION_ID, notification);
430
wangqicf61ca02017-08-31 15:32:55 -0700431 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800432 call.getLatencyReport().onNotificationShown();
linyuh183cb712017-12-27 17:02:37 -0800433 currentNotification = notificationType;
wangqicf61ca02017-08-31 15:32:55 -0700434 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800435 }
436
437 private void createIncomingCallNotification(
yuegb26c1ae2017-09-18 16:59:16 -0700438 DialerCall call, int state, CallAudioState callAudioState, Notification.Builder builder) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800439 setNotificationWhen(call, state, builder);
440
441 // Add hang up option for any active calls (active | onhold), outgoing calls (dialing).
wangqibb94ca62018-04-27 14:34:04 -0700442 if (state == DialerCallState.ACTIVE
443 || state == DialerCallState.ONHOLD
444 || DialerCallState.isDialing(state)) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800445 addHangupAction(builder);
yuegb26c1ae2017-09-18 16:59:16 -0700446 addSpeakerAction(builder, callAudioState);
wangqibb94ca62018-04-27 14:34:04 -0700447 } else if (state == DialerCallState.INCOMING || state == DialerCallState.CALL_WAITING) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800448 addDismissAction(builder);
449 if (call.isVideoCall()) {
450 addVideoCallAction(builder);
451 } else {
452 addAnswerAction(builder);
453 }
454 }
455 }
456
457 /**
458 * Sets the notification's when section as needed. For active calls, this is explicitly set as the
459 * duration of the call. For all other states, the notification will automatically show the time
460 * at which the notification was created.
461 */
462 private void setNotificationWhen(DialerCall call, int state, Notification.Builder builder) {
wangqibb94ca62018-04-27 14:34:04 -0700463 if (state == DialerCallState.ACTIVE) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800464 builder.setUsesChronometer(true);
465 builder.setWhen(call.getConnectTimeMillis());
466 } else {
467 builder.setUsesChronometer(false);
468 }
469 }
470
471 /**
472 * Checks the new notification data and compares it against any notification that we are already
473 * displaying. If the data is exactly the same, we return false so that we do not issue a new
474 * notification for the exact same data.
475 */
476 private boolean checkForChangeAndSaveData(
477 int icon,
478 String content,
479 Bitmap largeIcon,
480 String contentTitle,
481 int state,
roldenburgc14610d2017-10-31 12:51:06 -0700482 int videoState,
Eric Erfanianccca3152017-02-22 16:32:36 -0800483 int notificationType,
yuegb26c1ae2017-09-18 16:59:16 -0700484 Uri ringtone,
485 CallAudioState callAudioState) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800486
487 // The two are different:
488 // if new title is not null, it should be different from saved version OR
489 // if new title is null, the saved version should not be null
490 final boolean contentTitleChanged =
linyuh183cb712017-12-27 17:02:37 -0800491 (contentTitle != null && !contentTitle.equals(savedContentTitle))
492 || (contentTitle == null && savedContentTitle != null);
Eric Erfanianccca3152017-02-22 16:32:36 -0800493
roldenburgc14610d2017-10-31 12:51:06 -0700494 boolean largeIconChanged;
linyuh183cb712017-12-27 17:02:37 -0800495 if (savedLargeIcon == null) {
roldenburgc14610d2017-10-31 12:51:06 -0700496 largeIconChanged = largeIcon != null;
497 } else {
linyuh183cb712017-12-27 17:02:37 -0800498 largeIconChanged = largeIcon == null || !savedLargeIcon.sameAs(largeIcon);
roldenburgc14610d2017-10-31 12:51:06 -0700499 }
Eric Erfanian8369df02017-05-03 10:27:13 -0700500
Eric Erfanianccca3152017-02-22 16:32:36 -0800501 // any change means we are definitely updating
502 boolean retval =
linyuh183cb712017-12-27 17:02:37 -0800503 (savedIcon != icon)
504 || !Objects.equals(savedContent, content)
505 || (callState != state)
506 || (this.videoState != videoState)
Eric Erfanian8369df02017-05-03 10:27:13 -0700507 || largeIconChanged
Eric Erfanianccca3152017-02-22 16:32:36 -0800508 || contentTitleChanged
linyuh183cb712017-12-27 17:02:37 -0800509 || !Objects.equals(this.ringtone, ringtone)
yuegb26c1ae2017-09-18 16:59:16 -0700510 || !Objects.equals(savedCallAudioState, callAudioState);
Eric Erfanianccca3152017-02-22 16:32:36 -0800511
wangqi9982f0d2017-10-11 17:46:07 -0700512 LogUtil.d(
513 "StatusBarNotifier.checkForChangeAndSaveData",
roldenburgc14610d2017-10-31 12:51:06 -0700514 "data changed: icon: %b, content: %b, state: %b, videoState: %b, largeIcon: %b, title: %b,"
515 + "ringtone: %b, audioState: %b, type: %b",
linyuh183cb712017-12-27 17:02:37 -0800516 (savedIcon != icon),
517 !Objects.equals(savedContent, content),
518 (callState != state),
519 (this.videoState != videoState),
wangqi9982f0d2017-10-11 17:46:07 -0700520 largeIconChanged,
521 contentTitleChanged,
linyuh183cb712017-12-27 17:02:37 -0800522 !Objects.equals(this.ringtone, ringtone),
wangqi9982f0d2017-10-11 17:46:07 -0700523 !Objects.equals(savedCallAudioState, callAudioState),
linyuh183cb712017-12-27 17:02:37 -0800524 currentNotification != notificationType);
Eric Erfanianccca3152017-02-22 16:32:36 -0800525 // If we aren't showing a notification right now or the notification type is changing,
526 // definitely do an update.
linyuh183cb712017-12-27 17:02:37 -0800527 if (currentNotification != notificationType) {
528 if (currentNotification == NOTIFICATION_NONE) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700529 LogUtil.d(
530 "StatusBarNotifier.checkForChangeAndSaveData", "showing notification for first time.");
Eric Erfanianccca3152017-02-22 16:32:36 -0800531 }
532 retval = true;
533 }
534
linyuh183cb712017-12-27 17:02:37 -0800535 savedIcon = icon;
536 savedContent = content;
537 callState = state;
538 this.videoState = videoState;
539 savedLargeIcon = largeIcon;
540 savedContentTitle = contentTitle;
541 this.ringtone = ringtone;
yuegb26c1ae2017-09-18 16:59:16 -0700542 savedCallAudioState = callAudioState;
Eric Erfanianccca3152017-02-22 16:32:36 -0800543
544 if (retval) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700545 LogUtil.d(
546 "StatusBarNotifier.checkForChangeAndSaveData", "data changed. Showing notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800547 }
548
549 return retval;
550 }
551
552 /** Returns the main string to use in the notification. */
553 @VisibleForTesting
554 @Nullable
555 String getContentTitle(ContactCacheEntry contactInfo, DialerCall call) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700556 if (call.isConferenceCall()) {
557 return CallerInfoUtils.getConferenceString(
linyuh183cb712017-12-27 17:02:37 -0800558 context, call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE));
Eric Erfanianccca3152017-02-22 16:32:36 -0800559 }
560
561 String preferredName =
562 ContactDisplayUtils.getPreferredDisplayName(
linyuh183cb712017-12-27 17:02:37 -0800563 contactInfo.namePrimary, contactInfo.nameAlternative, contactsPreferences);
Eric Erfanianccca3152017-02-22 16:32:36 -0800564 if (TextUtils.isEmpty(preferredName)) {
565 return TextUtils.isEmpty(contactInfo.number)
566 ? null
567 : BidiFormatter.getInstance()
568 .unicodeWrap(contactInfo.number, TextDirectionHeuristics.LTR);
569 }
570 return preferredName;
571 }
572
573 private void addPersonReference(
574 Notification.Builder builder, ContactCacheEntry contactInfo, DialerCall call) {
575 // Query {@link Contacts#CONTENT_LOOKUP_URI} directly with work lookup key is not allowed.
576 // So, do not pass {@link Contacts#CONTENT_LOOKUP_URI} to NotificationManager to avoid
577 // NotificationManager using it.
578 if (contactInfo.lookupUri != null && contactInfo.userType != ContactsUtils.USER_TYPE_WORK) {
579 builder.addPerson(contactInfo.lookupUri.toString());
580 } else if (!TextUtils.isEmpty(call.getNumber())) {
581 builder.addPerson(Uri.fromParts(PhoneAccount.SCHEME_TEL, call.getNumber(), null).toString());
582 }
583 }
584
585 /** Gets a large icon from the contact info object to display in the notification. */
Eric Erfanian83b20212017-05-31 08:53:10 -0700586 private static Bitmap getLargeIconToDisplay(
587 Context context, ContactCacheEntry contactInfo, DialerCall call) {
wangqic8cf79e2017-10-17 09:21:00 -0700588 Trace.beginSection("StatusBarNotifier.getLargeIconToDisplay");
Eric Erfanian83b20212017-05-31 08:53:10 -0700589 Resources resources = context.getResources();
Eric Erfanianccca3152017-02-22 16:32:36 -0800590 Bitmap largeIcon = null;
Eric Erfanianccca3152017-02-22 16:32:36 -0800591 if (contactInfo.photo != null && (contactInfo.photo instanceof BitmapDrawable)) {
592 largeIcon = ((BitmapDrawable) contactInfo.photo).getBitmap();
593 }
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700594 if (contactInfo.photo == null) {
Eric Erfanian83b20212017-05-31 08:53:10 -0700595 int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
596 int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
Eric Erfanian2ca43182017-08-31 06:57:16 -0700597 @ContactType
598 int contactType =
599 LetterTileDrawable.getContactTypeFromPrimitives(
wangqi9982f0d2017-10-11 17:46:07 -0700600 call.isVoiceMailNumber(),
Eric Erfanian2ca43182017-08-31 06:57:16 -0700601 call.isSpam(),
602 contactInfo.isBusiness,
603 call.getNumberPresentation(),
604 call.isConferenceCall() && !call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE));
Eric Erfanian83b20212017-05-31 08:53:10 -0700605 LetterTileDrawable lettertile = new LetterTileDrawable(resources);
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700606
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700607 lettertile.setCanonicalDialerLetterTileDetails(
608 contactInfo.namePrimary == null ? contactInfo.number : contactInfo.namePrimary,
609 contactInfo.lookupKey,
610 LetterTileDrawable.SHAPE_CIRCLE,
611 contactType);
612 largeIcon = lettertile.getBitmap(width, height);
613 }
614
Eric Erfanianccca3152017-02-22 16:32:36 -0800615 if (call.isSpam()) {
Eric Erfanian83b20212017-05-31 08:53:10 -0700616 Drawable drawable = resources.getDrawable(R.drawable.blocked_contact, context.getTheme());
Eric Erfanianccca3152017-02-22 16:32:36 -0800617 largeIcon = DrawableConverter.drawableToBitmap(drawable);
618 }
wangqic8cf79e2017-10-17 09:21:00 -0700619 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800620 return largeIcon;
621 }
622
623 private Bitmap getRoundedIcon(Bitmap bitmap) {
624 if (bitmap == null) {
625 return null;
626 }
627 final int height =
linyuh183cb712017-12-27 17:02:37 -0800628 (int) context.getResources().getDimension(android.R.dimen.notification_large_icon_height);
Eric Erfanianccca3152017-02-22 16:32:36 -0800629 final int width =
linyuh183cb712017-12-27 17:02:37 -0800630 (int) context.getResources().getDimension(android.R.dimen.notification_large_icon_width);
Eric Erfanianccca3152017-02-22 16:32:36 -0800631 return BitmapUtil.getRoundedBitmap(bitmap, width, height);
632 }
633
634 /**
635 * Returns the appropriate icon res Id to display based on the call for which we want to display
636 * information.
637 */
Eric Erfanian2827dd12017-10-26 09:37:50 -0700638 @VisibleForTesting
639 public int getIconToDisplay(DialerCall call) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800640 // Even if both lines are in use, we only show a single item in
641 // the expanded Notifications UI. It's labeled "Ongoing call"
642 // (or "On hold" if there's only one call, and it's on hold.)
643 // Also, we don't have room to display caller-id info from two
644 // different calls. So if both lines are in use, display info
645 // from the foreground call. And if there's a ringing call,
646 // display that regardless of the state of the other calls.
wangqibb94ca62018-04-27 14:34:04 -0700647 if (call.getState() == DialerCallState.ONHOLD) {
Eric Erfanian2827dd12017-10-26 09:37:50 -0700648 return R.drawable.quantum_ic_phone_paused_vd_theme_24;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700649 } else if (call.getVideoTech().getSessionModificationState()
calderwoodra1dc2cea2017-09-20 16:30:41 -0700650 == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST
651 || call.isVideoCall()) {
linyuh8dc242d2018-03-28 13:09:47 -0700652 return R.drawable.quantum_ic_videocam_vd_white_24;
Eric Erfanian90508232017-03-24 09:31:16 -0700653 } else if (call.hasProperty(PROPERTY_HIGH_DEF_AUDIO)
linyuh183cb712017-12-27 17:02:37 -0800654 && MotorolaUtils.shouldShowHdIconInNotification(context)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700655 // Normally when a call is ongoing the status bar displays an icon of a phone. This is a
656 // helpful hint for users so they know how to get back to the call. For Sprint HD calls, we
657 // replace this icon with an icon of a phone with a HD badge. This is a carrier requirement.
Eric Erfanian90508232017-03-24 09:31:16 -0700658 return R.drawable.ic_hd_call;
Eric Erfanian2827dd12017-10-26 09:37:50 -0700659 } else if (call.hasProperty(Details.PROPERTY_HAS_CDMA_VOICE_PRIVACY)) {
660 return R.drawable.quantum_ic_phone_locked_vd_theme_24;
Eric Erfanianccca3152017-02-22 16:32:36 -0800661 }
yueg48f93f42018-03-09 16:49:38 -0800662 // If ReturnToCall is enabled, use the static icon. The animated one will show in the bubble.
663 if (ReturnToCallController.isEnabled(context)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700664 return R.drawable.quantum_ic_call_vd_theme_24;
665 } else {
666 return R.drawable.on_going_call;
667 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800668 }
669
670 /** Returns the message to use with the notification. */
twyend1d1d0c2017-10-05 17:34:43 -0700671 private CharSequence getContentString(DialerCall call, @UserType long userType) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800672 boolean isIncomingOrWaiting =
wangqibb94ca62018-04-27 14:34:04 -0700673 call.getState() == DialerCallState.INCOMING
674 || call.getState() == DialerCallState.CALL_WAITING;
Eric Erfanianccca3152017-02-22 16:32:36 -0800675
676 if (isIncomingOrWaiting
677 && call.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED) {
678
679 if (!TextUtils.isEmpty(call.getChildNumber())) {
linyuh183cb712017-12-27 17:02:37 -0800680 return context.getString(R.string.child_number, call.getChildNumber());
Eric Erfanianccca3152017-02-22 16:32:36 -0800681 } else if (!TextUtils.isEmpty(call.getCallSubject()) && call.isCallSubjectSupported()) {
682 return call.getCallSubject();
683 }
684 }
685
686 int resId = R.string.notification_ongoing_call;
linyuh183cb712017-12-27 17:02:37 -0800687 String wifiBrand = context.getString(R.string.notification_call_wifi_brand);
Eric Erfanianccca3152017-02-22 16:32:36 -0800688 if (call.hasProperty(Details.PROPERTY_WIFI)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700689 resId = R.string.notification_ongoing_call_wifi_template;
Eric Erfanianccca3152017-02-22 16:32:36 -0800690 }
691
692 if (isIncomingOrWaiting) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700693 if (call.isSpam()) {
694 resId = R.string.notification_incoming_spam_call;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700695 } else if (shouldShowEnrichedCallNotification(call.getEnrichedCallSession())) {
696 resId = getECIncomingCallText(call.getEnrichedCallSession());
Eric Erfaniand8046e52017-04-06 09:41:50 -0700697 } else if (call.hasProperty(Details.PROPERTY_WIFI)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700698 resId = R.string.notification_incoming_call_wifi_template;
wangqi9982f0d2017-10-11 17:46:07 -0700699 } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts(call)) {
twyend1d1d0c2017-10-05 17:34:43 -0700700 return getMultiSimIncomingText(call);
yueg45e45732017-10-09 14:35:06 -0700701 } else if (call.isVideoCall()) {
702 resId = R.string.notification_incoming_video_call;
Eric Erfanianccca3152017-02-22 16:32:36 -0800703 } else {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700704 resId = R.string.notification_incoming_call;
Eric Erfanianccca3152017-02-22 16:32:36 -0800705 }
wangqibb94ca62018-04-27 14:34:04 -0700706 } else if (call.getState() == DialerCallState.ONHOLD) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800707 resId = R.string.notification_on_hold;
calderwoodra1dc2cea2017-09-20 16:30:41 -0700708 } else if (call.isVideoCall()) {
709 resId =
710 call.getVideoTech().isPaused()
711 ? R.string.notification_ongoing_paused_video_call
712 : R.string.notification_ongoing_video_call;
wangqibb94ca62018-04-27 14:34:04 -0700713 } else if (DialerCallState.isDialing(call.getState())) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800714 resId = R.string.notification_dialing;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700715 } else if (call.getVideoTech().getSessionModificationState()
Eric Erfanian90508232017-03-24 09:31:16 -0700716 == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800717 resId = R.string.notification_requesting_video_call;
718 }
719
720 // Is the call placed through work connection service.
721 boolean isWorkCall = call.hasProperty(PROPERTY_ENTERPRISE_CALL);
722 if (userType == ContactsUtils.USER_TYPE_WORK || isWorkCall) {
723 resId = getWorkStringFromPersonalString(resId);
linyuh183cb712017-12-27 17:02:37 -0800724 wifiBrand = context.getString(R.string.notification_call_wifi_work_brand);
Eric Erfanian2ca43182017-08-31 06:57:16 -0700725 }
726
727 if (resId == R.string.notification_incoming_call_wifi_template
728 || resId == R.string.notification_ongoing_call_wifi_template) {
Eric Erfanian938468d2017-10-24 14:05:52 -0700729 // TODO(a bug): Potentially apply this template logic everywhere.
linyuh183cb712017-12-27 17:02:37 -0800730 return context.getString(resId, wifiBrand);
Eric Erfanianccca3152017-02-22 16:32:36 -0800731 }
732
linyuh183cb712017-12-27 17:02:37 -0800733 return context.getString(resId);
Eric Erfanianccca3152017-02-22 16:32:36 -0800734 }
735
Eric Erfanian2ca43182017-08-31 06:57:16 -0700736 private boolean shouldShowEnrichedCallNotification(Session session) {
737 if (session == null) {
738 return false;
739 }
740 return session.getMultimediaData().hasData() || session.getMultimediaData().isImportant();
741 }
742
Eric Erfaniand8046e52017-04-06 09:41:50 -0700743 private int getECIncomingCallText(Session session) {
744 int resId;
745 MultimediaData data = session.getMultimediaData();
746 boolean hasImage = data.hasImageData();
747 boolean hasSubject = !TextUtils.isEmpty(data.getText());
748 boolean hasMap = data.getLocation() != null;
749 if (data.isImportant()) {
750 if (hasMap) {
751 if (hasImage) {
752 if (hasSubject) {
753 resId = R.string.important_notification_incoming_call_with_photo_message_location;
754 } else {
755 resId = R.string.important_notification_incoming_call_with_photo_location;
756 }
757 } else if (hasSubject) {
758 resId = R.string.important_notification_incoming_call_with_message_location;
759 } else {
760 resId = R.string.important_notification_incoming_call_with_location;
761 }
762 } else if (hasImage) {
763 if (hasSubject) {
764 resId = R.string.important_notification_incoming_call_with_photo_message;
765 } else {
766 resId = R.string.important_notification_incoming_call_with_photo;
767 }
Eric Erfanian2ca43182017-08-31 06:57:16 -0700768 } else if (hasSubject) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700769 resId = R.string.important_notification_incoming_call_with_message;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700770 } else {
771 resId = R.string.important_notification_incoming_call;
Eric Erfaniand8046e52017-04-06 09:41:50 -0700772 }
linyuh183cb712017-12-27 17:02:37 -0800773 if (context.getString(resId).length() > 50) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700774 resId = R.string.important_notification_incoming_call_attachments;
775 }
776 } else {
777 if (hasMap) {
778 if (hasImage) {
779 if (hasSubject) {
780 resId = R.string.notification_incoming_call_with_photo_message_location;
781 } else {
782 resId = R.string.notification_incoming_call_with_photo_location;
783 }
784 } else if (hasSubject) {
785 resId = R.string.notification_incoming_call_with_message_location;
786 } else {
787 resId = R.string.notification_incoming_call_with_location;
788 }
789 } else if (hasImage) {
790 if (hasSubject) {
791 resId = R.string.notification_incoming_call_with_photo_message;
792 } else {
793 resId = R.string.notification_incoming_call_with_photo;
794 }
795 } else {
796 resId = R.string.notification_incoming_call_with_message;
797 }
798 }
linyuh183cb712017-12-27 17:02:37 -0800799 if (context.getString(resId).length() > 50) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700800 resId = R.string.notification_incoming_call_attachments;
801 }
802 return resId;
803 }
804
twyend1d1d0c2017-10-05 17:34:43 -0700805 private CharSequence getMultiSimIncomingText(DialerCall call) {
806 PhoneAccount phoneAccount =
linyuh183cb712017-12-27 17:02:37 -0800807 context.getSystemService(TelecomManager.class).getPhoneAccount(call.getAccountHandle());
twyene931c122018-03-19 14:47:28 -0700808 if (phoneAccount == null) {
809 return context.getString(R.string.notification_incoming_call);
810 }
twyend1d1d0c2017-10-05 17:34:43 -0700811 SpannableString string =
812 new SpannableString(
linyuh183cb712017-12-27 17:02:37 -0800813 context.getString(
twyend1d1d0c2017-10-05 17:34:43 -0700814 R.string.notification_incoming_call_mutli_sim, phoneAccount.getLabel()));
815 int accountStart = string.toString().lastIndexOf(phoneAccount.getLabel().toString());
816 int accountEnd = accountStart + phoneAccount.getLabel().length();
817
818 string.setSpan(
819 new ForegroundColorSpan(phoneAccount.getHighlightColor()),
820 accountStart,
821 accountEnd,
822 Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
823 return string;
824 }
825
Eric Erfanianccca3152017-02-22 16:32:36 -0800826 /** Gets the most relevant call to display in the notification. */
827 private DialerCall getCallToShow(CallList callList) {
828 if (callList == null) {
829 return null;
830 }
831 DialerCall call = callList.getIncomingCall();
832 if (call == null) {
833 call = callList.getOutgoingCall();
834 }
835 if (call == null) {
836 call = callList.getVideoUpgradeRequestCall();
837 }
838 if (call == null) {
839 call = callList.getActiveOrBackgroundCall();
840 }
841 return call;
842 }
843
844 private Spannable getActionText(@StringRes int stringRes, @ColorRes int colorRes) {
linyuh183cb712017-12-27 17:02:37 -0800845 Spannable spannable = new SpannableString(context.getText(stringRes));
Eric Erfanianccca3152017-02-22 16:32:36 -0800846 if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
847 // This will only work for cases where the Notification.Builder has a fullscreen intent set
848 // Notification.Builder that does not have a full screen intent will take the color of the
849 // app and the following leads to a no-op.
850 spannable.setSpan(
linyuh183cb712017-12-27 17:02:37 -0800851 new ForegroundColorSpan(context.getColor(colorRes)), 0, spannable.length(), 0);
Eric Erfanianccca3152017-02-22 16:32:36 -0800852 }
853 return spannable;
854 }
855
856 private void addAnswerAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700857 LogUtil.d(
858 "StatusBarNotifier.addAnswerAction",
859 "will show \"answer\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800860 PendingIntent answerVoicePendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800861 createNotificationPendingIntent(context, ACTION_ANSWER_VOICE_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800862 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700863 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800864 Icon.createWithResource(context, R.drawable.quantum_ic_call_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700865 getActionText(
866 R.string.notification_action_answer, R.color.notification_action_accept),
867 answerVoicePendingIntent)
868 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800869 }
870
871 private void addDismissAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700872 LogUtil.d(
873 "StatusBarNotifier.addDismissAction",
874 "will show \"decline\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800875 PendingIntent declinePendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800876 createNotificationPendingIntent(context, ACTION_DECLINE_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800877 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700878 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800879 Icon.createWithResource(context, R.drawable.quantum_ic_close_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700880 getActionText(
881 R.string.notification_action_dismiss, R.color.notification_action_dismiss),
882 declinePendingIntent)
883 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800884 }
885
886 private void addHangupAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700887 LogUtil.d(
888 "StatusBarNotifier.addHangupAction",
889 "will show \"hang-up\" action in the ongoing active call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800890 PendingIntent hangupPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800891 createNotificationPendingIntent(context, ACTION_HANG_UP_ONGOING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800892 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700893 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800894 Icon.createWithResource(context, R.drawable.quantum_ic_call_end_white_24),
895 context.getText(R.string.notification_action_end_call),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700896 hangupPendingIntent)
897 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800898 }
899
yuegb26c1ae2017-09-18 16:59:16 -0700900 private void addSpeakerAction(Notification.Builder builder, CallAudioState callAudioState) {
901 if ((callAudioState.getSupportedRouteMask() & CallAudioState.ROUTE_BLUETOOTH)
902 == CallAudioState.ROUTE_BLUETOOTH) {
903 // Don't add speaker button if bluetooth is connected
904 return;
905 }
906 if (callAudioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
907 addSpeakerOffAction(builder);
908 } else if ((callAudioState.getRoute() & CallAudioState.ROUTE_WIRED_OR_EARPIECE) != 0) {
909 addSpeakerOnAction(builder);
910 }
911 }
912
913 private void addSpeakerOnAction(Notification.Builder builder) {
914 LogUtil.d(
915 "StatusBarNotifier.addSpeakerOnAction",
916 "will show \"Speaker on\" action in the ongoing active call Notification");
917 PendingIntent speakerOnPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800918 createNotificationPendingIntent(context, ACTION_TURN_ON_SPEAKER);
yuegb26c1ae2017-09-18 16:59:16 -0700919 builder.addAction(
920 new Notification.Action.Builder(
wangqi6ca8c722018-03-29 10:19:58 -0700921 Icon.createWithResource(context, R.drawable.quantum_ic_volume_up_vd_theme_24),
linyuh183cb712017-12-27 17:02:37 -0800922 context.getText(R.string.notification_action_speaker_on),
yuegb26c1ae2017-09-18 16:59:16 -0700923 speakerOnPendingIntent)
924 .build());
925 }
926
927 private void addSpeakerOffAction(Notification.Builder builder) {
928 LogUtil.d(
929 "StatusBarNotifier.addSpeakerOffAction",
930 "will show \"Speaker off\" action in the ongoing active call Notification");
931 PendingIntent speakerOffPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800932 createNotificationPendingIntent(context, ACTION_TURN_OFF_SPEAKER);
yuegb26c1ae2017-09-18 16:59:16 -0700933 builder.addAction(
934 new Notification.Action.Builder(
wangqi6ca8c722018-03-29 10:19:58 -0700935 Icon.createWithResource(context, R.drawable.quantum_ic_phone_in_talk_vd_theme_24),
linyuh183cb712017-12-27 17:02:37 -0800936 context.getText(R.string.notification_action_speaker_off),
yuegb26c1ae2017-09-18 16:59:16 -0700937 speakerOffPendingIntent)
938 .build());
939 }
940
Eric Erfanianccca3152017-02-22 16:32:36 -0800941 private void addVideoCallAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700942 LogUtil.i(
943 "StatusBarNotifier.addVideoCallAction",
944 "will show \"video\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800945 PendingIntent answerVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800946 createNotificationPendingIntent(context, ACTION_ANSWER_VIDEO_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800947 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700948 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700949 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700950 getActionText(
951 R.string.notification_action_answer_video,
952 R.color.notification_action_answer_video),
953 answerVideoPendingIntent)
954 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800955 }
956
957 private void addAcceptUpgradeRequestAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700958 LogUtil.i(
959 "StatusBarNotifier.addAcceptUpgradeRequestAction",
960 "will show \"accept upgrade\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800961 PendingIntent acceptVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800962 createNotificationPendingIntent(context, ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST);
Eric Erfanianccca3152017-02-22 16:32:36 -0800963 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700964 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700965 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700966 getActionText(
967 R.string.notification_action_accept, R.color.notification_action_accept),
968 acceptVideoPendingIntent)
969 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800970 }
971
972 private void addDismissUpgradeRequestAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700973 LogUtil.i(
974 "StatusBarNotifier.addDismissUpgradeRequestAction",
975 "will show \"dismiss upgrade\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800976 PendingIntent declineVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800977 createNotificationPendingIntent(context, ACTION_DECLINE_VIDEO_UPGRADE_REQUEST);
Eric Erfanianccca3152017-02-22 16:32:36 -0800978 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700979 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700980 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700981 getActionText(
982 R.string.notification_action_dismiss, R.color.notification_action_dismiss),
983 declineVideoPendingIntent)
984 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800985 }
986
987 /** Adds fullscreen intent to the builder. */
Eric Erfanian10b34a52017-05-04 08:23:17 -0700988 private void configureFullScreenIntent(Notification.Builder builder, PendingIntent intent) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800989 // Ok, we actually want to launch the incoming call
990 // UI at this point (in addition to simply posting a notification
991 // to the status bar). Setting fullScreenIntent will cause
992 // the InCallScreen to be launched immediately *unless* the
993 // current foreground activity is marked as "immersive".
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700994 LogUtil.d("StatusBarNotifier.configureFullScreenIntent", "setting fullScreenIntent: " + intent);
Eric Erfanianccca3152017-02-22 16:32:36 -0800995 builder.setFullScreenIntent(intent, true);
Eric Erfanianccca3152017-02-22 16:32:36 -0800996 }
997
998 private Notification.Builder getNotificationBuilder() {
linyuh183cb712017-12-27 17:02:37 -0800999 final Notification.Builder builder = new Notification.Builder(context);
Eric Erfanianccca3152017-02-22 16:32:36 -08001000 builder.setOngoing(true);
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001001 builder.setOnlyAlertOnce(true);
Eric Erfanian10b34a52017-05-04 08:23:17 -07001002 // This will be ignored on O+ and handled by the channel
Eric Erfanian2ca43182017-08-31 06:57:16 -07001003 // noinspection deprecation
Eric Erfanian10b34a52017-05-04 08:23:17 -07001004 builder.setPriority(Notification.PRIORITY_HIGH);
Eric Erfanianccca3152017-02-22 16:32:36 -08001005
1006 return builder;
1007 }
1008
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001009 private PendingIntent createLaunchPendingIntent(boolean isFullScreen) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001010 Intent intent =
1011 InCallActivity.getIntent(
linyuh183cb712017-12-27 17:02:37 -08001012 context, false /* showDialpad */, false /* newOutgoingCall */, isFullScreen);
Eric Erfanianccca3152017-02-22 16:32:36 -08001013
linyuhc3968e62017-11-20 17:40:50 -08001014 int requestCode = InCallActivity.PendingIntentRequestCodes.NON_FULL_SCREEN;
Eric Erfanianccca3152017-02-22 16:32:36 -08001015 if (isFullScreen) {
1016 // Use a unique request code so that the pending intent isn't clobbered by the
1017 // non-full screen pending intent.
linyuhc3968e62017-11-20 17:40:50 -08001018 requestCode = InCallActivity.PendingIntentRequestCodes.FULL_SCREEN;
Eric Erfanianccca3152017-02-22 16:32:36 -08001019 }
1020
1021 // PendingIntent that can be used to launch the InCallActivity. The
1022 // system fires off this intent if the user pulls down the windowshade
1023 // and clicks the notification's expanded view. It's also used to
1024 // launch the InCallActivity immediately when when there's an incoming
1025 // call (see the "fullScreenIntent" field below).
linyuh183cb712017-12-27 17:02:37 -08001026 return PendingIntent.getActivity(context, requestCode, intent, 0);
Eric Erfanianccca3152017-02-22 16:32:36 -08001027 }
1028
1029 private void setStatusBarCallListener(StatusBarCallListener listener) {
linyuh183cb712017-12-27 17:02:37 -08001030 if (statusBarCallListener != null) {
1031 statusBarCallListener.cleanup();
Eric Erfanianccca3152017-02-22 16:32:36 -08001032 }
linyuh183cb712017-12-27 17:02:37 -08001033 statusBarCallListener = listener;
Eric Erfanianccca3152017-02-22 16:32:36 -08001034 }
1035
wangqi9982f0d2017-10-11 17:46:07 -07001036 private boolean hasMultiplePhoneAccounts(DialerCall call) {
1037 if (call.getCallCapableAccounts() == null) {
1038 return false;
1039 }
1040 return call.getCallCapableAccounts().size() > 1;
twyend1d1d0c2017-10-05 17:34:43 -07001041 }
1042
yuegb26c1ae2017-09-18 16:59:16 -07001043 @Override
wangqic8cf79e2017-10-17 09:21:00 -07001044 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
1045 public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
1046 DialerCall call = CallList.getInstance().getCallById(callId);
1047 if (call != null) {
1048 call.getLogState().contactLookupResult = entry.contactLookupResult;
1049 buildAndSendNotification(CallList.getInstance(), call, entry);
1050 }
1051 }
1052
1053 @Override
1054 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
1055 public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
1056 DialerCall call = CallList.getInstance().getCallById(callId);
1057 if (call != null) {
1058 buildAndSendNotification(CallList.getInstance(), call, entry);
1059 }
yuegb26c1ae2017-09-18 16:59:16 -07001060 }
1061
Eric Erfanianccca3152017-02-22 16:32:36 -08001062 private class StatusBarCallListener implements DialerCallListener {
1063
linyuh183cb712017-12-27 17:02:37 -08001064 private DialerCall dialerCall;
Eric Erfanianccca3152017-02-22 16:32:36 -08001065
1066 StatusBarCallListener(DialerCall dialerCall) {
linyuh183cb712017-12-27 17:02:37 -08001067 this.dialerCall = dialerCall;
1068 this.dialerCall.addListener(this);
Eric Erfanianccca3152017-02-22 16:32:36 -08001069 }
1070
1071 void cleanup() {
linyuh183cb712017-12-27 17:02:37 -08001072 dialerCall.removeListener(this);
Eric Erfanianccca3152017-02-22 16:32:36 -08001073 }
1074
1075 @Override
1076 public void onDialerCallDisconnect() {}
1077
1078 @Override
1079 public void onDialerCallUpdate() {
1080 if (CallList.getInstance().getIncomingCall() == null) {
linyuh183cb712017-12-27 17:02:37 -08001081 dialerRingtoneManager.stopCallWaitingTone();
Eric Erfanianccca3152017-02-22 16:32:36 -08001082 }
1083 }
1084
1085 @Override
1086 public void onDialerCallChildNumberChange() {}
1087
1088 @Override
1089 public void onDialerCallLastForwardedNumberChange() {}
1090
1091 @Override
1092 public void onDialerCallUpgradeToVideo() {}
1093
1094 @Override
1095 public void onWiFiToLteHandover() {}
1096
1097 @Override
1098 public void onHandoverToWifiFailure() {}
1099
Eric Erfanianc857f902017-05-15 14:05:33 -07001100 @Override
1101 public void onInternationalCallOnWifi() {}
1102
Eric Erfanian2ca43182017-08-31 06:57:16 -07001103 @Override
1104 public void onEnrichedCallSessionUpdate() {}
1105
Eric Erfanianccca3152017-02-22 16:32:36 -08001106 /**
1107 * Responds to changes in the session modification state for the call by dismissing the status
1108 * bar notification as required.
1109 */
1110 @Override
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001111 public void onDialerCallSessionModificationStateChange() {
linyuh183cb712017-12-27 17:02:37 -08001112 if (dialerCall.getVideoTech().getSessionModificationState()
Eric Erfanian90508232017-03-24 09:31:16 -07001113 == SessionModificationState.NO_REQUEST) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001114 cleanup();
wangqic8cf79e2017-10-17 09:21:00 -07001115 updateNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -08001116 }
1117 }
1118 }
1119}