Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.incallui; |
| 18 | |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 19 | import static android.telecom.Call.Details.PROPERTY_HIGH_DEF_AUDIO; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 20 | import static com.android.contacts.common.compat.CallCompat.Details.PROPERTY_ENTERPRISE_CALL; |
| 21 | import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST; |
| 22 | import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_VIDEO_INCOMING_CALL; |
| 23 | import static com.android.incallui.NotificationBroadcastReceiver.ACTION_ANSWER_VOICE_INCOMING_CALL; |
| 24 | import static com.android.incallui.NotificationBroadcastReceiver.ACTION_DECLINE_INCOMING_CALL; |
| 25 | import static com.android.incallui.NotificationBroadcastReceiver.ACTION_DECLINE_VIDEO_UPGRADE_REQUEST; |
| 26 | import static com.android.incallui.NotificationBroadcastReceiver.ACTION_HANG_UP_ONGOING_CALL; |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 27 | import static com.android.incallui.NotificationBroadcastReceiver.ACTION_TURN_OFF_SPEAKER; |
| 28 | import static com.android.incallui.NotificationBroadcastReceiver.ACTION_TURN_ON_SPEAKER; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 29 | |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 30 | import android.Manifest; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 31 | import android.app.Notification; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 32 | import android.app.PendingIntent; |
| 33 | import android.content.Context; |
| 34 | import android.content.Intent; |
Eric Erfanian | 83b2021 | 2017-05-31 08:53:10 -0700 | [diff] [blame] | 35 | import android.content.res.Resources; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 36 | import android.graphics.Bitmap; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 37 | import android.graphics.drawable.BitmapDrawable; |
| 38 | import android.graphics.drawable.Drawable; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 39 | import android.graphics.drawable.Icon; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 40 | import android.media.AudioAttributes; |
| 41 | import android.net.Uri; |
| 42 | import android.os.Build.VERSION; |
| 43 | import android.os.Build.VERSION_CODES; |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 44 | import android.os.Trace; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 45 | import android.support.annotation.ColorRes; |
| 46 | import android.support.annotation.NonNull; |
| 47 | import android.support.annotation.Nullable; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 48 | import android.support.annotation.RequiresPermission; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 49 | import android.support.annotation.StringRes; |
| 50 | import android.support.annotation.VisibleForTesting; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 51 | import android.support.v4.os.BuildCompat; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 52 | import android.telecom.Call.Details; |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 53 | import android.telecom.CallAudioState; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 54 | import android.telecom.PhoneAccount; |
| 55 | import android.telecom.TelecomManager; |
roldenburg | c14610d | 2017-10-31 12:51:06 -0700 | [diff] [blame] | 56 | import android.telecom.VideoProfile; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 57 | import android.text.BidiFormatter; |
| 58 | import android.text.Spannable; |
| 59 | import android.text.SpannableString; |
| 60 | import android.text.TextDirectionHeuristics; |
| 61 | import android.text.TextUtils; |
| 62 | import android.text.style.ForegroundColorSpan; |
| 63 | import com.android.contacts.common.ContactsUtils; |
| 64 | import com.android.contacts.common.ContactsUtils.UserType; |
| 65 | import com.android.contacts.common.preference.ContactsPreferences; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 66 | import com.android.contacts.common.util.ContactDisplayUtils; |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 67 | import com.android.dialer.common.Assert; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 68 | import com.android.dialer.common.LogUtil; |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 69 | import com.android.dialer.configprovider.ConfigProviderBindings; |
| 70 | import com.android.dialer.contactphoto.BitmapUtil; |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 71 | import com.android.dialer.enrichedcall.EnrichedCallManager; |
| 72 | import com.android.dialer.enrichedcall.Session; |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 73 | import com.android.dialer.lettertile.LetterTileDrawable; |
| 74 | import com.android.dialer.lettertile.LetterTileDrawable.ContactType; |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 75 | import com.android.dialer.multimedia.MultimediaData; |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 76 | import com.android.dialer.notification.NotificationChannelId; |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 77 | import com.android.dialer.oem.MotorolaUtils; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 78 | import com.android.dialer.util.DrawableConverter; |
| 79 | import com.android.incallui.ContactInfoCache.ContactCacheEntry; |
| 80 | import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; |
| 81 | import com.android.incallui.InCallPresenter.InCallState; |
| 82 | import com.android.incallui.async.PausableExecutorImpl; |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 83 | import com.android.incallui.audiomode.AudioModeProvider; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 84 | import com.android.incallui.call.CallList; |
| 85 | import com.android.incallui.call.DialerCall; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 86 | import com.android.incallui.call.DialerCallListener; |
yueg | 01a964d | 2017-10-03 15:25:41 -0700 | [diff] [blame] | 87 | import com.android.incallui.call.TelecomAdapter; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 88 | import com.android.incallui.ringtone.DialerRingtoneManager; |
| 89 | import com.android.incallui.ringtone.InCallTonePlayer; |
| 90 | import com.android.incallui.ringtone.ToneGeneratorFactory; |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 91 | import com.android.incallui.videotech.utils.SessionModificationState; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 92 | import java.util.Objects; |
| 93 | |
| 94 | /** This class adds Notifications to the status bar for the in-call experience. */ |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 95 | public class StatusBarNotifier |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 96 | implements InCallPresenter.InCallStateListener, |
| 97 | EnrichedCallManager.StateChangedListener, |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 98 | ContactInfoCacheCallback { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 99 | |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 100 | private static final int NOTIFICATION_ID = 1; |
| 101 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 102 | // Notification types |
| 103 | // Indicates that no notification is currently showing. |
| 104 | private static final int NOTIFICATION_NONE = 0; |
| 105 | // Notification for an active call. This is non-interruptive, but cannot be dismissed. |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 106 | private static final int NOTIFICATION_IN_CALL = 1; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 107 | // Notification for incoming calls. This is interruptive and will show up as a HUN. |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 108 | private static final int NOTIFICATION_INCOMING_CALL = 2; |
| 109 | // Notification for incoming calls in the case where there is already an active call. |
| 110 | // This is non-interruptive, but otherwise behaves the same as NOTIFICATION_INCOMING_CALL |
| 111 | private static final int NOTIFICATION_INCOMING_CALL_QUIET = 3; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 112 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 113 | private static final long[] VIBRATE_PATTERN = new long[] {0, 1000, 1000}; |
| 114 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 115 | private final Context context; |
| 116 | private final ContactInfoCache contactInfoCache; |
| 117 | private final DialerRingtoneManager dialerRingtoneManager; |
| 118 | @Nullable private ContactsPreferences contactsPreferences; |
| 119 | private int currentNotification = NOTIFICATION_NONE; |
| 120 | private int callState = DialerCall.State.INVALID; |
| 121 | private int videoState = VideoProfile.STATE_AUDIO_ONLY; |
| 122 | private int savedIcon = 0; |
| 123 | private String savedContent = null; |
| 124 | private Bitmap savedLargeIcon; |
| 125 | private String savedContentTitle; |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 126 | private CallAudioState savedCallAudioState; |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 127 | private Uri ringtone; |
| 128 | private StatusBarCallListener statusBarCallListener; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 129 | |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 130 | public StatusBarNotifier(@NonNull Context context, @NonNull ContactInfoCache contactInfoCache) { |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 131 | Trace.beginSection("StatusBarNotifier.Constructor"); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 132 | this.context = Assert.isNotNull(context); |
| 133 | contactsPreferences = ContactsPreferencesFactory.newContactsPreferences(this.context); |
| 134 | this.contactInfoCache = contactInfoCache; |
| 135 | dialerRingtoneManager = |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 136 | new DialerRingtoneManager( |
| 137 | new InCallTonePlayer(new ToneGeneratorFactory(), new PausableExecutorImpl()), |
| 138 | CallList.getInstance()); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 139 | currentNotification = NOTIFICATION_NONE; |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 140 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Should only be called from a irrecoverable state where it is necessary to dismiss all |
| 145 | * notifications. |
| 146 | */ |
yueg | 01a964d | 2017-10-03 15:25:41 -0700 | [diff] [blame] | 147 | static void clearAllCallNotifications() { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 148 | LogUtil.e( |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 149 | "StatusBarNotifier.clearAllCallNotifications", |
| 150 | "something terrible happened, clear all InCall notifications"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 151 | |
yueg | 01a964d | 2017-10-03 15:25:41 -0700 | [diff] [blame] | 152 | TelecomAdapter.getInstance().stopForegroundNotification(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | private static int getWorkStringFromPersonalString(int resId) { |
| 156 | if (resId == R.string.notification_ongoing_call) { |
| 157 | return R.string.notification_ongoing_work_call; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 158 | } else if (resId == R.string.notification_incoming_call) { |
| 159 | return R.string.notification_incoming_work_call; |
| 160 | } else { |
| 161 | return resId; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Returns PendingIntent for answering a phone call. This will typically be used from Notification |
| 167 | * context. |
| 168 | */ |
| 169 | private static PendingIntent createNotificationPendingIntent(Context context, String action) { |
| 170 | final Intent intent = new Intent(action, null, context, NotificationBroadcastReceiver.class); |
| 171 | return PendingIntent.getBroadcast(context, 0, intent, 0); |
| 172 | } |
| 173 | |
| 174 | /** Creates notifications according to the state we receive from {@link InCallPresenter}. */ |
| 175 | @Override |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 176 | @RequiresPermission(Manifest.permission.READ_PHONE_STATE) |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 177 | public void onStateChange(InCallState oldState, InCallState newState, CallList callList) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 178 | LogUtil.d("StatusBarNotifier.onStateChange", "%s->%s", oldState, newState); |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 179 | updateNotification(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 180 | } |
| 181 | |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 182 | @Override |
| 183 | public void onEnrichedCallStateChanged() { |
| 184 | LogUtil.enterBlock("StatusBarNotifier.onEnrichedCallStateChanged"); |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 185 | updateNotification(); |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 188 | /** |
| 189 | * Updates the phone app's status bar notification *and* launches the incoming call UI in response |
| 190 | * to a new incoming call. |
| 191 | * |
| 192 | * <p>If an incoming call is ringing (or call-waiting), the notification will also include a |
| 193 | * "fullScreenIntent" that will cause the InCallScreen to be launched, unless the current |
| 194 | * foreground activity is marked as "immersive". |
| 195 | * |
| 196 | * <p>(This is the mechanism that actually brings up the incoming call UI when we receive a "new |
| 197 | * ringing connection" event from the telephony layer.) |
| 198 | * |
| 199 | * <p>Also note that this method is safe to call even if the phone isn't actually ringing (or, |
| 200 | * more likely, if an incoming call *was* ringing briefly but then disconnected). In that case, |
| 201 | * we'll simply update or cancel the in-call notification based on the current phone state. |
| 202 | * |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 203 | * @see #updateInCallNotification() |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 204 | */ |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 205 | @RequiresPermission(Manifest.permission.READ_PHONE_STATE) |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 206 | public void updateNotification() { |
| 207 | updateInCallNotification(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Take down the in-call notification. |
| 212 | * |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 213 | * @see #updateInCallNotification() |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 214 | */ |
| 215 | private void cancelNotification() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 216 | if (statusBarCallListener != null) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 217 | setStatusBarCallListener(null); |
| 218 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 219 | if (currentNotification != NOTIFICATION_NONE) { |
yueg | 01a964d | 2017-10-03 15:25:41 -0700 | [diff] [blame] | 220 | TelecomAdapter.getInstance().stopForegroundNotification(); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 221 | currentNotification = NOTIFICATION_NONE; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 222 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Helper method for updateInCallNotification() and updateNotification(): Update the phone app's |
| 227 | * status bar notification based on the current telephony state, or cancels the notification if |
| 228 | * the phone is totally idle. |
| 229 | */ |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 230 | @RequiresPermission(Manifest.permission.READ_PHONE_STATE) |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 231 | private void updateInCallNotification() { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 232 | LogUtil.d("StatusBarNotifier.updateInCallNotification", ""); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 233 | |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 234 | final DialerCall call = getCallToShow(CallList.getInstance()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 235 | |
| 236 | if (call != null) { |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 237 | showNotification(call); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 238 | } else { |
| 239 | cancelNotification(); |
| 240 | } |
| 241 | } |
| 242 | |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 243 | @RequiresPermission(Manifest.permission.READ_PHONE_STATE) |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 244 | private void showNotification(final DialerCall call) { |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 245 | Trace.beginSection("StatusBarNotifier.showNotification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 246 | final boolean isIncoming = |
| 247 | (call.getState() == DialerCall.State.INCOMING |
| 248 | || call.getState() == DialerCall.State.CALL_WAITING); |
| 249 | setStatusBarCallListener(new StatusBarCallListener(call)); |
| 250 | |
| 251 | // we make a call to the contact info cache to query for supplemental data to what the |
| 252 | // call provides. This includes the contact name and photo. |
| 253 | // This callback will always get called immediately and synchronously with whatever data |
| 254 | // it has available, and may make a subsequent call later (same thread) if it had to |
| 255 | // call into the contacts provider for more data. |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 256 | contactInfoCache.findInfo(call, isIncoming, this); |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 257 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | /** Sets up the main Ui for the notification */ |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 261 | @RequiresPermission(Manifest.permission.READ_PHONE_STATE) |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 262 | private void buildAndSendNotification( |
| 263 | CallList callList, DialerCall originalCall, ContactCacheEntry contactInfo) { |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 264 | Trace.beginSection("StatusBarNotifier.buildAndSendNotification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 265 | // This can get called to update an existing notification after contact information has come |
| 266 | // back. However, it can happen much later. Before we continue, we need to make sure that |
| 267 | // the call being passed in is still the one we want to show in the notification. |
| 268 | final DialerCall call = getCallToShow(callList); |
| 269 | if (call == null || !call.getId().equals(originalCall.getId())) { |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 270 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 271 | return; |
| 272 | } |
| 273 | |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 274 | Trace.beginSection("prepare work"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 275 | final int callState = call.getState(); |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 276 | final CallAudioState callAudioState = AudioModeProvider.getInstance().getAudioState(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 277 | |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 278 | Trace.beginSection("read icon and strings"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 279 | // Check if data has changed; if nothing is different, don't issue another notification. |
| 280 | final int iconResId = getIconToDisplay(call); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 281 | Bitmap largeIcon = getLargeIconToDisplay(context, contactInfo, call); |
twyen | d1d1d0c | 2017-10-05 17:34:43 -0700 | [diff] [blame] | 282 | final CharSequence content = getContentString(call, contactInfo.userType); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 283 | final String contentTitle = getContentTitle(contactInfo, call); |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 284 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 285 | |
| 286 | final boolean isVideoUpgradeRequest = |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 287 | call.getVideoTech().getSessionModificationState() |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 288 | == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 289 | final int notificationType; |
| 290 | if (callState == DialerCall.State.INCOMING |
| 291 | || callState == DialerCall.State.CALL_WAITING |
| 292 | || isVideoUpgradeRequest) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 293 | if (ConfigProviderBindings.get(context) |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 294 | .getBoolean("quiet_incoming_call_if_ui_showing", true)) { |
| 295 | notificationType = |
| 296 | InCallPresenter.getInstance().isShowingInCallUi() |
| 297 | ? NOTIFICATION_INCOMING_CALL_QUIET |
| 298 | : NOTIFICATION_INCOMING_CALL; |
| 299 | } else { |
| 300 | boolean alreadyActive = |
| 301 | callList.getActiveOrBackgroundCall() != null |
| 302 | && InCallPresenter.getInstance().isShowingInCallUi(); |
| 303 | notificationType = |
| 304 | alreadyActive ? NOTIFICATION_INCOMING_CALL_QUIET : NOTIFICATION_INCOMING_CALL; |
| 305 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 306 | } else { |
| 307 | notificationType = NOTIFICATION_IN_CALL; |
| 308 | } |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 309 | Trace.endSection(); // prepare work |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 310 | |
| 311 | if (!checkForChangeAndSaveData( |
| 312 | iconResId, |
twyen | d1d1d0c | 2017-10-05 17:34:43 -0700 | [diff] [blame] | 313 | content.toString(), |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 314 | largeIcon, |
| 315 | contentTitle, |
| 316 | callState, |
roldenburg | c14610d | 2017-10-31 12:51:06 -0700 | [diff] [blame] | 317 | call.getVideoState(), |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 318 | notificationType, |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 319 | contactInfo.contactRingtoneUri, |
| 320 | callAudioState)) { |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 321 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 322 | return; |
| 323 | } |
| 324 | |
| 325 | if (largeIcon != null) { |
| 326 | largeIcon = getRoundedIcon(largeIcon); |
| 327 | } |
| 328 | |
| 329 | // This builder is used for the notification shown when the device is locked and the user |
| 330 | // has set their notification settings to 'hide sensitive content' |
| 331 | // {@see Notification.Builder#setPublicVersion}. |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 332 | Notification.Builder publicBuilder = new Notification.Builder(context); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 333 | publicBuilder |
| 334 | .setSmallIcon(iconResId) |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 335 | .setColor(context.getResources().getColor(R.color.dialer_theme_color, context.getTheme())) |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 336 | // Hide work call state for the lock screen notification |
| 337 | .setContentTitle(getContentString(call, ContactsUtils.USER_TYPE_CURRENT)); |
| 338 | setNotificationWhen(call, callState, publicBuilder); |
| 339 | |
| 340 | // Builder for the notification shown when the device is unlocked or the user has set their |
| 341 | // notification settings to 'show all notification content'. |
| 342 | final Notification.Builder builder = getNotificationBuilder(); |
| 343 | builder.setPublicVersion(publicBuilder.build()); |
| 344 | |
| 345 | // Set up the main intent to send the user to the in-call screen |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 346 | builder.setContentIntent(createLaunchPendingIntent(false /* isFullScreen */)); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 347 | |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 348 | LogUtil.i("StatusBarNotifier.buildAndSendNotification", "notificationType=" + notificationType); |
| 349 | switch (notificationType) { |
| 350 | case NOTIFICATION_INCOMING_CALL: |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 351 | if (BuildCompat.isAtLeastO()) { |
| 352 | builder.setChannelId(NotificationChannelId.INCOMING_CALL); |
| 353 | } |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 354 | // Set the intent as a full screen intent as well if a call is incoming |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 355 | configureFullScreenIntent(builder, createLaunchPendingIntent(true /* isFullScreen */)); |
| 356 | // Set the notification category and bump the priority for incoming calls |
| 357 | builder.setCategory(Notification.CATEGORY_CALL); |
| 358 | // This will be ignored on O+ and handled by the channel |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 359 | builder.setPriority(Notification.PRIORITY_MAX); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 360 | if (currentNotification != NOTIFICATION_INCOMING_CALL) { |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 361 | LogUtil.i( |
| 362 | "StatusBarNotifier.buildAndSendNotification", |
| 363 | "Canceling old notification so this one can be noisy"); |
| 364 | // Moving from a non-interuptive notification (or none) to a noisy one. Cancel the old |
| 365 | // notification (if there is one) so the fullScreenIntent or HUN will show |
yueg | 01a964d | 2017-10-03 15:25:41 -0700 | [diff] [blame] | 366 | TelecomAdapter.getInstance().stopForegroundNotification(); |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 367 | } |
| 368 | break; |
| 369 | case NOTIFICATION_INCOMING_CALL_QUIET: |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 370 | if (BuildCompat.isAtLeastO()) { |
| 371 | builder.setChannelId(NotificationChannelId.ONGOING_CALL); |
| 372 | } |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 373 | break; |
| 374 | case NOTIFICATION_IN_CALL: |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 375 | if (BuildCompat.isAtLeastO()) { |
| 376 | publicBuilder.setColorized(true); |
| 377 | builder.setColorized(true); |
| 378 | builder.setChannelId(NotificationChannelId.ONGOING_CALL); |
| 379 | } |
| 380 | break; |
| 381 | default: |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 382 | break; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | // Set the content |
| 386 | builder.setContentText(content); |
| 387 | builder.setSmallIcon(iconResId); |
| 388 | builder.setContentTitle(contentTitle); |
| 389 | builder.setLargeIcon(largeIcon); |
yueg | 01a964d | 2017-10-03 15:25:41 -0700 | [diff] [blame] | 390 | builder.setColor(InCallPresenter.getInstance().getThemeColorManager().getPrimaryColor()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 391 | |
| 392 | if (isVideoUpgradeRequest) { |
| 393 | builder.setUsesChronometer(false); |
| 394 | addDismissUpgradeRequestAction(builder); |
| 395 | addAcceptUpgradeRequestAction(builder); |
| 396 | } else { |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 397 | createIncomingCallNotification(call, callState, callAudioState, builder); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | addPersonReference(builder, contactInfo, call); |
| 401 | |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 402 | Trace.beginSection("fire notification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 403 | // Fire off the notification |
| 404 | Notification notification = builder.build(); |
| 405 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 406 | if (dialerRingtoneManager.shouldPlayRingtone(callState, contactInfo.contactRingtoneUri)) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 407 | notification.flags |= Notification.FLAG_INSISTENT; |
| 408 | notification.sound = contactInfo.contactRingtoneUri; |
| 409 | AudioAttributes.Builder audioAttributes = new AudioAttributes.Builder(); |
| 410 | audioAttributes.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC); |
| 411 | audioAttributes.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE); |
| 412 | notification.audioAttributes = audioAttributes.build(); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 413 | if (dialerRingtoneManager.shouldVibrate(context.getContentResolver())) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 414 | notification.vibrate = VIBRATE_PATTERN; |
| 415 | } |
| 416 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 417 | if (dialerRingtoneManager.shouldPlayCallWaitingTone(callState)) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 418 | LogUtil.v("StatusBarNotifier.buildAndSendNotification", "playing call waiting tone"); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 419 | dialerRingtoneManager.playCallWaitingTone(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 420 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 421 | |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 422 | LogUtil.i( |
| 423 | "StatusBarNotifier.buildAndSendNotification", |
| 424 | "displaying notification for " + notificationType); |
| 425 | |
yueg | 01a964d | 2017-10-03 15:25:41 -0700 | [diff] [blame] | 426 | // If a notification exists, this will only update it. |
| 427 | TelecomAdapter.getInstance().startForegroundNotification(NOTIFICATION_ID, notification); |
| 428 | |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 429 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 430 | call.getLatencyReport().onNotificationShown(); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 431 | currentNotification = notificationType; |
wangqi | cf61ca0 | 2017-08-31 15:32:55 -0700 | [diff] [blame] | 432 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | private void createIncomingCallNotification( |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 436 | DialerCall call, int state, CallAudioState callAudioState, Notification.Builder builder) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 437 | setNotificationWhen(call, state, builder); |
| 438 | |
| 439 | // Add hang up option for any active calls (active | onhold), outgoing calls (dialing). |
| 440 | if (state == DialerCall.State.ACTIVE |
| 441 | || state == DialerCall.State.ONHOLD |
| 442 | || DialerCall.State.isDialing(state)) { |
| 443 | addHangupAction(builder); |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 444 | addSpeakerAction(builder, callAudioState); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 445 | } else if (state == DialerCall.State.INCOMING || state == DialerCall.State.CALL_WAITING) { |
| 446 | addDismissAction(builder); |
| 447 | if (call.isVideoCall()) { |
| 448 | addVideoCallAction(builder); |
| 449 | } else { |
| 450 | addAnswerAction(builder); |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * Sets the notification's when section as needed. For active calls, this is explicitly set as the |
| 457 | * duration of the call. For all other states, the notification will automatically show the time |
| 458 | * at which the notification was created. |
| 459 | */ |
| 460 | private void setNotificationWhen(DialerCall call, int state, Notification.Builder builder) { |
| 461 | if (state == DialerCall.State.ACTIVE) { |
| 462 | builder.setUsesChronometer(true); |
| 463 | builder.setWhen(call.getConnectTimeMillis()); |
| 464 | } else { |
| 465 | builder.setUsesChronometer(false); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | /** |
| 470 | * Checks the new notification data and compares it against any notification that we are already |
| 471 | * displaying. If the data is exactly the same, we return false so that we do not issue a new |
| 472 | * notification for the exact same data. |
| 473 | */ |
| 474 | private boolean checkForChangeAndSaveData( |
| 475 | int icon, |
| 476 | String content, |
| 477 | Bitmap largeIcon, |
| 478 | String contentTitle, |
| 479 | int state, |
roldenburg | c14610d | 2017-10-31 12:51:06 -0700 | [diff] [blame] | 480 | int videoState, |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 481 | int notificationType, |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 482 | Uri ringtone, |
| 483 | CallAudioState callAudioState) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 484 | |
| 485 | // The two are different: |
| 486 | // if new title is not null, it should be different from saved version OR |
| 487 | // if new title is null, the saved version should not be null |
| 488 | final boolean contentTitleChanged = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 489 | (contentTitle != null && !contentTitle.equals(savedContentTitle)) |
| 490 | || (contentTitle == null && savedContentTitle != null); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 491 | |
roldenburg | c14610d | 2017-10-31 12:51:06 -0700 | [diff] [blame] | 492 | boolean largeIconChanged; |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 493 | if (savedLargeIcon == null) { |
roldenburg | c14610d | 2017-10-31 12:51:06 -0700 | [diff] [blame] | 494 | largeIconChanged = largeIcon != null; |
| 495 | } else { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 496 | largeIconChanged = largeIcon == null || !savedLargeIcon.sameAs(largeIcon); |
roldenburg | c14610d | 2017-10-31 12:51:06 -0700 | [diff] [blame] | 497 | } |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 498 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 499 | // any change means we are definitely updating |
| 500 | boolean retval = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 501 | (savedIcon != icon) |
| 502 | || !Objects.equals(savedContent, content) |
| 503 | || (callState != state) |
| 504 | || (this.videoState != videoState) |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 505 | || largeIconChanged |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 506 | || contentTitleChanged |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 507 | || !Objects.equals(this.ringtone, ringtone) |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 508 | || !Objects.equals(savedCallAudioState, callAudioState); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 509 | |
wangqi | 9982f0d | 2017-10-11 17:46:07 -0700 | [diff] [blame] | 510 | LogUtil.d( |
| 511 | "StatusBarNotifier.checkForChangeAndSaveData", |
roldenburg | c14610d | 2017-10-31 12:51:06 -0700 | [diff] [blame] | 512 | "data changed: icon: %b, content: %b, state: %b, videoState: %b, largeIcon: %b, title: %b," |
| 513 | + "ringtone: %b, audioState: %b, type: %b", |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 514 | (savedIcon != icon), |
| 515 | !Objects.equals(savedContent, content), |
| 516 | (callState != state), |
| 517 | (this.videoState != videoState), |
wangqi | 9982f0d | 2017-10-11 17:46:07 -0700 | [diff] [blame] | 518 | largeIconChanged, |
| 519 | contentTitleChanged, |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 520 | !Objects.equals(this.ringtone, ringtone), |
wangqi | 9982f0d | 2017-10-11 17:46:07 -0700 | [diff] [blame] | 521 | !Objects.equals(savedCallAudioState, callAudioState), |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 522 | currentNotification != notificationType); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 523 | // If we aren't showing a notification right now or the notification type is changing, |
| 524 | // definitely do an update. |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 525 | if (currentNotification != notificationType) { |
| 526 | if (currentNotification == NOTIFICATION_NONE) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 527 | LogUtil.d( |
| 528 | "StatusBarNotifier.checkForChangeAndSaveData", "showing notification for first time."); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 529 | } |
| 530 | retval = true; |
| 531 | } |
| 532 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 533 | savedIcon = icon; |
| 534 | savedContent = content; |
| 535 | callState = state; |
| 536 | this.videoState = videoState; |
| 537 | savedLargeIcon = largeIcon; |
| 538 | savedContentTitle = contentTitle; |
| 539 | this.ringtone = ringtone; |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 540 | savedCallAudioState = callAudioState; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 541 | |
| 542 | if (retval) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 543 | LogUtil.d( |
| 544 | "StatusBarNotifier.checkForChangeAndSaveData", "data changed. Showing notification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | return retval; |
| 548 | } |
| 549 | |
| 550 | /** Returns the main string to use in the notification. */ |
| 551 | @VisibleForTesting |
| 552 | @Nullable |
| 553 | String getContentTitle(ContactCacheEntry contactInfo, DialerCall call) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 554 | if (call.isConferenceCall()) { |
| 555 | return CallerInfoUtils.getConferenceString( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 556 | context, call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | String preferredName = |
| 560 | ContactDisplayUtils.getPreferredDisplayName( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 561 | contactInfo.namePrimary, contactInfo.nameAlternative, contactsPreferences); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 562 | if (TextUtils.isEmpty(preferredName)) { |
| 563 | return TextUtils.isEmpty(contactInfo.number) |
| 564 | ? null |
| 565 | : BidiFormatter.getInstance() |
| 566 | .unicodeWrap(contactInfo.number, TextDirectionHeuristics.LTR); |
| 567 | } |
| 568 | return preferredName; |
| 569 | } |
| 570 | |
| 571 | private void addPersonReference( |
| 572 | Notification.Builder builder, ContactCacheEntry contactInfo, DialerCall call) { |
| 573 | // Query {@link Contacts#CONTENT_LOOKUP_URI} directly with work lookup key is not allowed. |
| 574 | // So, do not pass {@link Contacts#CONTENT_LOOKUP_URI} to NotificationManager to avoid |
| 575 | // NotificationManager using it. |
| 576 | if (contactInfo.lookupUri != null && contactInfo.userType != ContactsUtils.USER_TYPE_WORK) { |
| 577 | builder.addPerson(contactInfo.lookupUri.toString()); |
| 578 | } else if (!TextUtils.isEmpty(call.getNumber())) { |
| 579 | builder.addPerson(Uri.fromParts(PhoneAccount.SCHEME_TEL, call.getNumber(), null).toString()); |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | /** Gets a large icon from the contact info object to display in the notification. */ |
Eric Erfanian | 83b2021 | 2017-05-31 08:53:10 -0700 | [diff] [blame] | 584 | private static Bitmap getLargeIconToDisplay( |
| 585 | Context context, ContactCacheEntry contactInfo, DialerCall call) { |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 586 | Trace.beginSection("StatusBarNotifier.getLargeIconToDisplay"); |
Eric Erfanian | 83b2021 | 2017-05-31 08:53:10 -0700 | [diff] [blame] | 587 | Resources resources = context.getResources(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 588 | Bitmap largeIcon = null; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 589 | if (contactInfo.photo != null && (contactInfo.photo instanceof BitmapDrawable)) { |
| 590 | largeIcon = ((BitmapDrawable) contactInfo.photo).getBitmap(); |
| 591 | } |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 592 | if (contactInfo.photo == null) { |
Eric Erfanian | 83b2021 | 2017-05-31 08:53:10 -0700 | [diff] [blame] | 593 | int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width); |
| 594 | int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height); |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 595 | @ContactType |
| 596 | int contactType = |
| 597 | LetterTileDrawable.getContactTypeFromPrimitives( |
wangqi | 9982f0d | 2017-10-11 17:46:07 -0700 | [diff] [blame] | 598 | call.isVoiceMailNumber(), |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 599 | call.isSpam(), |
| 600 | contactInfo.isBusiness, |
| 601 | call.getNumberPresentation(), |
| 602 | call.isConferenceCall() && !call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)); |
Eric Erfanian | 83b2021 | 2017-05-31 08:53:10 -0700 | [diff] [blame] | 603 | LetterTileDrawable lettertile = new LetterTileDrawable(resources); |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 604 | |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 605 | lettertile.setCanonicalDialerLetterTileDetails( |
| 606 | contactInfo.namePrimary == null ? contactInfo.number : contactInfo.namePrimary, |
| 607 | contactInfo.lookupKey, |
| 608 | LetterTileDrawable.SHAPE_CIRCLE, |
| 609 | contactType); |
| 610 | largeIcon = lettertile.getBitmap(width, height); |
| 611 | } |
| 612 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 613 | if (call.isSpam()) { |
Eric Erfanian | 83b2021 | 2017-05-31 08:53:10 -0700 | [diff] [blame] | 614 | Drawable drawable = resources.getDrawable(R.drawable.blocked_contact, context.getTheme()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 615 | largeIcon = DrawableConverter.drawableToBitmap(drawable); |
| 616 | } |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 617 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 618 | return largeIcon; |
| 619 | } |
| 620 | |
| 621 | private Bitmap getRoundedIcon(Bitmap bitmap) { |
| 622 | if (bitmap == null) { |
| 623 | return null; |
| 624 | } |
| 625 | final int height = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 626 | (int) context.getResources().getDimension(android.R.dimen.notification_large_icon_height); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 627 | final int width = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 628 | (int) context.getResources().getDimension(android.R.dimen.notification_large_icon_width); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 629 | return BitmapUtil.getRoundedBitmap(bitmap, width, height); |
| 630 | } |
| 631 | |
| 632 | /** |
| 633 | * Returns the appropriate icon res Id to display based on the call for which we want to display |
| 634 | * information. |
| 635 | */ |
Eric Erfanian | 2827dd1 | 2017-10-26 09:37:50 -0700 | [diff] [blame] | 636 | @VisibleForTesting |
| 637 | public int getIconToDisplay(DialerCall call) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 638 | // Even if both lines are in use, we only show a single item in |
| 639 | // the expanded Notifications UI. It's labeled "Ongoing call" |
| 640 | // (or "On hold" if there's only one call, and it's on hold.) |
| 641 | // Also, we don't have room to display caller-id info from two |
| 642 | // different calls. So if both lines are in use, display info |
| 643 | // from the foreground call. And if there's a ringing call, |
| 644 | // display that regardless of the state of the other calls. |
| 645 | if (call.getState() == DialerCall.State.ONHOLD) { |
Eric Erfanian | 2827dd1 | 2017-10-26 09:37:50 -0700 | [diff] [blame] | 646 | return R.drawable.quantum_ic_phone_paused_vd_theme_24; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 647 | } else if (call.getVideoTech().getSessionModificationState() |
calderwoodra | 1dc2cea | 2017-09-20 16:30:41 -0700 | [diff] [blame] | 648 | == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST |
| 649 | || call.isVideoCall()) { |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 650 | return R.drawable.quantum_ic_videocam_white_24; |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 651 | } else if (call.hasProperty(PROPERTY_HIGH_DEF_AUDIO) |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 652 | && MotorolaUtils.shouldShowHdIconInNotification(context)) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 653 | // Normally when a call is ongoing the status bar displays an icon of a phone. This is a |
| 654 | // helpful hint for users so they know how to get back to the call. For Sprint HD calls, we |
| 655 | // replace this icon with an icon of a phone with a HD badge. This is a carrier requirement. |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 656 | return R.drawable.ic_hd_call; |
Eric Erfanian | 2827dd1 | 2017-10-26 09:37:50 -0700 | [diff] [blame] | 657 | } else if (call.hasProperty(Details.PROPERTY_HAS_CDMA_VOICE_PRIVACY)) { |
| 658 | return R.drawable.quantum_ic_phone_locked_vd_theme_24; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 659 | } |
yueg | 48f93f4 | 2018-03-09 16:49:38 -0800 | [diff] [blame] | 660 | // If ReturnToCall is enabled, use the static icon. The animated one will show in the bubble. |
| 661 | if (ReturnToCallController.isEnabled(context)) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 662 | return R.drawable.quantum_ic_call_vd_theme_24; |
| 663 | } else { |
| 664 | return R.drawable.on_going_call; |
| 665 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | /** Returns the message to use with the notification. */ |
twyen | d1d1d0c | 2017-10-05 17:34:43 -0700 | [diff] [blame] | 669 | private CharSequence getContentString(DialerCall call, @UserType long userType) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 670 | boolean isIncomingOrWaiting = |
| 671 | call.getState() == DialerCall.State.INCOMING |
| 672 | || call.getState() == DialerCall.State.CALL_WAITING; |
| 673 | |
| 674 | if (isIncomingOrWaiting |
| 675 | && call.getNumberPresentation() == TelecomManager.PRESENTATION_ALLOWED) { |
| 676 | |
| 677 | if (!TextUtils.isEmpty(call.getChildNumber())) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 678 | return context.getString(R.string.child_number, call.getChildNumber()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 679 | } else if (!TextUtils.isEmpty(call.getCallSubject()) && call.isCallSubjectSupported()) { |
| 680 | return call.getCallSubject(); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | int resId = R.string.notification_ongoing_call; |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 685 | String wifiBrand = context.getString(R.string.notification_call_wifi_brand); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 686 | if (call.hasProperty(Details.PROPERTY_WIFI)) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 687 | resId = R.string.notification_ongoing_call_wifi_template; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | if (isIncomingOrWaiting) { |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 691 | if (call.isSpam()) { |
| 692 | resId = R.string.notification_incoming_spam_call; |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 693 | } else if (shouldShowEnrichedCallNotification(call.getEnrichedCallSession())) { |
| 694 | resId = getECIncomingCallText(call.getEnrichedCallSession()); |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 695 | } else if (call.hasProperty(Details.PROPERTY_WIFI)) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 696 | resId = R.string.notification_incoming_call_wifi_template; |
wangqi | 9982f0d | 2017-10-11 17:46:07 -0700 | [diff] [blame] | 697 | } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts(call)) { |
twyen | d1d1d0c | 2017-10-05 17:34:43 -0700 | [diff] [blame] | 698 | return getMultiSimIncomingText(call); |
yueg | 45e4573 | 2017-10-09 14:35:06 -0700 | [diff] [blame] | 699 | } else if (call.isVideoCall()) { |
| 700 | resId = R.string.notification_incoming_video_call; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 701 | } else { |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 702 | resId = R.string.notification_incoming_call; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 703 | } |
| 704 | } else if (call.getState() == DialerCall.State.ONHOLD) { |
| 705 | resId = R.string.notification_on_hold; |
calderwoodra | 1dc2cea | 2017-09-20 16:30:41 -0700 | [diff] [blame] | 706 | } else if (call.isVideoCall()) { |
| 707 | resId = |
| 708 | call.getVideoTech().isPaused() |
| 709 | ? R.string.notification_ongoing_paused_video_call |
| 710 | : R.string.notification_ongoing_video_call; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 711 | } else if (DialerCall.State.isDialing(call.getState())) { |
| 712 | resId = R.string.notification_dialing; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 713 | } else if (call.getVideoTech().getSessionModificationState() |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 714 | == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 715 | resId = R.string.notification_requesting_video_call; |
| 716 | } |
| 717 | |
| 718 | // Is the call placed through work connection service. |
| 719 | boolean isWorkCall = call.hasProperty(PROPERTY_ENTERPRISE_CALL); |
| 720 | if (userType == ContactsUtils.USER_TYPE_WORK || isWorkCall) { |
| 721 | resId = getWorkStringFromPersonalString(resId); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 722 | wifiBrand = context.getString(R.string.notification_call_wifi_work_brand); |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | if (resId == R.string.notification_incoming_call_wifi_template |
| 726 | || resId == R.string.notification_ongoing_call_wifi_template) { |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 727 | // TODO(a bug): Potentially apply this template logic everywhere. |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 728 | return context.getString(resId, wifiBrand); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 729 | } |
| 730 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 731 | return context.getString(resId); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 732 | } |
| 733 | |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 734 | private boolean shouldShowEnrichedCallNotification(Session session) { |
| 735 | if (session == null) { |
| 736 | return false; |
| 737 | } |
| 738 | return session.getMultimediaData().hasData() || session.getMultimediaData().isImportant(); |
| 739 | } |
| 740 | |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 741 | private int getECIncomingCallText(Session session) { |
| 742 | int resId; |
| 743 | MultimediaData data = session.getMultimediaData(); |
| 744 | boolean hasImage = data.hasImageData(); |
| 745 | boolean hasSubject = !TextUtils.isEmpty(data.getText()); |
| 746 | boolean hasMap = data.getLocation() != null; |
| 747 | if (data.isImportant()) { |
| 748 | if (hasMap) { |
| 749 | if (hasImage) { |
| 750 | if (hasSubject) { |
| 751 | resId = R.string.important_notification_incoming_call_with_photo_message_location; |
| 752 | } else { |
| 753 | resId = R.string.important_notification_incoming_call_with_photo_location; |
| 754 | } |
| 755 | } else if (hasSubject) { |
| 756 | resId = R.string.important_notification_incoming_call_with_message_location; |
| 757 | } else { |
| 758 | resId = R.string.important_notification_incoming_call_with_location; |
| 759 | } |
| 760 | } else if (hasImage) { |
| 761 | if (hasSubject) { |
| 762 | resId = R.string.important_notification_incoming_call_with_photo_message; |
| 763 | } else { |
| 764 | resId = R.string.important_notification_incoming_call_with_photo; |
| 765 | } |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 766 | } else if (hasSubject) { |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 767 | resId = R.string.important_notification_incoming_call_with_message; |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 768 | } else { |
| 769 | resId = R.string.important_notification_incoming_call; |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 770 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 771 | if (context.getString(resId).length() > 50) { |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 772 | resId = R.string.important_notification_incoming_call_attachments; |
| 773 | } |
| 774 | } else { |
| 775 | if (hasMap) { |
| 776 | if (hasImage) { |
| 777 | if (hasSubject) { |
| 778 | resId = R.string.notification_incoming_call_with_photo_message_location; |
| 779 | } else { |
| 780 | resId = R.string.notification_incoming_call_with_photo_location; |
| 781 | } |
| 782 | } else if (hasSubject) { |
| 783 | resId = R.string.notification_incoming_call_with_message_location; |
| 784 | } else { |
| 785 | resId = R.string.notification_incoming_call_with_location; |
| 786 | } |
| 787 | } else if (hasImage) { |
| 788 | if (hasSubject) { |
| 789 | resId = R.string.notification_incoming_call_with_photo_message; |
| 790 | } else { |
| 791 | resId = R.string.notification_incoming_call_with_photo; |
| 792 | } |
| 793 | } else { |
| 794 | resId = R.string.notification_incoming_call_with_message; |
| 795 | } |
| 796 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 797 | if (context.getString(resId).length() > 50) { |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 798 | resId = R.string.notification_incoming_call_attachments; |
| 799 | } |
| 800 | return resId; |
| 801 | } |
| 802 | |
twyen | d1d1d0c | 2017-10-05 17:34:43 -0700 | [diff] [blame] | 803 | private CharSequence getMultiSimIncomingText(DialerCall call) { |
| 804 | PhoneAccount phoneAccount = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 805 | context.getSystemService(TelecomManager.class).getPhoneAccount(call.getAccountHandle()); |
twyen | e931c12 | 2018-03-19 14:47:28 -0700 | [diff] [blame^] | 806 | if (phoneAccount == null) { |
| 807 | return context.getString(R.string.notification_incoming_call); |
| 808 | } |
twyen | d1d1d0c | 2017-10-05 17:34:43 -0700 | [diff] [blame] | 809 | SpannableString string = |
| 810 | new SpannableString( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 811 | context.getString( |
twyen | d1d1d0c | 2017-10-05 17:34:43 -0700 | [diff] [blame] | 812 | R.string.notification_incoming_call_mutli_sim, phoneAccount.getLabel())); |
| 813 | int accountStart = string.toString().lastIndexOf(phoneAccount.getLabel().toString()); |
| 814 | int accountEnd = accountStart + phoneAccount.getLabel().length(); |
| 815 | |
| 816 | string.setSpan( |
| 817 | new ForegroundColorSpan(phoneAccount.getHighlightColor()), |
| 818 | accountStart, |
| 819 | accountEnd, |
| 820 | Spannable.SPAN_INCLUSIVE_EXCLUSIVE); |
| 821 | return string; |
| 822 | } |
| 823 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 824 | /** Gets the most relevant call to display in the notification. */ |
| 825 | private DialerCall getCallToShow(CallList callList) { |
| 826 | if (callList == null) { |
| 827 | return null; |
| 828 | } |
| 829 | DialerCall call = callList.getIncomingCall(); |
| 830 | if (call == null) { |
| 831 | call = callList.getOutgoingCall(); |
| 832 | } |
| 833 | if (call == null) { |
| 834 | call = callList.getVideoUpgradeRequestCall(); |
| 835 | } |
| 836 | if (call == null) { |
| 837 | call = callList.getActiveOrBackgroundCall(); |
| 838 | } |
| 839 | return call; |
| 840 | } |
| 841 | |
| 842 | private Spannable getActionText(@StringRes int stringRes, @ColorRes int colorRes) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 843 | Spannable spannable = new SpannableString(context.getText(stringRes)); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 844 | if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) { |
| 845 | // This will only work for cases where the Notification.Builder has a fullscreen intent set |
| 846 | // Notification.Builder that does not have a full screen intent will take the color of the |
| 847 | // app and the following leads to a no-op. |
| 848 | spannable.setSpan( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 849 | new ForegroundColorSpan(context.getColor(colorRes)), 0, spannable.length(), 0); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 850 | } |
| 851 | return spannable; |
| 852 | } |
| 853 | |
| 854 | private void addAnswerAction(Notification.Builder builder) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 855 | LogUtil.d( |
| 856 | "StatusBarNotifier.addAnswerAction", |
| 857 | "will show \"answer\" action in the incoming call Notification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 858 | PendingIntent answerVoicePendingIntent = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 859 | createNotificationPendingIntent(context, ACTION_ANSWER_VOICE_INCOMING_CALL); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 860 | builder.addAction( |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 861 | new Notification.Action.Builder( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 862 | Icon.createWithResource(context, R.drawable.quantum_ic_call_white_24), |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 863 | getActionText( |
| 864 | R.string.notification_action_answer, R.color.notification_action_accept), |
| 865 | answerVoicePendingIntent) |
| 866 | .build()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 867 | } |
| 868 | |
| 869 | private void addDismissAction(Notification.Builder builder) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 870 | LogUtil.d( |
| 871 | "StatusBarNotifier.addDismissAction", |
| 872 | "will show \"decline\" action in the incoming call Notification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 873 | PendingIntent declinePendingIntent = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 874 | createNotificationPendingIntent(context, ACTION_DECLINE_INCOMING_CALL); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 875 | builder.addAction( |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 876 | new Notification.Action.Builder( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 877 | Icon.createWithResource(context, R.drawable.quantum_ic_close_white_24), |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 878 | getActionText( |
| 879 | R.string.notification_action_dismiss, R.color.notification_action_dismiss), |
| 880 | declinePendingIntent) |
| 881 | .build()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 882 | } |
| 883 | |
| 884 | private void addHangupAction(Notification.Builder builder) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 885 | LogUtil.d( |
| 886 | "StatusBarNotifier.addHangupAction", |
| 887 | "will show \"hang-up\" action in the ongoing active call Notification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 888 | PendingIntent hangupPendingIntent = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 889 | createNotificationPendingIntent(context, ACTION_HANG_UP_ONGOING_CALL); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 890 | builder.addAction( |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 891 | new Notification.Action.Builder( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 892 | Icon.createWithResource(context, R.drawable.quantum_ic_call_end_white_24), |
| 893 | context.getText(R.string.notification_action_end_call), |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 894 | hangupPendingIntent) |
| 895 | .build()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 896 | } |
| 897 | |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 898 | private void addSpeakerAction(Notification.Builder builder, CallAudioState callAudioState) { |
| 899 | if ((callAudioState.getSupportedRouteMask() & CallAudioState.ROUTE_BLUETOOTH) |
| 900 | == CallAudioState.ROUTE_BLUETOOTH) { |
| 901 | // Don't add speaker button if bluetooth is connected |
| 902 | return; |
| 903 | } |
| 904 | if (callAudioState.getRoute() == CallAudioState.ROUTE_SPEAKER) { |
| 905 | addSpeakerOffAction(builder); |
| 906 | } else if ((callAudioState.getRoute() & CallAudioState.ROUTE_WIRED_OR_EARPIECE) != 0) { |
| 907 | addSpeakerOnAction(builder); |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | private void addSpeakerOnAction(Notification.Builder builder) { |
| 912 | LogUtil.d( |
| 913 | "StatusBarNotifier.addSpeakerOnAction", |
| 914 | "will show \"Speaker on\" action in the ongoing active call Notification"); |
| 915 | PendingIntent speakerOnPendingIntent = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 916 | createNotificationPendingIntent(context, ACTION_TURN_ON_SPEAKER); |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 917 | builder.addAction( |
| 918 | new Notification.Action.Builder( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 919 | Icon.createWithResource(context, R.drawable.quantum_ic_volume_up_white_24), |
| 920 | context.getText(R.string.notification_action_speaker_on), |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 921 | speakerOnPendingIntent) |
| 922 | .build()); |
| 923 | } |
| 924 | |
| 925 | private void addSpeakerOffAction(Notification.Builder builder) { |
| 926 | LogUtil.d( |
| 927 | "StatusBarNotifier.addSpeakerOffAction", |
| 928 | "will show \"Speaker off\" action in the ongoing active call Notification"); |
| 929 | PendingIntent speakerOffPendingIntent = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 930 | createNotificationPendingIntent(context, ACTION_TURN_OFF_SPEAKER); |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 931 | builder.addAction( |
| 932 | new Notification.Action.Builder( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 933 | Icon.createWithResource(context, R.drawable.quantum_ic_phone_in_talk_white_24), |
| 934 | context.getText(R.string.notification_action_speaker_off), |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 935 | speakerOffPendingIntent) |
| 936 | .build()); |
| 937 | } |
| 938 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 939 | private void addVideoCallAction(Notification.Builder builder) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 940 | LogUtil.i( |
| 941 | "StatusBarNotifier.addVideoCallAction", |
| 942 | "will show \"video\" action in the incoming call Notification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 943 | PendingIntent answerVideoPendingIntent = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 944 | createNotificationPendingIntent(context, ACTION_ANSWER_VIDEO_INCOMING_CALL); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 945 | builder.addAction( |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 946 | new Notification.Action.Builder( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 947 | Icon.createWithResource(context, R.drawable.quantum_ic_videocam_white_24), |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 948 | getActionText( |
| 949 | R.string.notification_action_answer_video, |
| 950 | R.color.notification_action_answer_video), |
| 951 | answerVideoPendingIntent) |
| 952 | .build()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 953 | } |
| 954 | |
| 955 | private void addAcceptUpgradeRequestAction(Notification.Builder builder) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 956 | LogUtil.i( |
| 957 | "StatusBarNotifier.addAcceptUpgradeRequestAction", |
| 958 | "will show \"accept upgrade\" action in the incoming call Notification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 959 | PendingIntent acceptVideoPendingIntent = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 960 | createNotificationPendingIntent(context, ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 961 | builder.addAction( |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 962 | new Notification.Action.Builder( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 963 | Icon.createWithResource(context, R.drawable.quantum_ic_videocam_white_24), |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 964 | getActionText( |
| 965 | R.string.notification_action_accept, R.color.notification_action_accept), |
| 966 | acceptVideoPendingIntent) |
| 967 | .build()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | private void addDismissUpgradeRequestAction(Notification.Builder builder) { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 971 | LogUtil.i( |
| 972 | "StatusBarNotifier.addDismissUpgradeRequestAction", |
| 973 | "will show \"dismiss upgrade\" action in the incoming call Notification"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 974 | PendingIntent declineVideoPendingIntent = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 975 | createNotificationPendingIntent(context, ACTION_DECLINE_VIDEO_UPGRADE_REQUEST); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 976 | builder.addAction( |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 977 | new Notification.Action.Builder( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 978 | Icon.createWithResource(context, R.drawable.quantum_ic_videocam_white_24), |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 979 | getActionText( |
| 980 | R.string.notification_action_dismiss, R.color.notification_action_dismiss), |
| 981 | declineVideoPendingIntent) |
| 982 | .build()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 983 | } |
| 984 | |
| 985 | /** Adds fullscreen intent to the builder. */ |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 986 | private void configureFullScreenIntent(Notification.Builder builder, PendingIntent intent) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 987 | // Ok, we actually want to launch the incoming call |
| 988 | // UI at this point (in addition to simply posting a notification |
| 989 | // to the status bar). Setting fullScreenIntent will cause |
| 990 | // the InCallScreen to be launched immediately *unless* the |
| 991 | // current foreground activity is marked as "immersive". |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 992 | LogUtil.d("StatusBarNotifier.configureFullScreenIntent", "setting fullScreenIntent: " + intent); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 993 | builder.setFullScreenIntent(intent, true); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | private Notification.Builder getNotificationBuilder() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 997 | final Notification.Builder builder = new Notification.Builder(context); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 998 | builder.setOngoing(true); |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 999 | builder.setOnlyAlertOnce(true); |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 1000 | // This will be ignored on O+ and handled by the channel |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 1001 | // noinspection deprecation |
Eric Erfanian | 10b34a5 | 2017-05-04 08:23:17 -0700 | [diff] [blame] | 1002 | builder.setPriority(Notification.PRIORITY_HIGH); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1003 | |
| 1004 | return builder; |
| 1005 | } |
| 1006 | |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 1007 | private PendingIntent createLaunchPendingIntent(boolean isFullScreen) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1008 | Intent intent = |
| 1009 | InCallActivity.getIntent( |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1010 | context, false /* showDialpad */, false /* newOutgoingCall */, isFullScreen); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1011 | |
linyuh | c3968e6 | 2017-11-20 17:40:50 -0800 | [diff] [blame] | 1012 | int requestCode = InCallActivity.PendingIntentRequestCodes.NON_FULL_SCREEN; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1013 | if (isFullScreen) { |
| 1014 | // Use a unique request code so that the pending intent isn't clobbered by the |
| 1015 | // non-full screen pending intent. |
linyuh | c3968e6 | 2017-11-20 17:40:50 -0800 | [diff] [blame] | 1016 | requestCode = InCallActivity.PendingIntentRequestCodes.FULL_SCREEN; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | // PendingIntent that can be used to launch the InCallActivity. The |
| 1020 | // system fires off this intent if the user pulls down the windowshade |
| 1021 | // and clicks the notification's expanded view. It's also used to |
| 1022 | // launch the InCallActivity immediately when when there's an incoming |
| 1023 | // call (see the "fullScreenIntent" field below). |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1024 | return PendingIntent.getActivity(context, requestCode, intent, 0); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | private void setStatusBarCallListener(StatusBarCallListener listener) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1028 | if (statusBarCallListener != null) { |
| 1029 | statusBarCallListener.cleanup(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1030 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1031 | statusBarCallListener = listener; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1032 | } |
| 1033 | |
wangqi | 9982f0d | 2017-10-11 17:46:07 -0700 | [diff] [blame] | 1034 | private boolean hasMultiplePhoneAccounts(DialerCall call) { |
| 1035 | if (call.getCallCapableAccounts() == null) { |
| 1036 | return false; |
| 1037 | } |
| 1038 | return call.getCallCapableAccounts().size() > 1; |
twyen | d1d1d0c | 2017-10-05 17:34:43 -0700 | [diff] [blame] | 1039 | } |
| 1040 | |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 1041 | @Override |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 1042 | @RequiresPermission(Manifest.permission.READ_PHONE_STATE) |
| 1043 | public void onContactInfoComplete(String callId, ContactCacheEntry entry) { |
| 1044 | DialerCall call = CallList.getInstance().getCallById(callId); |
| 1045 | if (call != null) { |
| 1046 | call.getLogState().contactLookupResult = entry.contactLookupResult; |
| 1047 | buildAndSendNotification(CallList.getInstance(), call, entry); |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | @Override |
| 1052 | @RequiresPermission(Manifest.permission.READ_PHONE_STATE) |
| 1053 | public void onImageLoadComplete(String callId, ContactCacheEntry entry) { |
| 1054 | DialerCall call = CallList.getInstance().getCallById(callId); |
| 1055 | if (call != null) { |
| 1056 | buildAndSendNotification(CallList.getInstance(), call, entry); |
| 1057 | } |
yueg | b26c1ae | 2017-09-18 16:59:16 -0700 | [diff] [blame] | 1058 | } |
| 1059 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1060 | private class StatusBarCallListener implements DialerCallListener { |
| 1061 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1062 | private DialerCall dialerCall; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1063 | |
| 1064 | StatusBarCallListener(DialerCall dialerCall) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1065 | this.dialerCall = dialerCall; |
| 1066 | this.dialerCall.addListener(this); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | void cleanup() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1070 | dialerCall.removeListener(this); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | @Override |
| 1074 | public void onDialerCallDisconnect() {} |
| 1075 | |
| 1076 | @Override |
| 1077 | public void onDialerCallUpdate() { |
| 1078 | if (CallList.getInstance().getIncomingCall() == null) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1079 | dialerRingtoneManager.stopCallWaitingTone(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | @Override |
| 1084 | public void onDialerCallChildNumberChange() {} |
| 1085 | |
| 1086 | @Override |
| 1087 | public void onDialerCallLastForwardedNumberChange() {} |
| 1088 | |
| 1089 | @Override |
| 1090 | public void onDialerCallUpgradeToVideo() {} |
| 1091 | |
| 1092 | @Override |
| 1093 | public void onWiFiToLteHandover() {} |
| 1094 | |
| 1095 | @Override |
| 1096 | public void onHandoverToWifiFailure() {} |
| 1097 | |
Eric Erfanian | c857f90 | 2017-05-15 14:05:33 -0700 | [diff] [blame] | 1098 | @Override |
| 1099 | public void onInternationalCallOnWifi() {} |
| 1100 | |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 1101 | @Override |
| 1102 | public void onEnrichedCallSessionUpdate() {} |
| 1103 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1104 | /** |
| 1105 | * Responds to changes in the session modification state for the call by dismissing the status |
| 1106 | * bar notification as required. |
| 1107 | */ |
| 1108 | @Override |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 1109 | public void onDialerCallSessionModificationStateChange() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 1110 | if (dialerCall.getVideoTech().getSessionModificationState() |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 1111 | == SessionModificationState.NO_REQUEST) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1112 | cleanup(); |
wangqi | c8cf79e | 2017-10-17 09:21:00 -0700 | [diff] [blame] | 1113 | updateNotification(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1114 | } |
| 1115 | } |
| 1116 | } |
| 1117 | } |