blob: 486691f3bbc2744cdbdc28468b425a4f2092aa62 [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 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700164 * Indicates that this {@code RemoteConnection} has been destroyed. No further requests
165 * should be made to the {@code RemoteConnection}, and references to it should be cleared.
166 *
167 * @param connection The {@code RemoteConnection} invoking this method.
168 */
Evan Charltonbf11f982014-07-20 22:06:28 -0700169 public void onDestroyed(RemoteConnection connection) {}
Ihab Awadb8e85c72014-08-23 20:34:57 -0700170
171 /**
172 * Indicates that the {@code RemoteConnection}s with which this {@code RemoteConnection}
173 * may be asked to create a conference has changed.
174 *
175 * @param connection The {@code RemoteConnection} invoking this method.
176 * @param conferenceableConnections The {@code RemoteConnection}s with which this
177 * {@code RemoteConnection} may be asked to create a conference.
178 */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700179 public void onConferenceableConnectionsChanged(
Ihab Awadb8e85c72014-08-23 20:34:57 -0700180 RemoteConnection connection,
181 List<RemoteConnection> conferenceableConnections) {}
182
183 /**
Ihab Awada64627c2014-08-20 09:36:40 -0700184 * Indicates that the {@code VideoProvider} associated with this {@code RemoteConnection}
185 * has changed.
186 *
187 * @param connection The {@code RemoteConnection} invoking this method.
188 * @param videoProvider The new {@code VideoProvider} associated with this
189 * {@code RemoteConnection}.
190 * @hide
191 */
192 public void onVideoProviderChanged(
193 RemoteConnection connection, VideoProvider videoProvider) {}
194
195 /**
Ihab Awadb8e85c72014-08-23 20:34:57 -0700196 * Indicates that the {@code RemoteConference} that this {@code RemoteConnection} is a part
197 * of has changed.
198 *
199 * @param connection The {@code RemoteConnection} invoking this method.
200 * @param conference The {@code RemoteConference} of which this {@code RemoteConnection} is
201 * a part, which may be {@code null}.
202 */
203 public void onConferenceChanged(
204 RemoteConnection connection,
205 RemoteConference conference) {}
Santos Cordon52d8a152014-06-17 19:08:45 -0700206 }
207
Ihab Awada64627c2014-08-20 09:36:40 -0700208 /** {@hide} */
209 public static class VideoProvider {
210
211 public abstract static class Listener {
212 public void onReceiveSessionModifyRequest(
213 VideoProvider videoProvider,
214 VideoProfile videoProfile) {}
215
216 public void onReceiveSessionModifyResponse(
217 VideoProvider videoProvider,
218 int status,
219 VideoProfile requestedProfile,
220 VideoProfile responseProfile) {}
221
222 public void onHandleCallSessionEvent(VideoProvider videoProvider, int event) {}
223
224 public void onPeerDimensionsChanged(VideoProvider videoProvider, int width, int height) {}
225
226 public void onCallDataUsageChanged(VideoProvider videoProvider, int dataUsage) {}
227
228 public void onCameraCapabilitiesChanged(
229 VideoProvider videoProvider,
230 CameraCapabilities cameraCapabilities) {}
231 }
232
233 private final IVideoCallback mVideoCallbackDelegate = new IVideoCallback() {
234 @Override
235 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
236 for (Listener l : mListeners) {
237 l.onReceiveSessionModifyRequest(VideoProvider.this, videoProfile);
238 }
239 }
240
241 @Override
242 public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile,
243 VideoProfile responseProfile) {
244 for (Listener l : mListeners) {
245 l.onReceiveSessionModifyResponse(
246 VideoProvider.this,
247 status,
248 requestedProfile,
249 responseProfile);
250 }
251 }
252
253 @Override
254 public void handleCallSessionEvent(int event) {
255 for (Listener l : mListeners) {
256 l.onHandleCallSessionEvent(VideoProvider.this, event);
257 }
258 }
259
260 @Override
261 public void changePeerDimensions(int width, int height) {
262 for (Listener l : mListeners) {
263 l.onPeerDimensionsChanged(VideoProvider.this, width, height);
264 }
265 }
266
267 @Override
268 public void changeCallDataUsage(int dataUsage) {
269 for (Listener l : mListeners) {
270 l.onCallDataUsageChanged(VideoProvider.this, dataUsage);
271 }
272 }
273
274 @Override
275 public void changeCameraCapabilities(CameraCapabilities cameraCapabilities) {
276 for (Listener l : mListeners) {
277 l.onCameraCapabilitiesChanged(VideoProvider.this, cameraCapabilities);
278 }
279 }
280
281 @Override
282 public IBinder asBinder() {
283 return null;
284 }
285 };
286
287 private final VideoCallbackServant mVideoCallbackServant =
288 new VideoCallbackServant(mVideoCallbackDelegate);
289
290 private final IVideoProvider mVideoProviderBinder;
291
292 /**
293 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
294 * load factor before resizing, 1 means we only expect a single thread to
295 * access the map so make only a single shard
296 */
297 private final Set<Listener> mListeners = Collections.newSetFromMap(
298 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
299
300 public VideoProvider(IVideoProvider videoProviderBinder) {
301 mVideoProviderBinder = videoProviderBinder;
302 try {
303 mVideoProviderBinder.setVideoCallback(mVideoCallbackServant.getStub().asBinder());
304 } catch (RemoteException e) {
305 }
306 }
307
308 public void addListener(Listener l) {
309 mListeners.add(l);
310 }
311
312 public void removeListener(Listener l) {
313 mListeners.remove(l);
314 }
315
316 public void setCamera(String cameraId) {
317 try {
318 mVideoProviderBinder.setCamera(cameraId);
319 } catch (RemoteException e) {
320 }
321 }
322
323 public void setPreviewSurface(Surface surface) {
324 try {
325 mVideoProviderBinder.setPreviewSurface(surface);
326 } catch (RemoteException e) {
327 }
328 }
329
330 public void setDisplaySurface(Surface surface) {
331 try {
332 mVideoProviderBinder.setDisplaySurface(surface);
333 } catch (RemoteException e) {
334 }
335 }
336
337 public void setDeviceOrientation(int rotation) {
338 try {
339 mVideoProviderBinder.setDeviceOrientation(rotation);
340 } catch (RemoteException e) {
341 }
342 }
343
344 public void setZoom(float value) {
345 try {
346 mVideoProviderBinder.setZoom(value);
347 } catch (RemoteException e) {
348 }
349 }
350
351 public void sendSessionModifyRequest(VideoProfile reqProfile) {
352 try {
353 mVideoProviderBinder.sendSessionModifyRequest(reqProfile);
354 } catch (RemoteException e) {
355 }
356 }
357
358 public void sendSessionModifyResponse(VideoProfile responseProfile) {
359 try {
360 mVideoProviderBinder.sendSessionModifyResponse(responseProfile);
361 } catch (RemoteException e) {
362 }
363 }
364
365 public void requestCameraCapabilities() {
366 try {
367 mVideoProviderBinder.requestCameraCapabilities();
368 } catch (RemoteException e) {
369 }
370 }
371
372 public void requestCallDataUsage() {
373 try {
374 mVideoProviderBinder.requestCallDataUsage();
375 } catch (RemoteException e) {
376 }
377 }
378
379 public void setPauseImage(String uri) {
380 try {
381 mVideoProviderBinder.setPauseImage(uri);
382 } catch (RemoteException e) {
383 }
384 }
385 }
386
Evan Charltonbf11f982014-07-20 22:06:28 -0700387 private IConnectionService mConnectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700388 private final String mConnectionId;
Jay Shrauner229e3822014-08-15 09:23:07 -0700389 /**
390 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
391 * load factor before resizing, 1 means we only expect a single thread to
392 * access the map so make only a single shard
393 */
Andrew Lee100e2932014-09-08 15:34:24 -0700394 private final Set<Callback> mCallbacks = Collections.newSetFromMap(
395 new ConcurrentHashMap<Callback, Boolean>(8, 0.9f, 1));
Ihab Awadb8e85c72014-08-23 20:34:57 -0700396 private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>();
397 private final List<RemoteConnection> mUnmodifiableconferenceableConnections =
398 Collections.unmodifiableList(mConferenceableConnections);
Santos Cordon52d8a152014-06-17 19:08:45 -0700399
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700400 private int mState = Connection.STATE_NEW;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700401 private DisconnectCause mDisconnectCause;
Andrew Lee100e2932014-09-08 15:34:24 -0700402 private boolean mRingbackRequested;
Santos Cordon52d8a152014-06-17 19:08:45 -0700403 private boolean mConnected;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800404 private int mConnectionCapabilities;
Tyler Gunnaa07df82014-07-17 07:50:22 -0700405 private int mVideoState;
Ihab Awada64627c2014-08-20 09:36:40 -0700406 private VideoProvider mVideoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700407 private boolean mIsVoipAudioMode;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700408 private StatusHints mStatusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700409 private Uri mAddress;
410 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700411 private String mCallerDisplayName;
412 private int mCallerDisplayNamePresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -0700413 private RemoteConference mConference;
Santos Cordon52d8a152014-06-17 19:08:45 -0700414
415 /**
416 * @hide
417 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700418 RemoteConnection(
419 String id,
420 IConnectionService connectionService,
421 ConnectionRequest request) {
422 mConnectionId = id;
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700423 mConnectionService = connectionService;
Santos Cordon52d8a152014-06-17 19:08:45 -0700424 mConnected = true;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700425 mState = Connection.STATE_INITIALIZING;
Evan Charltonbf11f982014-07-20 22:06:28 -0700426 }
427
428 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700429 * @hide
430 */
431 RemoteConnection(String callId, IConnectionService connectionService,
432 ParcelableConnection connection) {
433 mConnectionId = callId;
434 mConnectionService = connectionService;
435 mConnected = true;
436 mState = connection.getState();
437 mDisconnectCause = connection.getDisconnectCause();
438 mRingbackRequested = connection.isRingbackRequested();
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800439 mConnectionCapabilities = connection.getConnectionCapabilities();
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700440 mVideoState = connection.getVideoState();
441 mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider());
442 mIsVoipAudioMode = connection.getIsVoipAudioMode();
443 mStatusHints = connection.getStatusHints();
444 mAddress = connection.getHandle();
445 mAddressPresentation = connection.getHandlePresentation();
446 mCallerDisplayName = connection.getCallerDisplayName();
447 mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
448 mConference = null;
449 }
450
451 /**
Evan Charltonbf11f982014-07-20 22:06:28 -0700452 * Create a RemoteConnection which is used for failed connections. Note that using it for any
453 * "real" purpose will almost certainly fail. Callers should note the failure and act
454 * accordingly (moving on to another RemoteConnection, for example)
455 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700456 * @param disconnectCause The reason for the failed connection.
457 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700458 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700459 RemoteConnection(DisconnectCause disconnectCause) {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700460 mConnectionId = "NULL";
Evan Charltonbf11f982014-07-20 22:06:28 -0700461 mConnected = false;
Ihab Awad6107bab2014-08-18 09:23:25 -0700462 mState = Connection.STATE_DISCONNECTED;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700463 mDisconnectCause = disconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700464 }
465
Ihab Awad5d0410f2014-07-30 10:07:40 -0700466 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700467 * Adds a callback to this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700468 *
Andrew Lee100e2932014-09-08 15:34:24 -0700469 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700470 */
Andrew Lee100e2932014-09-08 15:34:24 -0700471 public void registerCallback(Callback callback) {
472 mCallbacks.add(callback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700473 }
474
Ihab Awad5d0410f2014-07-30 10:07:40 -0700475 /**
Andrew Lee100e2932014-09-08 15:34:24 -0700476 * Removes a callback from this {@code RemoteConnection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700477 *
Andrew Lee100e2932014-09-08 15:34:24 -0700478 * @param callback A {@code Callback}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700479 */
Andrew Lee100e2932014-09-08 15:34:24 -0700480 public void unregisterCallback(Callback callback) {
481 if (callback != null) {
482 mCallbacks.remove(callback);
Jay Shrauner229e3822014-08-15 09:23:07 -0700483 }
Santos Cordon52d8a152014-06-17 19:08:45 -0700484 }
485
Ihab Awad5d0410f2014-07-30 10:07:40 -0700486 /**
Ihab Awad5d0410f2014-07-30 10:07:40 -0700487 * Obtains the state of this {@code RemoteConnection}.
488 *
489 * @return A state value, chosen from the {@code STATE_*} constants.
490 */
Sailesh Nepalade3f252014-07-01 17:25:37 -0700491 public int getState() {
492 return mState;
493 }
494
Ihab Awad5d0410f2014-07-30 10:07:40 -0700495 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800496 * Obtains the reason why this {@code RemoteConnection} may have been disconnected.
497 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700498 * @return For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800499 * disconnect cause expressed as a code chosen from among those declared in
500 * {@link DisconnectCause}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700501 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700502 public DisconnectCause getDisconnectCause() {
503 return mDisconnectCause;
Santos Cordon52d8a152014-06-17 19:08:45 -0700504 }
505
Ihab Awad5d0410f2014-07-30 10:07:40 -0700506 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800507 * Obtains the capabilities of this {@code RemoteConnection}.
508 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700509 * @return A bitmask of the capabilities of the {@code RemoteConnection}, as defined in
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800510 * the {@code CAPABILITY_*} constants in class {@link Connection}.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700511 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800512 public int getConnectionCapabilities() {
513 return mConnectionCapabilities;
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700514 }
515
Ihab Awad5d0410f2014-07-30 10:07:40 -0700516 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800517 * Determines if the audio mode of this {@code RemoteConnection} is VOIP.
518 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700519 * @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP.
520 */
Andrew Lee100e2932014-09-08 15:34:24 -0700521 public boolean isVoipAudioMode() {
522 return mIsVoipAudioMode;
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700523 }
524
Ihab Awad5d0410f2014-07-30 10:07:40 -0700525 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800526 * Obtains status hints pertaining to this {@code RemoteConnection}.
527 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700528 * @return The current {@link StatusHints} of this {@code RemoteConnection},
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800529 * or {@code null} if none have been set.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700530 */
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700531 public StatusHints getStatusHints() {
532 return mStatusHints;
533 }
534
Ihab Awad5d0410f2014-07-30 10:07:40 -0700535 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800536 * Obtains the address of this {@code RemoteConnection}.
537 *
538 * @return The address (e.g., phone number) to which the {@code RemoteConnection}
539 * is currently connected.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700540 */
Andrew Lee100e2932014-09-08 15:34:24 -0700541 public Uri getAddress() {
542 return mAddress;
Sailesh Nepal61203862014-07-11 14:50:13 -0700543 }
544
Ihab Awad5d0410f2014-07-30 10:07:40 -0700545 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800546 * Obtains the presentation requirements for the address of this {@code RemoteConnection}.
547 *
548 * @return The presentation requirements for the address. See
549 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700550 */
Andrew Lee100e2932014-09-08 15:34:24 -0700551 public int getAddressPresentation() {
552 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -0700553 }
554
Ihab Awad5d0410f2014-07-30 10:07:40 -0700555 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800556 * Obtains the display name for this {@code RemoteConnection}'s caller.
557 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700558 * @return The display name for the caller.
559 */
Andrew Lee100e2932014-09-08 15:34:24 -0700560 public CharSequence getCallerDisplayName() {
Sailesh Nepal61203862014-07-11 14:50:13 -0700561 return mCallerDisplayName;
562 }
563
Ihab Awad5d0410f2014-07-30 10:07:40 -0700564 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800565 * Obtains the presentation requirements for this {@code RemoteConnection}'s
566 * caller's display name.
567 *
Ihab Awad5d0410f2014-07-30 10:07:40 -0700568 * @return The presentation requirements for the caller display name. See
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800569 * {@link TelecomManager} for valid values.
Ihab Awad5d0410f2014-07-30 10:07:40 -0700570 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700571 public int getCallerDisplayNamePresentation() {
572 return mCallerDisplayNamePresentation;
573 }
574
Ihab Awad5d0410f2014-07-30 10:07:40 -0700575 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800576 * Obtains the video state of this {@code RemoteConnection}.
577 *
578 * @return The video state of the {@code RemoteConnection}. See {@link VideoProfile.VideoState}.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700579 * @hide
Ihab Awad5d0410f2014-07-30 10:07:40 -0700580 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700581 public int getVideoState() {
582 return mVideoState;
583 }
584
Ihab Awad5d0410f2014-07-30 10:07:40 -0700585 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800586 * Obtains the video provider of this {@code RemoteConnection}.
587 *
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);
845 c.onCallCapabilitiesChanged(this, connectionCapabilities);
Sailesh Nepal1a7061b2014-07-09 21:03:20 -0700846 }
847 }
848
849 /**
850 * @hide
851 */
Santos Cordon52d8a152014-06-17 19:08:45 -0700852 void setDestroyed() {
Andrew Lee100e2932014-09-08 15:34:24 -0700853 if (!mCallbacks.isEmpty()) {
854 // Make sure that the callbacks are notified that the call is destroyed first.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700855 if (mState != Connection.STATE_DISCONNECTED) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700856 setDisconnected(
857 new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed."));
Santos Cordon52d8a152014-06-17 19:08:45 -0700858 }
859
Andrew Lee100e2932014-09-08 15:34:24 -0700860 for (Callback c : mCallbacks) {
861 c.onDestroyed(this);
Santos Cordon52d8a152014-06-17 19:08:45 -0700862 }
Andrew Lee100e2932014-09-08 15:34:24 -0700863 mCallbacks.clear();
Santos Cordon52d8a152014-06-17 19:08:45 -0700864
865 mConnected = false;
866 }
867 }
868
869 /**
870 * @hide
871 */
872 void setPostDialWait(String remainingDigits) {
Andrew Lee100e2932014-09-08 15:34:24 -0700873 for (Callback c : mCallbacks) {
874 c.onPostDialWait(this, remainingDigits);
Santos Cordon52d8a152014-06-17 19:08:45 -0700875 }
876 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700877
Tyler Gunnaa07df82014-07-17 07:50:22 -0700878 /**
879 * @hide
880 */
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800881 void onPostDialChar(char nextChar) {
882 for (Callback c : mCallbacks) {
883 c.onPostDialChar(this, nextChar);
884 }
885 }
886
887 /**
888 * @hide
889 */
Tyler Gunnaa07df82014-07-17 07:50:22 -0700890 void setVideoState(int videoState) {
891 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700892 for (Callback c : mCallbacks) {
893 c.onVideoStateChanged(this, videoState);
Tyler Gunnaa07df82014-07-17 07:50:22 -0700894 }
895 }
896
Ihab Awada64627c2014-08-20 09:36:40 -0700897 /**
898 * @hide
899 */
900 void setVideoProvider(VideoProvider videoProvider) {
901 mVideoProvider = videoProvider;
Andrew Lee100e2932014-09-08 15:34:24 -0700902 for (Callback c : mCallbacks) {
903 c.onVideoProviderChanged(this, videoProvider);
Ihab Awada64627c2014-08-20 09:36:40 -0700904 }
905 }
906
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700907 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700908 void setIsVoipAudioMode(boolean isVoip) {
909 mIsVoipAudioMode = isVoip;
910 for (Callback c : mCallbacks) {
911 c.onVoipAudioChanged(this, isVoip);
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700912 }
913 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700914
915 /** @hide */
916 void setStatusHints(StatusHints statusHints) {
917 mStatusHints = statusHints;
Andrew Lee100e2932014-09-08 15:34:24 -0700918 for (Callback c : mCallbacks) {
919 c.onStatusHintsChanged(this, statusHints);
Sailesh Nepal61203862014-07-11 14:50:13 -0700920 }
921 }
922
923 /** @hide */
Andrew Lee100e2932014-09-08 15:34:24 -0700924 void setAddress(Uri address, int presentation) {
925 mAddress = address;
926 mAddressPresentation = presentation;
927 for (Callback c : mCallbacks) {
928 c.onAddressChanged(this, address, presentation);
Sailesh Nepal61203862014-07-11 14:50:13 -0700929 }
930 }
931
932 /** @hide */
933 void setCallerDisplayName(String callerDisplayName, int presentation) {
934 mCallerDisplayName = callerDisplayName;
935 mCallerDisplayNamePresentation = presentation;
Andrew Lee100e2932014-09-08 15:34:24 -0700936 for (Callback c : mCallbacks) {
937 c.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700938 }
939 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700940
941 /** @hide */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700942 void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) {
943 mConferenceableConnections.clear();
944 mConferenceableConnections.addAll(conferenceableConnections);
Andrew Lee100e2932014-09-08 15:34:24 -0700945 for (Callback c : mCallbacks) {
946 c.onConferenceableConnectionsChanged(this, mUnmodifiableconferenceableConnections);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700947 }
948 }
949
950 /** @hide */
951 void setConference(RemoteConference conference) {
952 if (mConference != conference) {
953 mConference = conference;
Andrew Lee100e2932014-09-08 15:34:24 -0700954 for (Callback c : mCallbacks) {
955 c.onConferenceChanged(this, conference);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700956 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700957 }
958 }
959
Evan Charltonbf11f982014-07-20 22:06:28 -0700960 /**
Ihab Awad6107bab2014-08-18 09:23:25 -0700961 * Create a RemoteConnection represents a failure, and which will be in
962 * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
963 * certainly result in bad things happening. Do not do this.
Evan Charltonbf11f982014-07-20 22:06:28 -0700964 *
965 * @return a failed {@link RemoteConnection}
966 *
967 * @hide
Evan Charltonbf11f982014-07-20 22:06:28 -0700968 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700969 public static RemoteConnection failure(DisconnectCause disconnectCause) {
970 return new RemoteConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -0700971 }
Santos Cordon52d8a152014-06-17 19:08:45 -0700972}