blob: 95cc387c519b1dc9d05764748dd603fb2f8348d5 [file] [log] [blame]
Santos Cordon52d8a152014-06-17 19:08:45 -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 Cordon52d8a152014-06-17 19:08:45 -070018
Tyler Gunnef9f6f92014-09-12 22:16:17 -070019import com.android.internal.telecom.IConnectionService;
20import com.android.internal.telecom.IVideoCallback;
21import com.android.internal.telecom.IVideoProvider;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070022
Evan Charlton0e094d92014-11-08 15:49:16 -080023import android.annotation.SystemApi;
Santos Cordon52d8a152014-06-17 19:08:45 -070024import android.net.Uri;
Ihab Awada64627c2014-08-20 09:36:40 -070025import android.os.IBinder;
Santos Cordon52d8a152014-06-17 19:08:45 -070026import android.os.RemoteException;
Ihab Awada64627c2014-08-20 09:36:40 -070027import android.view.Surface;
Santos Cordon52d8a152014-06-17 19:08:45 -070028
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070029import java.util.ArrayList;
Sailesh Nepalf4669df2014-08-14 17:43:13 -070030import java.util.Collections;
Ihab Awad5d0410f2014-07-30 10:07:40 -070031import java.util.List;
Santos Cordon52d8a152014-06-17 19:08:45 -070032import java.util.Set;
Sailesh Nepalf4669df2014-08-14 17:43:13 -070033import java.util.concurrent.ConcurrentHashMap;
Santos Cordon52d8a152014-06-17 19:08:45 -070034
35/**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070036 * A connection provided to a {@link ConnectionService} by another {@code ConnectionService}
37 * running in a different process.
38 *
39 * @see ConnectionService#createRemoteOutgoingConnection(PhoneAccountHandle, ConnectionRequest)
40 * @see ConnectionService#createRemoteIncomingConnection(PhoneAccountHandle, ConnectionRequest)
Evan Charlton0e094d92014-11-08 15:49:16 -080041 * @hide
Santos Cordon52d8a152014-06-17 19:08:45 -070042 */
Evan Charlton0e094d92014-11-08 15:49:16 -080043@SystemApi
Santos Cordon52d8a152014-06-17 19:08:45 -070044public final class RemoteConnection {
Ihab Awad5d0410f2014-07-30 10:07:40 -070045
Andrew Lee100e2932014-09-08 15:34:24 -070046 public static abstract class Callback {
Ihab Awad5d0410f2014-07-30 10:07:40 -070047 /**
48 * Invoked when the state of this {@code RemoteConnection} has changed. See
49 * {@link #getState()}.
50 *
51 * @param connection The {@code RemoteConnection} invoking this method.
52 * @param state The new state of the {@code RemoteConnection}.
53 */
Evan Charltonbf11f982014-07-20 22:06:28 -070054 public void onStateChanged(RemoteConnection connection, int state) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -070055
56 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -070057 * Invoked when this {@code RemoteConnection} is disconnected.
58 *
59 * @param connection The {@code RemoteConnection} invoking this method.
Andrew Lee7f3d41f2014-09-11 17:33:16 -070060 * @param disconnectCause The ({@see DisconnectCause}) associated with this failed
61 * connection.
Ihab Awad5d0410f2014-07-30 10:07:40 -070062 */
63 public void onDisconnected(
64 RemoteConnection connection,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070065 DisconnectCause disconnectCause) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -070066
67 /**
68 * Invoked when this {@code RemoteConnection} is requesting ringback. See
Andrew Lee100e2932014-09-08 15:34:24 -070069 * {@link #isRingbackRequested()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -070070 *
71 * @param connection The {@code RemoteConnection} invoking this method.
72 * @param ringback Whether the {@code RemoteConnection} is requesting ringback.
73 */
Andrew Lee100e2932014-09-08 15:34:24 -070074 public void onRingbackRequested(RemoteConnection connection, boolean ringback) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -070075
Ihab Awad5c9c86e2014-11-12 13:41:16 -080076 /** @hide */
77 @Deprecated public void onCallCapabilitiesChanged(
78 RemoteConnection connection,
79 int callCapabilities) {}
80
Ihab Awad5d0410f2014-07-30 10:07:40 -070081 /**
82 * Indicates that the call capabilities of this {@code RemoteConnection} have changed.
Ihab Awad5c9c86e2014-11-12 13:41:16 -080083 * See {@link #getConnectionCapabilities()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -070084 *
85 * @param connection The {@code RemoteConnection} invoking this method.
Ihab Awad5c9c86e2014-11-12 13:41:16 -080086 * @param connectionCapabilities The new capabilities of the {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -070087 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -080088 public void onConnectionCapabilitiesChanged(
89 RemoteConnection connection,
90 int connectionCapabilities) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -070091
92 /**
93 * Invoked when the post-dial sequence in the outgoing {@code Connection} has reached a
94 * pause character. This causes the post-dial signals to stop pending user confirmation. An
95 * implementation should present this choice to the user and invoke
Ihab Awadb19a0bc2014-08-07 19:46:01 -070096 * {@link RemoteConnection#postDialContinue(boolean)} when the user makes the choice.
Ihab Awad5d0410f2014-07-30 10:07:40 -070097 *
98 * @param connection The {@code RemoteConnection} invoking this method.
99 * @param remainingPostDialSequence The post-dial characters that remain to be sent.
100 */
101 public void onPostDialWait(RemoteConnection connection, String remainingPostDialSequence) {}
102
103 /**
104 * Indicates that the VOIP audio status of this {@code RemoteConnection} has changed.
Andrew Lee100e2932014-09-08 15:34:24 -0700105 * See {@link #isVoipAudioMode()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700106 *
107 * @param connection The {@code RemoteConnection} invoking this method.
108 * @param isVoip Whether the new audio state of the {@code RemoteConnection} is VOIP.
109 */
Andrew Lee100e2932014-09-08 15:34:24 -0700110 public void onVoipAudioChanged(RemoteConnection connection, boolean isVoip) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700111
112 /**
113 * Indicates that the status hints of this {@code RemoteConnection} have changed. See
114 * {@link #getStatusHints()} ()}.
115 *
116 * @param connection The {@code RemoteConnection} invoking this method.
117 * @param statusHints The new status hints of the {@code RemoteConnection}.
118 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700119 public void onStatusHintsChanged(RemoteConnection connection, StatusHints statusHints) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700120
121 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700122 * Indicates that the address (e.g., phone number) of this {@code RemoteConnection} has
123 * changed. See {@link #getAddress()} and {@link #getAddressPresentation()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700124 *
125 * @param connection The {@code RemoteConnection} invoking this method.
Andrew Lee100e2932014-09-08 15:34:24 -0700126 * @param address The new address of the {@code RemoteConnection}.
127 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700128 * See {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700129 */
Andrew Lee100e2932014-09-08 15:34:24 -0700130 public void onAddressChanged(RemoteConnection connection, Uri address, int presentation) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700131
132 /**
133 * Indicates that the caller display name of this {@code RemoteConnection} has changed.
134 * See {@link #getCallerDisplayName()} and {@link #getCallerDisplayNamePresentation()}.
135 *
136 * @param connection The {@code RemoteConnection} invoking this method.
137 * @param callerDisplayName The new caller display name of the {@code RemoteConnection}.
Nancy Chen9d568c02014-09-08 14:17:59 -0700138 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700139 * See {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700140 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700141 public void onCallerDisplayNameChanged(
142 RemoteConnection connection, String callerDisplayName, int presentation) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700143
144 /**
145 * Indicates that the video state of this {@code RemoteConnection} has changed.
146 * See {@link #getVideoState()}.
147 *
148 * @param connection The {@code RemoteConnection} invoking this method.
149 * @param videoState The new video state of the {@code RemoteConnection}.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700150 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700151 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700152 public void onVideoStateChanged(RemoteConnection connection, int videoState) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700153
154 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700155 * Indicates that this {@code RemoteConnection} has been destroyed. No further requests
156 * should be made to the {@code RemoteConnection}, and references to it should be cleared.
157 *
158 * @param connection The {@code RemoteConnection} invoking this method.
159 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700160 public void onDestroyed(RemoteConnection connection) {}
Ihab Awadb8e85c72014-08-23 20:34:57 -0700161
162 /**
163 * Indicates that the {@code RemoteConnection}s with which this {@code RemoteConnection}
164 * may be asked to create a conference has changed.
165 *
166 * @param connection The {@code RemoteConnection} invoking this method.
167 * @param conferenceableConnections The {@code RemoteConnection}s with which this
168 * {@code RemoteConnection} may be asked to create a conference.
169 */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700170 public void onConferenceableConnectionsChanged(
Ihab Awadb8e85c72014-08-23 20:34:57 -0700171 RemoteConnection connection,
172 List<RemoteConnection> conferenceableConnections) {}
173
174 /**
Ihab Awada64627c2014-08-20 09:36:40 -0700175 * Indicates that the {@code VideoProvider} associated with this {@code RemoteConnection}
176 * has changed.
177 *
178 * @param connection The {@code RemoteConnection} invoking this method.
179 * @param videoProvider The new {@code VideoProvider} associated with this
180 * {@code RemoteConnection}.
181 * @hide
182 */
183 public void onVideoProviderChanged(
184 RemoteConnection connection, VideoProvider videoProvider) {}
185
186 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700187 * Indicates that the {@code RemoteConference} that this {@code RemoteConnection} is a part
188 * of has changed.
189 *
190 * @param connection The {@code RemoteConnection} invoking this method.
191 * @param conference The {@code RemoteConference} of which this {@code RemoteConnection} is
192 * a part, which may be {@code null}.
193 */
194 public void onConferenceChanged(
195 RemoteConnection connection,
196 RemoteConference conference) {}
Santos Cordon52d8a152014-06-17 19:08:45 -0700197 }
198
Ihab Awada64627c2014-08-20 09:36:40 -0700199 /** {@hide} */
200 public static class VideoProvider {
201
202 public abstract static class Listener {
203 public void onReceiveSessionModifyRequest(
204 VideoProvider videoProvider,
205 VideoProfile videoProfile) {}
206
207 public void onReceiveSessionModifyResponse(
208 VideoProvider videoProvider,
209 int status,
210 VideoProfile requestedProfile,
211 VideoProfile responseProfile) {}
212
213 public void onHandleCallSessionEvent(VideoProvider videoProvider, int event) {}
214
215 public void onPeerDimensionsChanged(VideoProvider videoProvider, int width, int height) {}
216
217 public void onCallDataUsageChanged(VideoProvider videoProvider, int dataUsage) {}
218
219 public void onCameraCapabilitiesChanged(
220 VideoProvider videoProvider,
221 CameraCapabilities cameraCapabilities) {}
222 }
223
224 private final IVideoCallback mVideoCallbackDelegate = new IVideoCallback() {
225 @Override
226 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
227 for (Listener l : mListeners) {
228 l.onReceiveSessionModifyRequest(VideoProvider.this, videoProfile);
229 }
230 }
231
232 @Override
233 public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile,
234 VideoProfile responseProfile) {
235 for (Listener l : mListeners) {
236 l.onReceiveSessionModifyResponse(
237 VideoProvider.this,
238 status,
239 requestedProfile,
240 responseProfile);
241 }
242 }
243
244 @Override
245 public void handleCallSessionEvent(int event) {
246 for (Listener l : mListeners) {
247 l.onHandleCallSessionEvent(VideoProvider.this, event);
248 }
249 }
250
251 @Override
252 public void changePeerDimensions(int width, int height) {
253 for (Listener l : mListeners) {
254 l.onPeerDimensionsChanged(VideoProvider.this, width, height);
255 }
256 }
257
258 @Override
259 public void changeCallDataUsage(int dataUsage) {
260 for (Listener l : mListeners) {
261 l.onCallDataUsageChanged(VideoProvider.this, dataUsage);
262 }
263 }
264
265 @Override
266 public void changeCameraCapabilities(CameraCapabilities cameraCapabilities) {
267 for (Listener l : mListeners) {
268 l.onCameraCapabilitiesChanged(VideoProvider.this, cameraCapabilities);
269 }
270 }
271
272 @Override
273 public IBinder asBinder() {
274 return null;
275 }
276 };
277
278 private final VideoCallbackServant mVideoCallbackServant =
279 new VideoCallbackServant(mVideoCallbackDelegate);
280
281 private final IVideoProvider mVideoProviderBinder;
282
283 /**
284 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
285 * load factor before resizing, 1 means we only expect a single thread to
286 * access the map so make only a single shard
287 */
288 private final Set<Listener> mListeners = Collections.newSetFromMap(
289 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
290
291 public VideoProvider(IVideoProvider videoProviderBinder) {
292 mVideoProviderBinder = videoProviderBinder;
293 try {
294 mVideoProviderBinder.setVideoCallback(mVideoCallbackServant.getStub().asBinder());
295 } catch (RemoteException e) {
296 }
297 }
298
299 public void addListener(Listener l) {
300 mListeners.add(l);
301 }
302
303 public void removeListener(Listener l) {
304 mListeners.remove(l);
305 }
306
307 public void setCamera(String cameraId) {
308 try {
309 mVideoProviderBinder.setCamera(cameraId);
310 } catch (RemoteException e) {
311 }
312 }
313
314 public void setPreviewSurface(Surface surface) {
315 try {
316 mVideoProviderBinder.setPreviewSurface(surface);
317 } catch (RemoteException e) {
318 }
319 }
320
321 public void setDisplaySurface(Surface surface) {
322 try {
323 mVideoProviderBinder.setDisplaySurface(surface);
324 } catch (RemoteException e) {
325 }
326 }
327
328 public void setDeviceOrientation(int rotation) {
329 try {
330 mVideoProviderBinder.setDeviceOrientation(rotation);
331 } catch (RemoteException e) {
332 }
333 }
334
335 public void setZoom(float value) {
336 try {
337 mVideoProviderBinder.setZoom(value);
338 } catch (RemoteException e) {
339 }
340 }
341
342 public void sendSessionModifyRequest(VideoProfile reqProfile) {
343 try {
344 mVideoProviderBinder.sendSessionModifyRequest(reqProfile);
345 } catch (RemoteException e) {
346 }
347 }
348
349 public void sendSessionModifyResponse(VideoProfile responseProfile) {
350 try {
351 mVideoProviderBinder.sendSessionModifyResponse(responseProfile);
352 } catch (RemoteException e) {
353 }
354 }
355
356 public void requestCameraCapabilities() {
357 try {
358 mVideoProviderBinder.requestCameraCapabilities();
359 } catch (RemoteException e) {
360 }
361 }
362
363 public void requestCallDataUsage() {
364 try {
365 mVideoProviderBinder.requestCallDataUsage();
366 } catch (RemoteException e) {
367 }
368 }
369
370 public void setPauseImage(String uri) {
371 try {
372 mVideoProviderBinder.setPauseImage(uri);
373 } catch (RemoteException e) {
374 }
375 }
376 }
377
Evan Charltonbf11f982014-07-20 22:06:28 -0700378 private IConnectionService mConnectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700379 private final String mConnectionId;
Jay Shrauner229e3822014-08-15 09:23:07 -0700380 /**
381 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
382 * load factor before resizing, 1 means we only expect a single thread to
383 * access the map so make only a single shard
384 */
Andrew Lee100e2932014-09-08 15:34:24 -0700385 private final Set<Callback> mCallbacks = Collections.newSetFromMap(
386 new ConcurrentHashMap<Callback, Boolean>(8, 0.9f, 1));
Ihab Awadb8e85c72014-08-23 20:34:57 -0700387 private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>();
388 private final List<RemoteConnection> mUnmodifiableconferenceableConnections =
389 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon52d8a152014-06-17 19:08:45 -0700390
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700391 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700392 private DisconnectCause mDisconnectCause;
Andrew Lee100e2932014-09-08 15:34:24 -0700393 private boolean mRingbackRequested;
Santos Cordon52d8a152014-06-17 19:08:45 -0700394 private boolean mConnected;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800395 private int mConnectionCapabilities;
Tyler Gunnaa07df82014-07-17 07:50:22 -0700396 private int mVideoState;
Ihab Awada64627c2014-08-20 09:36:40 -0700397 private VideoProvider mVideoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700398 private boolean mIsVoipAudioMode;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700399 private StatusHints mStatusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700400 private Uri mAddress;
401 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700402 private String mCallerDisplayName;
403 private int mCallerDisplayNamePresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -0700404 private RemoteConference mConference;
Santos Cordon52d8a152014-06-17 19:08:45 -0700405
406 /**
407 * @hide
408 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700409 RemoteConnection(
410 String id,
411 IConnectionService connectionService,
412 ConnectionRequest request) {
413 mConnectionId = id;
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700414 mConnectionService = connectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700415 mConnected = true;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700416 mState = Connection.STATE_INITIALIZING;
Evan Charltonbf11f982014-07-20 22:06:28 -0700417 }
418
419 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700420 * @hide
421 */
422 RemoteConnection(String callId, IConnectionService connectionService,
423 ParcelableConnection connection) {
424 mConnectionId = callId;
425 mConnectionService = connectionService;
426 mConnected = true;
427 mState = connection.getState();
428 mDisconnectCause = connection.getDisconnectCause();
429 mRingbackRequested = connection.isRingbackRequested();
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800430 mConnectionCapabilities = connection.getConnectionCapabilities();
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700431 mVideoState = connection.getVideoState();
432 mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider());
433 mIsVoipAudioMode = connection.getIsVoipAudioMode();
434 mStatusHints = connection.getStatusHints();
435 mAddress = connection.getHandle();
436 mAddressPresentation = connection.getHandlePresentation();
437 mCallerDisplayName = connection.getCallerDisplayName();
438 mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
439 mConference = null;
440 }
441
442 /**
Evan Charltonbf11f982014-07-20 22:06:28 -0700443 * Create a RemoteConnection which is used for failed connections. Note that using it for any
444 * "real" purpose will almost certainly fail. Callers should note the failure and act
445 * accordingly (moving on to another RemoteConnection, for example)
446 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700447 * @param disconnectCause The reason for the failed connection.
448 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700449 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700450 RemoteConnection(DisconnectCause disconnectCause) {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700451 mConnectionId = "NULL";
Evan Charltonbf11f982014-07-20 22:06:28 -0700452 mConnected = false;
Ihab Awad6107bab2014-08-18 09:23:25 -0700453 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700454 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700455 }
456
Ihab Awad5d0410f2014-07-30 10:07:40 -0700457 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700458 * Adds a callback to this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700459 *
Andrew Lee100e2932014-09-08 15:34:24 -0700460 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700461 */
Andrew Lee100e2932014-09-08 15:34:24 -0700462 public void registerCallback(Callback callback) {
463 mCallbacks.add(callback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700464 }
465
Ihab Awad5d0410f2014-07-30 10:07:40 -0700466 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700467 * Removes a callback from this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700468 *
Andrew Lee100e2932014-09-08 15:34:24 -0700469 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700470 */
Andrew Lee100e2932014-09-08 15:34:24 -0700471 public void unregisterCallback(Callback callback) {
472 if (callback != null) {
473 mCallbacks.remove(callback);
Jay Shrauner229e3822014-08-15 09:23:07 -0700474 }
Santos Cordon52d8a152014-06-17 19:08:45 -0700475 }
476
Ihab Awad5d0410f2014-07-30 10:07:40 -0700477 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700478 * Obtains the state of this {@code RemoteConnection}.
479 *
480 * @return A state value, chosen from the {@code STATE_*} constants.
481 */
Sailesh Nepalade3f252014-07-01 17:25:37 -0700482 public int getState() {
483 return mState;
484 }
485
Ihab Awad5d0410f2014-07-30 10:07:40 -0700486 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800487 * Obtains the reason why this {@code RemoteConnection} may have been disconnected.
488 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700489 * @return For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800490 * disconnect cause expressed as a code chosen from among those declared in
491 * {@link DisconnectCause}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700492 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700493 public DisconnectCause getDisconnectCause() {
494 return mDisconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700495 }
496
Ihab Awad5d0410f2014-07-30 10:07:40 -0700497 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800498 * Obtains the capabilities of this {@code RemoteConnection}.
499 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700500 * @return A bitmask of the capabilities of the {@code RemoteConnection}, as defined in
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800501 * the {@code CAPABILITY_*} constants in class {@link Connection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700502 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800503 public int getConnectionCapabilities() {
504 return mConnectionCapabilities;
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700505 }
506
Ihab Awad5d0410f2014-07-30 10:07:40 -0700507 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800508 * Determines if the audio mode of this {@code RemoteConnection} is VOIP.
509 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700510 * @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP.
511 */
Andrew Lee100e2932014-09-08 15:34:24 -0700512 public boolean isVoipAudioMode() {
513 return mIsVoipAudioMode;
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700514 }
515
Ihab Awad5d0410f2014-07-30 10:07:40 -0700516 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800517 * Obtains status hints pertaining to this {@code RemoteConnection}.
518 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700519 * @return The current {@link StatusHints} of this {@code RemoteConnection},
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800520 * or {@code null} if none have been set.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700521 */
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700522 public StatusHints getStatusHints() {
523 return mStatusHints;
524 }
525
Ihab Awad5d0410f2014-07-30 10:07:40 -0700526 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800527 * Obtains the address of this {@code RemoteConnection}.
528 *
529 * @return The address (e.g., phone number) to which the {@code RemoteConnection}
530 * is currently connected.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700531 */
Andrew Lee100e2932014-09-08 15:34:24 -0700532 public Uri getAddress() {
533 return mAddress;
Sailesh Nepal61203862014-07-11 14:50:13 -0700534 }
535
Ihab Awad5d0410f2014-07-30 10:07:40 -0700536 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800537 * Obtains the presentation requirements for the address of this {@code RemoteConnection}.
538 *
539 * @return The presentation requirements for the address. See
540 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700541 */
Andrew Lee100e2932014-09-08 15:34:24 -0700542 public int getAddressPresentation() {
543 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700544 }
545
Ihab Awad5d0410f2014-07-30 10:07:40 -0700546 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800547 * Obtains the display name for this {@code RemoteConnection}'s caller.
548 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700549 * @return The display name for the caller.
550 */
Andrew Lee100e2932014-09-08 15:34:24 -0700551 public CharSequence getCallerDisplayName() {
Sailesh Nepal61203862014-07-11 14:50:13 -0700552 return mCallerDisplayName;
553 }
554
Ihab Awad5d0410f2014-07-30 10:07:40 -0700555 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800556 * Obtains the presentation requirements for this {@code RemoteConnection}'s
557 * caller's display name.
558 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700559 * @return The presentation requirements for the caller display name. See
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800560 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700561 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700562 public int getCallerDisplayNamePresentation() {
563 return mCallerDisplayNamePresentation;
564 }
565
Ihab Awad5d0410f2014-07-30 10:07:40 -0700566 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800567 * Obtains the video state of this {@code RemoteConnection}.
568 *
569 * @return The video state of the {@code RemoteConnection}. See {@link VideoProfile.VideoState}.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700570 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700571 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700572 public int getVideoState() {
573 return mVideoState;
574 }
575
Ihab Awad5d0410f2014-07-30 10:07:40 -0700576 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800577 * Obtains the video provider of this {@code RemoteConnection}.
578 *
Ihab Awada64627c2014-08-20 09:36:40 -0700579 * @return The video provider associated with this {@code RemoteConnection}.
580 * @hide
581 */
582 public final VideoProvider getVideoProvider() {
583 return mVideoProvider;
584 }
585
586 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800587 * Determines whether this {@code RemoteConnection} is requesting ringback.
588 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700589 * @return Whether the {@code RemoteConnection} is requesting that the framework play a
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800590 * ringback tone on its behalf.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700591 */
Andrew Lee100e2932014-09-08 15:34:24 -0700592 public boolean isRingbackRequested() {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700593 return false;
594 }
595
596 /**
597 * Instructs this {@code RemoteConnection} to abort.
598 */
Sailesh Nepal091768c2014-06-30 15:15:23 -0700599 public void abort() {
600 try {
601 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700602 mConnectionService.abort(mConnectionId);
Sailesh Nepal091768c2014-06-30 15:15:23 -0700603 }
604 } catch (RemoteException ignored) {
605 }
606 }
607
Ihab Awad5d0410f2014-07-30 10:07:40 -0700608 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700609 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
Tyler Gunnbe74de02014-08-29 14:51:48 -0700610 */
611 public void answer() {
612 try {
613 if (mConnected) {
614 mConnectionService.answer(mConnectionId);
615 }
616 } catch (RemoteException ignored) {
617 }
618 }
619
620 /**
621 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700622 * @param videoState The video state in which to answer the call.
Tyler Gunnbe74de02014-08-29 14:51:48 -0700623 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700624 */
Andrew Lee8da4c3c2014-07-16 10:11:42 -0700625 public void answer(int videoState) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700626 try {
627 if (mConnected) {
Tyler Gunnbe74de02014-08-29 14:51:48 -0700628 mConnectionService.answerVideo(mConnectionId, videoState);
Santos Cordon52d8a152014-06-17 19:08:45 -0700629 }
630 } catch (RemoteException ignored) {
631 }
632 }
633
Ihab Awad5d0410f2014-07-30 10:07:40 -0700634 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700635 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to reject.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700636 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700637 public void reject() {
638 try {
639 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700640 mConnectionService.reject(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700641 }
642 } catch (RemoteException ignored) {
643 }
644 }
645
Ihab Awad5d0410f2014-07-30 10:07:40 -0700646 /**
647 * Instructs this {@code RemoteConnection} to go on hold.
648 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700649 public void hold() {
650 try {
651 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700652 mConnectionService.hold(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700653 }
654 } catch (RemoteException ignored) {
655 }
656 }
657
Ihab Awad5d0410f2014-07-30 10:07:40 -0700658 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700659 * Instructs this {@link Connection#STATE_HOLDING} call to release from hold.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700660 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700661 public void unhold() {
662 try {
663 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700664 mConnectionService.unhold(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700665 }
666 } catch (RemoteException ignored) {
667 }
668 }
669
Ihab Awad5d0410f2014-07-30 10:07:40 -0700670 /**
671 * Instructs this {@code RemoteConnection} to disconnect.
672 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700673 public void disconnect() {
674 try {
675 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700676 mConnectionService.disconnect(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700677 }
678 } catch (RemoteException ignored) {
679 }
680 }
681
Ihab Awad5d0410f2014-07-30 10:07:40 -0700682 /**
683 * Instructs this {@code RemoteConnection} to play a dual-tone multi-frequency signaling
684 * (DTMF) tone.
685 *
686 * Any other currently playing DTMF tone in the specified call is immediately stopped.
687 *
688 * @param digit A character representing the DTMF digit for which to play the tone. This
689 * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.
690 */
691 public void playDtmfTone(char digit) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700692 try {
693 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700694 mConnectionService.playDtmfTone(mConnectionId, digit);
Santos Cordon52d8a152014-06-17 19:08:45 -0700695 }
696 } catch (RemoteException ignored) {
697 }
698 }
699
Ihab Awad5d0410f2014-07-30 10:07:40 -0700700 /**
701 * Instructs this {@code RemoteConnection} to stop any dual-tone multi-frequency signaling
702 * (DTMF) tone currently playing.
703 *
704 * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is
705 * currently playing, this method will do nothing.
706 */
707 public void stopDtmfTone() {
Santos Cordon52d8a152014-06-17 19:08:45 -0700708 try {
709 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700710 mConnectionService.stopDtmfTone(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700711 }
712 } catch (RemoteException ignored) {
713 }
714 }
715
Ihab Awad5d0410f2014-07-30 10:07:40 -0700716 /**
717 * Instructs this {@code RemoteConnection} to continue playing a post-dial DTMF string.
718 *
719 * A post-dial DTMF string is a string of digits following the first instance of either
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700720 * {@link TelecomManager#DTMF_CHARACTER_WAIT} or {@link TelecomManager#DTMF_CHARACTER_PAUSE}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700721 * These digits are immediately sent as DTMF tones to the recipient as soon as the
722 * connection is made.
723 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700724 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this
Ihab Awad5d0410f2014-07-30 10:07:40 -0700725 * {@code RemoteConnection} will temporarily pause playing the tones for a pre-defined period
726 * of time.
727 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700728 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this
Andrew Lee100e2932014-09-08 15:34:24 -0700729 * {@code RemoteConnection} will pause playing the tones and notify callbackss via
730 * {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app
Ihab Awad5d0410f2014-07-30 10:07:40 -0700731 * should display to the user an indication of this state and an affordance to continue
732 * the postdial sequence. When the user decides to continue the postdial sequence, the in-call
733 * app should invoke the {@link #postDialContinue(boolean)} method.
734 *
735 * @param proceed Whether or not to continue with the post-dial sequence.
736 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700737 public void postDialContinue(boolean proceed) {
738 try {
739 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700740 mConnectionService.onPostDialContinue(mConnectionId, proceed);
Santos Cordon52d8a152014-06-17 19:08:45 -0700741 }
742 } catch (RemoteException ignored) {
743 }
744 }
745
Ihab Awad5d0410f2014-07-30 10:07:40 -0700746 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700747 * Set the audio state of this {@code RemoteConnection}.
748 *
749 * @param state The audio state of this {@code RemoteConnection}.
750 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700751 public void setAudioState(AudioState state) {
Sailesh Nepal091768c2014-06-30 15:15:23 -0700752 try {
753 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700754 mConnectionService.onAudioStateChanged(mConnectionId, state);
Sailesh Nepal091768c2014-06-30 15:15:23 -0700755 }
756 } catch (RemoteException ignored) {
757 }
758 }
759
Santos Cordon52d8a152014-06-17 19:08:45 -0700760 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700761 * Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be
762 * successfully asked to create a conference with.
763 *
764 * @return The {@code RemoteConnection}s with which this {@code RemoteConnection} may be
765 * merged into a {@link RemoteConference}.
766 */
767 public List<RemoteConnection> getConferenceableConnections() {
768 return mUnmodifiableconferenceableConnections;
769 }
770
771 /**
772 * Obtain the {@code RemoteConference} that this {@code RemoteConnection} may be a part
773 * of, or {@code null} if there is no such {@code RemoteConference}.
774 *
775 * @return A {@code RemoteConference} or {@code null};
776 */
777 public RemoteConference getConference() {
778 return mConference;
779 }
780
781 /** {@hide} */
782 String getId() {
783 return mConnectionId;
784 }
785
786 /** {@hide} */
787 IConnectionService getConnectionService() {
788 return mConnectionService;
789 }
790
791 /**
Santos Cordon52d8a152014-06-17 19:08:45 -0700792 * @hide
793 */
794 void setState(int state) {
795 if (mState != state) {
796 mState = state;
Andrew Lee100e2932014-09-08 15:34:24 -0700797 for (Callback c: mCallbacks) {
798 c.onStateChanged(this, state);
Santos Cordon52d8a152014-06-17 19:08:45 -0700799 }
800 }
801 }
802
803 /**
804 * @hide
805 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700806 void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700807 if (mState != Connection.STATE_DISCONNECTED) {
808 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700809 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700810
Andrew Lee100e2932014-09-08 15:34:24 -0700811 for (Callback c : mCallbacks) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700812 c.onDisconnected(this, mDisconnectCause);
Santos Cordon52d8a152014-06-17 19:08:45 -0700813 }
814 }
815 }
816
817 /**
818 * @hide
819 */
Andrew Lee100e2932014-09-08 15:34:24 -0700820 void setRingbackRequested(boolean ringback) {
821 if (mRingbackRequested != ringback) {
822 mRingbackRequested = ringback;
823 for (Callback c : mCallbacks) {
824 c.onRingbackRequested(this, ringback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700825 }
826 }
827 }
828
829 /**
830 * @hide
831 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800832 void setConnectionCapabilities(int connectionCapabilities) {
833 mConnectionCapabilities = connectionCapabilities;
Andrew Lee100e2932014-09-08 15:34:24 -0700834 for (Callback c : mCallbacks) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800835 c.onConnectionCapabilitiesChanged(this, connectionCapabilities);
836 c.onCallCapabilitiesChanged(this, connectionCapabilities);
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700837 }
838 }
839
840 /**
841 * @hide
842 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700843 void setDestroyed() {
Andrew Lee100e2932014-09-08 15:34:24 -0700844 if (!mCallbacks.isEmpty()) {
845 // Make sure that the callbacks are notified that the call is destroyed first.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700846 if (mState != Connection.STATE_DISCONNECTED) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700847 setDisconnected(
848 new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed."));
Santos Cordon52d8a152014-06-17 19:08:45 -0700849 }
850
Andrew Lee100e2932014-09-08 15:34:24 -0700851 for (Callback c : mCallbacks) {
852 c.onDestroyed(this);
Santos Cordon52d8a152014-06-17 19:08:45 -0700853 }
Andrew Lee100e2932014-09-08 15:34:24 -0700854 mCallbacks.clear();
Santos Cordon52d8a152014-06-17 19:08:45 -0700855
856 mConnected = false;
857 }
858 }
859
860 /**
861 * @hide
862 */
863 void setPostDialWait(String remainingDigits) {
Andrew Lee100e2932014-09-08 15:34:24 -0700864 for (Callback c : mCallbacks) {
865 c.onPostDialWait(this, remainingDigits);
Santos Cordon52d8a152014-06-17 19:08:45 -0700866 }
867 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700868
Tyler Gunnaa07df82014-07-17 07:50:22 -0700869 /**
870 * @hide
871 */
872 void setVideoState(int videoState) {
873 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700874 for (Callback c : mCallbacks) {
875 c.onVideoStateChanged(this, videoState);
Tyler Gunnaa07df82014-07-17 07:50:22 -0700876 }
877 }
878
Ihab Awada64627c2014-08-20 09:36:40 -0700879 /**
880 * @hide
881 */
882 void setVideoProvider(VideoProvider videoProvider) {
883 mVideoProvider = videoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700884 for (Callback c : mCallbacks) {
885 c.onVideoProviderChanged(this, videoProvider);
Ihab Awada64627c2014-08-20 09:36:40 -0700886 }
887 }
888
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700889 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700890 void setIsVoipAudioMode(boolean isVoip) {
891 mIsVoipAudioMode = isVoip;
892 for (Callback c : mCallbacks) {
893 c.onVoipAudioChanged(this, isVoip);
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700894 }
895 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700896
897 /** @hide */
898 void setStatusHints(StatusHints statusHints) {
899 mStatusHints = statusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700900 for (Callback c : mCallbacks) {
901 c.onStatusHintsChanged(this, statusHints);
Sailesh Nepal61203862014-07-11 14:50:13 -0700902 }
903 }
904
905 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700906 void setAddress(Uri address, int presentation) {
907 mAddress = address;
908 mAddressPresentation = presentation;
909 for (Callback c : mCallbacks) {
910 c.onAddressChanged(this, address, presentation);
Sailesh Nepal61203862014-07-11 14:50:13 -0700911 }
912 }
913
914 /** @hide */
915 void setCallerDisplayName(String callerDisplayName, int presentation) {
916 mCallerDisplayName = callerDisplayName;
917 mCallerDisplayNamePresentation = presentation;
Andrew Lee100e2932014-09-08 15:34:24 -0700918 for (Callback c : mCallbacks) {
919 c.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700920 }
921 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700922
923 /** @hide */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700924 void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) {
925 mConferenceableConnections.clear();
926 mConferenceableConnections.addAll(conferenceableConnections);
Andrew Lee100e2932014-09-08 15:34:24 -0700927 for (Callback c : mCallbacks) {
928 c.onConferenceableConnectionsChanged(this, mUnmodifiableconferenceableConnections);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700929 }
930 }
931
932 /** @hide */
933 void setConference(RemoteConference conference) {
934 if (mConference != conference) {
935 mConference = conference;
Andrew Lee100e2932014-09-08 15:34:24 -0700936 for (Callback c : mCallbacks) {
937 c.onConferenceChanged(this, conference);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700938 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700939 }
940 }
941
Evan Charltonbf11f982014-07-20 22:06:28 -0700942 /**
Ihab Awad6107bab2014-08-18 09:23:25 -0700943 * Create a RemoteConnection represents a failure, and which will be in
944 * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
945 * certainly result in bad things happening. Do not do this.
Evan Charltonbf11f982014-07-20 22:06:28 -0700946 *
947 * @return a failed {@link RemoteConnection}
948 *
949 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700950 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700951 public static RemoteConnection failure(DisconnectCause disconnectCause) {
952 return new RemoteConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -0700953 }
Santos Cordon52d8a152014-06-17 19:08:45 -0700954}