Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [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 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 18 | |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 20 | import android.os.Bundle; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 21 | import android.util.ArrayMap; |
| 22 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 23 | import java.util.Collections; |
| 24 | import java.util.List; |
| 25 | import java.util.Map; |
| 26 | import java.util.Objects; |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 27 | import java.util.concurrent.CopyOnWriteArrayList; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * A unified virtual device providing a means of voice (and other) communication on a device. |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 31 | * |
| 32 | * @hide |
| 33 | * @deprecated Use {@link InCallService} directly instead of using this class. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 34 | */ |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 35 | @SystemApi |
| 36 | @Deprecated |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 37 | public final class Phone { |
| 38 | |
| 39 | public abstract static class Listener { |
| 40 | /** |
| 41 | * Called when the audio state changes. |
| 42 | * |
| 43 | * @param phone The {@code Phone} calling this method. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 44 | * @param audioState The new {@link AudioState}. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 45 | * |
| 46 | * @deprecated Use {@link #onCallAudioStateChanged(Phone, CallAudioState)} instead. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 47 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 48 | @Deprecated |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 49 | public void onAudioStateChanged(Phone phone, AudioState audioState) { } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 52 | * Called when the audio state changes. |
| 53 | * |
| 54 | * @param phone The {@code Phone} calling this method. |
| 55 | * @param callAudioState The new {@link CallAudioState}. |
| 56 | */ |
| 57 | public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) { } |
| 58 | |
| 59 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 60 | * Called to bring the in-call screen to the foreground. The in-call experience should |
| 61 | * respond immediately by coming to the foreground to inform the user of the state of |
| 62 | * ongoing {@code Call}s. |
| 63 | * |
| 64 | * @param phone The {@code Phone} calling this method. |
| 65 | * @param showDialpad If true, put up the dialpad when the screen is shown. |
| 66 | */ |
| 67 | public void onBringToForeground(Phone phone, boolean showDialpad) { } |
| 68 | |
| 69 | /** |
| 70 | * Called when a {@code Call} has been added to this in-call session. The in-call user |
| 71 | * experience should add necessary state listeners to the specified {@code Call} and |
| 72 | * immediately start to show the user information about the existence |
| 73 | * and nature of this {@code Call}. Subsequent invocations of {@link #getCalls()} will |
| 74 | * include this {@code Call}. |
| 75 | * |
| 76 | * @param phone The {@code Phone} calling this method. |
| 77 | * @param call A newly added {@code Call}. |
| 78 | */ |
| 79 | public void onCallAdded(Phone phone, Call call) { } |
| 80 | |
| 81 | /** |
| 82 | * Called when a {@code Call} has been removed from this in-call session. The in-call user |
| 83 | * experience should remove any state listeners from the specified {@code Call} and |
| 84 | * immediately stop displaying any information about this {@code Call}. |
| 85 | * Subsequent invocations of {@link #getCalls()} will no longer include this {@code Call}. |
| 86 | * |
| 87 | * @param phone The {@code Phone} calling this method. |
| 88 | * @param call A newly removed {@code Call}. |
| 89 | */ |
| 90 | public void onCallRemoved(Phone phone, Call call) { } |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 91 | |
| 92 | /** |
| 93 | * Called when the {@code Phone} ability to add more calls changes. If the phone cannot |
| 94 | * support more calls then {@code canAddCall} is set to {@code false}. If it can, then it |
| 95 | * is set to {@code true}. |
| 96 | * |
| 97 | * @param phone The {@code Phone} calling this method. |
| 98 | * @param canAddCall Indicates whether an additional call can be added. |
| 99 | */ |
| 100 | public void onCanAddCallChanged(Phone phone, boolean canAddCall) { } |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Called to silence the ringer if a ringing call exists. |
| 104 | * |
| 105 | * @param phone The {@code Phone} calling this method. |
| 106 | */ |
| 107 | public void onSilenceRinger(Phone phone) { } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 110 | // A Map allows us to track each Call by its Telecom-specified call ID |
| 111 | private final Map<String, Call> mCallByTelecomCallId = new ArrayMap<>(); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 112 | |
| 113 | // A List allows us to keep the Calls in a stable iteration order so that casually developed |
| 114 | // user interface components do not incur any spurious jank |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 115 | private final List<Call> mCalls = new CopyOnWriteArrayList<>(); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 116 | |
| 117 | // An unmodifiable view of the above List can be safely shared with subclass implementations |
| 118 | private final List<Call> mUnmodifiableCalls = Collections.unmodifiableList(mCalls); |
| 119 | |
| 120 | private final InCallAdapter mInCallAdapter; |
| 121 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 122 | private CallAudioState mCallAudioState; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 123 | |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 124 | private final List<Listener> mListeners = new CopyOnWriteArrayList<>(); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 125 | |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 126 | private boolean mCanAddCall = true; |
| 127 | |
Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 128 | private final String mCallingPackage; |
| 129 | |
| 130 | Phone(InCallAdapter adapter, String callingPackage) { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 131 | mInCallAdapter = adapter; |
Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 132 | mCallingPackage = callingPackage; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 135 | final void internalAddCall(ParcelableCall parcelableCall) { |
Shriram Ganesh | ddf570e | 2015-05-31 09:18:48 -0700 | [diff] [blame] | 136 | Call call = new Call(this, parcelableCall.getId(), mInCallAdapter, |
Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 137 | parcelableCall.getState(), mCallingPackage); |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 138 | mCallByTelecomCallId.put(parcelableCall.getId(), call); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 139 | mCalls.add(call); |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 140 | checkCallTree(parcelableCall); |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 141 | call.internalUpdate(parcelableCall, mCallByTelecomCallId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 142 | fireCallAdded(call); |
| 143 | } |
| 144 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 145 | final void internalRemoveCall(Call call) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 146 | mCallByTelecomCallId.remove(call.internalGetCallId()); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 147 | mCalls.remove(call); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 148 | |
| 149 | InCallService.VideoCall videoCall = call.getVideoCall(); |
| 150 | if (videoCall != null) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 151 | videoCall.destroy(); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 152 | } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 153 | fireCallRemoved(call); |
| 154 | } |
| 155 | |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 156 | final void internalUpdateCall(ParcelableCall parcelableCall) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 157 | Call call = mCallByTelecomCallId.get(parcelableCall.getId()); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 158 | if (call != null) { |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 159 | checkCallTree(parcelableCall); |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 160 | call.internalUpdate(parcelableCall, mCallByTelecomCallId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 161 | } |
| 162 | } |
| 163 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 164 | final void internalSetPostDialWait(String telecomId, String remaining) { |
| 165 | Call call = mCallByTelecomCallId.get(telecomId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 166 | if (call != null) { |
| 167 | call.internalSetPostDialWait(remaining); |
| 168 | } |
| 169 | } |
| 170 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 171 | final void internalCallAudioStateChanged(CallAudioState callAudioState) { |
| 172 | if (!Objects.equals(mCallAudioState, callAudioState)) { |
| 173 | mCallAudioState = callAudioState; |
| 174 | fireCallAudioStateChanged(callAudioState); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 178 | final Call internalGetCallByTelecomId(String telecomId) { |
| 179 | return mCallByTelecomCallId.get(telecomId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 182 | final void internalBringToForeground(boolean showDialpad) { |
| 183 | fireBringToForeground(showDialpad); |
| 184 | } |
| 185 | |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 186 | final void internalSetCanAddCall(boolean canAddCall) { |
| 187 | if (mCanAddCall != canAddCall) { |
| 188 | mCanAddCall = canAddCall; |
| 189 | fireCanAddCallChanged(canAddCall); |
| 190 | } |
| 191 | } |
| 192 | |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 193 | final void internalSilenceRinger() { |
| 194 | fireSilenceRinger(); |
| 195 | } |
| 196 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 197 | final void internalOnConnectionEvent(String telecomId, String event, Bundle extras) { |
| 198 | Call call = mCallByTelecomCallId.get(telecomId); |
| 199 | if (call != null) { |
| 200 | call.internalOnConnectionEvent(event, extras); |
| 201 | } |
| 202 | } |
| 203 | |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 204 | final void internalOnRttUpgradeRequest(String callId, int requestId) { |
| 205 | Call call = mCallByTelecomCallId.get(callId); |
| 206 | if (call != null) { |
| 207 | call.internalOnRttUpgradeRequest(requestId); |
| 208 | } |
| 209 | } |
| 210 | |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame^] | 211 | final void internalOnRttInitiationFailure(String callId, int reason) { |
| 212 | Call call = mCallByTelecomCallId.get(callId); |
| 213 | if (call != null) { |
| 214 | call.internalOnRttInitiationFailure(reason); |
| 215 | } |
| 216 | } |
| 217 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 218 | /** |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 219 | * Called to destroy the phone and cleanup any lingering calls. |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 220 | */ |
| 221 | final void destroy() { |
| 222 | for (Call call : mCalls) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 223 | InCallService.VideoCall videoCall = call.getVideoCall(); |
| 224 | if (videoCall != null) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 225 | videoCall.destroy(); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 226 | } |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 227 | if (call.getState() != Call.STATE_DISCONNECTED) { |
| 228 | call.internalSetDisconnected(); |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 234 | * Adds a listener to this {@code Phone}. |
| 235 | * |
| 236 | * @param listener A {@code Listener} object. |
| 237 | */ |
| 238 | public final void addListener(Listener listener) { |
| 239 | mListeners.add(listener); |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Removes a listener from this {@code Phone}. |
| 244 | * |
| 245 | * @param listener A {@code Listener} object. |
| 246 | */ |
| 247 | public final void removeListener(Listener listener) { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 248 | if (listener != null) { |
| 249 | mListeners.remove(listener); |
| 250 | } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | /** |
| 254 | * Obtains the current list of {@code Call}s to be displayed by this in-call experience. |
| 255 | * |
| 256 | * @return A list of the relevant {@code Call}s. |
| 257 | */ |
| 258 | public final List<Call> getCalls() { |
| 259 | return mUnmodifiableCalls; |
| 260 | } |
| 261 | |
| 262 | /** |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 263 | * Returns if the {@code Phone} can support additional calls. |
| 264 | * |
| 265 | * @return Whether the phone supports adding more calls. |
| 266 | */ |
| 267 | public final boolean canAddCall() { |
| 268 | return mCanAddCall; |
| 269 | } |
| 270 | |
| 271 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 272 | * Sets the microphone mute state. When this request is honored, there will be change to |
| 273 | * the {@link #getAudioState()}. |
| 274 | * |
| 275 | * @param state {@code true} if the microphone should be muted; {@code false} otherwise. |
| 276 | */ |
| 277 | public final void setMuted(boolean state) { |
| 278 | mInCallAdapter.mute(state); |
| 279 | } |
| 280 | |
| 281 | /** |
| 282 | * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will |
| 283 | * be change to the {@link #getAudioState()}. |
| 284 | * |
| 285 | * @param route The audio route to use. |
| 286 | */ |
| 287 | public final void setAudioRoute(int route) { |
| 288 | mInCallAdapter.setAudioRoute(route); |
| 289 | } |
| 290 | |
| 291 | /** |
Yorke Lee | 0d6ea71 | 2014-07-28 14:39:23 -0700 | [diff] [blame] | 292 | * Turns the proximity sensor on. When this request is made, the proximity sensor will |
| 293 | * become active, and the touch screen and display will be turned off when the user's face |
| 294 | * is detected to be in close proximity to the screen. This operation is a no-op on devices |
| 295 | * that do not have a proximity sensor. |
Yorke Lee | 22244d0 | 2015-04-14 12:34:28 -0700 | [diff] [blame] | 296 | * |
| 297 | * @hide |
Yorke Lee | 0d6ea71 | 2014-07-28 14:39:23 -0700 | [diff] [blame] | 298 | */ |
| 299 | public final void setProximitySensorOn() { |
| 300 | mInCallAdapter.turnProximitySensorOn(); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Turns the proximity sensor off. When this request is made, the proximity sensor will |
| 305 | * become inactive, and no longer affect the touch screen and display. This operation is a |
| 306 | * no-op on devices that do not have a proximity sensor. |
| 307 | * |
| 308 | * @param screenOnImmediately If true, the screen will be turned on immediately if it was |
| 309 | * previously off. Otherwise, the screen will only be turned on after the proximity sensor |
| 310 | * is no longer triggered. |
Yorke Lee | 22244d0 | 2015-04-14 12:34:28 -0700 | [diff] [blame] | 311 | * |
| 312 | * @hide |
Yorke Lee | 0d6ea71 | 2014-07-28 14:39:23 -0700 | [diff] [blame] | 313 | */ |
| 314 | public final void setProximitySensorOff(boolean screenOnImmediately) { |
| 315 | mInCallAdapter.turnProximitySensorOff(screenOnImmediately); |
| 316 | } |
| 317 | |
| 318 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 319 | * Obtains the current phone call audio state of the {@code Phone}. |
| 320 | * |
| 321 | * @return An object encapsulating the audio state. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 322 | * @deprecated Use {@link #getCallAudioState()} instead. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 323 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 324 | @Deprecated |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 325 | public final AudioState getAudioState() { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 326 | return new AudioState(mCallAudioState); |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * Obtains the current phone call audio state of the {@code Phone}. |
| 331 | * |
| 332 | * @return An object encapsulating the audio state. |
| 333 | */ |
| 334 | public final CallAudioState getCallAudioState() { |
| 335 | return mCallAudioState; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | private void fireCallAdded(Call call) { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 339 | for (Listener listener : mListeners) { |
| 340 | listener.onCallAdded(this, call); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | |
| 344 | private void fireCallRemoved(Call call) { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 345 | for (Listener listener : mListeners) { |
| 346 | listener.onCallRemoved(this, call); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 347 | } |
| 348 | } |
| 349 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 350 | private void fireCallAudioStateChanged(CallAudioState audioState) { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 351 | for (Listener listener : mListeners) { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 352 | listener.onCallAudioStateChanged(this, audioState); |
| 353 | listener.onAudioStateChanged(this, new AudioState(audioState)); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | |
| 357 | private void fireBringToForeground(boolean showDialpad) { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 358 | for (Listener listener : mListeners) { |
| 359 | listener.onBringToForeground(this, showDialpad); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 360 | } |
| 361 | } |
| 362 | |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 363 | private void fireCanAddCallChanged(boolean canAddCall) { |
| 364 | for (Listener listener : mListeners) { |
| 365 | listener.onCanAddCallChanged(this, canAddCall); |
| 366 | } |
| 367 | } |
| 368 | |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 369 | private void fireSilenceRinger() { |
| 370 | for (Listener listener : mListeners) { |
| 371 | listener.onSilenceRinger(this); |
| 372 | } |
| 373 | } |
| 374 | |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 375 | private void checkCallTree(ParcelableCall parcelableCall) { |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 376 | if (parcelableCall.getChildCallIds() != null) { |
| 377 | for (int i = 0; i < parcelableCall.getChildCallIds().size(); i++) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 378 | if (!mCallByTelecomCallId.containsKey(parcelableCall.getChildCallIds().get(i))) { |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 379 | Log.wtf(this, "ParcelableCall %s has nonexistent child %s", |
| 380 | parcelableCall.getId(), parcelableCall.getChildCallIds().get(i)); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | } |