blob: cd5fd971a0658389a278c33027c3a0d084392fd2 [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 */
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 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.
123 *
124 * @return The telecom call ID.
125 * @hide
126 */
127 public final String getTelecomCallId() {
128 return mTelecomCallId;
129 }
130
131 /**
132 * Sets the telecom internal call ID associated with this conference.
133 *
134 * @param telecomCallId The telecom call ID.
135 * @hide
136 */
137 public final void setTelecomCallId(String telecomCallId) {
138 mTelecomCallId = telecomCallId;
139 }
140
141 /**
Nancy Chen56fc25d2014-09-09 12:24:51 -0700142 * Returns the {@link PhoneAccountHandle} the conference call is being placed through.
143 *
144 * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference.
145 */
Nancy Chenea38cca2014-09-05 16:38:49 -0700146 public final PhoneAccountHandle getPhoneAccountHandle() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700147 return mPhoneAccount;
148 }
149
Nancy Chen56fc25d2014-09-09 12:24:51 -0700150 /**
151 * Returns the list of connections currently associated with the conference call.
152 *
153 * @return A list of {@code Connection} objects which represent the children of the conference.
154 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700155 public final List<Connection> getConnections() {
Ihab Awadb8e85c72014-08-23 20:34:57 -0700156 return mUnmodifiableChildConnections;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700157 }
158
Nancy Chen56fc25d2014-09-09 12:24:51 -0700159 /**
160 * Gets the state of the conference call. See {@link Connection} for valid values.
161 *
162 * @return A constant representing the state the conference call is currently in.
163 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700164 public final int getState() {
165 return mState;
166 }
167
Nancy Chen56fc25d2014-09-09 12:24:51 -0700168 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700169 * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800170 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700171 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800172 * @return A bitmask of the capabilities of the conference call.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700173 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800174 public final int getConnectionCapabilities() {
175 return mConnectionCapabilities;
176 }
177
178 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700179 * Returns the properties of the conference. See {@code PROPERTY_*} constants in class
180 * {@link Connection} for valid values.
181 *
182 * @return A bitmask of the properties of the conference call.
183 */
184 public final int getConnectionProperties() {
185 return mConnectionProperties;
186 }
187
188 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800189 * Whether the given capabilities support the specified capability.
190 *
191 * @param capabilities A capability bit field.
192 * @param capability The capability to check capabilities for.
193 * @return Whether the specified capability is supported.
194 * @hide
195 */
196 public static boolean can(int capabilities, int capability) {
197 return (capabilities & capability) != 0;
198 }
199
200 /**
201 * Whether the capabilities of this {@code Connection} supports the specified capability.
202 *
203 * @param capability The capability to check capabilities for.
204 * @return Whether the specified capability is supported.
205 * @hide
206 */
207 public boolean can(int capability) {
208 return can(mConnectionCapabilities, capability);
209 }
210
211 /**
212 * Removes the specified capability from the set of capabilities of this {@code Conference}.
213 *
214 * @param capability The capability to remove from the set.
215 * @hide
216 */
217 public void removeCapability(int capability) {
Omkar Kolangadea0f46a92015-03-23 17:51:16 -0700218 int newCapabilities = mConnectionCapabilities;
219 newCapabilities &= ~capability;
220
221 setConnectionCapabilities(newCapabilities);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800222 }
223
224 /**
225 * Adds the specified capability to the set of capabilities of this {@code Conference}.
226 *
227 * @param capability The capability to add to the set.
228 * @hide
229 */
230 public void addCapability(int capability) {
Omkar Kolangadea0f46a92015-03-23 17:51:16 -0700231 int newCapabilities = mConnectionCapabilities;
232 newCapabilities |= capability;
233
234 setConnectionCapabilities(newCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700235 }
236
237 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700238 * @return The audio state of the conference, describing how its audio is currently
239 * being routed by the system. This is {@code null} if this Conference
240 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700241 * @deprecated Use {@link #getCallAudioState()} instead.
242 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700243 */
Yorke Lee4af59352015-05-13 14:14:54 -0700244 @Deprecated
245 @SystemApi
Yorke Leea0d3ca92014-09-15 19:18:13 -0700246 public final AudioState getAudioState() {
Yorke Lee4af59352015-05-13 14:14:54 -0700247 return new AudioState(mCallAudioState);
248 }
249
250 /**
251 * @return The audio state of the conference, describing how its audio is currently
252 * being routed by the system. This is {@code null} if this Conference
253 * does not directly know about its audio state.
254 */
255 public final CallAudioState getCallAudioState() {
256 return mCallAudioState;
Yorke Leea0d3ca92014-09-15 19:18:13 -0700257 }
258
259 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700260 * Returns VideoProvider of the primary call. This can be null.
Rekha Kumar07366812015-03-24 16:42:31 -0700261 */
262 public VideoProvider getVideoProvider() {
263 return null;
264 }
265
266 /**
267 * Returns video state of the primary call.
Rekha Kumar07366812015-03-24 16:42:31 -0700268 */
269 public int getVideoState() {
Tyler Gunn87b73f32015-06-03 10:09:59 -0700270 return VideoProfile.STATE_AUDIO_ONLY;
Rekha Kumar07366812015-03-24 16:42:31 -0700271 }
272
273 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700274 * Notifies the {@link Conference} when the Conference and all it's {@link Connection}s should
275 * be disconnected.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700276 */
277 public void onDisconnect() {}
278
279 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700280 * Notifies the {@link Conference} when the specified {@link Connection} should be separated
281 * from the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700282 *
283 * @param connection The connection to separate.
284 */
285 public void onSeparate(Connection connection) {}
286
287 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700288 * Notifies the {@link Conference} when the specified {@link Connection} should merged with the
289 * conference call.
Ihab Awad50e35062014-09-30 09:17:03 -0700290 *
291 * @param connection The {@code Connection} to merge.
292 */
293 public void onMerge(Connection connection) {}
294
295 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700296 * Notifies the {@link Conference} when it should be put on hold.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700297 */
298 public void onHold() {}
299
300 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700301 * Notifies the {@link Conference} when it should be moved from a held to active state.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700302 */
303 public void onUnhold() {}
304
305 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700306 * Notifies the {@link Conference} when the child calls should be merged. Only invoked if the
307 * conference contains the capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700308 */
309 public void onMerge() {}
310
311 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700312 * Notifies the {@link Conference} when the child calls should be swapped. Only invoked if the
313 * conference contains the capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}.
Santos Cordona4868042014-09-04 17:39:22 -0700314 */
315 public void onSwap() {}
316
317 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700318 * Notifies the {@link Conference} of a request to play a DTMF tone.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700319 *
320 * @param c A DTMF character.
321 */
322 public void onPlayDtmfTone(char c) {}
323
324 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700325 * Notifies the {@link Conference} of a request to stop any currently playing DTMF tones.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700326 */
327 public void onStopDtmfTone() {}
328
329 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700330 * Notifies the {@link Conference} that the {@link #getAudioState()} property has a new value.
Yorke Leea0d3ca92014-09-15 19:18:13 -0700331 *
332 * @param state The new call audio state.
Yorke Lee4af59352015-05-13 14:14:54 -0700333 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
334 * @hide
Yorke Leea0d3ca92014-09-15 19:18:13 -0700335 */
Yorke Lee4af59352015-05-13 14:14:54 -0700336 @SystemApi
337 @Deprecated
Yorke Leea0d3ca92014-09-15 19:18:13 -0700338 public void onAudioStateChanged(AudioState state) {}
339
340 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700341 * Notifies the {@link Conference} that the {@link #getCallAudioState()} property has a new
342 * value.
Yorke Lee4af59352015-05-13 14:14:54 -0700343 *
344 * @param state The new call audio state.
345 */
346 public void onCallAudioStateChanged(CallAudioState state) {}
347
348 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700349 * Notifies the {@link Conference} that a {@link Connection} has been added to it.
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800350 *
351 * @param connection The newly added connection.
352 */
353 public void onConnectionAdded(Connection connection) {}
354
355 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700356 * Sets state to be on hold.
357 */
358 public final void setOnHold() {
359 setState(Connection.STATE_HOLDING);
360 }
361
362 /**
Tyler Gunnd46595a2015-06-01 14:29:11 -0700363 * Sets state to be dialing.
364 */
365 public final void setDialing() {
366 setState(Connection.STATE_DIALING);
367 }
368
369 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700370 * Sets state to be active.
371 */
372 public final void setActive() {
373 setState(Connection.STATE_ACTIVE);
374 }
375
376 /**
377 * Sets state to disconnected.
378 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700379 * @param disconnectCause The reason for the disconnection, as described by
380 * {@link android.telecom.DisconnectCause}.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700381 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700382 public final void setDisconnected(DisconnectCause disconnectCause) {
383 mDisconnectCause = disconnectCause;;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700384 setState(Connection.STATE_DISCONNECTED);
385 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700386 l.onDisconnected(this, mDisconnectCause);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700387 }
388 }
389
390 /**
mike dooley1cf14ac2014-11-04 10:59:53 -0800391 * @return The {@link DisconnectCause} for this connection.
392 */
393 public final DisconnectCause getDisconnectCause() {
394 return mDisconnectCause;
395 }
396
397 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800398 * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class
399 * {@link Connection} for valid values.
Nancy Chen56fc25d2014-09-09 12:24:51 -0700400 *
Tyler Gunn720c6642016-03-22 09:02:47 -0700401 * @param connectionCapabilities A bitmask of the {@code Capabilities} of the conference call.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700402 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800403 public final void setConnectionCapabilities(int connectionCapabilities) {
404 if (connectionCapabilities != mConnectionCapabilities) {
405 mConnectionCapabilities = connectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700406
407 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800408 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700409 }
410 }
411 }
412
413 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700414 * Sets the properties of a conference. See {@code PROPERTY_*} constants of class
415 * {@link Connection} for valid values.
416 *
417 * @param connectionProperties A bitmask of the {@code Properties} of the conference call.
418 */
419 public final void setConnectionProperties(int connectionProperties) {
420 if (connectionProperties != mConnectionProperties) {
421 mConnectionProperties = connectionProperties;
422
423 for (Listener l : mListeners) {
424 l.onConnectionPropertiesChanged(this, mConnectionProperties);
425 }
426 }
427 }
428
429 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -0700430 * Adds the specified connection as a child of this conference.
431 *
432 * @param connection The connection to add.
433 * @return True if the connection was successfully added.
434 */
Santos Cordona4868042014-09-04 17:39:22 -0700435 public final boolean addConnection(Connection connection) {
Rekha Kumar07366812015-03-24 16:42:31 -0700436 Log.d(this, "Connection=%s, connection=", connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700437 if (connection != null && !mChildConnections.contains(connection)) {
438 if (connection.setConference(this)) {
439 mChildConnections.add(connection);
Andrew Lee46f7f5d2014-11-06 17:00:25 -0800440 onConnectionAdded(connection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700441 for (Listener l : mListeners) {
442 l.onConnectionAdded(this, connection);
443 }
444 return true;
445 }
446 }
447 return false;
448 }
449
450 /**
451 * Removes the specified connection as a child of this conference.
452 *
453 * @param connection The connection to remove.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700454 */
Santos Cordona4868042014-09-04 17:39:22 -0700455 public final void removeConnection(Connection connection) {
Santos Cordon0159ac02014-08-21 14:28:11 -0700456 Log.d(this, "removing %s from %s", connection, mChildConnections);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700457 if (connection != null && mChildConnections.remove(connection)) {
458 connection.resetConference();
459 for (Listener l : mListeners) {
460 l.onConnectionRemoved(this, connection);
461 }
462 }
463 }
464
465 /**
Ihab Awad50e35062014-09-30 09:17:03 -0700466 * Sets the connections with which this connection can be conferenced.
467 *
468 * @param conferenceableConnections The set of connections this connection can conference with.
469 */
470 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
471 clearConferenceableList();
472 for (Connection c : conferenceableConnections) {
473 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
474 // small amount of items here.
475 if (!mConferenceableConnections.contains(c)) {
476 c.addConnectionListener(mConnectionDeathListener);
477 mConferenceableConnections.add(c);
478 }
479 }
480 fireOnConferenceableConnectionsChanged();
481 }
482
Rekha Kumar07366812015-03-24 16:42:31 -0700483 /**
484 * Set the video state for the conference.
Yorke Lee32f24732015-05-12 16:18:03 -0700485 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
486 * {@link VideoProfile#STATE_BIDIRECTIONAL},
487 * {@link VideoProfile#STATE_TX_ENABLED},
488 * {@link VideoProfile#STATE_RX_ENABLED}.
Rekha Kumar07366812015-03-24 16:42:31 -0700489 *
490 * @param videoState The new video state.
Rekha Kumar07366812015-03-24 16:42:31 -0700491 */
492 public final void setVideoState(Connection c, int videoState) {
493 Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s",
494 this, c, videoState);
495 for (Listener l : mListeners) {
496 l.onVideoStateChanged(this, videoState);
497 }
498 }
499
500 /**
501 * Sets the video connection provider.
502 *
503 * @param videoProvider The video provider.
Rekha Kumar07366812015-03-24 16:42:31 -0700504 */
505 public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) {
506 Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s",
507 this, c, videoProvider);
508 for (Listener l : mListeners) {
509 l.onVideoProviderChanged(this, videoProvider);
510 }
511 }
512
Ihab Awad50e35062014-09-30 09:17:03 -0700513 private final void fireOnConferenceableConnectionsChanged() {
514 for (Listener l : mListeners) {
515 l.onConferenceableConnectionsChanged(this, getConferenceableConnections());
516 }
517 }
518
519 /**
520 * Returns the connections with which this connection can be conferenced.
521 */
522 public final List<Connection> getConferenceableConnections() {
523 return mUnmodifiableConferenceableConnections;
524 }
525
526 /**
Nancy Chenea38cca2014-09-05 16:38:49 -0700527 * Tears down the conference object and any of its current connections.
Santos Cordon823fd3c2014-08-07 18:35:18 -0700528 */
Santos Cordona4868042014-09-04 17:39:22 -0700529 public final void destroy() {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700530 Log.d(this, "destroying conference : %s", this);
531 // Tear down the children.
Santos Cordon0159ac02014-08-21 14:28:11 -0700532 for (Connection connection : mChildConnections) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700533 Log.d(this, "removing connection %s", connection);
534 removeConnection(connection);
535 }
536
537 // If not yet disconnected, set the conference call as disconnected first.
538 if (mState != Connection.STATE_DISCONNECTED) {
539 Log.d(this, "setting to disconnected");
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700540 setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
Santos Cordon823fd3c2014-08-07 18:35:18 -0700541 }
542
543 // ...and notify.
544 for (Listener l : mListeners) {
545 l.onDestroyed(this);
546 }
547 }
548
549 /**
550 * Add a listener to be notified of a state change.
551 *
552 * @param listener The new listener.
553 * @return This conference.
554 * @hide
555 */
556 public final Conference addListener(Listener listener) {
557 mListeners.add(listener);
558 return this;
559 }
560
561 /**
562 * Removes the specified listener.
563 *
564 * @param listener The listener to remove.
565 * @return This conference.
566 * @hide
567 */
568 public final Conference removeListener(Listener listener) {
569 mListeners.remove(listener);
570 return this;
571 }
572
Yorke Leea0d3ca92014-09-15 19:18:13 -0700573 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700574 * Retrieves the primary connection associated with the conference. The primary connection is
575 * the connection from which the conference will retrieve its current state.
576 *
577 * @return The primary connection.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700578 * @hide
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700579 */
Tyler Gunn6c14a6992019-02-04 15:12:06 -0800580 @TestApi
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700581 @SystemApi
Santos Cordon4055d642015-05-12 14:19:24 -0700582 public Connection getPrimaryConnection() {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700583 if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) {
584 return null;
585 }
586 return mUnmodifiableChildConnections.get(0);
587 }
588
589 /**
Wei Huang7f7f72e2018-05-30 19:21:36 +0800590 * Updates RIL voice radio technology used for current conference after its creation.
591 *
592 * @hide
593 */
594 public void updateCallRadioTechAfterCreation() {
595 final Connection primaryConnection = getPrimaryConnection();
596 if (primaryConnection != null) {
597 setCallRadioTech(primaryConnection.getCallRadioTech());
598 } else {
599 Log.w(this, "No primary connection found while updateCallRadioTechAfterCreation");
600 }
601 }
602
603 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700604 * @hide
605 * @deprecated Use {@link #setConnectionTime}.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800606 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700607 @Deprecated
608 @SystemApi
609 public final void setConnectTimeMillis(long connectTimeMillis) {
610 setConnectionTime(connectTimeMillis);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800611 }
612
613 /**
Tyler Gunn17541392018-02-01 08:58:38 -0800614 * Sets the connection start time of the {@code Conference}. This is used in the call log to
615 * indicate the date and time when the conference took place.
616 * <p>
617 * Should be specified in wall-clock time returned by {@link System#currentTimeMillis()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700618 * <p>
619 * When setting the connection time, you should always set the connection elapsed time via
Tyler Gunn17541392018-02-01 08:58:38 -0800620 * {@link #setConnectionStartElapsedRealTime(long)} to ensure the duration is reflected.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700621 *
Tyler Gunn17541392018-02-01 08:58:38 -0800622 * @param connectionTimeMillis The connection time, in milliseconds, as returned by
623 * {@link System#currentTimeMillis()}.
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700624 */
625 public final void setConnectionTime(long connectionTimeMillis) {
626 mConnectTimeMillis = connectionTimeMillis;
627 }
628
629 /**
Tyler Gunn17541392018-02-01 08:58:38 -0800630 * Sets the start time of the {@link Conference} which is the basis for the determining the
631 * duration of the {@link Conference}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700632 * <p>
Tyler Gunn17541392018-02-01 08:58:38 -0800633 * You should use a value returned by {@link SystemClock#elapsedRealtime()} to ensure that time
634 * zone changes do not impact the conference duration.
635 * <p>
636 * When setting this, you should also set the connection time via
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700637 * {@link #setConnectionTime(long)}.
638 *
Tyler Gunn17541392018-02-01 08:58:38 -0800639 * @param connectionStartElapsedRealTime The connection time, as measured by
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700640 * {@link SystemClock#elapsedRealtime()}.
641 */
Tyler Gunn17541392018-02-01 08:58:38 -0800642 public final void setConnectionStartElapsedRealTime(long connectionStartElapsedRealTime) {
643 mConnectionStartElapsedRealTime = connectionStartElapsedRealTime;
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700644 }
645
646 /**
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700647 * @hide
648 * @deprecated Use {@link #getConnectionTime}.
649 */
650 @Deprecated
651 @SystemApi
652 public final long getConnectTimeMillis() {
653 return getConnectionTime();
654 }
655
656 /**
657 * Retrieves the connection start time of the {@code Conference}, if specified. A value of
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800658 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
659 * of the conference.
660 *
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700661 * @return The time at which the {@code Conference} was connected.
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800662 */
Santos Cordon5d2e4f22015-05-12 12:32:51 -0700663 public final long getConnectionTime() {
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800664 return mConnectTimeMillis;
665 }
666
667 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700668 * Retrieves the connection start time of the {@link Conference}, if specified. A value of
669 * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
670 * of the conference.
671 *
672 * This is based on the value of {@link SystemClock#elapsedRealtime()} to ensure that it is not
673 * impacted by wall clock changes (user initiated, network initiated, time zone change, etc).
674 *
675 * @return The elapsed time at which the {@link Conference} was connected.
676 * @hide
677 */
Tyler Gunn17541392018-02-01 08:58:38 -0800678 public final long getConnectionStartElapsedRealTime() {
679 return mConnectionStartElapsedRealTime;
Tyler Gunn3fa819c2017-08-04 09:27:26 -0700680 }
681
682 /**
Wei Huang7f7f72e2018-05-30 19:21:36 +0800683 * Sets RIL voice radio technology used for current conference.
684 *
685 * @param vrat the RIL voice radio technology used for current conference,
686 * see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
687 *
688 * @hide
689 */
690 public final void setCallRadioTech(@ServiceState.RilRadioTechnology int vrat) {
691 putExtra(TelecomManager.EXTRA_CALL_NETWORK_TYPE,
692 ServiceState.rilRadioTechnologyToNetworkType(vrat));
693 }
694
695 /**
696 * Returns RIL voice radio technology used for current conference.
697 *
698 * @return the RIL voice radio technology used for current conference,
699 * see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}.
700 *
701 * @hide
702 */
703 public final @ServiceState.RilRadioTechnology int getCallRadioTech() {
704 int voiceNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
705 Bundle extras = getExtras();
706 if (extras != null) {
707 voiceNetworkType = extras.getInt(TelecomManager.EXTRA_CALL_NETWORK_TYPE,
708 TelephonyManager.NETWORK_TYPE_UNKNOWN);
709 }
710 return ServiceState.networkTypeToRilRadioTechnology(voiceNetworkType);
711 }
712
713 /**
Yorke Leea0d3ca92014-09-15 19:18:13 -0700714 * Inform this Conference that the state of its audio output has been changed externally.
715 *
716 * @param state The new audio state.
717 * @hide
718 */
Yorke Lee4af59352015-05-13 14:14:54 -0700719 final void setCallAudioState(CallAudioState state) {
720 Log.d(this, "setCallAudioState %s", state);
721 mCallAudioState = state;
722 onAudioStateChanged(getAudioState());
723 onCallAudioStateChanged(state);
Yorke Leea0d3ca92014-09-15 19:18:13 -0700724 }
725
Santos Cordon823fd3c2014-08-07 18:35:18 -0700726 private void setState(int newState) {
727 if (newState != Connection.STATE_ACTIVE &&
728 newState != Connection.STATE_HOLDING &&
729 newState != Connection.STATE_DISCONNECTED) {
730 Log.w(this, "Unsupported state transition for Conference call.",
731 Connection.stateToString(newState));
732 return;
733 }
734
735 if (mState != newState) {
736 int oldState = mState;
737 mState = newState;
738 for (Listener l : mListeners) {
739 l.onStateChanged(this, oldState, newState);
740 }
741 }
742 }
Ihab Awad50e35062014-09-30 09:17:03 -0700743
744 private final void clearConferenceableList() {
745 for (Connection c : mConferenceableConnections) {
746 c.removeConnectionListener(mConnectionDeathListener);
747 }
748 mConferenceableConnections.clear();
749 }
Rekha Kumar07366812015-03-24 16:42:31 -0700750
751 @Override
752 public String toString() {
753 return String.format(Locale.US,
754 "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]",
755 Connection.stateToString(mState),
756 Call.Details.capabilitiesToString(mConnectionCapabilities),
757 getVideoState(),
758 getVideoProvider(),
759 super.toString());
760 }
Andrew Lee0f51da32015-04-16 13:11:55 -0700761
Andrew Leeedc625f2015-04-14 13:38:12 -0700762 /**
763 * Sets the label and icon status to display in the InCall UI.
764 *
765 * @param statusHints The status label and icon to set.
766 */
767 public final void setStatusHints(StatusHints statusHints) {
768 mStatusHints = statusHints;
769 for (Listener l : mListeners) {
770 l.onStatusHintsChanged(this, statusHints);
771 }
772 }
773
774 /**
775 * @return The status hints for this conference.
776 */
777 public final StatusHints getStatusHints() {
778 return mStatusHints;
779 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700780
781 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700782 * Replaces all the extras associated with this {@code Conference}.
783 * <p>
784 * New or existing keys are replaced in the {@code Conference} extras. Keys which are no longer
785 * in the new extras, but were present the last time {@code setExtras} was called are removed.
786 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700787 * Alternatively you may use the {@link #putExtras(Bundle)}, and
788 * {@link #removeExtras(String...)} methods to modify the extras.
789 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -0700790 * 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 -0700791 * Keys should be fully qualified (e.g., com.example.extras.MY_EXTRA) to avoid conflicts.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700792 *
Tyler Gunndee56a82016-03-23 16:06:34 -0700793 * @param extras The extras associated with this {@code Conference}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700794 */
795 public final void setExtras(@Nullable Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700796 // Keeping putExtras and removeExtras in the same lock so that this operation happens as a
797 // block instead of letting other threads put/remove while this method is running.
798 synchronized (mExtrasLock) {
799 // Add/replace any new or changed extras values.
800 putExtras(extras);
801 // If we have used "setExtras" in the past, compare the key set from the last invocation
802 // to the current one and remove any keys that went away.
803 if (mPreviousExtraKeys != null) {
804 List<String> toRemove = new ArrayList<String>();
805 for (String oldKey : mPreviousExtraKeys) {
806 if (extras == null || !extras.containsKey(oldKey)) {
807 toRemove.add(oldKey);
808 }
809 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700810
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700811 if (!toRemove.isEmpty()) {
812 removeExtras(toRemove);
Tyler Gunndee56a82016-03-23 16:06:34 -0700813 }
814 }
815
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700816 // Track the keys the last time set called setExtras. This way, the next time setExtras
817 // is called we can see if the caller has removed any extras values.
818 if (mPreviousExtraKeys == null) {
819 mPreviousExtraKeys = new ArraySet<String>();
Tyler Gunndee56a82016-03-23 16:06:34 -0700820 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700821 mPreviousExtraKeys.clear();
822 if (extras != null) {
823 mPreviousExtraKeys.addAll(extras.keySet());
824 }
Tyler Gunna8fb8ab2016-03-29 10:24:22 -0700825 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700826 }
827
828 /**
829 * Adds some extras to this {@link Conference}. Existing keys are replaced and new ones are
830 * added.
831 * <p>
832 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
833 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
834 *
835 * @param extras The extras to add.
836 */
837 public final void putExtras(@NonNull Bundle extras) {
838 if (extras == null) {
839 return;
840 }
841
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700842 // Creating a Bundle clone so we don't have to synchronize on mExtrasLock while calling
843 // onExtrasChanged.
844 Bundle listenersBundle;
845 synchronized (mExtrasLock) {
846 if (mExtras == null) {
847 mExtras = new Bundle();
848 }
849 mExtras.putAll(extras);
850 listenersBundle = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -0700851 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700852
Santos Cordon6b7f9552015-05-27 17:21:45 -0700853 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700854 l.onExtrasChanged(this, new Bundle(listenersBundle));
Santos Cordon6b7f9552015-05-27 17:21:45 -0700855 }
856 }
857
858 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700859 * Adds a boolean extra to this {@link Conference}.
860 *
861 * @param key The extra key.
862 * @param value The value.
863 * @hide
864 */
865 public final void putExtra(String key, boolean value) {
866 Bundle newExtras = new Bundle();
867 newExtras.putBoolean(key, value);
868 putExtras(newExtras);
869 }
870
871 /**
872 * Adds an integer extra to this {@link Conference}.
873 *
874 * @param key The extra key.
875 * @param value The value.
876 * @hide
877 */
878 public final void putExtra(String key, int value) {
879 Bundle newExtras = new Bundle();
880 newExtras.putInt(key, value);
881 putExtras(newExtras);
882 }
883
884 /**
885 * Adds a string extra to this {@link Conference}.
886 *
887 * @param key The extra key.
888 * @param value The value.
889 * @hide
890 */
891 public final void putExtra(String key, String value) {
892 Bundle newExtras = new Bundle();
893 newExtras.putString(key, value);
894 putExtras(newExtras);
895 }
896
897 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -0700898 * Removes extras from this {@link Conference}.
Tyler Gunndee56a82016-03-23 16:06:34 -0700899 *
Tyler Gunn071be6f2016-05-10 14:52:33 -0700900 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -0700901 */
902 public final void removeExtras(List<String> keys) {
903 if (keys == null || keys.isEmpty()) {
904 return;
905 }
906
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700907 synchronized (mExtrasLock) {
908 if (mExtras != null) {
909 for (String key : keys) {
910 mExtras.remove(key);
911 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700912 }
913 }
914
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700915 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -0700916 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -0700917 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -0700918 }
919 }
920
921 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -0700922 * Removes extras from this {@link Conference}.
923 *
924 * @param keys The keys of the extras to remove.
925 */
926 public final void removeExtras(String ... keys) {
927 removeExtras(Arrays.asList(keys));
928 }
929
930 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700931 * Returns the extras associated with this conference.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +0000932 * <p>
933 * Extras should be updated using {@link #putExtras(Bundle)} and {@link #removeExtras(List)}.
934 * <p>
935 * Telecom or an {@link InCallService} can also update the extras via
936 * {@link android.telecom.Call#putExtras(Bundle)}, and
937 * {@link Call#removeExtras(List)}.
938 * <p>
939 * The conference is notified of changes to the extras made by Telecom or an
940 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -0700941 *
942 * @return The extras associated with this connection.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700943 */
944 public final Bundle getExtras() {
945 return mExtras;
946 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700947
948 /**
949 * Notifies this {@link Conference} of a change to the extras made outside the
950 * {@link ConnectionService}.
951 * <p>
952 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
953 * {@link android.telecom.Call#putExtras(Bundle)}, and
954 * {@link Call#removeExtras(List)}.
955 *
956 * @param extras The new extras bundle.
957 */
958 public void onExtrasChanged(Bundle extras) {}
959
960 /**
Tyler Gunn68a73a42018-10-03 15:38:57 -0700961 * Set whether Telecom should treat this {@link Conference} as a conference call or if it
962 * should treat it as a single-party call.
963 * This method is used as part of a workaround regarding IMS conference calls and user
964 * expectation. In IMS, once a conference is formed, the UE is connected to an IMS conference
965 * server. If all participants of the conference drop out of the conference except for one, the
966 * UE is still connected to the IMS conference server. At this point, the user logically
967 * assumes they're no longer in a conference, yet the underlying network actually is.
968 * To help provide a better user experiece, IMS conference calls can pretend to actually be a
969 * single-party call when the participant count drops to 1. Although the dialer/phone app
970 * could perform this trickery, it makes sense to do this in Telephony since a fix there will
971 * ensure that bluetooth head units, auto and wearable apps all behave consistently.
972 *
973 * @param isConference {@code true} if this {@link Conference} should be treated like a
974 * conference call, {@code false} if it should be treated like a single-party call.
975 * @hide
976 */
977 public void setConferenceState(boolean isConference) {
978 for (Listener l : mListeners) {
979 l.onConferenceStateChanged(this, isConference);
980 }
981 }
982
983 /**
984 * Sets the address of this {@link Conference}. Used when {@link #setConferenceState(boolean)}
985 * is called to mark a conference temporarily as NOT a conference.
986 *
987 * @param address The new address.
988 * @param presentation The presentation requirements for the address.
989 * See {@link TelecomManager} for valid values.
990 * @hide
991 */
992 public final void setAddress(Uri address, int presentation) {
993 Log.d(this, "setAddress %s", address);
Tyler Gunnac60f952019-05-31 07:23:16 -0700994 mAddress = address;
995 mAddressPresentation = presentation;
Tyler Gunn68a73a42018-10-03 15:38:57 -0700996 for (Listener l : mListeners) {
997 l.onAddressChanged(this, address, presentation);
998 }
999 }
1000
1001 /**
Tyler Gunnac60f952019-05-31 07:23:16 -07001002 * Returns the "address" associated with the conference. This is applicable in two cases:
1003 * <ol>
1004 * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as
1005 * temporarily "not a conference"; we need to present the correct address in the in-call
1006 * UI.</li>
1007 * <li>When the conference is not hosted on the current device, we need to know the address
1008 * information for the purpose of showing the original address to the user, as well as for
1009 * logging to the call log.</li>
1010 * </ol>
1011 * @return The address of the conference, or {@code null} if not applicable.
1012 * @hide
1013 */
1014 public final Uri getAddress() {
1015 return mAddress;
1016 }
1017
1018 /**
1019 * Returns the address presentation associated with the conference.
1020 * <p>
1021 * This is applicable in two cases:
1022 * <ol>
1023 * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as
1024 * temporarily "not a conference"; we need to present the correct address in the in-call
1025 * UI.</li>
1026 * <li>When the conference is not hosted on the current device, we need to know the address
1027 * information for the purpose of showing the original address to the user, as well as for
1028 * logging to the call log.</li>
1029 * </ol>
1030 * @return The address of the conference, or {@code null} if not applicable.
1031 * @hide
1032 */
1033 public final int getAddressPresentation() {
1034 return mAddressPresentation;
1035 }
1036
1037 /**
1038 * @return The caller display name (CNAP).
1039 * @hide
1040 */
1041 public final String getCallerDisplayName() {
1042 return mCallerDisplayName;
1043 }
1044
1045 /**
1046 * @return The presentation requirements for the handle.
1047 * See {@link TelecomManager} for valid values.
1048 * @hide
1049 */
1050 public final int getCallerDisplayNamePresentation() {
1051 return mCallerDisplayNamePresentation;
1052 }
1053
1054 /**
Tyler Gunn68a73a42018-10-03 15:38:57 -07001055 * Sets the caller display name (CNAP) of this {@link Conference}. Used when
1056 * {@link #setConferenceState(boolean)} is called to mark a conference temporarily as NOT a
1057 * conference.
1058 *
1059 * @param callerDisplayName The new display name.
1060 * @param presentation The presentation requirements for the handle.
1061 * See {@link TelecomManager} for valid values.
1062 * @hide
1063 */
1064 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
1065 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Tyler Gunnac60f952019-05-31 07:23:16 -07001066 mCallerDisplayName = callerDisplayName;
1067 mCallerDisplayNamePresentation = presentation;
Tyler Gunn68a73a42018-10-03 15:38:57 -07001068 for (Listener l : mListeners) {
1069 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
1070 }
1071 }
1072
1073 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001074 * Handles a change to extras received from Telecom.
1075 *
1076 * @param extras The new extras.
1077 * @hide
1078 */
1079 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001080 Bundle b = null;
1081 synchronized (mExtrasLock) {
1082 mExtras = extras;
1083 if (mExtras != null) {
1084 b = new Bundle(mExtras);
1085 }
1086 }
1087 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07001088 }
Hall Liuc9bc1c62019-04-16 14:00:55 -07001089
1090 /**
1091 * See {@link Connection#sendConnectionEvent(String, Bundle)}
1092 * @hide
1093 */
1094 public void sendConnectionEvent(String event, Bundle extras) {
1095 for (Listener l : mListeners) {
1096 l.onConnectionEvent(this, event, extras);
1097 }
1098 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07001099}