blob: eec8076bfd406f37da482f6c3be706e4fe79e7b2 [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
Santos Cordon52d8a152014-06-17 19:08:45 -070023import android.net.Uri;
Ihab Awada64627c2014-08-20 09:36:40 -070024import android.os.IBinder;
Santos Cordon52d8a152014-06-17 19:08:45 -070025import android.os.RemoteException;
Ihab Awada64627c2014-08-20 09:36:40 -070026import android.view.Surface;
Santos Cordon52d8a152014-06-17 19:08:45 -070027
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070028import java.util.ArrayList;
Sailesh Nepalf4669df2014-08-14 17:43:13 -070029import java.util.Collections;
Ihab Awad5d0410f2014-07-30 10:07:40 -070030import java.util.List;
Santos Cordon52d8a152014-06-17 19:08:45 -070031import java.util.Set;
Sailesh Nepalf4669df2014-08-14 17:43:13 -070032import java.util.concurrent.ConcurrentHashMap;
Santos Cordon52d8a152014-06-17 19:08:45 -070033
34/**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070035 * A connection provided to a {@link ConnectionService} by another {@code ConnectionService}
36 * running in a different process.
37 *
38 * @see ConnectionService#createRemoteOutgoingConnection(PhoneAccountHandle, ConnectionRequest)
39 * @see ConnectionService#createRemoteIncomingConnection(PhoneAccountHandle, ConnectionRequest)
Santos Cordon52d8a152014-06-17 19:08:45 -070040 */
41public final class RemoteConnection {
Ihab Awad5d0410f2014-07-30 10:07:40 -070042
Andrew Lee100e2932014-09-08 15:34:24 -070043 public static abstract class Callback {
Ihab Awad5d0410f2014-07-30 10:07:40 -070044 /**
45 * Invoked when the state of this {@code RemoteConnection} has changed. See
46 * {@link #getState()}.
47 *
48 * @param connection The {@code RemoteConnection} invoking this method.
49 * @param state The new state of the {@code RemoteConnection}.
50 */
Evan Charltonbf11f982014-07-20 22:06:28 -070051 public void onStateChanged(RemoteConnection connection, int state) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -070052
53 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -070054 * Invoked when this {@code RemoteConnection} is disconnected.
55 *
56 * @param connection The {@code RemoteConnection} invoking this method.
Andrew Lee7f3d41f2014-09-11 17:33:16 -070057 * @param disconnectCause The ({@see DisconnectCause}) associated with this failed
58 * connection.
Ihab Awad5d0410f2014-07-30 10:07:40 -070059 */
60 public void onDisconnected(
61 RemoteConnection connection,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070062 DisconnectCause disconnectCause) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -070063
64 /**
65 * Invoked when this {@code RemoteConnection} is requesting ringback. See
Andrew Lee100e2932014-09-08 15:34:24 -070066 * {@link #isRingbackRequested()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -070067 *
68 * @param connection The {@code RemoteConnection} invoking this method.
69 * @param ringback Whether the {@code RemoteConnection} is requesting ringback.
70 */
Andrew Lee100e2932014-09-08 15:34:24 -070071 public void onRingbackRequested(RemoteConnection connection, boolean ringback) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -070072
73 /**
74 * Indicates that the call capabilities of this {@code RemoteConnection} have changed.
Ihab Awad5c9c86e2014-11-12 13:41:16 -080075 * See {@link #getConnectionCapabilities()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -070076 *
77 * @param connection The {@code RemoteConnection} invoking this method.
Ihab Awad5c9c86e2014-11-12 13:41:16 -080078 * @param connectionCapabilities The new capabilities of the {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -070079 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -080080 public void onConnectionCapabilitiesChanged(
81 RemoteConnection connection,
82 int connectionCapabilities) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -070083
84 /**
85 * Invoked when the post-dial sequence in the outgoing {@code Connection} has reached a
86 * pause character. This causes the post-dial signals to stop pending user confirmation. An
87 * implementation should present this choice to the user and invoke
Ihab Awadb19a0bc2014-08-07 19:46:01 -070088 * {@link RemoteConnection#postDialContinue(boolean)} when the user makes the choice.
Ihab Awad5d0410f2014-07-30 10:07:40 -070089 *
90 * @param connection The {@code RemoteConnection} invoking this method.
91 * @param remainingPostDialSequence The post-dial characters that remain to be sent.
92 */
93 public void onPostDialWait(RemoteConnection connection, String remainingPostDialSequence) {}
94
95 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -080096 * Invoked when the post-dial sequence in the outgoing {@code Connection} has processed
97 * a character.
98 *
99 * @param connection The {@code RemoteConnection} invoking this method.
100 * @param nextChar The character being processed.
101 */
102 public void onPostDialChar(RemoteConnection connection, char nextChar) {}
103
104 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700105 * Indicates that the VOIP audio status of this {@code RemoteConnection} has changed.
Andrew Lee100e2932014-09-08 15:34:24 -0700106 * See {@link #isVoipAudioMode()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700107 *
108 * @param connection The {@code RemoteConnection} invoking this method.
109 * @param isVoip Whether the new audio state of the {@code RemoteConnection} is VOIP.
110 */
Andrew Lee100e2932014-09-08 15:34:24 -0700111 public void onVoipAudioChanged(RemoteConnection connection, boolean isVoip) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700112
113 /**
114 * Indicates that the status hints of this {@code RemoteConnection} have changed. See
115 * {@link #getStatusHints()} ()}.
116 *
117 * @param connection The {@code RemoteConnection} invoking this method.
118 * @param statusHints The new status hints of the {@code RemoteConnection}.
119 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700120 public void onStatusHintsChanged(RemoteConnection connection, StatusHints statusHints) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700121
122 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700123 * Indicates that the address (e.g., phone number) of this {@code RemoteConnection} has
124 * changed. See {@link #getAddress()} and {@link #getAddressPresentation()}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700125 *
126 * @param connection The {@code RemoteConnection} invoking this method.
Andrew Lee100e2932014-09-08 15:34:24 -0700127 * @param address The new address of the {@code RemoteConnection}.
128 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700129 * See {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700130 */
Andrew Lee100e2932014-09-08 15:34:24 -0700131 public void onAddressChanged(RemoteConnection connection, Uri address, int presentation) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700132
133 /**
134 * Indicates that the caller display name of this {@code RemoteConnection} has changed.
135 * See {@link #getCallerDisplayName()} and {@link #getCallerDisplayNamePresentation()}.
136 *
137 * @param connection The {@code RemoteConnection} invoking this method.
138 * @param callerDisplayName The new caller display name of the {@code RemoteConnection}.
Nancy Chen9d568c02014-09-08 14:17:59 -0700139 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700140 * See {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700141 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700142 public void onCallerDisplayNameChanged(
143 RemoteConnection connection, String callerDisplayName, int presentation) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700144
145 /**
146 * Indicates that the video state of this {@code RemoteConnection} has changed.
147 * See {@link #getVideoState()}.
148 *
149 * @param connection The {@code RemoteConnection} invoking this method.
150 * @param videoState The new video state of the {@code RemoteConnection}.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700151 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700152 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700153 public void onVideoStateChanged(RemoteConnection connection, int videoState) {}
Ihab Awad5d0410f2014-07-30 10:07:40 -0700154
155 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700156 * Indicates that the call substate of this {@code RemoteConnection} has changed.
157 * See {@link #getCallSubstate()}.
158 *
159 * @param connection The {@code RemoteConnection} invoking this method.
160 * @param callSubstate The new call substate of the {@code RemoteConnection}.
161 * @hide
162 */
163 public void onCallSubstateChanged(RemoteConnection connection, int callSubstate) {}
164
165 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700166 * Indicates that this {@code RemoteConnection} has been destroyed. No further requests
167 * should be made to the {@code RemoteConnection}, and references to it should be cleared.
168 *
169 * @param connection The {@code RemoteConnection} invoking this method.
170 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700171 public void onDestroyed(RemoteConnection connection) {}
Ihab Awadb8e85c72014-08-23 20:34:57 -0700172
173 /**
174 * Indicates that the {@code RemoteConnection}s with which this {@code RemoteConnection}
175 * may be asked to create a conference has changed.
176 *
177 * @param connection The {@code RemoteConnection} invoking this method.
178 * @param conferenceableConnections The {@code RemoteConnection}s with which this
179 * {@code RemoteConnection} may be asked to create a conference.
180 */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700181 public void onConferenceableConnectionsChanged(
Ihab Awadb8e85c72014-08-23 20:34:57 -0700182 RemoteConnection connection,
183 List<RemoteConnection> conferenceableConnections) {}
184
185 /**
Ihab Awada64627c2014-08-20 09:36:40 -0700186 * Indicates that the {@code VideoProvider} associated with this {@code RemoteConnection}
187 * has changed.
188 *
189 * @param connection The {@code RemoteConnection} invoking this method.
190 * @param videoProvider The new {@code VideoProvider} associated with this
191 * {@code RemoteConnection}.
192 * @hide
193 */
194 public void onVideoProviderChanged(
195 RemoteConnection connection, VideoProvider videoProvider) {}
196
197 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700198 * Indicates that the {@code RemoteConference} that this {@code RemoteConnection} is a part
199 * of has changed.
200 *
201 * @param connection The {@code RemoteConnection} invoking this method.
202 * @param conference The {@code RemoteConference} of which this {@code RemoteConnection} is
203 * a part, which may be {@code null}.
204 */
205 public void onConferenceChanged(
206 RemoteConnection connection,
207 RemoteConference conference) {}
Santos Cordon52d8a152014-06-17 19:08:45 -0700208 }
209
Ihab Awada64627c2014-08-20 09:36:40 -0700210 /** {@hide} */
211 public static class VideoProvider {
212
213 public abstract static class Listener {
214 public void onReceiveSessionModifyRequest(
215 VideoProvider videoProvider,
216 VideoProfile videoProfile) {}
217
218 public void onReceiveSessionModifyResponse(
219 VideoProvider videoProvider,
220 int status,
221 VideoProfile requestedProfile,
222 VideoProfile responseProfile) {}
223
224 public void onHandleCallSessionEvent(VideoProvider videoProvider, int event) {}
225
226 public void onPeerDimensionsChanged(VideoProvider videoProvider, int width, int height) {}
227
Rekha Kumar07366812015-03-24 16:42:31 -0700228 public void onCallDataUsageChanged(VideoProvider videoProvider, long dataUsage) {}
Ihab Awada64627c2014-08-20 09:36:40 -0700229
230 public void onCameraCapabilitiesChanged(
231 VideoProvider videoProvider,
232 CameraCapabilities cameraCapabilities) {}
Rekha Kumar07366812015-03-24 16:42:31 -0700233
234 public void onVideoQualityChanged(VideoProvider videoProvider, int videoQuality) {}
Ihab Awada64627c2014-08-20 09:36:40 -0700235 }
236
237 private final IVideoCallback mVideoCallbackDelegate = new IVideoCallback() {
238 @Override
239 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
240 for (Listener l : mListeners) {
241 l.onReceiveSessionModifyRequest(VideoProvider.this, videoProfile);
242 }
243 }
244
245 @Override
246 public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile,
247 VideoProfile responseProfile) {
248 for (Listener l : mListeners) {
249 l.onReceiveSessionModifyResponse(
250 VideoProvider.this,
251 status,
252 requestedProfile,
253 responseProfile);
254 }
255 }
256
257 @Override
258 public void handleCallSessionEvent(int event) {
259 for (Listener l : mListeners) {
260 l.onHandleCallSessionEvent(VideoProvider.this, event);
261 }
262 }
263
264 @Override
265 public void changePeerDimensions(int width, int height) {
266 for (Listener l : mListeners) {
267 l.onPeerDimensionsChanged(VideoProvider.this, width, height);
268 }
269 }
270
271 @Override
Rekha Kumar07366812015-03-24 16:42:31 -0700272 public void changeCallDataUsage(long dataUsage) {
Ihab Awada64627c2014-08-20 09:36:40 -0700273 for (Listener l : mListeners) {
274 l.onCallDataUsageChanged(VideoProvider.this, dataUsage);
275 }
276 }
277
278 @Override
279 public void changeCameraCapabilities(CameraCapabilities cameraCapabilities) {
280 for (Listener l : mListeners) {
281 l.onCameraCapabilitiesChanged(VideoProvider.this, cameraCapabilities);
282 }
283 }
284
285 @Override
Rekha Kumar07366812015-03-24 16:42:31 -0700286 public void changeVideoQuality(int videoQuality) {
287 for (Listener l : mListeners) {
288 l.onVideoQualityChanged(VideoProvider.this, videoQuality);
289 }
290 }
291
292 @Override
Ihab Awada64627c2014-08-20 09:36:40 -0700293 public IBinder asBinder() {
294 return null;
295 }
296 };
297
298 private final VideoCallbackServant mVideoCallbackServant =
299 new VideoCallbackServant(mVideoCallbackDelegate);
300
301 private final IVideoProvider mVideoProviderBinder;
302
303 /**
304 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
305 * load factor before resizing, 1 means we only expect a single thread to
306 * access the map so make only a single shard
307 */
308 private final Set<Listener> mListeners = Collections.newSetFromMap(
309 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
310
311 public VideoProvider(IVideoProvider videoProviderBinder) {
312 mVideoProviderBinder = videoProviderBinder;
313 try {
Tyler Gunn75958422015-04-15 14:23:42 -0700314 mVideoProviderBinder.addVideoCallback(mVideoCallbackServant.getStub().asBinder());
Ihab Awada64627c2014-08-20 09:36:40 -0700315 } catch (RemoteException e) {
316 }
317 }
318
319 public void addListener(Listener l) {
320 mListeners.add(l);
321 }
322
323 public void removeListener(Listener l) {
324 mListeners.remove(l);
325 }
326
327 public void setCamera(String cameraId) {
328 try {
329 mVideoProviderBinder.setCamera(cameraId);
330 } catch (RemoteException e) {
331 }
332 }
333
334 public void setPreviewSurface(Surface surface) {
335 try {
336 mVideoProviderBinder.setPreviewSurface(surface);
337 } catch (RemoteException e) {
338 }
339 }
340
341 public void setDisplaySurface(Surface surface) {
342 try {
343 mVideoProviderBinder.setDisplaySurface(surface);
344 } catch (RemoteException e) {
345 }
346 }
347
348 public void setDeviceOrientation(int rotation) {
349 try {
350 mVideoProviderBinder.setDeviceOrientation(rotation);
351 } catch (RemoteException e) {
352 }
353 }
354
355 public void setZoom(float value) {
356 try {
357 mVideoProviderBinder.setZoom(value);
358 } catch (RemoteException e) {
359 }
360 }
361
362 public void sendSessionModifyRequest(VideoProfile reqProfile) {
363 try {
364 mVideoProviderBinder.sendSessionModifyRequest(reqProfile);
365 } catch (RemoteException e) {
366 }
367 }
368
369 public void sendSessionModifyResponse(VideoProfile responseProfile) {
370 try {
371 mVideoProviderBinder.sendSessionModifyResponse(responseProfile);
372 } catch (RemoteException e) {
373 }
374 }
375
376 public void requestCameraCapabilities() {
377 try {
378 mVideoProviderBinder.requestCameraCapabilities();
379 } catch (RemoteException e) {
380 }
381 }
382
383 public void requestCallDataUsage() {
384 try {
385 mVideoProviderBinder.requestCallDataUsage();
386 } catch (RemoteException e) {
387 }
388 }
389
390 public void setPauseImage(String uri) {
391 try {
392 mVideoProviderBinder.setPauseImage(uri);
393 } catch (RemoteException e) {
394 }
395 }
396 }
397
Evan Charltonbf11f982014-07-20 22:06:28 -0700398 private IConnectionService mConnectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700399 private final String mConnectionId;
Jay Shrauner229e3822014-08-15 09:23:07 -0700400 /**
401 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
402 * load factor before resizing, 1 means we only expect a single thread to
403 * access the map so make only a single shard
404 */
Andrew Lee100e2932014-09-08 15:34:24 -0700405 private final Set<Callback> mCallbacks = Collections.newSetFromMap(
406 new ConcurrentHashMap<Callback, Boolean>(8, 0.9f, 1));
Ihab Awadb8e85c72014-08-23 20:34:57 -0700407 private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>();
408 private final List<RemoteConnection> mUnmodifiableconferenceableConnections =
409 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon52d8a152014-06-17 19:08:45 -0700410
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700411 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700412 private DisconnectCause mDisconnectCause;
Andrew Lee100e2932014-09-08 15:34:24 -0700413 private boolean mRingbackRequested;
Santos Cordon52d8a152014-06-17 19:08:45 -0700414 private boolean mConnected;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800415 private int mConnectionCapabilities;
Tyler Gunnaa07df82014-07-17 07:50:22 -0700416 private int mVideoState;
Rekha Kumar07366812015-03-24 16:42:31 -0700417 private int mCallSubstate;
Ihab Awada64627c2014-08-20 09:36:40 -0700418 private VideoProvider mVideoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700419 private boolean mIsVoipAudioMode;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700420 private StatusHints mStatusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700421 private Uri mAddress;
422 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700423 private String mCallerDisplayName;
424 private int mCallerDisplayNamePresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -0700425 private RemoteConference mConference;
Santos Cordon52d8a152014-06-17 19:08:45 -0700426
427 /**
428 * @hide
429 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700430 RemoteConnection(
431 String id,
432 IConnectionService connectionService,
433 ConnectionRequest request) {
434 mConnectionId = id;
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700435 mConnectionService = connectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700436 mConnected = true;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700437 mState = Connection.STATE_INITIALIZING;
Evan Charltonbf11f982014-07-20 22:06:28 -0700438 }
439
440 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700441 * @hide
442 */
443 RemoteConnection(String callId, IConnectionService connectionService,
444 ParcelableConnection connection) {
445 mConnectionId = callId;
446 mConnectionService = connectionService;
447 mConnected = true;
448 mState = connection.getState();
449 mDisconnectCause = connection.getDisconnectCause();
450 mRingbackRequested = connection.isRingbackRequested();
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800451 mConnectionCapabilities = connection.getConnectionCapabilities();
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700452 mVideoState = connection.getVideoState();
453 mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider());
454 mIsVoipAudioMode = connection.getIsVoipAudioMode();
455 mStatusHints = connection.getStatusHints();
456 mAddress = connection.getHandle();
457 mAddressPresentation = connection.getHandlePresentation();
458 mCallerDisplayName = connection.getCallerDisplayName();
459 mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
460 mConference = null;
461 }
462
463 /**
Evan Charltonbf11f982014-07-20 22:06:28 -0700464 * Create a RemoteConnection which is used for failed connections. Note that using it for any
465 * "real" purpose will almost certainly fail. Callers should note the failure and act
466 * accordingly (moving on to another RemoteConnection, for example)
467 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700468 * @param disconnectCause The reason for the failed connection.
469 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700470 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700471 RemoteConnection(DisconnectCause disconnectCause) {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700472 mConnectionId = "NULL";
Evan Charltonbf11f982014-07-20 22:06:28 -0700473 mConnected = false;
Ihab Awad6107bab2014-08-18 09:23:25 -0700474 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700475 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700476 }
477
Ihab Awad5d0410f2014-07-30 10:07:40 -0700478 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700479 * Adds a callback to this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700480 *
Andrew Lee100e2932014-09-08 15:34:24 -0700481 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700482 */
Andrew Lee100e2932014-09-08 15:34:24 -0700483 public void registerCallback(Callback callback) {
484 mCallbacks.add(callback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700485 }
486
Ihab Awad5d0410f2014-07-30 10:07:40 -0700487 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700488 * Removes a callback from this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700489 *
Andrew Lee100e2932014-09-08 15:34:24 -0700490 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700491 */
Andrew Lee100e2932014-09-08 15:34:24 -0700492 public void unregisterCallback(Callback callback) {
493 if (callback != null) {
494 mCallbacks.remove(callback);
Jay Shrauner229e3822014-08-15 09:23:07 -0700495 }
Santos Cordon52d8a152014-06-17 19:08:45 -0700496 }
497
Ihab Awad5d0410f2014-07-30 10:07:40 -0700498 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700499 * Obtains the state of this {@code RemoteConnection}.
500 *
501 * @return A state value, chosen from the {@code STATE_*} constants.
502 */
Sailesh Nepalade3f252014-07-01 17:25:37 -0700503 public int getState() {
504 return mState;
505 }
506
Ihab Awad5d0410f2014-07-30 10:07:40 -0700507 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800508 * Obtains the reason why this {@code RemoteConnection} may have been disconnected.
509 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700510 * @return For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800511 * disconnect cause expressed as a code chosen from among those declared in
512 * {@link DisconnectCause}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700513 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700514 public DisconnectCause getDisconnectCause() {
515 return mDisconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700516 }
517
Ihab Awad5d0410f2014-07-30 10:07:40 -0700518 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800519 * Obtains the capabilities of this {@code RemoteConnection}.
520 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700521 * @return A bitmask of the capabilities of the {@code RemoteConnection}, as defined in
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800522 * the {@code CAPABILITY_*} constants in class {@link Connection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700523 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800524 public int getConnectionCapabilities() {
525 return mConnectionCapabilities;
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700526 }
527
Ihab Awad5d0410f2014-07-30 10:07:40 -0700528 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800529 * Determines if the audio mode of this {@code RemoteConnection} is VOIP.
530 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700531 * @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP.
532 */
Andrew Lee100e2932014-09-08 15:34:24 -0700533 public boolean isVoipAudioMode() {
534 return mIsVoipAudioMode;
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700535 }
536
Ihab Awad5d0410f2014-07-30 10:07:40 -0700537 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800538 * Obtains status hints pertaining to this {@code RemoteConnection}.
539 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700540 * @return The current {@link StatusHints} of this {@code RemoteConnection},
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800541 * or {@code null} if none have been set.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700542 */
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700543 public StatusHints getStatusHints() {
544 return mStatusHints;
545 }
546
Ihab Awad5d0410f2014-07-30 10:07:40 -0700547 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800548 * Obtains the address of this {@code RemoteConnection}.
549 *
550 * @return The address (e.g., phone number) to which the {@code RemoteConnection}
551 * is currently connected.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700552 */
Andrew Lee100e2932014-09-08 15:34:24 -0700553 public Uri getAddress() {
554 return mAddress;
Sailesh Nepal61203862014-07-11 14:50:13 -0700555 }
556
Ihab Awad5d0410f2014-07-30 10:07:40 -0700557 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800558 * Obtains the presentation requirements for the address of this {@code RemoteConnection}.
559 *
560 * @return The presentation requirements for the address. See
561 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700562 */
Andrew Lee100e2932014-09-08 15:34:24 -0700563 public int getAddressPresentation() {
564 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700565 }
566
Ihab Awad5d0410f2014-07-30 10:07:40 -0700567 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800568 * Obtains the display name for this {@code RemoteConnection}'s caller.
569 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700570 * @return The display name for the caller.
571 */
Andrew Lee100e2932014-09-08 15:34:24 -0700572 public CharSequence getCallerDisplayName() {
Sailesh Nepal61203862014-07-11 14:50:13 -0700573 return mCallerDisplayName;
574 }
575
Ihab Awad5d0410f2014-07-30 10:07:40 -0700576 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800577 * Obtains the presentation requirements for this {@code RemoteConnection}'s
578 * caller's display name.
579 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700580 * @return The presentation requirements for the caller display name. See
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800581 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700582 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700583 public int getCallerDisplayNamePresentation() {
584 return mCallerDisplayNamePresentation;
585 }
586
Ihab Awad5d0410f2014-07-30 10:07:40 -0700587 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800588 * Obtains the video state of this {@code RemoteConnection}.
589 *
590 * @return The video state of the {@code RemoteConnection}. See {@link VideoProfile.VideoState}.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700591 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700592 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700593 public int getVideoState() {
594 return mVideoState;
595 }
596
Ihab Awad5d0410f2014-07-30 10:07:40 -0700597 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800598 *
Rekha Kumar07366812015-03-24 16:42:31 -0700599 * @return The call substate of the {@code RemoteConnection}. See
600 * @hide
601 */
602 public int getCallSubstate() {
603 return mCallSubstate;
604 }
605
606 /**
607 * Obtains the video provider of this {@code RemoteConnection}.
Ihab Awada64627c2014-08-20 09:36:40 -0700608 * @return The video provider associated with this {@code RemoteConnection}.
609 * @hide
610 */
611 public final VideoProvider getVideoProvider() {
612 return mVideoProvider;
613 }
614
615 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800616 * Determines whether this {@code RemoteConnection} is requesting ringback.
617 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700618 * @return Whether the {@code RemoteConnection} is requesting that the framework play a
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800619 * ringback tone on its behalf.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700620 */
Andrew Lee100e2932014-09-08 15:34:24 -0700621 public boolean isRingbackRequested() {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700622 return false;
623 }
624
625 /**
626 * Instructs this {@code RemoteConnection} to abort.
627 */
Sailesh Nepal091768c2014-06-30 15:15:23 -0700628 public void abort() {
629 try {
630 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700631 mConnectionService.abort(mConnectionId);
Sailesh Nepal091768c2014-06-30 15:15:23 -0700632 }
633 } catch (RemoteException ignored) {
634 }
635 }
636
Ihab Awad5d0410f2014-07-30 10:07:40 -0700637 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700638 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
Tyler Gunnbe74de02014-08-29 14:51:48 -0700639 */
640 public void answer() {
641 try {
642 if (mConnected) {
643 mConnectionService.answer(mConnectionId);
644 }
645 } catch (RemoteException ignored) {
646 }
647 }
648
649 /**
650 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700651 * @param videoState The video state in which to answer the call.
Tyler Gunnbe74de02014-08-29 14:51:48 -0700652 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700653 */
Andrew Lee8da4c3c2014-07-16 10:11:42 -0700654 public void answer(int videoState) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700655 try {
656 if (mConnected) {
Tyler Gunnbe74de02014-08-29 14:51:48 -0700657 mConnectionService.answerVideo(mConnectionId, videoState);
Santos Cordon52d8a152014-06-17 19:08:45 -0700658 }
659 } catch (RemoteException ignored) {
660 }
661 }
662
Ihab Awad5d0410f2014-07-30 10:07:40 -0700663 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700664 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to reject.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700665 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700666 public void reject() {
667 try {
668 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700669 mConnectionService.reject(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700670 }
671 } catch (RemoteException ignored) {
672 }
673 }
674
Ihab Awad5d0410f2014-07-30 10:07:40 -0700675 /**
676 * Instructs this {@code RemoteConnection} to go on hold.
677 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700678 public void hold() {
679 try {
680 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700681 mConnectionService.hold(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700682 }
683 } catch (RemoteException ignored) {
684 }
685 }
686
Ihab Awad5d0410f2014-07-30 10:07:40 -0700687 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700688 * Instructs this {@link Connection#STATE_HOLDING} call to release from hold.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700689 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700690 public void unhold() {
691 try {
692 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700693 mConnectionService.unhold(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700694 }
695 } catch (RemoteException ignored) {
696 }
697 }
698
Ihab Awad5d0410f2014-07-30 10:07:40 -0700699 /**
700 * Instructs this {@code RemoteConnection} to disconnect.
701 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700702 public void disconnect() {
703 try {
704 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700705 mConnectionService.disconnect(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700706 }
707 } catch (RemoteException ignored) {
708 }
709 }
710
Ihab Awad5d0410f2014-07-30 10:07:40 -0700711 /**
712 * Instructs this {@code RemoteConnection} to play a dual-tone multi-frequency signaling
713 * (DTMF) tone.
714 *
715 * Any other currently playing DTMF tone in the specified call is immediately stopped.
716 *
717 * @param digit A character representing the DTMF digit for which to play the tone. This
718 * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.
719 */
720 public void playDtmfTone(char digit) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700721 try {
722 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700723 mConnectionService.playDtmfTone(mConnectionId, digit);
Santos Cordon52d8a152014-06-17 19:08:45 -0700724 }
725 } catch (RemoteException ignored) {
726 }
727 }
728
Ihab Awad5d0410f2014-07-30 10:07:40 -0700729 /**
730 * Instructs this {@code RemoteConnection} to stop any dual-tone multi-frequency signaling
731 * (DTMF) tone currently playing.
732 *
733 * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is
734 * currently playing, this method will do nothing.
735 */
736 public void stopDtmfTone() {
Santos Cordon52d8a152014-06-17 19:08:45 -0700737 try {
738 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700739 mConnectionService.stopDtmfTone(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700740 }
741 } catch (RemoteException ignored) {
742 }
743 }
744
Ihab Awad5d0410f2014-07-30 10:07:40 -0700745 /**
746 * Instructs this {@code RemoteConnection} to continue playing a post-dial DTMF string.
747 *
748 * A post-dial DTMF string is a string of digits following the first instance of either
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700749 * {@link TelecomManager#DTMF_CHARACTER_WAIT} or {@link TelecomManager#DTMF_CHARACTER_PAUSE}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700750 * These digits are immediately sent as DTMF tones to the recipient as soon as the
751 * connection is made.
752 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700753 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this
Ihab Awad5d0410f2014-07-30 10:07:40 -0700754 * {@code RemoteConnection} will temporarily pause playing the tones for a pre-defined period
755 * of time.
756 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700757 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800758 * {@code RemoteConnection} will pause playing the tones and notify callbacks via
Andrew Lee100e2932014-09-08 15:34:24 -0700759 * {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app
Ihab Awad5d0410f2014-07-30 10:07:40 -0700760 * should display to the user an indication of this state and an affordance to continue
761 * the postdial sequence. When the user decides to continue the postdial sequence, the in-call
762 * app should invoke the {@link #postDialContinue(boolean)} method.
763 *
764 * @param proceed Whether or not to continue with the post-dial sequence.
765 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700766 public void postDialContinue(boolean proceed) {
767 try {
768 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700769 mConnectionService.onPostDialContinue(mConnectionId, proceed);
Santos Cordon52d8a152014-06-17 19:08:45 -0700770 }
771 } catch (RemoteException ignored) {
772 }
773 }
774
Ihab Awad5d0410f2014-07-30 10:07:40 -0700775 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700776 * Set the audio state of this {@code RemoteConnection}.
777 *
778 * @param state The audio state of this {@code RemoteConnection}.
779 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700780 public void setAudioState(AudioState state) {
Sailesh Nepal091768c2014-06-30 15:15:23 -0700781 try {
782 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700783 mConnectionService.onAudioStateChanged(mConnectionId, state);
Sailesh Nepal091768c2014-06-30 15:15:23 -0700784 }
785 } catch (RemoteException ignored) {
786 }
787 }
788
Santos Cordon52d8a152014-06-17 19:08:45 -0700789 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700790 * Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be
791 * successfully asked to create a conference with.
792 *
793 * @return The {@code RemoteConnection}s with which this {@code RemoteConnection} may be
794 * merged into a {@link RemoteConference}.
795 */
796 public List<RemoteConnection> getConferenceableConnections() {
797 return mUnmodifiableconferenceableConnections;
798 }
799
800 /**
801 * Obtain the {@code RemoteConference} that this {@code RemoteConnection} may be a part
802 * of, or {@code null} if there is no such {@code RemoteConference}.
803 *
804 * @return A {@code RemoteConference} or {@code null};
805 */
806 public RemoteConference getConference() {
807 return mConference;
808 }
809
810 /** {@hide} */
811 String getId() {
812 return mConnectionId;
813 }
814
815 /** {@hide} */
816 IConnectionService getConnectionService() {
817 return mConnectionService;
818 }
819
820 /**
Santos Cordon52d8a152014-06-17 19:08:45 -0700821 * @hide
822 */
823 void setState(int state) {
824 if (mState != state) {
825 mState = state;
Andrew Lee100e2932014-09-08 15:34:24 -0700826 for (Callback c: mCallbacks) {
827 c.onStateChanged(this, state);
Santos Cordon52d8a152014-06-17 19:08:45 -0700828 }
829 }
830 }
831
832 /**
833 * @hide
834 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700835 void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700836 if (mState != Connection.STATE_DISCONNECTED) {
837 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700838 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700839
Andrew Lee100e2932014-09-08 15:34:24 -0700840 for (Callback c : mCallbacks) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700841 c.onDisconnected(this, mDisconnectCause);
Santos Cordon52d8a152014-06-17 19:08:45 -0700842 }
843 }
844 }
845
846 /**
847 * @hide
848 */
Andrew Lee100e2932014-09-08 15:34:24 -0700849 void setRingbackRequested(boolean ringback) {
850 if (mRingbackRequested != ringback) {
851 mRingbackRequested = ringback;
852 for (Callback c : mCallbacks) {
853 c.onRingbackRequested(this, ringback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700854 }
855 }
856 }
857
858 /**
859 * @hide
860 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800861 void setConnectionCapabilities(int connectionCapabilities) {
862 mConnectionCapabilities = connectionCapabilities;
Andrew Lee100e2932014-09-08 15:34:24 -0700863 for (Callback c : mCallbacks) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800864 c.onConnectionCapabilitiesChanged(this, connectionCapabilities);
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700865 }
866 }
867
868 /**
869 * @hide
870 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700871 void setDestroyed() {
Andrew Lee100e2932014-09-08 15:34:24 -0700872 if (!mCallbacks.isEmpty()) {
873 // Make sure that the callbacks are notified that the call is destroyed first.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700874 if (mState != Connection.STATE_DISCONNECTED) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700875 setDisconnected(
876 new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed."));
Santos Cordon52d8a152014-06-17 19:08:45 -0700877 }
878
Andrew Lee100e2932014-09-08 15:34:24 -0700879 for (Callback c : mCallbacks) {
880 c.onDestroyed(this);
Santos Cordon52d8a152014-06-17 19:08:45 -0700881 }
Andrew Lee100e2932014-09-08 15:34:24 -0700882 mCallbacks.clear();
Santos Cordon52d8a152014-06-17 19:08:45 -0700883
884 mConnected = false;
885 }
886 }
887
888 /**
889 * @hide
890 */
891 void setPostDialWait(String remainingDigits) {
Andrew Lee100e2932014-09-08 15:34:24 -0700892 for (Callback c : mCallbacks) {
893 c.onPostDialWait(this, remainingDigits);
Santos Cordon52d8a152014-06-17 19:08:45 -0700894 }
895 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700896
Tyler Gunnaa07df82014-07-17 07:50:22 -0700897 /**
898 * @hide
899 */
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800900 void onPostDialChar(char nextChar) {
901 for (Callback c : mCallbacks) {
902 c.onPostDialChar(this, nextChar);
903 }
904 }
905
906 /**
907 * @hide
908 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700909 void setVideoState(int videoState) {
910 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700911 for (Callback c : mCallbacks) {
912 c.onVideoStateChanged(this, videoState);
Tyler Gunnaa07df82014-07-17 07:50:22 -0700913 }
914 }
915
Ihab Awada64627c2014-08-20 09:36:40 -0700916 /**
917 * @hide
918 */
Rekha Kumar07366812015-03-24 16:42:31 -0700919 void setCallSubstate(int callSubstate) {
920 mCallSubstate = callSubstate;
921 for (Callback c : mCallbacks) {
922 c.onCallSubstateChanged(this, callSubstate);
923 }
924 }
925
926 /**
927 * @hide
928 */
Ihab Awada64627c2014-08-20 09:36:40 -0700929 void setVideoProvider(VideoProvider videoProvider) {
930 mVideoProvider = videoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700931 for (Callback c : mCallbacks) {
932 c.onVideoProviderChanged(this, videoProvider);
Ihab Awada64627c2014-08-20 09:36:40 -0700933 }
934 }
935
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700936 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700937 void setIsVoipAudioMode(boolean isVoip) {
938 mIsVoipAudioMode = isVoip;
939 for (Callback c : mCallbacks) {
940 c.onVoipAudioChanged(this, isVoip);
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700941 }
942 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700943
944 /** @hide */
945 void setStatusHints(StatusHints statusHints) {
946 mStatusHints = statusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700947 for (Callback c : mCallbacks) {
948 c.onStatusHintsChanged(this, statusHints);
Sailesh Nepal61203862014-07-11 14:50:13 -0700949 }
950 }
951
952 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700953 void setAddress(Uri address, int presentation) {
954 mAddress = address;
955 mAddressPresentation = presentation;
956 for (Callback c : mCallbacks) {
957 c.onAddressChanged(this, address, presentation);
Sailesh Nepal61203862014-07-11 14:50:13 -0700958 }
959 }
960
961 /** @hide */
962 void setCallerDisplayName(String callerDisplayName, int presentation) {
963 mCallerDisplayName = callerDisplayName;
964 mCallerDisplayNamePresentation = presentation;
Andrew Lee100e2932014-09-08 15:34:24 -0700965 for (Callback c : mCallbacks) {
966 c.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700967 }
968 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700969
970 /** @hide */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700971 void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) {
972 mConferenceableConnections.clear();
973 mConferenceableConnections.addAll(conferenceableConnections);
Andrew Lee100e2932014-09-08 15:34:24 -0700974 for (Callback c : mCallbacks) {
975 c.onConferenceableConnectionsChanged(this, mUnmodifiableconferenceableConnections);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700976 }
977 }
978
979 /** @hide */
980 void setConference(RemoteConference conference) {
981 if (mConference != conference) {
982 mConference = conference;
Andrew Lee100e2932014-09-08 15:34:24 -0700983 for (Callback c : mCallbacks) {
984 c.onConferenceChanged(this, conference);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700985 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700986 }
987 }
988
Evan Charltonbf11f982014-07-20 22:06:28 -0700989 /**
Ihab Awad6107bab2014-08-18 09:23:25 -0700990 * Create a RemoteConnection represents a failure, and which will be in
991 * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
992 * certainly result in bad things happening. Do not do this.
Evan Charltonbf11f982014-07-20 22:06:28 -0700993 *
994 * @return a failed {@link RemoteConnection}
995 *
996 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700997 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700998 public static RemoteConnection failure(DisconnectCause disconnectCause) {
999 return new RemoteConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07001000 }
Santos Cordon52d8a152014-06-17 19:08:45 -07001001}