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