blob: 61e829e75930664328bf87d1ec9587588b84f430 [file] [log] [blame]
Ihab Awade63fadb2014-07-09 21:52:04 -07001/*
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 Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awade63fadb2014-07-09 21:52:04 -070018
Junhoedf3d822022-11-24 09:26:37 +000019import android.annotation.CallbackExecutor;
20import android.annotation.NonNull;
Santos Cordon29886d82015-04-16 15:34:07 -070021import android.annotation.SystemApi;
Hall Liua98f58b52017-11-07 17:59:28 -080022import android.bluetooth.BluetoothDevice;
Artur Satayev2ebb31c2020-01-08 12:24:36 +000023import android.compat.annotation.UnsupportedAppUsage;
Tyler Gunn17933eb2019-03-05 13:58:45 -080024import android.os.Build;
Tyler Gunn876dbfb2016-03-14 15:18:07 -070025import android.os.Bundle;
Junhoedf3d822022-11-24 09:26:37 +000026import android.os.OutcomeReceiver;
Ihab Awade63fadb2014-07-09 21:52:04 -070027import android.util.ArrayMap;
28
Grace Jiac7173232021-07-15 11:36:49 -070029import com.android.internal.annotations.GuardedBy;
30
Ihab Awade63fadb2014-07-09 21:52:04 -070031import java.util.Collections;
32import java.util.List;
33import java.util.Map;
34import java.util.Objects;
Jay Shrauner229e3822014-08-15 09:23:07 -070035import java.util.concurrent.CopyOnWriteArrayList;
Junhoedf3d822022-11-24 09:26:37 +000036import java.util.concurrent.Executor;
Ihab Awade63fadb2014-07-09 21:52:04 -070037
38/**
39 * A unified virtual device providing a means of voice (and other) communication on a device.
Santos Cordon29886d82015-04-16 15:34:07 -070040 *
41 * @hide
42 * @deprecated Use {@link InCallService} directly instead of using this class.
Ihab Awade63fadb2014-07-09 21:52:04 -070043 */
Santos Cordon29886d82015-04-16 15:34:07 -070044@SystemApi
45@Deprecated
Ihab Awade63fadb2014-07-09 21:52:04 -070046public final class Phone {
47
48 public abstract static class Listener {
49 /**
50 * Called when the audio state changes.
51 *
52 * @param phone The {@code Phone} calling this method.
Ihab Awadb19a0bc2014-08-07 19:46:01 -070053 * @param audioState The new {@link AudioState}.
Yorke Lee4af59352015-05-13 14:14:54 -070054 *
55 * @deprecated Use {@link #onCallAudioStateChanged(Phone, CallAudioState)} instead.
Ihab Awade63fadb2014-07-09 21:52:04 -070056 */
Yorke Lee4af59352015-05-13 14:14:54 -070057 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -070058 public void onAudioStateChanged(Phone phone, AudioState audioState) { }
Ihab Awade63fadb2014-07-09 21:52:04 -070059
60 /**
Yorke Lee4af59352015-05-13 14:14:54 -070061 * Called when the audio state changes.
62 *
63 * @param phone The {@code Phone} calling this method.
64 * @param callAudioState The new {@link CallAudioState}.
65 */
66 public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) { }
67
68 /**
Ihab Awade63fadb2014-07-09 21:52:04 -070069 * Called to bring the in-call screen to the foreground. The in-call experience should
70 * respond immediately by coming to the foreground to inform the user of the state of
71 * ongoing {@code Call}s.
72 *
73 * @param phone The {@code Phone} calling this method.
74 * @param showDialpad If true, put up the dialpad when the screen is shown.
75 */
76 public void onBringToForeground(Phone phone, boolean showDialpad) { }
77
78 /**
79 * Called when a {@code Call} has been added to this in-call session. The in-call user
80 * experience should add necessary state listeners to the specified {@code Call} and
81 * immediately start to show the user information about the existence
82 * and nature of this {@code Call}. Subsequent invocations of {@link #getCalls()} will
83 * include this {@code Call}.
84 *
85 * @param phone The {@code Phone} calling this method.
86 * @param call A newly added {@code Call}.
87 */
88 public void onCallAdded(Phone phone, Call call) { }
89
90 /**
91 * Called when a {@code Call} has been removed from this in-call session. The in-call user
92 * experience should remove any state listeners from the specified {@code Call} and
93 * immediately stop displaying any information about this {@code Call}.
94 * Subsequent invocations of {@link #getCalls()} will no longer include this {@code Call}.
95 *
96 * @param phone The {@code Phone} calling this method.
97 * @param call A newly removed {@code Call}.
98 */
99 public void onCallRemoved(Phone phone, Call call) { }
Santos Cordon6c912b72014-11-07 16:05:09 -0800100
101 /**
102 * Called when the {@code Phone} ability to add more calls changes. If the phone cannot
103 * support more calls then {@code canAddCall} is set to {@code false}. If it can, then it
104 * is set to {@code true}.
105 *
106 * @param phone The {@code Phone} calling this method.
107 * @param canAddCall Indicates whether an additional call can be added.
108 */
109 public void onCanAddCallChanged(Phone phone, boolean canAddCall) { }
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800110
111 /**
112 * Called to silence the ringer if a ringing call exists.
113 *
114 * @param phone The {@code Phone} calling this method.
115 */
116 public void onSilenceRinger(Phone phone) { }
Ihab Awade63fadb2014-07-09 21:52:04 -0700117 }
118
Hall Liu31de23d2019-10-11 15:38:29 -0700119 // TODO: replace all usages of this with the actual R constant from Build.VERSION_CODES
120 /** @hide */
121 public static final int SDK_VERSION_R = 30;
122
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700123 // A Map allows us to track each Call by its Telecom-specified call ID
Grace Jiac7173232021-07-15 11:36:49 -0700124 @GuardedBy("mLock")
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700125 private final Map<String, Call> mCallByTelecomCallId = new ArrayMap<>();
Ihab Awade63fadb2014-07-09 21:52:04 -0700126
127 // A List allows us to keep the Calls in a stable iteration order so that casually developed
128 // user interface components do not incur any spurious jank
Santos Cordonf30d7e92014-08-26 09:54:33 -0700129 private final List<Call> mCalls = new CopyOnWriteArrayList<>();
Ihab Awade63fadb2014-07-09 21:52:04 -0700130
131 // An unmodifiable view of the above List can be safely shared with subclass implementations
132 private final List<Call> mUnmodifiableCalls = Collections.unmodifiableList(mCalls);
133
134 private final InCallAdapter mInCallAdapter;
135
Yorke Lee4af59352015-05-13 14:14:54 -0700136 private CallAudioState mCallAudioState;
Ihab Awade63fadb2014-07-09 21:52:04 -0700137
Jay Shrauner229e3822014-08-15 09:23:07 -0700138 private final List<Listener> mListeners = new CopyOnWriteArrayList<>();
Ihab Awade63fadb2014-07-09 21:52:04 -0700139
Santos Cordon6c912b72014-11-07 16:05:09 -0800140 private boolean mCanAddCall = true;
141
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -0800142 private final String mCallingPackage;
143
Tyler Gunn159f35c2017-03-02 09:28:37 -0800144 /**
145 * The Target SDK version of the InCallService implementation.
146 */
147 private final int mTargetSdkVersion;
148
Grace Jiac7173232021-07-15 11:36:49 -0700149 private final Object mLock = new Object();
150
Tyler Gunn159f35c2017-03-02 09:28:37 -0800151 Phone(InCallAdapter adapter, String callingPackage, int targetSdkVersion) {
Ihab Awade63fadb2014-07-09 21:52:04 -0700152 mInCallAdapter = adapter;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -0800153 mCallingPackage = callingPackage;
Tyler Gunn159f35c2017-03-02 09:28:37 -0800154 mTargetSdkVersion = targetSdkVersion;
Ihab Awade63fadb2014-07-09 21:52:04 -0700155 }
156
Santos Cordon88b771d2014-07-19 13:10:40 -0700157 final void internalAddCall(ParcelableCall parcelableCall) {
Hall Liu31de23d2019-10-11 15:38:29 -0700158 if (mTargetSdkVersion < SDK_VERSION_R
159 && parcelableCall.getState() == Call.STATE_AUDIO_PROCESSING) {
160 Log.i(this, "Skipping adding audio processing call for sdk compatibility");
161 return;
162 }
163
Grace Jiac7173232021-07-15 11:36:49 -0700164 Call call = getCallById(parcelableCall.getId());
Hall Liufc2be9c2019-11-08 18:26:47 -0800165 if (call == null) {
166 call = new Call(this, parcelableCall.getId(), mInCallAdapter,
167 parcelableCall.getState(), mCallingPackage, mTargetSdkVersion);
Grace Jiac7173232021-07-15 11:36:49 -0700168
169 synchronized (mLock) {
170 mCallByTelecomCallId.put(parcelableCall.getId(), call);
171 mCalls.add(call);
172 }
173
Hall Liufc2be9c2019-11-08 18:26:47 -0800174 checkCallTree(parcelableCall);
175 call.internalUpdate(parcelableCall, mCallByTelecomCallId);
176 fireCallAdded(call);
qing278fdb12021-10-26 19:05:51 +0000177 if (call.getState() == Call.STATE_DISCONNECTED) {
178 internalRemoveCall(call);
179 }
Hall Liufc2be9c2019-11-08 18:26:47 -0800180 } else {
181 Log.w(this, "Call %s added, but it was already present", call.internalGetCallId());
182 checkCallTree(parcelableCall);
183 call.internalUpdate(parcelableCall, mCallByTelecomCallId);
184 }
Hall Liu31de23d2019-10-11 15:38:29 -0700185 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700186
Ihab Awade63fadb2014-07-09 21:52:04 -0700187 final void internalRemoveCall(Call call) {
Grace Jiac7173232021-07-15 11:36:49 -0700188 synchronized (mLock) {
189 mCallByTelecomCallId.remove(call.internalGetCallId());
190 mCalls.remove(call);
191 }
Tyler Gunn75958422015-04-15 14:23:42 -0700192
193 InCallService.VideoCall videoCall = call.getVideoCall();
194 if (videoCall != null) {
Andrew Lee011728f2015-04-23 15:47:06 -0700195 videoCall.destroy();
Tyler Gunn75958422015-04-15 14:23:42 -0700196 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700197 fireCallRemoved(call);
198 }
199
Santos Cordon88b771d2014-07-19 13:10:40 -0700200 final void internalUpdateCall(ParcelableCall parcelableCall) {
Hall Liu31de23d2019-10-11 15:38:29 -0700201 if (mTargetSdkVersion < SDK_VERSION_R
202 && parcelableCall.getState() == Call.STATE_AUDIO_PROCESSING) {
203 Log.i(this, "removing audio processing call during update for sdk compatibility");
Grace Jiac7173232021-07-15 11:36:49 -0700204 Call call = getCallById(parcelableCall.getId());
Hall Liu31de23d2019-10-11 15:38:29 -0700205 if (call != null) {
206 internalRemoveCall(call);
207 }
208 return;
209 }
210
Grace Jiac7173232021-07-15 11:36:49 -0700211 Call call = getCallById(parcelableCall.getId());
Hall Liu31de23d2019-10-11 15:38:29 -0700212 if (call != null) {
213 checkCallTree(parcelableCall);
214 call.internalUpdate(parcelableCall, mCallByTelecomCallId);
215 } else {
216 // This call may have come out of audio processing. Try adding it if our target sdk
217 // version is low enough.
Hall Liufc2be9c2019-11-08 18:26:47 -0800218 // The only two allowable states coming out of audio processing are ACTIVE and
219 // SIMULATED_RINGING.
220 if (mTargetSdkVersion < SDK_VERSION_R && (parcelableCall.getState() == Call.STATE_ACTIVE
221 || parcelableCall.getState() == Call.STATE_SIMULATED_RINGING)) {
222 Log.i(this, "adding call during update for sdk compatibility");
Hall Liu31de23d2019-10-11 15:38:29 -0700223 internalAddCall(parcelableCall);
224 }
225 }
226 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700227
Grace Jiac7173232021-07-15 11:36:49 -0700228 Call getCallById(String callId) {
229 synchronized (mLock) {
230 return mCallByTelecomCallId.get(callId);
231 }
232 }
233
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700234 final void internalSetPostDialWait(String telecomId, String remaining) {
Grace Jiac7173232021-07-15 11:36:49 -0700235 Call call = getCallById(telecomId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700236 if (call != null) {
237 call.internalSetPostDialWait(remaining);
238 }
239 }
240
Yorke Lee4af59352015-05-13 14:14:54 -0700241 final void internalCallAudioStateChanged(CallAudioState callAudioState) {
242 if (!Objects.equals(mCallAudioState, callAudioState)) {
243 mCallAudioState = callAudioState;
244 fireCallAudioStateChanged(callAudioState);
Ihab Awade63fadb2014-07-09 21:52:04 -0700245 }
246 }
247
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700248 final Call internalGetCallByTelecomId(String telecomId) {
Grace Jiac7173232021-07-15 11:36:49 -0700249 return getCallById(telecomId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700250 }
251
Ihab Awade63fadb2014-07-09 21:52:04 -0700252 final void internalBringToForeground(boolean showDialpad) {
253 fireBringToForeground(showDialpad);
254 }
255
Santos Cordon6c912b72014-11-07 16:05:09 -0800256 final void internalSetCanAddCall(boolean canAddCall) {
257 if (mCanAddCall != canAddCall) {
258 mCanAddCall = canAddCall;
259 fireCanAddCallChanged(canAddCall);
260 }
261 }
262
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800263 final void internalSilenceRinger() {
264 fireSilenceRinger();
265 }
266
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700267 final void internalOnConnectionEvent(String telecomId, String event, Bundle extras) {
Grace Jiac7173232021-07-15 11:36:49 -0700268 Call call = getCallById(telecomId);
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700269 if (call != null) {
270 call.internalOnConnectionEvent(event, extras);
271 }
272 }
273
Hall Liu95d55872017-01-25 17:12:49 -0800274 final void internalOnRttUpgradeRequest(String callId, int requestId) {
Grace Jiac7173232021-07-15 11:36:49 -0700275 Call call = getCallById(callId);
Hall Liu95d55872017-01-25 17:12:49 -0800276 if (call != null) {
277 call.internalOnRttUpgradeRequest(requestId);
278 }
279 }
280
Hall Liu57006aa2017-02-06 10:49:48 -0800281 final void internalOnRttInitiationFailure(String callId, int reason) {
Grace Jiac7173232021-07-15 11:36:49 -0700282 Call call = getCallById(callId);
Hall Liu57006aa2017-02-06 10:49:48 -0800283 if (call != null) {
284 call.internalOnRttInitiationFailure(reason);
285 }
286 }
287
Sanket Padawe85291f62017-12-01 13:59:27 -0800288 final void internalOnHandoverFailed(String callId, int error) {
Grace Jiac7173232021-07-15 11:36:49 -0700289 Call call = getCallById(callId);
Sanket Padawe85291f62017-12-01 13:59:27 -0800290 if (call != null) {
291 call.internalOnHandoverFailed(error);
292 }
293 }
294
Tyler Gunn858bfaf2018-01-22 15:17:54 -0800295 final void internalOnHandoverComplete(String callId) {
Grace Jiac7173232021-07-15 11:36:49 -0700296 Call call = getCallById(callId);
Tyler Gunn858bfaf2018-01-22 15:17:54 -0800297 if (call != null) {
298 call.internalOnHandoverComplete();
299 }
300 }
301
Ihab Awade63fadb2014-07-09 21:52:04 -0700302 /**
Santos Cordonf30d7e92014-08-26 09:54:33 -0700303 * Called to destroy the phone and cleanup any lingering calls.
Santos Cordonf30d7e92014-08-26 09:54:33 -0700304 */
305 final void destroy() {
306 for (Call call : mCalls) {
Tyler Gunn75958422015-04-15 14:23:42 -0700307 InCallService.VideoCall videoCall = call.getVideoCall();
308 if (videoCall != null) {
Andrew Lee011728f2015-04-23 15:47:06 -0700309 videoCall.destroy();
Tyler Gunn75958422015-04-15 14:23:42 -0700310 }
Santos Cordonf30d7e92014-08-26 09:54:33 -0700311 if (call.getState() != Call.STATE_DISCONNECTED) {
312 call.internalSetDisconnected();
313 }
314 }
315 }
316
317 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700318 * Adds a listener to this {@code Phone}.
319 *
320 * @param listener A {@code Listener} object.
321 */
322 public final void addListener(Listener listener) {
323 mListeners.add(listener);
324 }
325
326 /**
327 * Removes a listener from this {@code Phone}.
328 *
329 * @param listener A {@code Listener} object.
330 */
331 public final void removeListener(Listener listener) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700332 if (listener != null) {
333 mListeners.remove(listener);
334 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700335 }
336
337 /**
338 * Obtains the current list of {@code Call}s to be displayed by this in-call experience.
339 *
340 * @return A list of the relevant {@code Call}s.
341 */
342 public final List<Call> getCalls() {
343 return mUnmodifiableCalls;
344 }
345
346 /**
Santos Cordon6c912b72014-11-07 16:05:09 -0800347 * Returns if the {@code Phone} can support additional calls.
348 *
349 * @return Whether the phone supports adding more calls.
350 */
351 public final boolean canAddCall() {
352 return mCanAddCall;
353 }
354
355 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700356 * Sets the microphone mute state. When this request is honored, there will be change to
357 * the {@link #getAudioState()}.
358 *
359 * @param state {@code true} if the microphone should be muted; {@code false} otherwise.
360 */
361 public final void setMuted(boolean state) {
362 mInCallAdapter.mute(state);
363 }
364
365 /**
366 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
367 * be change to the {@link #getAudioState()}.
368 *
369 * @param route The audio route to use.
370 */
371 public final void setAudioRoute(int route) {
372 mInCallAdapter.setAudioRoute(route);
373 }
374
375 /**
Hall Liua98f58b52017-11-07 17:59:28 -0800376 * Request audio routing to a specific bluetooth device. Calling this method may result in
377 * the device routing audio to a different bluetooth device than the one specified. A list of
378 * available devices can be obtained via {@link CallAudioState#getSupportedBluetoothDevices()}
379 *
380 * @param bluetoothAddress The address of the bluetooth device to connect to, as returned by
381 * {@link BluetoothDevice#getAddress()}, or {@code null} if no device is preferred.
382 */
383 public void requestBluetoothAudio(String bluetoothAddress) {
384 mInCallAdapter.requestBluetoothAudio(bluetoothAddress);
385 }
386
387 /**
Junhoedf3d822022-11-24 09:26:37 +0000388 * Request audio routing to a specific CallEndpoint. When this request is honored, there will
389 * be change to the {@link #getCurrentCallEndpoint()}.
390 *
391 * @param endpoint The call endpoint to use.
392 * @param executor The executor of where the callback will execute.
393 * @param callback The callback to notify the result of the endpoint change.
394 * @hide
395 */
396 public void requestCallEndpointChange(@NonNull CallEndpoint endpoint,
397 @NonNull @CallbackExecutor Executor executor,
398 @NonNull OutcomeReceiver<Void, CallEndpointException> callback) {
399 mInCallAdapter.requestCallEndpointChange(endpoint, executor, callback);
400 }
401
402 /**
Yorke Lee0d6ea712014-07-28 14:39:23 -0700403 * Turns the proximity sensor on. When this request is made, the proximity sensor will
404 * become active, and the touch screen and display will be turned off when the user's face
405 * is detected to be in close proximity to the screen. This operation is a no-op on devices
406 * that do not have a proximity sensor.
Tyler Gunn17933eb2019-03-05 13:58:45 -0800407 * <p>
408 * This API does not actually turn on the proximity sensor; apps should do this on their own if
409 * required.
Yorke Lee22244d02015-04-14 12:34:28 -0700410 * @hide
Yorke Lee0d6ea712014-07-28 14:39:23 -0700411 */
Tyler Gunn17933eb2019-03-05 13:58:45 -0800412 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 127403196)
Yorke Lee0d6ea712014-07-28 14:39:23 -0700413 public final void setProximitySensorOn() {
414 mInCallAdapter.turnProximitySensorOn();
415 }
416
417 /**
418 * Turns the proximity sensor off. When this request is made, the proximity sensor will
419 * become inactive, and no longer affect the touch screen and display. This operation is a
420 * no-op on devices that do not have a proximity sensor.
421 *
422 * @param screenOnImmediately If true, the screen will be turned on immediately if it was
423 * previously off. Otherwise, the screen will only be turned on after the proximity sensor
424 * is no longer triggered.
Tyler Gunn17933eb2019-03-05 13:58:45 -0800425 * <p>
426 * This API does not actually turn of the proximity sensor; apps should do this on their own if
427 * required.
Yorke Lee22244d02015-04-14 12:34:28 -0700428 * @hide
Yorke Lee0d6ea712014-07-28 14:39:23 -0700429 */
Tyler Gunn17933eb2019-03-05 13:58:45 -0800430 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 127403196)
Yorke Lee0d6ea712014-07-28 14:39:23 -0700431 public final void setProximitySensorOff(boolean screenOnImmediately) {
432 mInCallAdapter.turnProximitySensorOff(screenOnImmediately);
433 }
434
435 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700436 * Obtains the current phone call audio state of the {@code Phone}.
437 *
438 * @return An object encapsulating the audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700439 * @deprecated Use {@link #getCallAudioState()} instead.
Ihab Awade63fadb2014-07-09 21:52:04 -0700440 */
Yorke Lee4af59352015-05-13 14:14:54 -0700441 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700442 public final AudioState getAudioState() {
Yorke Lee4af59352015-05-13 14:14:54 -0700443 return new AudioState(mCallAudioState);
444 }
445
446 /**
447 * Obtains the current phone call audio state of the {@code Phone}.
448 *
449 * @return An object encapsulating the audio state.
450 */
451 public final CallAudioState getCallAudioState() {
452 return mCallAudioState;
Ihab Awade63fadb2014-07-09 21:52:04 -0700453 }
454
455 private void fireCallAdded(Call call) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700456 for (Listener listener : mListeners) {
457 listener.onCallAdded(this, call);
Ihab Awade63fadb2014-07-09 21:52:04 -0700458 }
459 }
460
461 private void fireCallRemoved(Call call) {
Pranav Madapurmath21712982023-01-20 16:32:14 +0000462 for (Listener listener : mListeners) {
463 listener.onCallRemoved(this, call);
Ihab Awade63fadb2014-07-09 21:52:04 -0700464 }
465 }
466
Yorke Lee4af59352015-05-13 14:14:54 -0700467 private void fireCallAudioStateChanged(CallAudioState audioState) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700468 for (Listener listener : mListeners) {
Yorke Lee4af59352015-05-13 14:14:54 -0700469 listener.onCallAudioStateChanged(this, audioState);
470 listener.onAudioStateChanged(this, new AudioState(audioState));
Ihab Awade63fadb2014-07-09 21:52:04 -0700471 }
472 }
473
474 private void fireBringToForeground(boolean showDialpad) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700475 for (Listener listener : mListeners) {
476 listener.onBringToForeground(this, showDialpad);
Ihab Awade63fadb2014-07-09 21:52:04 -0700477 }
478 }
479
Santos Cordon6c912b72014-11-07 16:05:09 -0800480 private void fireCanAddCallChanged(boolean canAddCall) {
481 for (Listener listener : mListeners) {
482 listener.onCanAddCallChanged(this, canAddCall);
483 }
484 }
485
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800486 private void fireSilenceRinger() {
487 for (Listener listener : mListeners) {
488 listener.onSilenceRinger(this);
489 }
490 }
491
Santos Cordon88b771d2014-07-19 13:10:40 -0700492 private void checkCallTree(ParcelableCall parcelableCall) {
Santos Cordon88b771d2014-07-19 13:10:40 -0700493 if (parcelableCall.getChildCallIds() != null) {
494 for (int i = 0; i < parcelableCall.getChildCallIds().size(); i++) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700495 if (!mCallByTelecomCallId.containsKey(parcelableCall.getChildCallIds().get(i))) {
Santos Cordon88b771d2014-07-19 13:10:40 -0700496 Log.wtf(this, "ParcelableCall %s has nonexistent child %s",
497 parcelableCall.getId(), parcelableCall.getChildCallIds().get(i));
Ihab Awade63fadb2014-07-09 21:52:04 -0700498 }
499 }
500 }
501 }
502}