blob: 9db0b92ef8a331f6781636ebaa7b2c8e74d928b4 [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 Cordon6b7f9552015-05-27 17:21:45 -070019import android.annotation.Nullable;
Santos Cordon5d2e4f22015-05-12 12:32:51 -070020import android.annotation.SystemApi;
Santos Cordon6b7f9552015-05-27 17:21:45 -070021import android.os.Bundle;
Rekha Kumar07366812015-03-24 16:42:31 -070022import android.telecom.Connection.VideoProvider;
Evan Charlton0e094d92014-11-08 15:49:16 -080023
Ihab Awad50e35062014-09-30 09:17:03 -070024import java.util.ArrayList;
Santos Cordon823fd3c2014-08-07 18:35:18 -070025import java.util.Collections;
Santos Cordon823fd3c2014-08-07 18:35:18 -070026import java.util.List;
Rekha Kumar07366812015-03-24 16:42:31 -070027import java.util.Locale;
Santos Cordon823fd3c2014-08-07 18:35:18 -070028import java.util.Set;
29import java.util.concurrent.CopyOnWriteArrayList;
30import java.util.concurrent.CopyOnWriteArraySet;
31
32/**
33 * Represents a conference call which can contain any number of {@link Connection} objects.
34 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -070035public abstract class Conference extends Conferenceable {
Santos Cordon823fd3c2014-08-07 18:35:18 -070036
Tyler Gunncd5d33c2015-01-12 09:02:01 -080037 /**
38 * Used to indicate that the conference connection time is not specified. If not specified,
39 * Telecom will set the connect time.
40 */
Jay Shrauner164a0ac2015-04-14 18:16:10 -070041 public static final long CONNECT_TIME_NOT_SPECIFIED = 0;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080042
Santos Cordon823fd3c2014-08-07 18:35:18 -070043 /** @hide */
44 public abstract static class Listener {
45 public void onStateChanged(Conference conference, int oldState, int newState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -070046 public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070047 public void onConnectionAdded(Conference conference, Connection connection) {}
48 public void onConnectionRemoved(Conference conference, Connection connection) {}
Ihab Awad50e35062014-09-30 09:17:03 -070049 public void onConferenceableConnectionsChanged(
50 Conference conference, List<Connection> conferenceableConnections) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070051 public void onDestroyed(Conference conference) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -080052 public void onConnectionCapabilitiesChanged(
53 Conference conference, int connectionCapabilities) {}
Rekha Kumar07366812015-03-24 16:42:31 -070054 public void onVideoStateChanged(Conference c, int videoState) { }
55 public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {}
Andrew Leeedc625f2015-04-14 13:38:12 -070056 public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -070057 public void onExtrasChanged(Conference conference, Bundle extras) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070058 }
59
60 private final Set<Listener> mListeners = new CopyOnWriteArraySet<>();
61 private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>();
Ihab Awadb8e85c72014-08-23 20:34:57 -070062 private final List<Connection> mUnmodifiableChildConnections =
Santos Cordon823fd3c2014-08-07 18:35:18 -070063 Collections.unmodifiableList(mChildConnections);
Ihab Awad50e35062014-09-30 09:17:03 -070064 private final List<Connection> mConferenceableConnections = new ArrayList<>();
65 private final List<Connection> mUnmodifiableConferenceableConnections =
66 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -070067
Jay Shrauner164a0ac2015-04-14 18:16:10 -070068 private PhoneAccountHandle mPhoneAccount;
Yorke Lee4af59352015-05-13 14:14:54 -070069 private CallAudioState mCallAudioState;
Santos Cordon823fd3c2014-08-07 18:35:18 -070070 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070071 private DisconnectCause mDisconnectCause;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080072 private int mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070073 private String mDisconnectMessage;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080074 private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED;
Andrew Leeedc625f2015-04-14 13:38:12 -070075 private StatusHints mStatusHints;
Santos Cordon6b7f9552015-05-27 17:21:45 -070076 private Bundle mExtras;
Santos Cordon823fd3c2014-08-07 18:35:18 -070077
Ihab Awad50e35062014-09-30 09:17:03 -070078 private final Connection.Listener mConnectionDeathListener = new Connection.Listener() {
79 @Override
80 public void onDestroyed(Connection c) {
81 if (mConferenceableConnections.remove(c)) {
82 fireOnConferenceableConnectionsChanged();
83 }
84 }
85 };
86
Nancy Chen56fc25d2014-09-09 12:24:51 -070087 /**
88 * Constructs a new Conference with a mandatory {@link PhoneAccountHandle}
89 *
90 * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference.
91 */
Santos Cordon823fd3c2014-08-07 18:35:18 -070092 public Conference(PhoneAccountHandle phoneAccount) {
93 mPhoneAccount = phoneAccount;
94 }
95
Nancy Chen56fc25d2014-09-09 12:24:51 -070096 /**
97 * Returns the {@link PhoneAccountHandle} the conference call is being placed through.
98 *
99 * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference.
100 */
Nancy Chenea38cca2014-09-05 16:38:49 -0700101 public final PhoneAccountHandle getPhoneAccountHandle() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700102 return mPhoneAccount;
103 }
104
Nancy Chen56fc25d2014-09-09 12:24:51 -0700105 /**
106 * Returns the list of connections currently associated with the conference call.
107 *
108 * @return A list of {@code Connection} objects which represent the children of the conference.
109 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700110 public final List<Connection> getConnections() {
Ihab Awadb8e85c72014-08-23 20:34:57 -0700111 return mUnmodifiableChildConnections;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700112 }
113
Nancy Chen56fc25d2014-09-09 12:24:51 -0700114 /**
115 * Gets the state of the conference call. See {@link Connection} for valid values.
116 *
117 * @return A constant representing the state the conference call is currently in.
118 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700119 public final int getState() {
120 return mState;
121 }
122
Nancy Chen56fc25d2014-09-09 12:24:51 -0700123 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700124 * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800125 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700126 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800127 * @return A bitmask of the capabilities of the conference call.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700128 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800129 public final int getConnectionCapabilities() {
130 return mConnectionCapabilities;
131 }
132
133 /**
134 * Whether the given capabilities support the specified capability.
135 *
136 * @param capabilities A capability bit field.
137 * @param capability The capability to check capabilities for.
138 * @return Whether the specified capability is supported.
139 * @hide
140 */
141 public static boolean can(int capabilities, int capability) {
142 return (capabilities & capability) != 0;
143 }
144
145 /**
146 * Whether the capabilities of this {@code Connection} supports the specified capability.
147 *
148 * @param capability The capability to check capabilities for.
149 * @return Whether the specified capability is supported.
150 * @hide
151 */
152 public boolean can(int capability) {
153 return can(mConnectionCapabilities, capability);
154 }
155
156 /**
157 * Removes the specified capability from the set of capabilities of this {@code Conference}.
158 *
159 * @param capability The capability to remove from the set.
160 * @hide
161 */
162 public void removeCapability(int capability) {
163 mConnectionCapabilities &= ~capability;
164 }
165
166 /**
167 * Adds the specified capability to the set of capabilities of this {@code Conference}.
168 *
169 * @param capability The capability to add to the set.
170 * @hide
171 */
172 public void addCapability(int capability) {
173 mConnectionCapabilities |= capability;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700174 }
175
176 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700177 * @return The audio state of the conference, describing how its audio is currently
178 * being routed by the system. This is {@code null} if this Conference
179 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700180 * @deprecated Use {@link #getCallAudioState()} instead.
181 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700182 */
Yorke Lee4af59352015-05-13 14:14:54 -0700183 @Deprecated
184 @SystemApi
Yorke Leea0d3ca92014-09-15 19:18:13 -0700185 public final AudioState getAudioState() {
Yorke Lee4af59352015-05-13 14:14:54 -0700186 return new AudioState(mCallAudioState);
187 }
188
189 /**
190 * @return The audio state of the conference, describing how its audio is currently
191 * being routed by the system. This is {@code null} if this Conference
192 * does not directly know about its audio state.
193 */
194 public final CallAudioState getCallAudioState() {
195 return mCallAudioState;
Yorke Leea0d3ca92014-09-15 19:18:13 -0700196 }
197
198 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700199 * Returns VideoProvider of the primary call. This can be null.
Rekha Kumar07366812015-03-24 16:42:31 -0700200 */
201 public VideoProvider getVideoProvider() {
202 return null;
203 }
204
205 /**
206 * Returns video state of the primary call.
Rekha Kumar07366812015-03-24 16:42:31 -0700207 */
208 public int getVideoState() {
209 return VideoProfile.VideoState.AUDIO_ONLY;
210 }
211
212 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700213 * Invoked when the Conference and all it's {@link Connection}s should be disconnected.
214 */
215 public void onDisconnect() {}
216
217 /**
218 * Invoked when the specified {@link Connection} should be separated from the conference call.
219 *
220 * @param connection The connection to separate.
221 */
222 public void onSeparate(Connection connection) {}
223
224 /**
Ihab Awad50e35062014-09-30 09:17:03 -0700225 * Invoked when the specified {@link Connection} should merged with the conference call.
226 *
227 * @param connection The {@code Connection} to merge.
228 */
229 public void onMerge(Connection connection) {}
230
231 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700232 * Invoked when the conference should be put on hold.
233 */
234 public void onHold() {}
235
236 /**
237 * Invoked when the conference should be moved from hold to active.
238 */
239 public void onUnhold() {}
240
241 /**
Santos Cordona4868042014-09-04 17:39:22 -0700242 * Invoked when the child calls should be merged. Only invoked if the conference contains the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800243 * capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700244 */
245 public void onMerge() {}
246
247 /**
248 * Invoked when the child calls should be swapped. Only invoked if the conference contains the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800249 * capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700250 */
251 public void onSwap() {}
252
253 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700254 * Notifies this conference of a request to play a DTMF tone.
255 *
256 * @param c A DTMF character.
257 */
258 public void onPlayDtmfTone(char c) {}
259
260 /**
261 * Notifies this conference of a request to stop any currently playing DTMF tones.
262 */
263 public void onStopDtmfTone() {}
264
265 /**
266 * Notifies this conference that the {@link #getAudioState()} property has a new value.
267 *
268 * @param state The new call audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700269 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
270 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700271 */
Yorke Lee4af59352015-05-13 14:14:54 -0700272 @SystemApi
273 @Deprecated
Yorke Leea0d3ca92014-09-15 19:18:13 -0700274 public void onAudioStateChanged(AudioState state) {}
275
276 /**
Yorke Lee4af59352015-05-13 14:14:54 -0700277 * Notifies this conference that the {@link #getCallAudioState()} property has a new value.
278 *
279 * @param state The new call audio state.
280 */
281 public void onCallAudioStateChanged(CallAudioState state) {}
282
283 /**
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800284 * Notifies this conference that a connection has been added to it.
285 *
286 * @param connection The newly added connection.
287 */
288 public void onConnectionAdded(Connection connection) {}
289
290 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700291 * Sets state to be on hold.
292 */
293 public final void setOnHold() {
294 setState(Connection.STATE_HOLDING);
295 }
296
297 /**
298 * Sets state to be active.
299 */
300 public final void setActive() {
301 setState(Connection.STATE_ACTIVE);
302 }
303
304 /**
305 * Sets state to disconnected.
306 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700307 * @param disconnectCause The reason for the disconnection, as described by
308 * {@link android.telecom.DisconnectCause}.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700309 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700310 public final void setDisconnected(DisconnectCause disconnectCause) {
311 mDisconnectCause = disconnectCause;;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700312 setState(Connection.STATE_DISCONNECTED);
313 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700314 l.onDisconnected(this, mDisconnectCause);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700315 }
316 }
317
318 /**
mike dooley1cf14ac2014-11-04 10:59:53 -0800319 * @return The {@link DisconnectCause} for this connection.
320 */
321 public final DisconnectCause getDisconnectCause() {
322 return mDisconnectCause;
323 }
324
325 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800326 * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class
327 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700328 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800329 * @param connectionCapabilities A bitmask of the {@code PhoneCapabilities} of the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700330 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800331 public final void setConnectionCapabilities(int connectionCapabilities) {
332 if (connectionCapabilities != mConnectionCapabilities) {
333 mConnectionCapabilities = connectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700334
335 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800336 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700337 }
338 }
339 }
340
341 /**
342 * Adds the specified connection as a child of this conference.
343 *
344 * @param connection The connection to add.
345 * @return True if the connection was successfully added.
346 */
Santos Cordona4868042014-09-04 17:39:22 -0700347 public final boolean addConnection(Connection connection) {
Rekha Kumar07366812015-03-24 16:42:31 -0700348 Log.d(this, "Connection=%s, connection=", connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700349 if (connection != null && !mChildConnections.contains(connection)) {
350 if (connection.setConference(this)) {
351 mChildConnections.add(connection);
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800352 onConnectionAdded(connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700353 for (Listener l : mListeners) {
354 l.onConnectionAdded(this, connection);
355 }
356 return true;
357 }
358 }
359 return false;
360 }
361
362 /**
363 * Removes the specified connection as a child of this conference.
364 *
365 * @param connection The connection to remove.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700366 */
Santos Cordona4868042014-09-04 17:39:22 -0700367 public final void removeConnection(Connection connection) {
Santos Cordon0159ac02014-08-21 14:28:11 -0700368 Log.d(this, "removing %s from %s", connection, mChildConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700369 if (connection != null && mChildConnections.remove(connection)) {
370 connection.resetConference();
371 for (Listener l : mListeners) {
372 l.onConnectionRemoved(this, connection);
373 }
374 }
375 }
376
377 /**
Ihab Awad50e35062014-09-30 09:17:03 -0700378 * Sets the connections with which this connection can be conferenced.
379 *
380 * @param conferenceableConnections The set of connections this connection can conference with.
381 */
382 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
383 clearConferenceableList();
384 for (Connection c : conferenceableConnections) {
385 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
386 // small amount of items here.
387 if (!mConferenceableConnections.contains(c)) {
388 c.addConnectionListener(mConnectionDeathListener);
389 mConferenceableConnections.add(c);
390 }
391 }
392 fireOnConferenceableConnectionsChanged();
393 }
394
Rekha Kumar07366812015-03-24 16:42:31 -0700395 /**
396 * Set the video state for the conference.
Yorke Lee32f24732015-05-12 16:18:03 -0700397 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
398 * {@link VideoProfile#STATE_BIDIRECTIONAL},
399 * {@link VideoProfile#STATE_TX_ENABLED},
400 * {@link VideoProfile#STATE_RX_ENABLED}.
Rekha Kumar07366812015-03-24 16:42:31 -0700401 *
402 * @param videoState The new video state.
Rekha Kumar07366812015-03-24 16:42:31 -0700403 */
404 public final void setVideoState(Connection c, int videoState) {
405 Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s",
406 this, c, videoState);
407 for (Listener l : mListeners) {
408 l.onVideoStateChanged(this, videoState);
409 }
410 }
411
412 /**
413 * Sets the video connection provider.
414 *
415 * @param videoProvider The video provider.
Rekha Kumar07366812015-03-24 16:42:31 -0700416 */
417 public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) {
418 Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s",
419 this, c, videoProvider);
420 for (Listener l : mListeners) {
421 l.onVideoProviderChanged(this, videoProvider);
422 }
423 }
424
Ihab Awad50e35062014-09-30 09:17:03 -0700425 private final void fireOnConferenceableConnectionsChanged() {
426 for (Listener l : mListeners) {
427 l.onConferenceableConnectionsChanged(this, getConferenceableConnections());
428 }
429 }
430
431 /**
432 * Returns the connections with which this connection can be conferenced.
433 */
434 public final List<Connection> getConferenceableConnections() {
435 return mUnmodifiableConferenceableConnections;
436 }
437
438 /**
Nancy Chenea38cca2014-09-05 16:38:49 -0700439 * Tears down the conference object and any of its current connections.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700440 */
Santos Cordona4868042014-09-04 17:39:22 -0700441 public final void destroy() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700442 Log.d(this, "destroying conference : %s", this);
443 // Tear down the children.
Santos Cordon0159ac02014-08-21 14:28:11 -0700444 for (Connection connection : mChildConnections) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700445 Log.d(this, "removing connection %s", connection);
446 removeConnection(connection);
447 }
448
449 // If not yet disconnected, set the conference call as disconnected first.
450 if (mState != Connection.STATE_DISCONNECTED) {
451 Log.d(this, "setting to disconnected");
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700452 setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
Santos Cordon823fd3c2014-08-07 18:35:18 -0700453 }
454
455 // ...and notify.
456 for (Listener l : mListeners) {
457 l.onDestroyed(this);
458 }
459 }
460
461 /**
462 * Add a listener to be notified of a state change.
463 *
464 * @param listener The new listener.
465 * @return This conference.
466 * @hide
467 */
468 public final Conference addListener(Listener listener) {
469 mListeners.add(listener);
470 return this;
471 }
472
473 /**
474 * Removes the specified listener.
475 *
476 * @param listener The listener to remove.
477 * @return This conference.
478 * @hide
479 */
480 public final Conference removeListener(Listener listener) {
481 mListeners.remove(listener);
482 return this;
483 }
484
Yorke Leea0d3ca92014-09-15 19:18:13 -0700485 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700486 * Retrieves the primary connection associated with the conference. The primary connection is
487 * the connection from which the conference will retrieve its current state.
488 *
489 * @return The primary connection.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700490 * @hide
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700491 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700492 @SystemApi
Santos Cordon4055d642015-05-12 14:19:24 -0700493 public Connection getPrimaryConnection() {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700494 if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) {
495 return null;
496 }
497 return mUnmodifiableChildConnections.get(0);
498 }
499
500 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700501 * @hide
502 * @deprecated Use {@link #setConnectionTime}.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800503 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700504 @Deprecated
505 @SystemApi
506 public final void setConnectTimeMillis(long connectTimeMillis) {
507 setConnectionTime(connectTimeMillis);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800508 }
509
510 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700511 * Sets the connection start time of the {@code Conference}.
512 *
513 * @param connectionTimeMillis The connection time, in milliseconds.
514 */
515 public final void setConnectionTime(long connectionTimeMillis) {
516 mConnectTimeMillis = connectionTimeMillis;
517 }
518
519 /**
520 * @hide
521 * @deprecated Use {@link #getConnectionTime}.
522 */
523 @Deprecated
524 @SystemApi
525 public final long getConnectTimeMillis() {
526 return getConnectionTime();
527 }
528
529 /**
530 * Retrieves the connection start time of the {@code Conference}, if specified. A value of
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800531 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
532 * of the conference.
533 *
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700534 * @return The time at which the {@code Conference} was connected.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800535 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700536 public final long getConnectionTime() {
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800537 return mConnectTimeMillis;
538 }
539
540 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700541 * Inform this Conference that the state of its audio output has been changed externally.
542 *
543 * @param state The new audio state.
544 * @hide
545 */
Yorke Lee4af59352015-05-13 14:14:54 -0700546 final void setCallAudioState(CallAudioState state) {
547 Log.d(this, "setCallAudioState %s", state);
548 mCallAudioState = state;
549 onAudioStateChanged(getAudioState());
550 onCallAudioStateChanged(state);
Yorke Leea0d3ca92014-09-15 19:18:13 -0700551 }
552
Santos Cordon823fd3c2014-08-07 18:35:18 -0700553 private void setState(int newState) {
554 if (newState != Connection.STATE_ACTIVE &&
555 newState != Connection.STATE_HOLDING &&
556 newState != Connection.STATE_DISCONNECTED) {
557 Log.w(this, "Unsupported state transition for Conference call.",
558 Connection.stateToString(newState));
559 return;
560 }
561
562 if (mState != newState) {
563 int oldState = mState;
564 mState = newState;
565 for (Listener l : mListeners) {
566 l.onStateChanged(this, oldState, newState);
567 }
568 }
569 }
Ihab Awad50e35062014-09-30 09:17:03 -0700570
571 private final void clearConferenceableList() {
572 for (Connection c : mConferenceableConnections) {
573 c.removeConnectionListener(mConnectionDeathListener);
574 }
575 mConferenceableConnections.clear();
576 }
Rekha Kumar07366812015-03-24 16:42:31 -0700577
578 @Override
579 public String toString() {
580 return String.format(Locale.US,
581 "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]",
582 Connection.stateToString(mState),
583 Call.Details.capabilitiesToString(mConnectionCapabilities),
584 getVideoState(),
585 getVideoProvider(),
586 super.toString());
587 }
Andrew Lee0f51da32015-04-16 13:11:55 -0700588
Andrew Leeedc625f2015-04-14 13:38:12 -0700589 /**
590 * Sets the label and icon status to display in the InCall UI.
591 *
592 * @param statusHints The status label and icon to set.
593 */
594 public final void setStatusHints(StatusHints statusHints) {
595 mStatusHints = statusHints;
596 for (Listener l : mListeners) {
597 l.onStatusHintsChanged(this, statusHints);
598 }
599 }
600
601 /**
602 * @return The status hints for this conference.
603 */
604 public final StatusHints getStatusHints() {
605 return mStatusHints;
606 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700607
608 /**
609 * Set some extras that can be associated with this {@code Conference}. No assumptions should
610 * be made as to how an In-Call UI or service will handle these extras.
611 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
612 *
613 * @param extras The extras associated with this {@code Connection}.
614 */
615 public final void setExtras(@Nullable Bundle extras) {
616 mExtras = extras;
617 for (Listener l : mListeners) {
618 l.onExtrasChanged(this, extras);
619 }
620 }
621
622 /**
623 * @return The extras associated with this conference.
624 */
625 public final Bundle getExtras() {
626 return mExtras;
627 }
Santos Cordon823fd3c2014-08-07 18:35:18 -0700628}