blob: be7a0a04d7ac77829b03568bcc3798cda9892bdf [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 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800104 * Invoked when the post-dial sequence in the outgoing {@code Connection} has processed
105 * a character.
106 *
107 * @param connection The {@code RemoteConnection} invoking this method.
108 * @param nextChar The character being processed.
109 */
110 public void onPostDialChar(RemoteConnection connection, char nextChar) {}
111
112 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700113 * Indicates that the VOIP audio status of this {@code RemoteConnection} has changed.
Andrew Lee100e2932014-09-08 15:34:24 -0700114 * See {@link #isVoipAudioMode()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700115 *
116 * @param connection The {@code RemoteConnection} invoking this method.
117 * @param isVoip Whether the new audio state of the {@code RemoteConnection} is VOIP.
118 */
Andrew Lee100e2932014-09-08 15:34:24 -0700119 public void onVoipAudioChanged(RemoteConnection connection, boolean isVoip) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700120
121 /**
122 * Indicates that the status hints of this {@code RemoteConnection} have changed. See
123 * {@link #getStatusHints()} ()}.
124 *
125 * @param connection The {@code RemoteConnection} invoking this method.
126 * @param statusHints The new status hints of the {@code RemoteConnection}.
127 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700128 public void onStatusHintsChanged(RemoteConnection connection, StatusHints statusHints) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700129
130 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700131 * Indicates that the address (e.g., phone number) of this {@code RemoteConnection} has
132 * changed. See {@link #getAddress()} and {@link #getAddressPresentation()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700133 *
134 * @param connection The {@code RemoteConnection} invoking this method.
Andrew Lee100e2932014-09-08 15:34:24 -0700135 * @param address The new address of the {@code RemoteConnection}.
136 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700137 * See {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700138 */
Andrew Lee100e2932014-09-08 15:34:24 -0700139 public void onAddressChanged(RemoteConnection connection, Uri address, int presentation) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700140
141 /**
142 * Indicates that the caller display name of this {@code RemoteConnection} has changed.
143 * See {@link #getCallerDisplayName()} and {@link #getCallerDisplayNamePresentation()}.
144 *
145 * @param connection The {@code RemoteConnection} invoking this method.
146 * @param callerDisplayName The new caller display name of the {@code RemoteConnection}.
Nancy Chen9d568c02014-09-08 14:17:59 -0700147 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700148 * See {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700149 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700150 public void onCallerDisplayNameChanged(
151 RemoteConnection connection, String callerDisplayName, int presentation) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700152
153 /**
154 * Indicates that the video state of this {@code RemoteConnection} has changed.
155 * See {@link #getVideoState()}.
156 *
157 * @param connection The {@code RemoteConnection} invoking this method.
158 * @param videoState The new video state of the {@code RemoteConnection}.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700159 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700160 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700161 public void onVideoStateChanged(RemoteConnection connection, int videoState) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700162
163 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700164 * Indicates that the call substate of this {@code RemoteConnection} has changed.
165 * See {@link #getCallSubstate()}.
166 *
167 * @param connection The {@code RemoteConnection} invoking this method.
168 * @param callSubstate The new call substate of the {@code RemoteConnection}.
169 * @hide
170 */
171 public void onCallSubstateChanged(RemoteConnection connection, int callSubstate) {}
172
173 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700174 * Indicates that this {@code RemoteConnection} has been destroyed. No further requests
175 * should be made to the {@code RemoteConnection}, and references to it should be cleared.
176 *
177 * @param connection The {@code RemoteConnection} invoking this method.
178 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700179 public void onDestroyed(RemoteConnection connection) {}
Ihab Awadb8e85c72014-08-23 20:34:57 -0700180
181 /**
182 * Indicates that the {@code RemoteConnection}s with which this {@code RemoteConnection}
183 * may be asked to create a conference has changed.
184 *
185 * @param connection The {@code RemoteConnection} invoking this method.
186 * @param conferenceableConnections The {@code RemoteConnection}s with which this
187 * {@code RemoteConnection} may be asked to create a conference.
188 */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700189 public void onConferenceableConnectionsChanged(
Ihab Awadb8e85c72014-08-23 20:34:57 -0700190 RemoteConnection connection,
191 List<RemoteConnection> conferenceableConnections) {}
192
193 /**
Ihab Awada64627c2014-08-20 09:36:40 -0700194 * Indicates that the {@code VideoProvider} associated with this {@code RemoteConnection}
195 * has changed.
196 *
197 * @param connection The {@code RemoteConnection} invoking this method.
198 * @param videoProvider The new {@code VideoProvider} associated with this
199 * {@code RemoteConnection}.
200 * @hide
201 */
202 public void onVideoProviderChanged(
203 RemoteConnection connection, VideoProvider videoProvider) {}
204
205 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700206 * Indicates that the {@code RemoteConference} that this {@code RemoteConnection} is a part
207 * of has changed.
208 *
209 * @param connection The {@code RemoteConnection} invoking this method.
210 * @param conference The {@code RemoteConference} of which this {@code RemoteConnection} is
211 * a part, which may be {@code null}.
212 */
213 public void onConferenceChanged(
214 RemoteConnection connection,
215 RemoteConference conference) {}
Santos Cordon52d8a152014-06-17 19:08:45 -0700216 }
217
Ihab Awada64627c2014-08-20 09:36:40 -0700218 /** {@hide} */
219 public static class VideoProvider {
220
221 public abstract static class Listener {
222 public void onReceiveSessionModifyRequest(
223 VideoProvider videoProvider,
224 VideoProfile videoProfile) {}
225
226 public void onReceiveSessionModifyResponse(
227 VideoProvider videoProvider,
228 int status,
229 VideoProfile requestedProfile,
230 VideoProfile responseProfile) {}
231
232 public void onHandleCallSessionEvent(VideoProvider videoProvider, int event) {}
233
234 public void onPeerDimensionsChanged(VideoProvider videoProvider, int width, int height) {}
235
Rekha Kumar07366812015-03-24 16:42:31 -0700236 public void onCallDataUsageChanged(VideoProvider videoProvider, long dataUsage) {}
Ihab Awada64627c2014-08-20 09:36:40 -0700237
238 public void onCameraCapabilitiesChanged(
239 VideoProvider videoProvider,
240 CameraCapabilities cameraCapabilities) {}
Rekha Kumar07366812015-03-24 16:42:31 -0700241
242 public void onVideoQualityChanged(VideoProvider videoProvider, int videoQuality) {}
Ihab Awada64627c2014-08-20 09:36:40 -0700243 }
244
245 private final IVideoCallback mVideoCallbackDelegate = new IVideoCallback() {
246 @Override
247 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
248 for (Listener l : mListeners) {
249 l.onReceiveSessionModifyRequest(VideoProvider.this, videoProfile);
250 }
251 }
252
253 @Override
254 public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile,
255 VideoProfile responseProfile) {
256 for (Listener l : mListeners) {
257 l.onReceiveSessionModifyResponse(
258 VideoProvider.this,
259 status,
260 requestedProfile,
261 responseProfile);
262 }
263 }
264
265 @Override
266 public void handleCallSessionEvent(int event) {
267 for (Listener l : mListeners) {
268 l.onHandleCallSessionEvent(VideoProvider.this, event);
269 }
270 }
271
272 @Override
273 public void changePeerDimensions(int width, int height) {
274 for (Listener l : mListeners) {
275 l.onPeerDimensionsChanged(VideoProvider.this, width, height);
276 }
277 }
278
279 @Override
Rekha Kumar07366812015-03-24 16:42:31 -0700280 public void changeCallDataUsage(long dataUsage) {
Ihab Awada64627c2014-08-20 09:36:40 -0700281 for (Listener l : mListeners) {
282 l.onCallDataUsageChanged(VideoProvider.this, dataUsage);
283 }
284 }
285
286 @Override
287 public void changeCameraCapabilities(CameraCapabilities cameraCapabilities) {
288 for (Listener l : mListeners) {
289 l.onCameraCapabilitiesChanged(VideoProvider.this, cameraCapabilities);
290 }
291 }
292
293 @Override
Rekha Kumar07366812015-03-24 16:42:31 -0700294 public void changeVideoQuality(int videoQuality) {
295 for (Listener l : mListeners) {
296 l.onVideoQualityChanged(VideoProvider.this, videoQuality);
297 }
298 }
299
300 @Override
Ihab Awada64627c2014-08-20 09:36:40 -0700301 public IBinder asBinder() {
302 return null;
303 }
304 };
305
306 private final VideoCallbackServant mVideoCallbackServant =
307 new VideoCallbackServant(mVideoCallbackDelegate);
308
309 private final IVideoProvider mVideoProviderBinder;
310
311 /**
312 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
313 * load factor before resizing, 1 means we only expect a single thread to
314 * access the map so make only a single shard
315 */
316 private final Set<Listener> mListeners = Collections.newSetFromMap(
317 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
318
319 public VideoProvider(IVideoProvider videoProviderBinder) {
320 mVideoProviderBinder = videoProviderBinder;
321 try {
322 mVideoProviderBinder.setVideoCallback(mVideoCallbackServant.getStub().asBinder());
323 } catch (RemoteException e) {
324 }
325 }
326
327 public void addListener(Listener l) {
328 mListeners.add(l);
329 }
330
331 public void removeListener(Listener l) {
332 mListeners.remove(l);
333 }
334
335 public void setCamera(String cameraId) {
336 try {
337 mVideoProviderBinder.setCamera(cameraId);
338 } catch (RemoteException e) {
339 }
340 }
341
342 public void setPreviewSurface(Surface surface) {
343 try {
344 mVideoProviderBinder.setPreviewSurface(surface);
345 } catch (RemoteException e) {
346 }
347 }
348
349 public void setDisplaySurface(Surface surface) {
350 try {
351 mVideoProviderBinder.setDisplaySurface(surface);
352 } catch (RemoteException e) {
353 }
354 }
355
356 public void setDeviceOrientation(int rotation) {
357 try {
358 mVideoProviderBinder.setDeviceOrientation(rotation);
359 } catch (RemoteException e) {
360 }
361 }
362
363 public void setZoom(float value) {
364 try {
365 mVideoProviderBinder.setZoom(value);
366 } catch (RemoteException e) {
367 }
368 }
369
370 public void sendSessionModifyRequest(VideoProfile reqProfile) {
371 try {
372 mVideoProviderBinder.sendSessionModifyRequest(reqProfile);
373 } catch (RemoteException e) {
374 }
375 }
376
377 public void sendSessionModifyResponse(VideoProfile responseProfile) {
378 try {
379 mVideoProviderBinder.sendSessionModifyResponse(responseProfile);
380 } catch (RemoteException e) {
381 }
382 }
383
384 public void requestCameraCapabilities() {
385 try {
386 mVideoProviderBinder.requestCameraCapabilities();
387 } catch (RemoteException e) {
388 }
389 }
390
391 public void requestCallDataUsage() {
392 try {
393 mVideoProviderBinder.requestCallDataUsage();
394 } catch (RemoteException e) {
395 }
396 }
397
398 public void setPauseImage(String uri) {
399 try {
400 mVideoProviderBinder.setPauseImage(uri);
401 } catch (RemoteException e) {
402 }
403 }
404 }
405
Evan Charltonbf11f982014-07-20 22:06:28 -0700406 private IConnectionService mConnectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700407 private final String mConnectionId;
Jay Shrauner229e3822014-08-15 09:23:07 -0700408 /**
409 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
410 * load factor before resizing, 1 means we only expect a single thread to
411 * access the map so make only a single shard
412 */
Andrew Lee100e2932014-09-08 15:34:24 -0700413 private final Set<Callback> mCallbacks = Collections.newSetFromMap(
414 new ConcurrentHashMap<Callback, Boolean>(8, 0.9f, 1));
Ihab Awadb8e85c72014-08-23 20:34:57 -0700415 private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>();
416 private final List<RemoteConnection> mUnmodifiableconferenceableConnections =
417 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon52d8a152014-06-17 19:08:45 -0700418
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700419 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700420 private DisconnectCause mDisconnectCause;
Andrew Lee100e2932014-09-08 15:34:24 -0700421 private boolean mRingbackRequested;
Santos Cordon52d8a152014-06-17 19:08:45 -0700422 private boolean mConnected;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800423 private int mConnectionCapabilities;
Tyler Gunnaa07df82014-07-17 07:50:22 -0700424 private int mVideoState;
Rekha Kumar07366812015-03-24 16:42:31 -0700425 private int mCallSubstate;
Ihab Awada64627c2014-08-20 09:36:40 -0700426 private VideoProvider mVideoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700427 private boolean mIsVoipAudioMode;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700428 private StatusHints mStatusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700429 private Uri mAddress;
430 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700431 private String mCallerDisplayName;
432 private int mCallerDisplayNamePresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -0700433 private RemoteConference mConference;
Santos Cordon52d8a152014-06-17 19:08:45 -0700434
435 /**
436 * @hide
437 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700438 RemoteConnection(
439 String id,
440 IConnectionService connectionService,
441 ConnectionRequest request) {
442 mConnectionId = id;
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700443 mConnectionService = connectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700444 mConnected = true;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700445 mState = Connection.STATE_INITIALIZING;
Evan Charltonbf11f982014-07-20 22:06:28 -0700446 }
447
448 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700449 * @hide
450 */
451 RemoteConnection(String callId, IConnectionService connectionService,
452 ParcelableConnection connection) {
453 mConnectionId = callId;
454 mConnectionService = connectionService;
455 mConnected = true;
456 mState = connection.getState();
457 mDisconnectCause = connection.getDisconnectCause();
458 mRingbackRequested = connection.isRingbackRequested();
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800459 mConnectionCapabilities = connection.getConnectionCapabilities();
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700460 mVideoState = connection.getVideoState();
461 mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider());
462 mIsVoipAudioMode = connection.getIsVoipAudioMode();
463 mStatusHints = connection.getStatusHints();
464 mAddress = connection.getHandle();
465 mAddressPresentation = connection.getHandlePresentation();
466 mCallerDisplayName = connection.getCallerDisplayName();
467 mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
468 mConference = null;
469 }
470
471 /**
Evan Charltonbf11f982014-07-20 22:06:28 -0700472 * Create a RemoteConnection which is used for failed connections. Note that using it for any
473 * "real" purpose will almost certainly fail. Callers should note the failure and act
474 * accordingly (moving on to another RemoteConnection, for example)
475 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700476 * @param disconnectCause The reason for the failed connection.
477 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700478 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700479 RemoteConnection(DisconnectCause disconnectCause) {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700480 mConnectionId = "NULL";
Evan Charltonbf11f982014-07-20 22:06:28 -0700481 mConnected = false;
Ihab Awad6107bab2014-08-18 09:23:25 -0700482 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700483 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700484 }
485
Ihab Awad5d0410f2014-07-30 10:07:40 -0700486 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700487 * Adds a callback to this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700488 *
Andrew Lee100e2932014-09-08 15:34:24 -0700489 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700490 */
Andrew Lee100e2932014-09-08 15:34:24 -0700491 public void registerCallback(Callback callback) {
492 mCallbacks.add(callback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700493 }
494
Ihab Awad5d0410f2014-07-30 10:07:40 -0700495 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700496 * Removes a callback from this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700497 *
Andrew Lee100e2932014-09-08 15:34:24 -0700498 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700499 */
Andrew Lee100e2932014-09-08 15:34:24 -0700500 public void unregisterCallback(Callback callback) {
501 if (callback != null) {
502 mCallbacks.remove(callback);
Jay Shrauner229e3822014-08-15 09:23:07 -0700503 }
Santos Cordon52d8a152014-06-17 19:08:45 -0700504 }
505
Ihab Awad5d0410f2014-07-30 10:07:40 -0700506 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700507 * Obtains the state of this {@code RemoteConnection}.
508 *
509 * @return A state value, chosen from the {@code STATE_*} constants.
510 */
Sailesh Nepalade3f252014-07-01 17:25:37 -0700511 public int getState() {
512 return mState;
513 }
514
Ihab Awad5d0410f2014-07-30 10:07:40 -0700515 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800516 * Obtains the reason why this {@code RemoteConnection} may have been disconnected.
517 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700518 * @return For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800519 * disconnect cause expressed as a code chosen from among those declared in
520 * {@link DisconnectCause}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700521 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700522 public DisconnectCause getDisconnectCause() {
523 return mDisconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700524 }
525
Ihab Awad5d0410f2014-07-30 10:07:40 -0700526 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800527 * Obtains the capabilities of this {@code RemoteConnection}.
528 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700529 * @return A bitmask of the capabilities of the {@code RemoteConnection}, as defined in
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800530 * the {@code CAPABILITY_*} constants in class {@link Connection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700531 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800532 public int getConnectionCapabilities() {
533 return mConnectionCapabilities;
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700534 }
535
Ihab Awad5d0410f2014-07-30 10:07:40 -0700536 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800537 * Determines if the audio mode of this {@code RemoteConnection} is VOIP.
538 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700539 * @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP.
540 */
Andrew Lee100e2932014-09-08 15:34:24 -0700541 public boolean isVoipAudioMode() {
542 return mIsVoipAudioMode;
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700543 }
544
Ihab Awad5d0410f2014-07-30 10:07:40 -0700545 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800546 * Obtains status hints pertaining to this {@code RemoteConnection}.
547 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700548 * @return The current {@link StatusHints} of this {@code RemoteConnection},
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800549 * or {@code null} if none have been set.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700550 */
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700551 public StatusHints getStatusHints() {
552 return mStatusHints;
553 }
554
Ihab Awad5d0410f2014-07-30 10:07:40 -0700555 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800556 * Obtains the address of this {@code RemoteConnection}.
557 *
558 * @return The address (e.g., phone number) to which the {@code RemoteConnection}
559 * is currently connected.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700560 */
Andrew Lee100e2932014-09-08 15:34:24 -0700561 public Uri getAddress() {
562 return mAddress;
Sailesh Nepal61203862014-07-11 14:50:13 -0700563 }
564
Ihab Awad5d0410f2014-07-30 10:07:40 -0700565 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800566 * Obtains the presentation requirements for the address of this {@code RemoteConnection}.
567 *
568 * @return The presentation requirements for the address. See
569 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700570 */
Andrew Lee100e2932014-09-08 15:34:24 -0700571 public int getAddressPresentation() {
572 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700573 }
574
Ihab Awad5d0410f2014-07-30 10:07:40 -0700575 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800576 * Obtains the display name for this {@code RemoteConnection}'s caller.
577 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700578 * @return The display name for the caller.
579 */
Andrew Lee100e2932014-09-08 15:34:24 -0700580 public CharSequence getCallerDisplayName() {
Sailesh Nepal61203862014-07-11 14:50:13 -0700581 return mCallerDisplayName;
582 }
583
Ihab Awad5d0410f2014-07-30 10:07:40 -0700584 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800585 * Obtains the presentation requirements for this {@code RemoteConnection}'s
586 * caller's display name.
587 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700588 * @return The presentation requirements for the caller display name. See
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800589 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700590 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700591 public int getCallerDisplayNamePresentation() {
592 return mCallerDisplayNamePresentation;
593 }
594
Ihab Awad5d0410f2014-07-30 10:07:40 -0700595 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800596 * Obtains the video state of this {@code RemoteConnection}.
597 *
598 * @return The video state of the {@code RemoteConnection}. See {@link VideoProfile.VideoState}.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700599 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700600 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700601 public int getVideoState() {
602 return mVideoState;
603 }
604
Ihab Awad5d0410f2014-07-30 10:07:40 -0700605 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800606 *
Rekha Kumar07366812015-03-24 16:42:31 -0700607 * @return The call substate of the {@code RemoteConnection}. See
608 * @hide
609 */
610 public int getCallSubstate() {
611 return mCallSubstate;
612 }
613
614 /**
615 * Obtains the video provider of this {@code RemoteConnection}.
Ihab Awada64627c2014-08-20 09:36:40 -0700616 * @return The video provider associated with this {@code RemoteConnection}.
617 * @hide
618 */
619 public final VideoProvider getVideoProvider() {
620 return mVideoProvider;
621 }
622
623 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800624 * Determines whether this {@code RemoteConnection} is requesting ringback.
625 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700626 * @return Whether the {@code RemoteConnection} is requesting that the framework play a
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800627 * ringback tone on its behalf.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700628 */
Andrew Lee100e2932014-09-08 15:34:24 -0700629 public boolean isRingbackRequested() {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700630 return false;
631 }
632
633 /**
634 * Instructs this {@code RemoteConnection} to abort.
635 */
Sailesh Nepal091768c2014-06-30 15:15:23 -0700636 public void abort() {
637 try {
638 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700639 mConnectionService.abort(mConnectionId);
Sailesh Nepal091768c2014-06-30 15:15:23 -0700640 }
641 } catch (RemoteException ignored) {
642 }
643 }
644
Ihab Awad5d0410f2014-07-30 10:07:40 -0700645 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700646 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
Tyler Gunnbe74de02014-08-29 14:51:48 -0700647 */
648 public void answer() {
649 try {
650 if (mConnected) {
651 mConnectionService.answer(mConnectionId);
652 }
653 } catch (RemoteException ignored) {
654 }
655 }
656
657 /**
658 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700659 * @param videoState The video state in which to answer the call.
Tyler Gunnbe74de02014-08-29 14:51:48 -0700660 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700661 */
Andrew Lee8da4c3c2014-07-16 10:11:42 -0700662 public void answer(int videoState) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700663 try {
664 if (mConnected) {
Tyler Gunnbe74de02014-08-29 14:51:48 -0700665 mConnectionService.answerVideo(mConnectionId, videoState);
Santos Cordon52d8a152014-06-17 19:08:45 -0700666 }
667 } catch (RemoteException ignored) {
668 }
669 }
670
Ihab Awad5d0410f2014-07-30 10:07:40 -0700671 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700672 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to reject.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700673 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700674 public void reject() {
675 try {
676 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700677 mConnectionService.reject(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700678 }
679 } catch (RemoteException ignored) {
680 }
681 }
682
Ihab Awad5d0410f2014-07-30 10:07:40 -0700683 /**
684 * Instructs this {@code RemoteConnection} to go on hold.
685 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700686 public void hold() {
687 try {
688 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700689 mConnectionService.hold(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700690 }
691 } catch (RemoteException ignored) {
692 }
693 }
694
Ihab Awad5d0410f2014-07-30 10:07:40 -0700695 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700696 * Instructs this {@link Connection#STATE_HOLDING} call to release from hold.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700697 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700698 public void unhold() {
699 try {
700 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700701 mConnectionService.unhold(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700702 }
703 } catch (RemoteException ignored) {
704 }
705 }
706
Ihab Awad5d0410f2014-07-30 10:07:40 -0700707 /**
708 * Instructs this {@code RemoteConnection} to disconnect.
709 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700710 public void disconnect() {
711 try {
712 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700713 mConnectionService.disconnect(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700714 }
715 } catch (RemoteException ignored) {
716 }
717 }
718
Ihab Awad5d0410f2014-07-30 10:07:40 -0700719 /**
720 * Instructs this {@code RemoteConnection} to play a dual-tone multi-frequency signaling
721 * (DTMF) tone.
722 *
723 * Any other currently playing DTMF tone in the specified call is immediately stopped.
724 *
725 * @param digit A character representing the DTMF digit for which to play the tone. This
726 * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.
727 */
728 public void playDtmfTone(char digit) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700729 try {
730 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700731 mConnectionService.playDtmfTone(mConnectionId, digit);
Santos Cordon52d8a152014-06-17 19:08:45 -0700732 }
733 } catch (RemoteException ignored) {
734 }
735 }
736
Ihab Awad5d0410f2014-07-30 10:07:40 -0700737 /**
738 * Instructs this {@code RemoteConnection} to stop any dual-tone multi-frequency signaling
739 * (DTMF) tone currently playing.
740 *
741 * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is
742 * currently playing, this method will do nothing.
743 */
744 public void stopDtmfTone() {
Santos Cordon52d8a152014-06-17 19:08:45 -0700745 try {
746 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700747 mConnectionService.stopDtmfTone(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700748 }
749 } catch (RemoteException ignored) {
750 }
751 }
752
Ihab Awad5d0410f2014-07-30 10:07:40 -0700753 /**
754 * Instructs this {@code RemoteConnection} to continue playing a post-dial DTMF string.
755 *
756 * A post-dial DTMF string is a string of digits following the first instance of either
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700757 * {@link TelecomManager#DTMF_CHARACTER_WAIT} or {@link TelecomManager#DTMF_CHARACTER_PAUSE}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700758 * These digits are immediately sent as DTMF tones to the recipient as soon as the
759 * connection is made.
760 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700761 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this
Ihab Awad5d0410f2014-07-30 10:07:40 -0700762 * {@code RemoteConnection} will temporarily pause playing the tones for a pre-defined period
763 * of time.
764 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700765 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800766 * {@code RemoteConnection} will pause playing the tones and notify callbacks via
Andrew Lee100e2932014-09-08 15:34:24 -0700767 * {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app
Ihab Awad5d0410f2014-07-30 10:07:40 -0700768 * should display to the user an indication of this state and an affordance to continue
769 * the postdial sequence. When the user decides to continue the postdial sequence, the in-call
770 * app should invoke the {@link #postDialContinue(boolean)} method.
771 *
772 * @param proceed Whether or not to continue with the post-dial sequence.
773 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700774 public void postDialContinue(boolean proceed) {
775 try {
776 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700777 mConnectionService.onPostDialContinue(mConnectionId, proceed);
Santos Cordon52d8a152014-06-17 19:08:45 -0700778 }
779 } catch (RemoteException ignored) {
780 }
781 }
782
Ihab Awad5d0410f2014-07-30 10:07:40 -0700783 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700784 * Set the audio state of this {@code RemoteConnection}.
785 *
786 * @param state The audio state of this {@code RemoteConnection}.
787 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700788 public void setAudioState(AudioState state) {
Sailesh Nepal091768c2014-06-30 15:15:23 -0700789 try {
790 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700791 mConnectionService.onAudioStateChanged(mConnectionId, state);
Sailesh Nepal091768c2014-06-30 15:15:23 -0700792 }
793 } catch (RemoteException ignored) {
794 }
795 }
796
Santos Cordon52d8a152014-06-17 19:08:45 -0700797 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700798 * Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be
799 * successfully asked to create a conference with.
800 *
801 * @return The {@code RemoteConnection}s with which this {@code RemoteConnection} may be
802 * merged into a {@link RemoteConference}.
803 */
804 public List<RemoteConnection> getConferenceableConnections() {
805 return mUnmodifiableconferenceableConnections;
806 }
807
808 /**
809 * Obtain the {@code RemoteConference} that this {@code RemoteConnection} may be a part
810 * of, or {@code null} if there is no such {@code RemoteConference}.
811 *
812 * @return A {@code RemoteConference} or {@code null};
813 */
814 public RemoteConference getConference() {
815 return mConference;
816 }
817
818 /** {@hide} */
819 String getId() {
820 return mConnectionId;
821 }
822
823 /** {@hide} */
824 IConnectionService getConnectionService() {
825 return mConnectionService;
826 }
827
828 /**
Santos Cordon52d8a152014-06-17 19:08:45 -0700829 * @hide
830 */
831 void setState(int state) {
832 if (mState != state) {
833 mState = state;
Andrew Lee100e2932014-09-08 15:34:24 -0700834 for (Callback c: mCallbacks) {
835 c.onStateChanged(this, state);
Santos Cordon52d8a152014-06-17 19:08:45 -0700836 }
837 }
838 }
839
840 /**
841 * @hide
842 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700843 void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700844 if (mState != Connection.STATE_DISCONNECTED) {
845 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700846 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700847
Andrew Lee100e2932014-09-08 15:34:24 -0700848 for (Callback c : mCallbacks) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700849 c.onDisconnected(this, mDisconnectCause);
Santos Cordon52d8a152014-06-17 19:08:45 -0700850 }
851 }
852 }
853
854 /**
855 * @hide
856 */
Andrew Lee100e2932014-09-08 15:34:24 -0700857 void setRingbackRequested(boolean ringback) {
858 if (mRingbackRequested != ringback) {
859 mRingbackRequested = ringback;
860 for (Callback c : mCallbacks) {
861 c.onRingbackRequested(this, ringback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700862 }
863 }
864 }
865
866 /**
867 * @hide
868 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800869 void setConnectionCapabilities(int connectionCapabilities) {
870 mConnectionCapabilities = connectionCapabilities;
Andrew Lee100e2932014-09-08 15:34:24 -0700871 for (Callback c : mCallbacks) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800872 c.onConnectionCapabilitiesChanged(this, connectionCapabilities);
873 c.onCallCapabilitiesChanged(this, connectionCapabilities);
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700874 }
875 }
876
877 /**
878 * @hide
879 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700880 void setDestroyed() {
Andrew Lee100e2932014-09-08 15:34:24 -0700881 if (!mCallbacks.isEmpty()) {
882 // Make sure that the callbacks are notified that the call is destroyed first.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700883 if (mState != Connection.STATE_DISCONNECTED) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700884 setDisconnected(
885 new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed."));
Santos Cordon52d8a152014-06-17 19:08:45 -0700886 }
887
Andrew Lee100e2932014-09-08 15:34:24 -0700888 for (Callback c : mCallbacks) {
889 c.onDestroyed(this);
Santos Cordon52d8a152014-06-17 19:08:45 -0700890 }
Andrew Lee100e2932014-09-08 15:34:24 -0700891 mCallbacks.clear();
Santos Cordon52d8a152014-06-17 19:08:45 -0700892
893 mConnected = false;
894 }
895 }
896
897 /**
898 * @hide
899 */
900 void setPostDialWait(String remainingDigits) {
Andrew Lee100e2932014-09-08 15:34:24 -0700901 for (Callback c : mCallbacks) {
902 c.onPostDialWait(this, remainingDigits);
Santos Cordon52d8a152014-06-17 19:08:45 -0700903 }
904 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700905
Tyler Gunnaa07df82014-07-17 07:50:22 -0700906 /**
907 * @hide
908 */
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800909 void onPostDialChar(char nextChar) {
910 for (Callback c : mCallbacks) {
911 c.onPostDialChar(this, nextChar);
912 }
913 }
914
915 /**
916 * @hide
917 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700918 void setVideoState(int videoState) {
919 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700920 for (Callback c : mCallbacks) {
921 c.onVideoStateChanged(this, videoState);
Tyler Gunnaa07df82014-07-17 07:50:22 -0700922 }
923 }
924
Ihab Awada64627c2014-08-20 09:36:40 -0700925 /**
926 * @hide
927 */
Rekha Kumar07366812015-03-24 16:42:31 -0700928 void setCallSubstate(int callSubstate) {
929 mCallSubstate = callSubstate;
930 for (Callback c : mCallbacks) {
931 c.onCallSubstateChanged(this, callSubstate);
932 }
933 }
934
935 /**
936 * @hide
937 */
Ihab Awada64627c2014-08-20 09:36:40 -0700938 void setVideoProvider(VideoProvider videoProvider) {
939 mVideoProvider = videoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700940 for (Callback c : mCallbacks) {
941 c.onVideoProviderChanged(this, videoProvider);
Ihab Awada64627c2014-08-20 09:36:40 -0700942 }
943 }
944
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700945 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700946 void setIsVoipAudioMode(boolean isVoip) {
947 mIsVoipAudioMode = isVoip;
948 for (Callback c : mCallbacks) {
949 c.onVoipAudioChanged(this, isVoip);
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700950 }
951 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700952
953 /** @hide */
954 void setStatusHints(StatusHints statusHints) {
955 mStatusHints = statusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700956 for (Callback c : mCallbacks) {
957 c.onStatusHintsChanged(this, statusHints);
Sailesh Nepal61203862014-07-11 14:50:13 -0700958 }
959 }
960
961 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700962 void setAddress(Uri address, int presentation) {
963 mAddress = address;
964 mAddressPresentation = presentation;
965 for (Callback c : mCallbacks) {
966 c.onAddressChanged(this, address, presentation);
Sailesh Nepal61203862014-07-11 14:50:13 -0700967 }
968 }
969
970 /** @hide */
971 void setCallerDisplayName(String callerDisplayName, int presentation) {
972 mCallerDisplayName = callerDisplayName;
973 mCallerDisplayNamePresentation = presentation;
Andrew Lee100e2932014-09-08 15:34:24 -0700974 for (Callback c : mCallbacks) {
975 c.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700976 }
977 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700978
979 /** @hide */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700980 void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) {
981 mConferenceableConnections.clear();
982 mConferenceableConnections.addAll(conferenceableConnections);
Andrew Lee100e2932014-09-08 15:34:24 -0700983 for (Callback c : mCallbacks) {
984 c.onConferenceableConnectionsChanged(this, mUnmodifiableconferenceableConnections);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700985 }
986 }
987
988 /** @hide */
989 void setConference(RemoteConference conference) {
990 if (mConference != conference) {
991 mConference = conference;
Andrew Lee100e2932014-09-08 15:34:24 -0700992 for (Callback c : mCallbacks) {
993 c.onConferenceChanged(this, conference);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700994 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700995 }
996 }
997
Evan Charltonbf11f982014-07-20 22:06:28 -0700998 /**
Ihab Awad6107bab2014-08-18 09:23:25 -0700999 * Create a RemoteConnection represents a failure, and which will be in
1000 * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
1001 * certainly result in bad things happening. Do not do this.
Evan Charltonbf11f982014-07-20 22:06:28 -07001002 *
1003 * @return a failed {@link RemoteConnection}
1004 *
1005 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -07001006 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001007 public static RemoteConnection failure(DisconnectCause disconnectCause) {
1008 return new RemoteConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07001009 }
Santos Cordon52d8a152014-06-17 19:08:45 -07001010}