blob: 32d20259553d861b98e16cc6aadad5b8d1e4d7f0 [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;
Eric Erfanianccca3152017-02-22 16:32:36 -080078import com.android.dialer.util.DrawableConverter;
79import com.android.incallui.ContactInfoCache.ContactCacheEntry;
80import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback;
81import com.android.incallui.InCallPresenter.InCallState;
82import com.android.incallui.async.PausableExecutorImpl;
yuegb26c1ae2017-09-18 16:59:16 -070083import com.android.incallui.audiomode.AudioModeProvider;
Eric Erfanianccca3152017-02-22 16:32:36 -080084import com.android.incallui.call.CallList;
85import com.android.incallui.call.DialerCall;
Eric Erfanianccca3152017-02-22 16:32:36 -080086import com.android.incallui.call.DialerCallListener;
yueg01a964d2017-10-03 15:25:41 -070087import com.android.incallui.call.TelecomAdapter;
wangqibb94ca62018-04-27 14:34:04 -070088import com.android.incallui.call.state.DialerCallState;
Eric Erfanianccca3152017-02-22 16:32:36 -080089import com.android.incallui.ringtone.DialerRingtoneManager;
90import com.android.incallui.ringtone.InCallTonePlayer;
91import com.android.incallui.ringtone.ToneGeneratorFactory;
Eric Erfanian90508232017-03-24 09:31:16 -070092import com.android.incallui.videotech.utils.SessionModificationState;
Eric Erfanianccca3152017-02-22 16:32:36 -080093import java.util.Objects;
94
95/** This class adds Notifications to the status bar for the in-call experience. */
Eric Erfaniand8046e52017-04-06 09:41:50 -070096public class StatusBarNotifier
yuegb26c1ae2017-09-18 16:59:16 -070097 implements InCallPresenter.InCallStateListener,
98 EnrichedCallManager.StateChangedListener,
wangqic8cf79e2017-10-17 09:21:00 -070099 ContactInfoCacheCallback {
Eric Erfanianccca3152017-02-22 16:32:36 -0800100
Eric Erfanian2ca43182017-08-31 06:57:16 -0700101 private static final int NOTIFICATION_ID = 1;
102
Eric Erfanianccca3152017-02-22 16:32:36 -0800103 // Notification types
104 // Indicates that no notification is currently showing.
105 private static final int NOTIFICATION_NONE = 0;
106 // Notification for an active call. This is non-interruptive, but cannot be dismissed.
Eric Erfanian10b34a52017-05-04 08:23:17 -0700107 private static final int NOTIFICATION_IN_CALL = 1;
Eric Erfanianccca3152017-02-22 16:32:36 -0800108 // Notification for incoming calls. This is interruptive and will show up as a HUN.
Eric Erfanian10b34a52017-05-04 08:23:17 -0700109 private static final int NOTIFICATION_INCOMING_CALL = 2;
110 // Notification for incoming calls in the case where there is already an active call.
111 // This is non-interruptive, but otherwise behaves the same as NOTIFICATION_INCOMING_CALL
112 private static final int NOTIFICATION_INCOMING_CALL_QUIET = 3;
Eric Erfanianccca3152017-02-22 16:32:36 -0800113
Eric Erfanianccca3152017-02-22 16:32:36 -0800114 private static final long[] VIBRATE_PATTERN = new long[] {0, 1000, 1000};
115
linyuh183cb712017-12-27 17:02:37 -0800116 private final Context context;
117 private final ContactInfoCache contactInfoCache;
118 private final DialerRingtoneManager dialerRingtoneManager;
119 @Nullable private ContactsPreferences contactsPreferences;
120 private int currentNotification = NOTIFICATION_NONE;
wangqibb94ca62018-04-27 14:34:04 -0700121 private int callState = DialerCallState.INVALID;
linyuh183cb712017-12-27 17:02:37 -0800122 private int videoState = VideoProfile.STATE_AUDIO_ONLY;
123 private int savedIcon = 0;
124 private String savedContent = null;
125 private Bitmap savedLargeIcon;
126 private String savedContentTitle;
yuegb26c1ae2017-09-18 16:59:16 -0700127 private CallAudioState savedCallAudioState;
linyuh183cb712017-12-27 17:02:37 -0800128 private Uri ringtone;
129 private StatusBarCallListener statusBarCallListener;
Eric Erfanianccca3152017-02-22 16:32:36 -0800130
Eric Erfaniand8046e52017-04-06 09:41:50 -0700131 public StatusBarNotifier(@NonNull Context context, @NonNull ContactInfoCache contactInfoCache) {
wangqic8cf79e2017-10-17 09:21:00 -0700132 Trace.beginSection("StatusBarNotifier.Constructor");
linyuh183cb712017-12-27 17:02:37 -0800133 this.context = Assert.isNotNull(context);
134 contactsPreferences = ContactsPreferencesFactory.newContactsPreferences(this.context);
135 this.contactInfoCache = contactInfoCache;
136 dialerRingtoneManager =
Eric Erfanianccca3152017-02-22 16:32:36 -0800137 new DialerRingtoneManager(
138 new InCallTonePlayer(new ToneGeneratorFactory(), new PausableExecutorImpl()),
139 CallList.getInstance());
linyuh183cb712017-12-27 17:02:37 -0800140 currentNotification = NOTIFICATION_NONE;
wangqic8cf79e2017-10-17 09:21:00 -0700141 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800142 }
143
144 /**
145 * Should only be called from a irrecoverable state where it is necessary to dismiss all
146 * notifications.
147 */
yueg01a964d2017-10-03 15:25:41 -0700148 static void clearAllCallNotifications() {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700149 LogUtil.e(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700150 "StatusBarNotifier.clearAllCallNotifications",
151 "something terrible happened, clear all InCall notifications");
Eric Erfanianccca3152017-02-22 16:32:36 -0800152
yueg01a964d2017-10-03 15:25:41 -0700153 TelecomAdapter.getInstance().stopForegroundNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -0800154 }
155
156 private static int getWorkStringFromPersonalString(int resId) {
157 if (resId == R.string.notification_ongoing_call) {
158 return R.string.notification_ongoing_work_call;
Eric Erfanianccca3152017-02-22 16:32:36 -0800159 } else if (resId == R.string.notification_incoming_call) {
160 return R.string.notification_incoming_work_call;
161 } else {
162 return resId;
163 }
164 }
165
166 /**
167 * Returns PendingIntent for answering a phone call. This will typically be used from Notification
168 * context.
169 */
170 private static PendingIntent createNotificationPendingIntent(Context context, String action) {
171 final Intent intent = new Intent(action, null, context, NotificationBroadcastReceiver.class);
172 return PendingIntent.getBroadcast(context, 0, intent, 0);
173 }
174
175 /** Creates notifications according to the state we receive from {@link InCallPresenter}. */
176 @Override
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700177 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
Eric Erfanianccca3152017-02-22 16:32:36 -0800178 public void onStateChange(InCallState oldState, InCallState newState, CallList callList) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700179 LogUtil.d("StatusBarNotifier.onStateChange", "%s->%s", oldState, newState);
wangqic8cf79e2017-10-17 09:21:00 -0700180 updateNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -0800181 }
182
Eric Erfaniand8046e52017-04-06 09:41:50 -0700183 @Override
184 public void onEnrichedCallStateChanged() {
185 LogUtil.enterBlock("StatusBarNotifier.onEnrichedCallStateChanged");
wangqic8cf79e2017-10-17 09:21:00 -0700186 updateNotification();
Eric Erfaniand8046e52017-04-06 09:41:50 -0700187 }
188
Eric Erfanianccca3152017-02-22 16:32:36 -0800189 /**
190 * Updates the phone app's status bar notification *and* launches the incoming call UI in response
191 * to a new incoming call.
192 *
193 * <p>If an incoming call is ringing (or call-waiting), the notification will also include a
194 * "fullScreenIntent" that will cause the InCallScreen to be launched, unless the current
195 * foreground activity is marked as "immersive".
196 *
197 * <p>(This is the mechanism that actually brings up the incoming call UI when we receive a "new
198 * ringing connection" event from the telephony layer.)
199 *
200 * <p>Also note that this method is safe to call even if the phone isn't actually ringing (or,
201 * more likely, if an incoming call *was* ringing briefly but then disconnected). In that case,
202 * we'll simply update or cancel the in-call notification based on the current phone state.
203 *
wangqic8cf79e2017-10-17 09:21:00 -0700204 * @see #updateInCallNotification()
Eric Erfanianccca3152017-02-22 16:32:36 -0800205 */
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700206 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
wangqic8cf79e2017-10-17 09:21:00 -0700207 public void updateNotification() {
208 updateInCallNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -0800209 }
210
211 /**
212 * Take down the in-call notification.
213 *
wangqic8cf79e2017-10-17 09:21:00 -0700214 * @see #updateInCallNotification()
Eric Erfanianccca3152017-02-22 16:32:36 -0800215 */
216 private void cancelNotification() {
linyuh183cb712017-12-27 17:02:37 -0800217 if (statusBarCallListener != null) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800218 setStatusBarCallListener(null);
219 }
linyuh183cb712017-12-27 17:02:37 -0800220 if (currentNotification != NOTIFICATION_NONE) {
yueg01a964d2017-10-03 15:25:41 -0700221 TelecomAdapter.getInstance().stopForegroundNotification();
linyuh183cb712017-12-27 17:02:37 -0800222 currentNotification = NOTIFICATION_NONE;
Eric Erfanianccca3152017-02-22 16:32:36 -0800223 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800224 }
225
226 /**
227 * Helper method for updateInCallNotification() and updateNotification(): Update the phone app's
228 * status bar notification based on the current telephony state, or cancels the notification if
229 * the phone is totally idle.
230 */
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700231 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
wangqic8cf79e2017-10-17 09:21:00 -0700232 private void updateInCallNotification() {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700233 LogUtil.d("StatusBarNotifier.updateInCallNotification", "");
Eric Erfanianccca3152017-02-22 16:32:36 -0800234
wangqic8cf79e2017-10-17 09:21:00 -0700235 final DialerCall call = getCallToShow(CallList.getInstance());
Eric Erfanianccca3152017-02-22 16:32:36 -0800236
237 if (call != null) {
wangqic8cf79e2017-10-17 09:21:00 -0700238 showNotification(call);
Eric Erfanianccca3152017-02-22 16:32:36 -0800239 } else {
240 cancelNotification();
241 }
242 }
243
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700244 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
wangqic8cf79e2017-10-17 09:21:00 -0700245 private void showNotification(final DialerCall call) {
wangqicf61ca02017-08-31 15:32:55 -0700246 Trace.beginSection("StatusBarNotifier.showNotification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800247 final boolean isIncoming =
wangqibb94ca62018-04-27 14:34:04 -0700248 (call.getState() == DialerCallState.INCOMING
249 || call.getState() == DialerCallState.CALL_WAITING);
Eric Erfanianccca3152017-02-22 16:32:36 -0800250 setStatusBarCallListener(new StatusBarCallListener(call));
251
252 // we make a call to the contact info cache to query for supplemental data to what the
253 // call provides. This includes the contact name and photo.
254 // This callback will always get called immediately and synchronously with whatever data
255 // it has available, and may make a subsequent call later (same thread) if it had to
256 // call into the contacts provider for more data.
linyuh183cb712017-12-27 17:02:37 -0800257 contactInfoCache.findInfo(call, isIncoming, this);
wangqicf61ca02017-08-31 15:32:55 -0700258 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800259 }
260
261 /** Sets up the main Ui for the notification */
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700262 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
Eric Erfanianccca3152017-02-22 16:32:36 -0800263 private void buildAndSendNotification(
264 CallList callList, DialerCall originalCall, ContactCacheEntry contactInfo) {
wangqicf61ca02017-08-31 15:32:55 -0700265 Trace.beginSection("StatusBarNotifier.buildAndSendNotification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800266 // This can get called to update an existing notification after contact information has come
267 // back. However, it can happen much later. Before we continue, we need to make sure that
268 // the call being passed in is still the one we want to show in the notification.
269 final DialerCall call = getCallToShow(callList);
270 if (call == null || !call.getId().equals(originalCall.getId())) {
wangqicf61ca02017-08-31 15:32:55 -0700271 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800272 return;
273 }
274
wangqicf61ca02017-08-31 15:32:55 -0700275 Trace.beginSection("prepare work");
Eric Erfanianccca3152017-02-22 16:32:36 -0800276 final int callState = call.getState();
yuegb26c1ae2017-09-18 16:59:16 -0700277 final CallAudioState callAudioState = AudioModeProvider.getInstance().getAudioState();
Eric Erfanianccca3152017-02-22 16:32:36 -0800278
wangqic8cf79e2017-10-17 09:21:00 -0700279 Trace.beginSection("read icon and strings");
Eric Erfanianccca3152017-02-22 16:32:36 -0800280 // Check if data has changed; if nothing is different, don't issue another notification.
281 final int iconResId = getIconToDisplay(call);
linyuh183cb712017-12-27 17:02:37 -0800282 Bitmap largeIcon = getLargeIconToDisplay(context, contactInfo, call);
twyend1d1d0c2017-10-05 17:34:43 -0700283 final CharSequence content = getContentString(call, contactInfo.userType);
Eric Erfanianccca3152017-02-22 16:32:36 -0800284 final String contentTitle = getContentTitle(contactInfo, call);
wangqic8cf79e2017-10-17 09:21:00 -0700285 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800286
287 final boolean isVideoUpgradeRequest =
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700288 call.getVideoTech().getSessionModificationState()
Eric Erfanian90508232017-03-24 09:31:16 -0700289 == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST;
Eric Erfanianccca3152017-02-22 16:32:36 -0800290 final int notificationType;
wangqibb94ca62018-04-27 14:34:04 -0700291 if (callState == DialerCallState.INCOMING
292 || callState == DialerCallState.CALL_WAITING
Eric Erfanianccca3152017-02-22 16:32:36 -0800293 || isVideoUpgradeRequest) {
linyuh183cb712017-12-27 17:02:37 -0800294 if (ConfigProviderBindings.get(context)
Eric Erfanian2ca43182017-08-31 06:57:16 -0700295 .getBoolean("quiet_incoming_call_if_ui_showing", true)) {
296 notificationType =
297 InCallPresenter.getInstance().isShowingInCallUi()
298 ? NOTIFICATION_INCOMING_CALL_QUIET
299 : NOTIFICATION_INCOMING_CALL;
300 } else {
301 boolean alreadyActive =
302 callList.getActiveOrBackgroundCall() != null
303 && InCallPresenter.getInstance().isShowingInCallUi();
304 notificationType =
305 alreadyActive ? NOTIFICATION_INCOMING_CALL_QUIET : NOTIFICATION_INCOMING_CALL;
306 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800307 } else {
308 notificationType = NOTIFICATION_IN_CALL;
309 }
wangqicf61ca02017-08-31 15:32:55 -0700310 Trace.endSection(); // prepare work
Eric Erfanianccca3152017-02-22 16:32:36 -0800311
312 if (!checkForChangeAndSaveData(
313 iconResId,
twyend1d1d0c2017-10-05 17:34:43 -0700314 content.toString(),
Eric Erfanianccca3152017-02-22 16:32:36 -0800315 largeIcon,
316 contentTitle,
317 callState,
roldenburgc14610d2017-10-31 12:51:06 -0700318 call.getVideoState(),
Eric Erfanianccca3152017-02-22 16:32:36 -0800319 notificationType,
yuegb26c1ae2017-09-18 16:59:16 -0700320 contactInfo.contactRingtoneUri,
321 callAudioState)) {
wangqicf61ca02017-08-31 15:32:55 -0700322 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800323 return;
324 }
325
326 if (largeIcon != null) {
327 largeIcon = getRoundedIcon(largeIcon);
328 }
329
330 // This builder is used for the notification shown when the device is locked and the user
331 // has set their notification settings to 'hide sensitive content'
332 // {@see Notification.Builder#setPublicVersion}.
linyuh183cb712017-12-27 17:02:37 -0800333 Notification.Builder publicBuilder = new Notification.Builder(context);
Eric Erfanianccca3152017-02-22 16:32:36 -0800334 publicBuilder
335 .setSmallIcon(iconResId)
linyuh183cb712017-12-27 17:02:37 -0800336 .setColor(context.getResources().getColor(R.color.dialer_theme_color, context.getTheme()))
Eric Erfanianccca3152017-02-22 16:32:36 -0800337 // Hide work call state for the lock screen notification
338 .setContentTitle(getContentString(call, ContactsUtils.USER_TYPE_CURRENT));
339 setNotificationWhen(call, callState, publicBuilder);
340
341 // Builder for the notification shown when the device is unlocked or the user has set their
342 // notification settings to 'show all notification content'.
343 final Notification.Builder builder = getNotificationBuilder();
344 builder.setPublicVersion(publicBuilder.build());
345
346 // Set up the main intent to send the user to the in-call screen
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700347 builder.setContentIntent(createLaunchPendingIntent(false /* isFullScreen */));
Eric Erfanianccca3152017-02-22 16:32:36 -0800348
Eric Erfanian10b34a52017-05-04 08:23:17 -0700349 LogUtil.i("StatusBarNotifier.buildAndSendNotification", "notificationType=" + notificationType);
350 switch (notificationType) {
351 case NOTIFICATION_INCOMING_CALL:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700352 if (BuildCompat.isAtLeastO()) {
353 builder.setChannelId(NotificationChannelId.INCOMING_CALL);
354 }
wangqic8cf79e2017-10-17 09:21:00 -0700355 // Set the intent as a full screen intent as well if a call is incoming
Eric Erfanian10b34a52017-05-04 08:23:17 -0700356 configureFullScreenIntent(builder, createLaunchPendingIntent(true /* isFullScreen */));
357 // Set the notification category and bump the priority for incoming calls
358 builder.setCategory(Notification.CATEGORY_CALL);
359 // This will be ignored on O+ and handled by the channel
Eric Erfanian10b34a52017-05-04 08:23:17 -0700360 builder.setPriority(Notification.PRIORITY_MAX);
linyuh183cb712017-12-27 17:02:37 -0800361 if (currentNotification != NOTIFICATION_INCOMING_CALL) {
Eric Erfanian10b34a52017-05-04 08:23:17 -0700362 LogUtil.i(
363 "StatusBarNotifier.buildAndSendNotification",
364 "Canceling old notification so this one can be noisy");
365 // Moving from a non-interuptive notification (or none) to a noisy one. Cancel the old
366 // notification (if there is one) so the fullScreenIntent or HUN will show
yueg01a964d2017-10-03 15:25:41 -0700367 TelecomAdapter.getInstance().stopForegroundNotification();
Eric Erfanian10b34a52017-05-04 08:23:17 -0700368 }
369 break;
370 case NOTIFICATION_INCOMING_CALL_QUIET:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700371 if (BuildCompat.isAtLeastO()) {
372 builder.setChannelId(NotificationChannelId.ONGOING_CALL);
373 }
Eric Erfanian10b34a52017-05-04 08:23:17 -0700374 break;
375 case NOTIFICATION_IN_CALL:
Eric Erfanian2ca43182017-08-31 06:57:16 -0700376 if (BuildCompat.isAtLeastO()) {
377 publicBuilder.setColorized(true);
378 builder.setColorized(true);
379 builder.setChannelId(NotificationChannelId.ONGOING_CALL);
380 }
381 break;
382 default:
Eric Erfanian10b34a52017-05-04 08:23:17 -0700383 break;
Eric Erfanianccca3152017-02-22 16:32:36 -0800384 }
385
386 // Set the content
387 builder.setContentText(content);
388 builder.setSmallIcon(iconResId);
389 builder.setContentTitle(contentTitle);
390 builder.setLargeIcon(largeIcon);
yueg01a964d2017-10-03 15:25:41 -0700391 builder.setColor(InCallPresenter.getInstance().getThemeColorManager().getPrimaryColor());
Eric Erfanianccca3152017-02-22 16:32:36 -0800392
393 if (isVideoUpgradeRequest) {
394 builder.setUsesChronometer(false);
395 addDismissUpgradeRequestAction(builder);
396 addAcceptUpgradeRequestAction(builder);
397 } else {
yuegb26c1ae2017-09-18 16:59:16 -0700398 createIncomingCallNotification(call, callState, callAudioState, builder);
Eric Erfanianccca3152017-02-22 16:32:36 -0800399 }
400
401 addPersonReference(builder, contactInfo, call);
402
wangqicf61ca02017-08-31 15:32:55 -0700403 Trace.beginSection("fire notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800404 // Fire off the notification
405 Notification notification = builder.build();
406
linyuh183cb712017-12-27 17:02:37 -0800407 if (dialerRingtoneManager.shouldPlayRingtone(callState, contactInfo.contactRingtoneUri)) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800408 notification.flags |= Notification.FLAG_INSISTENT;
409 notification.sound = contactInfo.contactRingtoneUri;
410 AudioAttributes.Builder audioAttributes = new AudioAttributes.Builder();
411 audioAttributes.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC);
412 audioAttributes.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE);
413 notification.audioAttributes = audioAttributes.build();
linyuh183cb712017-12-27 17:02:37 -0800414 if (dialerRingtoneManager.shouldVibrate(context.getContentResolver())) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800415 notification.vibrate = VIBRATE_PATTERN;
416 }
417 }
linyuh183cb712017-12-27 17:02:37 -0800418 if (dialerRingtoneManager.shouldPlayCallWaitingTone(callState)) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700419 LogUtil.v("StatusBarNotifier.buildAndSendNotification", "playing call waiting tone");
linyuh183cb712017-12-27 17:02:37 -0800420 dialerRingtoneManager.playCallWaitingTone();
Eric Erfanianccca3152017-02-22 16:32:36 -0800421 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800422
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700423 LogUtil.i(
424 "StatusBarNotifier.buildAndSendNotification",
425 "displaying notification for " + notificationType);
426
yueg01a964d2017-10-03 15:25:41 -0700427 // If a notification exists, this will only update it.
428 TelecomAdapter.getInstance().startForegroundNotification(NOTIFICATION_ID, notification);
429
wangqicf61ca02017-08-31 15:32:55 -0700430 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800431 call.getLatencyReport().onNotificationShown();
linyuh183cb712017-12-27 17:02:37 -0800432 currentNotification = notificationType;
wangqicf61ca02017-08-31 15:32:55 -0700433 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800434 }
435
436 private void createIncomingCallNotification(
yuegb26c1ae2017-09-18 16:59:16 -0700437 DialerCall call, int state, CallAudioState callAudioState, Notification.Builder builder) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800438 setNotificationWhen(call, state, builder);
439
440 // Add hang up option for any active calls (active | onhold), outgoing calls (dialing).
wangqibb94ca62018-04-27 14:34:04 -0700441 if (state == DialerCallState.ACTIVE
442 || state == DialerCallState.ONHOLD
443 || DialerCallState.isDialing(state)) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800444 addHangupAction(builder);
yuegb26c1ae2017-09-18 16:59:16 -0700445 addSpeakerAction(builder, callAudioState);
wangqibb94ca62018-04-27 14:34:04 -0700446 } else if (state == DialerCallState.INCOMING || state == DialerCallState.CALL_WAITING) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800447 addDismissAction(builder);
448 if (call.isVideoCall()) {
449 addVideoCallAction(builder);
450 } else {
451 addAnswerAction(builder);
452 }
453 }
454 }
455
456 /**
457 * Sets the notification's when section as needed. For active calls, this is explicitly set as the
458 * duration of the call. For all other states, the notification will automatically show the time
459 * at which the notification was created.
460 */
461 private void setNotificationWhen(DialerCall call, int state, Notification.Builder builder) {
wangqibb94ca62018-04-27 14:34:04 -0700462 if (state == DialerCallState.ACTIVE) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800463 builder.setUsesChronometer(true);
464 builder.setWhen(call.getConnectTimeMillis());
465 } else {
466 builder.setUsesChronometer(false);
467 }
468 }
469
470 /**
471 * Checks the new notification data and compares it against any notification that we are already
472 * displaying. If the data is exactly the same, we return false so that we do not issue a new
473 * notification for the exact same data.
474 */
475 private boolean checkForChangeAndSaveData(
476 int icon,
477 String content,
478 Bitmap largeIcon,
479 String contentTitle,
480 int state,
roldenburgc14610d2017-10-31 12:51:06 -0700481 int videoState,
Eric Erfanianccca3152017-02-22 16:32:36 -0800482 int notificationType,
yuegb26c1ae2017-09-18 16:59:16 -0700483 Uri ringtone,
484 CallAudioState callAudioState) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800485
486 // The two are different:
487 // if new title is not null, it should be different from saved version OR
488 // if new title is null, the saved version should not be null
489 final boolean contentTitleChanged =
linyuh183cb712017-12-27 17:02:37 -0800490 (contentTitle != null && !contentTitle.equals(savedContentTitle))
491 || (contentTitle == null && savedContentTitle != null);
Eric Erfanianccca3152017-02-22 16:32:36 -0800492
roldenburgc14610d2017-10-31 12:51:06 -0700493 boolean largeIconChanged;
linyuh183cb712017-12-27 17:02:37 -0800494 if (savedLargeIcon == null) {
roldenburgc14610d2017-10-31 12:51:06 -0700495 largeIconChanged = largeIcon != null;
496 } else {
linyuh183cb712017-12-27 17:02:37 -0800497 largeIconChanged = largeIcon == null || !savedLargeIcon.sameAs(largeIcon);
roldenburgc14610d2017-10-31 12:51:06 -0700498 }
Eric Erfanian8369df02017-05-03 10:27:13 -0700499
Eric Erfanianccca3152017-02-22 16:32:36 -0800500 // any change means we are definitely updating
501 boolean retval =
linyuh183cb712017-12-27 17:02:37 -0800502 (savedIcon != icon)
503 || !Objects.equals(savedContent, content)
504 || (callState != state)
505 || (this.videoState != videoState)
Eric Erfanian8369df02017-05-03 10:27:13 -0700506 || largeIconChanged
Eric Erfanianccca3152017-02-22 16:32:36 -0800507 || contentTitleChanged
linyuh183cb712017-12-27 17:02:37 -0800508 || !Objects.equals(this.ringtone, ringtone)
yuegb26c1ae2017-09-18 16:59:16 -0700509 || !Objects.equals(savedCallAudioState, callAudioState);
Eric Erfanianccca3152017-02-22 16:32:36 -0800510
wangqi9982f0d2017-10-11 17:46:07 -0700511 LogUtil.d(
512 "StatusBarNotifier.checkForChangeAndSaveData",
roldenburgc14610d2017-10-31 12:51:06 -0700513 "data changed: icon: %b, content: %b, state: %b, videoState: %b, largeIcon: %b, title: %b,"
514 + "ringtone: %b, audioState: %b, type: %b",
linyuh183cb712017-12-27 17:02:37 -0800515 (savedIcon != icon),
516 !Objects.equals(savedContent, content),
517 (callState != state),
518 (this.videoState != videoState),
wangqi9982f0d2017-10-11 17:46:07 -0700519 largeIconChanged,
520 contentTitleChanged,
linyuh183cb712017-12-27 17:02:37 -0800521 !Objects.equals(this.ringtone, ringtone),
wangqi9982f0d2017-10-11 17:46:07 -0700522 !Objects.equals(savedCallAudioState, callAudioState),
linyuh183cb712017-12-27 17:02:37 -0800523 currentNotification != notificationType);
Eric Erfanianccca3152017-02-22 16:32:36 -0800524 // If we aren't showing a notification right now or the notification type is changing,
525 // definitely do an update.
linyuh183cb712017-12-27 17:02:37 -0800526 if (currentNotification != notificationType) {
527 if (currentNotification == NOTIFICATION_NONE) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700528 LogUtil.d(
529 "StatusBarNotifier.checkForChangeAndSaveData", "showing notification for first time.");
Eric Erfanianccca3152017-02-22 16:32:36 -0800530 }
531 retval = true;
532 }
533
linyuh183cb712017-12-27 17:02:37 -0800534 savedIcon = icon;
535 savedContent = content;
536 callState = state;
537 this.videoState = videoState;
538 savedLargeIcon = largeIcon;
539 savedContentTitle = contentTitle;
540 this.ringtone = ringtone;
yuegb26c1ae2017-09-18 16:59:16 -0700541 savedCallAudioState = callAudioState;
Eric Erfanianccca3152017-02-22 16:32:36 -0800542
543 if (retval) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700544 LogUtil.d(
545 "StatusBarNotifier.checkForChangeAndSaveData", "data changed. Showing notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800546 }
547
548 return retval;
549 }
550
551 /** Returns the main string to use in the notification. */
552 @VisibleForTesting
553 @Nullable
554 String getContentTitle(ContactCacheEntry contactInfo, DialerCall call) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700555 if (call.isConferenceCall()) {
556 return CallerInfoUtils.getConferenceString(
linyuh183cb712017-12-27 17:02:37 -0800557 context, call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE));
Eric Erfanianccca3152017-02-22 16:32:36 -0800558 }
559
560 String preferredName =
561 ContactDisplayUtils.getPreferredDisplayName(
linyuh183cb712017-12-27 17:02:37 -0800562 contactInfo.namePrimary, contactInfo.nameAlternative, contactsPreferences);
Eric Erfanianccca3152017-02-22 16:32:36 -0800563 if (TextUtils.isEmpty(preferredName)) {
564 return TextUtils.isEmpty(contactInfo.number)
565 ? null
566 : BidiFormatter.getInstance()
567 .unicodeWrap(contactInfo.number, TextDirectionHeuristics.LTR);
568 }
569 return preferredName;
570 }
571
572 private void addPersonReference(
573 Notification.Builder builder, ContactCacheEntry contactInfo, DialerCall call) {
574 // Query {@link Contacts#CONTENT_LOOKUP_URI} directly with work lookup key is not allowed.
575 // So, do not pass {@link Contacts#CONTENT_LOOKUP_URI} to NotificationManager to avoid
576 // NotificationManager using it.
577 if (contactInfo.lookupUri != null && contactInfo.userType != ContactsUtils.USER_TYPE_WORK) {
578 builder.addPerson(contactInfo.lookupUri.toString());
579 } else if (!TextUtils.isEmpty(call.getNumber())) {
580 builder.addPerson(Uri.fromParts(PhoneAccount.SCHEME_TEL, call.getNumber(), null).toString());
581 }
582 }
583
584 /** Gets a large icon from the contact info object to display in the notification. */
Eric Erfanian83b20212017-05-31 08:53:10 -0700585 private static Bitmap getLargeIconToDisplay(
586 Context context, ContactCacheEntry contactInfo, DialerCall call) {
wangqic8cf79e2017-10-17 09:21:00 -0700587 Trace.beginSection("StatusBarNotifier.getLargeIconToDisplay");
Eric Erfanian83b20212017-05-31 08:53:10 -0700588 Resources resources = context.getResources();
Eric Erfanianccca3152017-02-22 16:32:36 -0800589 Bitmap largeIcon = null;
Eric Erfanianccca3152017-02-22 16:32:36 -0800590 if (contactInfo.photo != null && (contactInfo.photo instanceof BitmapDrawable)) {
591 largeIcon = ((BitmapDrawable) contactInfo.photo).getBitmap();
592 }
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700593 if (contactInfo.photo == null) {
Eric Erfanian83b20212017-05-31 08:53:10 -0700594 int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
595 int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
Eric Erfanian2ca43182017-08-31 06:57:16 -0700596 @ContactType
597 int contactType =
598 LetterTileDrawable.getContactTypeFromPrimitives(
wangqi9982f0d2017-10-11 17:46:07 -0700599 call.isVoiceMailNumber(),
Eric Erfanian2ca43182017-08-31 06:57:16 -0700600 call.isSpam(),
601 contactInfo.isBusiness,
602 call.getNumberPresentation(),
603 call.isConferenceCall() && !call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE));
Eric Erfanian83b20212017-05-31 08:53:10 -0700604 LetterTileDrawable lettertile = new LetterTileDrawable(resources);
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700605
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700606 lettertile.setCanonicalDialerLetterTileDetails(
607 contactInfo.namePrimary == null ? contactInfo.number : contactInfo.namePrimary,
608 contactInfo.lookupKey,
609 LetterTileDrawable.SHAPE_CIRCLE,
610 contactType);
611 largeIcon = lettertile.getBitmap(width, height);
612 }
613
Eric Erfanianccca3152017-02-22 16:32:36 -0800614 if (call.isSpam()) {
Eric Erfanian83b20212017-05-31 08:53:10 -0700615 Drawable drawable = resources.getDrawable(R.drawable.blocked_contact, context.getTheme());
Eric Erfanianccca3152017-02-22 16:32:36 -0800616 largeIcon = DrawableConverter.drawableToBitmap(drawable);
617 }
wangqic8cf79e2017-10-17 09:21:00 -0700618 Trace.endSection();
Eric Erfanianccca3152017-02-22 16:32:36 -0800619 return largeIcon;
620 }
621
622 private Bitmap getRoundedIcon(Bitmap bitmap) {
623 if (bitmap == null) {
624 return null;
625 }
626 final int height =
linyuh183cb712017-12-27 17:02:37 -0800627 (int) context.getResources().getDimension(android.R.dimen.notification_large_icon_height);
Eric Erfanianccca3152017-02-22 16:32:36 -0800628 final int width =
linyuh183cb712017-12-27 17:02:37 -0800629 (int) context.getResources().getDimension(android.R.dimen.notification_large_icon_width);
Eric Erfanianccca3152017-02-22 16:32:36 -0800630 return BitmapUtil.getRoundedBitmap(bitmap, width, height);
631 }
632
633 /**
634 * Returns the appropriate icon res Id to display based on the call for which we want to display
635 * information.
636 */
Eric Erfanian2827dd12017-10-26 09:37:50 -0700637 @VisibleForTesting
638 public int getIconToDisplay(DialerCall call) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800639 // Even if both lines are in use, we only show a single item in
640 // the expanded Notifications UI. It's labeled "Ongoing call"
641 // (or "On hold" if there's only one call, and it's on hold.)
642 // Also, we don't have room to display caller-id info from two
643 // different calls. So if both lines are in use, display info
644 // from the foreground call. And if there's a ringing call,
645 // display that regardless of the state of the other calls.
wangqibb94ca62018-04-27 14:34:04 -0700646 if (call.getState() == DialerCallState.ONHOLD) {
Eric Erfanian2827dd12017-10-26 09:37:50 -0700647 return R.drawable.quantum_ic_phone_paused_vd_theme_24;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700648 } else if (call.getVideoTech().getSessionModificationState()
calderwoodra1dc2cea2017-09-20 16:30:41 -0700649 == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST
650 || call.isVideoCall()) {
linyuh8dc242d2018-03-28 13:09:47 -0700651 return R.drawable.quantum_ic_videocam_vd_white_24;
Eric Erfanian90508232017-03-24 09:31:16 -0700652 } else if (call.hasProperty(PROPERTY_HIGH_DEF_AUDIO)
linyuh183cb712017-12-27 17:02:37 -0800653 && MotorolaUtils.shouldShowHdIconInNotification(context)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700654 // Normally when a call is ongoing the status bar displays an icon of a phone. This is a
655 // helpful hint for users so they know how to get back to the call. For Sprint HD calls, we
656 // 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 -0700657 return R.drawable.ic_hd_call;
Eric Erfanian2827dd12017-10-26 09:37:50 -0700658 } else if (call.hasProperty(Details.PROPERTY_HAS_CDMA_VOICE_PRIVACY)) {
659 return R.drawable.quantum_ic_phone_locked_vd_theme_24;
Eric Erfanianccca3152017-02-22 16:32:36 -0800660 }
yueg48f93f42018-03-09 16:49:38 -0800661 // If ReturnToCall is enabled, use the static icon. The animated one will show in the bubble.
662 if (ReturnToCallController.isEnabled(context)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700663 return R.drawable.quantum_ic_call_vd_theme_24;
664 } else {
665 return R.drawable.on_going_call;
666 }
Eric Erfanianccca3152017-02-22 16:32:36 -0800667 }
668
669 /** Returns the message to use with the notification. */
twyend1d1d0c2017-10-05 17:34:43 -0700670 private CharSequence getContentString(DialerCall call, @UserType long userType) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800671 boolean isIncomingOrWaiting =
wangqibb94ca62018-04-27 14:34:04 -0700672 call.getState() == DialerCallState.INCOMING
673 || call.getState() == DialerCallState.CALL_WAITING;
Eric Erfanianccca3152017-02-22 16:32:36 -0800674
675 if (isIncomingOrWaiting
676 && call.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED) {
677
678 if (!TextUtils.isEmpty(call.getChildNumber())) {
linyuh183cb712017-12-27 17:02:37 -0800679 return context.getString(R.string.child_number, call.getChildNumber());
Eric Erfanianccca3152017-02-22 16:32:36 -0800680 } else if (!TextUtils.isEmpty(call.getCallSubject()) && call.isCallSubjectSupported()) {
681 return call.getCallSubject();
682 }
683 }
684
685 int resId = R.string.notification_ongoing_call;
linyuh183cb712017-12-27 17:02:37 -0800686 String wifiBrand = context.getString(R.string.notification_call_wifi_brand);
Eric Erfanianccca3152017-02-22 16:32:36 -0800687 if (call.hasProperty(Details.PROPERTY_WIFI)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700688 resId = R.string.notification_ongoing_call_wifi_template;
Eric Erfanianccca3152017-02-22 16:32:36 -0800689 }
690
691 if (isIncomingOrWaiting) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700692 if (call.isSpam()) {
693 resId = R.string.notification_incoming_spam_call;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700694 } else if (shouldShowEnrichedCallNotification(call.getEnrichedCallSession())) {
695 resId = getECIncomingCallText(call.getEnrichedCallSession());
Eric Erfaniand8046e52017-04-06 09:41:50 -0700696 } else if (call.hasProperty(Details.PROPERTY_WIFI)) {
Eric Erfanian2ca43182017-08-31 06:57:16 -0700697 resId = R.string.notification_incoming_call_wifi_template;
wangqi9982f0d2017-10-11 17:46:07 -0700698 } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts(call)) {
twyend1d1d0c2017-10-05 17:34:43 -0700699 return getMultiSimIncomingText(call);
yueg45e45732017-10-09 14:35:06 -0700700 } else if (call.isVideoCall()) {
701 resId = R.string.notification_incoming_video_call;
Eric Erfanianccca3152017-02-22 16:32:36 -0800702 } else {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700703 resId = R.string.notification_incoming_call;
Eric Erfanianccca3152017-02-22 16:32:36 -0800704 }
wangqibb94ca62018-04-27 14:34:04 -0700705 } else if (call.getState() == DialerCallState.ONHOLD) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800706 resId = R.string.notification_on_hold;
calderwoodra1dc2cea2017-09-20 16:30:41 -0700707 } else if (call.isVideoCall()) {
708 resId =
709 call.getVideoTech().isPaused()
710 ? R.string.notification_ongoing_paused_video_call
711 : R.string.notification_ongoing_video_call;
wangqibb94ca62018-04-27 14:34:04 -0700712 } else if (DialerCallState.isDialing(call.getState())) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800713 resId = R.string.notification_dialing;
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700714 } else if (call.getVideoTech().getSessionModificationState()
Eric Erfanian90508232017-03-24 09:31:16 -0700715 == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800716 resId = R.string.notification_requesting_video_call;
717 }
718
719 // Is the call placed through work connection service.
720 boolean isWorkCall = call.hasProperty(PROPERTY_ENTERPRISE_CALL);
721 if (userType == ContactsUtils.USER_TYPE_WORK || isWorkCall) {
722 resId = getWorkStringFromPersonalString(resId);
linyuh183cb712017-12-27 17:02:37 -0800723 wifiBrand = context.getString(R.string.notification_call_wifi_work_brand);
Eric Erfanian2ca43182017-08-31 06:57:16 -0700724 }
725
726 if (resId == R.string.notification_incoming_call_wifi_template
727 || resId == R.string.notification_ongoing_call_wifi_template) {
Eric Erfanian938468d2017-10-24 14:05:52 -0700728 // TODO(a bug): Potentially apply this template logic everywhere.
linyuh183cb712017-12-27 17:02:37 -0800729 return context.getString(resId, wifiBrand);
Eric Erfanianccca3152017-02-22 16:32:36 -0800730 }
731
linyuh183cb712017-12-27 17:02:37 -0800732 return context.getString(resId);
Eric Erfanianccca3152017-02-22 16:32:36 -0800733 }
734
Eric Erfanian2ca43182017-08-31 06:57:16 -0700735 private boolean shouldShowEnrichedCallNotification(Session session) {
736 if (session == null) {
737 return false;
738 }
739 return session.getMultimediaData().hasData() || session.getMultimediaData().isImportant();
740 }
741
Eric Erfaniand8046e52017-04-06 09:41:50 -0700742 private int getECIncomingCallText(Session session) {
743 int resId;
744 MultimediaData data = session.getMultimediaData();
745 boolean hasImage = data.hasImageData();
746 boolean hasSubject = !TextUtils.isEmpty(data.getText());
747 boolean hasMap = data.getLocation() != null;
748 if (data.isImportant()) {
749 if (hasMap) {
750 if (hasImage) {
751 if (hasSubject) {
752 resId = R.string.important_notification_incoming_call_with_photo_message_location;
753 } else {
754 resId = R.string.important_notification_incoming_call_with_photo_location;
755 }
756 } else if (hasSubject) {
757 resId = R.string.important_notification_incoming_call_with_message_location;
758 } else {
759 resId = R.string.important_notification_incoming_call_with_location;
760 }
761 } else if (hasImage) {
762 if (hasSubject) {
763 resId = R.string.important_notification_incoming_call_with_photo_message;
764 } else {
765 resId = R.string.important_notification_incoming_call_with_photo;
766 }
Eric Erfanian2ca43182017-08-31 06:57:16 -0700767 } else if (hasSubject) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700768 resId = R.string.important_notification_incoming_call_with_message;
Eric Erfanian2ca43182017-08-31 06:57:16 -0700769 } else {
770 resId = R.string.important_notification_incoming_call;
Eric Erfaniand8046e52017-04-06 09:41:50 -0700771 }
linyuh183cb712017-12-27 17:02:37 -0800772 if (context.getString(resId).length() > 50) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700773 resId = R.string.important_notification_incoming_call_attachments;
774 }
775 } else {
776 if (hasMap) {
777 if (hasImage) {
778 if (hasSubject) {
779 resId = R.string.notification_incoming_call_with_photo_message_location;
780 } else {
781 resId = R.string.notification_incoming_call_with_photo_location;
782 }
783 } else if (hasSubject) {
784 resId = R.string.notification_incoming_call_with_message_location;
785 } else {
786 resId = R.string.notification_incoming_call_with_location;
787 }
788 } else if (hasImage) {
789 if (hasSubject) {
790 resId = R.string.notification_incoming_call_with_photo_message;
791 } else {
792 resId = R.string.notification_incoming_call_with_photo;
793 }
794 } else {
795 resId = R.string.notification_incoming_call_with_message;
796 }
797 }
linyuh183cb712017-12-27 17:02:37 -0800798 if (context.getString(resId).length() > 50) {
Eric Erfaniand8046e52017-04-06 09:41:50 -0700799 resId = R.string.notification_incoming_call_attachments;
800 }
801 return resId;
802 }
803
twyend1d1d0c2017-10-05 17:34:43 -0700804 private CharSequence getMultiSimIncomingText(DialerCall call) {
805 PhoneAccount phoneAccount =
linyuh183cb712017-12-27 17:02:37 -0800806 context.getSystemService(TelecomManager.class).getPhoneAccount(call.getAccountHandle());
twyene931c122018-03-19 14:47:28 -0700807 if (phoneAccount == null) {
808 return context.getString(R.string.notification_incoming_call);
809 }
twyend1d1d0c2017-10-05 17:34:43 -0700810 SpannableString string =
811 new SpannableString(
linyuh183cb712017-12-27 17:02:37 -0800812 context.getString(
twyend1d1d0c2017-10-05 17:34:43 -0700813 R.string.notification_incoming_call_mutli_sim, phoneAccount.getLabel()));
814 int accountStart = string.toString().lastIndexOf(phoneAccount.getLabel().toString());
815 int accountEnd = accountStart + phoneAccount.getLabel().length();
816
817 string.setSpan(
818 new ForegroundColorSpan(phoneAccount.getHighlightColor()),
819 accountStart,
820 accountEnd,
821 Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
822 return string;
823 }
824
Eric Erfanianccca3152017-02-22 16:32:36 -0800825 /** Gets the most relevant call to display in the notification. */
826 private DialerCall getCallToShow(CallList callList) {
827 if (callList == null) {
828 return null;
829 }
830 DialerCall call = callList.getIncomingCall();
831 if (call == null) {
832 call = callList.getOutgoingCall();
833 }
834 if (call == null) {
835 call = callList.getVideoUpgradeRequestCall();
836 }
837 if (call == null) {
838 call = callList.getActiveOrBackgroundCall();
839 }
840 return call;
841 }
842
843 private Spannable getActionText(@StringRes int stringRes, @ColorRes int colorRes) {
linyuh183cb712017-12-27 17:02:37 -0800844 Spannable spannable = new SpannableString(context.getText(stringRes));
Eric Erfanianccca3152017-02-22 16:32:36 -0800845 if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
846 // This will only work for cases where the Notification.Builder has a fullscreen intent set
847 // Notification.Builder that does not have a full screen intent will take the color of the
848 // app and the following leads to a no-op.
849 spannable.setSpan(
linyuh183cb712017-12-27 17:02:37 -0800850 new ForegroundColorSpan(context.getColor(colorRes)), 0, spannable.length(), 0);
Eric Erfanianccca3152017-02-22 16:32:36 -0800851 }
852 return spannable;
853 }
854
855 private void addAnswerAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700856 LogUtil.d(
857 "StatusBarNotifier.addAnswerAction",
858 "will show \"answer\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800859 PendingIntent answerVoicePendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800860 createNotificationPendingIntent(context, ACTION_ANSWER_VOICE_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800861 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700862 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800863 Icon.createWithResource(context, R.drawable.quantum_ic_call_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700864 getActionText(
865 R.string.notification_action_answer, R.color.notification_action_accept),
866 answerVoicePendingIntent)
867 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800868 }
869
870 private void addDismissAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700871 LogUtil.d(
872 "StatusBarNotifier.addDismissAction",
873 "will show \"decline\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800874 PendingIntent declinePendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800875 createNotificationPendingIntent(context, ACTION_DECLINE_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800876 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700877 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800878 Icon.createWithResource(context, R.drawable.quantum_ic_close_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700879 getActionText(
880 R.string.notification_action_dismiss, R.color.notification_action_dismiss),
881 declinePendingIntent)
882 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800883 }
884
885 private void addHangupAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700886 LogUtil.d(
887 "StatusBarNotifier.addHangupAction",
888 "will show \"hang-up\" action in the ongoing active call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800889 PendingIntent hangupPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800890 createNotificationPendingIntent(context, ACTION_HANG_UP_ONGOING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800891 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700892 new Notification.Action.Builder(
linyuh183cb712017-12-27 17:02:37 -0800893 Icon.createWithResource(context, R.drawable.quantum_ic_call_end_white_24),
894 context.getText(R.string.notification_action_end_call),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700895 hangupPendingIntent)
896 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800897 }
898
yuegb26c1ae2017-09-18 16:59:16 -0700899 private void addSpeakerAction(Notification.Builder builder, CallAudioState callAudioState) {
900 if ((callAudioState.getSupportedRouteMask() & CallAudioState.ROUTE_BLUETOOTH)
901 == CallAudioState.ROUTE_BLUETOOTH) {
902 // Don't add speaker button if bluetooth is connected
903 return;
904 }
905 if (callAudioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
906 addSpeakerOffAction(builder);
907 } else if ((callAudioState.getRoute() & CallAudioState.ROUTE_WIRED_OR_EARPIECE) != 0) {
908 addSpeakerOnAction(builder);
909 }
910 }
911
912 private void addSpeakerOnAction(Notification.Builder builder) {
913 LogUtil.d(
914 "StatusBarNotifier.addSpeakerOnAction",
915 "will show \"Speaker on\" action in the ongoing active call Notification");
916 PendingIntent speakerOnPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800917 createNotificationPendingIntent(context, ACTION_TURN_ON_SPEAKER);
yuegb26c1ae2017-09-18 16:59:16 -0700918 builder.addAction(
919 new Notification.Action.Builder(
wangqi6ca8c722018-03-29 10:19:58 -0700920 Icon.createWithResource(context, R.drawable.quantum_ic_volume_up_vd_theme_24),
linyuh183cb712017-12-27 17:02:37 -0800921 context.getText(R.string.notification_action_speaker_on),
yuegb26c1ae2017-09-18 16:59:16 -0700922 speakerOnPendingIntent)
923 .build());
924 }
925
926 private void addSpeakerOffAction(Notification.Builder builder) {
927 LogUtil.d(
928 "StatusBarNotifier.addSpeakerOffAction",
929 "will show \"Speaker off\" action in the ongoing active call Notification");
930 PendingIntent speakerOffPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800931 createNotificationPendingIntent(context, ACTION_TURN_OFF_SPEAKER);
yuegb26c1ae2017-09-18 16:59:16 -0700932 builder.addAction(
933 new Notification.Action.Builder(
wangqi6ca8c722018-03-29 10:19:58 -0700934 Icon.createWithResource(context, R.drawable.quantum_ic_phone_in_talk_vd_theme_24),
linyuh183cb712017-12-27 17:02:37 -0800935 context.getText(R.string.notification_action_speaker_off),
yuegb26c1ae2017-09-18 16:59:16 -0700936 speakerOffPendingIntent)
937 .build());
938 }
939
Eric Erfanianccca3152017-02-22 16:32:36 -0800940 private void addVideoCallAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700941 LogUtil.i(
942 "StatusBarNotifier.addVideoCallAction",
943 "will show \"video\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800944 PendingIntent answerVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800945 createNotificationPendingIntent(context, ACTION_ANSWER_VIDEO_INCOMING_CALL);
Eric Erfanianccca3152017-02-22 16:32:36 -0800946 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700947 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700948 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700949 getActionText(
950 R.string.notification_action_answer_video,
951 R.color.notification_action_answer_video),
952 answerVideoPendingIntent)
953 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800954 }
955
956 private void addAcceptUpgradeRequestAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700957 LogUtil.i(
958 "StatusBarNotifier.addAcceptUpgradeRequestAction",
959 "will show \"accept upgrade\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800960 PendingIntent acceptVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800961 createNotificationPendingIntent(context, ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST);
Eric Erfanianccca3152017-02-22 16:32:36 -0800962 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700963 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700964 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700965 getActionText(
966 R.string.notification_action_accept, R.color.notification_action_accept),
967 acceptVideoPendingIntent)
968 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800969 }
970
971 private void addDismissUpgradeRequestAction(Notification.Builder builder) {
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700972 LogUtil.i(
973 "StatusBarNotifier.addDismissUpgradeRequestAction",
974 "will show \"dismiss upgrade\" action in the incoming call Notification");
Eric Erfanianccca3152017-02-22 16:32:36 -0800975 PendingIntent declineVideoPendingIntent =
linyuh183cb712017-12-27 17:02:37 -0800976 createNotificationPendingIntent(context, ACTION_DECLINE_VIDEO_UPGRADE_REQUEST);
Eric Erfanianccca3152017-02-22 16:32:36 -0800977 builder.addAction(
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700978 new Notification.Action.Builder(
linyuh8dc242d2018-03-28 13:09:47 -0700979 Icon.createWithResource(context, R.drawable.quantum_ic_videocam_vd_white_24),
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700980 getActionText(
981 R.string.notification_action_dismiss, R.color.notification_action_dismiss),
982 declineVideoPendingIntent)
983 .build());
Eric Erfanianccca3152017-02-22 16:32:36 -0800984 }
985
986 /** Adds fullscreen intent to the builder. */
Eric Erfanian10b34a52017-05-04 08:23:17 -0700987 private void configureFullScreenIntent(Notification.Builder builder, PendingIntent intent) {
Eric Erfanianccca3152017-02-22 16:32:36 -0800988 // Ok, we actually want to launch the incoming call
989 // UI at this point (in addition to simply posting a notification
990 // to the status bar). Setting fullScreenIntent will cause
991 // the InCallScreen to be launched immediately *unless* the
992 // current foreground activity is marked as "immersive".
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700993 LogUtil.d("StatusBarNotifier.configureFullScreenIntent", "setting fullScreenIntent: " + intent);
Eric Erfanianccca3152017-02-22 16:32:36 -0800994 builder.setFullScreenIntent(intent, true);
Eric Erfanianccca3152017-02-22 16:32:36 -0800995 }
996
997 private Notification.Builder getNotificationBuilder() {
linyuh183cb712017-12-27 17:02:37 -0800998 final Notification.Builder builder = new Notification.Builder(context);
Eric Erfanianccca3152017-02-22 16:32:36 -0800999 builder.setOngoing(true);
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001000 builder.setOnlyAlertOnce(true);
Eric Erfanian10b34a52017-05-04 08:23:17 -07001001 // This will be ignored on O+ and handled by the channel
Eric Erfanian2ca43182017-08-31 06:57:16 -07001002 // noinspection deprecation
Eric Erfanian10b34a52017-05-04 08:23:17 -07001003 builder.setPriority(Notification.PRIORITY_HIGH);
Eric Erfanianccca3152017-02-22 16:32:36 -08001004
1005 return builder;
1006 }
1007
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001008 private PendingIntent createLaunchPendingIntent(boolean isFullScreen) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001009 Intent intent =
1010 InCallActivity.getIntent(
linyuh183cb712017-12-27 17:02:37 -08001011 context, false /* showDialpad */, false /* newOutgoingCall */, isFullScreen);
Eric Erfanianccca3152017-02-22 16:32:36 -08001012
linyuhc3968e62017-11-20 17:40:50 -08001013 int requestCode = InCallActivity.PendingIntentRequestCodes.NON_FULL_SCREEN;
Eric Erfanianccca3152017-02-22 16:32:36 -08001014 if (isFullScreen) {
1015 // Use a unique request code so that the pending intent isn't clobbered by the
1016 // non-full screen pending intent.
linyuhc3968e62017-11-20 17:40:50 -08001017 requestCode = InCallActivity.PendingIntentRequestCodes.FULL_SCREEN;
Eric Erfanianccca3152017-02-22 16:32:36 -08001018 }
1019
1020 // PendingIntent that can be used to launch the InCallActivity. The
1021 // system fires off this intent if the user pulls down the windowshade
1022 // and clicks the notification's expanded view. It's also used to
1023 // launch the InCallActivity immediately when when there's an incoming
1024 // call (see the "fullScreenIntent" field below).
linyuh183cb712017-12-27 17:02:37 -08001025 return PendingIntent.getActivity(context, requestCode, intent, 0);
Eric Erfanianccca3152017-02-22 16:32:36 -08001026 }
1027
1028 private void setStatusBarCallListener(StatusBarCallListener listener) {
linyuh183cb712017-12-27 17:02:37 -08001029 if (statusBarCallListener != null) {
1030 statusBarCallListener.cleanup();
Eric Erfanianccca3152017-02-22 16:32:36 -08001031 }
linyuh183cb712017-12-27 17:02:37 -08001032 statusBarCallListener = listener;
Eric Erfanianccca3152017-02-22 16:32:36 -08001033 }
1034
wangqi9982f0d2017-10-11 17:46:07 -07001035 private boolean hasMultiplePhoneAccounts(DialerCall call) {
1036 if (call.getCallCapableAccounts() == null) {
1037 return false;
1038 }
1039 return call.getCallCapableAccounts().size() > 1;
twyend1d1d0c2017-10-05 17:34:43 -07001040 }
1041
yuegb26c1ae2017-09-18 16:59:16 -07001042 @Override
wangqic8cf79e2017-10-17 09:21:00 -07001043 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
1044 public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
1045 DialerCall call = CallList.getInstance().getCallById(callId);
1046 if (call != null) {
1047 call.getLogState().contactLookupResult = entry.contactLookupResult;
1048 buildAndSendNotification(CallList.getInstance(), call, entry);
1049 }
1050 }
1051
1052 @Override
1053 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
1054 public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
1055 DialerCall call = CallList.getInstance().getCallById(callId);
1056 if (call != null) {
1057 buildAndSendNotification(CallList.getInstance(), call, entry);
1058 }
yuegb26c1ae2017-09-18 16:59:16 -07001059 }
1060
Eric Erfanianccca3152017-02-22 16:32:36 -08001061 private class StatusBarCallListener implements DialerCallListener {
1062
linyuh183cb712017-12-27 17:02:37 -08001063 private DialerCall dialerCall;
Eric Erfanianccca3152017-02-22 16:32:36 -08001064
1065 StatusBarCallListener(DialerCall dialerCall) {
linyuh183cb712017-12-27 17:02:37 -08001066 this.dialerCall = dialerCall;
1067 this.dialerCall.addListener(this);
Eric Erfanianccca3152017-02-22 16:32:36 -08001068 }
1069
1070 void cleanup() {
linyuh183cb712017-12-27 17:02:37 -08001071 dialerCall.removeListener(this);
Eric Erfanianccca3152017-02-22 16:32:36 -08001072 }
1073
1074 @Override
1075 public void onDialerCallDisconnect() {}
1076
1077 @Override
1078 public void onDialerCallUpdate() {
1079 if (CallList.getInstance().getIncomingCall() == null) {
linyuh183cb712017-12-27 17:02:37 -08001080 dialerRingtoneManager.stopCallWaitingTone();
Eric Erfanianccca3152017-02-22 16:32:36 -08001081 }
1082 }
1083
1084 @Override
1085 public void onDialerCallChildNumberChange() {}
1086
1087 @Override
1088 public void onDialerCallLastForwardedNumberChange() {}
1089
1090 @Override
1091 public void onDialerCallUpgradeToVideo() {}
1092
1093 @Override
1094 public void onWiFiToLteHandover() {}
1095
1096 @Override
1097 public void onHandoverToWifiFailure() {}
1098
Eric Erfanianc857f902017-05-15 14:05:33 -07001099 @Override
1100 public void onInternationalCallOnWifi() {}
1101
Eric Erfanian2ca43182017-08-31 06:57:16 -07001102 @Override
1103 public void onEnrichedCallSessionUpdate() {}
1104
Eric Erfanianccca3152017-02-22 16:32:36 -08001105 /**
1106 * Responds to changes in the session modification state for the call by dismissing the status
1107 * bar notification as required.
1108 */
1109 @Override
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001110 public void onDialerCallSessionModificationStateChange() {
linyuh183cb712017-12-27 17:02:37 -08001111 if (dialerCall.getVideoTech().getSessionModificationState()
Eric Erfanian90508232017-03-24 09:31:16 -07001112 == SessionModificationState.NO_REQUEST) {
Eric Erfanianccca3152017-02-22 16:32:36 -08001113 cleanup();
wangqic8cf79e2017-10-17 09:21:00 -07001114 updateNotification();
Eric Erfanianccca3152017-02-22 16:32:36 -08001115 }
1116 }
1117 }
1118}