blob: 6000b56d191ece7fb142f905ed76aa89ff7b2d8b [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 Gunn124f1f62019-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 */
52 public abstract static class Listener {
53 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 Liua5400912019-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();
Santos Cordon823fd3c2014-08-07 18:35:18 -070098
Ihab Awad50e35062014-09-30 09:17:03 -070099 private final Connection.Listener mConnectionDeathListener = new Connection.Listener() {
100 @Override
101 public void onDestroyed(Connection c) {
102 if (mConferenceableConnections.remove(c)) {
103 fireOnConferenceableConnectionsChanged();
104 }
105 }
106 };
107
Nancy Chen56fc25d2014-09-09 12:24:51 -0700108 /**
109 * Constructs a new Conference with a mandatory {@link PhoneAccountHandle}
110 *
111 * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference.
112 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700113 public Conference(PhoneAccountHandle phoneAccount) {
114 mPhoneAccount = phoneAccount;
115 }
116
Nancy Chen56fc25d2014-09-09 12:24:51 -0700117 /**
Jack Yu67140302015-12-10 12:27:58 -0800118 * Returns the telecom internal call ID associated with this conference.
119 *
120 * @return The telecom call ID.
121 * @hide
122 */
123 public final String getTelecomCallId() {
124 return mTelecomCallId;
125 }
126
127 /**
128 * Sets the telecom internal call ID associated with this conference.
129 *
130 * @param telecomCallId The telecom call ID.
131 * @hide
132 */
133 public final void setTelecomCallId(String telecomCallId) {
134 mTelecomCallId = telecomCallId;
135 }
136
137 /**
Nancy Chen56fc25d2014-09-09 12:24:51 -0700138 * Returns the {@link PhoneAccountHandle} the conference call is being placed through.
139 *
140 * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference.
141 */
Nancy Chenea38cca2014-09-05 16:38:49 -0700142 public final PhoneAccountHandle getPhoneAccountHandle() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700143 return mPhoneAccount;
144 }
145
Nancy Chen56fc25d2014-09-09 12:24:51 -0700146 /**
147 * Returns the list of connections currently associated with the conference call.
148 *
149 * @return A list of {@code Connection} objects which represent the children of the conference.
150 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700151 public final List<Connection> getConnections() {
Ihab Awadb8e85c72014-08-23 20:34:57 -0700152 return mUnmodifiableChildConnections;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700153 }
154
Nancy Chen56fc25d2014-09-09 12:24:51 -0700155 /**
156 * Gets the state of the conference call. See {@link Connection} for valid values.
157 *
158 * @return A constant representing the state the conference call is currently in.
159 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700160 public final int getState() {
161 return mState;
162 }
163
Nancy Chen56fc25d2014-09-09 12:24:51 -0700164 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700165 * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800166 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700167 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800168 * @return A bitmask of the capabilities of the conference call.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700169 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800170 public final int getConnectionCapabilities() {
171 return mConnectionCapabilities;
172 }
173
174 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700175 * Returns the properties of the conference. See {@code PROPERTY_*} constants in class
176 * {@link Connection} for valid values.
177 *
178 * @return A bitmask of the properties of the conference call.
179 */
180 public final int getConnectionProperties() {
181 return mConnectionProperties;
182 }
183
184 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800185 * Whether the given capabilities support the specified capability.
186 *
187 * @param capabilities A capability bit field.
188 * @param capability The capability to check capabilities for.
189 * @return Whether the specified capability is supported.
190 * @hide
191 */
192 public static boolean can(int capabilities, int capability) {
193 return (capabilities & capability) != 0;
194 }
195
196 /**
197 * Whether the capabilities of this {@code Connection} supports the specified capability.
198 *
199 * @param capability The capability to check capabilities for.
200 * @return Whether the specified capability is supported.
201 * @hide
202 */
203 public boolean can(int capability) {
204 return can(mConnectionCapabilities, capability);
205 }
206
207 /**
208 * Removes the specified capability from the set of capabilities of this {@code Conference}.
209 *
210 * @param capability The capability to remove from the set.
211 * @hide
212 */
213 public void removeCapability(int capability) {
Omkar Kolangadea0f46a92015-03-23 17:51:16 -0700214 int newCapabilities = mConnectionCapabilities;
215 newCapabilities &= ~capability;
216
217 setConnectionCapabilities(newCapabilities);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800218 }
219
220 /**
221 * Adds the specified capability to the set of capabilities of this {@code Conference}.
222 *
223 * @param capability The capability to add to the set.
224 * @hide
225 */
226 public void addCapability(int capability) {
Omkar Kolangadea0f46a92015-03-23 17:51:16 -0700227 int newCapabilities = mConnectionCapabilities;
228 newCapabilities |= capability;
229
230 setConnectionCapabilities(newCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700231 }
232
233 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700234 * @return The audio state of the conference, describing how its audio is currently
235 * being routed by the system. This is {@code null} if this Conference
236 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700237 * @deprecated Use {@link #getCallAudioState()} instead.
238 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700239 */
Yorke Lee4af59352015-05-13 14:14:54 -0700240 @Deprecated
241 @SystemApi
Yorke Leea0d3ca92014-09-15 19:18:13 -0700242 public final AudioState getAudioState() {
Yorke Lee4af59352015-05-13 14:14:54 -0700243 return new AudioState(mCallAudioState);
244 }
245
246 /**
247 * @return The audio state of the conference, describing how its audio is currently
248 * being routed by the system. This is {@code null} if this Conference
249 * does not directly know about its audio state.
250 */
251 public final CallAudioState getCallAudioState() {
252 return mCallAudioState;
Yorke Leea0d3ca92014-09-15 19:18:13 -0700253 }
254
255 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700256 * Returns VideoProvider of the primary call. This can be null.
Rekha Kumar07366812015-03-24 16:42:31 -0700257 */
258 public VideoProvider getVideoProvider() {
259 return null;
260 }
261
262 /**
263 * Returns video state of the primary call.
Rekha Kumar07366812015-03-24 16:42:31 -0700264 */
265 public int getVideoState() {
Tyler Gunn87b73f32015-06-03 10:09:59 -0700266 return VideoProfile.STATE_AUDIO_ONLY;
Rekha Kumar07366812015-03-24 16:42:31 -0700267 }
268
269 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700270 * Notifies the {@link Conference} when the Conference and all it's {@link Connection}s should
271 * be disconnected.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700272 */
273 public void onDisconnect() {}
274
275 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700276 * Notifies the {@link Conference} when the specified {@link Connection} should be separated
277 * from the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700278 *
279 * @param connection The connection to separate.
280 */
281 public void onSeparate(Connection connection) {}
282
283 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700284 * Notifies the {@link Conference} when the specified {@link Connection} should merged with the
285 * conference call.
Ihab Awad50e35062014-09-30 09:17:03 -0700286 *
287 * @param connection The {@code Connection} to merge.
288 */
289 public void onMerge(Connection connection) {}
290
291 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700292 * Notifies the {@link Conference} when it should be put on hold.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700293 */
294 public void onHold() {}
295
296 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700297 * Notifies the {@link Conference} when it should be moved from a held to active state.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700298 */
299 public void onUnhold() {}
300
301 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700302 * Notifies the {@link Conference} when the child calls should be merged. Only invoked if the
303 * conference contains the capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700304 */
305 public void onMerge() {}
306
307 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700308 * Notifies the {@link Conference} when the child calls should be swapped. Only invoked if the
309 * conference contains the capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700310 */
311 public void onSwap() {}
312
313 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700314 * Notifies the {@link Conference} of a request to play a DTMF tone.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700315 *
316 * @param c A DTMF character.
317 */
318 public void onPlayDtmfTone(char c) {}
319
320 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700321 * Notifies the {@link Conference} of a request to stop any currently playing DTMF tones.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700322 */
323 public void onStopDtmfTone() {}
324
325 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700326 * Notifies the {@link Conference} that the {@link #getAudioState()} property has a new value.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700327 *
328 * @param state The new call audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700329 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
330 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700331 */
Yorke Lee4af59352015-05-13 14:14:54 -0700332 @SystemApi
333 @Deprecated
Yorke Leea0d3ca92014-09-15 19:18:13 -0700334 public void onAudioStateChanged(AudioState state) {}
335
336 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700337 * Notifies the {@link Conference} that the {@link #getCallAudioState()} property has a new
338 * value.
Yorke Lee4af59352015-05-13 14:14:54 -0700339 *
340 * @param state The new call audio state.
341 */
342 public void onCallAudioStateChanged(CallAudioState state) {}
343
344 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700345 * Notifies the {@link Conference} that a {@link Connection} has been added to it.
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800346 *
347 * @param connection The newly added connection.
348 */
349 public void onConnectionAdded(Connection connection) {}
350
351 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700352 * Sets state to be on hold.
353 */
354 public final void setOnHold() {
355 setState(Connection.STATE_HOLDING);
356 }
357
358 /**
Tyler Gunnd46595a2015-06-01 14:29:11 -0700359 * Sets state to be dialing.
360 */
361 public final void setDialing() {
362 setState(Connection.STATE_DIALING);
363 }
364
365 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700366 * Sets state to be active.
367 */
368 public final void setActive() {
369 setState(Connection.STATE_ACTIVE);
370 }
371
372 /**
373 * Sets state to disconnected.
374 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700375 * @param disconnectCause The reason for the disconnection, as described by
376 * {@link android.telecom.DisconnectCause}.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700377 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700378 public final void setDisconnected(DisconnectCause disconnectCause) {
379 mDisconnectCause = disconnectCause;;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700380 setState(Connection.STATE_DISCONNECTED);
381 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700382 l.onDisconnected(this, mDisconnectCause);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700383 }
384 }
385
386 /**
mike dooley1cf14ac2014-11-04 10:59:53 -0800387 * @return The {@link DisconnectCause} for this connection.
388 */
389 public final DisconnectCause getDisconnectCause() {
390 return mDisconnectCause;
391 }
392
393 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800394 * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class
395 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700396 *
Tyler Gunn720c6642016-03-22 09:02:47 -0700397 * @param connectionCapabilities A bitmask of the {@code Capabilities} of the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700398 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800399 public final void setConnectionCapabilities(int connectionCapabilities) {
400 if (connectionCapabilities != mConnectionCapabilities) {
401 mConnectionCapabilities = connectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700402
403 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800404 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700405 }
406 }
407 }
408
409 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700410 * Sets the properties of a conference. See {@code PROPERTY_*} constants of class
411 * {@link Connection} for valid values.
412 *
413 * @param connectionProperties A bitmask of the {@code Properties} of the conference call.
414 */
415 public final void setConnectionProperties(int connectionProperties) {
416 if (connectionProperties != mConnectionProperties) {
417 mConnectionProperties = connectionProperties;
418
419 for (Listener l : mListeners) {
420 l.onConnectionPropertiesChanged(this, mConnectionProperties);
421 }
422 }
423 }
424
425 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700426 * Adds the specified connection as a child of this conference.
427 *
428 * @param connection The connection to add.
429 * @return True if the connection was successfully added.
430 */
Santos Cordona4868042014-09-04 17:39:22 -0700431 public final boolean addConnection(Connection connection) {
Rekha Kumar07366812015-03-24 16:42:31 -0700432 Log.d(this, "Connection=%s, connection=", connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700433 if (connection != null && !mChildConnections.contains(connection)) {
434 if (connection.setConference(this)) {
435 mChildConnections.add(connection);
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800436 onConnectionAdded(connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700437 for (Listener l : mListeners) {
438 l.onConnectionAdded(this, connection);
439 }
440 return true;
441 }
442 }
443 return false;
444 }
445
446 /**
447 * Removes the specified connection as a child of this conference.
448 *
449 * @param connection The connection to remove.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700450 */
Santos Cordona4868042014-09-04 17:39:22 -0700451 public final void removeConnection(Connection connection) {
Santos Cordon0159ac02014-08-21 14:28:11 -0700452 Log.d(this, "removing %s from %s", connection, mChildConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700453 if (connection != null && mChildConnections.remove(connection)) {
454 connection.resetConference();
455 for (Listener l : mListeners) {
456 l.onConnectionRemoved(this, connection);
457 }
458 }
459 }
460
461 /**
Ihab Awad50e35062014-09-30 09:17:03 -0700462 * Sets the connections with which this connection can be conferenced.
463 *
464 * @param conferenceableConnections The set of connections this connection can conference with.
465 */
466 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
467 clearConferenceableList();
468 for (Connection c : conferenceableConnections) {
469 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
470 // small amount of items here.
471 if (!mConferenceableConnections.contains(c)) {
472 c.addConnectionListener(mConnectionDeathListener);
473 mConferenceableConnections.add(c);
474 }
475 }
476 fireOnConferenceableConnectionsChanged();
477 }
478
Rekha Kumar07366812015-03-24 16:42:31 -0700479 /**
480 * Set the video state for the conference.
Yorke Lee32f24732015-05-12 16:18:03 -0700481 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
482 * {@link VideoProfile#STATE_BIDIRECTIONAL},
483 * {@link VideoProfile#STATE_TX_ENABLED},
484 * {@link VideoProfile#STATE_RX_ENABLED}.
Rekha Kumar07366812015-03-24 16:42:31 -0700485 *
486 * @param videoState The new video state.
Rekha Kumar07366812015-03-24 16:42:31 -0700487 */
488 public final void setVideoState(Connection c, int videoState) {
489 Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s",
490 this, c, videoState);
491 for (Listener l : mListeners) {
492 l.onVideoStateChanged(this, videoState);
493 }
494 }
495
496 /**
497 * Sets the video connection provider.
498 *
499 * @param videoProvider The video provider.
Rekha Kumar07366812015-03-24 16:42:31 -0700500 */
501 public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) {
502 Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s",
503 this, c, videoProvider);
504 for (Listener l : mListeners) {
505 l.onVideoProviderChanged(this, videoProvider);
506 }
507 }
508
Ihab Awad50e35062014-09-30 09:17:03 -0700509 private final void fireOnConferenceableConnectionsChanged() {
510 for (Listener l : mListeners) {
511 l.onConferenceableConnectionsChanged(this, getConferenceableConnections());
512 }
513 }
514
515 /**
516 * Returns the connections with which this connection can be conferenced.
517 */
518 public final List<Connection> getConferenceableConnections() {
519 return mUnmodifiableConferenceableConnections;
520 }
521
522 /**
Nancy Chenea38cca2014-09-05 16:38:49 -0700523 * Tears down the conference object and any of its current connections.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700524 */
Santos Cordona4868042014-09-04 17:39:22 -0700525 public final void destroy() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700526 Log.d(this, "destroying conference : %s", this);
527 // Tear down the children.
Santos Cordon0159ac02014-08-21 14:28:11 -0700528 for (Connection connection : mChildConnections) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700529 Log.d(this, "removing connection %s", connection);
530 removeConnection(connection);
531 }
532
533 // If not yet disconnected, set the conference call as disconnected first.
534 if (mState != Connection.STATE_DISCONNECTED) {
535 Log.d(this, "setting to disconnected");
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700536 setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
Santos Cordon823fd3c2014-08-07 18:35:18 -0700537 }
538
539 // ...and notify.
540 for (Listener l : mListeners) {
541 l.onDestroyed(this);
542 }
543 }
544
545 /**
546 * Add a listener to be notified of a state change.
547 *
548 * @param listener The new listener.
549 * @return This conference.
550 * @hide
551 */
552 public final Conference addListener(Listener listener) {
553 mListeners.add(listener);
554 return this;
555 }
556
557 /**
558 * Removes the specified listener.
559 *
560 * @param listener The listener to remove.
561 * @return This conference.
562 * @hide
563 */
564 public final Conference removeListener(Listener listener) {
565 mListeners.remove(listener);
566 return this;
567 }
568
Yorke Leea0d3ca92014-09-15 19:18:13 -0700569 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700570 * Retrieves the primary connection associated with the conference. The primary connection is
571 * the connection from which the conference will retrieve its current state.
572 *
573 * @return The primary connection.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700574 * @hide
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700575 */
Tyler Gunn124f1f62019-02-04 15:12:06 -0800576 @TestApi
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700577 @SystemApi
Santos Cordon4055d642015-05-12 14:19:24 -0700578 public Connection getPrimaryConnection() {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700579 if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) {
580 return null;
581 }
582 return mUnmodifiableChildConnections.get(0);
583 }
584
585 /**
Wei Huang7f7f72e2018-05-30 19:21:36 +0800586 * Updates RIL voice radio technology used for current conference after its creation.
587 *
588 * @hide
589 */
590 public void updateCallRadioTechAfterCreation() {
591 final Connection primaryConnection = getPrimaryConnection();
592 if (primaryConnection != null) {
593 setCallRadioTech(primaryConnection.getCallRadioTech());
594 } else {
595 Log.w(this, "No primary connection found while updateCallRadioTechAfterCreation");
596 }
597 }
598
599 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700600 * @hide
601 * @deprecated Use {@link #setConnectionTime}.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800602 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700603 @Deprecated
604 @SystemApi
605 public final void setConnectTimeMillis(long connectTimeMillis) {
606 setConnectionTime(connectTimeMillis);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800607 }
608
609 /**
Tyler Gunn17541392018-02-01 08:58:38 -0800610 * Sets the connection start time of the {@code Conference}. This is used in the call log to
611 * indicate the date and time when the conference took place.
612 * <p>
613 * Should be specified in wall-clock time returned by {@link System#currentTimeMillis()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700614 * <p>
615 * When setting the connection time, you should always set the connection elapsed time via
Tyler Gunn17541392018-02-01 08:58:38 -0800616 * {@link #setConnectionStartElapsedRealTime(long)} to ensure the duration is reflected.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700617 *
Tyler Gunn17541392018-02-01 08:58:38 -0800618 * @param connectionTimeMillis The connection time, in milliseconds, as returned by
619 * {@link System#currentTimeMillis()}.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700620 */
621 public final void setConnectionTime(long connectionTimeMillis) {
622 mConnectTimeMillis = connectionTimeMillis;
623 }
624
625 /**
Tyler Gunn17541392018-02-01 08:58:38 -0800626 * Sets the start time of the {@link Conference} which is the basis for the determining the
627 * duration of the {@link Conference}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700628 * <p>
Tyler Gunn17541392018-02-01 08:58:38 -0800629 * You should use a value returned by {@link SystemClock#elapsedRealtime()} to ensure that time
630 * zone changes do not impact the conference duration.
631 * <p>
632 * When setting this, you should also set the connection time via
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700633 * {@link #setConnectionTime(long)}.
634 *
Tyler Gunn17541392018-02-01 08:58:38 -0800635 * @param connectionStartElapsedRealTime The connection time, as measured by
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700636 * {@link SystemClock#elapsedRealtime()}.
637 */
Tyler Gunn17541392018-02-01 08:58:38 -0800638 public final void setConnectionStartElapsedRealTime(long connectionStartElapsedRealTime) {
639 mConnectionStartElapsedRealTime = connectionStartElapsedRealTime;
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700640 }
641
642 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700643 * @hide
644 * @deprecated Use {@link #getConnectionTime}.
645 */
646 @Deprecated
647 @SystemApi
648 public final long getConnectTimeMillis() {
649 return getConnectionTime();
650 }
651
652 /**
653 * Retrieves the connection start time of the {@code Conference}, if specified. A value of
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800654 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
655 * of the conference.
656 *
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700657 * @return The time at which the {@code Conference} was connected.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800658 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700659 public final long getConnectionTime() {
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800660 return mConnectTimeMillis;
661 }
662
663 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700664 * Retrieves the connection start time of the {@link Conference}, if specified. A value of
665 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
666 * of the conference.
667 *
668 * This is based on the value of {@link SystemClock#elapsedRealtime()} to ensure that it is not
669 * impacted by wall clock changes (user initiated, network initiated, time zone change, etc).
670 *
671 * @return The elapsed time at which the {@link Conference} was connected.
672 * @hide
673 */
Tyler Gunn17541392018-02-01 08:58:38 -0800674 public final long getConnectionStartElapsedRealTime() {
675 return mConnectionStartElapsedRealTime;
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700676 }
677
678 /**
Wei Huang7f7f72e2018-05-30 19:21:36 +0800679 * Sets RIL voice radio technology used for current conference.
680 *
681 * @param vrat the RIL voice radio technology used for current conference,
682 * see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
683 *
684 * @hide
685 */
686 public final void setCallRadioTech(@ServiceState.RilRadioTechnology int vrat) {
687 putExtra(TelecomManager.EXTRA_CALL_NETWORK_TYPE,
688 ServiceState.rilRadioTechnologyToNetworkType(vrat));
689 }
690
691 /**
692 * Returns RIL voice radio technology used for current conference.
693 *
694 * @return the RIL voice radio technology used for current conference,
695 * see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
696 *
697 * @hide
698 */
699 public final @ServiceState.RilRadioTechnology int getCallRadioTech() {
700 int voiceNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
701 Bundle extras = getExtras();
702 if (extras != null) {
703 voiceNetworkType = extras.getInt(TelecomManager.EXTRA_CALL_NETWORK_TYPE,
704 TelephonyManager.NETWORK_TYPE_UNKNOWN);
705 }
706 return ServiceState.networkTypeToRilRadioTechnology(voiceNetworkType);
707 }
708
709 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700710 * Inform this Conference that the state of its audio output has been changed externally.
711 *
712 * @param state The new audio state.
713 * @hide
714 */
Yorke Lee4af59352015-05-13 14:14:54 -0700715 final void setCallAudioState(CallAudioState state) {
716 Log.d(this, "setCallAudioState %s", state);
717 mCallAudioState = state;
718 onAudioStateChanged(getAudioState());
719 onCallAudioStateChanged(state);
Yorke Leea0d3ca92014-09-15 19:18:13 -0700720 }
721
Santos Cordon823fd3c2014-08-07 18:35:18 -0700722 private void setState(int newState) {
723 if (newState != Connection.STATE_ACTIVE &&
724 newState != Connection.STATE_HOLDING &&
725 newState != Connection.STATE_DISCONNECTED) {
726 Log.w(this, "Unsupported state transition for Conference call.",
727 Connection.stateToString(newState));
728 return;
729 }
730
731 if (mState != newState) {
732 int oldState = mState;
733 mState = newState;
734 for (Listener l : mListeners) {
735 l.onStateChanged(this, oldState, newState);
736 }
737 }
738 }
Ihab Awad50e35062014-09-30 09:17:03 -0700739
740 private final void clearConferenceableList() {
741 for (Connection c : mConferenceableConnections) {
742 c.removeConnectionListener(mConnectionDeathListener);
743 }
744 mConferenceableConnections.clear();
745 }
Rekha Kumar07366812015-03-24 16:42:31 -0700746
747 @Override
748 public String toString() {
749 return String.format(Locale.US,
750 "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]",
751 Connection.stateToString(mState),
752 Call.Details.capabilitiesToString(mConnectionCapabilities),
753 getVideoState(),
754 getVideoProvider(),
755 super.toString());
756 }
Andrew Lee0f51da32015-04-16 13:11:55 -0700757
Andrew Leeedc625f2015-04-14 13:38:12 -0700758 /**
759 * Sets the label and icon status to display in the InCall UI.
760 *
761 * @param statusHints The status label and icon to set.
762 */
763 public final void setStatusHints(StatusHints statusHints) {
764 mStatusHints = statusHints;
765 for (Listener l : mListeners) {
766 l.onStatusHintsChanged(this, statusHints);
767 }
768 }
769
770 /**
771 * @return The status hints for this conference.
772 */
773 public final StatusHints getStatusHints() {
774 return mStatusHints;
775 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700776
777 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700778 * Replaces all the extras associated with this {@code Conference}.
779 * <p>
780 * New or existing keys are replaced in the {@code Conference} extras. Keys which are no longer
781 * in the new extras, but were present the last time {@code setExtras} was called are removed.
782 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700783 * Alternatively you may use the {@link #putExtras(Bundle)}, and
784 * {@link #removeExtras(String...)} methods to modify the extras.
785 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -0700786 * 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 -0700787 * Keys should be fully qualified (e.g., com.example.extras.MY_EXTRA) to avoid conflicts.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700788 *
Tyler Gunndee56a82016-03-23 16:06:34 -0700789 * @param extras The extras associated with this {@code Conference}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700790 */
791 public final void setExtras(@Nullable Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700792 // Keeping putExtras and removeExtras in the same lock so that this operation happens as a
793 // block instead of letting other threads put/remove while this method is running.
794 synchronized (mExtrasLock) {
795 // Add/replace any new or changed extras values.
796 putExtras(extras);
797 // If we have used "setExtras" in the past, compare the key set from the last invocation
798 // to the current one and remove any keys that went away.
799 if (mPreviousExtraKeys != null) {
800 List<String> toRemove = new ArrayList<String>();
801 for (String oldKey : mPreviousExtraKeys) {
802 if (extras == null || !extras.containsKey(oldKey)) {
803 toRemove.add(oldKey);
804 }
805 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700806
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700807 if (!toRemove.isEmpty()) {
808 removeExtras(toRemove);
Tyler Gunndee56a82016-03-23 16:06:34 -0700809 }
810 }
811
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700812 // Track the keys the last time set called setExtras. This way, the next time setExtras
813 // is called we can see if the caller has removed any extras values.
814 if (mPreviousExtraKeys == null) {
815 mPreviousExtraKeys = new ArraySet<String>();
Tyler Gunndee56a82016-03-23 16:06:34 -0700816 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700817 mPreviousExtraKeys.clear();
818 if (extras != null) {
819 mPreviousExtraKeys.addAll(extras.keySet());
820 }
Tyler Gunna8fb8ab2016-03-29 10:24:22 -0700821 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700822 }
823
824 /**
825 * Adds some extras to this {@link Conference}. Existing keys are replaced and new ones are
826 * added.
827 * <p>
828 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
829 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
830 *
831 * @param extras The extras to add.
832 */
833 public final void putExtras(@NonNull Bundle extras) {
834 if (extras == null) {
835 return;
836 }
837
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700838 // Creating a Bundle clone so we don't have to synchronize on mExtrasLock while calling
839 // onExtrasChanged.
840 Bundle listenersBundle;
841 synchronized (mExtrasLock) {
842 if (mExtras == null) {
843 mExtras = new Bundle();
844 }
845 mExtras.putAll(extras);
846 listenersBundle = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -0700847 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700848
Santos Cordon6b7f9552015-05-27 17:21:45 -0700849 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700850 l.onExtrasChanged(this, new Bundle(listenersBundle));
Santos Cordon6b7f9552015-05-27 17:21:45 -0700851 }
852 }
853
854 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700855 * Adds a boolean extra to this {@link Conference}.
856 *
857 * @param key The extra key.
858 * @param value The value.
859 * @hide
860 */
861 public final void putExtra(String key, boolean value) {
862 Bundle newExtras = new Bundle();
863 newExtras.putBoolean(key, value);
864 putExtras(newExtras);
865 }
866
867 /**
868 * Adds an integer extra to this {@link Conference}.
869 *
870 * @param key The extra key.
871 * @param value The value.
872 * @hide
873 */
874 public final void putExtra(String key, int value) {
875 Bundle newExtras = new Bundle();
876 newExtras.putInt(key, value);
877 putExtras(newExtras);
878 }
879
880 /**
881 * Adds a string extra to this {@link Conference}.
882 *
883 * @param key The extra key.
884 * @param value The value.
885 * @hide
886 */
887 public final void putExtra(String key, String value) {
888 Bundle newExtras = new Bundle();
889 newExtras.putString(key, value);
890 putExtras(newExtras);
891 }
892
893 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -0700894 * Removes extras from this {@link Conference}.
Tyler Gunndee56a82016-03-23 16:06:34 -0700895 *
Tyler Gunn071be6f2016-05-10 14:52:33 -0700896 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -0700897 */
898 public final void removeExtras(List<String> keys) {
899 if (keys == null || keys.isEmpty()) {
900 return;
901 }
902
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700903 synchronized (mExtrasLock) {
904 if (mExtras != null) {
905 for (String key : keys) {
906 mExtras.remove(key);
907 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700908 }
909 }
910
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700911 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -0700912 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700913 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -0700914 }
915 }
916
917 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -0700918 * Removes extras from this {@link Conference}.
919 *
920 * @param keys The keys of the extras to remove.
921 */
922 public final void removeExtras(String ... keys) {
923 removeExtras(Arrays.asList(keys));
924 }
925
926 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700927 * Returns the extras associated with this conference.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +0000928 * <p>
929 * Extras should be updated using {@link #putExtras(Bundle)} and {@link #removeExtras(List)}.
930 * <p>
931 * Telecom or an {@link InCallService} can also update the extras via
932 * {@link android.telecom.Call#putExtras(Bundle)}, and
933 * {@link Call#removeExtras(List)}.
934 * <p>
935 * The conference is notified of changes to the extras made by Telecom or an
936 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -0700937 *
938 * @return The extras associated with this connection.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700939 */
940 public final Bundle getExtras() {
941 return mExtras;
942 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700943
944 /**
945 * Notifies this {@link Conference} of a change to the extras made outside the
946 * {@link ConnectionService}.
947 * <p>
948 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
949 * {@link android.telecom.Call#putExtras(Bundle)}, and
950 * {@link Call#removeExtras(List)}.
951 *
952 * @param extras The new extras bundle.
953 */
954 public void onExtrasChanged(Bundle extras) {}
955
956 /**
Tyler Gunn68a73a42018-10-03 15:38:57 -0700957 * Set whether Telecom should treat this {@link Conference} as a conference call or if it
958 * should treat it as a single-party call.
959 * This method is used as part of a workaround regarding IMS conference calls and user
960 * expectation. In IMS, once a conference is formed, the UE is connected to an IMS conference
961 * server. If all participants of the conference drop out of the conference except for one, the
962 * UE is still connected to the IMS conference server. At this point, the user logically
963 * assumes they're no longer in a conference, yet the underlying network actually is.
964 * To help provide a better user experiece, IMS conference calls can pretend to actually be a
965 * single-party call when the participant count drops to 1. Although the dialer/phone app
966 * could perform this trickery, it makes sense to do this in Telephony since a fix there will
967 * ensure that bluetooth head units, auto and wearable apps all behave consistently.
968 *
969 * @param isConference {@code true} if this {@link Conference} should be treated like a
970 * conference call, {@code false} if it should be treated like a single-party call.
971 * @hide
972 */
973 public void setConferenceState(boolean isConference) {
974 for (Listener l : mListeners) {
975 l.onConferenceStateChanged(this, isConference);
976 }
977 }
978
979 /**
980 * Sets the address of this {@link Conference}. Used when {@link #setConferenceState(boolean)}
981 * is called to mark a conference temporarily as NOT a conference.
982 *
983 * @param address The new address.
984 * @param presentation The presentation requirements for the address.
985 * See {@link TelecomManager} for valid values.
986 * @hide
987 */
988 public final void setAddress(Uri address, int presentation) {
989 Log.d(this, "setAddress %s", address);
990 for (Listener l : mListeners) {
991 l.onAddressChanged(this, address, presentation);
992 }
993 }
994
995 /**
996 * Sets the caller display name (CNAP) of this {@link Conference}. Used when
997 * {@link #setConferenceState(boolean)} is called to mark a conference temporarily as NOT a
998 * conference.
999 *
1000 * @param callerDisplayName The new display name.
1001 * @param presentation The presentation requirements for the handle.
1002 * See {@link TelecomManager} for valid values.
1003 * @hide
1004 */
1005 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
1006 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
1007 for (Listener l : mListeners) {
1008 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
1009 }
1010 }
1011
1012 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001013 * Handles a change to extras received from Telecom.
1014 *
1015 * @param extras The new extras.
1016 * @hide
1017 */
1018 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001019 Bundle b = null;
1020 synchronized (mExtrasLock) {
1021 mExtras = extras;
1022 if (mExtras != null) {
1023 b = new Bundle(mExtras);
1024 }
1025 }
1026 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07001027 }
Hall Liua5400912019-04-16 14:00:55 -07001028
1029 /**
1030 * See {@link Connection#sendConnectionEvent(String, Bundle)}
1031 * @hide
1032 */
1033 public void sendConnectionEvent(String event, Bundle extras) {
1034 for (Listener l : mListeners) {
1035 l.onConnectionEvent(this, event, extras);
1036 }
1037 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07001038}