blob: d669e905e4df2a882444dcf7e5a153803dcd5f63 [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;
Wei Huang7f7f72e2018-05-30 19:21:36 +080027import android.telephony.ServiceState;
28import android.telephony.TelephonyManager;
Tyler Gunndee56a82016-03-23 16:06:34 -070029import android.util.ArraySet;
Evan Charlton0e094d92014-11-08 15:49:16 -080030
Ihab Awad50e35062014-09-30 09:17:03 -070031import java.util.ArrayList;
Tyler Gunn071be6f2016-05-10 14:52:33 -070032import java.util.Arrays;
Santos Cordon823fd3c2014-08-07 18:35:18 -070033import java.util.Collections;
Santos Cordon823fd3c2014-08-07 18:35:18 -070034import java.util.List;
Rekha Kumar07366812015-03-24 16:42:31 -070035import java.util.Locale;
Santos Cordon823fd3c2014-08-07 18:35:18 -070036import java.util.Set;
37import java.util.concurrent.CopyOnWriteArrayList;
38import java.util.concurrent.CopyOnWriteArraySet;
39
40/**
41 * Represents a conference call which can contain any number of {@link Connection} objects.
42 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -070043public abstract class Conference extends Conferenceable {
Santos Cordon823fd3c2014-08-07 18:35:18 -070044
Tyler Gunncd5d33c2015-01-12 09:02:01 -080045 /**
46 * Used to indicate that the conference connection time is not specified. If not specified,
47 * Telecom will set the connect time.
48 */
Jay Shrauner164a0ac2015-04-14 18:16:10 -070049 public static final long CONNECT_TIME_NOT_SPECIFIED = 0;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080050
Santos Cordon823fd3c2014-08-07 18:35:18 -070051 /** @hide */
Tyler Gunn5567d742019-10-31 13:04:37 -070052 abstract static class Listener {
Santos Cordon823fd3c2014-08-07 18:35:18 -070053 public void onStateChanged(Conference conference, int oldState, int newState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -070054 public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070055 public void onConnectionAdded(Conference conference, Connection connection) {}
56 public void onConnectionRemoved(Conference conference, Connection connection) {}
Ihab Awad50e35062014-09-30 09:17:03 -070057 public void onConferenceableConnectionsChanged(
58 Conference conference, List<Connection> conferenceableConnections) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070059 public void onDestroyed(Conference conference) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -080060 public void onConnectionCapabilitiesChanged(
61 Conference conference, int connectionCapabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -070062 public void onConnectionPropertiesChanged(
63 Conference conference, int connectionProperties) {}
Rekha Kumar07366812015-03-24 16:42:31 -070064 public void onVideoStateChanged(Conference c, int videoState) { }
65 public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {}
Andrew Leeedc625f2015-04-14 13:38:12 -070066 public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {}
Tyler Gunndee56a82016-03-23 16:06:34 -070067 public void onExtrasChanged(Conference c, Bundle extras) {}
68 public void onExtrasRemoved(Conference c, List<String> keys) {}
Tyler Gunn68a73a42018-10-03 15:38:57 -070069 public void onConferenceStateChanged(Conference c, boolean isConference) {}
70 public void onAddressChanged(Conference c, Uri newAddress, int presentation) {}
Hall Liuc9bc1c62019-04-16 14:00:55 -070071 public void onConnectionEvent(Conference c, String event, Bundle extras) {}
Tyler Gunn68a73a42018-10-03 15:38:57 -070072 public void onCallerDisplayNameChanged(
73 Conference c, String callerDisplayName, int presentation) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -070074 }
75
76 private final Set<Listener> mListeners = new CopyOnWriteArraySet<>();
77 private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>();
Ihab Awadb8e85c72014-08-23 20:34:57 -070078 private final List<Connection> mUnmodifiableChildConnections =
Santos Cordon823fd3c2014-08-07 18:35:18 -070079 Collections.unmodifiableList(mChildConnections);
Ihab Awad50e35062014-09-30 09:17:03 -070080 private final List<Connection> mConferenceableConnections = new ArrayList<>();
81 private final List<Connection> mUnmodifiableConferenceableConnections =
82 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -070083
Jack Yu67140302015-12-10 12:27:58 -080084 private String mTelecomCallId;
Jay Shrauner164a0ac2015-04-14 18:16:10 -070085 private PhoneAccountHandle mPhoneAccount;
Yorke Lee4af59352015-05-13 14:14:54 -070086 private CallAudioState mCallAudioState;
Santos Cordon823fd3c2014-08-07 18:35:18 -070087 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070088 private DisconnectCause mDisconnectCause;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080089 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -070090 private int mConnectionProperties;
Santos Cordon823fd3c2014-08-07 18:35:18 -070091 private String mDisconnectMessage;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080092 private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn17541392018-02-01 08:58:38 -080093 private long mConnectionStartElapsedRealTime = CONNECT_TIME_NOT_SPECIFIED;
Andrew Leeedc625f2015-04-14 13:38:12 -070094 private StatusHints mStatusHints;
Santos Cordon6b7f9552015-05-27 17:21:45 -070095 private Bundle mExtras;
Tyler Gunndee56a82016-03-23 16:06:34 -070096 private Set<String> mPreviousExtraKeys;
Brad Ebinger4fa6a012016-06-14 17:04:01 -070097 private final Object mExtrasLock = new Object();
Tyler Gunnac60f952019-05-31 07:23:16 -070098 private Uri mAddress;
99 private int mAddressPresentation;
100 private String mCallerDisplayName;
101 private int mCallerDisplayNamePresentation;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700102
Ihab Awad50e35062014-09-30 09:17:03 -0700103 private final Connection.Listener mConnectionDeathListener = new Connection.Listener() {
104 @Override
105 public void onDestroyed(Connection c) {
106 if (mConferenceableConnections.remove(c)) {
107 fireOnConferenceableConnectionsChanged();
108 }
109 }
110 };
111
Nancy Chen56fc25d2014-09-09 12:24:51 -0700112 /**
113 * Constructs a new Conference with a mandatory {@link PhoneAccountHandle}
114 *
115 * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference.
116 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700117 public Conference(PhoneAccountHandle phoneAccount) {
118 mPhoneAccount = phoneAccount;
119 }
120
Nancy Chen56fc25d2014-09-09 12:24:51 -0700121 /**
Jack Yu67140302015-12-10 12:27:58 -0800122 * Returns the telecom internal call ID associated with this conference.
Tyler Gunn5567d742019-10-31 13:04:37 -0700123 * <p>
124 * Note: This is ONLY used for debugging purposes so that the Telephony stack can better
125 * associate logs in Telephony with those in Telecom.
126 * The ID returned should not be used for any other purpose.
Jack Yu67140302015-12-10 12:27:58 -0800127 *
128 * @return The telecom call ID.
129 * @hide
130 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700131 @SystemApi
132 @TestApi
133 public final @NonNull String getTelecomCallId() {
Jack Yu67140302015-12-10 12:27:58 -0800134 return mTelecomCallId;
135 }
136
137 /**
138 * Sets the telecom internal call ID associated with this conference.
139 *
140 * @param telecomCallId The telecom call ID.
141 * @hide
142 */
143 public final void setTelecomCallId(String telecomCallId) {
144 mTelecomCallId = telecomCallId;
145 }
146
147 /**
Nancy Chen56fc25d2014-09-09 12:24:51 -0700148 * Returns the {@link PhoneAccountHandle} the conference call is being placed through.
149 *
150 * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference.
151 */
Nancy Chenea38cca2014-09-05 16:38:49 -0700152 public final PhoneAccountHandle getPhoneAccountHandle() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700153 return mPhoneAccount;
154 }
155
Nancy Chen56fc25d2014-09-09 12:24:51 -0700156 /**
157 * Returns the list of connections currently associated with the conference call.
158 *
159 * @return A list of {@code Connection} objects which represent the children of the conference.
160 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700161 public final List<Connection> getConnections() {
Ihab Awadb8e85c72014-08-23 20:34:57 -0700162 return mUnmodifiableChildConnections;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700163 }
164
Nancy Chen56fc25d2014-09-09 12:24:51 -0700165 /**
166 * Gets the state of the conference call. See {@link Connection} for valid values.
167 *
168 * @return A constant representing the state the conference call is currently in.
169 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700170 public final int getState() {
171 return mState;
172 }
173
Nancy Chen56fc25d2014-09-09 12:24:51 -0700174 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700175 * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800176 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700177 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800178 * @return A bitmask of the capabilities of the conference call.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700179 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800180 public final int getConnectionCapabilities() {
181 return mConnectionCapabilities;
182 }
183
184 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700185 * Returns the properties of the conference. See {@code PROPERTY_*} constants in class
186 * {@link Connection} for valid values.
187 *
188 * @return A bitmask of the properties of the conference call.
189 */
190 public final int getConnectionProperties() {
191 return mConnectionProperties;
192 }
193
194 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700195 * @return The audio state of the conference, describing how its audio is currently
196 * being routed by the system. This is {@code null} if this Conference
197 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700198 * @deprecated Use {@link #getCallAudioState()} instead.
199 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700200 */
Yorke Lee4af59352015-05-13 14:14:54 -0700201 @Deprecated
202 @SystemApi
Yorke Leea0d3ca92014-09-15 19:18:13 -0700203 public final AudioState getAudioState() {
Yorke Lee4af59352015-05-13 14:14:54 -0700204 return new AudioState(mCallAudioState);
205 }
206
207 /**
208 * @return The audio state of the conference, describing how its audio is currently
209 * being routed by the system. This is {@code null} if this Conference
210 * does not directly know about its audio state.
211 */
212 public final CallAudioState getCallAudioState() {
213 return mCallAudioState;
Yorke Leea0d3ca92014-09-15 19:18:13 -0700214 }
215
216 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700217 * Returns VideoProvider of the primary call. This can be null.
Rekha Kumar07366812015-03-24 16:42:31 -0700218 */
219 public VideoProvider getVideoProvider() {
220 return null;
221 }
222
223 /**
224 * Returns video state of the primary call.
Rekha Kumar07366812015-03-24 16:42:31 -0700225 */
226 public int getVideoState() {
Tyler Gunn87b73f32015-06-03 10:09:59 -0700227 return VideoProfile.STATE_AUDIO_ONLY;
Rekha Kumar07366812015-03-24 16:42:31 -0700228 }
229
230 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700231 * Notifies the {@link Conference} when the Conference and all it's {@link Connection}s should
232 * be disconnected.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700233 */
234 public void onDisconnect() {}
235
236 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700237 * Notifies the {@link Conference} when the specified {@link Connection} should be separated
238 * from the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700239 *
240 * @param connection The connection to separate.
241 */
242 public void onSeparate(Connection connection) {}
243
244 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700245 * Notifies the {@link Conference} when the specified {@link Connection} should merged with the
246 * conference call.
Ihab Awad50e35062014-09-30 09:17:03 -0700247 *
248 * @param connection The {@code Connection} to merge.
249 */
250 public void onMerge(Connection connection) {}
251
252 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700253 * Notifies the {@link Conference} when it should be put on hold.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700254 */
255 public void onHold() {}
256
257 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700258 * Notifies the {@link Conference} when it should be moved from a held to active state.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700259 */
260 public void onUnhold() {}
261
262 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700263 * Notifies the {@link Conference} when the child calls should be merged. Only invoked if the
264 * conference contains the capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700265 */
266 public void onMerge() {}
267
268 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700269 * Notifies the {@link Conference} when the child calls should be swapped. Only invoked if the
270 * conference contains the capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700271 */
272 public void onSwap() {}
273
274 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700275 * Notifies the {@link Conference} of a request to play a DTMF tone.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700276 *
277 * @param c A DTMF character.
278 */
279 public void onPlayDtmfTone(char c) {}
280
281 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700282 * Notifies the {@link Conference} of a request to stop any currently playing DTMF tones.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700283 */
284 public void onStopDtmfTone() {}
285
286 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700287 * Notifies the {@link Conference} that the {@link #getAudioState()} property has a new value.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700288 *
289 * @param state The new call audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700290 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
291 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700292 */
Yorke Lee4af59352015-05-13 14:14:54 -0700293 @SystemApi
294 @Deprecated
Yorke Leea0d3ca92014-09-15 19:18:13 -0700295 public void onAudioStateChanged(AudioState state) {}
296
297 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700298 * Notifies the {@link Conference} that the {@link #getCallAudioState()} property has a new
299 * value.
Yorke Lee4af59352015-05-13 14:14:54 -0700300 *
301 * @param state The new call audio state.
302 */
303 public void onCallAudioStateChanged(CallAudioState state) {}
304
305 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700306 * Notifies the {@link Conference} that a {@link Connection} has been added to it.
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800307 *
308 * @param connection The newly added connection.
309 */
310 public void onConnectionAdded(Connection connection) {}
311
312 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700313 * Sets state to be on hold.
314 */
315 public final void setOnHold() {
316 setState(Connection.STATE_HOLDING);
317 }
318
319 /**
Tyler Gunnd46595a2015-06-01 14:29:11 -0700320 * Sets state to be dialing.
321 */
322 public final void setDialing() {
323 setState(Connection.STATE_DIALING);
324 }
325
326 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700327 * Sets state to be active.
328 */
329 public final void setActive() {
330 setState(Connection.STATE_ACTIVE);
331 }
332
333 /**
334 * Sets state to disconnected.
335 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700336 * @param disconnectCause The reason for the disconnection, as described by
337 * {@link android.telecom.DisconnectCause}.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700338 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700339 public final void setDisconnected(DisconnectCause disconnectCause) {
340 mDisconnectCause = disconnectCause;;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700341 setState(Connection.STATE_DISCONNECTED);
342 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700343 l.onDisconnected(this, mDisconnectCause);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700344 }
345 }
346
347 /**
mike dooley1cf14ac2014-11-04 10:59:53 -0800348 * @return The {@link DisconnectCause} for this connection.
349 */
350 public final DisconnectCause getDisconnectCause() {
351 return mDisconnectCause;
352 }
353
354 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800355 * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class
356 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700357 *
Tyler Gunn720c6642016-03-22 09:02:47 -0700358 * @param connectionCapabilities A bitmask of the {@code Capabilities} of the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700359 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800360 public final void setConnectionCapabilities(int connectionCapabilities) {
361 if (connectionCapabilities != mConnectionCapabilities) {
362 mConnectionCapabilities = connectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700363
364 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800365 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700366 }
367 }
368 }
369
370 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700371 * Sets the properties of a conference. See {@code PROPERTY_*} constants of class
372 * {@link Connection} for valid values.
373 *
374 * @param connectionProperties A bitmask of the {@code Properties} of the conference call.
375 */
376 public final void setConnectionProperties(int connectionProperties) {
377 if (connectionProperties != mConnectionProperties) {
378 mConnectionProperties = connectionProperties;
379
380 for (Listener l : mListeners) {
381 l.onConnectionPropertiesChanged(this, mConnectionProperties);
382 }
383 }
384 }
385
386 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700387 * Adds the specified connection as a child of this conference.
388 *
389 * @param connection The connection to add.
390 * @return True if the connection was successfully added.
391 */
Santos Cordona4868042014-09-04 17:39:22 -0700392 public final boolean addConnection(Connection connection) {
Rekha Kumar07366812015-03-24 16:42:31 -0700393 Log.d(this, "Connection=%s, connection=", connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700394 if (connection != null && !mChildConnections.contains(connection)) {
395 if (connection.setConference(this)) {
396 mChildConnections.add(connection);
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800397 onConnectionAdded(connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700398 for (Listener l : mListeners) {
399 l.onConnectionAdded(this, connection);
400 }
401 return true;
402 }
403 }
404 return false;
405 }
406
407 /**
408 * Removes the specified connection as a child of this conference.
409 *
410 * @param connection The connection to remove.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700411 */
Santos Cordona4868042014-09-04 17:39:22 -0700412 public final void removeConnection(Connection connection) {
Santos Cordon0159ac02014-08-21 14:28:11 -0700413 Log.d(this, "removing %s from %s", connection, mChildConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700414 if (connection != null && mChildConnections.remove(connection)) {
415 connection.resetConference();
416 for (Listener l : mListeners) {
417 l.onConnectionRemoved(this, connection);
418 }
419 }
420 }
421
422 /**
Ihab Awad50e35062014-09-30 09:17:03 -0700423 * Sets the connections with which this connection can be conferenced.
424 *
425 * @param conferenceableConnections The set of connections this connection can conference with.
426 */
427 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
428 clearConferenceableList();
429 for (Connection c : conferenceableConnections) {
430 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
431 // small amount of items here.
432 if (!mConferenceableConnections.contains(c)) {
433 c.addConnectionListener(mConnectionDeathListener);
434 mConferenceableConnections.add(c);
435 }
436 }
437 fireOnConferenceableConnectionsChanged();
438 }
439
Rekha Kumar07366812015-03-24 16:42:31 -0700440 /**
441 * Set the video state for the conference.
Yorke Lee32f24732015-05-12 16:18:03 -0700442 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
443 * {@link VideoProfile#STATE_BIDIRECTIONAL},
444 * {@link VideoProfile#STATE_TX_ENABLED},
445 * {@link VideoProfile#STATE_RX_ENABLED}.
Rekha Kumar07366812015-03-24 16:42:31 -0700446 *
447 * @param videoState The new video state.
Rekha Kumar07366812015-03-24 16:42:31 -0700448 */
449 public final void setVideoState(Connection c, int videoState) {
450 Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s",
451 this, c, videoState);
452 for (Listener l : mListeners) {
453 l.onVideoStateChanged(this, videoState);
454 }
455 }
456
457 /**
458 * Sets the video connection provider.
459 *
460 * @param videoProvider The video provider.
Rekha Kumar07366812015-03-24 16:42:31 -0700461 */
462 public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) {
463 Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s",
464 this, c, videoProvider);
465 for (Listener l : mListeners) {
466 l.onVideoProviderChanged(this, videoProvider);
467 }
468 }
469
Ihab Awad50e35062014-09-30 09:17:03 -0700470 private final void fireOnConferenceableConnectionsChanged() {
471 for (Listener l : mListeners) {
472 l.onConferenceableConnectionsChanged(this, getConferenceableConnections());
473 }
474 }
475
476 /**
477 * Returns the connections with which this connection can be conferenced.
478 */
479 public final List<Connection> getConferenceableConnections() {
480 return mUnmodifiableConferenceableConnections;
481 }
482
483 /**
Nancy Chenea38cca2014-09-05 16:38:49 -0700484 * Tears down the conference object and any of its current connections.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700485 */
Santos Cordona4868042014-09-04 17:39:22 -0700486 public final void destroy() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700487 Log.d(this, "destroying conference : %s", this);
488 // Tear down the children.
Santos Cordon0159ac02014-08-21 14:28:11 -0700489 for (Connection connection : mChildConnections) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700490 Log.d(this, "removing connection %s", connection);
491 removeConnection(connection);
492 }
493
494 // If not yet disconnected, set the conference call as disconnected first.
495 if (mState != Connection.STATE_DISCONNECTED) {
496 Log.d(this, "setting to disconnected");
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700497 setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
Santos Cordon823fd3c2014-08-07 18:35:18 -0700498 }
499
500 // ...and notify.
501 for (Listener l : mListeners) {
502 l.onDestroyed(this);
503 }
504 }
505
506 /**
507 * Add a listener to be notified of a state change.
508 *
509 * @param listener The new listener.
510 * @return This conference.
511 * @hide
512 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700513 final Conference addListener(Listener listener) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700514 mListeners.add(listener);
515 return this;
516 }
517
518 /**
519 * Removes the specified listener.
520 *
521 * @param listener The listener to remove.
522 * @return This conference.
523 * @hide
524 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700525 final Conference removeListener(Listener listener) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700526 mListeners.remove(listener);
527 return this;
528 }
529
Yorke Leea0d3ca92014-09-15 19:18:13 -0700530 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700531 * Retrieves the primary connection associated with the conference. The primary connection is
532 * the connection from which the conference will retrieve its current state.
533 *
534 * @return The primary connection.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700535 * @hide
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700536 */
Tyler Gunn6c14a6992019-02-04 15:12:06 -0800537 @TestApi
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700538 @SystemApi
Santos Cordon4055d642015-05-12 14:19:24 -0700539 public Connection getPrimaryConnection() {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700540 if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) {
541 return null;
542 }
543 return mUnmodifiableChildConnections.get(0);
544 }
545
546 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700547 * @hide
548 * @deprecated Use {@link #setConnectionTime}.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800549 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700550 @Deprecated
551 @SystemApi
552 public final void setConnectTimeMillis(long connectTimeMillis) {
553 setConnectionTime(connectTimeMillis);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800554 }
555
556 /**
Tyler Gunn17541392018-02-01 08:58:38 -0800557 * Sets the connection start time of the {@code Conference}. This is used in the call log to
558 * indicate the date and time when the conference took place.
559 * <p>
560 * Should be specified in wall-clock time returned by {@link System#currentTimeMillis()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700561 * <p>
562 * When setting the connection time, you should always set the connection elapsed time via
Tyler Gunn17541392018-02-01 08:58:38 -0800563 * {@link #setConnectionStartElapsedRealTime(long)} to ensure the duration is reflected.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700564 *
Tyler Gunn17541392018-02-01 08:58:38 -0800565 * @param connectionTimeMillis The connection time, in milliseconds, as returned by
566 * {@link System#currentTimeMillis()}.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700567 */
568 public final void setConnectionTime(long connectionTimeMillis) {
569 mConnectTimeMillis = connectionTimeMillis;
570 }
571
572 /**
Tyler Gunn17541392018-02-01 08:58:38 -0800573 * Sets the start time of the {@link Conference} which is the basis for the determining the
574 * duration of the {@link Conference}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700575 * <p>
Tyler Gunn17541392018-02-01 08:58:38 -0800576 * You should use a value returned by {@link SystemClock#elapsedRealtime()} to ensure that time
577 * zone changes do not impact the conference duration.
578 * <p>
579 * When setting this, you should also set the connection time via
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700580 * {@link #setConnectionTime(long)}.
581 *
Tyler Gunn17541392018-02-01 08:58:38 -0800582 * @param connectionStartElapsedRealTime The connection time, as measured by
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700583 * {@link SystemClock#elapsedRealtime()}.
584 */
Tyler Gunn17541392018-02-01 08:58:38 -0800585 public final void setConnectionStartElapsedRealTime(long connectionStartElapsedRealTime) {
586 mConnectionStartElapsedRealTime = connectionStartElapsedRealTime;
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700587 }
588
589 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700590 * @hide
591 * @deprecated Use {@link #getConnectionTime}.
592 */
593 @Deprecated
594 @SystemApi
595 public final long getConnectTimeMillis() {
596 return getConnectionTime();
597 }
598
599 /**
600 * Retrieves the connection start time of the {@code Conference}, if specified. A value of
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800601 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
602 * of the conference.
603 *
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700604 * @return The time at which the {@code Conference} was connected.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800605 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700606 public final long getConnectionTime() {
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800607 return mConnectTimeMillis;
608 }
609
610 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700611 * Retrieves the connection start time of the {@link Conference}, if specified. A value of
612 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
613 * of the conference.
Tyler Gunn5567d742019-10-31 13:04:37 -0700614 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700615 * This is based on the value of {@link SystemClock#elapsedRealtime()} to ensure that it is not
616 * impacted by wall clock changes (user initiated, network initiated, time zone change, etc).
Tyler Gunn5567d742019-10-31 13:04:37 -0700617 * <p>
618 * Note: This is only exposed for use by the Telephony framework which needs it to copy
619 * conference start times among conference participants. It is exposed as a system API since it
620 * has no general use other than to the Telephony framework.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700621 *
622 * @return The elapsed time at which the {@link Conference} was connected.
623 * @hide
624 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700625 @SystemApi
626 @TestApi
Tyler Gunn17541392018-02-01 08:58:38 -0800627 public final long getConnectionStartElapsedRealTime() {
628 return mConnectionStartElapsedRealTime;
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700629 }
630
631 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700632 * Inform this Conference that the state of its audio output has been changed externally.
633 *
634 * @param state The new audio state.
635 * @hide
636 */
Yorke Lee4af59352015-05-13 14:14:54 -0700637 final void setCallAudioState(CallAudioState state) {
638 Log.d(this, "setCallAudioState %s", state);
639 mCallAudioState = state;
640 onAudioStateChanged(getAudioState());
641 onCallAudioStateChanged(state);
Yorke Leea0d3ca92014-09-15 19:18:13 -0700642 }
643
Santos Cordon823fd3c2014-08-07 18:35:18 -0700644 private void setState(int newState) {
645 if (newState != Connection.STATE_ACTIVE &&
646 newState != Connection.STATE_HOLDING &&
647 newState != Connection.STATE_DISCONNECTED) {
648 Log.w(this, "Unsupported state transition for Conference call.",
649 Connection.stateToString(newState));
650 return;
651 }
652
653 if (mState != newState) {
654 int oldState = mState;
655 mState = newState;
656 for (Listener l : mListeners) {
657 l.onStateChanged(this, oldState, newState);
658 }
659 }
660 }
Ihab Awad50e35062014-09-30 09:17:03 -0700661
662 private final void clearConferenceableList() {
663 for (Connection c : mConferenceableConnections) {
664 c.removeConnectionListener(mConnectionDeathListener);
665 }
666 mConferenceableConnections.clear();
667 }
Rekha Kumar07366812015-03-24 16:42:31 -0700668
669 @Override
670 public String toString() {
671 return String.format(Locale.US,
672 "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]",
673 Connection.stateToString(mState),
674 Call.Details.capabilitiesToString(mConnectionCapabilities),
675 getVideoState(),
676 getVideoProvider(),
677 super.toString());
678 }
Andrew Lee0f51da32015-04-16 13:11:55 -0700679
Andrew Leeedc625f2015-04-14 13:38:12 -0700680 /**
681 * Sets the label and icon status to display in the InCall UI.
682 *
683 * @param statusHints The status label and icon to set.
684 */
685 public final void setStatusHints(StatusHints statusHints) {
686 mStatusHints = statusHints;
687 for (Listener l : mListeners) {
688 l.onStatusHintsChanged(this, statusHints);
689 }
690 }
691
692 /**
693 * @return The status hints for this conference.
694 */
695 public final StatusHints getStatusHints() {
696 return mStatusHints;
697 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700698
699 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700700 * Replaces all the extras associated with this {@code Conference}.
701 * <p>
702 * New or existing keys are replaced in the {@code Conference} extras. Keys which are no longer
703 * in the new extras, but were present the last time {@code setExtras} was called are removed.
704 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700705 * Alternatively you may use the {@link #putExtras(Bundle)}, and
706 * {@link #removeExtras(String...)} methods to modify the extras.
707 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -0700708 * 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 -0700709 * Keys should be fully qualified (e.g., com.example.extras.MY_EXTRA) to avoid conflicts.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700710 *
Tyler Gunndee56a82016-03-23 16:06:34 -0700711 * @param extras The extras associated with this {@code Conference}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700712 */
713 public final void setExtras(@Nullable Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700714 // Keeping putExtras and removeExtras in the same lock so that this operation happens as a
715 // block instead of letting other threads put/remove while this method is running.
716 synchronized (mExtrasLock) {
717 // Add/replace any new or changed extras values.
718 putExtras(extras);
719 // If we have used "setExtras" in the past, compare the key set from the last invocation
720 // to the current one and remove any keys that went away.
721 if (mPreviousExtraKeys != null) {
722 List<String> toRemove = new ArrayList<String>();
723 for (String oldKey : mPreviousExtraKeys) {
724 if (extras == null || !extras.containsKey(oldKey)) {
725 toRemove.add(oldKey);
726 }
727 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700728
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700729 if (!toRemove.isEmpty()) {
730 removeExtras(toRemove);
Tyler Gunndee56a82016-03-23 16:06:34 -0700731 }
732 }
733
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700734 // Track the keys the last time set called setExtras. This way, the next time setExtras
735 // is called we can see if the caller has removed any extras values.
736 if (mPreviousExtraKeys == null) {
737 mPreviousExtraKeys = new ArraySet<String>();
Tyler Gunndee56a82016-03-23 16:06:34 -0700738 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700739 mPreviousExtraKeys.clear();
740 if (extras != null) {
741 mPreviousExtraKeys.addAll(extras.keySet());
742 }
Tyler Gunna8fb8ab2016-03-29 10:24:22 -0700743 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700744 }
745
746 /**
747 * Adds some extras to this {@link Conference}. Existing keys are replaced and new ones are
748 * added.
749 * <p>
750 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
751 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
752 *
753 * @param extras The extras to add.
754 */
755 public final void putExtras(@NonNull Bundle extras) {
756 if (extras == null) {
757 return;
758 }
759
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700760 // Creating a Bundle clone so we don't have to synchronize on mExtrasLock while calling
761 // onExtrasChanged.
762 Bundle listenersBundle;
763 synchronized (mExtrasLock) {
764 if (mExtras == null) {
765 mExtras = new Bundle();
766 }
767 mExtras.putAll(extras);
768 listenersBundle = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -0700769 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700770
Santos Cordon6b7f9552015-05-27 17:21:45 -0700771 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700772 l.onExtrasChanged(this, new Bundle(listenersBundle));
Santos Cordon6b7f9552015-05-27 17:21:45 -0700773 }
774 }
775
776 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700777 * Adds a boolean extra to this {@link Conference}.
778 *
779 * @param key The extra key.
780 * @param value The value.
781 * @hide
782 */
783 public final void putExtra(String key, boolean value) {
784 Bundle newExtras = new Bundle();
785 newExtras.putBoolean(key, value);
786 putExtras(newExtras);
787 }
788
789 /**
790 * Adds an integer extra to this {@link Conference}.
791 *
792 * @param key The extra key.
793 * @param value The value.
794 * @hide
795 */
796 public final void putExtra(String key, int value) {
797 Bundle newExtras = new Bundle();
798 newExtras.putInt(key, value);
799 putExtras(newExtras);
800 }
801
802 /**
803 * Adds a string extra to this {@link Conference}.
804 *
805 * @param key The extra key.
806 * @param value The value.
807 * @hide
808 */
809 public final void putExtra(String key, String value) {
810 Bundle newExtras = new Bundle();
811 newExtras.putString(key, value);
812 putExtras(newExtras);
813 }
814
815 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -0700816 * Removes extras from this {@link Conference}.
Tyler Gunndee56a82016-03-23 16:06:34 -0700817 *
Tyler Gunn071be6f2016-05-10 14:52:33 -0700818 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -0700819 */
820 public final void removeExtras(List<String> keys) {
821 if (keys == null || keys.isEmpty()) {
822 return;
823 }
824
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700825 synchronized (mExtrasLock) {
826 if (mExtras != null) {
827 for (String key : keys) {
828 mExtras.remove(key);
829 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700830 }
831 }
832
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700833 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -0700834 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700835 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -0700836 }
837 }
838
839 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -0700840 * Removes extras from this {@link Conference}.
841 *
842 * @param keys The keys of the extras to remove.
843 */
844 public final void removeExtras(String ... keys) {
845 removeExtras(Arrays.asList(keys));
846 }
847
848 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700849 * Returns the extras associated with this conference.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +0000850 * <p>
851 * Extras should be updated using {@link #putExtras(Bundle)} and {@link #removeExtras(List)}.
852 * <p>
853 * Telecom or an {@link InCallService} can also update the extras via
854 * {@link android.telecom.Call#putExtras(Bundle)}, and
855 * {@link Call#removeExtras(List)}.
856 * <p>
857 * The conference is notified of changes to the extras made by Telecom or an
858 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -0700859 *
860 * @return The extras associated with this connection.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700861 */
862 public final Bundle getExtras() {
863 return mExtras;
864 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700865
866 /**
867 * Notifies this {@link Conference} of a change to the extras made outside the
868 * {@link ConnectionService}.
869 * <p>
870 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
871 * {@link android.telecom.Call#putExtras(Bundle)}, and
872 * {@link Call#removeExtras(List)}.
873 *
874 * @param extras The new extras bundle.
875 */
876 public void onExtrasChanged(Bundle extras) {}
877
878 /**
Tyler Gunn68a73a42018-10-03 15:38:57 -0700879 * Set whether Telecom should treat this {@link Conference} as a conference call or if it
880 * should treat it as a single-party call.
881 * This method is used as part of a workaround regarding IMS conference calls and user
882 * expectation. In IMS, once a conference is formed, the UE is connected to an IMS conference
883 * server. If all participants of the conference drop out of the conference except for one, the
884 * UE is still connected to the IMS conference server. At this point, the user logically
885 * assumes they're no longer in a conference, yet the underlying network actually is.
886 * To help provide a better user experiece, IMS conference calls can pretend to actually be a
887 * single-party call when the participant count drops to 1. Although the dialer/phone app
888 * could perform this trickery, it makes sense to do this in Telephony since a fix there will
889 * ensure that bluetooth head units, auto and wearable apps all behave consistently.
Tyler Gunn5567d742019-10-31 13:04:37 -0700890 * <p>
891 * This API is intended for use by the platform Telephony stack only.
Tyler Gunn68a73a42018-10-03 15:38:57 -0700892 *
893 * @param isConference {@code true} if this {@link Conference} should be treated like a
894 * conference call, {@code false} if it should be treated like a single-party call.
895 * @hide
896 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700897 @SystemApi
898 @TestApi
Tyler Gunn68a73a42018-10-03 15:38:57 -0700899 public void setConferenceState(boolean isConference) {
900 for (Listener l : mListeners) {
901 l.onConferenceStateChanged(this, isConference);
902 }
903 }
904
905 /**
906 * Sets the address of this {@link Conference}. Used when {@link #setConferenceState(boolean)}
907 * is called to mark a conference temporarily as NOT a conference.
Tyler Gunn5567d742019-10-31 13:04:37 -0700908 * <p>
909 * Note: This is a Telephony-specific implementation detail related to IMS conferences. It is
910 * not intended for use outside of the Telephony stack.
Tyler Gunn68a73a42018-10-03 15:38:57 -0700911 *
912 * @param address The new address.
913 * @param presentation The presentation requirements for the address.
914 * See {@link TelecomManager} for valid values.
915 * @hide
916 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700917 @SystemApi
918 @TestApi
919 public final void setAddress(@NonNull Uri address,
920 @TelecomManager.Presentation int presentation) {
Tyler Gunn68a73a42018-10-03 15:38:57 -0700921 Log.d(this, "setAddress %s", address);
Tyler Gunnac60f952019-05-31 07:23:16 -0700922 mAddress = address;
923 mAddressPresentation = presentation;
Tyler Gunn68a73a42018-10-03 15:38:57 -0700924 for (Listener l : mListeners) {
925 l.onAddressChanged(this, address, presentation);
926 }
927 }
928
929 /**
Tyler Gunnac60f952019-05-31 07:23:16 -0700930 * Returns the "address" associated with the conference. This is applicable in two cases:
931 * <ol>
932 * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as
933 * temporarily "not a conference"; we need to present the correct address in the in-call
934 * UI.</li>
935 * <li>When the conference is not hosted on the current device, we need to know the address
936 * information for the purpose of showing the original address to the user, as well as for
937 * logging to the call log.</li>
938 * </ol>
939 * @return The address of the conference, or {@code null} if not applicable.
940 * @hide
941 */
942 public final Uri getAddress() {
943 return mAddress;
944 }
945
946 /**
947 * Returns the address presentation associated with the conference.
948 * <p>
949 * This is applicable in two cases:
950 * <ol>
951 * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as
952 * temporarily "not a conference"; we need to present the correct address in the in-call
953 * UI.</li>
954 * <li>When the conference is not hosted on the current device, we need to know the address
955 * information for the purpose of showing the original address to the user, as well as for
956 * logging to the call log.</li>
957 * </ol>
958 * @return The address of the conference, or {@code null} if not applicable.
959 * @hide
960 */
961 public final int getAddressPresentation() {
962 return mAddressPresentation;
963 }
964
965 /**
966 * @return The caller display name (CNAP).
967 * @hide
968 */
969 public final String getCallerDisplayName() {
970 return mCallerDisplayName;
971 }
972
973 /**
974 * @return The presentation requirements for the handle.
975 * See {@link TelecomManager} for valid values.
976 * @hide
977 */
978 public final int getCallerDisplayNamePresentation() {
979 return mCallerDisplayNamePresentation;
980 }
981
982 /**
Tyler Gunn68a73a42018-10-03 15:38:57 -0700983 * Sets the caller display name (CNAP) of this {@link Conference}. Used when
984 * {@link #setConferenceState(boolean)} is called to mark a conference temporarily as NOT a
985 * conference.
Tyler Gunn5567d742019-10-31 13:04:37 -0700986 * <p>
987 * Note: This is a Telephony-specific implementation detail related to IMS conferences. It is
988 * not intended for use outside of the Telephony stack.
Tyler Gunn68a73a42018-10-03 15:38:57 -0700989 *
990 * @param callerDisplayName The new display name.
991 * @param presentation The presentation requirements for the handle.
992 * See {@link TelecomManager} for valid values.
993 * @hide
994 */
Tyler Gunn5567d742019-10-31 13:04:37 -0700995 @SystemApi
996 @TestApi
997 public final void setCallerDisplayName(@NonNull String callerDisplayName,
998 @TelecomManager.Presentation int presentation) {
Tyler Gunn68a73a42018-10-03 15:38:57 -0700999 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Tyler Gunnac60f952019-05-31 07:23:16 -07001000 mCallerDisplayName = callerDisplayName;
1001 mCallerDisplayNamePresentation = presentation;
Tyler Gunn68a73a42018-10-03 15:38:57 -07001002 for (Listener l : mListeners) {
1003 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
1004 }
1005 }
1006
1007 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001008 * Handles a change to extras received from Telecom.
1009 *
1010 * @param extras The new extras.
1011 * @hide
1012 */
1013 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001014 Bundle b = null;
1015 synchronized (mExtrasLock) {
1016 mExtras = extras;
1017 if (mExtras != null) {
1018 b = new Bundle(mExtras);
1019 }
1020 }
1021 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07001022 }
Hall Liuc9bc1c62019-04-16 14:00:55 -07001023
1024 /**
Tyler Gunn5567d742019-10-31 13:04:37 -07001025 * Sends an event associated with this {@code Conference} with associated event extras to the
1026 * {@link InCallService} (note: this is identical in concept to
1027 * {@link Connection#sendConnectionEvent(String, Bundle)}).
1028 * @see Connection#sendConnectionEvent(String, Bundle)
1029 *
1030 * @param event The connection event.
1031 * @param extras Optional bundle containing extra information associated with the event.
Hall Liuc9bc1c62019-04-16 14:00:55 -07001032 */
Tyler Gunn5567d742019-10-31 13:04:37 -07001033 public void sendConferenceEvent(@NonNull String event, @Nullable Bundle extras) {
Hall Liuc9bc1c62019-04-16 14:00:55 -07001034 for (Listener l : mListeners) {
1035 l.onConnectionEvent(this, event, extras);
1036 }
1037 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07001038}