blob: 456290cd772afcc82c9b7fd9c3136d35009b5feb [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
Tyler Gunndee56a82016-03-23 16:06:34 -070019import android.annotation.NonNull;
Santos Cordon6b7f9552015-05-27 17:21:45 -070020import android.annotation.Nullable;
Santos Cordon5d2e4f22015-05-12 12:32:51 -070021import android.annotation.SystemApi;
Tyler Gunn6c14a6992019-02-04 15:12:06 -080022import android.annotation.TestApi;
Tyler Gunn68a73a42018-10-03 15:38:57 -070023import android.net.Uri;
Santos Cordon6b7f9552015-05-27 17:21:45 -070024import android.os.Bundle;
Tyler Gunn3fa819c2017-08-04 09:27:26 -070025import android.os.SystemClock;
Rekha Kumar07366812015-03-24 16:42:31 -070026import android.telecom.Connection.VideoProvider;
Tyler Gunndee56a82016-03-23 16:06:34 -070027import android.util.ArraySet;
Evan Charlton0e094d92014-11-08 15:49:16 -080028
Ihab Awad50e35062014-09-30 09:17:03 -070029import java.util.ArrayList;
Tyler Gunn071be6f2016-05-10 14:52:33 -070030import java.util.Arrays;
Santos Cordon823fd3c2014-08-07 18:35:18 -070031import java.util.Collections;
Santos Cordon823fd3c2014-08-07 18:35:18 -070032import java.util.List;
Rekha Kumar07366812015-03-24 16:42:31 -070033import java.util.Locale;
Santos Cordon823fd3c2014-08-07 18:35:18 -070034import java.util.Set;
35import java.util.concurrent.CopyOnWriteArrayList;
36import java.util.concurrent.CopyOnWriteArraySet;
37
38/**
39 * Represents a conference call which can contain any number of {@link Connection} objects.
40 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -070041public abstract class Conference extends Conferenceable {
Santos Cordon823fd3c2014-08-07 18:35:18 -070042
Tyler Gunncd5d33c2015-01-12 09:02:01 -080043 /**
44 * Used to indicate that the conference connection time is not specified. If not specified,
45 * Telecom will set the connect time.
46 */
Jay Shrauner164a0ac2015-04-14 18:16:10 -070047 public static final long CONNECT_TIME_NOT_SPECIFIED = 0;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080048
Santos Cordon823fd3c2014-08-07 18:35:18 -070049 /** @hide */
Tyler Gunn5567d742019-10-31 13:04:37 -070050 abstract static class Listener {
Santos Cordon823fd3c2014-08-07 18:35:18 -070051 public void onStateChanged(Conference conference, int oldState, int newState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -070052 public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070053 public void onConnectionAdded(Conference conference, Connection connection) {}
54 public void onConnectionRemoved(Conference conference, Connection connection) {}
Ihab Awad50e35062014-09-30 09:17:03 -070055 public void onConferenceableConnectionsChanged(
56 Conference conference, List<Connection> conferenceableConnections) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070057 public void onDestroyed(Conference conference) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -080058 public void onConnectionCapabilitiesChanged(
59 Conference conference, int connectionCapabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -070060 public void onConnectionPropertiesChanged(
61 Conference conference, int connectionProperties) {}
Rekha Kumar07366812015-03-24 16:42:31 -070062 public void onVideoStateChanged(Conference c, int videoState) { }
63 public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {}
Andrew Leeedc625f2015-04-14 13:38:12 -070064 public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {}
Tyler Gunndee56a82016-03-23 16:06:34 -070065 public void onExtrasChanged(Conference c, Bundle extras) {}
66 public void onExtrasRemoved(Conference c, List<String> keys) {}
Tyler Gunn68a73a42018-10-03 15:38:57 -070067 public void onConferenceStateChanged(Conference c, boolean isConference) {}
68 public void onAddressChanged(Conference c, Uri newAddress, int presentation) {}
Hall Liuc9bc1c62019-04-16 14:00:55 -070069 public void onConnectionEvent(Conference c, String event, Bundle extras) {}
Tyler Gunn68a73a42018-10-03 15:38:57 -070070 public void onCallerDisplayNameChanged(
71 Conference c, String callerDisplayName, int presentation) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070072 }
73
74 private final Set<Listener> mListeners = new CopyOnWriteArraySet<>();
75 private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>();
Ihab Awadb8e85c72014-08-23 20:34:57 -070076 private final List<Connection> mUnmodifiableChildConnections =
Santos Cordon823fd3c2014-08-07 18:35:18 -070077 Collections.unmodifiableList(mChildConnections);
Ihab Awad50e35062014-09-30 09:17:03 -070078 private final List<Connection> mConferenceableConnections = new ArrayList<>();
79 private final List<Connection> mUnmodifiableConferenceableConnections =
80 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -070081
Jack Yu67140302015-12-10 12:27:58 -080082 private String mTelecomCallId;
Jay Shrauner164a0ac2015-04-14 18:16:10 -070083 private PhoneAccountHandle mPhoneAccount;
Yorke Lee4af59352015-05-13 14:14:54 -070084 private CallAudioState mCallAudioState;
Santos Cordon823fd3c2014-08-07 18:35:18 -070085 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070086 private DisconnectCause mDisconnectCause;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080087 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -070088 private int mConnectionProperties;
Santos Cordon823fd3c2014-08-07 18:35:18 -070089 private String mDisconnectMessage;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080090 private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn17541392018-02-01 08:58:38 -080091 private long mConnectionStartElapsedRealTime = CONNECT_TIME_NOT_SPECIFIED;
Andrew Leeedc625f2015-04-14 13:38:12 -070092 private StatusHints mStatusHints;
Santos Cordon6b7f9552015-05-27 17:21:45 -070093 private Bundle mExtras;
Tyler Gunndee56a82016-03-23 16:06:34 -070094 private Set<String> mPreviousExtraKeys;
Brad Ebinger4fa6a012016-06-14 17:04:01 -070095 private final Object mExtrasLock = new Object();
Tyler Gunnac60f952019-05-31 07:23:16 -070096 private Uri mAddress;
97 private int mAddressPresentation;
98 private String mCallerDisplayName;
99 private int mCallerDisplayNamePresentation;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700100
Ihab Awad50e35062014-09-30 09:17:03 -0700101 private final Connection.Listener mConnectionDeathListener = new Connection.Listener() {
102 @Override
103 public void onDestroyed(Connection c) {
104 if (mConferenceableConnections.remove(c)) {
105 fireOnConferenceableConnectionsChanged();
106 }
107 }
108 };
109
Nancy Chen56fc25d2014-09-09 12:24:51 -0700110 /**
111 * Constructs a new Conference with a mandatory {@link PhoneAccountHandle}
112 *
113 * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference.
114 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700115 public Conference(PhoneAccountHandle phoneAccount) {
116 mPhoneAccount = phoneAccount;
117 }
118
Nancy Chen56fc25d2014-09-09 12:24:51 -0700119 /**
Jack Yu67140302015-12-10 12:27:58 -0800120 * Returns the telecom internal call ID associated with this conference.
Tyler Gunn5567d742019-10-31 13:04:37 -0700121 * <p>
122 * Note: This is ONLY used for debugging purposes so that the Telephony stack can better
123 * associate logs in Telephony with those in Telecom.
124 * The ID returned should not be used for any other purpose.
Jack Yu67140302015-12-10 12:27:58 -0800125 *
126 * @return The telecom call ID.
127 * @hide
128 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700129 @SystemApi
130 @TestApi
131 public final @NonNull String getTelecomCallId() {
Jack Yu67140302015-12-10 12:27:58 -0800132 return mTelecomCallId;
133 }
134
135 /**
136 * Sets the telecom internal call ID associated with this conference.
137 *
138 * @param telecomCallId The telecom call ID.
139 * @hide
140 */
141 public final void setTelecomCallId(String telecomCallId) {
142 mTelecomCallId = telecomCallId;
143 }
144
145 /**
Nancy Chen56fc25d2014-09-09 12:24:51 -0700146 * Returns the {@link PhoneAccountHandle} the conference call is being placed through.
147 *
148 * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference.
149 */
Nancy Chenea38cca2014-09-05 16:38:49 -0700150 public final PhoneAccountHandle getPhoneAccountHandle() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700151 return mPhoneAccount;
152 }
153
Nancy Chen56fc25d2014-09-09 12:24:51 -0700154 /**
155 * Returns the list of connections currently associated with the conference call.
156 *
157 * @return A list of {@code Connection} objects which represent the children of the conference.
158 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700159 public final List<Connection> getConnections() {
Ihab Awadb8e85c72014-08-23 20:34:57 -0700160 return mUnmodifiableChildConnections;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700161 }
162
Nancy Chen56fc25d2014-09-09 12:24:51 -0700163 /**
164 * Gets the state of the conference call. See {@link Connection} for valid values.
165 *
166 * @return A constant representing the state the conference call is currently in.
167 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700168 public final int getState() {
169 return mState;
170 }
171
Nancy Chen56fc25d2014-09-09 12:24:51 -0700172 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700173 * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800174 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700175 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800176 * @return A bitmask of the capabilities of the conference call.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700177 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800178 public final int getConnectionCapabilities() {
179 return mConnectionCapabilities;
180 }
181
182 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700183 * Returns the properties of the conference. See {@code PROPERTY_*} constants in class
184 * {@link Connection} for valid values.
185 *
186 * @return A bitmask of the properties of the conference call.
187 */
188 public final int getConnectionProperties() {
189 return mConnectionProperties;
190 }
191
192 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700193 * @return The audio state of the conference, describing how its audio is currently
194 * being routed by the system. This is {@code null} if this Conference
195 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700196 * @deprecated Use {@link #getCallAudioState()} instead.
197 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700198 */
Yorke Lee4af59352015-05-13 14:14:54 -0700199 @Deprecated
200 @SystemApi
Yorke Leea0d3ca92014-09-15 19:18:13 -0700201 public final AudioState getAudioState() {
Yorke Lee4af59352015-05-13 14:14:54 -0700202 return new AudioState(mCallAudioState);
203 }
204
205 /**
206 * @return The audio state of the conference, describing how its audio is currently
207 * being routed by the system. This is {@code null} if this Conference
208 * does not directly know about its audio state.
209 */
210 public final CallAudioState getCallAudioState() {
211 return mCallAudioState;
Yorke Leea0d3ca92014-09-15 19:18:13 -0700212 }
213
214 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700215 * Returns VideoProvider of the primary call. This can be null.
Rekha Kumar07366812015-03-24 16:42:31 -0700216 */
217 public VideoProvider getVideoProvider() {
218 return null;
219 }
220
221 /**
222 * Returns video state of the primary call.
Rekha Kumar07366812015-03-24 16:42:31 -0700223 */
224 public int getVideoState() {
Tyler Gunn87b73f32015-06-03 10:09:59 -0700225 return VideoProfile.STATE_AUDIO_ONLY;
Rekha Kumar07366812015-03-24 16:42:31 -0700226 }
227
228 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700229 * Notifies the {@link Conference} when the Conference and all it's {@link Connection}s should
230 * be disconnected.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700231 */
232 public void onDisconnect() {}
233
234 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700235 * Notifies the {@link Conference} when the specified {@link Connection} should be separated
236 * from the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700237 *
238 * @param connection The connection to separate.
239 */
240 public void onSeparate(Connection connection) {}
241
242 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700243 * Notifies the {@link Conference} when the specified {@link Connection} should merged with the
244 * conference call.
Ihab Awad50e35062014-09-30 09:17:03 -0700245 *
246 * @param connection The {@code Connection} to merge.
247 */
248 public void onMerge(Connection connection) {}
249
250 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700251 * Notifies the {@link Conference} when it should be put on hold.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700252 */
253 public void onHold() {}
254
255 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700256 * Notifies the {@link Conference} when it should be moved from a held to active state.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700257 */
258 public void onUnhold() {}
259
260 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700261 * Notifies the {@link Conference} when the child calls should be merged. Only invoked if the
262 * conference contains the capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700263 */
264 public void onMerge() {}
265
266 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700267 * Notifies the {@link Conference} when the child calls should be swapped. Only invoked if the
268 * conference contains the capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700269 */
270 public void onSwap() {}
271
272 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700273 * Notifies the {@link Conference} of a request to play a DTMF tone.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700274 *
275 * @param c A DTMF character.
276 */
277 public void onPlayDtmfTone(char c) {}
278
279 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700280 * Notifies the {@link Conference} of a request to stop any currently playing DTMF tones.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700281 */
282 public void onStopDtmfTone() {}
283
284 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700285 * Notifies the {@link Conference} that the {@link #getAudioState()} property has a new value.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700286 *
287 * @param state The new call audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700288 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
289 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700290 */
Yorke Lee4af59352015-05-13 14:14:54 -0700291 @SystemApi
292 @Deprecated
Yorke Leea0d3ca92014-09-15 19:18:13 -0700293 public void onAudioStateChanged(AudioState state) {}
294
295 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700296 * Notifies the {@link Conference} that the {@link #getCallAudioState()} property has a new
297 * value.
Yorke Lee4af59352015-05-13 14:14:54 -0700298 *
299 * @param state The new call audio state.
300 */
301 public void onCallAudioStateChanged(CallAudioState state) {}
302
303 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700304 * Notifies the {@link Conference} that a {@link Connection} has been added to it.
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800305 *
306 * @param connection The newly added connection.
307 */
308 public void onConnectionAdded(Connection connection) {}
309
310 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700311 * Sets state to be on hold.
312 */
313 public final void setOnHold() {
314 setState(Connection.STATE_HOLDING);
315 }
316
317 /**
Tyler Gunnd46595a2015-06-01 14:29:11 -0700318 * Sets state to be dialing.
319 */
320 public final void setDialing() {
321 setState(Connection.STATE_DIALING);
322 }
323
324 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700325 * Sets state to be active.
326 */
327 public final void setActive() {
328 setState(Connection.STATE_ACTIVE);
329 }
330
331 /**
332 * Sets state to disconnected.
333 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700334 * @param disconnectCause The reason for the disconnection, as described by
335 * {@link android.telecom.DisconnectCause}.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700336 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700337 public final void setDisconnected(DisconnectCause disconnectCause) {
338 mDisconnectCause = disconnectCause;;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700339 setState(Connection.STATE_DISCONNECTED);
340 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700341 l.onDisconnected(this, mDisconnectCause);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700342 }
343 }
344
345 /**
mike dooley1cf14ac2014-11-04 10:59:53 -0800346 * @return The {@link DisconnectCause} for this connection.
347 */
348 public final DisconnectCause getDisconnectCause() {
349 return mDisconnectCause;
350 }
351
352 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800353 * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class
354 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700355 *
Tyler Gunn720c6642016-03-22 09:02:47 -0700356 * @param connectionCapabilities A bitmask of the {@code Capabilities} of the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700357 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800358 public final void setConnectionCapabilities(int connectionCapabilities) {
359 if (connectionCapabilities != mConnectionCapabilities) {
360 mConnectionCapabilities = connectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700361
362 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800363 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700364 }
365 }
366 }
367
368 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700369 * Sets the properties of a conference. See {@code PROPERTY_*} constants of class
370 * {@link Connection} for valid values.
371 *
372 * @param connectionProperties A bitmask of the {@code Properties} of the conference call.
373 */
374 public final void setConnectionProperties(int connectionProperties) {
375 if (connectionProperties != mConnectionProperties) {
376 mConnectionProperties = connectionProperties;
377
378 for (Listener l : mListeners) {
379 l.onConnectionPropertiesChanged(this, mConnectionProperties);
380 }
381 }
382 }
383
384 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700385 * Adds the specified connection as a child of this conference.
386 *
387 * @param connection The connection to add.
388 * @return True if the connection was successfully added.
389 */
Santos Cordona4868042014-09-04 17:39:22 -0700390 public final boolean addConnection(Connection connection) {
Rekha Kumar07366812015-03-24 16:42:31 -0700391 Log.d(this, "Connection=%s, connection=", connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700392 if (connection != null && !mChildConnections.contains(connection)) {
393 if (connection.setConference(this)) {
394 mChildConnections.add(connection);
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800395 onConnectionAdded(connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700396 for (Listener l : mListeners) {
397 l.onConnectionAdded(this, connection);
398 }
399 return true;
400 }
401 }
402 return false;
403 }
404
405 /**
406 * Removes the specified connection as a child of this conference.
407 *
408 * @param connection The connection to remove.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700409 */
Santos Cordona4868042014-09-04 17:39:22 -0700410 public final void removeConnection(Connection connection) {
Santos Cordon0159ac02014-08-21 14:28:11 -0700411 Log.d(this, "removing %s from %s", connection, mChildConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700412 if (connection != null && mChildConnections.remove(connection)) {
413 connection.resetConference();
414 for (Listener l : mListeners) {
415 l.onConnectionRemoved(this, connection);
416 }
417 }
418 }
419
420 /**
Ihab Awad50e35062014-09-30 09:17:03 -0700421 * Sets the connections with which this connection can be conferenced.
422 *
423 * @param conferenceableConnections The set of connections this connection can conference with.
424 */
425 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
426 clearConferenceableList();
427 for (Connection c : conferenceableConnections) {
428 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
429 // small amount of items here.
430 if (!mConferenceableConnections.contains(c)) {
431 c.addConnectionListener(mConnectionDeathListener);
432 mConferenceableConnections.add(c);
433 }
434 }
435 fireOnConferenceableConnectionsChanged();
436 }
437
Rekha Kumar07366812015-03-24 16:42:31 -0700438 /**
439 * Set the video state for the conference.
Yorke Lee32f24732015-05-12 16:18:03 -0700440 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
441 * {@link VideoProfile#STATE_BIDIRECTIONAL},
442 * {@link VideoProfile#STATE_TX_ENABLED},
443 * {@link VideoProfile#STATE_RX_ENABLED}.
Rekha Kumar07366812015-03-24 16:42:31 -0700444 *
445 * @param videoState The new video state.
Rekha Kumar07366812015-03-24 16:42:31 -0700446 */
447 public final void setVideoState(Connection c, int videoState) {
448 Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s",
449 this, c, videoState);
450 for (Listener l : mListeners) {
451 l.onVideoStateChanged(this, videoState);
452 }
453 }
454
455 /**
456 * Sets the video connection provider.
457 *
458 * @param videoProvider The video provider.
Rekha Kumar07366812015-03-24 16:42:31 -0700459 */
460 public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) {
461 Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s",
462 this, c, videoProvider);
463 for (Listener l : mListeners) {
464 l.onVideoProviderChanged(this, videoProvider);
465 }
466 }
467
Ihab Awad50e35062014-09-30 09:17:03 -0700468 private final void fireOnConferenceableConnectionsChanged() {
469 for (Listener l : mListeners) {
470 l.onConferenceableConnectionsChanged(this, getConferenceableConnections());
471 }
472 }
473
474 /**
475 * Returns the connections with which this connection can be conferenced.
476 */
477 public final List<Connection> getConferenceableConnections() {
478 return mUnmodifiableConferenceableConnections;
479 }
480
481 /**
Nancy Chenea38cca2014-09-05 16:38:49 -0700482 * Tears down the conference object and any of its current connections.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700483 */
Santos Cordona4868042014-09-04 17:39:22 -0700484 public final void destroy() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700485 Log.d(this, "destroying conference : %s", this);
486 // Tear down the children.
Santos Cordon0159ac02014-08-21 14:28:11 -0700487 for (Connection connection : mChildConnections) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700488 Log.d(this, "removing connection %s", connection);
489 removeConnection(connection);
490 }
491
492 // If not yet disconnected, set the conference call as disconnected first.
493 if (mState != Connection.STATE_DISCONNECTED) {
494 Log.d(this, "setting to disconnected");
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700495 setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
Santos Cordon823fd3c2014-08-07 18:35:18 -0700496 }
497
498 // ...and notify.
499 for (Listener l : mListeners) {
500 l.onDestroyed(this);
501 }
502 }
503
504 /**
505 * Add a listener to be notified of a state change.
506 *
507 * @param listener The new listener.
508 * @return This conference.
509 * @hide
510 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700511 final Conference addListener(Listener listener) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700512 mListeners.add(listener);
513 return this;
514 }
515
516 /**
517 * Removes the specified listener.
518 *
519 * @param listener The listener to remove.
520 * @return This conference.
521 * @hide
522 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700523 final Conference removeListener(Listener listener) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700524 mListeners.remove(listener);
525 return this;
526 }
527
Yorke Leea0d3ca92014-09-15 19:18:13 -0700528 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700529 * Retrieves the primary connection associated with the conference. The primary connection is
530 * the connection from which the conference will retrieve its current state.
531 *
532 * @return The primary connection.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700533 * @hide
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700534 */
Tyler Gunn6c14a6992019-02-04 15:12:06 -0800535 @TestApi
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700536 @SystemApi
Santos Cordon4055d642015-05-12 14:19:24 -0700537 public Connection getPrimaryConnection() {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700538 if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) {
539 return null;
540 }
541 return mUnmodifiableChildConnections.get(0);
542 }
543
544 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700545 * @hide
546 * @deprecated Use {@link #setConnectionTime}.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800547 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700548 @Deprecated
549 @SystemApi
550 public final void setConnectTimeMillis(long connectTimeMillis) {
551 setConnectionTime(connectTimeMillis);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800552 }
553
554 /**
Tyler Gunn17541392018-02-01 08:58:38 -0800555 * Sets the connection start time of the {@code Conference}. This is used in the call log to
556 * indicate the date and time when the conference took place.
557 * <p>
558 * Should be specified in wall-clock time returned by {@link System#currentTimeMillis()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700559 * <p>
560 * When setting the connection time, you should always set the connection elapsed time via
Tyler Gunn17541392018-02-01 08:58:38 -0800561 * {@link #setConnectionStartElapsedRealTime(long)} to ensure the duration is reflected.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700562 *
Tyler Gunn17541392018-02-01 08:58:38 -0800563 * @param connectionTimeMillis The connection time, in milliseconds, as returned by
564 * {@link System#currentTimeMillis()}.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700565 */
566 public final void setConnectionTime(long connectionTimeMillis) {
567 mConnectTimeMillis = connectionTimeMillis;
568 }
569
570 /**
Tyler Gunn17541392018-02-01 08:58:38 -0800571 * Sets the start time of the {@link Conference} which is the basis for the determining the
572 * duration of the {@link Conference}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700573 * <p>
Tyler Gunn17541392018-02-01 08:58:38 -0800574 * You should use a value returned by {@link SystemClock#elapsedRealtime()} to ensure that time
575 * zone changes do not impact the conference duration.
576 * <p>
577 * When setting this, you should also set the connection time via
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700578 * {@link #setConnectionTime(long)}.
579 *
Tyler Gunn17541392018-02-01 08:58:38 -0800580 * @param connectionStartElapsedRealTime The connection time, as measured by
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700581 * {@link SystemClock#elapsedRealtime()}.
582 */
Tyler Gunn17541392018-02-01 08:58:38 -0800583 public final void setConnectionStartElapsedRealTime(long connectionStartElapsedRealTime) {
584 mConnectionStartElapsedRealTime = connectionStartElapsedRealTime;
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700585 }
586
587 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700588 * @hide
589 * @deprecated Use {@link #getConnectionTime}.
590 */
591 @Deprecated
592 @SystemApi
593 public final long getConnectTimeMillis() {
594 return getConnectionTime();
595 }
596
597 /**
598 * Retrieves the connection start time of the {@code Conference}, if specified. A value of
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800599 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
600 * of the conference.
601 *
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700602 * @return The time at which the {@code Conference} was connected.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800603 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700604 public final long getConnectionTime() {
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800605 return mConnectTimeMillis;
606 }
607
608 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700609 * Retrieves the connection start time of the {@link Conference}, if specified. A value of
610 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
611 * of the conference.
Tyler Gunn5567d742019-10-31 13:04:37 -0700612 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700613 * This is based on the value of {@link SystemClock#elapsedRealtime()} to ensure that it is not
614 * impacted by wall clock changes (user initiated, network initiated, time zone change, etc).
Tyler Gunn5567d742019-10-31 13:04:37 -0700615 * <p>
616 * Note: This is only exposed for use by the Telephony framework which needs it to copy
617 * conference start times among conference participants. It is exposed as a system API since it
618 * has no general use other than to the Telephony framework.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700619 *
620 * @return The elapsed time at which the {@link Conference} was connected.
621 * @hide
622 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700623 @SystemApi
624 @TestApi
Tyler Gunn17541392018-02-01 08:58:38 -0800625 public final long getConnectionStartElapsedRealTime() {
626 return mConnectionStartElapsedRealTime;
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700627 }
628
629 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700630 * Inform this Conference that the state of its audio output has been changed externally.
631 *
632 * @param state The new audio state.
633 * @hide
634 */
Yorke Lee4af59352015-05-13 14:14:54 -0700635 final void setCallAudioState(CallAudioState state) {
636 Log.d(this, "setCallAudioState %s", state);
637 mCallAudioState = state;
638 onAudioStateChanged(getAudioState());
639 onCallAudioStateChanged(state);
Yorke Leea0d3ca92014-09-15 19:18:13 -0700640 }
641
Santos Cordon823fd3c2014-08-07 18:35:18 -0700642 private void setState(int newState) {
643 if (newState != Connection.STATE_ACTIVE &&
644 newState != Connection.STATE_HOLDING &&
645 newState != Connection.STATE_DISCONNECTED) {
646 Log.w(this, "Unsupported state transition for Conference call.",
647 Connection.stateToString(newState));
648 return;
649 }
650
651 if (mState != newState) {
652 int oldState = mState;
653 mState = newState;
654 for (Listener l : mListeners) {
655 l.onStateChanged(this, oldState, newState);
656 }
657 }
658 }
Ihab Awad50e35062014-09-30 09:17:03 -0700659
660 private final void clearConferenceableList() {
661 for (Connection c : mConferenceableConnections) {
662 c.removeConnectionListener(mConnectionDeathListener);
663 }
664 mConferenceableConnections.clear();
665 }
Rekha Kumar07366812015-03-24 16:42:31 -0700666
667 @Override
668 public String toString() {
669 return String.format(Locale.US,
670 "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]",
671 Connection.stateToString(mState),
672 Call.Details.capabilitiesToString(mConnectionCapabilities),
673 getVideoState(),
674 getVideoProvider(),
675 super.toString());
676 }
Andrew Lee0f51da32015-04-16 13:11:55 -0700677
Andrew Leeedc625f2015-04-14 13:38:12 -0700678 /**
679 * Sets the label and icon status to display in the InCall UI.
680 *
681 * @param statusHints The status label and icon to set.
682 */
683 public final void setStatusHints(StatusHints statusHints) {
684 mStatusHints = statusHints;
685 for (Listener l : mListeners) {
686 l.onStatusHintsChanged(this, statusHints);
687 }
688 }
689
690 /**
691 * @return The status hints for this conference.
692 */
693 public final StatusHints getStatusHints() {
694 return mStatusHints;
695 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700696
697 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700698 * Replaces all the extras associated with this {@code Conference}.
699 * <p>
700 * New or existing keys are replaced in the {@code Conference} extras. Keys which are no longer
701 * in the new extras, but were present the last time {@code setExtras} was called are removed.
702 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700703 * Alternatively you may use the {@link #putExtras(Bundle)}, and
704 * {@link #removeExtras(String...)} methods to modify the extras.
705 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -0700706 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700707 * Keys should be fully qualified (e.g., com.example.extras.MY_EXTRA) to avoid conflicts.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700708 *
Tyler Gunndee56a82016-03-23 16:06:34 -0700709 * @param extras The extras associated with this {@code Conference}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700710 */
711 public final void setExtras(@Nullable Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700712 // Keeping putExtras and removeExtras in the same lock so that this operation happens as a
713 // block instead of letting other threads put/remove while this method is running.
714 synchronized (mExtrasLock) {
715 // Add/replace any new or changed extras values.
716 putExtras(extras);
717 // If we have used "setExtras" in the past, compare the key set from the last invocation
718 // to the current one and remove any keys that went away.
719 if (mPreviousExtraKeys != null) {
720 List<String> toRemove = new ArrayList<String>();
721 for (String oldKey : mPreviousExtraKeys) {
722 if (extras == null || !extras.containsKey(oldKey)) {
723 toRemove.add(oldKey);
724 }
725 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700726
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700727 if (!toRemove.isEmpty()) {
728 removeExtras(toRemove);
Tyler Gunndee56a82016-03-23 16:06:34 -0700729 }
730 }
731
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700732 // Track the keys the last time set called setExtras. This way, the next time setExtras
733 // is called we can see if the caller has removed any extras values.
734 if (mPreviousExtraKeys == null) {
735 mPreviousExtraKeys = new ArraySet<String>();
Tyler Gunndee56a82016-03-23 16:06:34 -0700736 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700737 mPreviousExtraKeys.clear();
738 if (extras != null) {
739 mPreviousExtraKeys.addAll(extras.keySet());
740 }
Tyler Gunna8fb8ab2016-03-29 10:24:22 -0700741 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700742 }
743
744 /**
745 * Adds some extras to this {@link Conference}. Existing keys are replaced and new ones are
746 * added.
747 * <p>
748 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
749 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
750 *
751 * @param extras The extras to add.
752 */
753 public final void putExtras(@NonNull Bundle extras) {
754 if (extras == null) {
755 return;
756 }
757
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700758 // Creating a Bundle clone so we don't have to synchronize on mExtrasLock while calling
759 // onExtrasChanged.
760 Bundle listenersBundle;
761 synchronized (mExtrasLock) {
762 if (mExtras == null) {
763 mExtras = new Bundle();
764 }
765 mExtras.putAll(extras);
766 listenersBundle = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -0700767 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700768
Santos Cordon6b7f9552015-05-27 17:21:45 -0700769 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700770 l.onExtrasChanged(this, new Bundle(listenersBundle));
Santos Cordon6b7f9552015-05-27 17:21:45 -0700771 }
772 }
773
774 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700775 * Adds a boolean extra to this {@link Conference}.
776 *
777 * @param key The extra key.
778 * @param value The value.
779 * @hide
780 */
781 public final void putExtra(String key, boolean value) {
782 Bundle newExtras = new Bundle();
783 newExtras.putBoolean(key, value);
784 putExtras(newExtras);
785 }
786
787 /**
788 * Adds an integer extra to this {@link Conference}.
789 *
790 * @param key The extra key.
791 * @param value The value.
792 * @hide
793 */
794 public final void putExtra(String key, int value) {
795 Bundle newExtras = new Bundle();
796 newExtras.putInt(key, value);
797 putExtras(newExtras);
798 }
799
800 /**
801 * Adds a string extra to this {@link Conference}.
802 *
803 * @param key The extra key.
804 * @param value The value.
805 * @hide
806 */
807 public final void putExtra(String key, String value) {
808 Bundle newExtras = new Bundle();
809 newExtras.putString(key, value);
810 putExtras(newExtras);
811 }
812
813 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -0700814 * Removes extras from this {@link Conference}.
Tyler Gunndee56a82016-03-23 16:06:34 -0700815 *
Tyler Gunn071be6f2016-05-10 14:52:33 -0700816 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -0700817 */
818 public final void removeExtras(List<String> keys) {
819 if (keys == null || keys.isEmpty()) {
820 return;
821 }
822
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700823 synchronized (mExtrasLock) {
824 if (mExtras != null) {
825 for (String key : keys) {
826 mExtras.remove(key);
827 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700828 }
829 }
830
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700831 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -0700832 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700833 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -0700834 }
835 }
836
837 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -0700838 * Removes extras from this {@link Conference}.
839 *
840 * @param keys The keys of the extras to remove.
841 */
842 public final void removeExtras(String ... keys) {
843 removeExtras(Arrays.asList(keys));
844 }
845
846 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700847 * Returns the extras associated with this conference.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +0000848 * <p>
849 * Extras should be updated using {@link #putExtras(Bundle)} and {@link #removeExtras(List)}.
850 * <p>
851 * Telecom or an {@link InCallService} can also update the extras via
852 * {@link android.telecom.Call#putExtras(Bundle)}, and
853 * {@link Call#removeExtras(List)}.
854 * <p>
855 * The conference is notified of changes to the extras made by Telecom or an
856 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -0700857 *
858 * @return The extras associated with this connection.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700859 */
860 public final Bundle getExtras() {
861 return mExtras;
862 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700863
864 /**
865 * Notifies this {@link Conference} of a change to the extras made outside the
866 * {@link ConnectionService}.
867 * <p>
868 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
869 * {@link android.telecom.Call#putExtras(Bundle)}, and
870 * {@link Call#removeExtras(List)}.
871 *
872 * @param extras The new extras bundle.
873 */
874 public void onExtrasChanged(Bundle extras) {}
875
876 /**
Tyler Gunn68a73a42018-10-03 15:38:57 -0700877 * Set whether Telecom should treat this {@link Conference} as a conference call or if it
878 * should treat it as a single-party call.
879 * This method is used as part of a workaround regarding IMS conference calls and user
880 * expectation. In IMS, once a conference is formed, the UE is connected to an IMS conference
881 * server. If all participants of the conference drop out of the conference except for one, the
882 * UE is still connected to the IMS conference server. At this point, the user logically
883 * assumes they're no longer in a conference, yet the underlying network actually is.
884 * To help provide a better user experiece, IMS conference calls can pretend to actually be a
885 * single-party call when the participant count drops to 1. Although the dialer/phone app
886 * could perform this trickery, it makes sense to do this in Telephony since a fix there will
887 * ensure that bluetooth head units, auto and wearable apps all behave consistently.
Tyler Gunn5567d742019-10-31 13:04:37 -0700888 * <p>
889 * This API is intended for use by the platform Telephony stack only.
Tyler Gunn68a73a42018-10-03 15:38:57 -0700890 *
891 * @param isConference {@code true} if this {@link Conference} should be treated like a
892 * conference call, {@code false} if it should be treated like a single-party call.
893 * @hide
894 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700895 @SystemApi
896 @TestApi
Tyler Gunn68a73a42018-10-03 15:38:57 -0700897 public void setConferenceState(boolean isConference) {
898 for (Listener l : mListeners) {
899 l.onConferenceStateChanged(this, isConference);
900 }
901 }
902
903 /**
904 * Sets the address of this {@link Conference}. Used when {@link #setConferenceState(boolean)}
905 * is called to mark a conference temporarily as NOT a conference.
Tyler Gunn5567d742019-10-31 13:04:37 -0700906 * <p>
907 * Note: This is a Telephony-specific implementation detail related to IMS conferences. It is
908 * not intended for use outside of the Telephony stack.
Tyler Gunn68a73a42018-10-03 15:38:57 -0700909 *
910 * @param address The new address.
911 * @param presentation The presentation requirements for the address.
912 * See {@link TelecomManager} for valid values.
913 * @hide
914 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700915 @SystemApi
916 @TestApi
917 public final void setAddress(@NonNull Uri address,
918 @TelecomManager.Presentation int presentation) {
Tyler Gunn68a73a42018-10-03 15:38:57 -0700919 Log.d(this, "setAddress %s", address);
Tyler Gunnac60f952019-05-31 07:23:16 -0700920 mAddress = address;
921 mAddressPresentation = presentation;
Tyler Gunn68a73a42018-10-03 15:38:57 -0700922 for (Listener l : mListeners) {
923 l.onAddressChanged(this, address, presentation);
924 }
925 }
926
927 /**
Tyler Gunnac60f952019-05-31 07:23:16 -0700928 * Returns the "address" associated with the conference. This is applicable in two cases:
929 * <ol>
930 * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as
931 * temporarily "not a conference"; we need to present the correct address in the in-call
932 * UI.</li>
933 * <li>When the conference is not hosted on the current device, we need to know the address
934 * information for the purpose of showing the original address to the user, as well as for
935 * logging to the call log.</li>
936 * </ol>
937 * @return The address of the conference, or {@code null} if not applicable.
938 * @hide
939 */
940 public final Uri getAddress() {
941 return mAddress;
942 }
943
944 /**
945 * Returns the address presentation associated with the conference.
946 * <p>
947 * This is applicable in two cases:
948 * <ol>
949 * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as
950 * temporarily "not a conference"; we need to present the correct address in the in-call
951 * UI.</li>
952 * <li>When the conference is not hosted on the current device, we need to know the address
953 * information for the purpose of showing the original address to the user, as well as for
954 * logging to the call log.</li>
955 * </ol>
956 * @return The address of the conference, or {@code null} if not applicable.
957 * @hide
958 */
959 public final int getAddressPresentation() {
960 return mAddressPresentation;
961 }
962
963 /**
964 * @return The caller display name (CNAP).
965 * @hide
966 */
967 public final String getCallerDisplayName() {
968 return mCallerDisplayName;
969 }
970
971 /**
972 * @return The presentation requirements for the handle.
973 * See {@link TelecomManager} for valid values.
974 * @hide
975 */
976 public final int getCallerDisplayNamePresentation() {
977 return mCallerDisplayNamePresentation;
978 }
979
980 /**
Tyler Gunn68a73a42018-10-03 15:38:57 -0700981 * Sets the caller display name (CNAP) of this {@link Conference}. Used when
982 * {@link #setConferenceState(boolean)} is called to mark a conference temporarily as NOT a
983 * conference.
Tyler Gunn5567d742019-10-31 13:04:37 -0700984 * <p>
985 * Note: This is a Telephony-specific implementation detail related to IMS conferences. It is
986 * not intended for use outside of the Telephony stack.
Tyler Gunn68a73a42018-10-03 15:38:57 -0700987 *
988 * @param callerDisplayName The new display name.
989 * @param presentation The presentation requirements for the handle.
990 * See {@link TelecomManager} for valid values.
991 * @hide
992 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700993 @SystemApi
994 @TestApi
995 public final void setCallerDisplayName(@NonNull String callerDisplayName,
996 @TelecomManager.Presentation int presentation) {
Tyler Gunn68a73a42018-10-03 15:38:57 -0700997 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Tyler Gunnac60f952019-05-31 07:23:16 -0700998 mCallerDisplayName = callerDisplayName;
999 mCallerDisplayNamePresentation = presentation;
Tyler Gunn68a73a42018-10-03 15:38:57 -07001000 for (Listener l : mListeners) {
1001 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
1002 }
1003 }
1004
1005 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001006 * Handles a change to extras received from Telecom.
1007 *
1008 * @param extras The new extras.
1009 * @hide
1010 */
1011 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001012 Bundle b = null;
1013 synchronized (mExtrasLock) {
1014 mExtras = extras;
1015 if (mExtras != null) {
1016 b = new Bundle(mExtras);
1017 }
1018 }
1019 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07001020 }
Hall Liuc9bc1c62019-04-16 14:00:55 -07001021
1022 /**
Tyler Gunn5567d742019-10-31 13:04:37 -07001023 * Sends an event associated with this {@code Conference} with associated event extras to the
1024 * {@link InCallService} (note: this is identical in concept to
1025 * {@link Connection#sendConnectionEvent(String, Bundle)}).
1026 * @see Connection#sendConnectionEvent(String, Bundle)
1027 *
1028 * @param event The connection event.
1029 * @param extras Optional bundle containing extra information associated with the event.
Hall Liuc9bc1c62019-04-16 14:00:55 -07001030 */
Tyler Gunn5567d742019-10-31 13:04:37 -07001031 public void sendConferenceEvent(@NonNull String event, @Nullable Bundle extras) {
Hall Liuc9bc1c62019-04-16 14:00:55 -07001032 for (Listener l : mListeners) {
1033 l.onConnectionEvent(this, event, extras);
1034 }
1035 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07001036}