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 | |
| 19 | import android.content.Context; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 20 | import android.os.Bundle; |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 21 | import android.os.Trace; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 22 | import android.support.v4.app.Fragment; |
| 23 | import android.support.v4.os.UserManagerCompat; |
| 24 | import android.telecom.CallAudioState; |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 25 | import android.telecom.PhoneAccountHandle; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 26 | import com.android.contacts.common.compat.CallCompat; |
| 27 | import com.android.dialer.common.Assert; |
| 28 | import com.android.dialer.common.LogUtil; |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 29 | import com.android.dialer.common.concurrent.DialerExecutorComponent; |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 30 | import com.android.dialer.logging.DialerImpression; |
twyen | fc1f9cf | 2017-11-27 13:22:48 -0800 | [diff] [blame] | 31 | import com.android.dialer.logging.DialerImpression.Type; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 32 | import com.android.dialer.logging.Logger; |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 33 | import com.android.dialer.telecom.TelecomUtil; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 34 | import com.android.incallui.InCallCameraManager.Listener; |
| 35 | import com.android.incallui.InCallPresenter.CanAddCallListener; |
| 36 | import com.android.incallui.InCallPresenter.InCallDetailsListener; |
| 37 | import com.android.incallui.InCallPresenter.InCallState; |
| 38 | import com.android.incallui.InCallPresenter.InCallStateListener; |
| 39 | import com.android.incallui.InCallPresenter.IncomingCallListener; |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 40 | import com.android.incallui.audiomode.AudioModeProvider; |
| 41 | import com.android.incallui.audiomode.AudioModeProvider.AudioModeListener; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 42 | import com.android.incallui.call.CallList; |
| 43 | import com.android.incallui.call.DialerCall; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 44 | import com.android.incallui.call.DialerCall.CameraDirection; |
Sekine Yasuaki | da2c0ae | 2017-07-07 17:01:56 +0900 | [diff] [blame] | 45 | import com.android.incallui.call.DialerCallListener; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 46 | import com.android.incallui.call.TelecomAdapter; |
wangqi | bb94ca6 | 2018-04-27 14:34:04 -0700 | [diff] [blame] | 47 | import com.android.incallui.call.state.DialerCallState; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 48 | import com.android.incallui.incall.protocol.InCallButtonIds; |
| 49 | import com.android.incallui.incall.protocol.InCallButtonUi; |
| 50 | import com.android.incallui.incall.protocol.InCallButtonUiDelegate; |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 51 | import com.android.incallui.multisim.SwapSimWorker; |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 52 | import com.android.incallui.videotech.utils.VideoUtils; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 53 | |
| 54 | /** Logic for call buttons. */ |
| 55 | public class CallButtonPresenter |
| 56 | implements InCallStateListener, |
| 57 | AudioModeListener, |
| 58 | IncomingCallListener, |
| 59 | InCallDetailsListener, |
| 60 | CanAddCallListener, |
| 61 | Listener, |
Sekine Yasuaki | da2c0ae | 2017-07-07 17:01:56 +0900 | [diff] [blame] | 62 | InCallButtonUiDelegate, |
| 63 | DialerCallListener { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 64 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 65 | private final Context context; |
| 66 | private InCallButtonUi inCallButtonUi; |
| 67 | private DialerCall call; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 68 | private boolean isInCallButtonUiReady; |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 69 | private PhoneAccountHandle otherAccount; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 70 | |
| 71 | public CallButtonPresenter(Context context) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 72 | this.context = context.getApplicationContext(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | @Override |
| 76 | public void onInCallButtonUiReady(InCallButtonUi ui) { |
| 77 | Assert.checkState(!isInCallButtonUiReady); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 78 | inCallButtonUi = ui; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 79 | AudioModeProvider.getInstance().addListener(this); |
| 80 | |
| 81 | // register for call state changes last |
| 82 | final InCallPresenter inCallPresenter = InCallPresenter.getInstance(); |
| 83 | inCallPresenter.addListener(this); |
| 84 | inCallPresenter.addIncomingCallListener(this); |
| 85 | inCallPresenter.addDetailsListener(this); |
| 86 | inCallPresenter.addCanAddCallListener(this); |
| 87 | inCallPresenter.getInCallCameraManager().addCameraSelectionListener(this); |
| 88 | |
| 89 | // Update the buttons state immediately for the current call |
| 90 | onStateChange(InCallState.NO_CALLS, inCallPresenter.getInCallState(), CallList.getInstance()); |
| 91 | isInCallButtonUiReady = true; |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public void onInCallButtonUiUnready() { |
| 96 | Assert.checkState(isInCallButtonUiReady); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 97 | inCallButtonUi = null; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 98 | InCallPresenter.getInstance().removeListener(this); |
| 99 | AudioModeProvider.getInstance().removeListener(this); |
| 100 | InCallPresenter.getInstance().removeIncomingCallListener(this); |
| 101 | InCallPresenter.getInstance().removeDetailsListener(this); |
| 102 | InCallPresenter.getInstance().getInCallCameraManager().removeCameraSelectionListener(this); |
| 103 | InCallPresenter.getInstance().removeCanAddCallListener(this); |
| 104 | isInCallButtonUiReady = false; |
Sekine Yasuaki | da2c0ae | 2017-07-07 17:01:56 +0900 | [diff] [blame] | 105 | |
| 106 | if (call != null) { |
| 107 | call.removeListener(this); |
| 108 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public void onStateChange(InCallState oldState, InCallState newState, CallList callList) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 113 | Trace.beginSection("CallButtonPresenter.onStateChange"); |
Sekine Yasuaki | da2c0ae | 2017-07-07 17:01:56 +0900 | [diff] [blame] | 114 | if (call != null) { |
| 115 | call.removeListener(this); |
| 116 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 117 | if (newState == InCallState.OUTGOING) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 118 | call = callList.getOutgoingCall(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 119 | } else if (newState == InCallState.INCALL) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 120 | call = callList.getActiveOrBackgroundCall(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 121 | |
| 122 | // When connected to voice mail, automatically shows the dialpad. |
| 123 | // (On previous releases we showed it when in-call shows up, before waiting for |
| 124 | // OUTGOING. We may want to do that once we start showing "Voice mail" label on |
| 125 | // the dialpad too.) |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 126 | if (oldState == InCallState.OUTGOING && call != null) { |
| 127 | if (call.isVoiceMailNumber() && getActivity() != null) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 128 | getActivity().showDialpadFragment(true /* show */, true /* animate */); |
| 129 | } |
| 130 | } |
| 131 | } else if (newState == InCallState.INCOMING) { |
| 132 | if (getActivity() != null) { |
| 133 | getActivity().showDialpadFragment(false /* show */, true /* animate */); |
| 134 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 135 | call = callList.getIncomingCall(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 136 | } else { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 137 | call = null; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 138 | } |
Sekine Yasuaki | da2c0ae | 2017-07-07 17:01:56 +0900 | [diff] [blame] | 139 | |
| 140 | if (call != null) { |
| 141 | call.addListener(this); |
| 142 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 143 | updateUi(newState, call); |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 144 | Trace.endSection(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Updates the user interface in response to a change in the details of a call. Currently handles |
| 149 | * changes to the call buttons in response to a change in the details for a call. This is |
| 150 | * important to ensure changes to the active call are reflected in the available buttons. |
| 151 | * |
| 152 | * @param call The active call. |
| 153 | * @param details The call details. |
| 154 | */ |
| 155 | @Override |
| 156 | public void onDetailsChanged(DialerCall call, android.telecom.Call.Details details) { |
| 157 | // Only update if the changes are for the currently active call |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 158 | if (inCallButtonUi != null && call != null && call.equals(this.call)) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 159 | updateButtonsState(call); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | @Override |
| 164 | public void onIncomingCall(InCallState oldState, InCallState newState, DialerCall call) { |
| 165 | onStateChange(oldState, newState, CallList.getInstance()); |
| 166 | } |
| 167 | |
| 168 | @Override |
| 169 | public void onCanAddCallChanged(boolean canAddCall) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 170 | if (inCallButtonUi != null && call != null) { |
| 171 | updateButtonsState(call); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
| 175 | @Override |
| 176 | public void onAudioStateChanged(CallAudioState audioState) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 177 | if (inCallButtonUi != null) { |
| 178 | inCallButtonUi.setAudioState(audioState); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
| 182 | @Override |
| 183 | public CallAudioState getCurrentAudioState() { |
| 184 | return AudioModeProvider.getInstance().getAudioState(); |
| 185 | } |
| 186 | |
| 187 | @Override |
| 188 | public void setAudioRoute(int route) { |
| 189 | LogUtil.i( |
| 190 | "CallButtonPresenter.setAudioRoute", |
| 191 | "sending new audio route: " + CallAudioState.audioRouteToString(route)); |
| 192 | TelecomAdapter.getInstance().setAudioRoute(route); |
| 193 | } |
| 194 | |
| 195 | /** Function assumes that bluetooth is not supported. */ |
| 196 | @Override |
| 197 | public void toggleSpeakerphone() { |
| 198 | // This function should not be called if bluetooth is available. |
| 199 | CallAudioState audioState = getCurrentAudioState(); |
| 200 | if (0 != (CallAudioState.ROUTE_BLUETOOTH & audioState.getSupportedRouteMask())) { |
| 201 | // It's clear the UI is wrong, so update the supported mode once again. |
| 202 | LogUtil.e( |
| 203 | "CallButtonPresenter", "toggling speakerphone not allowed when bluetooth supported."); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 204 | inCallButtonUi.setAudioState(audioState); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 205 | return; |
| 206 | } |
| 207 | |
| 208 | int newRoute; |
| 209 | if (audioState.getRoute() == CallAudioState.ROUTE_SPEAKER) { |
| 210 | newRoute = CallAudioState.ROUTE_WIRED_OR_EARPIECE; |
Grace Jia | 0ddedc3 | 2021-04-09 08:33:01 -0700 | [diff] [blame] | 211 | if (call != null) { |
| 212 | Logger.get(context) |
| 213 | .logCallImpression( |
| 214 | DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_WIRED_OR_EARPIECE, |
| 215 | call.getUniqueCallId(), |
| 216 | call.getTimeAddedMs()); |
| 217 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 218 | } else { |
| 219 | newRoute = CallAudioState.ROUTE_SPEAKER; |
Grace Jia | 0ddedc3 | 2021-04-09 08:33:01 -0700 | [diff] [blame] | 220 | if (call != null) { |
| 221 | Logger.get(context) |
| 222 | .logCallImpression( |
| 223 | DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_SPEAKERPHONE, |
| 224 | call.getUniqueCallId(), |
| 225 | call.getTimeAddedMs()); |
| 226 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | setAudioRoute(newRoute); |
| 230 | } |
| 231 | |
| 232 | @Override |
Eric Erfanian | 9a090c8 | 2017-03-16 19:22:24 -0700 | [diff] [blame] | 233 | public void muteClicked(boolean checked, boolean clickedByUser) { |
| 234 | LogUtil.i( |
| 235 | "CallButtonPresenter", "turning on mute: %s, clicked by user: %s", checked, clickedByUser); |
| 236 | if (clickedByUser) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 237 | Logger.get(context) |
Eric Erfanian | 9a090c8 | 2017-03-16 19:22:24 -0700 | [diff] [blame] | 238 | .logCallImpression( |
| 239 | checked |
| 240 | ? DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_MUTE |
| 241 | : DialerImpression.Type.IN_CALL_SCREEN_TURN_OFF_MUTE, |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 242 | call.getUniqueCallId(), |
| 243 | call.getTimeAddedMs()); |
Eric Erfanian | 9a090c8 | 2017-03-16 19:22:24 -0700 | [diff] [blame] | 244 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 245 | TelecomAdapter.getInstance().mute(checked); |
| 246 | } |
| 247 | |
| 248 | @Override |
| 249 | public void holdClicked(boolean checked) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 250 | if (call == null) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 251 | return; |
| 252 | } |
| 253 | if (checked) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 254 | LogUtil.i("CallButtonPresenter", "putting the call on hold: " + call); |
| 255 | call.hold(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 256 | } else { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 257 | LogUtil.i("CallButtonPresenter", "removing the call from hold: " + call); |
| 258 | call.unhold(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | |
| 262 | @Override |
| 263 | public void swapClicked() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 264 | if (call == null) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 265 | return; |
| 266 | } |
| 267 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 268 | LogUtil.i("CallButtonPresenter", "swapping the call: " + call); |
| 269 | TelecomAdapter.getInstance().swap(call.getId()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | @Override |
| 273 | public void mergeClicked() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 274 | Logger.get(context) |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 275 | .logCallImpression( |
| 276 | DialerImpression.Type.IN_CALL_MERGE_BUTTON_PRESSED, |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 277 | call.getUniqueCallId(), |
| 278 | call.getTimeAddedMs()); |
| 279 | TelecomAdapter.getInstance().merge(call.getId()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | @Override |
| 283 | public void addCallClicked() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 284 | Logger.get(context) |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 285 | .logCallImpression( |
| 286 | DialerImpression.Type.IN_CALL_ADD_CALL_BUTTON_PRESSED, |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 287 | call.getUniqueCallId(), |
| 288 | call.getTimeAddedMs()); |
Sekine Yasuaki | a702084 | 2018-05-31 17:10:12 +0900 | [diff] [blame] | 289 | InCallPresenter.getInstance().addCallClicked(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | @Override |
| 293 | public void showDialpadClicked(boolean checked) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 294 | Logger.get(context) |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 295 | .logCallImpression( |
| 296 | DialerImpression.Type.IN_CALL_SHOW_DIALPAD_BUTTON_PRESSED, |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 297 | call.getUniqueCallId(), |
| 298 | call.getTimeAddedMs()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 299 | LogUtil.v("CallButtonPresenter", "show dialpad " + String.valueOf(checked)); |
| 300 | getActivity().showDialpadFragment(checked /* show */, true /* animate */); |
| 301 | } |
| 302 | |
| 303 | @Override |
| 304 | public void changeToVideoClicked() { |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 305 | LogUtil.enterBlock("CallButtonPresenter.changeToVideoClicked"); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 306 | Logger.get(context) |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 307 | .logCallImpression( |
| 308 | DialerImpression.Type.VIDEO_CALL_UPGRADE_REQUESTED, |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 309 | call.getUniqueCallId(), |
| 310 | call.getTimeAddedMs()); |
| 311 | call.getVideoTech().upgradeToVideo(context); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | @Override |
wangqi | f6be617 | 2018-03-30 15:57:56 -0700 | [diff] [blame] | 315 | public void changeToRttClicked() { |
| 316 | LogUtil.enterBlock("CallButtonPresenter.changeToRttClicked"); |
| 317 | call.sendRttUpgradeRequest(); |
| 318 | } |
| 319 | |
| 320 | @Override |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 321 | public void onEndCallClicked() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 322 | LogUtil.i("CallButtonPresenter.onEndCallClicked", "call: " + call); |
| 323 | if (call != null) { |
| 324 | call.disconnect(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public void showAudioRouteSelector() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 330 | inCallButtonUi.showAudioRouteSelector(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 331 | } |
| 332 | |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 333 | @Override |
| 334 | public void swapSimClicked() { |
| 335 | LogUtil.enterBlock("CallButtonPresenter.swapSimClicked"); |
twyen | fc1f9cf | 2017-11-27 13:22:48 -0800 | [diff] [blame] | 336 | Logger.get(getContext()).logImpression(Type.DUAL_SIM_CHANGE_SIM_PRESSED); |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 337 | SwapSimWorker worker = |
| 338 | new SwapSimWorker( |
| 339 | getContext(), |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 340 | call, |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 341 | InCallPresenter.getInstance().getCallList(), |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 342 | otherAccount, |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 343 | InCallPresenter.getInstance().acquireInCallUiLock("swapSim")); |
| 344 | DialerExecutorComponent.get(getContext()) |
| 345 | .dialerExecutorFactory() |
| 346 | .createNonUiTaskBuilder(worker) |
| 347 | .build() |
| 348 | .executeParallel(null); |
| 349 | } |
| 350 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 351 | /** |
| 352 | * Switches the camera between the front-facing and back-facing camera. |
| 353 | * |
| 354 | * @param useFrontFacingCamera True if we should switch to using the front-facing camera, or false |
| 355 | * if we should switch to using the back-facing camera. |
| 356 | */ |
| 357 | @Override |
| 358 | public void switchCameraClicked(boolean useFrontFacingCamera) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 359 | updateCamera(useFrontFacingCamera); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | @Override |
| 363 | public void toggleCameraClicked() { |
| 364 | LogUtil.i("CallButtonPresenter.toggleCameraClicked", ""); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 365 | if (call == null) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 366 | return; |
| 367 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 368 | Logger.get(context) |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 369 | .logCallImpression( |
| 370 | DialerImpression.Type.IN_CALL_SCREEN_SWAP_CAMERA, |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 371 | call.getUniqueCallId(), |
| 372 | call.getTimeAddedMs()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 373 | switchCameraClicked( |
| 374 | !InCallPresenter.getInstance().getInCallCameraManager().isUsingFrontFacingCamera()); |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Stop or start client's video transmission. |
| 379 | * |
| 380 | * @param pause True if pausing the local user's video, or false if starting the local user's |
| 381 | * video. |
| 382 | */ |
| 383 | @Override |
| 384 | public void pauseVideoClicked(boolean pause) { |
| 385 | LogUtil.i("CallButtonPresenter.pauseVideoClicked", "%s", pause ? "pause" : "unpause"); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 386 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 387 | Logger.get(context) |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 388 | .logCallImpression( |
| 389 | pause |
| 390 | ? DialerImpression.Type.IN_CALL_SCREEN_TURN_OFF_VIDEO |
| 391 | : DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_VIDEO, |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 392 | call.getUniqueCallId(), |
| 393 | call.getTimeAddedMs()); |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 394 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 395 | if (pause) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 396 | call.getVideoTech().stopTransmission(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 397 | } else { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 398 | updateCamera( |
| 399 | InCallPresenter.getInstance().getInCallCameraManager().isUsingFrontFacingCamera()); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 400 | call.getVideoTech().resumeTransmission(context); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 401 | } |
| 402 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 403 | inCallButtonUi.setVideoPaused(pause); |
| 404 | inCallButtonUi.enableButton(InCallButtonIds.BUTTON_PAUSE_VIDEO, false); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 405 | } |
| 406 | |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 407 | private void updateCamera(boolean useFrontFacingCamera) { |
| 408 | InCallCameraManager cameraManager = InCallPresenter.getInstance().getInCallCameraManager(); |
| 409 | cameraManager.setUseFrontFacingCamera(useFrontFacingCamera); |
| 410 | |
| 411 | String cameraId = cameraManager.getActiveCameraId(); |
| 412 | if (cameraId != null) { |
| 413 | final int cameraDir = |
| 414 | cameraManager.isUsingFrontFacingCamera() |
| 415 | ? CameraDirection.CAMERA_DIRECTION_FRONT_FACING |
| 416 | : CameraDirection.CAMERA_DIRECTION_BACK_FACING; |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 417 | call.setCameraDir(cameraDir); |
| 418 | call.getVideoTech().setCamera(cameraId); |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 419 | } |
| 420 | } |
| 421 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 422 | private void updateUi(InCallState state, DialerCall call) { |
Eric Erfanian | 2ca4318 | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 423 | LogUtil.v("CallButtonPresenter", "updating call UI for call: %s", call); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 424 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 425 | if (inCallButtonUi == null) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 426 | return; |
| 427 | } |
| 428 | |
Eric Erfanian | 92854e0 | 2018-07-10 18:37:33 +0000 | [diff] [blame] | 429 | if (call != null) { |
| 430 | inCallButtonUi.updateInCallButtonUiColors( |
| 431 | InCallPresenter.getInstance().getThemeColorManager().getSecondaryColor()); |
| 432 | } |
| 433 | |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 434 | final boolean isEnabled = |
| 435 | state.isConnectingOrConnected() && !state.isIncoming() && call != null; |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 436 | inCallButtonUi.setEnabled(isEnabled); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 437 | |
| 438 | if (call == null) { |
| 439 | return; |
| 440 | } |
| 441 | |
| 442 | updateButtonsState(call); |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Updates the buttons applicable for the UI. |
| 447 | * |
| 448 | * @param call The active call. |
| 449 | */ |
linyuh | 60c1e57 | 2018-06-28 20:13:52 -0700 | [diff] [blame] | 450 | @SuppressWarnings(value = {"MissingPermission"}) |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 451 | private void updateButtonsState(DialerCall call) { |
| 452 | LogUtil.v("CallButtonPresenter.updateButtonsState", ""); |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 453 | final boolean isVideo = call.isVideoCall(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 454 | |
| 455 | // Common functionality (audio, hold, etc). |
| 456 | // Show either HOLD or SWAP, but not both. If neither HOLD or SWAP is available: |
| 457 | // (1) If the device normally can hold, show HOLD in a disabled state. |
| 458 | // (2) If the device doesn't have the concept of hold/swap, remove the button. |
| 459 | final boolean showSwap = call.can(android.telecom.Call.Details.CAPABILITY_SWAP_CONFERENCE); |
| 460 | final boolean showHold = |
| 461 | !showSwap |
| 462 | && call.can(android.telecom.Call.Details.CAPABILITY_SUPPORT_HOLD) |
| 463 | && call.can(android.telecom.Call.Details.CAPABILITY_HOLD); |
wangqi | bb94ca6 | 2018-04-27 14:34:04 -0700 | [diff] [blame] | 464 | final boolean isCallOnHold = call.getState() == DialerCallState.ONHOLD; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 465 | |
| 466 | final boolean showAddCall = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 467 | TelecomAdapter.getInstance().canAddCall() && UserManagerCompat.isUserUnlocked(context); |
erfanian | 9dfd6a4 | 2018-04-17 15:01:17 -0700 | [diff] [blame] | 468 | // There can only be two calls so don't show the ability to merge when one of them |
| 469 | // is a speak easy call. |
| 470 | final boolean showMerge = |
| 471 | InCallPresenter.getInstance() |
| 472 | .getCallList() |
| 473 | .getAllCalls() |
| 474 | .stream() |
| 475 | .noneMatch(c -> c != null && c.isSpeakEasyCall()) |
| 476 | && call.can(android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE); |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 477 | final boolean showUpgradeToVideo = !isVideo && (hasVideoCallCapabilities(call)); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 478 | final boolean showDowngradeToAudio = isVideo && isDowngradeToAudioSupported(call); |
| 479 | final boolean showMute = call.can(android.telecom.Call.Details.CAPABILITY_MUTE); |
| 480 | |
| 481 | final boolean hasCameraPermission = |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 482 | isVideo && VideoUtils.hasCameraPermissionAndShownPrivacyToast(context); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 483 | // Disabling local video doesn't seem to work when dialing. See a bug. |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 484 | final boolean showPauseVideo = |
| 485 | isVideo |
wangqi | bb94ca6 | 2018-04-27 14:34:04 -0700 | [diff] [blame] | 486 | && call.getState() != DialerCallState.DIALING |
| 487 | && call.getState() != DialerCallState.CONNECTING; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 488 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 489 | otherAccount = TelecomUtil.getOtherAccount(getContext(), call.getAccountHandle()); |
twyen | 38af651 | 2017-11-22 17:12:49 -0800 | [diff] [blame] | 490 | boolean showSwapSim = |
twyen | ea3b162 | 2018-04-24 10:45:08 -0700 | [diff] [blame] | 491 | !call.isEmergencyCall() |
| 492 | && otherAccount != null |
twyen | 2c6803d | 2017-11-28 11:41:49 -0800 | [diff] [blame] | 493 | && !call.isVoiceMailNumber() |
wangqi | bb94ca6 | 2018-04-27 14:34:04 -0700 | [diff] [blame] | 494 | && DialerCallState.isDialing(call.getState()) |
twyen | 38af651 | 2017-11-22 17:12:49 -0800 | [diff] [blame] | 495 | // Most devices cannot make calls on 2 SIMs at the same time. |
| 496 | && InCallPresenter.getInstance().getCallList().getAllCalls().size() == 1; |
twyen | 00623aa | 2017-10-10 12:15:08 -0700 | [diff] [blame] | 497 | |
wangqi | 01b7827 | 2018-04-03 17:02:44 -0700 | [diff] [blame] | 498 | boolean showUpgradeToRtt = call.canUpgradeToRttCall(); |
wangqi | bb94ca6 | 2018-04-27 14:34:04 -0700 | [diff] [blame] | 499 | boolean enableUpgradeToRtt = showUpgradeToRtt && call.getState() == DialerCallState.ACTIVE; |
wangqi | f6be617 | 2018-03-30 15:57:56 -0700 | [diff] [blame] | 500 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 501 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_AUDIO, true); |
| 502 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_SWAP, showSwap); |
| 503 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_HOLD, showHold); |
| 504 | inCallButtonUi.setHold(isCallOnHold); |
| 505 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_MUTE, showMute); |
| 506 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_SWAP_SIM, showSwapSim); |
| 507 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_ADD_CALL, true); |
| 508 | inCallButtonUi.enableButton(InCallButtonIds.BUTTON_ADD_CALL, showAddCall); |
| 509 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_UPGRADE_TO_VIDEO, showUpgradeToVideo); |
wangqi | f6be617 | 2018-03-30 15:57:56 -0700 | [diff] [blame] | 510 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_UPGRADE_TO_RTT, showUpgradeToRtt); |
wangqi | 15514ef | 2018-04-04 10:50:13 -0700 | [diff] [blame] | 511 | inCallButtonUi.enableButton(InCallButtonIds.BUTTON_UPGRADE_TO_RTT, enableUpgradeToRtt); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 512 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_DOWNGRADE_TO_AUDIO, showDowngradeToAudio); |
| 513 | inCallButtonUi.showButton( |
roldenburg | f15085f | 2017-11-06 12:02:06 -0800 | [diff] [blame] | 514 | InCallButtonIds.BUTTON_SWITCH_CAMERA, |
| 515 | isVideo && hasCameraPermission && call.getVideoTech().isTransmitting()); |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 516 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_PAUSE_VIDEO, showPauseVideo); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 517 | if (isVideo) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 518 | inCallButtonUi.setVideoPaused(!call.getVideoTech().isTransmitting() || !hasCameraPermission); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 519 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 520 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_DIALPAD, true); |
| 521 | inCallButtonUi.showButton(InCallButtonIds.BUTTON_MERGE, showMerge); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 522 | |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 523 | inCallButtonUi.updateButtonStates(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | private boolean hasVideoCallCapabilities(DialerCall call) { |
roldenburg | 6bd612f | 2018-01-18 12:57:19 -0800 | [diff] [blame] | 527 | return call.getVideoTech().isAvailable(context, call.getAccountHandle()); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | /** |
| 531 | * Determines if downgrading from a video call to an audio-only call is supported. In order to |
| 532 | * support downgrade to audio, the SDK version must be >= N and the call should NOT have the |
| 533 | * {@link android.telecom.Call.Details#CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO}. |
| 534 | * |
| 535 | * @param call The call. |
| 536 | * @return {@code true} if downgrading to an audio-only call from a video call is supported. |
| 537 | */ |
| 538 | private boolean isDowngradeToAudioSupported(DialerCall call) { |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 539 | // TODO(a bug): If there is an RCS video share session, return true here |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 540 | return !call.can(CallCompat.Details.CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO); |
| 541 | } |
| 542 | |
| 543 | @Override |
Sekine Yasuaki | a702084 | 2018-05-31 17:10:12 +0900 | [diff] [blame] | 544 | public void onSaveInstanceState(Bundle outState) {} |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 545 | |
| 546 | @Override |
Sekine Yasuaki | a702084 | 2018-05-31 17:10:12 +0900 | [diff] [blame] | 547 | public void onRestoreInstanceState(Bundle savedInstanceState) {} |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 548 | |
| 549 | @Override |
| 550 | public void onCameraPermissionGranted() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 551 | if (call != null) { |
| 552 | updateButtonsState(call); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 553 | } |
| 554 | } |
| 555 | |
| 556 | @Override |
| 557 | public void onActiveCameraSelectionChanged(boolean isUsingFrontFacingCamera) { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 558 | if (inCallButtonUi == null) { |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 559 | return; |
| 560 | } |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 561 | inCallButtonUi.setCameraSwitched(!isUsingFrontFacingCamera); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | @Override |
Sekine Yasuaki | da2c0ae | 2017-07-07 17:01:56 +0900 | [diff] [blame] | 565 | public void onDialerCallSessionModificationStateChange() { |
| 566 | if (inCallButtonUi != null && call != null) { |
| 567 | inCallButtonUi.enableButton(InCallButtonIds.BUTTON_PAUSE_VIDEO, true); |
| 568 | updateButtonsState(call); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | @Override |
| 573 | public void onDialerCallDisconnect() {} |
| 574 | |
| 575 | @Override |
| 576 | public void onDialerCallUpdate() {} |
| 577 | |
| 578 | @Override |
| 579 | public void onDialerCallChildNumberChange() {} |
| 580 | |
| 581 | @Override |
| 582 | public void onDialerCallLastForwardedNumberChange() {} |
| 583 | |
| 584 | @Override |
| 585 | public void onDialerCallUpgradeToVideo() {} |
| 586 | |
| 587 | @Override |
| 588 | public void onWiFiToLteHandover() {} |
| 589 | |
| 590 | @Override |
| 591 | public void onHandoverToWifiFailure() {} |
| 592 | |
| 593 | @Override |
| 594 | public void onInternationalCallOnWifi() {} |
| 595 | |
| 596 | @Override |
| 597 | public void onEnrichedCallSessionUpdate() {} |
| 598 | |
| 599 | @Override |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 600 | public Context getContext() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 601 | return context; |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | private InCallActivity getActivity() { |
linyuh | 183cb71 | 2017-12-27 17:02:37 -0800 | [diff] [blame] | 605 | if (inCallButtonUi != null) { |
| 606 | Fragment fragment = inCallButtonUi.getInCallButtonUiFragment(); |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 607 | if (fragment != null) { |
| 608 | return (InCallActivity) fragment.getActivity(); |
| 609 | } |
| 610 | } |
| 611 | return null; |
| 612 | } |
Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 613 | } |