blob: 95a8e16ace3d1f41c14cf276ac82e16d5f1566d6 [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);
177 } else {
178 Log.w(this, "Call %s added, but it was already present", call.internalGetCallId());
179 checkCallTree(parcelableCall);
180 call.internalUpdate(parcelableCall, mCallByTelecomCallId);
181 }
Hall Liu31de23d2019-10-11 15:38:29 -0700182 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700183
Ihab Awade63fadb2014-07-09 21:52:04 -0700184 final void internalRemoveCall(Call call) {
Grace Jiac7173232021-07-15 11:36:49 -0700185 synchronized (mLock) {
186 mCallByTelecomCallId.remove(call.internalGetCallId());
187 mCalls.remove(call);
188 }
Tyler Gunn75958422015-04-15 14:23:42 -0700189
190 InCallService.VideoCall videoCall = call.getVideoCall();
191 if (videoCall != null) {
Andrew Lee011728f2015-04-23 15:47:06 -0700192 videoCall.destroy();
Tyler Gunn75958422015-04-15 14:23:42 -0700193 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700194 fireCallRemoved(call);
195 }
196
Santos Cordon88b771d2014-07-19 13:10:40 -0700197 final void internalUpdateCall(ParcelableCall parcelableCall) {
Hall Liu31de23d2019-10-11 15:38:29 -0700198 if (mTargetSdkVersion < SDK_VERSION_R
199 && parcelableCall.getState() == Call.STATE_AUDIO_PROCESSING) {
200 Log.i(this, "removing audio processing call during update for sdk compatibility");
Grace Jiac7173232021-07-15 11:36:49 -0700201 Call call = getCallById(parcelableCall.getId());
Hall Liu31de23d2019-10-11 15:38:29 -0700202 if (call != null) {
203 internalRemoveCall(call);
204 }
205 return;
206 }
207
Grace Jiac7173232021-07-15 11:36:49 -0700208 Call call = getCallById(parcelableCall.getId());
Hall Liu31de23d2019-10-11 15:38:29 -0700209 if (call != null) {
210 checkCallTree(parcelableCall);
211 call.internalUpdate(parcelableCall, mCallByTelecomCallId);
212 } else {
213 // This call may have come out of audio processing. Try adding it if our target sdk
214 // version is low enough.
Hall Liufc2be9c2019-11-08 18:26:47 -0800215 // The only two allowable states coming out of audio processing are ACTIVE and
216 // SIMULATED_RINGING.
217 if (mTargetSdkVersion < SDK_VERSION_R && (parcelableCall.getState() == Call.STATE_ACTIVE
218 || parcelableCall.getState() == Call.STATE_SIMULATED_RINGING)) {
219 Log.i(this, "adding call during update for sdk compatibility");
Hall Liu31de23d2019-10-11 15:38:29 -0700220 internalAddCall(parcelableCall);
221 }
222 }
223 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700224
Grace Jiac7173232021-07-15 11:36:49 -0700225 Call getCallById(String callId) {
226 synchronized (mLock) {
227 return mCallByTelecomCallId.get(callId);
228 }
229 }
230
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700231 final void internalSetPostDialWait(String telecomId, String remaining) {
Grace Jiac7173232021-07-15 11:36:49 -0700232 Call call = getCallById(telecomId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700233 if (call != null) {
234 call.internalSetPostDialWait(remaining);
235 }
236 }
237
Yorke Lee4af59352015-05-13 14:14:54 -0700238 final void internalCallAudioStateChanged(CallAudioState callAudioState) {
239 if (!Objects.equals(mCallAudioState, callAudioState)) {
240 mCallAudioState = callAudioState;
241 fireCallAudioStateChanged(callAudioState);
Ihab Awade63fadb2014-07-09 21:52:04 -0700242 }
243 }
244
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700245 final Call internalGetCallByTelecomId(String telecomId) {
Grace Jiac7173232021-07-15 11:36:49 -0700246 return getCallById(telecomId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700247 }
248
Ihab Awade63fadb2014-07-09 21:52:04 -0700249 final void internalBringToForeground(boolean showDialpad) {
250 fireBringToForeground(showDialpad);
251 }
252
Santos Cordon6c912b72014-11-07 16:05:09 -0800253 final void internalSetCanAddCall(boolean canAddCall) {
254 if (mCanAddCall != canAddCall) {
255 mCanAddCall = canAddCall;
256 fireCanAddCallChanged(canAddCall);
257 }
258 }
259
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800260 final void internalSilenceRinger() {
261 fireSilenceRinger();
262 }
263
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700264 final void internalOnConnectionEvent(String telecomId, String event, Bundle extras) {
Grace Jiac7173232021-07-15 11:36:49 -0700265 Call call = getCallById(telecomId);
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700266 if (call != null) {
267 call.internalOnConnectionEvent(event, extras);
268 }
269 }
270
Hall Liu95d55872017-01-25 17:12:49 -0800271 final void internalOnRttUpgradeRequest(String callId, int requestId) {
Grace Jiac7173232021-07-15 11:36:49 -0700272 Call call = getCallById(callId);
Hall Liu95d55872017-01-25 17:12:49 -0800273 if (call != null) {
274 call.internalOnRttUpgradeRequest(requestId);
275 }
276 }
277
Hall Liu57006aa2017-02-06 10:49:48 -0800278 final void internalOnRttInitiationFailure(String callId, int reason) {
Grace Jiac7173232021-07-15 11:36:49 -0700279 Call call = getCallById(callId);
Hall Liu57006aa2017-02-06 10:49:48 -0800280 if (call != null) {
281 call.internalOnRttInitiationFailure(reason);
282 }
283 }
284
Sanket Padawe85291f62017-12-01 13:59:27 -0800285 final void internalOnHandoverFailed(String callId, int error) {
Grace Jiac7173232021-07-15 11:36:49 -0700286 Call call = getCallById(callId);
Sanket Padawe85291f62017-12-01 13:59:27 -0800287 if (call != null) {
288 call.internalOnHandoverFailed(error);
289 }
290 }
291
Tyler Gunn858bfaf2018-01-22 15:17:54 -0800292 final void internalOnHandoverComplete(String callId) {
Grace Jiac7173232021-07-15 11:36:49 -0700293 Call call = getCallById(callId);
Tyler Gunn858bfaf2018-01-22 15:17:54 -0800294 if (call != null) {
295 call.internalOnHandoverComplete();
296 }
297 }
298
Ihab Awade63fadb2014-07-09 21:52:04 -0700299 /**
Santos Cordonf30d7e92014-08-26 09:54:33 -0700300 * Called to destroy the phone and cleanup any lingering calls.
Santos Cordonf30d7e92014-08-26 09:54:33 -0700301 */
302 final void destroy() {
303 for (Call call : mCalls) {
Tyler Gunn75958422015-04-15 14:23:42 -0700304 InCallService.VideoCall videoCall = call.getVideoCall();
305 if (videoCall != null) {
Andrew Lee011728f2015-04-23 15:47:06 -0700306 videoCall.destroy();
Tyler Gunn75958422015-04-15 14:23:42 -0700307 }
Santos Cordonf30d7e92014-08-26 09:54:33 -0700308 if (call.getState() != Call.STATE_DISCONNECTED) {
309 call.internalSetDisconnected();
310 }
311 }
312 }
313
314 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700315 * Adds a listener to this {@code Phone}.
316 *
317 * @param listener A {@code Listener} object.
318 */
319 public final void addListener(Listener listener) {
320 mListeners.add(listener);
321 }
322
323 /**
324 * Removes a listener from this {@code Phone}.
325 *
326 * @param listener A {@code Listener} object.
327 */
328 public final void removeListener(Listener listener) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700329 if (listener != null) {
330 mListeners.remove(listener);
331 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700332 }
333
334 /**
335 * Obtains the current list of {@code Call}s to be displayed by this in-call experience.
336 *
337 * @return A list of the relevant {@code Call}s.
338 */
339 public final List<Call> getCalls() {
340 return mUnmodifiableCalls;
341 }
342
343 /**
Santos Cordon6c912b72014-11-07 16:05:09 -0800344 * Returns if the {@code Phone} can support additional calls.
345 *
346 * @return Whether the phone supports adding more calls.
347 */
348 public final boolean canAddCall() {
349 return mCanAddCall;
350 }
351
352 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700353 * Sets the microphone mute state. When this request is honored, there will be change to
354 * the {@link #getAudioState()}.
355 *
356 * @param state {@code true} if the microphone should be muted; {@code false} otherwise.
357 */
358 public final void setMuted(boolean state) {
359 mInCallAdapter.mute(state);
360 }
361
362 /**
363 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
364 * be change to the {@link #getAudioState()}.
365 *
366 * @param route The audio route to use.
367 */
368 public final void setAudioRoute(int route) {
369 mInCallAdapter.setAudioRoute(route);
370 }
371
372 /**
Hall Liua98f58b52017-11-07 17:59:28 -0800373 * Request audio routing to a specific bluetooth device. Calling this method may result in
374 * the device routing audio to a different bluetooth device than the one specified. A list of
375 * available devices can be obtained via {@link CallAudioState#getSupportedBluetoothDevices()}
376 *
377 * @param bluetoothAddress The address of the bluetooth device to connect to, as returned by
378 * {@link BluetoothDevice#getAddress()}, or {@code null} if no device is preferred.
379 */
380 public void requestBluetoothAudio(String bluetoothAddress) {
381 mInCallAdapter.requestBluetoothAudio(bluetoothAddress);
382 }
383
384 /**
Junhoedf3d822022-11-24 09:26:37 +0000385 * Request audio routing to a specific CallEndpoint. When this request is honored, there will
386 * be change to the {@link #getCurrentCallEndpoint()}.
387 *
388 * @param endpoint The call endpoint to use.
389 * @param executor The executor of where the callback will execute.
390 * @param callback The callback to notify the result of the endpoint change.
391 * @hide
392 */
393 public void requestCallEndpointChange(@NonNull CallEndpoint endpoint,
394 @NonNull @CallbackExecutor Executor executor,
395 @NonNull OutcomeReceiver<Void, CallEndpointException> callback) {
396 mInCallAdapter.requestCallEndpointChange(endpoint, executor, callback);
397 }
398
399 /**
Yorke Lee0d6ea712014-07-28 14:39:23 -0700400 * Turns the proximity sensor on. When this request is made, the proximity sensor will
401 * become active, and the touch screen and display will be turned off when the user's face
402 * is detected to be in close proximity to the screen. This operation is a no-op on devices
403 * that do not have a proximity sensor.
Tyler Gunn17933eb2019-03-05 13:58:45 -0800404 * <p>
405 * This API does not actually turn on the proximity sensor; apps should do this on their own if
406 * required.
Yorke Lee22244d02015-04-14 12:34:28 -0700407 * @hide
Yorke Lee0d6ea712014-07-28 14:39:23 -0700408 */
Tyler Gunn17933eb2019-03-05 13:58:45 -0800409 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 127403196)
Yorke Lee0d6ea712014-07-28 14:39:23 -0700410 public final void setProximitySensorOn() {
411 mInCallAdapter.turnProximitySensorOn();
412 }
413
414 /**
415 * Turns the proximity sensor off. When this request is made, the proximity sensor will
416 * become inactive, and no longer affect the touch screen and display. This operation is a
417 * no-op on devices that do not have a proximity sensor.
418 *
419 * @param screenOnImmediately If true, the screen will be turned on immediately if it was
420 * previously off. Otherwise, the screen will only be turned on after the proximity sensor
421 * is no longer triggered.
Tyler Gunn17933eb2019-03-05 13:58:45 -0800422 * <p>
423 * This API does not actually turn of the proximity sensor; apps should do this on their own if
424 * required.
Yorke Lee22244d02015-04-14 12:34:28 -0700425 * @hide
Yorke Lee0d6ea712014-07-28 14:39:23 -0700426 */
Tyler Gunn17933eb2019-03-05 13:58:45 -0800427 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 127403196)
Yorke Lee0d6ea712014-07-28 14:39:23 -0700428 public final void setProximitySensorOff(boolean screenOnImmediately) {
429 mInCallAdapter.turnProximitySensorOff(screenOnImmediately);
430 }
431
432 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700433 * Obtains the current phone call audio state of the {@code Phone}.
434 *
435 * @return An object encapsulating the audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700436 * @deprecated Use {@link #getCallAudioState()} instead.
Ihab Awade63fadb2014-07-09 21:52:04 -0700437 */
Yorke Lee4af59352015-05-13 14:14:54 -0700438 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700439 public final AudioState getAudioState() {
Yorke Lee4af59352015-05-13 14:14:54 -0700440 return new AudioState(mCallAudioState);
441 }
442
443 /**
444 * Obtains the current phone call audio state of the {@code Phone}.
445 *
446 * @return An object encapsulating the audio state.
447 */
448 public final CallAudioState getCallAudioState() {
449 return mCallAudioState;
Ihab Awade63fadb2014-07-09 21:52:04 -0700450 }
451
452 private void fireCallAdded(Call call) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700453 for (Listener listener : mListeners) {
454 listener.onCallAdded(this, call);
Ihab Awade63fadb2014-07-09 21:52:04 -0700455 }
456 }
457
458 private void fireCallRemoved(Call call) {
Pranav Madapurmath21712982023-01-20 16:32:14 +0000459 for (Listener listener : mListeners) {
460 listener.onCallRemoved(this, call);
Ihab Awade63fadb2014-07-09 21:52:04 -0700461 }
462 }
463
Yorke Lee4af59352015-05-13 14:14:54 -0700464 private void fireCallAudioStateChanged(CallAudioState audioState) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700465 for (Listener listener : mListeners) {
Yorke Lee4af59352015-05-13 14:14:54 -0700466 listener.onCallAudioStateChanged(this, audioState);
467 listener.onAudioStateChanged(this, new AudioState(audioState));
Ihab Awade63fadb2014-07-09 21:52:04 -0700468 }
469 }
470
471 private void fireBringToForeground(boolean showDialpad) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700472 for (Listener listener : mListeners) {
473 listener.onBringToForeground(this, showDialpad);
Ihab Awade63fadb2014-07-09 21:52:04 -0700474 }
475 }
476
Santos Cordon6c912b72014-11-07 16:05:09 -0800477 private void fireCanAddCallChanged(boolean canAddCall) {
478 for (Listener listener : mListeners) {
479 listener.onCanAddCallChanged(this, canAddCall);
480 }
481 }
482
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800483 private void fireSilenceRinger() {
484 for (Listener listener : mListeners) {
485 listener.onSilenceRinger(this);
486 }
487 }
488
Santos Cordon88b771d2014-07-19 13:10:40 -0700489 private void checkCallTree(ParcelableCall parcelableCall) {
Santos Cordon88b771d2014-07-19 13:10:40 -0700490 if (parcelableCall.getChildCallIds() != null) {
491 for (int i = 0; i < parcelableCall.getChildCallIds().size(); i++) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700492 if (!mCallByTelecomCallId.containsKey(parcelableCall.getChildCallIds().get(i))) {
Santos Cordon88b771d2014-07-19 13:10:40 -0700493 Log.wtf(this, "ParcelableCall %s has nonexistent child %s",
494 parcelableCall.getId(), parcelableCall.getChildCallIds().get(i));
Ihab Awade63fadb2014-07-09 21:52:04 -0700495 }
496 }
497 }
498 }
499}