blob: 6fa94b95e882bd06063eb5aa978ad38675a94891 [file] [log] [blame]
Santos Cordon823fd3c2014-08-07 18:35:18 -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;
Santos Cordon823fd3c2014-08-07 18:35:18 -070018
Santos Cordon5d2e4f22015-05-12 12:32:51 -070019import android.annotation.SystemApi;
Rekha Kumar07366812015-03-24 16:42:31 -070020import android.telecom.Connection.VideoProvider;
Evan Charlton0e094d92014-11-08 15:49:16 -080021
Ihab Awad50e35062014-09-30 09:17:03 -070022import java.util.ArrayList;
Santos Cordon823fd3c2014-08-07 18:35:18 -070023import java.util.Collections;
Santos Cordon823fd3c2014-08-07 18:35:18 -070024import java.util.List;
Rekha Kumar07366812015-03-24 16:42:31 -070025import java.util.Locale;
Santos Cordon823fd3c2014-08-07 18:35:18 -070026import java.util.Set;
27import java.util.concurrent.CopyOnWriteArrayList;
28import java.util.concurrent.CopyOnWriteArraySet;
29
30/**
31 * Represents a conference call which can contain any number of {@link Connection} objects.
32 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -070033public abstract class Conference implements Conferenceable {
Santos Cordon823fd3c2014-08-07 18:35:18 -070034
Tyler Gunncd5d33c2015-01-12 09:02:01 -080035 /**
36 * Used to indicate that the conference connection time is not specified. If not specified,
37 * Telecom will set the connect time.
38 */
Jay Shrauner164a0ac2015-04-14 18:16:10 -070039 public static final long CONNECT_TIME_NOT_SPECIFIED = 0;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080040
Santos Cordon823fd3c2014-08-07 18:35:18 -070041 /** @hide */
42 public abstract static class Listener {
43 public void onStateChanged(Conference conference, int oldState, int newState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -070044 public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070045 public void onConnectionAdded(Conference conference, Connection connection) {}
46 public void onConnectionRemoved(Conference conference, Connection connection) {}
Ihab Awad50e35062014-09-30 09:17:03 -070047 public void onConferenceableConnectionsChanged(
48 Conference conference, List<Connection> conferenceableConnections) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070049 public void onDestroyed(Conference conference) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -080050 public void onConnectionCapabilitiesChanged(
51 Conference conference, int connectionCapabilities) {}
Rekha Kumar07366812015-03-24 16:42:31 -070052 public void onVideoStateChanged(Conference c, int videoState) { }
53 public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {}
Andrew Leeedc625f2015-04-14 13:38:12 -070054 public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070055 }
56
57 private final Set<Listener> mListeners = new CopyOnWriteArraySet<>();
58 private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>();
Ihab Awadb8e85c72014-08-23 20:34:57 -070059 private final List<Connection> mUnmodifiableChildConnections =
Santos Cordon823fd3c2014-08-07 18:35:18 -070060 Collections.unmodifiableList(mChildConnections);
Ihab Awad50e35062014-09-30 09:17:03 -070061 private final List<Connection> mConferenceableConnections = new ArrayList<>();
62 private final List<Connection> mUnmodifiableConferenceableConnections =
63 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -070064
Jay Shrauner164a0ac2015-04-14 18:16:10 -070065 private PhoneAccountHandle mPhoneAccount;
Yorke Leea0d3ca92014-09-15 19:18:13 -070066 private AudioState mAudioState;
Santos Cordon823fd3c2014-08-07 18:35:18 -070067 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070068 private DisconnectCause mDisconnectCause;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080069 private int mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070070 private String mDisconnectMessage;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080071 private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED;
Andrew Leeedc625f2015-04-14 13:38:12 -070072 private StatusHints mStatusHints;
Santos Cordon823fd3c2014-08-07 18:35:18 -070073
Ihab Awad50e35062014-09-30 09:17:03 -070074 private final Connection.Listener mConnectionDeathListener = new Connection.Listener() {
75 @Override
76 public void onDestroyed(Connection c) {
77 if (mConferenceableConnections.remove(c)) {
78 fireOnConferenceableConnectionsChanged();
79 }
80 }
81 };
82
Nancy Chen56fc25d2014-09-09 12:24:51 -070083 /**
84 * Constructs a new Conference with a mandatory {@link PhoneAccountHandle}
85 *
86 * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference.
87 */
Santos Cordon823fd3c2014-08-07 18:35:18 -070088 public Conference(PhoneAccountHandle phoneAccount) {
89 mPhoneAccount = phoneAccount;
90 }
91
Nancy Chen56fc25d2014-09-09 12:24:51 -070092 /**
93 * Returns the {@link PhoneAccountHandle} the conference call is being placed through.
94 *
95 * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference.
96 */
Nancy Chenea38cca2014-09-05 16:38:49 -070097 public final PhoneAccountHandle getPhoneAccountHandle() {
Santos Cordon823fd3c2014-08-07 18:35:18 -070098 return mPhoneAccount;
99 }
100
Nancy Chen56fc25d2014-09-09 12:24:51 -0700101 /**
102 * Returns the list of connections currently associated with the conference call.
103 *
104 * @return A list of {@code Connection} objects which represent the children of the conference.
105 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700106 public final List<Connection> getConnections() {
Ihab Awadb8e85c72014-08-23 20:34:57 -0700107 return mUnmodifiableChildConnections;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700108 }
109
Nancy Chen56fc25d2014-09-09 12:24:51 -0700110 /**
111 * Gets the state of the conference call. See {@link Connection} for valid values.
112 *
113 * @return A constant representing the state the conference call is currently in.
114 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700115 public final int getState() {
116 return mState;
117 }
118
Nancy Chen56fc25d2014-09-09 12:24:51 -0700119 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700120 * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800121 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700122 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800123 * @return A bitmask of the capabilities of the conference call.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700124 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800125 public final int getConnectionCapabilities() {
126 return mConnectionCapabilities;
127 }
128
129 /**
130 * Whether the given capabilities support the specified capability.
131 *
132 * @param capabilities A capability bit field.
133 * @param capability The capability to check capabilities for.
134 * @return Whether the specified capability is supported.
135 * @hide
136 */
137 public static boolean can(int capabilities, int capability) {
138 return (capabilities & capability) != 0;
139 }
140
141 /**
142 * Whether the capabilities of this {@code Connection} supports the specified capability.
143 *
144 * @param capability The capability to check capabilities for.
145 * @return Whether the specified capability is supported.
146 * @hide
147 */
148 public boolean can(int capability) {
149 return can(mConnectionCapabilities, capability);
150 }
151
152 /**
153 * Removes the specified capability from the set of capabilities of this {@code Conference}.
154 *
155 * @param capability The capability to remove from the set.
156 * @hide
157 */
158 public void removeCapability(int capability) {
159 mConnectionCapabilities &= ~capability;
160 }
161
162 /**
163 * Adds the specified capability to the set of capabilities of this {@code Conference}.
164 *
165 * @param capability The capability to add to the set.
166 * @hide
167 */
168 public void addCapability(int capability) {
169 mConnectionCapabilities |= capability;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700170 }
171
172 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700173 * @return The audio state of the conference, describing how its audio is currently
174 * being routed by the system. This is {@code null} if this Conference
175 * does not directly know about its audio state.
176 */
177 public final AudioState getAudioState() {
178 return mAudioState;
179 }
180
181 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700182 * Returns VideoProvider of the primary call. This can be null.
Rekha Kumar07366812015-03-24 16:42:31 -0700183 */
184 public VideoProvider getVideoProvider() {
185 return null;
186 }
187
188 /**
189 * Returns video state of the primary call.
Rekha Kumar07366812015-03-24 16:42:31 -0700190 */
191 public int getVideoState() {
192 return VideoProfile.VideoState.AUDIO_ONLY;
193 }
194
195 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700196 * Invoked when the Conference and all it's {@link Connection}s should be disconnected.
197 */
198 public void onDisconnect() {}
199
200 /**
201 * Invoked when the specified {@link Connection} should be separated from the conference call.
202 *
203 * @param connection The connection to separate.
204 */
205 public void onSeparate(Connection connection) {}
206
207 /**
Ihab Awad50e35062014-09-30 09:17:03 -0700208 * Invoked when the specified {@link Connection} should merged with the conference call.
209 *
210 * @param connection The {@code Connection} to merge.
211 */
212 public void onMerge(Connection connection) {}
213
214 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700215 * Invoked when the conference should be put on hold.
216 */
217 public void onHold() {}
218
219 /**
220 * Invoked when the conference should be moved from hold to active.
221 */
222 public void onUnhold() {}
223
224 /**
Santos Cordona4868042014-09-04 17:39:22 -0700225 * Invoked when the child calls should be merged. Only invoked if the conference contains the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800226 * capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700227 */
228 public void onMerge() {}
229
230 /**
231 * Invoked when the child calls should be swapped. Only invoked if the conference contains the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800232 * capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700233 */
234 public void onSwap() {}
235
236 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700237 * Notifies this conference of a request to play a DTMF tone.
238 *
239 * @param c A DTMF character.
240 */
241 public void onPlayDtmfTone(char c) {}
242
243 /**
244 * Notifies this conference of a request to stop any currently playing DTMF tones.
245 */
246 public void onStopDtmfTone() {}
247
248 /**
249 * Notifies this conference that the {@link #getAudioState()} property has a new value.
250 *
251 * @param state The new call audio state.
252 */
253 public void onAudioStateChanged(AudioState state) {}
254
255 /**
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800256 * Notifies this conference that a connection has been added to it.
257 *
258 * @param connection The newly added connection.
259 */
260 public void onConnectionAdded(Connection connection) {}
261
262 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700263 * Sets state to be on hold.
264 */
265 public final void setOnHold() {
266 setState(Connection.STATE_HOLDING);
267 }
268
269 /**
270 * Sets state to be active.
271 */
272 public final void setActive() {
273 setState(Connection.STATE_ACTIVE);
274 }
275
276 /**
277 * Sets state to disconnected.
278 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700279 * @param disconnectCause The reason for the disconnection, as described by
280 * {@link android.telecom.DisconnectCause}.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700281 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700282 public final void setDisconnected(DisconnectCause disconnectCause) {
283 mDisconnectCause = disconnectCause;;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700284 setState(Connection.STATE_DISCONNECTED);
285 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700286 l.onDisconnected(this, mDisconnectCause);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700287 }
288 }
289
290 /**
mike dooley1cf14ac2014-11-04 10:59:53 -0800291 * @return The {@link DisconnectCause} for this connection.
292 */
293 public final DisconnectCause getDisconnectCause() {
294 return mDisconnectCause;
295 }
296
297 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800298 * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class
299 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700300 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800301 * @param connectionCapabilities A bitmask of the {@code PhoneCapabilities} of the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700302 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800303 public final void setConnectionCapabilities(int connectionCapabilities) {
304 if (connectionCapabilities != mConnectionCapabilities) {
305 mConnectionCapabilities = connectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700306
307 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800308 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700309 }
310 }
311 }
312
313 /**
314 * Adds the specified connection as a child of this conference.
315 *
316 * @param connection The connection to add.
317 * @return True if the connection was successfully added.
318 */
Santos Cordona4868042014-09-04 17:39:22 -0700319 public final boolean addConnection(Connection connection) {
Rekha Kumar07366812015-03-24 16:42:31 -0700320 Log.d(this, "Connection=%s, connection=", connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700321 if (connection != null && !mChildConnections.contains(connection)) {
322 if (connection.setConference(this)) {
323 mChildConnections.add(connection);
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800324 onConnectionAdded(connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700325 for (Listener l : mListeners) {
326 l.onConnectionAdded(this, connection);
327 }
328 return true;
329 }
330 }
331 return false;
332 }
333
334 /**
335 * Removes the specified connection as a child of this conference.
336 *
337 * @param connection The connection to remove.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700338 */
Santos Cordona4868042014-09-04 17:39:22 -0700339 public final void removeConnection(Connection connection) {
Santos Cordon0159ac02014-08-21 14:28:11 -0700340 Log.d(this, "removing %s from %s", connection, mChildConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700341 if (connection != null && mChildConnections.remove(connection)) {
342 connection.resetConference();
343 for (Listener l : mListeners) {
344 l.onConnectionRemoved(this, connection);
345 }
346 }
347 }
348
349 /**
Ihab Awad50e35062014-09-30 09:17:03 -0700350 * Sets the connections with which this connection can be conferenced.
351 *
352 * @param conferenceableConnections The set of connections this connection can conference with.
353 */
354 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
355 clearConferenceableList();
356 for (Connection c : conferenceableConnections) {
357 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
358 // small amount of items here.
359 if (!mConferenceableConnections.contains(c)) {
360 c.addConnectionListener(mConnectionDeathListener);
361 mConferenceableConnections.add(c);
362 }
363 }
364 fireOnConferenceableConnectionsChanged();
365 }
366
Rekha Kumar07366812015-03-24 16:42:31 -0700367 /**
368 * Set the video state for the conference.
Yorke Lee32f24732015-05-12 16:18:03 -0700369 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
370 * {@link VideoProfile#STATE_BIDIRECTIONAL},
371 * {@link VideoProfile#STATE_TX_ENABLED},
372 * {@link VideoProfile#STATE_RX_ENABLED}.
Rekha Kumar07366812015-03-24 16:42:31 -0700373 *
374 * @param videoState The new video state.
Rekha Kumar07366812015-03-24 16:42:31 -0700375 */
376 public final void setVideoState(Connection c, int videoState) {
377 Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s",
378 this, c, videoState);
379 for (Listener l : mListeners) {
380 l.onVideoStateChanged(this, videoState);
381 }
382 }
383
384 /**
385 * Sets the video connection provider.
386 *
387 * @param videoProvider The video provider.
Rekha Kumar07366812015-03-24 16:42:31 -0700388 */
389 public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) {
390 Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s",
391 this, c, videoProvider);
392 for (Listener l : mListeners) {
393 l.onVideoProviderChanged(this, videoProvider);
394 }
395 }
396
Ihab Awad50e35062014-09-30 09:17:03 -0700397 private final void fireOnConferenceableConnectionsChanged() {
398 for (Listener l : mListeners) {
399 l.onConferenceableConnectionsChanged(this, getConferenceableConnections());
400 }
401 }
402
403 /**
404 * Returns the connections with which this connection can be conferenced.
405 */
406 public final List<Connection> getConferenceableConnections() {
407 return mUnmodifiableConferenceableConnections;
408 }
409
410 /**
Nancy Chenea38cca2014-09-05 16:38:49 -0700411 * Tears down the conference object and any of its current connections.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700412 */
Santos Cordona4868042014-09-04 17:39:22 -0700413 public final void destroy() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700414 Log.d(this, "destroying conference : %s", this);
415 // Tear down the children.
Santos Cordon0159ac02014-08-21 14:28:11 -0700416 for (Connection connection : mChildConnections) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700417 Log.d(this, "removing connection %s", connection);
418 removeConnection(connection);
419 }
420
421 // If not yet disconnected, set the conference call as disconnected first.
422 if (mState != Connection.STATE_DISCONNECTED) {
423 Log.d(this, "setting to disconnected");
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700424 setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
Santos Cordon823fd3c2014-08-07 18:35:18 -0700425 }
426
427 // ...and notify.
428 for (Listener l : mListeners) {
429 l.onDestroyed(this);
430 }
431 }
432
433 /**
434 * Add a listener to be notified of a state change.
435 *
436 * @param listener The new listener.
437 * @return This conference.
438 * @hide
439 */
440 public final Conference addListener(Listener listener) {
441 mListeners.add(listener);
442 return this;
443 }
444
445 /**
446 * Removes the specified listener.
447 *
448 * @param listener The listener to remove.
449 * @return This conference.
450 * @hide
451 */
452 public final Conference removeListener(Listener listener) {
453 mListeners.remove(listener);
454 return this;
455 }
456
Yorke Leea0d3ca92014-09-15 19:18:13 -0700457 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700458 * Retrieves the primary connection associated with the conference. The primary connection is
459 * the connection from which the conference will retrieve its current state.
460 *
461 * @return The primary connection.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700462 * @hide
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700463 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700464 @SystemApi
Santos Cordon4055d642015-05-12 14:19:24 -0700465 public Connection getPrimaryConnection() {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700466 if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) {
467 return null;
468 }
469 return mUnmodifiableChildConnections.get(0);
470 }
471
472 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700473 * @hide
474 * @deprecated Use {@link #setConnectionTime}.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800475 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700476 @Deprecated
477 @SystemApi
478 public final void setConnectTimeMillis(long connectTimeMillis) {
479 setConnectionTime(connectTimeMillis);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800480 }
481
482 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700483 * Sets the connection start time of the {@code Conference}.
484 *
485 * @param connectionTimeMillis The connection time, in milliseconds.
486 */
487 public final void setConnectionTime(long connectionTimeMillis) {
488 mConnectTimeMillis = connectionTimeMillis;
489 }
490
491 /**
492 * @hide
493 * @deprecated Use {@link #getConnectionTime}.
494 */
495 @Deprecated
496 @SystemApi
497 public final long getConnectTimeMillis() {
498 return getConnectionTime();
499 }
500
501 /**
502 * Retrieves the connection start time of the {@code Conference}, if specified. A value of
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800503 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
504 * of the conference.
505 *
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700506 * @return The time at which the {@code Conference} was connected.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800507 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700508 public final long getConnectionTime() {
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800509 return mConnectTimeMillis;
510 }
511
512 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700513 * Inform this Conference that the state of its audio output has been changed externally.
514 *
515 * @param state The new audio state.
516 * @hide
517 */
518 final void setAudioState(AudioState state) {
519 Log.d(this, "setAudioState %s", state);
520 mAudioState = state;
521 onAudioStateChanged(state);
522 }
523
Santos Cordon823fd3c2014-08-07 18:35:18 -0700524 private void setState(int newState) {
525 if (newState != Connection.STATE_ACTIVE &&
526 newState != Connection.STATE_HOLDING &&
527 newState != Connection.STATE_DISCONNECTED) {
528 Log.w(this, "Unsupported state transition for Conference call.",
529 Connection.stateToString(newState));
530 return;
531 }
532
533 if (mState != newState) {
534 int oldState = mState;
535 mState = newState;
536 for (Listener l : mListeners) {
537 l.onStateChanged(this, oldState, newState);
538 }
539 }
540 }
Ihab Awad50e35062014-09-30 09:17:03 -0700541
542 private final void clearConferenceableList() {
543 for (Connection c : mConferenceableConnections) {
544 c.removeConnectionListener(mConnectionDeathListener);
545 }
546 mConferenceableConnections.clear();
547 }
Rekha Kumar07366812015-03-24 16:42:31 -0700548
549 @Override
550 public String toString() {
551 return String.format(Locale.US,
552 "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]",
553 Connection.stateToString(mState),
554 Call.Details.capabilitiesToString(mConnectionCapabilities),
555 getVideoState(),
556 getVideoProvider(),
557 super.toString());
558 }
Andrew Lee0f51da32015-04-16 13:11:55 -0700559
Andrew Leeedc625f2015-04-14 13:38:12 -0700560 /**
561 * Sets the label and icon status to display in the InCall UI.
562 *
563 * @param statusHints The status label and icon to set.
564 */
565 public final void setStatusHints(StatusHints statusHints) {
566 mStatusHints = statusHints;
567 for (Listener l : mListeners) {
568 l.onStatusHintsChanged(this, statusHints);
569 }
570 }
571
572 /**
573 * @return The status hints for this conference.
574 */
575 public final StatusHints getStatusHints() {
576 return mStatusHints;
577 }
Santos Cordon823fd3c2014-08-07 18:35:18 -0700578}