blob: bbf338455cfb6a72c4e10e232a392bebc02c9f9c [file] [log] [blame]
Ihab Awade63fadb2014-07-09 21:52:04 -07001/*
2 * Copyright (C) 2014 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
Gabriel Pealb95f1692014-08-19 14:24:18 -070019import android.annotation.SystemApi;
Ihab Awade63fadb2014-07-09 21:52:04 -070020import android.net.Uri;
Nancy Chen10798dc2014-08-08 14:00:25 -070021import android.os.Bundle;
Ihab Awade63fadb2014-07-09 21:52:04 -070022
Andrew Lee50aca232014-07-22 16:41:54 -070023import java.lang.String;
Ihab Awade63fadb2014-07-09 21:52:04 -070024import java.util.ArrayList;
25import java.util.Collections;
26import java.util.List;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070027import java.util.Map;
Ihab Awade63fadb2014-07-09 21:52:04 -070028import java.util.Objects;
Jay Shrauner229e3822014-08-15 09:23:07 -070029import java.util.concurrent.CopyOnWriteArrayList;
Ihab Awade63fadb2014-07-09 21:52:04 -070030
31/**
32 * Represents an ongoing phone call that the in-call app should present to the user.
Ihab Awadb19a0bc2014-08-07 19:46:01 -070033 *
34 * {@hide}
Ihab Awade63fadb2014-07-09 21:52:04 -070035 */
Gabriel Pealb95f1692014-08-19 14:24:18 -070036@SystemApi
Ihab Awade63fadb2014-07-09 21:52:04 -070037public final class Call {
38 /**
39 * The state of a {@code Call} when newly created.
40 */
41 public static final int STATE_NEW = 0;
42
43 /**
44 * The state of an outgoing {@code Call} when dialing the remote number, but not yet connected.
45 */
46 public static final int STATE_DIALING = 1;
47
48 /**
49 * The state of an incoming {@code Call} when ringing locally, but not yet connected.
50 */
51 public static final int STATE_RINGING = 2;
52
53 /**
54 * The state of a {@code Call} when in a holding state.
55 */
56 public static final int STATE_HOLDING = 3;
57
58 /**
59 * The state of a {@code Call} when actively supporting conversation.
60 */
61 public static final int STATE_ACTIVE = 4;
62
63 /**
64 * The state of a {@code Call} when no further voice or other communication is being
65 * transmitted, the remote side has been or will inevitably be informed that the {@code Call}
66 * is no longer active, and the local data transport has or inevitably will release resources
67 * associated with this {@code Call}.
68 */
69 public static final int STATE_DISCONNECTED = 7;
70
Nancy Chen5da0fd52014-07-08 14:16:17 -070071 /**
72 * The state of an outgoing {@code Call}, but waiting for user input before proceeding.
73 */
74 public static final int STATE_PRE_DIAL_WAIT = 8;
75
Nancy Chene20930f2014-08-07 16:17:21 -070076 /**
Nancy Chene9b7a8e2014-08-08 14:26:27 -070077 * The initial state of an outgoing {@code Call}.
78 * Common transitions are to {@link #STATE_DIALING} state for a successful call or
79 * {@link #STATE_DISCONNECTED} if it failed.
Nancy Chene20930f2014-08-07 16:17:21 -070080 */
81 public static final int STATE_CONNECTING = 9;
82
Nancy Chen513c8922014-09-17 14:47:20 -070083 /**
Tyler Gunn4afc6af2014-10-07 10:14:55 -070084 * The state of a {@code Call} when the user has initiated a disconnection of the call, but the
85 * call has not yet been disconnected by the underlying {@code ConnectionService}. The next
86 * state of the call is (potentially) {@link #STATE_DISCONNECTED}.
87 */
88 public static final int STATE_DISCONNECTING = 10;
89
90 /**
Nancy Chen513c8922014-09-17 14:47:20 -070091 * The key to retrieve the optional {@code PhoneAccount}s Telecom can bundle with its Call
92 * extras. Used to pass the phone accounts to display on the front end to the user in order to
93 * select phone accounts to (for example) place a call.
94 *
95 * @hide
96 */
97 public static final String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts";
98
Ihab Awade63fadb2014-07-09 21:52:04 -070099 public static class Details {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800100
101 /** Call can currently be put on hold or unheld. */
102 public static final int CAPABILITY_HOLD = 0x00000001;
103
104 /** Call supports the hold feature. */
105 public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002;
106
107 /**
108 * Calls within a conference can be merged. A {@link ConnectionService} has the option to
109 * add a {@link Conference} call before the child {@link Connection}s are merged. This is how
110 * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
111 * capability allows a merge button to be shown while the conference call is in the foreground
112 * of the in-call UI.
113 * <p>
114 * This is only intended for use by a {@link Conference}.
115 */
116 public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004;
117
118 /**
119 * Calls within a conference can be swapped between foreground and background.
120 * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information.
121 * <p>
122 * This is only intended for use by a {@link Conference}.
123 */
124 public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008;
125
126 /**
127 * @hide
128 */
129 public static final int CAPABILITY_UNUSED = 0x00000010;
130
131 /** Call supports responding via text option. */
132 public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020;
133
134 /** Call can be muted. */
135 public static final int CAPABILITY_MUTE = 0x00000040;
136
137 /**
138 * Call supports conference call management. This capability only applies to {@link Conference}
139 * calls which can have {@link Connection}s as children.
140 */
141 public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080;
142
143 /**
144 * Local device supports video telephony.
145 * @hide
146 */
147 public static final int CAPABILITY_SUPPORTS_VT_LOCAL = 0x00000100;
148
149 /**
150 * Remote device supports video telephony.
151 * @hide
152 */
153 public static final int CAPABILITY_SUPPORTS_VT_REMOTE = 0x00000200;
154
155 /**
Andrew Lee80fff3c2014-11-25 17:36:51 -0800156 * Call is using high definition audio.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800157 * @hide
158 */
Andrew Lee80fff3c2014-11-25 17:36:51 -0800159 public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00000400;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800160
161 /**
162 * Call is using voice over WIFI.
163 * @hide
164 */
165 public static final int CAPABILITY_VoWIFI = 0x00000800;
166
167 /**
168 * Call is able to be separated from its parent {@code Conference}, if any.
169 */
170 public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000;
171
172 /**
173 * Call is able to be individually disconnected when in a {@code Conference}.
174 */
175 public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000;
176
177 /**
178 * Whether the call is a generic conference, where we do not know the precise state of
179 * participants in the conference (eg. on CDMA).
180 *
181 * @hide
182 */
183 public static final int CAPABILITY_GENERIC_CONFERENCE = 0x00004000;
184
Ihab Awade63fadb2014-07-09 21:52:04 -0700185 private final Uri mHandle;
186 private final int mHandlePresentation;
187 private final String mCallerDisplayName;
188 private final int mCallerDisplayNamePresentation;
Evan Charlton8c8a0622014-07-20 12:31:00 -0700189 private final PhoneAccountHandle mAccountHandle;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700190 private final int mCallCapabilities;
Andrew Lee223ad142014-08-27 16:33:08 -0700191 private final int mCallProperties;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700192 private final DisconnectCause mDisconnectCause;
Ihab Awade63fadb2014-07-09 21:52:04 -0700193 private final long mConnectTimeMillis;
194 private final GatewayInfo mGatewayInfo;
Andrew Lee85f5d422014-07-11 17:22:03 -0700195 private final int mVideoState;
Evan Charlton5b49ade2014-07-15 17:03:20 -0700196 private final StatusHints mStatusHints;
Nancy Chen10798dc2014-08-08 14:00:25 -0700197 private final Bundle mExtras;
Ihab Awade63fadb2014-07-09 21:52:04 -0700198
199 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800200 * Whether the supplied capabilities supports the specified capability.
201 *
202 * @param capabilities A bit field of capabilities.
203 * @param capability The capability to check capabilities for.
204 * @return Whether the specified capability is supported.
205 * @hide
206 */
207 public static boolean can(int capabilities, int capability) {
208 return (capabilities & capability) != 0;
209 }
210
211 /**
212 * Whether the capabilities of this {@code Details} supports the specified capability.
213 *
214 * @param capability The capability to check capabilities for.
215 * @return Whether the specified capability is supported.
216 * @hide
217 */
218 public boolean can(int capability) {
219 return can(mCallCapabilities, capability);
220 }
221
222 /**
223 * Render a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
224 *
225 * @param capabilities A capability bit field.
226 * @return A human readable string representation.
227 */
228 public static String capabilitiesToString(int capabilities) {
229 StringBuilder builder = new StringBuilder();
230 builder.append("[Capabilities:");
231 if (can(capabilities, CAPABILITY_HOLD)) {
232 builder.append(" CAPABILITY_HOLD");
233 }
234 if (can(capabilities, CAPABILITY_SUPPORT_HOLD)) {
235 builder.append(" CAPABILITY_SUPPORT_HOLD");
236 }
237 if (can(capabilities, CAPABILITY_MERGE_CONFERENCE)) {
238 builder.append(" CAPABILITY_MERGE_CONFERENCE");
239 }
240 if (can(capabilities, CAPABILITY_SWAP_CONFERENCE)) {
241 builder.append(" CAPABILITY_SWAP_CONFERENCE");
242 }
243 if (can(capabilities, CAPABILITY_RESPOND_VIA_TEXT)) {
244 builder.append(" CAPABILITY_RESPOND_VIA_TEXT");
245 }
246 if (can(capabilities, CAPABILITY_MUTE)) {
247 builder.append(" CAPABILITY_MUTE");
248 }
249 if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) {
250 builder.append(" CAPABILITY_MANAGE_CONFERENCE");
251 }
252 if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL)) {
253 builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL");
254 }
255 if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE)) {
256 builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE");
257 }
Andrew Lee80fff3c2014-11-25 17:36:51 -0800258 if (can(capabilities, CAPABILITY_HIGH_DEF_AUDIO)) {
259 builder.append(" CAPABILITY_HIGH_DEF_AUDIO");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800260 }
261 if (can(capabilities, CAPABILITY_VoWIFI)) {
262 builder.append(" CAPABILITY_VoWIFI");
263 }
264 if (can(capabilities, CAPABILITY_GENERIC_CONFERENCE)) {
265 builder.append(" CAPABILITY_GENERIC_CONFERENCE");
266 }
267 builder.append("]");
268 return builder.toString();
269 }
270
271 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700272 * @return The handle (e.g., phone number) to which the {@code Call} is currently
273 * connected.
274 */
275 public Uri getHandle() {
276 return mHandle;
277 }
278
279 /**
280 * @return The presentation requirements for the handle. See
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700281 * {@link TelecomManager} for valid values.
Ihab Awade63fadb2014-07-09 21:52:04 -0700282 */
283 public int getHandlePresentation() {
284 return mHandlePresentation;
285 }
286
287 /**
288 * @return The display name for the caller.
289 */
290 public String getCallerDisplayName() {
291 return mCallerDisplayName;
292 }
293
294 /**
295 * @return The presentation requirements for the caller display name. See
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700296 * {@link TelecomManager} for valid values.
Ihab Awade63fadb2014-07-09 21:52:04 -0700297 */
298 public int getCallerDisplayNamePresentation() {
299 return mCallerDisplayNamePresentation;
300 }
301
302 /**
Evan Charlton6eb262c2014-07-19 18:18:19 -0700303 * @return The {@code PhoneAccountHandle} whereby the {@code Call} is currently being
304 * routed.
Ihab Awade63fadb2014-07-09 21:52:04 -0700305 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700306 public PhoneAccountHandle getAccountHandle() {
307 return mAccountHandle;
Ihab Awade63fadb2014-07-09 21:52:04 -0700308 }
309
310 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800311 * @return A bitmask of the capabilities of the {@code Call}, as defined by the various
312 * {@code CAPABILITY_*} constants in this class.
Ihab Awade63fadb2014-07-09 21:52:04 -0700313 */
Ihab Awad5d0410f2014-07-30 10:07:40 -0700314 public int getCallCapabilities() {
315 return mCallCapabilities;
Ihab Awade63fadb2014-07-09 21:52:04 -0700316 }
317
318 /**
Andrew Lee223ad142014-08-27 16:33:08 -0700319 * @return A bitmask of the properties of the {@code Call}, as defined in
320 * {@link CallProperties}.
321 */
322 public int getCallProperties() {
323 return mCallProperties;
324 }
325
326 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700327 * @return For a {@link #STATE_DISCONNECTED} {@code Call}, the disconnect cause expressed
Nancy Chenf4cf77c2014-09-19 10:53:21 -0700328 * by {@link android.telecom.DisconnectCause}.
Ihab Awade63fadb2014-07-09 21:52:04 -0700329 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700330 public DisconnectCause getDisconnectCause() {
331 return mDisconnectCause;
Ihab Awade63fadb2014-07-09 21:52:04 -0700332 }
333
334 /**
335 * @return The time the {@code Call} has been connected. This information is updated
336 * periodically, but user interfaces should not rely on this to display any "call time
337 * clock".
338 */
339 public long getConnectTimeMillis() {
340 return mConnectTimeMillis;
341 }
342
343 /**
344 * @return Information about any calling gateway the {@code Call} may be using.
345 */
346 public GatewayInfo getGatewayInfo() {
347 return mGatewayInfo;
348 }
349
Andrew Lee7a341382014-07-15 17:05:08 -0700350 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700351 * @return The video state of the {@code Call}.
Andrew Lee7a341382014-07-15 17:05:08 -0700352 */
353 public int getVideoState() {
354 return mVideoState;
355 }
356
Ihab Awad5d0410f2014-07-30 10:07:40 -0700357 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700358 * @return The current {@link android.telecom.StatusHints}, or {@code null} if none
Ihab Awad5d0410f2014-07-30 10:07:40 -0700359 * have been set.
Evan Charlton5b49ade2014-07-15 17:03:20 -0700360 */
361 public StatusHints getStatusHints() {
362 return mStatusHints;
363 }
364
Nancy Chen10798dc2014-08-08 14:00:25 -0700365 /**
366 * @return A bundle extras to pass with the call
367 */
368 public Bundle getExtras() {
369 return mExtras;
370 }
371
Ihab Awade63fadb2014-07-09 21:52:04 -0700372 @Override
373 public boolean equals(Object o) {
374 if (o instanceof Details) {
375 Details d = (Details) o;
376 return
377 Objects.equals(mHandle, d.mHandle) &&
378 Objects.equals(mHandlePresentation, d.mHandlePresentation) &&
379 Objects.equals(mCallerDisplayName, d.mCallerDisplayName) &&
380 Objects.equals(mCallerDisplayNamePresentation,
381 d.mCallerDisplayNamePresentation) &&
Evan Charlton8c8a0622014-07-20 12:31:00 -0700382 Objects.equals(mAccountHandle, d.mAccountHandle) &&
Ihab Awad5d0410f2014-07-30 10:07:40 -0700383 Objects.equals(mCallCapabilities, d.mCallCapabilities) &&
Andrew Lee223ad142014-08-27 16:33:08 -0700384 Objects.equals(mCallProperties, d.mCallProperties) &&
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700385 Objects.equals(mDisconnectCause, d.mDisconnectCause) &&
Ihab Awade63fadb2014-07-09 21:52:04 -0700386 Objects.equals(mConnectTimeMillis, d.mConnectTimeMillis) &&
Andrew Lee85f5d422014-07-11 17:22:03 -0700387 Objects.equals(mGatewayInfo, d.mGatewayInfo) &&
Evan Charlton5b49ade2014-07-15 17:03:20 -0700388 Objects.equals(mVideoState, d.mVideoState) &&
Nancy Chen10798dc2014-08-08 14:00:25 -0700389 Objects.equals(mStatusHints, d.mStatusHints) &&
390 Objects.equals(mExtras, d.mExtras);
Ihab Awade63fadb2014-07-09 21:52:04 -0700391 }
392 return false;
393 }
394
395 @Override
396 public int hashCode() {
397 return
398 Objects.hashCode(mHandle) +
399 Objects.hashCode(mHandlePresentation) +
400 Objects.hashCode(mCallerDisplayName) +
401 Objects.hashCode(mCallerDisplayNamePresentation) +
Evan Charlton8c8a0622014-07-20 12:31:00 -0700402 Objects.hashCode(mAccountHandle) +
Ihab Awad5d0410f2014-07-30 10:07:40 -0700403 Objects.hashCode(mCallCapabilities) +
Andrew Lee223ad142014-08-27 16:33:08 -0700404 Objects.hashCode(mCallProperties) +
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700405 Objects.hashCode(mDisconnectCause) +
Ihab Awade63fadb2014-07-09 21:52:04 -0700406 Objects.hashCode(mConnectTimeMillis) +
Andrew Lee85f5d422014-07-11 17:22:03 -0700407 Objects.hashCode(mGatewayInfo) +
Evan Charlton5b49ade2014-07-15 17:03:20 -0700408 Objects.hashCode(mVideoState) +
Nancy Chen10798dc2014-08-08 14:00:25 -0700409 Objects.hashCode(mStatusHints) +
410 Objects.hashCode(mExtras);
Ihab Awade63fadb2014-07-09 21:52:04 -0700411 }
412
413 /** {@hide} */
414 public Details(
415 Uri handle,
416 int handlePresentation,
417 String callerDisplayName,
418 int callerDisplayNamePresentation,
Evan Charlton8c8a0622014-07-20 12:31:00 -0700419 PhoneAccountHandle accountHandle,
Ihab Awade63fadb2014-07-09 21:52:04 -0700420 int capabilities,
Andrew Lee223ad142014-08-27 16:33:08 -0700421 int properties,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700422 DisconnectCause disconnectCause,
Ihab Awade63fadb2014-07-09 21:52:04 -0700423 long connectTimeMillis,
Andrew Lee85f5d422014-07-11 17:22:03 -0700424 GatewayInfo gatewayInfo,
Evan Charlton5b49ade2014-07-15 17:03:20 -0700425 int videoState,
Nancy Chen10798dc2014-08-08 14:00:25 -0700426 StatusHints statusHints,
427 Bundle extras) {
Ihab Awade63fadb2014-07-09 21:52:04 -0700428 mHandle = handle;
429 mHandlePresentation = handlePresentation;
430 mCallerDisplayName = callerDisplayName;
431 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Evan Charlton8c8a0622014-07-20 12:31:00 -0700432 mAccountHandle = accountHandle;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700433 mCallCapabilities = capabilities;
Andrew Lee223ad142014-08-27 16:33:08 -0700434 mCallProperties = properties;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700435 mDisconnectCause = disconnectCause;
Ihab Awade63fadb2014-07-09 21:52:04 -0700436 mConnectTimeMillis = connectTimeMillis;
437 mGatewayInfo = gatewayInfo;
Andrew Lee85f5d422014-07-11 17:22:03 -0700438 mVideoState = videoState;
Evan Charlton5b49ade2014-07-15 17:03:20 -0700439 mStatusHints = statusHints;
Nancy Chen10798dc2014-08-08 14:00:25 -0700440 mExtras = extras;
Ihab Awade63fadb2014-07-09 21:52:04 -0700441 }
442 }
443
444 public static abstract class Listener {
445 /**
446 * Invoked when the state of this {@code Call} has changed. See {@link #getState()}.
447 *
Ihab Awade63fadb2014-07-09 21:52:04 -0700448 * @param call The {@code Call} invoking this method.
449 * @param state The new state of the {@code Call}.
450 */
451 public void onStateChanged(Call call, int state) {}
452
453 /**
454 * Invoked when the parent of this {@code Call} has changed. See {@link #getParent()}.
455 *
456 * @param call The {@code Call} invoking this method.
457 * @param parent The new parent of the {@code Call}.
458 */
459 public void onParentChanged(Call call, Call parent) {}
460
461 /**
462 * Invoked when the children of this {@code Call} have changed. See {@link #getChildren()}.
463 *
464 * @param call The {@code Call} invoking this method.
465 * @param children The new children of the {@code Call}.
466 */
467 public void onChildrenChanged(Call call, List<Call> children) {}
468
469 /**
470 * Invoked when the details of this {@code Call} have changed. See {@link #getDetails()}.
471 *
472 * @param call The {@code Call} invoking this method.
473 * @param details A {@code Details} object describing the {@code Call}.
474 */
475 public void onDetailsChanged(Call call, Details details) {}
476
477 /**
478 * Invoked when the text messages that can be used as responses to the incoming
479 * {@code Call} are loaded from the relevant database.
480 * See {@link #getCannedTextResponses()}.
481 *
482 * @param call The {@code Call} invoking this method.
483 * @param cannedTextResponses The text messages useable as responses.
484 */
485 public void onCannedTextResponsesLoaded(Call call, List<String> cannedTextResponses) {}
486
487 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700488 * Invoked when the post-dial sequence in the outgoing {@code Call} has reached a pause
489 * character. This causes the post-dial signals to stop pending user confirmation. An
490 * implementation should present this choice to the user and invoke
491 * {@link #postDialContinue(boolean)} when the user makes the choice.
492 *
493 * @param call The {@code Call} invoking this method.
494 * @param remainingPostDialSequence The post-dial characters that remain to be sent.
495 */
496 public void onPostDialWait(Call call, String remainingPostDialSequence) {}
497
498 /**
Andrew Lee50aca232014-07-22 16:41:54 -0700499 * Invoked when the {@code Call.VideoCall} of the {@code Call} has changed.
Ihab Awade63fadb2014-07-09 21:52:04 -0700500 *
501 * @param call The {@code Call} invoking this method.
Andrew Lee50aca232014-07-22 16:41:54 -0700502 * @param videoCall The {@code Call.VideoCall} associated with the {@code Call}.
Tyler Gunn75537ae2014-08-22 11:33:13 -0700503 * @hide
Ihab Awade63fadb2014-07-09 21:52:04 -0700504 */
Andrew Lee50aca232014-07-22 16:41:54 -0700505 public void onVideoCallChanged(Call call, InCallService.VideoCall videoCall) {}
Ihab Awade63fadb2014-07-09 21:52:04 -0700506
507 /**
508 * Invoked when the {@code Call} is destroyed. Clients should refrain from cleaning
509 * up their UI for the {@code Call} in response to state transitions. Specifically,
510 * clients should not assume that a {@link #onStateChanged(Call, int)} with a state of
511 * {@link #STATE_DISCONNECTED} is the final notification the {@code Call} will send. Rather,
512 * clients should wait for this method to be invoked.
513 *
514 * @param call The {@code Call} being destroyed.
515 */
516 public void onCallDestroyed(Call call) {}
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700517
518 /**
519 * Invoked upon changes to the set of {@code Call}s with which this {@code Call} can be
520 * conferenced.
521 *
522 * @param call The {@code Call} being updated.
523 * @param conferenceableCalls The {@code Call}s with which this {@code Call} can be
524 * conferenced.
525 */
526 public void onConferenceableCallsChanged(Call call, List<Call> conferenceableCalls) {}
Ihab Awade63fadb2014-07-09 21:52:04 -0700527 }
528
529 private final Phone mPhone;
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700530 private final String mTelecomCallId;
Ihab Awade63fadb2014-07-09 21:52:04 -0700531 private final InCallAdapter mInCallAdapter;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700532 private final List<String> mChildrenIds = new ArrayList<>();
Ihab Awade63fadb2014-07-09 21:52:04 -0700533 private final List<Call> mChildren = new ArrayList<>();
534 private final List<Call> mUnmodifiableChildren = Collections.unmodifiableList(mChildren);
Jay Shrauner229e3822014-08-15 09:23:07 -0700535 private final List<Listener> mListeners = new CopyOnWriteArrayList<>();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700536 private final List<Call> mConferenceableCalls = new ArrayList<>();
537 private final List<Call> mUnmodifiableConferenceableCalls =
538 Collections.unmodifiableList(mConferenceableCalls);
539
Santos Cordon823fd3c2014-08-07 18:35:18 -0700540 private boolean mChildrenCached;
541 private String mParentId = null;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700542 private int mState;
Ihab Awade63fadb2014-07-09 21:52:04 -0700543 private List<String> mCannedTextResponses = null;
544 private String mRemainingPostDialSequence;
Andrew Lee50aca232014-07-22 16:41:54 -0700545 private InCallService.VideoCall mVideoCall;
Ihab Awade63fadb2014-07-09 21:52:04 -0700546 private Details mDetails;
Ihab Awade63fadb2014-07-09 21:52:04 -0700547
548 /**
549 * Obtains the post-dial sequence remaining to be emitted by this {@code Call}, if any.
550 *
551 * @return The remaining post-dial sequence, or {@code null} if there is no post-dial sequence
552 * remaining or this {@code Call} is not in a post-dial state.
553 */
554 public String getRemainingPostDialSequence() {
555 return mRemainingPostDialSequence;
556 }
557
558 /**
559 * Instructs this {@link #STATE_RINGING} {@code Call} to answer.
Andrew Lee8da4c3c2014-07-16 10:11:42 -0700560 * @param videoState The video state in which to answer the call.
Ihab Awade63fadb2014-07-09 21:52:04 -0700561 */
Andrew Lee8da4c3c2014-07-16 10:11:42 -0700562 public void answer(int videoState) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700563 mInCallAdapter.answerCall(mTelecomCallId, videoState);
Ihab Awade63fadb2014-07-09 21:52:04 -0700564 }
565
566 /**
567 * Instructs this {@link #STATE_RINGING} {@code Call} to reject.
568 *
569 * @param rejectWithMessage Whether to reject with a text message.
570 * @param textMessage An optional text message with which to respond.
571 */
572 public void reject(boolean rejectWithMessage, String textMessage) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700573 mInCallAdapter.rejectCall(mTelecomCallId, rejectWithMessage, textMessage);
Ihab Awade63fadb2014-07-09 21:52:04 -0700574 }
575
576 /**
577 * Instructs this {@code Call} to disconnect.
578 */
579 public void disconnect() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700580 mInCallAdapter.disconnectCall(mTelecomCallId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700581 }
582
583 /**
584 * Instructs this {@code Call} to go on hold.
585 */
586 public void hold() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700587 mInCallAdapter.holdCall(mTelecomCallId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700588 }
589
590 /**
591 * Instructs this {@link #STATE_HOLDING} call to release from hold.
592 */
593 public void unhold() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700594 mInCallAdapter.unholdCall(mTelecomCallId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700595 }
596
597 /**
598 * Instructs this {@code Call} to play a dual-tone multi-frequency signaling (DTMF) tone.
599 *
600 * Any other currently playing DTMF tone in the specified call is immediately stopped.
601 *
602 * @param digit A character representing the DTMF digit for which to play the tone. This
603 * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.
604 */
605 public void playDtmfTone(char digit) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700606 mInCallAdapter.playDtmfTone(mTelecomCallId, digit);
Ihab Awade63fadb2014-07-09 21:52:04 -0700607 }
608
609 /**
610 * Instructs this {@code Call} to stop any dual-tone multi-frequency signaling (DTMF) tone
611 * currently playing.
612 *
613 * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is
614 * currently playing, this method will do nothing.
615 */
616 public void stopDtmfTone() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700617 mInCallAdapter.stopDtmfTone(mTelecomCallId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700618 }
619
620 /**
621 * Instructs this {@code Call} to continue playing a post-dial DTMF string.
622 *
623 * A post-dial DTMF string is a string of digits entered after a phone number, when dialed,
624 * that are immediately sent as DTMF tones to the recipient as soon as the connection is made.
Ihab Awade63fadb2014-07-09 21:52:04 -0700625 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700626 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this
Ihab Awade63fadb2014-07-09 21:52:04 -0700627 * {@code Call} will temporarily pause playing the tones for a pre-defined period of time.
628 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700629 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this
Ihab Awade63fadb2014-07-09 21:52:04 -0700630 * {@code Call} will pause playing the tones and notify listeners via
631 * {@link Listener#onPostDialWait(Call, String)}. At this point, the in-call app
632 * should display to the user an indication of this state and an affordance to continue
633 * the postdial sequence. When the user decides to continue the postdial sequence, the in-call
634 * app should invoke the {@link #postDialContinue(boolean)} method.
635 *
636 * @param proceed Whether or not to continue with the post-dial sequence.
637 */
638 public void postDialContinue(boolean proceed) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700639 mInCallAdapter.postDialContinue(mTelecomCallId, proceed);
Ihab Awade63fadb2014-07-09 21:52:04 -0700640 }
641
642 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -0700643 * Notifies this {@code Call} that an account has been selected and to proceed with placing
Nancy Chen36c62f32014-10-21 18:36:39 -0700644 * an outgoing call. Optionally sets this account as the default account.
Nancy Chen5da0fd52014-07-08 14:16:17 -0700645 */
Nancy Chen36c62f32014-10-21 18:36:39 -0700646 public void phoneAccountSelected(PhoneAccountHandle accountHandle, boolean setDefault) {
647 mInCallAdapter.phoneAccountSelected(mTelecomCallId, accountHandle, setDefault);
Nancy Chen5da0fd52014-07-08 14:16:17 -0700648
649 }
650
651 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700652 * Instructs this {@code Call} to enter a conference.
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700653 *
654 * @param callToConferenceWith The other call with which to conference.
Ihab Awade63fadb2014-07-09 21:52:04 -0700655 */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700656 public void conference(Call callToConferenceWith) {
657 if (callToConferenceWith != null) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700658 mInCallAdapter.conference(mTelecomCallId, callToConferenceWith.mTelecomCallId);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700659 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700660 }
661
662 /**
663 * Instructs this {@code Call} to split from any conference call with which it may be
664 * connected.
665 */
666 public void splitFromConference() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700667 mInCallAdapter.splitFromConference(mTelecomCallId);
Ihab Awade63fadb2014-07-09 21:52:04 -0700668 }
669
670 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800671 * Merges the calls within this conference. See {@link Details#CAPABILITY_MERGE_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700672 */
673 public void mergeConference() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700674 mInCallAdapter.mergeConference(mTelecomCallId);
Santos Cordona4868042014-09-04 17:39:22 -0700675 }
676
677 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800678 * Swaps the calls within this conference. See {@link Details#CAPABILITY_SWAP_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700679 */
680 public void swapConference() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700681 mInCallAdapter.swapConference(mTelecomCallId);
Santos Cordona4868042014-09-04 17:39:22 -0700682 }
683
684 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700685 * Obtains the parent of this {@code Call} in a conference, if any.
686 *
687 * @return The parent {@code Call}, or {@code null} if this {@code Call} is not a
688 * child of any conference {@code Call}s.
689 */
690 public Call getParent() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700691 if (mParentId != null) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700692 return mPhone.internalGetCallByTelecomId(mParentId);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700693 }
694 return null;
Ihab Awade63fadb2014-07-09 21:52:04 -0700695 }
696
697 /**
698 * Obtains the children of this conference {@code Call}, if any.
699 *
700 * @return The children of this {@code Call} if this {@code Call} is a conference, or an empty
701 * {@code List} otherwise.
702 */
703 public List<Call> getChildren() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700704 if (!mChildrenCached) {
705 mChildrenCached = true;
706 mChildren.clear();
707
708 for(String id : mChildrenIds) {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700709 Call call = mPhone.internalGetCallByTelecomId(id);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700710 if (call == null) {
711 // At least one child was still not found, so do not save true for "cached"
712 mChildrenCached = false;
713 } else {
714 mChildren.add(call);
715 }
716 }
717 }
718
Ihab Awade63fadb2014-07-09 21:52:04 -0700719 return mUnmodifiableChildren;
720 }
721
722 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700723 * Returns the list of {@code Call}s with which this {@code Call} is allowed to conference.
724 *
725 * @return The list of conferenceable {@code Call}s.
726 */
727 public List<Call> getConferenceableCalls() {
728 return mUnmodifiableConferenceableCalls;
729 }
730
731 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700732 * Obtains the state of this {@code Call}.
733 *
734 * @return A state value, chosen from the {@code STATE_*} constants.
735 */
736 public int getState() {
737 return mState;
738 }
739
740 /**
741 * Obtains a list of canned, pre-configured message responses to present to the user as
742 * ways of rejecting this {@code Call} using via a text message.
743 *
744 * @see #reject(boolean, String)
745 *
746 * @return A list of canned text message responses.
747 */
748 public List<String> getCannedTextResponses() {
749 return mCannedTextResponses;
750 }
751
752 /**
753 * Obtains an object that can be used to display video from this {@code Call}.
754 *
Andrew Lee50aca232014-07-22 16:41:54 -0700755 * @return An {@code Call.VideoCall}.
Tyler Gunn75537ae2014-08-22 11:33:13 -0700756 * @hide
Ihab Awade63fadb2014-07-09 21:52:04 -0700757 */
Andrew Lee50aca232014-07-22 16:41:54 -0700758 public InCallService.VideoCall getVideoCall() {
759 return mVideoCall;
Ihab Awade63fadb2014-07-09 21:52:04 -0700760 }
761
762 /**
763 * Obtains an object containing call details.
764 *
765 * @return A {@link Details} object. Depending on the state of the {@code Call}, the
766 * result may be {@code null}.
767 */
768 public Details getDetails() {
769 return mDetails;
770 }
771
772 /**
773 * Adds a listener to this {@code Call}.
774 *
775 * @param listener A {@code Listener}.
776 */
777 public void addListener(Listener listener) {
778 mListeners.add(listener);
779 }
780
781 /**
782 * Removes a listener from this {@code Call}.
783 *
784 * @param listener A {@code Listener}.
785 */
786 public void removeListener(Listener listener) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700787 if (listener != null) {
788 mListeners.remove(listener);
789 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700790 }
791
792 /** {@hide} */
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700793 Call(Phone phone, String telecomCallId, InCallAdapter inCallAdapter) {
Ihab Awade63fadb2014-07-09 21:52:04 -0700794 mPhone = phone;
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700795 mTelecomCallId = telecomCallId;
Ihab Awade63fadb2014-07-09 21:52:04 -0700796 mInCallAdapter = inCallAdapter;
797 mState = STATE_NEW;
798 }
799
800 /** {@hide} */
801 final String internalGetCallId() {
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700802 return mTelecomCallId;
Ihab Awade63fadb2014-07-09 21:52:04 -0700803 }
804
805 /** {@hide} */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700806 final void internalUpdate(ParcelableCall parcelableCall, Map<String, Call> callIdMap) {
Ihab Awade63fadb2014-07-09 21:52:04 -0700807 // First, we update the internal state as far as possible before firing any updates.
Ihab Awade63fadb2014-07-09 21:52:04 -0700808 Details details = new Details(
Santos Cordon88b771d2014-07-19 13:10:40 -0700809 parcelableCall.getHandle(),
810 parcelableCall.getHandlePresentation(),
811 parcelableCall.getCallerDisplayName(),
812 parcelableCall.getCallerDisplayNamePresentation(),
813 parcelableCall.getAccountHandle(),
814 parcelableCall.getCapabilities(),
Andrew Lee223ad142014-08-27 16:33:08 -0700815 parcelableCall.getProperties(),
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700816 parcelableCall.getDisconnectCause(),
Santos Cordon88b771d2014-07-19 13:10:40 -0700817 parcelableCall.getConnectTimeMillis(),
818 parcelableCall.getGatewayInfo(),
819 parcelableCall.getVideoState(),
Nancy Chen10798dc2014-08-08 14:00:25 -0700820 parcelableCall.getStatusHints(),
821 parcelableCall.getExtras());
Ihab Awade63fadb2014-07-09 21:52:04 -0700822 boolean detailsChanged = !Objects.equals(mDetails, details);
823 if (detailsChanged) {
824 mDetails = details;
825 }
826
827 boolean cannedTextResponsesChanged = false;
Santos Cordon88b771d2014-07-19 13:10:40 -0700828 if (mCannedTextResponses == null && parcelableCall.getCannedSmsResponses() != null
829 && !parcelableCall.getCannedSmsResponses().isEmpty()) {
830 mCannedTextResponses =
831 Collections.unmodifiableList(parcelableCall.getCannedSmsResponses());
Ihab Awade63fadb2014-07-09 21:52:04 -0700832 }
833
Andrew Lee50aca232014-07-22 16:41:54 -0700834 boolean videoCallChanged = !Objects.equals(mVideoCall, parcelableCall.getVideoCall());
835 if (videoCallChanged) {
836 mVideoCall = parcelableCall.getVideoCall();
Ihab Awade63fadb2014-07-09 21:52:04 -0700837 }
838
Santos Cordon88b771d2014-07-19 13:10:40 -0700839 int state = stateFromParcelableCallState(parcelableCall.getState());
Ihab Awade63fadb2014-07-09 21:52:04 -0700840 boolean stateChanged = mState != state;
841 if (stateChanged) {
842 mState = state;
843 }
844
Santos Cordon823fd3c2014-08-07 18:35:18 -0700845 String parentId = parcelableCall.getParentCallId();
846 boolean parentChanged = !Objects.equals(mParentId, parentId);
847 if (parentChanged) {
848 mParentId = parentId;
Ihab Awade63fadb2014-07-09 21:52:04 -0700849 }
850
Santos Cordon823fd3c2014-08-07 18:35:18 -0700851 List<String> childCallIds = parcelableCall.getChildCallIds();
852 boolean childrenChanged = !Objects.equals(childCallIds, mChildrenIds);
853 if (childrenChanged) {
854 mChildrenIds.clear();
855 mChildrenIds.addAll(parcelableCall.getChildCallIds());
856 mChildrenCached = false;
Ihab Awade63fadb2014-07-09 21:52:04 -0700857 }
858
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700859 List<String> conferenceableCallIds = parcelableCall.getConferenceableCallIds();
860 List<Call> conferenceableCalls = new ArrayList<Call>(conferenceableCallIds.size());
861 for (String otherId : conferenceableCallIds) {
862 if (callIdMap.containsKey(otherId)) {
863 conferenceableCalls.add(callIdMap.get(otherId));
864 }
865 }
866
867 if (!Objects.equals(mConferenceableCalls, conferenceableCalls)) {
868 mConferenceableCalls.clear();
869 mConferenceableCalls.addAll(conferenceableCalls);
870 fireConferenceableCallsChanged();
871 }
872
Ihab Awade63fadb2014-07-09 21:52:04 -0700873 // Now we fire updates, ensuring that any client who listens to any of these notifications
874 // gets the most up-to-date state.
875
876 if (stateChanged) {
877 fireStateChanged(mState);
878 }
879 if (detailsChanged) {
880 fireDetailsChanged(mDetails);
881 }
882 if (cannedTextResponsesChanged) {
883 fireCannedTextResponsesLoaded(mCannedTextResponses);
884 }
Andrew Lee50aca232014-07-22 16:41:54 -0700885 if (videoCallChanged) {
886 fireVideoCallChanged(mVideoCall);
Ihab Awade63fadb2014-07-09 21:52:04 -0700887 }
Santos Cordon823fd3c2014-08-07 18:35:18 -0700888 if (parentChanged) {
889 fireParentChanged(getParent());
890 }
891 if (childrenChanged) {
892 fireChildrenChanged(getChildren());
893 }
Ihab Awade63fadb2014-07-09 21:52:04 -0700894
895 // If we have transitioned to DISCONNECTED, that means we need to notify clients and
896 // remove ourselves from the Phone. Note that we do this after completing all state updates
897 // so a client can cleanly transition all their UI to the state appropriate for a
898 // DISCONNECTED Call while still relying on the existence of that Call in the Phone's list.
899 if (mState == STATE_DISCONNECTED) {
900 fireCallDestroyed();
901 mPhone.internalRemoveCall(this);
902 }
903 }
904
905 /** {@hide} */
Ihab Awade63fadb2014-07-09 21:52:04 -0700906 final void internalSetPostDialWait(String remaining) {
907 mRemainingPostDialSequence = remaining;
908 firePostDialWait(mRemainingPostDialSequence);
909 }
910
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700911 /** {@hide} */
Santos Cordonf30d7e92014-08-26 09:54:33 -0700912 final void internalSetDisconnected() {
913 if (mState != Call.STATE_DISCONNECTED) {
914 mState = Call.STATE_DISCONNECTED;
915 fireStateChanged(mState);
916 fireCallDestroyed();
917 mPhone.internalRemoveCall(this);
918 }
919 }
920
Ihab Awade63fadb2014-07-09 21:52:04 -0700921 private void fireStateChanged(int newState) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700922 for (Listener listener : mListeners) {
923 listener.onStateChanged(this, newState);
Ihab Awade63fadb2014-07-09 21:52:04 -0700924 }
925 }
926
927 private void fireParentChanged(Call newParent) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700928 for (Listener listener : mListeners) {
929 listener.onParentChanged(this, newParent);
Ihab Awade63fadb2014-07-09 21:52:04 -0700930 }
931 }
932
933 private void fireChildrenChanged(List<Call> children) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700934 for (Listener listener : mListeners) {
935 listener.onChildrenChanged(this, children);
Ihab Awade63fadb2014-07-09 21:52:04 -0700936 }
937 }
938
939 private void fireDetailsChanged(Details details) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700940 for (Listener listener : mListeners) {
941 listener.onDetailsChanged(this, details);
Ihab Awade63fadb2014-07-09 21:52:04 -0700942 }
943 }
944
945 private void fireCannedTextResponsesLoaded(List<String> cannedTextResponses) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700946 for (Listener listener : mListeners) {
947 listener.onCannedTextResponsesLoaded(this, cannedTextResponses);
Ihab Awade63fadb2014-07-09 21:52:04 -0700948 }
949 }
950
Andrew Lee50aca232014-07-22 16:41:54 -0700951 private void fireVideoCallChanged(InCallService.VideoCall videoCall) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700952 for (Listener listener : mListeners) {
953 listener.onVideoCallChanged(this, videoCall);
Ihab Awade63fadb2014-07-09 21:52:04 -0700954 }
955 }
956
Ihab Awade63fadb2014-07-09 21:52:04 -0700957 private void firePostDialWait(String remainingPostDialSequence) {
Jay Shrauner229e3822014-08-15 09:23:07 -0700958 for (Listener listener : mListeners) {
959 listener.onPostDialWait(this, remainingPostDialSequence);
Ihab Awade63fadb2014-07-09 21:52:04 -0700960 }
961 }
962
963 private void fireCallDestroyed() {
Jay Shrauner229e3822014-08-15 09:23:07 -0700964 for (Listener listener : mListeners) {
965 listener.onCallDestroyed(this);
Ihab Awade63fadb2014-07-09 21:52:04 -0700966 }
967 }
968
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700969 private void fireConferenceableCallsChanged() {
Jay Shrauner229e3822014-08-15 09:23:07 -0700970 for (Listener listener : mListeners) {
971 listener.onConferenceableCallsChanged(this, mUnmodifiableConferenceableCalls);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700972 }
973 }
974
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700975 private int stateFromParcelableCallState(int parcelableCallState) {
Santos Cordon88b771d2014-07-19 13:10:40 -0700976 switch (parcelableCallState) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700977 case CallState.NEW:
Ihab Awade63fadb2014-07-09 21:52:04 -0700978 return STATE_NEW;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700979 case CallState.CONNECTING:
Nancy Chene20930f2014-08-07 16:17:21 -0700980 return STATE_CONNECTING;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700981 case CallState.PRE_DIAL_WAIT:
Nancy Chen5da0fd52014-07-08 14:16:17 -0700982 return STATE_PRE_DIAL_WAIT;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700983 case CallState.DIALING:
Ihab Awade63fadb2014-07-09 21:52:04 -0700984 return STATE_DIALING;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700985 case CallState.RINGING:
Ihab Awade63fadb2014-07-09 21:52:04 -0700986 return STATE_RINGING;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700987 case CallState.ACTIVE:
Ihab Awade63fadb2014-07-09 21:52:04 -0700988 return STATE_ACTIVE;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700989 case CallState.ON_HOLD:
Ihab Awade63fadb2014-07-09 21:52:04 -0700990 return STATE_HOLDING;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700991 case CallState.DISCONNECTED:
Ihab Awade63fadb2014-07-09 21:52:04 -0700992 return STATE_DISCONNECTED;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700993 case CallState.ABORTED:
Ihab Awade63fadb2014-07-09 21:52:04 -0700994 return STATE_DISCONNECTED;
Tyler Gunn4afc6af2014-10-07 10:14:55 -0700995 case CallState.DISCONNECTING:
996 return STATE_DISCONNECTING;
Ihab Awade63fadb2014-07-09 21:52:04 -0700997 default:
Santos Cordon88b771d2014-07-19 13:10:40 -0700998 Log.wtf(this, "Unrecognized CallState %s", parcelableCallState);
Ihab Awade63fadb2014-07-09 21:52:04 -0700999 return STATE_NEW;
1000 }
1001 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07001002}