blob: 6519e00ac02ac5ac12346bf2973708629eb9c913 [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;
zachh190343a2018-05-31 17:30:46 -070069import com.android.dialer.configprovider.ConfigProviderComponent;
Eric Erfanian2ca43182017-08-31 06:57:16 -070070import 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) {
zachh190343a2018-05-31 17:30:46 -0700295 if (ConfigProviderComponent.get(context)
296 .getConfigProvider()
Eric Erfanian2ca43182017-08-31 06:57:16 -0700297 .getBoolean("quiet_incoming_call_if_ui_showing", true)) {
298 notificationType =
299 InCallPresenter.getInstance().isShowingInCallUi()
300 ? NOTIFICATION_INCOMING_CALL_QUIET
301 : NOTIFICATION_INCOMING_CALL;
302 } else {
303 boolean alreadyActive =
304 callList.getActiveOrBackgroundCall() != null
305 && InCallPresenter.getInstance().isShowingInCallUi();
306 notificationType =
307 alreadyActive ? NOTIFICATION_INCOMING_CALL_QUIET : NOTIFICATION_INCOMING_CALL;
308 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800309 } else {
310 notificationType = NOTIFICATION_IN_CALL;
311 }
wangqicf61ca02017-08-31 15:32:55 -0700312 Trace.endSection(); // prepare work
Eric Erfanianccca3152017-02-22 16:32:36 -0800313
314 if (!checkForChangeAndSaveData(
315 iconResId,
twyend1d1d0c2017-10-05 17:34:43 -0700316 content.toString(),
Eric Erfanianccca3152017-02-22 16:32:36 -0800317 largeIcon,
318 contentTitle,
319 callState,
roldenburgc14610d2017-10-31 12:51:06 -0700320 call.getVideoState(),
Eric Erfanianccca3152017-02-22 16:32:36 -0800321 notificationType,
yuegb26c1ae2017-09-18 16:59:16 -0700322 contactInfo.contactRingtoneUri,
323 callAudioState)) {
wangqicf61ca02017-08-31 15:32:55 -0700324 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800325 return;
326 }
327
328 if (largeIcon != null) {
329 largeIcon = getRoundedIcon(largeIcon);
330 }
331
332 // This builder is used for the notification shown when the device is locked and the user
333 // has set their notification settings to 'hide sensitive content'
334 // {@see Notification.Builder#setPublicVersion}.
linyuh183cb712017-12-27 17:02:37 -0800335 Notification.Builder publicBuilder = new Notification.Builder(context);
Eric Erfanianccca3152017-02-22 16:32:36 -0800336 publicBuilder
337 .setSmallIcon(iconResId)
calderwoodraa93df432018-05-23 12:59:03 -0700338 .setColor(ThemeComponent.get(context).theme().getColorPrimary())
Eric Erfanianccca3152017-02-22 16:32:36 -0800339 // Hide work call state for the lock screen notification
340 .setContentTitle(getContentString(call, ContactsUtils.USER_TYPE_CURRENT));
341 setNotificationWhen(call, callState, publicBuilder);
342
343 // Builder for the notification shown when the device is unlocked or the user has set their
344 // notification settings to 'show all notification content'.
345 final Notification.Builder builder = getNotificationBuilder();
346 builder.setPublicVersion(publicBuilder.build());
347
348 // Set up the main intent to send the user to the in-call screen
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700349 builder.setContentIntent(createLaunchPendingIntent(false /* isFullScreen */));
Eric Erfanianccca3152017-02-22 16:32:36 -0800350
Eric Erfanian10b34a52017-05-04 08:23:17 -0700351 LogUtil.i("StatusBarNotifier.buildAndSendNotification", "notificationType=" + notificationType);
352 switch (notificationType) {
353 case NOTIFICATION_INCOMING_CALL:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700354 if (BuildCompat.isAtLeastO()) {
355 builder.setChannelId(NotificationChannelId.INCOMING_CALL);
356 }
wangqic8cf79e2017-10-17 09:21:00 -0700357 // Set the intent as a full screen intent as well if a call is incoming
Eric Erfanian10b34a52017-05-04 08:23:17 -0700358 configureFullScreenIntent(builder, createLaunchPendingIntent(true /* isFullScreen */));
359 // Set the notification category and bump the priority for incoming calls
360 builder.setCategory(Notification.CATEGORY_CALL);
361 // This will be ignored on O+ and handled by the channel
Eric Erfanian10b34a52017-05-04 08:23:17 -0700362 builder.setPriority(Notification.PRIORITY_MAX);
linyuh183cb712017-12-27 17:02:37 -0800363 if (currentNotification != NOTIFICATION_INCOMING_CALL) {
Eric Erfanian10b34a52017-05-04 08:23:17 -0700364 LogUtil.i(
365 "StatusBarNotifier.buildAndSendNotification",
366 "Canceling old notification so this one can be noisy");
367 // Moving from a non-interuptive notification (or none) to a noisy one. Cancel the old
368 // notification (if there is one) so the fullScreenIntent or HUN will show
yueg01a964d2017-10-03 15:25:41 -0700369 TelecomAdapter.getInstance().stopForegroundNotification();
Eric Erfanian10b34a52017-05-04 08:23:17 -0700370 }
371 break;
372 case NOTIFICATION_INCOMING_CALL_QUIET:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700373 if (BuildCompat.isAtLeastO()) {
374 builder.setChannelId(NotificationChannelId.ONGOING_CALL);
375 }
Eric Erfanian10b34a52017-05-04 08:23:17 -0700376 break;
377 case NOTIFICATION_IN_CALL:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700378 if (BuildCompat.isAtLeastO()) {
379 publicBuilder.setColorized(true);
380 builder.setColorized(true);
381 builder.setChannelId(NotificationChannelId.ONGOING_CALL);
382 }
383 break;
384 default:
Eric Erfanian10b34a52017-05-04 08:23:17 -0700385 break;
Eric Erfanianccca3152017-02-22 16:32:36 -0800386 }
387
388 // Set the content
389 builder.setContentText(content);
390 builder.setSmallIcon(iconResId);
391 builder.setContentTitle(contentTitle);
392 builder.setLargeIcon(largeIcon);
yueg01a964d2017-10-03 15:25:41 -0700393 builder.setColor(InCallPresenter.getInstance().getThemeColorManager().getPrimaryColor());
Eric Erfanianccca3152017-02-22 16:32:36 -0800394
395 if (isVideoUpgradeRequest) {
396 builder.setUsesChronometer(false);
397 addDismissUpgradeRequestAction(builder);
398 addAcceptUpgradeRequestAction(builder);
399 } else {
yuegb26c1ae2017-09-18 16:59:16 -0700400 createIncomingCallNotification(call, callState, callAudioState, builder);
Eric Erfanianccca3152017-02-22 16:32:36 -0800401 }
402
403 addPersonReference(builder, contactInfo, call);
404
wangqicf61ca02017-08-31 15:32:55 -0700405 Trace.beginSection("fire notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800406 // Fire off the notification
407 Notification notification = builder.build();
408
linyuh183cb712017-12-27 17:02:37 -0800409 if (dialerRingtoneManager.shouldPlayRingtone(callState, contactInfo.contactRingtoneUri)) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800410 notification.flags |= Notification.FLAG_INSISTENT;
411 notification.sound = contactInfo.contactRingtoneUri;
412 AudioAttributes.Builder audioAttributes = new AudioAttributes.Builder();
413 audioAttributes.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC);
414 audioAttributes.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE);
415 notification.audioAttributes = audioAttributes.build();
linyuh183cb712017-12-27 17:02:37 -0800416 if (dialerRingtoneManager.shouldVibrate(context.getContentResolver())) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800417 notification.vibrate = VIBRATE_PATTERN;
418 }
419 }
linyuh183cb712017-12-27 17:02:37 -0800420 if (dialerRingtoneManager.shouldPlayCallWaitingTone(callState)) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700421 LogUtil.v("StatusBarNotifier.buildAndSendNotification", "playing call waiting tone");
linyuh183cb712017-12-27 17:02:37 -0800422 dialerRingtoneManager.playCallWaitingTone();
Eric Erfanianccca3152017-02-22 16:32:36 -0800423 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800424
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700425 LogUtil.i(
426 "StatusBarNotifier.buildAndSendNotification",
427 "displaying notification for " + notificationType);
428
yueg01a964d2017-10-03 15:25:41 -0700429 // If a notification exists, this will only update it.
430 TelecomAdapter.getInstance().startForegroundNotification(NOTIFICATION_ID, notification);
431
wangqicf61ca02017-08-31 15:32:55 -0700432 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800433 call.getLatencyReport().onNotificationShown();
linyuh183cb712017-12-27 17:02:37 -0800434 currentNotification = notificationType;
wangqicf61ca02017-08-31 15:32:55 -0700435 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800436 }
437
438 private void createIncomingCallNotification(
yuegb26c1ae2017-09-18 16:59:16 -0700439 DialerCall call, int state, CallAudioState callAudioState, Notification.Builder builder) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800440 setNotificationWhen(call, state, builder);
441
442 // Add hang up option for any active calls (active | onhold), outgoing calls (dialing).
wangqibb94ca62018-04-27 14:34:04 -0700443 if (state == DialerCallState.ACTIVE
444 || state == DialerCallState.ONHOLD
445 || DialerCallState.isDialing(state)) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800446 addHangupAction(builder);
yuegb26c1ae2017-09-18 16:59:16 -0700447 addSpeakerAction(builder, callAudioState);
wangqibb94ca62018-04-27 14:34:04 -0700448 } else if (state == DialerCallState.INCOMING || state == DialerCallState.CALL_WAITING) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800449 addDismissAction(builder);
450 if (call.isVideoCall()) {
451 addVideoCallAction(builder);
452 } else {
453 addAnswerAction(builder);
454 }
455 }
456 }
457
458 /**
459 * Sets the notification's when section as needed. For active calls, this is explicitly set as the
460 * duration of the call. For all other states, the notification will automatically show the time
461 * at which the notification was created.
462 */
463 private void setNotificationWhen(DialerCall call, int state, Notification.Builder builder) {
wangqibb94ca62018-04-27 14:34:04 -0700464 if (state == DialerCallState.ACTIVE) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800465 builder.setUsesChronometer(true);
466 builder.setWhen(call.getConnectTimeMillis());
467 } else {
468 builder.setUsesChronometer(false);
469 }
470 }
471
472 /**
473 * Checks the new notification data and compares it against any notification that we are already
474 * displaying. If the data is exactly the same, we return false so that we do not issue a new
475 * notification for the exact same data.
476 */
477 private boolean checkForChangeAndSaveData(
478 int icon,
479 String content,
480 Bitmap largeIcon,
481 String contentTitle,
482 int state,
roldenburgc14610d2017-10-31 12:51:06 -0700483 int videoState,
Eric Erfanianccca3152017-02-22 16:32:36 -0800484 int notificationType,
yuegb26c1ae2017-09-18 16:59:16 -0700485 Uri ringtone,
486 CallAudioState callAudioState) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800487
488 // The two are different:
489 // if new title is not null, it should be different from saved version OR
490 // if new title is null, the saved version should not be null
491 final boolean contentTitleChanged =
linyuh183cb712017-12-27 17:02:37 -0800492 (contentTitle != null && !contentTitle.equals(savedContentTitle))
493 || (contentTitle == null && savedContentTitle != null);
Eric Erfanianccca3152017-02-22 16:32:36 -0800494
roldenburgc14610d2017-10-31 12:51:06 -0700495 boolean largeIconChanged;
linyuh183cb712017-12-27 17:02:37 -0800496 if (savedLargeIcon == null) {
roldenburgc14610d2017-10-31 12:51:06 -0700497 largeIconChanged = largeIcon != null;
498 } else {
linyuh183cb712017-12-27 17:02:37 -0800499 largeIconChanged = largeIcon == null || !savedLargeIcon.sameAs(largeIcon);
roldenburgc14610d2017-10-31 12:51:06 -0700500 }
Eric Erfanian8369df02017-05-03 10:27:13 -0700501
Eric Erfanianccca3152017-02-22 16:32:36 -0800502 // any change means we are definitely updating
503 boolean retval =
linyuh183cb712017-12-27 17:02:37 -0800504 (savedIcon != icon)
505 || !Objects.equals(savedContent, content)
506 || (callState != state)
507 || (this.videoState != videoState)
Eric Erfanian8369df02017-05-03 10:27:13 -0700508 || largeIconChanged
Eric Erfanianccca3152017-02-22 16:32:36 -0800509 || contentTitleChanged
linyuh183cb712017-12-27 17:02:37 -0800510 || !Objects.equals(this.ringtone, ringtone)
yuegb26c1ae2017-09-18 16:59:16 -0700511 || !Objects.equals(savedCallAudioState, callAudioState);
Eric Erfanianccca3152017-02-22 16:32:36 -0800512
wangqi9982f0d2017-10-11 17:46:07 -0700513 LogUtil.d(
514 "StatusBarNotifier.checkForChangeAndSaveData",
roldenburgc14610d2017-10-31 12:51:06 -0700515 "data changed: icon: %b, content: %b, state: %b, videoState: %b, largeIcon: %b, title: %b,"
516 + "ringtone: %b, audioState: %b, type: %b",
linyuh183cb712017-12-27 17:02:37 -0800517 (savedIcon != icon),
518 !Objects.equals(savedContent, content),
519 (callState != state),
520 (this.videoState != videoState),
wangqi9982f0d2017-10-11 17:46:07 -0700521 largeIconChanged,
522 contentTitleChanged,
linyuh183cb712017-12-27 17:02:37 -0800523 !Objects.equals(this.ringtone, ringtone),
wangqi9982f0d2017-10-11 17:46:07 -0700524 !Objects.equals(savedCallAudioState, callAudioState),
linyuh183cb712017-12-27 17:02:37 -0800525 currentNotification != notificationType);
Eric Erfanianccca3152017-02-22 16:32:36 -0800526 // If we aren't showing a notification right now or the notification type is changing,
527 // definitely do an update.
linyuh183cb712017-12-27 17:02:37 -0800528 if (currentNotification != notificationType) {
529 if (currentNotification == NOTIFICATION_NONE) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700530 LogUtil.d(
531 "StatusBarNotifier.checkForChangeAndSaveData", "showing notification for first time.");
Eric Erfanianccca3152017-02-22 16:32:36 -0800532 }
533 retval = true;
534 }
535
linyuh183cb712017-12-27 17:02:37 -0800536 savedIcon = icon;
537 savedContent = content;
538 callState = state;
539 this.videoState = videoState;
540 savedLargeIcon = largeIcon;
541 savedContentTitle = contentTitle;
542 this.ringtone = ringtone;
yuegb26c1ae2017-09-18 16:59:16 -0700543 savedCallAudioState = callAudioState;
Eric Erfanianccca3152017-02-22 16:32:36 -0800544
545 if (retval) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700546 LogUtil.d(
547 "StatusBarNotifier.checkForChangeAndSaveData", "data changed. Showing notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800548 }
549
550 return retval;
551 }
552
553 /** Returns the main string to use in the notification. */
554 @VisibleForTesting
555 @Nullable
556 String getContentTitle(ContactCacheEntry contactInfo, DialerCall call) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700557 if (call.isConferenceCall()) {
558 return CallerInfoUtils.getConferenceString(
linyuh183cb712017-12-27 17:02:37 -0800559 context, call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE));
Eric Erfanianccca3152017-02-22 16:32:36 -0800560 }
561
562 String preferredName =
563 ContactDisplayUtils.getPreferredDisplayName(
linyuh183cb712017-12-27 17:02:37 -0800564 contactInfo.namePrimary, contactInfo.nameAlternative, contactsPreferences);
Eric Erfanianccca3152017-02-22 16:32:36 -0800565 if (TextUtils.isEmpty(preferredName)) {
566 return TextUtils.isEmpty(contactInfo.number)
567 ? null
568 : BidiFormatter.getInstance()
569 .unicodeWrap(contactInfo.number, TextDirectionHeuristics.LTR);
570 }
571 return preferredName;
572 }
573
574 private void addPersonReference(
575 Notification.Builder builder, ContactCacheEntry contactInfo, DialerCall call) {
576 // Query {@link Contacts#CONTENT_LOOKUP_URI} directly with work lookup key is not allowed.
577 // So, do not pass {@link Contacts#CONTENT_LOOKUP_URI} to NotificationManager to avoid
578 // NotificationManager using it.
579 if (contactInfo.lookupUri != null && contactInfo.userType != ContactsUtils.USER_TYPE_WORK) {
580 builder.addPerson(contactInfo.lookupUri.toString());
581 } else if (!TextUtils.isEmpty(call.getNumber())) {
582 builder.addPerson(Uri.fromParts(PhoneAccount.SCHEME_TEL, call.getNumber(), null).toString());
583 }
584 }
585
586 /** Gets a large icon from the contact info object to display in the notification. */
Eric Erfanian83b20212017-05-31 08:53:10 -0700587 private static Bitmap getLargeIconToDisplay(
588 Context context, ContactCacheEntry contactInfo, DialerCall call) {
wangqic8cf79e2017-10-17 09:21:00 -0700589 Trace.beginSection("StatusBarNotifier.getLargeIconToDisplay");
Eric Erfanian83b20212017-05-31 08:53:10 -0700590 Resources resources = context.getResources();
Eric Erfanianccca3152017-02-22 16:32:36 -0800591 Bitmap largeIcon = null;
Eric Erfanianccca3152017-02-22 16:32:36 -0800592 if (contactInfo.photo != null && (contactInfo.photo instanceof BitmapDrawable)) {
593 largeIcon = ((BitmapDrawable) contactInfo.photo).getBitmap();
594 }
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700595 if (contactInfo.photo == null) {
Eric Erfanian83b20212017-05-31 08:53:10 -0700596 int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
597 int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
Eric Erfanian2ca43182017-08-31 06:57:16 -0700598 @ContactType
599 int contactType =
600 LetterTileDrawable.getContactTypeFromPrimitives(
wangqi9982f0d2017-10-11 17:46:07 -0700601 call.isVoiceMailNumber(),
Eric Erfanian2ca43182017-08-31 06:57:16 -0700602 call.isSpam(),
603 contactInfo.isBusiness,
604 call.getNumberPresentation(),
605 call.isConferenceCall() && !call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE));
Eric Erfanian83b20212017-05-31 08:53:10 -0700606 LetterTileDrawable lettertile = new LetterTileDrawable(resources);
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700607
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700608 lettertile.setCanonicalDialerLetterTileDetails(
609 contactInfo.namePrimary == null ? contactInfo.number : contactInfo.namePrimary,
610 contactInfo.lookupKey,
611 LetterTileDrawable.SHAPE_CIRCLE,
612 contactType);
613 largeIcon = lettertile.getBitmap(width, height);
614 }
615
Eric Erfanianccca3152017-02-22 16:32:36 -0800616 if (call.isSpam()) {
Eric Erfanian83b20212017-05-31 08:53:10 -0700617 Drawable drawable = resources.getDrawable(R.drawable.blocked_contact, context.getTheme());
Eric Erfanianccca3152017-02-22 16:32:36 -0800618 largeIcon = DrawableConverter.drawableToBitmap(drawable);
619 }
wangqic8cf79e2017-10-17 09:21:00 -0700620 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800621 return largeIcon;
622 }
623
624 private Bitmap getRoundedIcon(Bitmap bitmap) {
625 if (bitmap == null) {
626 return null;
627 }
628 final int height =
linyuh183cb712017-12-27 17:02:37 -0800629 (int) context.getResources().getDimension(android.R.dimen.notification_large_icon_height);
Eric Erfanianccca3152017-02-22 16:32:36 -0800630 final int width =
linyuh183cb712017-12-27 17:02:37 -0800631 (int) context.getResources().getDimension(android.R.dimen.notification_large_icon_width);
Eric Erfanianccca3152017-02-22 16:32:36 -0800632 return BitmapUtil.getRoundedBitmap(bitmap, width, height);
633 }
634
635 /**
636 * Returns the appropriate icon res Id to display based on the call for which we want to display
637 * information.
638 */
Eric Erfanian2827dd12017-10-26 09:37:50 -0700639 @VisibleForTesting
640 public int getIconToDisplay(DialerCall call) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800641 // Even if both lines are in use, we only show a single item in
642 // the expanded Notifications UI. It's labeled "Ongoing call"
643 // (or "On hold" if there's only one call, and it's on hold.)
644 // Also, we don't have room to display caller-id info from two
645 // different calls. So if both lines are in use, display info
646 // from the foreground call. And if there's a ringing call,
647 // display that regardless of the state of the other calls.
wangqibb94ca62018-04-27 14:34:04 -0700648 if (call.getState() == DialerCallState.ONHOLD) {
Eric Erfanian2827dd12017-10-26 09:37:50 -0700649 return R.drawable.quantum_ic_phone_paused_vd_theme_24;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700650 } else if (call.getVideoTech().getSessionModificationState()
calderwoodra1dc2cea2017-09-20 16:30:41 -0700651 == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST
652 || call.isVideoCall()) {
linyuh8dc242d2018-03-28 13:09:47 -0700653 return R.drawable.quantum_ic_videocam_vd_white_24;
Eric Erfanian90508232017-03-24 09:31:16 -0700654 } else if (call.hasProperty(PROPERTY_HIGH_DEF_AUDIO)
linyuh183cb712017-12-27 17:02:37 -0800655 && MotorolaUtils.shouldShowHdIconInNotification(context)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700656 // Normally when a call is ongoing the status bar displays an icon of a phone. This is a
657 // helpful hint for users so they know how to get back to the call. For Sprint HD calls, we
658 // 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 -0700659 return R.drawable.ic_hd_call;
Eric Erfanian2827dd12017-10-26 09:37:50 -0700660 } else if (call.hasProperty(Details.PROPERTY_HAS_CDMA_VOICE_PRIVACY)) {
661 return R.drawable.quantum_ic_phone_locked_vd_theme_24;
Eric Erfanianccca3152017-02-22 16:32:36 -0800662 }
yueg48f93f42018-03-09 16:49:38 -0800663 // If ReturnToCall is enabled, use the static icon. The animated one will show in the bubble.
664 if (ReturnToCallController.isEnabled(context)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700665 return R.drawable.quantum_ic_call_vd_theme_24;
666 } else {
667 return R.drawable.on_going_call;
668 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800669 }
670
671 /** Returns the message to use with the notification. */
twyend1d1d0c2017-10-05 17:34:43 -0700672 private CharSequence getContentString(DialerCall call, @UserType long userType) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800673 boolean isIncomingOrWaiting =
wangqibb94ca62018-04-27 14:34:04 -0700674 call.getState() == DialerCallState.INCOMING
675 || call.getState() == DialerCallState.CALL_WAITING;
Eric Erfanianccca3152017-02-22 16:32:36 -0800676
677 if (isIncomingOrWaiting
678 && call.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED) {
679
680 if (!TextUtils.isEmpty(call.getChildNumber())) {
linyuh183cb712017-12-27 17:02:37 -0800681 return context.getString(R.string.child_number, call.getChildNumber());
Eric Erfanianccca3152017-02-22 16:32:36 -0800682 } else if (!TextUtils.isEmpty(call.getCallSubject()) && call.isCallSubjectSupported()) {
683 return call.getCallSubject();
684 }
685 }
686
687 int resId = R.string.notification_ongoing_call;
linyuh183cb712017-12-27 17:02:37 -0800688 String wifiBrand = context.getString(R.string.notification_call_wifi_brand);
Eric Erfanianccca3152017-02-22 16:32:36 -0800689 if (call.hasProperty(Details.PROPERTY_WIFI)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700690 resId = R.string.notification_ongoing_call_wifi_template;
Eric Erfanianccca3152017-02-22 16:32:36 -0800691 }
692
693 if (isIncomingOrWaiting) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700694 if (call.isSpam()) {
695 resId = R.string.notification_incoming_spam_call;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700696 } else if (shouldShowEnrichedCallNotification(call.getEnrichedCallSession())) {
697 resId = getECIncomingCallText(call.getEnrichedCallSession());
Eric Erfaniand8046e52017-04-06 09:41:50 -0700698 } else if (call.hasProperty(Details.PROPERTY_WIFI)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700699 resId = R.string.notification_incoming_call_wifi_template;
wangqi9982f0d2017-10-11 17:46:07 -0700700 } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts(call)) {
twyend1d1d0c2017-10-05 17:34:43 -0700701 return getMultiSimIncomingText(call);
yueg45e45732017-10-09 14:35:06 -0700702 } else if (call.isVideoCall()) {
703 resId = R.string.notification_incoming_video_call;
Eric Erfanianccca3152017-02-22 16:32:36 -0800704 } else {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700705 resId = R.string.notification_incoming_call;
Eric Erfanianccca3152017-02-22 16:32:36 -0800706 }
wangqibb94ca62018-04-27 14:34:04 -0700707 } else if (call.getState() == DialerCallState.ONHOLD) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800708 resId = R.string.notification_on_hold;
calderwoodra1dc2cea2017-09-20 16:30:41 -0700709 } else if (call.isVideoCall()) {
710 resId =
711 call.getVideoTech().isPaused()
712 ? R.string.notification_ongoing_paused_video_call
713 : R.string.notification_ongoing_video_call;
wangqibb94ca62018-04-27 14:34:04 -0700714 } else if (DialerCallState.isDialing(call.getState())) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800715 resId = R.string.notification_dialing;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700716 } else if (call.getVideoTech().getSessionModificationState()
Eric Erfanian90508232017-03-24 09:31:16 -0700717 == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800718 resId = R.string.notification_requesting_video_call;
719 }
720
721 // Is the call placed through work connection service.
722 boolean isWorkCall = call.hasProperty(PROPERTY_ENTERPRISE_CALL);
723 if (userType == ContactsUtils.USER_TYPE_WORK || isWorkCall) {
724 resId = getWorkStringFromPersonalString(resId);
linyuh183cb712017-12-27 17:02:37 -0800725 wifiBrand = context.getString(R.string.notification_call_wifi_work_brand);
Eric Erfanian2ca43182017-08-31 06:57:16 -0700726 }
727
728 if (resId == R.string.notification_incoming_call_wifi_template
729 || resId == R.string.notification_ongoing_call_wifi_template) {
Eric Erfanian938468d2017-10-24 14:05:52 -0700730 // TODO(a bug): Potentially apply this template logic everywhere.
linyuh183cb712017-12-27 17:02:37 -0800731 return context.getString(resId, wifiBrand);
Eric Erfanianccca3152017-02-22 16:32:36 -0800732 }
733
linyuh183cb712017-12-27 17:02:37 -0800734 return context.getString(resId);
Eric Erfanianccca3152017-02-22 16:32:36 -0800735 }
736
Eric Erfanian2ca43182017-08-31 06:57:16 -0700737 private boolean shouldShowEnrichedCallNotification(Session session) {
738 if (session == null) {
739 return false;
740 }
741 return session.getMultimediaData().hasData() || session.getMultimediaData().isImportant();
742 }
743
Eric Erfaniand8046e52017-04-06 09:41:50 -0700744 private int getECIncomingCallText(Session session) {
745 int resId;
746 MultimediaData data = session.getMultimediaData();
747 boolean hasImage = data.hasImageData();
748 boolean hasSubject = !TextUtils.isEmpty(data.getText());
749 boolean hasMap = data.getLocation() != null;
750 if (data.isImportant()) {
751 if (hasMap) {
752 if (hasImage) {
753 if (hasSubject) {
754 resId = R.string.important_notification_incoming_call_with_photo_message_location;
755 } else {
756 resId = R.string.important_notification_incoming_call_with_photo_location;
757 }
758 } else if (hasSubject) {
759 resId = R.string.important_notification_incoming_call_with_message_location;
760 } else {
761 resId = R.string.important_notification_incoming_call_with_location;
762 }
763 } else if (hasImage) {
764 if (hasSubject) {
765 resId = R.string.important_notification_incoming_call_with_photo_message;
766 } else {
767 resId = R.string.important_notification_incoming_call_with_photo;
768 }
Eric Erfanian2ca43182017-08-31 06:57:16 -0700769 } else if (hasSubject) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700770 resId = R.string.important_notification_incoming_call_with_message;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700771 } else {
772 resId = R.string.important_notification_incoming_call;
Eric Erfaniand8046e52017-04-06 09:41:50 -0700773 }
linyuh183cb712017-12-27 17:02:37 -0800774 if (context.getString(resId).length() > 50) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700775 resId = R.string.important_notification_incoming_call_attachments;
776 }
777 } else {
778 if (hasMap) {
779 if (hasImage) {
780 if (hasSubject) {
781 resId = R.string.notification_incoming_call_with_photo_message_location;
782 } else {
783 resId = R.string.notification_incoming_call_with_photo_location;
784 }
785 } else if (hasSubject) {
786 resId = R.string.notification_incoming_call_with_message_location;
787 } else {
788 resId = R.string.notification_incoming_call_with_location;
789 }
790 } else if (hasImage) {
791 if (hasSubject) {
792 resId = R.string.notification_incoming_call_with_photo_message;
793 } else {
794 resId = R.string.notification_incoming_call_with_photo;
795 }
796 } else {
797 resId = R.string.notification_incoming_call_with_message;
798 }
799 }
linyuh183cb712017-12-27 17:02:37 -0800800 if (context.getString(resId).length() > 50) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700801 resId = R.string.notification_incoming_call_attachments;
802 }
803 return resId;
804 }
805
twyend1d1d0c2017-10-05 17:34:43 -0700806 private CharSequence getMultiSimIncomingText(DialerCall call) {
807 PhoneAccount phoneAccount =
linyuh183cb712017-12-27 17:02:37 -0800808 context.getSystemService(TelecomManager.class).getPhoneAccount(call.getAccountHandle());
twyene931c122018-03-19 14:47:28 -0700809 if (phoneAccount == null) {
810 return context.getString(R.string.notification_incoming_call);
811 }
twyend1d1d0c2017-10-05 17:34:43 -0700812 SpannableString string =
813 new SpannableString(
linyuh183cb712017-12-27 17:02:37 -0800814 context.getString(
twyend1d1d0c2017-10-05 17:34:43 -0700815 R.string.notification_incoming_call_mutli_sim, phoneAccount.getLabel()));
816 int accountStart = string.toString().lastIndexOf(phoneAccount.getLabel().toString());
817 int accountEnd = accountStart + phoneAccount.getLabel().length();
818
819 string.setSpan(
820 new ForegroundColorSpan(phoneAccount.getHighlightColor()),
821 accountStart,
822 accountEnd,
823 Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
824 return string;
825 }
826
Eric Erfanianccca3152017-02-22 16:32:36 -0800827 /** Gets the most relevant call to display in the notification. */
828 private DialerCall getCallToShow(CallList callList) {
829 if (callList == null) {
830 return null;
831 }
832 DialerCall call = callList.getIncomingCall();
833 if (call == null) {
834 call = callList.getOutgoingCall();
835 }
836 if (call == null) {
837 call = callList.getVideoUpgradeRequestCall();
838 }
839 if (call == null) {
840 call = callList.getActiveOrBackgroundCall();
841 }
842 return call;
843 }
844
845 private Spannable getActionText(@StringRes int stringRes, @ColorRes int colorRes) {
linyuh183cb712017-12-27 17:02:37 -0800846 Spannable spannable = new SpannableString(context.getText(stringRes));
Eric Erfanianccca3152017-02-22 16:32:36 -0800847 if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
848 // This will only work for cases where the Notification.Builder has a fullscreen intent set
849 // Notification.Builder that does not have a full screen intent will take the color of the
850 // app and the following leads to a no-op.
851 spannable.setSpan(
linyuh183cb712017-12-27 17:02:37 -0800852 new ForegroundColorSpan(context.getColor(colorRes)), 0, spannable.length(), 0);
Eric Erfanianccca3152017-02-22 16:32:36 -0800853 }
854 return spannable;
855 }
856
857 private void addAnswerAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700858 LogUtil.d(
859 "StatusBarNotifier.addAnswerAction",
860 "will show \"answer\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800861 PendingIntent answerVoicePendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800862 createNotificationPendingIntent(context, ACTION_ANSWER_VOICE_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800863 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700864 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800865 Icon.createWithResource(context, R.drawable.quantum_ic_call_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700866 getActionText(
867 R.string.notification_action_answer, R.color.notification_action_accept),
868 answerVoicePendingIntent)
869 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800870 }
871
872 private void addDismissAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700873 LogUtil.d(
874 "StatusBarNotifier.addDismissAction",
875 "will show \"decline\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800876 PendingIntent declinePendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800877 createNotificationPendingIntent(context, ACTION_DECLINE_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800878 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700879 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800880 Icon.createWithResource(context, R.drawable.quantum_ic_close_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700881 getActionText(
882 R.string.notification_action_dismiss, R.color.notification_action_dismiss),
883 declinePendingIntent)
884 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800885 }
886
887 private void addHangupAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700888 LogUtil.d(
889 "StatusBarNotifier.addHangupAction",
890 "will show \"hang-up\" action in the ongoing active call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800891 PendingIntent hangupPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800892 createNotificationPendingIntent(context, ACTION_HANG_UP_ONGOING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800893 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700894 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800895 Icon.createWithResource(context, R.drawable.quantum_ic_call_end_white_24),
896 context.getText(R.string.notification_action_end_call),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700897 hangupPendingIntent)
898 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800899 }
900
yuegb26c1ae2017-09-18 16:59:16 -0700901 private void addSpeakerAction(Notification.Builder builder, CallAudioState callAudioState) {
902 if ((callAudioState.getSupportedRouteMask() & CallAudioState.ROUTE_BLUETOOTH)
903 == CallAudioState.ROUTE_BLUETOOTH) {
904 // Don't add speaker button if bluetooth is connected
905 return;
906 }
907 if (callAudioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
908 addSpeakerOffAction(builder);
909 } else if ((callAudioState.getRoute() & CallAudioState.ROUTE_WIRED_OR_EARPIECE) != 0) {
910 addSpeakerOnAction(builder);
911 }
912 }
913
914 private void addSpeakerOnAction(Notification.Builder builder) {
915 LogUtil.d(
916 "StatusBarNotifier.addSpeakerOnAction",
917 "will show \"Speaker on\" action in the ongoing active call Notification");
918 PendingIntent speakerOnPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800919 createNotificationPendingIntent(context, ACTION_TURN_ON_SPEAKER);
yuegb26c1ae2017-09-18 16:59:16 -0700920 builder.addAction(
921 new Notification.Action.Builder(
wangqi6ca8c722018-03-29 10:19:58 -0700922 Icon.createWithResource(context, R.drawable.quantum_ic_volume_up_vd_theme_24),
linyuh183cb712017-12-27 17:02:37 -0800923 context.getText(R.string.notification_action_speaker_on),
yuegb26c1ae2017-09-18 16:59:16 -0700924 speakerOnPendingIntent)
925 .build());
926 }
927
928 private void addSpeakerOffAction(Notification.Builder builder) {
929 LogUtil.d(
930 "StatusBarNotifier.addSpeakerOffAction",
931 "will show \"Speaker off\" action in the ongoing active call Notification");
932 PendingIntent speakerOffPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800933 createNotificationPendingIntent(context, ACTION_TURN_OFF_SPEAKER);
yuegb26c1ae2017-09-18 16:59:16 -0700934 builder.addAction(
935 new Notification.Action.Builder(
wangqi6ca8c722018-03-29 10:19:58 -0700936 Icon.createWithResource(context, R.drawable.quantum_ic_phone_in_talk_vd_theme_24),
linyuh183cb712017-12-27 17:02:37 -0800937 context.getText(R.string.notification_action_speaker_off),
yuegb26c1ae2017-09-18 16:59:16 -0700938 speakerOffPendingIntent)
939 .build());
940 }
941
Eric Erfanianccca3152017-02-22 16:32:36 -0800942 private void addVideoCallAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700943 LogUtil.i(
944 "StatusBarNotifier.addVideoCallAction",
945 "will show \"video\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800946 PendingIntent answerVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800947 createNotificationPendingIntent(context, ACTION_ANSWER_VIDEO_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800948 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700949 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700950 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700951 getActionText(
952 R.string.notification_action_answer_video,
953 R.color.notification_action_answer_video),
954 answerVideoPendingIntent)
955 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800956 }
957
958 private void addAcceptUpgradeRequestAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700959 LogUtil.i(
960 "StatusBarNotifier.addAcceptUpgradeRequestAction",
961 "will show \"accept upgrade\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800962 PendingIntent acceptVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800963 createNotificationPendingIntent(context, ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST);
Eric Erfanianccca3152017-02-22 16:32:36 -0800964 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700965 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700966 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700967 getActionText(
968 R.string.notification_action_accept, R.color.notification_action_accept),
969 acceptVideoPendingIntent)
970 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800971 }
972
973 private void addDismissUpgradeRequestAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700974 LogUtil.i(
975 "StatusBarNotifier.addDismissUpgradeRequestAction",
976 "will show \"dismiss upgrade\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800977 PendingIntent declineVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800978 createNotificationPendingIntent(context, ACTION_DECLINE_VIDEO_UPGRADE_REQUEST);
Eric Erfanianccca3152017-02-22 16:32:36 -0800979 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700980 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700981 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700982 getActionText(
983 R.string.notification_action_dismiss, R.color.notification_action_dismiss),
984 declineVideoPendingIntent)
985 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800986 }
987
988 /** Adds fullscreen intent to the builder. */
Eric Erfanian10b34a52017-05-04 08:23:17 -0700989 private void configureFullScreenIntent(Notification.Builder builder, PendingIntent intent) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800990 // Ok, we actually want to launch the incoming call
991 // UI at this point (in addition to simply posting a notification
992 // to the status bar). Setting fullScreenIntent will cause
993 // the InCallScreen to be launched immediately *unless* the
994 // current foreground activity is marked as "immersive".
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700995 LogUtil.d("StatusBarNotifier.configureFullScreenIntent", "setting fullScreenIntent: " + intent);
Eric Erfanianccca3152017-02-22 16:32:36 -0800996 builder.setFullScreenIntent(intent, true);
Eric Erfanianccca3152017-02-22 16:32:36 -0800997 }
998
999 private Notification.Builder getNotificationBuilder() {
linyuh183cb712017-12-27 17:02:37 -08001000 final Notification.Builder builder = new Notification.Builder(context);
Eric Erfanianccca3152017-02-22 16:32:36 -08001001 builder.setOngoing(true);
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001002 builder.setOnlyAlertOnce(true);
Eric Erfanian10b34a52017-05-04 08:23:17 -07001003 // This will be ignored on O+ and handled by the channel
Eric Erfanian2ca43182017-08-31 06:57:16 -07001004 // noinspection deprecation
Eric Erfanian10b34a52017-05-04 08:23:17 -07001005 builder.setPriority(Notification.PRIORITY_HIGH);
Eric Erfanianccca3152017-02-22 16:32:36 -08001006
1007 return builder;
1008 }
1009
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001010 private PendingIntent createLaunchPendingIntent(boolean isFullScreen) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001011 Intent intent =
1012 InCallActivity.getIntent(
linyuh183cb712017-12-27 17:02:37 -08001013 context, false /* showDialpad */, false /* newOutgoingCall */, isFullScreen);
Eric Erfanianccca3152017-02-22 16:32:36 -08001014
linyuhc3968e62017-11-20 17:40:50 -08001015 int requestCode = InCallActivity.PendingIntentRequestCodes.NON_FULL_SCREEN;
Eric Erfanianccca3152017-02-22 16:32:36 -08001016 if (isFullScreen) {
1017 // Use a unique request code so that the pending intent isn't clobbered by the
1018 // non-full screen pending intent.
linyuhc3968e62017-11-20 17:40:50 -08001019 requestCode = InCallActivity.PendingIntentRequestCodes.FULL_SCREEN;
Eric Erfanianccca3152017-02-22 16:32:36 -08001020 }
1021
1022 // PendingIntent that can be used to launch the InCallActivity. The
1023 // system fires off this intent if the user pulls down the windowshade
1024 // and clicks the notification's expanded view. It's also used to
1025 // launch the InCallActivity immediately when when there's an incoming
1026 // call (see the "fullScreenIntent" field below).
linyuh183cb712017-12-27 17:02:37 -08001027 return PendingIntent.getActivity(context, requestCode, intent, 0);
Eric Erfanianccca3152017-02-22 16:32:36 -08001028 }
1029
1030 private void setStatusBarCallListener(StatusBarCallListener listener) {
linyuh183cb712017-12-27 17:02:37 -08001031 if (statusBarCallListener != null) {
1032 statusBarCallListener.cleanup();
Eric Erfanianccca3152017-02-22 16:32:36 -08001033 }
linyuh183cb712017-12-27 17:02:37 -08001034 statusBarCallListener = listener;
Eric Erfanianccca3152017-02-22 16:32:36 -08001035 }
1036
wangqi9982f0d2017-10-11 17:46:07 -07001037 private boolean hasMultiplePhoneAccounts(DialerCall call) {
1038 if (call.getCallCapableAccounts() == null) {
1039 return false;
1040 }
1041 return call.getCallCapableAccounts().size() > 1;
twyend1d1d0c2017-10-05 17:34:43 -07001042 }
1043
yuegb26c1ae2017-09-18 16:59:16 -07001044 @Override
wangqic8cf79e2017-10-17 09:21:00 -07001045 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
1046 public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
1047 DialerCall call = CallList.getInstance().getCallById(callId);
1048 if (call != null) {
1049 call.getLogState().contactLookupResult = entry.contactLookupResult;
1050 buildAndSendNotification(CallList.getInstance(), call, entry);
1051 }
1052 }
1053
1054 @Override
1055 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
1056 public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
1057 DialerCall call = CallList.getInstance().getCallById(callId);
1058 if (call != null) {
1059 buildAndSendNotification(CallList.getInstance(), call, entry);
1060 }
yuegb26c1ae2017-09-18 16:59:16 -07001061 }
1062
Eric Erfanianccca3152017-02-22 16:32:36 -08001063 private class StatusBarCallListener implements DialerCallListener {
1064
linyuh183cb712017-12-27 17:02:37 -08001065 private DialerCall dialerCall;
Eric Erfanianccca3152017-02-22 16:32:36 -08001066
1067 StatusBarCallListener(DialerCall dialerCall) {
linyuh183cb712017-12-27 17:02:37 -08001068 this.dialerCall = dialerCall;
1069 this.dialerCall.addListener(this);
Eric Erfanianccca3152017-02-22 16:32:36 -08001070 }
1071
1072 void cleanup() {
linyuh183cb712017-12-27 17:02:37 -08001073 dialerCall.removeListener(this);
Eric Erfanianccca3152017-02-22 16:32:36 -08001074 }
1075
1076 @Override
1077 public void onDialerCallDisconnect() {}
1078
1079 @Override
1080 public void onDialerCallUpdate() {
1081 if (CallList.getInstance().getIncomingCall() == null) {
linyuh183cb712017-12-27 17:02:37 -08001082 dialerRingtoneManager.stopCallWaitingTone();
Eric Erfanianccca3152017-02-22 16:32:36 -08001083 }
1084 }
1085
1086 @Override
1087 public void onDialerCallChildNumberChange() {}
1088
1089 @Override
1090 public void onDialerCallLastForwardedNumberChange() {}
1091
1092 @Override
1093 public void onDialerCallUpgradeToVideo() {}
1094
1095 @Override
1096 public void onWiFiToLteHandover() {}
1097
1098 @Override
1099 public void onHandoverToWifiFailure() {}
1100
Eric Erfanianc857f902017-05-15 14:05:33 -07001101 @Override
1102 public void onInternationalCallOnWifi() {}
1103
Eric Erfanian2ca43182017-08-31 06:57:16 -07001104 @Override
1105 public void onEnrichedCallSessionUpdate() {}
1106
Eric Erfanianccca3152017-02-22 16:32:36 -08001107 /**
1108 * Responds to changes in the session modification state for the call by dismissing the status
1109 * bar notification as required.
1110 */
1111 @Override
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001112 public void onDialerCallSessionModificationStateChange() {
linyuh183cb712017-12-27 17:02:37 -08001113 if (dialerCall.getVideoTech().getSessionModificationState()
Eric Erfanian90508232017-03-24 09:31:16 -07001114 == SessionModificationState.NO_REQUEST) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001115 cleanup();
wangqic8cf79e2017-10-17 09:21:00 -07001116 updateNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -08001117 }
1118 }
1119 }
1120}