blob: 4c423f208f123c2e9afcdf8e3e3c759c9d8d86a7 [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 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700156 * Indicates that this {@code RemoteConnection} has been destroyed. No further requests
157 * should be made to the {@code RemoteConnection}, and references to it should be cleared.
158 *
159 * @param connection The {@code RemoteConnection} invoking this method.
160 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700161 public void onDestroyed(RemoteConnection connection) {}
Ihab Awadb8e85c72014-08-23 20:34:57 -0700162
163 /**
164 * Indicates that the {@code RemoteConnection}s with which this {@code RemoteConnection}
165 * may be asked to create a conference has changed.
166 *
167 * @param connection The {@code RemoteConnection} invoking this method.
168 * @param conferenceableConnections The {@code RemoteConnection}s with which this
169 * {@code RemoteConnection} may be asked to create a conference.
170 */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700171 public void onConferenceableConnectionsChanged(
Ihab Awadb8e85c72014-08-23 20:34:57 -0700172 RemoteConnection connection,
173 List<RemoteConnection> conferenceableConnections) {}
174
175 /**
Ihab Awada64627c2014-08-20 09:36:40 -0700176 * Indicates that the {@code VideoProvider} associated with this {@code RemoteConnection}
177 * has changed.
178 *
179 * @param connection The {@code RemoteConnection} invoking this method.
180 * @param videoProvider The new {@code VideoProvider} associated with this
181 * {@code RemoteConnection}.
182 * @hide
183 */
184 public void onVideoProviderChanged(
185 RemoteConnection connection, VideoProvider videoProvider) {}
186
187 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700188 * Indicates that the {@code RemoteConference} that this {@code RemoteConnection} is a part
189 * of has changed.
190 *
191 * @param connection The {@code RemoteConnection} invoking this method.
192 * @param conference The {@code RemoteConference} of which this {@code RemoteConnection} is
193 * a part, which may be {@code null}.
194 */
195 public void onConferenceChanged(
196 RemoteConnection connection,
197 RemoteConference conference) {}
Santos Cordon52d8a152014-06-17 19:08:45 -0700198 }
199
Ihab Awada64627c2014-08-20 09:36:40 -0700200 /** {@hide} */
201 public static class VideoProvider {
202
203 public abstract static class Listener {
204 public void onReceiveSessionModifyRequest(
205 VideoProvider videoProvider,
206 VideoProfile videoProfile) {}
207
208 public void onReceiveSessionModifyResponse(
209 VideoProvider videoProvider,
210 int status,
211 VideoProfile requestedProfile,
212 VideoProfile responseProfile) {}
213
214 public void onHandleCallSessionEvent(VideoProvider videoProvider, int event) {}
215
216 public void onPeerDimensionsChanged(VideoProvider videoProvider, int width, int height) {}
217
Rekha Kumar07366812015-03-24 16:42:31 -0700218 public void onCallDataUsageChanged(VideoProvider videoProvider, long dataUsage) {}
Ihab Awada64627c2014-08-20 09:36:40 -0700219
220 public void onCameraCapabilitiesChanged(
221 VideoProvider videoProvider,
222 CameraCapabilities cameraCapabilities) {}
Rekha Kumar07366812015-03-24 16:42:31 -0700223
224 public void onVideoQualityChanged(VideoProvider videoProvider, int videoQuality) {}
Ihab Awada64627c2014-08-20 09:36:40 -0700225 }
226
227 private final IVideoCallback mVideoCallbackDelegate = new IVideoCallback() {
228 @Override
229 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
230 for (Listener l : mListeners) {
231 l.onReceiveSessionModifyRequest(VideoProvider.this, videoProfile);
232 }
233 }
234
235 @Override
236 public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile,
237 VideoProfile responseProfile) {
238 for (Listener l : mListeners) {
239 l.onReceiveSessionModifyResponse(
240 VideoProvider.this,
241 status,
242 requestedProfile,
243 responseProfile);
244 }
245 }
246
247 @Override
248 public void handleCallSessionEvent(int event) {
249 for (Listener l : mListeners) {
250 l.onHandleCallSessionEvent(VideoProvider.this, event);
251 }
252 }
253
254 @Override
255 public void changePeerDimensions(int width, int height) {
256 for (Listener l : mListeners) {
257 l.onPeerDimensionsChanged(VideoProvider.this, width, height);
258 }
259 }
260
261 @Override
Rekha Kumar07366812015-03-24 16:42:31 -0700262 public void changeCallDataUsage(long dataUsage) {
Ihab Awada64627c2014-08-20 09:36:40 -0700263 for (Listener l : mListeners) {
264 l.onCallDataUsageChanged(VideoProvider.this, dataUsage);
265 }
266 }
267
268 @Override
269 public void changeCameraCapabilities(CameraCapabilities cameraCapabilities) {
270 for (Listener l : mListeners) {
271 l.onCameraCapabilitiesChanged(VideoProvider.this, cameraCapabilities);
272 }
273 }
274
275 @Override
Rekha Kumar07366812015-03-24 16:42:31 -0700276 public void changeVideoQuality(int videoQuality) {
277 for (Listener l : mListeners) {
278 l.onVideoQualityChanged(VideoProvider.this, videoQuality);
279 }
280 }
281
282 @Override
Ihab Awada64627c2014-08-20 09:36:40 -0700283 public IBinder asBinder() {
284 return null;
285 }
286 };
287
288 private final VideoCallbackServant mVideoCallbackServant =
289 new VideoCallbackServant(mVideoCallbackDelegate);
290
291 private final IVideoProvider mVideoProviderBinder;
292
293 /**
294 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
295 * load factor before resizing, 1 means we only expect a single thread to
296 * access the map so make only a single shard
297 */
298 private final Set<Listener> mListeners = Collections.newSetFromMap(
299 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
300
301 public VideoProvider(IVideoProvider videoProviderBinder) {
302 mVideoProviderBinder = videoProviderBinder;
303 try {
304 mVideoProviderBinder.setVideoCallback(mVideoCallbackServant.getStub().asBinder());
305 } catch (RemoteException e) {
306 }
307 }
308
309 public void addListener(Listener l) {
310 mListeners.add(l);
311 }
312
313 public void removeListener(Listener l) {
314 mListeners.remove(l);
315 }
316
317 public void setCamera(String cameraId) {
318 try {
319 mVideoProviderBinder.setCamera(cameraId);
320 } catch (RemoteException e) {
321 }
322 }
323
324 public void setPreviewSurface(Surface surface) {
325 try {
326 mVideoProviderBinder.setPreviewSurface(surface);
327 } catch (RemoteException e) {
328 }
329 }
330
331 public void setDisplaySurface(Surface surface) {
332 try {
333 mVideoProviderBinder.setDisplaySurface(surface);
334 } catch (RemoteException e) {
335 }
336 }
337
338 public void setDeviceOrientation(int rotation) {
339 try {
340 mVideoProviderBinder.setDeviceOrientation(rotation);
341 } catch (RemoteException e) {
342 }
343 }
344
345 public void setZoom(float value) {
346 try {
347 mVideoProviderBinder.setZoom(value);
348 } catch (RemoteException e) {
349 }
350 }
351
352 public void sendSessionModifyRequest(VideoProfile reqProfile) {
353 try {
354 mVideoProviderBinder.sendSessionModifyRequest(reqProfile);
355 } catch (RemoteException e) {
356 }
357 }
358
359 public void sendSessionModifyResponse(VideoProfile responseProfile) {
360 try {
361 mVideoProviderBinder.sendSessionModifyResponse(responseProfile);
362 } catch (RemoteException e) {
363 }
364 }
365
366 public void requestCameraCapabilities() {
367 try {
368 mVideoProviderBinder.requestCameraCapabilities();
369 } catch (RemoteException e) {
370 }
371 }
372
373 public void requestCallDataUsage() {
374 try {
375 mVideoProviderBinder.requestCallDataUsage();
376 } catch (RemoteException e) {
377 }
378 }
379
380 public void setPauseImage(String uri) {
381 try {
382 mVideoProviderBinder.setPauseImage(uri);
383 } catch (RemoteException e) {
384 }
385 }
386 }
387
Evan Charltonbf11f982014-07-20 22:06:28 -0700388 private IConnectionService mConnectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700389 private final String mConnectionId;
Jay Shrauner229e3822014-08-15 09:23:07 -0700390 /**
391 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
392 * load factor before resizing, 1 means we only expect a single thread to
393 * access the map so make only a single shard
394 */
Andrew Lee100e2932014-09-08 15:34:24 -0700395 private final Set<Callback> mCallbacks = Collections.newSetFromMap(
396 new ConcurrentHashMap<Callback, Boolean>(8, 0.9f, 1));
Ihab Awadb8e85c72014-08-23 20:34:57 -0700397 private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>();
398 private final List<RemoteConnection> mUnmodifiableconferenceableConnections =
399 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon52d8a152014-06-17 19:08:45 -0700400
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700401 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700402 private DisconnectCause mDisconnectCause;
Andrew Lee100e2932014-09-08 15:34:24 -0700403 private boolean mRingbackRequested;
Santos Cordon52d8a152014-06-17 19:08:45 -0700404 private boolean mConnected;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800405 private int mConnectionCapabilities;
Tyler Gunnaa07df82014-07-17 07:50:22 -0700406 private int mVideoState;
Ihab Awada64627c2014-08-20 09:36:40 -0700407 private VideoProvider mVideoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700408 private boolean mIsVoipAudioMode;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700409 private StatusHints mStatusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700410 private Uri mAddress;
411 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700412 private String mCallerDisplayName;
413 private int mCallerDisplayNamePresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -0700414 private RemoteConference mConference;
Santos Cordon52d8a152014-06-17 19:08:45 -0700415
416 /**
417 * @hide
418 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700419 RemoteConnection(
420 String id,
421 IConnectionService connectionService,
422 ConnectionRequest request) {
423 mConnectionId = id;
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700424 mConnectionService = connectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700425 mConnected = true;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700426 mState = Connection.STATE_INITIALIZING;
Evan Charltonbf11f982014-07-20 22:06:28 -0700427 }
428
429 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700430 * @hide
431 */
432 RemoteConnection(String callId, IConnectionService connectionService,
433 ParcelableConnection connection) {
434 mConnectionId = callId;
435 mConnectionService = connectionService;
436 mConnected = true;
437 mState = connection.getState();
438 mDisconnectCause = connection.getDisconnectCause();
439 mRingbackRequested = connection.isRingbackRequested();
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800440 mConnectionCapabilities = connection.getConnectionCapabilities();
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700441 mVideoState = connection.getVideoState();
442 mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider());
443 mIsVoipAudioMode = connection.getIsVoipAudioMode();
444 mStatusHints = connection.getStatusHints();
445 mAddress = connection.getHandle();
446 mAddressPresentation = connection.getHandlePresentation();
447 mCallerDisplayName = connection.getCallerDisplayName();
448 mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
449 mConference = null;
450 }
451
452 /**
Evan Charltonbf11f982014-07-20 22:06:28 -0700453 * Create a RemoteConnection which is used for failed connections. Note that using it for any
454 * "real" purpose will almost certainly fail. Callers should note the failure and act
455 * accordingly (moving on to another RemoteConnection, for example)
456 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700457 * @param disconnectCause The reason for the failed connection.
458 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700459 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700460 RemoteConnection(DisconnectCause disconnectCause) {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700461 mConnectionId = "NULL";
Evan Charltonbf11f982014-07-20 22:06:28 -0700462 mConnected = false;
Ihab Awad6107bab2014-08-18 09:23:25 -0700463 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700464 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700465 }
466
Ihab Awad5d0410f2014-07-30 10:07:40 -0700467 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700468 * Adds a callback to this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700469 *
Andrew Lee100e2932014-09-08 15:34:24 -0700470 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700471 */
Andrew Lee100e2932014-09-08 15:34:24 -0700472 public void registerCallback(Callback callback) {
473 mCallbacks.add(callback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700474 }
475
Ihab Awad5d0410f2014-07-30 10:07:40 -0700476 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700477 * Removes a callback from this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700478 *
Andrew Lee100e2932014-09-08 15:34:24 -0700479 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700480 */
Andrew Lee100e2932014-09-08 15:34:24 -0700481 public void unregisterCallback(Callback callback) {
482 if (callback != null) {
483 mCallbacks.remove(callback);
Jay Shrauner229e3822014-08-15 09:23:07 -0700484 }
Santos Cordon52d8a152014-06-17 19:08:45 -0700485 }
486
Ihab Awad5d0410f2014-07-30 10:07:40 -0700487 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700488 * Obtains the state of this {@code RemoteConnection}.
489 *
490 * @return A state value, chosen from the {@code STATE_*} constants.
491 */
Sailesh Nepalade3f252014-07-01 17:25:37 -0700492 public int getState() {
493 return mState;
494 }
495
Ihab Awad5d0410f2014-07-30 10:07:40 -0700496 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800497 * Obtains the reason why this {@code RemoteConnection} may have been disconnected.
498 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700499 * @return For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800500 * disconnect cause expressed as a code chosen from among those declared in
501 * {@link DisconnectCause}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700502 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700503 public DisconnectCause getDisconnectCause() {
504 return mDisconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700505 }
506
Ihab Awad5d0410f2014-07-30 10:07:40 -0700507 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800508 * Obtains the capabilities of this {@code RemoteConnection}.
509 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700510 * @return A bitmask of the capabilities of the {@code RemoteConnection}, as defined in
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800511 * the {@code CAPABILITY_*} constants in class {@link Connection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700512 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800513 public int getConnectionCapabilities() {
514 return mConnectionCapabilities;
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700515 }
516
Ihab Awad5d0410f2014-07-30 10:07:40 -0700517 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800518 * Determines if the audio mode of this {@code RemoteConnection} is VOIP.
519 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700520 * @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP.
521 */
Andrew Lee100e2932014-09-08 15:34:24 -0700522 public boolean isVoipAudioMode() {
523 return mIsVoipAudioMode;
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700524 }
525
Ihab Awad5d0410f2014-07-30 10:07:40 -0700526 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800527 * Obtains status hints pertaining to this {@code RemoteConnection}.
528 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700529 * @return The current {@link StatusHints} of this {@code RemoteConnection},
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800530 * or {@code null} if none have been set.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700531 */
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700532 public StatusHints getStatusHints() {
533 return mStatusHints;
534 }
535
Ihab Awad5d0410f2014-07-30 10:07:40 -0700536 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800537 * Obtains the address of this {@code RemoteConnection}.
538 *
539 * @return The address (e.g., phone number) to which the {@code RemoteConnection}
540 * is currently connected.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700541 */
Andrew Lee100e2932014-09-08 15:34:24 -0700542 public Uri getAddress() {
543 return mAddress;
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 presentation requirements for the address of this {@code RemoteConnection}.
548 *
549 * @return The presentation requirements for the address. See
550 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700551 */
Andrew Lee100e2932014-09-08 15:34:24 -0700552 public int getAddressPresentation() {
553 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700554 }
555
Ihab Awad5d0410f2014-07-30 10:07:40 -0700556 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800557 * Obtains the display name for this {@code RemoteConnection}'s caller.
558 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700559 * @return The display name for the caller.
560 */
Andrew Lee100e2932014-09-08 15:34:24 -0700561 public CharSequence getCallerDisplayName() {
Sailesh Nepal61203862014-07-11 14:50:13 -0700562 return mCallerDisplayName;
563 }
564
Ihab Awad5d0410f2014-07-30 10:07:40 -0700565 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800566 * Obtains the presentation requirements for this {@code RemoteConnection}'s
567 * caller's display name.
568 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700569 * @return The presentation requirements for the caller display name. See
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800570 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700571 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700572 public int getCallerDisplayNamePresentation() {
573 return mCallerDisplayNamePresentation;
574 }
575
Ihab Awad5d0410f2014-07-30 10:07:40 -0700576 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800577 * Obtains the video state of this {@code RemoteConnection}.
578 *
579 * @return The video state of the {@code RemoteConnection}. See {@link VideoProfile.VideoState}.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700580 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700581 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700582 public int getVideoState() {
583 return mVideoState;
584 }
585
Ihab Awad5d0410f2014-07-30 10:07:40 -0700586 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700587 * Obtains the video provider of this {@code RemoteConnection}.
Ihab Awada64627c2014-08-20 09:36:40 -0700588 * @return The video provider associated with this {@code RemoteConnection}.
589 * @hide
590 */
591 public final VideoProvider getVideoProvider() {
592 return mVideoProvider;
593 }
594
595 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800596 * Determines whether this {@code RemoteConnection} is requesting ringback.
597 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700598 * @return Whether the {@code RemoteConnection} is requesting that the framework play a
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800599 * ringback tone on its behalf.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700600 */
Andrew Lee100e2932014-09-08 15:34:24 -0700601 public boolean isRingbackRequested() {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700602 return false;
603 }
604
605 /**
606 * Instructs this {@code RemoteConnection} to abort.
607 */
Sailesh Nepal091768c2014-06-30 15:15:23 -0700608 public void abort() {
609 try {
610 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700611 mConnectionService.abort(mConnectionId);
Sailesh Nepal091768c2014-06-30 15:15:23 -0700612 }
613 } catch (RemoteException ignored) {
614 }
615 }
616
Ihab Awad5d0410f2014-07-30 10:07:40 -0700617 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700618 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
Tyler Gunnbe74de02014-08-29 14:51:48 -0700619 */
620 public void answer() {
621 try {
622 if (mConnected) {
623 mConnectionService.answer(mConnectionId);
624 }
625 } catch (RemoteException ignored) {
626 }
627 }
628
629 /**
630 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700631 * @param videoState The video state in which to answer the call.
Tyler Gunnbe74de02014-08-29 14:51:48 -0700632 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700633 */
Andrew Lee8da4c3c2014-07-16 10:11:42 -0700634 public void answer(int videoState) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700635 try {
636 if (mConnected) {
Tyler Gunnbe74de02014-08-29 14:51:48 -0700637 mConnectionService.answerVideo(mConnectionId, videoState);
Santos Cordon52d8a152014-06-17 19:08:45 -0700638 }
639 } catch (RemoteException ignored) {
640 }
641 }
642
Ihab Awad5d0410f2014-07-30 10:07:40 -0700643 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700644 * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to reject.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700645 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700646 public void reject() {
647 try {
648 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700649 mConnectionService.reject(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700650 }
651 } catch (RemoteException ignored) {
652 }
653 }
654
Ihab Awad5d0410f2014-07-30 10:07:40 -0700655 /**
656 * Instructs this {@code RemoteConnection} to go on hold.
657 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700658 public void hold() {
659 try {
660 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700661 mConnectionService.hold(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700662 }
663 } catch (RemoteException ignored) {
664 }
665 }
666
Ihab Awad5d0410f2014-07-30 10:07:40 -0700667 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700668 * Instructs this {@link Connection#STATE_HOLDING} call to release from hold.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700669 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700670 public void unhold() {
671 try {
672 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700673 mConnectionService.unhold(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700674 }
675 } catch (RemoteException ignored) {
676 }
677 }
678
Ihab Awad5d0410f2014-07-30 10:07:40 -0700679 /**
680 * Instructs this {@code RemoteConnection} to disconnect.
681 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700682 public void disconnect() {
683 try {
684 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700685 mConnectionService.disconnect(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700686 }
687 } catch (RemoteException ignored) {
688 }
689 }
690
Ihab Awad5d0410f2014-07-30 10:07:40 -0700691 /**
692 * Instructs this {@code RemoteConnection} to play a dual-tone multi-frequency signaling
693 * (DTMF) tone.
694 *
695 * Any other currently playing DTMF tone in the specified call is immediately stopped.
696 *
697 * @param digit A character representing the DTMF digit for which to play the tone. This
698 * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.
699 */
700 public void playDtmfTone(char digit) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700701 try {
702 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700703 mConnectionService.playDtmfTone(mConnectionId, digit);
Santos Cordon52d8a152014-06-17 19:08:45 -0700704 }
705 } catch (RemoteException ignored) {
706 }
707 }
708
Ihab Awad5d0410f2014-07-30 10:07:40 -0700709 /**
710 * Instructs this {@code RemoteConnection} to stop any dual-tone multi-frequency signaling
711 * (DTMF) tone currently playing.
712 *
713 * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is
714 * currently playing, this method will do nothing.
715 */
716 public void stopDtmfTone() {
Santos Cordon52d8a152014-06-17 19:08:45 -0700717 try {
718 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700719 mConnectionService.stopDtmfTone(mConnectionId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700720 }
721 } catch (RemoteException ignored) {
722 }
723 }
724
Ihab Awad5d0410f2014-07-30 10:07:40 -0700725 /**
726 * Instructs this {@code RemoteConnection} to continue playing a post-dial DTMF string.
727 *
728 * A post-dial DTMF string is a string of digits following the first instance of either
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700729 * {@link TelecomManager#DTMF_CHARACTER_WAIT} or {@link TelecomManager#DTMF_CHARACTER_PAUSE}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700730 * These digits are immediately sent as DTMF tones to the recipient as soon as the
731 * connection is made.
732 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700733 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this
Ihab Awad5d0410f2014-07-30 10:07:40 -0700734 * {@code RemoteConnection} will temporarily pause playing the tones for a pre-defined period
735 * of time.
736 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700737 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800738 * {@code RemoteConnection} will pause playing the tones and notify callbacks via
Andrew Lee100e2932014-09-08 15:34:24 -0700739 * {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app
Ihab Awad5d0410f2014-07-30 10:07:40 -0700740 * should display to the user an indication of this state and an affordance to continue
741 * the postdial sequence. When the user decides to continue the postdial sequence, the in-call
742 * app should invoke the {@link #postDialContinue(boolean)} method.
743 *
744 * @param proceed Whether or not to continue with the post-dial sequence.
745 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700746 public void postDialContinue(boolean proceed) {
747 try {
748 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700749 mConnectionService.onPostDialContinue(mConnectionId, proceed);
Santos Cordon52d8a152014-06-17 19:08:45 -0700750 }
751 } catch (RemoteException ignored) {
752 }
753 }
754
Ihab Awad5d0410f2014-07-30 10:07:40 -0700755 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700756 * Set the audio state of this {@code RemoteConnection}.
757 *
758 * @param state The audio state of this {@code RemoteConnection}.
759 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700760 public void setAudioState(AudioState state) {
Sailesh Nepal091768c2014-06-30 15:15:23 -0700761 try {
762 if (mConnected) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700763 mConnectionService.onAudioStateChanged(mConnectionId, state);
Sailesh Nepal091768c2014-06-30 15:15:23 -0700764 }
765 } catch (RemoteException ignored) {
766 }
767 }
768
Santos Cordon52d8a152014-06-17 19:08:45 -0700769 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700770 * Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be
771 * successfully asked to create a conference with.
772 *
773 * @return The {@code RemoteConnection}s with which this {@code RemoteConnection} may be
774 * merged into a {@link RemoteConference}.
775 */
776 public List<RemoteConnection> getConferenceableConnections() {
777 return mUnmodifiableconferenceableConnections;
778 }
779
780 /**
781 * Obtain the {@code RemoteConference} that this {@code RemoteConnection} may be a part
782 * of, or {@code null} if there is no such {@code RemoteConference}.
783 *
784 * @return A {@code RemoteConference} or {@code null};
785 */
786 public RemoteConference getConference() {
787 return mConference;
788 }
789
790 /** {@hide} */
791 String getId() {
792 return mConnectionId;
793 }
794
795 /** {@hide} */
796 IConnectionService getConnectionService() {
797 return mConnectionService;
798 }
799
800 /**
Santos Cordon52d8a152014-06-17 19:08:45 -0700801 * @hide
802 */
803 void setState(int state) {
804 if (mState != state) {
805 mState = state;
Andrew Lee100e2932014-09-08 15:34:24 -0700806 for (Callback c: mCallbacks) {
807 c.onStateChanged(this, state);
Santos Cordon52d8a152014-06-17 19:08:45 -0700808 }
809 }
810 }
811
812 /**
813 * @hide
814 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700815 void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700816 if (mState != Connection.STATE_DISCONNECTED) {
817 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700818 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700819
Andrew Lee100e2932014-09-08 15:34:24 -0700820 for (Callback c : mCallbacks) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700821 c.onDisconnected(this, mDisconnectCause);
Santos Cordon52d8a152014-06-17 19:08:45 -0700822 }
823 }
824 }
825
826 /**
827 * @hide
828 */
Andrew Lee100e2932014-09-08 15:34:24 -0700829 void setRingbackRequested(boolean ringback) {
830 if (mRingbackRequested != ringback) {
831 mRingbackRequested = ringback;
832 for (Callback c : mCallbacks) {
833 c.onRingbackRequested(this, ringback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700834 }
835 }
836 }
837
838 /**
839 * @hide
840 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800841 void setConnectionCapabilities(int connectionCapabilities) {
842 mConnectionCapabilities = connectionCapabilities;
Andrew Lee100e2932014-09-08 15:34:24 -0700843 for (Callback c : mCallbacks) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800844 c.onConnectionCapabilitiesChanged(this, connectionCapabilities);
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700845 }
846 }
847
848 /**
849 * @hide
850 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700851 void setDestroyed() {
Andrew Lee100e2932014-09-08 15:34:24 -0700852 if (!mCallbacks.isEmpty()) {
853 // Make sure that the callbacks are notified that the call is destroyed first.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700854 if (mState != Connection.STATE_DISCONNECTED) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700855 setDisconnected(
856 new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed."));
Santos Cordon52d8a152014-06-17 19:08:45 -0700857 }
858
Andrew Lee100e2932014-09-08 15:34:24 -0700859 for (Callback c : mCallbacks) {
860 c.onDestroyed(this);
Santos Cordon52d8a152014-06-17 19:08:45 -0700861 }
Andrew Lee100e2932014-09-08 15:34:24 -0700862 mCallbacks.clear();
Santos Cordon52d8a152014-06-17 19:08:45 -0700863
864 mConnected = false;
865 }
866 }
867
868 /**
869 * @hide
870 */
871 void setPostDialWait(String remainingDigits) {
Andrew Lee100e2932014-09-08 15:34:24 -0700872 for (Callback c : mCallbacks) {
873 c.onPostDialWait(this, remainingDigits);
Santos Cordon52d8a152014-06-17 19:08:45 -0700874 }
875 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700876
Tyler Gunnaa07df82014-07-17 07:50:22 -0700877 /**
878 * @hide
879 */
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800880 void onPostDialChar(char nextChar) {
881 for (Callback c : mCallbacks) {
882 c.onPostDialChar(this, nextChar);
883 }
884 }
885
886 /**
887 * @hide
888 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700889 void setVideoState(int videoState) {
890 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700891 for (Callback c : mCallbacks) {
892 c.onVideoStateChanged(this, videoState);
Tyler Gunnaa07df82014-07-17 07:50:22 -0700893 }
894 }
895
Ihab Awada64627c2014-08-20 09:36:40 -0700896 /**
897 * @hide
898 */
899 void setVideoProvider(VideoProvider videoProvider) {
900 mVideoProvider = videoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700901 for (Callback c : mCallbacks) {
902 c.onVideoProviderChanged(this, videoProvider);
Ihab Awada64627c2014-08-20 09:36:40 -0700903 }
904 }
905
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700906 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700907 void setIsVoipAudioMode(boolean isVoip) {
908 mIsVoipAudioMode = isVoip;
909 for (Callback c : mCallbacks) {
910 c.onVoipAudioChanged(this, isVoip);
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700911 }
912 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700913
914 /** @hide */
915 void setStatusHints(StatusHints statusHints) {
916 mStatusHints = statusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700917 for (Callback c : mCallbacks) {
918 c.onStatusHintsChanged(this, statusHints);
Sailesh Nepal61203862014-07-11 14:50:13 -0700919 }
920 }
921
922 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700923 void setAddress(Uri address, int presentation) {
924 mAddress = address;
925 mAddressPresentation = presentation;
926 for (Callback c : mCallbacks) {
927 c.onAddressChanged(this, address, presentation);
Sailesh Nepal61203862014-07-11 14:50:13 -0700928 }
929 }
930
931 /** @hide */
932 void setCallerDisplayName(String callerDisplayName, int presentation) {
933 mCallerDisplayName = callerDisplayName;
934 mCallerDisplayNamePresentation = presentation;
Andrew Lee100e2932014-09-08 15:34:24 -0700935 for (Callback c : mCallbacks) {
936 c.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700937 }
938 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700939
940 /** @hide */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700941 void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) {
942 mConferenceableConnections.clear();
943 mConferenceableConnections.addAll(conferenceableConnections);
Andrew Lee100e2932014-09-08 15:34:24 -0700944 for (Callback c : mCallbacks) {
945 c.onConferenceableConnectionsChanged(this, mUnmodifiableconferenceableConnections);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700946 }
947 }
948
949 /** @hide */
950 void setConference(RemoteConference conference) {
951 if (mConference != conference) {
952 mConference = conference;
Andrew Lee100e2932014-09-08 15:34:24 -0700953 for (Callback c : mCallbacks) {
954 c.onConferenceChanged(this, conference);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700955 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700956 }
957 }
958
Evan Charltonbf11f982014-07-20 22:06:28 -0700959 /**
Ihab Awad6107bab2014-08-18 09:23:25 -0700960 * Create a RemoteConnection represents a failure, and which will be in
961 * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
962 * certainly result in bad things happening. Do not do this.
Evan Charltonbf11f982014-07-20 22:06:28 -0700963 *
964 * @return a failed {@link RemoteConnection}
965 *
966 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700967 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700968 public static RemoteConnection failure(DisconnectCause disconnectCause) {
969 return new RemoteConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -0700970 }
Santos Cordon52d8a152014-06-17 19:08:45 -0700971}