Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1 | /* |
| 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 18 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 19 | import com.android.internal.telecom.IConnectionService; |
| 20 | import com.android.internal.telecom.IVideoCallback; |
| 21 | import com.android.internal.telecom.IVideoProvider; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 22 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame^] | 23 | import android.annotation.SystemApi; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 24 | import android.net.Uri; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 25 | import android.os.Handler; |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 26 | import android.os.IBinder; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 27 | import android.os.RemoteException; |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 28 | import android.view.Surface; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 29 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 30 | import java.util.ArrayList; |
Sailesh Nepal | f4669df | 2014-08-14 17:43:13 -0700 | [diff] [blame] | 31 | import java.util.Collections; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 32 | import java.util.List; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 33 | import java.util.Set; |
Sailesh Nepal | f4669df | 2014-08-14 17:43:13 -0700 | [diff] [blame] | 34 | import java.util.concurrent.ConcurrentHashMap; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 37 | * A connection provided to a {@link ConnectionService} by another {@code ConnectionService} |
| 38 | * running in a different process. |
| 39 | * |
| 40 | * @see ConnectionService#createRemoteOutgoingConnection(PhoneAccountHandle, ConnectionRequest) |
| 41 | * @see ConnectionService#createRemoteIncomingConnection(PhoneAccountHandle, ConnectionRequest) |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 42 | */ |
| 43 | public final class RemoteConnection { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 44 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 45 | public static abstract class Callback { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Invoked when the state of this {@code RemoteConnection} has changed. See |
| 48 | * {@link #getState()}. |
| 49 | * |
| 50 | * @param connection The {@code RemoteConnection} invoking this method. |
| 51 | * @param state The new state of the {@code RemoteConnection}. |
| 52 | */ |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 53 | public void onStateChanged(RemoteConnection connection, int state) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 56 | * Invoked when this {@code RemoteConnection} is disconnected. |
| 57 | * |
| 58 | * @param connection The {@code RemoteConnection} invoking this method. |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 59 | * @param disconnectCause The ({@see DisconnectCause}) associated with this failed |
| 60 | * connection. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 61 | */ |
| 62 | public void onDisconnected( |
| 63 | RemoteConnection connection, |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 64 | DisconnectCause disconnectCause) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Invoked when this {@code RemoteConnection} is requesting ringback. See |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 68 | * {@link #isRingbackRequested()}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 69 | * |
| 70 | * @param connection The {@code RemoteConnection} invoking this method. |
| 71 | * @param ringback Whether the {@code RemoteConnection} is requesting ringback. |
| 72 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 73 | public void onRingbackRequested(RemoteConnection connection, boolean ringback) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Indicates that the call capabilities of this {@code RemoteConnection} have changed. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 77 | * See {@link #getConnectionCapabilities()}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 78 | * |
| 79 | * @param connection The {@code RemoteConnection} invoking this method. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 80 | * @param connectionCapabilities The new capabilities of the {@code RemoteConnection}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 81 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 82 | public void onConnectionCapabilitiesChanged( |
| 83 | RemoteConnection connection, |
| 84 | int connectionCapabilities) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 85 | |
| 86 | /** |
| 87 | * Invoked when the post-dial sequence in the outgoing {@code Connection} has reached a |
| 88 | * pause character. This causes the post-dial signals to stop pending user confirmation. An |
| 89 | * implementation should present this choice to the user and invoke |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 90 | * {@link RemoteConnection#postDialContinue(boolean)} when the user makes the choice. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 91 | * |
| 92 | * @param connection The {@code RemoteConnection} invoking this method. |
| 93 | * @param remainingPostDialSequence The post-dial characters that remain to be sent. |
| 94 | */ |
| 95 | public void onPostDialWait(RemoteConnection connection, String remainingPostDialSequence) {} |
| 96 | |
| 97 | /** |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 98 | * Invoked when the post-dial sequence in the outgoing {@code Connection} has processed |
| 99 | * a character. |
| 100 | * |
| 101 | * @param connection The {@code RemoteConnection} invoking this method. |
| 102 | * @param nextChar The character being processed. |
| 103 | */ |
| 104 | public void onPostDialChar(RemoteConnection connection, char nextChar) {} |
| 105 | |
| 106 | /** |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 107 | * Indicates that the VOIP audio status of this {@code RemoteConnection} has changed. |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 108 | * See {@link #isVoipAudioMode()}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 109 | * |
| 110 | * @param connection The {@code RemoteConnection} invoking this method. |
| 111 | * @param isVoip Whether the new audio state of the {@code RemoteConnection} is VOIP. |
| 112 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 113 | public void onVoipAudioChanged(RemoteConnection connection, boolean isVoip) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Indicates that the status hints of this {@code RemoteConnection} have changed. See |
| 117 | * {@link #getStatusHints()} ()}. |
| 118 | * |
| 119 | * @param connection The {@code RemoteConnection} invoking this method. |
| 120 | * @param statusHints The new status hints of the {@code RemoteConnection}. |
| 121 | */ |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 122 | public void onStatusHintsChanged(RemoteConnection connection, StatusHints statusHints) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 125 | * Indicates that the address (e.g., phone number) of this {@code RemoteConnection} has |
| 126 | * changed. See {@link #getAddress()} and {@link #getAddressPresentation()}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 127 | * |
| 128 | * @param connection The {@code RemoteConnection} invoking this method. |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 129 | * @param address The new address of the {@code RemoteConnection}. |
| 130 | * @param presentation The presentation requirements for the address. |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 131 | * See {@link TelecomManager} for valid values. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 132 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 133 | public void onAddressChanged(RemoteConnection connection, Uri address, int presentation) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * Indicates that the caller display name of this {@code RemoteConnection} has changed. |
| 137 | * See {@link #getCallerDisplayName()} and {@link #getCallerDisplayNamePresentation()}. |
| 138 | * |
| 139 | * @param connection The {@code RemoteConnection} invoking this method. |
| 140 | * @param callerDisplayName The new caller display name of the {@code RemoteConnection}. |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 141 | * @param presentation The presentation requirements for the handle. |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 142 | * See {@link TelecomManager} for valid values. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 143 | */ |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 144 | public void onCallerDisplayNameChanged( |
| 145 | RemoteConnection connection, String callerDisplayName, int presentation) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
| 148 | * Indicates that the video state of this {@code RemoteConnection} has changed. |
| 149 | * See {@link #getVideoState()}. |
| 150 | * |
| 151 | * @param connection The {@code RemoteConnection} invoking this method. |
| 152 | * @param videoState The new video state of the {@code RemoteConnection}. |
Tyler Gunn | 27d1e25 | 2014-08-21 16:38:40 -0700 | [diff] [blame] | 153 | * @hide |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 154 | */ |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 155 | public void onVideoStateChanged(RemoteConnection connection, int videoState) {} |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 158 | * Indicates that this {@code RemoteConnection} has been destroyed. No further requests |
| 159 | * should be made to the {@code RemoteConnection}, and references to it should be cleared. |
| 160 | * |
| 161 | * @param connection The {@code RemoteConnection} invoking this method. |
| 162 | */ |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 163 | public void onDestroyed(RemoteConnection connection) {} |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 164 | |
| 165 | /** |
| 166 | * Indicates that the {@code RemoteConnection}s with which this {@code RemoteConnection} |
| 167 | * may be asked to create a conference has changed. |
| 168 | * |
| 169 | * @param connection The {@code RemoteConnection} invoking this method. |
| 170 | * @param conferenceableConnections The {@code RemoteConnection}s with which this |
| 171 | * {@code RemoteConnection} may be asked to create a conference. |
| 172 | */ |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 173 | public void onConferenceableConnectionsChanged( |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 174 | RemoteConnection connection, |
| 175 | List<RemoteConnection> conferenceableConnections) {} |
| 176 | |
| 177 | /** |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 178 | * Indicates that the {@code VideoProvider} associated with this {@code RemoteConnection} |
| 179 | * has changed. |
| 180 | * |
| 181 | * @param connection The {@code RemoteConnection} invoking this method. |
| 182 | * @param videoProvider The new {@code VideoProvider} associated with this |
| 183 | * {@code RemoteConnection}. |
| 184 | * @hide |
| 185 | */ |
| 186 | public void onVideoProviderChanged( |
| 187 | RemoteConnection connection, VideoProvider videoProvider) {} |
| 188 | |
| 189 | /** |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 190 | * Indicates that the {@code RemoteConference} that this {@code RemoteConnection} is a part |
| 191 | * of has changed. |
| 192 | * |
| 193 | * @param connection The {@code RemoteConnection} invoking this method. |
| 194 | * @param conference The {@code RemoteConference} of which this {@code RemoteConnection} is |
| 195 | * a part, which may be {@code null}. |
| 196 | */ |
| 197 | public void onConferenceChanged( |
| 198 | RemoteConnection connection, |
| 199 | RemoteConference conference) {} |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 202 | /** {@hide} */ |
| 203 | public static class VideoProvider { |
| 204 | |
| 205 | public abstract static class Listener { |
| 206 | public void onReceiveSessionModifyRequest( |
| 207 | VideoProvider videoProvider, |
| 208 | VideoProfile videoProfile) {} |
| 209 | |
| 210 | public void onReceiveSessionModifyResponse( |
| 211 | VideoProvider videoProvider, |
| 212 | int status, |
| 213 | VideoProfile requestedProfile, |
| 214 | VideoProfile responseProfile) {} |
| 215 | |
| 216 | public void onHandleCallSessionEvent(VideoProvider videoProvider, int event) {} |
| 217 | |
| 218 | public void onPeerDimensionsChanged(VideoProvider videoProvider, int width, int height) {} |
| 219 | |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 220 | public void onCallDataUsageChanged(VideoProvider videoProvider, long dataUsage) {} |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 221 | |
| 222 | public void onCameraCapabilitiesChanged( |
| 223 | VideoProvider videoProvider, |
Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 224 | VideoProfile.CameraCapabilities cameraCapabilities) {} |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 225 | |
| 226 | public void onVideoQualityChanged(VideoProvider videoProvider, int videoQuality) {} |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | private final IVideoCallback mVideoCallbackDelegate = new IVideoCallback() { |
| 230 | @Override |
| 231 | public void receiveSessionModifyRequest(VideoProfile videoProfile) { |
| 232 | for (Listener l : mListeners) { |
| 233 | l.onReceiveSessionModifyRequest(VideoProvider.this, videoProfile); |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | @Override |
| 238 | public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile, |
| 239 | VideoProfile responseProfile) { |
| 240 | for (Listener l : mListeners) { |
| 241 | l.onReceiveSessionModifyResponse( |
| 242 | VideoProvider.this, |
| 243 | status, |
| 244 | requestedProfile, |
| 245 | responseProfile); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public void handleCallSessionEvent(int event) { |
| 251 | for (Listener l : mListeners) { |
| 252 | l.onHandleCallSessionEvent(VideoProvider.this, event); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | @Override |
| 257 | public void changePeerDimensions(int width, int height) { |
| 258 | for (Listener l : mListeners) { |
| 259 | l.onPeerDimensionsChanged(VideoProvider.this, width, height); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | @Override |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 264 | public void changeCallDataUsage(long dataUsage) { |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 265 | for (Listener l : mListeners) { |
| 266 | l.onCallDataUsageChanged(VideoProvider.this, dataUsage); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | @Override |
Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 271 | public void changeCameraCapabilities( |
| 272 | VideoProfile.CameraCapabilities cameraCapabilities) { |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 273 | for (Listener l : mListeners) { |
| 274 | l.onCameraCapabilitiesChanged(VideoProvider.this, cameraCapabilities); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | @Override |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 279 | public void changeVideoQuality(int videoQuality) { |
| 280 | for (Listener l : mListeners) { |
| 281 | l.onVideoQualityChanged(VideoProvider.this, videoQuality); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | @Override |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 286 | public IBinder asBinder() { |
| 287 | return null; |
| 288 | } |
| 289 | }; |
| 290 | |
| 291 | private final VideoCallbackServant mVideoCallbackServant = |
| 292 | new VideoCallbackServant(mVideoCallbackDelegate); |
| 293 | |
| 294 | private final IVideoProvider mVideoProviderBinder; |
| 295 | |
| 296 | /** |
| 297 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 298 | * load factor before resizing, 1 means we only expect a single thread to |
| 299 | * access the map so make only a single shard |
| 300 | */ |
| 301 | private final Set<Listener> mListeners = Collections.newSetFromMap( |
| 302 | new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1)); |
| 303 | |
| 304 | public VideoProvider(IVideoProvider videoProviderBinder) { |
| 305 | mVideoProviderBinder = videoProviderBinder; |
| 306 | try { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 307 | mVideoProviderBinder.addVideoCallback(mVideoCallbackServant.getStub().asBinder()); |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 308 | } catch (RemoteException e) { |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | public void addListener(Listener l) { |
| 313 | mListeners.add(l); |
| 314 | } |
| 315 | |
| 316 | public void removeListener(Listener l) { |
| 317 | mListeners.remove(l); |
| 318 | } |
| 319 | |
| 320 | public void setCamera(String cameraId) { |
| 321 | try { |
| 322 | mVideoProviderBinder.setCamera(cameraId); |
| 323 | } catch (RemoteException e) { |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | public void setPreviewSurface(Surface surface) { |
| 328 | try { |
| 329 | mVideoProviderBinder.setPreviewSurface(surface); |
| 330 | } catch (RemoteException e) { |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | public void setDisplaySurface(Surface surface) { |
| 335 | try { |
| 336 | mVideoProviderBinder.setDisplaySurface(surface); |
| 337 | } catch (RemoteException e) { |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | public void setDeviceOrientation(int rotation) { |
| 342 | try { |
| 343 | mVideoProviderBinder.setDeviceOrientation(rotation); |
| 344 | } catch (RemoteException e) { |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | public void setZoom(float value) { |
| 349 | try { |
| 350 | mVideoProviderBinder.setZoom(value); |
| 351 | } catch (RemoteException e) { |
| 352 | } |
| 353 | } |
| 354 | |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 355 | public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) { |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 356 | try { |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 357 | mVideoProviderBinder.sendSessionModifyRequest(fromProfile, toProfile); |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 358 | } catch (RemoteException e) { |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | public void sendSessionModifyResponse(VideoProfile responseProfile) { |
| 363 | try { |
| 364 | mVideoProviderBinder.sendSessionModifyResponse(responseProfile); |
| 365 | } catch (RemoteException e) { |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | public void requestCameraCapabilities() { |
| 370 | try { |
| 371 | mVideoProviderBinder.requestCameraCapabilities(); |
| 372 | } catch (RemoteException e) { |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | public void requestCallDataUsage() { |
| 377 | try { |
| 378 | mVideoProviderBinder.requestCallDataUsage(); |
| 379 | } catch (RemoteException e) { |
| 380 | } |
| 381 | } |
| 382 | |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 383 | public void setPauseImage(Uri uri) { |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 384 | try { |
| 385 | mVideoProviderBinder.setPauseImage(uri); |
| 386 | } catch (RemoteException e) { |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 391 | private IConnectionService mConnectionService; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 392 | private final String mConnectionId; |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 393 | /** |
| 394 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 395 | * load factor before resizing, 1 means we only expect a single thread to |
| 396 | * access the map so make only a single shard |
| 397 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 398 | private final Set<CallbackRecord> mCallbackRecords = Collections.newSetFromMap( |
| 399 | new ConcurrentHashMap<CallbackRecord, Boolean>(8, 0.9f, 1)); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 400 | private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>(); |
| 401 | private final List<RemoteConnection> mUnmodifiableconferenceableConnections = |
| 402 | Collections.unmodifiableList(mConferenceableConnections); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 403 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 404 | private int mState = Connection.STATE_NEW; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 405 | private DisconnectCause mDisconnectCause; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 406 | private boolean mRingbackRequested; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 407 | private boolean mConnected; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 408 | private int mConnectionCapabilities; |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 409 | private int mVideoState; |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 410 | private VideoProvider mVideoProvider; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 411 | private boolean mIsVoipAudioMode; |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 412 | private StatusHints mStatusHints; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 413 | private Uri mAddress; |
| 414 | private int mAddressPresentation; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 415 | private String mCallerDisplayName; |
| 416 | private int mCallerDisplayNamePresentation; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 417 | private RemoteConference mConference; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 418 | |
| 419 | /** |
| 420 | * @hide |
| 421 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 422 | RemoteConnection( |
| 423 | String id, |
| 424 | IConnectionService connectionService, |
| 425 | ConnectionRequest request) { |
| 426 | mConnectionId = id; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 427 | mConnectionService = connectionService; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 428 | mConnected = true; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 429 | mState = Connection.STATE_INITIALIZING; |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | /** |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 433 | * @hide |
| 434 | */ |
| 435 | RemoteConnection(String callId, IConnectionService connectionService, |
| 436 | ParcelableConnection connection) { |
| 437 | mConnectionId = callId; |
| 438 | mConnectionService = connectionService; |
| 439 | mConnected = true; |
| 440 | mState = connection.getState(); |
| 441 | mDisconnectCause = connection.getDisconnectCause(); |
| 442 | mRingbackRequested = connection.isRingbackRequested(); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 443 | mConnectionCapabilities = connection.getConnectionCapabilities(); |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 444 | mVideoState = connection.getVideoState(); |
| 445 | mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider()); |
| 446 | mIsVoipAudioMode = connection.getIsVoipAudioMode(); |
| 447 | mStatusHints = connection.getStatusHints(); |
| 448 | mAddress = connection.getHandle(); |
| 449 | mAddressPresentation = connection.getHandlePresentation(); |
| 450 | mCallerDisplayName = connection.getCallerDisplayName(); |
| 451 | mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation(); |
| 452 | mConference = null; |
| 453 | } |
| 454 | |
| 455 | /** |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 456 | * Create a RemoteConnection which is used for failed connections. Note that using it for any |
| 457 | * "real" purpose will almost certainly fail. Callers should note the failure and act |
| 458 | * accordingly (moving on to another RemoteConnection, for example) |
| 459 | * |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 460 | * @param disconnectCause The reason for the failed connection. |
| 461 | * @hide |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 462 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 463 | RemoteConnection(DisconnectCause disconnectCause) { |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 464 | mConnectionId = "NULL"; |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 465 | mConnected = false; |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 466 | mState = Connection.STATE_DISCONNECTED; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 467 | mDisconnectCause = disconnectCause; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 468 | } |
| 469 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 470 | /** |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 471 | * Adds a callback to this {@code RemoteConnection}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 472 | * |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 473 | * @param callback A {@code Callback}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 474 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 475 | public void registerCallback(Callback callback) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 476 | registerCallback(callback, new Handler()); |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * Adds a callback to this {@code RemoteConnection}. |
| 481 | * |
| 482 | * @param callback A {@code Callback}. |
| 483 | * @param handler A {@code Handler} which command and status changes will be delivered to. |
| 484 | */ |
| 485 | public void registerCallback(Callback callback, Handler handler) { |
| 486 | unregisterCallback(callback); |
| 487 | if (callback != null && handler != null) { |
| 488 | mCallbackRecords.add(new CallbackRecord(callback, handler)); |
| 489 | } |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 490 | } |
| 491 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 492 | /** |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 493 | * Removes a callback from this {@code RemoteConnection}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 494 | * |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 495 | * @param callback A {@code Callback}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 496 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 497 | public void unregisterCallback(Callback callback) { |
| 498 | if (callback != null) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 499 | for (CallbackRecord record : mCallbackRecords) { |
| 500 | if (record.getCallback() == callback) { |
| 501 | mCallbackRecords.remove(record); |
| 502 | break; |
| 503 | } |
| 504 | } |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 505 | } |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 506 | } |
| 507 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 508 | /** |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 509 | * Obtains the state of this {@code RemoteConnection}. |
| 510 | * |
| 511 | * @return A state value, chosen from the {@code STATE_*} constants. |
| 512 | */ |
Sailesh Nepal | ade3f25 | 2014-07-01 17:25:37 -0700 | [diff] [blame] | 513 | public int getState() { |
| 514 | return mState; |
| 515 | } |
| 516 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 517 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 518 | * Obtains the reason why this {@code RemoteConnection} may have been disconnected. |
| 519 | * |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 520 | * @return For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 521 | * disconnect cause expressed as a code chosen from among those declared in |
| 522 | * {@link DisconnectCause}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 523 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 524 | public DisconnectCause getDisconnectCause() { |
| 525 | return mDisconnectCause; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 528 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 529 | * Obtains the capabilities of this {@code RemoteConnection}. |
| 530 | * |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 531 | * @return A bitmask of the capabilities of the {@code RemoteConnection}, as defined in |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 532 | * the {@code CAPABILITY_*} constants in class {@link Connection}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 533 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 534 | public int getConnectionCapabilities() { |
| 535 | return mConnectionCapabilities; |
Sailesh Nepal | 1a7061b | 2014-07-09 21:03:20 -0700 | [diff] [blame] | 536 | } |
| 537 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 538 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 539 | * Determines if the audio mode of this {@code RemoteConnection} is VOIP. |
| 540 | * |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 541 | * @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP. |
| 542 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 543 | public boolean isVoipAudioMode() { |
| 544 | return mIsVoipAudioMode; |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 545 | } |
| 546 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 547 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 548 | * Obtains status hints pertaining to this {@code RemoteConnection}. |
| 549 | * |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 550 | * @return The current {@link StatusHints} of this {@code RemoteConnection}, |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 551 | * or {@code null} if none have been set. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 552 | */ |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 553 | public StatusHints getStatusHints() { |
| 554 | return mStatusHints; |
| 555 | } |
| 556 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 557 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 558 | * Obtains the address of this {@code RemoteConnection}. |
| 559 | * |
| 560 | * @return The address (e.g., phone number) to which the {@code RemoteConnection} |
| 561 | * is currently connected. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 562 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 563 | public Uri getAddress() { |
| 564 | return mAddress; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 567 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 568 | * Obtains the presentation requirements for the address of this {@code RemoteConnection}. |
| 569 | * |
| 570 | * @return The presentation requirements for the address. See |
| 571 | * {@link TelecomManager} for valid values. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 572 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 573 | public int getAddressPresentation() { |
| 574 | return mAddressPresentation; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 575 | } |
| 576 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 577 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 578 | * Obtains the display name for this {@code RemoteConnection}'s caller. |
| 579 | * |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 580 | * @return The display name for the caller. |
| 581 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 582 | public CharSequence getCallerDisplayName() { |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 583 | return mCallerDisplayName; |
| 584 | } |
| 585 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 586 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 587 | * Obtains the presentation requirements for this {@code RemoteConnection}'s |
| 588 | * caller's display name. |
| 589 | * |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 590 | * @return The presentation requirements for the caller display name. See |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 591 | * {@link TelecomManager} for valid values. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 592 | */ |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 593 | public int getCallerDisplayNamePresentation() { |
| 594 | return mCallerDisplayNamePresentation; |
| 595 | } |
| 596 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 597 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 598 | * Obtains the video state of this {@code RemoteConnection}. |
| 599 | * |
| 600 | * @return The video state of the {@code RemoteConnection}. See {@link VideoProfile.VideoState}. |
Tyler Gunn | 27d1e25 | 2014-08-21 16:38:40 -0700 | [diff] [blame] | 601 | * @hide |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 602 | */ |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 603 | public int getVideoState() { |
| 604 | return mVideoState; |
| 605 | } |
| 606 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 607 | /** |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 608 | * Obtains the video provider of this {@code RemoteConnection}. |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 609 | * @return The video provider associated with this {@code RemoteConnection}. |
| 610 | * @hide |
| 611 | */ |
| 612 | public final VideoProvider getVideoProvider() { |
| 613 | return mVideoProvider; |
| 614 | } |
| 615 | |
| 616 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 617 | * Determines whether this {@code RemoteConnection} is requesting ringback. |
| 618 | * |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 619 | * @return Whether the {@code RemoteConnection} is requesting that the framework play a |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 620 | * ringback tone on its behalf. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 621 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 622 | public boolean isRingbackRequested() { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 623 | return false; |
| 624 | } |
| 625 | |
| 626 | /** |
| 627 | * Instructs this {@code RemoteConnection} to abort. |
| 628 | */ |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 629 | public void abort() { |
| 630 | try { |
| 631 | if (mConnected) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 632 | mConnectionService.abort(mConnectionId); |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 633 | } |
| 634 | } catch (RemoteException ignored) { |
| 635 | } |
| 636 | } |
| 637 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 638 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 639 | * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer. |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 640 | */ |
| 641 | public void answer() { |
| 642 | try { |
| 643 | if (mConnected) { |
| 644 | mConnectionService.answer(mConnectionId); |
| 645 | } |
| 646 | } catch (RemoteException ignored) { |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 652 | * @param videoState The video state in which to answer the call. |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 653 | * @hide |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 654 | */ |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 655 | public void answer(int videoState) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 656 | try { |
| 657 | if (mConnected) { |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 658 | mConnectionService.answerVideo(mConnectionId, videoState); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 659 | } |
| 660 | } catch (RemoteException ignored) { |
| 661 | } |
| 662 | } |
| 663 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 664 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 665 | * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to reject. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 666 | */ |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 667 | public void reject() { |
| 668 | try { |
| 669 | if (mConnected) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 670 | mConnectionService.reject(mConnectionId); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 671 | } |
| 672 | } catch (RemoteException ignored) { |
| 673 | } |
| 674 | } |
| 675 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 676 | /** |
| 677 | * Instructs this {@code RemoteConnection} to go on hold. |
| 678 | */ |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 679 | public void hold() { |
| 680 | try { |
| 681 | if (mConnected) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 682 | mConnectionService.hold(mConnectionId); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 683 | } |
| 684 | } catch (RemoteException ignored) { |
| 685 | } |
| 686 | } |
| 687 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 688 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 689 | * Instructs this {@link Connection#STATE_HOLDING} call to release from hold. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 690 | */ |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 691 | public void unhold() { |
| 692 | try { |
| 693 | if (mConnected) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 694 | mConnectionService.unhold(mConnectionId); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 695 | } |
| 696 | } catch (RemoteException ignored) { |
| 697 | } |
| 698 | } |
| 699 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 700 | /** |
| 701 | * Instructs this {@code RemoteConnection} to disconnect. |
| 702 | */ |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 703 | public void disconnect() { |
| 704 | try { |
| 705 | if (mConnected) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 706 | mConnectionService.disconnect(mConnectionId); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 707 | } |
| 708 | } catch (RemoteException ignored) { |
| 709 | } |
| 710 | } |
| 711 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 712 | /** |
| 713 | * Instructs this {@code RemoteConnection} to play a dual-tone multi-frequency signaling |
| 714 | * (DTMF) tone. |
| 715 | * |
| 716 | * Any other currently playing DTMF tone in the specified call is immediately stopped. |
| 717 | * |
| 718 | * @param digit A character representing the DTMF digit for which to play the tone. This |
| 719 | * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}. |
| 720 | */ |
| 721 | public void playDtmfTone(char digit) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 722 | try { |
| 723 | if (mConnected) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 724 | mConnectionService.playDtmfTone(mConnectionId, digit); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 725 | } |
| 726 | } catch (RemoteException ignored) { |
| 727 | } |
| 728 | } |
| 729 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 730 | /** |
| 731 | * Instructs this {@code RemoteConnection} to stop any dual-tone multi-frequency signaling |
| 732 | * (DTMF) tone currently playing. |
| 733 | * |
| 734 | * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is |
| 735 | * currently playing, this method will do nothing. |
| 736 | */ |
| 737 | public void stopDtmfTone() { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 738 | try { |
| 739 | if (mConnected) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 740 | mConnectionService.stopDtmfTone(mConnectionId); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 741 | } |
| 742 | } catch (RemoteException ignored) { |
| 743 | } |
| 744 | } |
| 745 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 746 | /** |
| 747 | * Instructs this {@code RemoteConnection} to continue playing a post-dial DTMF string. |
| 748 | * |
| 749 | * A post-dial DTMF string is a string of digits following the first instance of either |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 750 | * {@link TelecomManager#DTMF_CHARACTER_WAIT} or {@link TelecomManager#DTMF_CHARACTER_PAUSE}. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 751 | * These digits are immediately sent as DTMF tones to the recipient as soon as the |
| 752 | * connection is made. |
| 753 | * |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 754 | * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 755 | * {@code RemoteConnection} will temporarily pause playing the tones for a pre-defined period |
| 756 | * of time. |
| 757 | * |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 758 | * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 759 | * {@code RemoteConnection} will pause playing the tones and notify callbacks via |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 760 | * {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 761 | * should display to the user an indication of this state and an affordance to continue |
| 762 | * the postdial sequence. When the user decides to continue the postdial sequence, the in-call |
| 763 | * app should invoke the {@link #postDialContinue(boolean)} method. |
| 764 | * |
| 765 | * @param proceed Whether or not to continue with the post-dial sequence. |
| 766 | */ |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 767 | public void postDialContinue(boolean proceed) { |
| 768 | try { |
| 769 | if (mConnected) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 770 | mConnectionService.onPostDialContinue(mConnectionId, proceed); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 771 | } |
| 772 | } catch (RemoteException ignored) { |
| 773 | } |
| 774 | } |
| 775 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 776 | /** |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 777 | * Set the audio state of this {@code RemoteConnection}. |
| 778 | * |
| 779 | * @param state The audio state of this {@code RemoteConnection}. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame^] | 780 | * @hide |
| 781 | * @deprecated Use {@link #setCallAudioState(CallAudioState) instead. |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 782 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame^] | 783 | @SystemApi |
| 784 | @Deprecated |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 785 | public void setAudioState(AudioState state) { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame^] | 786 | setCallAudioState(new CallAudioState(state)); |
| 787 | } |
| 788 | |
| 789 | /** |
| 790 | * Set the audio state of this {@code RemoteConnection}. |
| 791 | * |
| 792 | * @param state The audio state of this {@code RemoteConnection}. |
| 793 | */ |
| 794 | public void setCallAudioState(CallAudioState state) { |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 795 | try { |
| 796 | if (mConnected) { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame^] | 797 | mConnectionService.onCallAudioStateChanged(mConnectionId, state); |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 798 | } |
| 799 | } catch (RemoteException ignored) { |
| 800 | } |
| 801 | } |
| 802 | |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 803 | /** |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 804 | * Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be |
| 805 | * successfully asked to create a conference with. |
| 806 | * |
| 807 | * @return The {@code RemoteConnection}s with which this {@code RemoteConnection} may be |
| 808 | * merged into a {@link RemoteConference}. |
| 809 | */ |
| 810 | public List<RemoteConnection> getConferenceableConnections() { |
| 811 | return mUnmodifiableconferenceableConnections; |
| 812 | } |
| 813 | |
| 814 | /** |
| 815 | * Obtain the {@code RemoteConference} that this {@code RemoteConnection} may be a part |
| 816 | * of, or {@code null} if there is no such {@code RemoteConference}. |
| 817 | * |
| 818 | * @return A {@code RemoteConference} or {@code null}; |
| 819 | */ |
| 820 | public RemoteConference getConference() { |
| 821 | return mConference; |
| 822 | } |
| 823 | |
| 824 | /** {@hide} */ |
| 825 | String getId() { |
| 826 | return mConnectionId; |
| 827 | } |
| 828 | |
| 829 | /** {@hide} */ |
| 830 | IConnectionService getConnectionService() { |
| 831 | return mConnectionService; |
| 832 | } |
| 833 | |
| 834 | /** |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 835 | * @hide |
| 836 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 837 | void setState(final int state) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 838 | if (mState != state) { |
| 839 | mState = state; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 840 | for (CallbackRecord record: mCallbackRecords) { |
| 841 | final RemoteConnection connection = this; |
| 842 | final Callback callback = record.getCallback(); |
| 843 | record.getHandler().post(new Runnable() { |
| 844 | @Override |
| 845 | public void run() { |
| 846 | callback.onStateChanged(connection, state); |
| 847 | } |
| 848 | }); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 849 | } |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | /** |
| 854 | * @hide |
| 855 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 856 | void setDisconnected(final DisconnectCause disconnectCause) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 857 | if (mState != Connection.STATE_DISCONNECTED) { |
| 858 | mState = Connection.STATE_DISCONNECTED; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 859 | mDisconnectCause = disconnectCause; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 860 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 861 | for (CallbackRecord record : mCallbackRecords) { |
| 862 | final RemoteConnection connection = this; |
| 863 | final Callback callback = record.getCallback(); |
| 864 | record.getHandler().post(new Runnable() { |
| 865 | @Override |
| 866 | public void run() { |
| 867 | callback.onDisconnected(connection, disconnectCause); |
| 868 | } |
| 869 | }); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 870 | } |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | /** |
| 875 | * @hide |
| 876 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 877 | void setRingbackRequested(final boolean ringback) { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 878 | if (mRingbackRequested != ringback) { |
| 879 | mRingbackRequested = ringback; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 880 | for (CallbackRecord record : mCallbackRecords) { |
| 881 | final RemoteConnection connection = this; |
| 882 | final Callback callback = record.getCallback(); |
| 883 | record.getHandler().post(new Runnable() { |
| 884 | @Override |
| 885 | public void run() { |
| 886 | callback.onRingbackRequested(connection, ringback); |
| 887 | } |
| 888 | }); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 889 | } |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | /** |
| 894 | * @hide |
| 895 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 896 | void setConnectionCapabilities(final int connectionCapabilities) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 897 | mConnectionCapabilities = connectionCapabilities; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 898 | for (CallbackRecord record : mCallbackRecords) { |
| 899 | final RemoteConnection connection = this; |
| 900 | final Callback callback = record.getCallback(); |
| 901 | record.getHandler().post(new Runnable() { |
| 902 | @Override |
| 903 | public void run() { |
| 904 | callback.onConnectionCapabilitiesChanged(connection, connectionCapabilities); |
| 905 | } |
| 906 | }); |
Sailesh Nepal | 1a7061b | 2014-07-09 21:03:20 -0700 | [diff] [blame] | 907 | } |
| 908 | } |
| 909 | |
| 910 | /** |
| 911 | * @hide |
| 912 | */ |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 913 | void setDestroyed() { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 914 | if (!mCallbackRecords.isEmpty()) { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 915 | // Make sure that the callbacks are notified that the call is destroyed first. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 916 | if (mState != Connection.STATE_DISCONNECTED) { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 917 | setDisconnected( |
| 918 | new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed.")); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 919 | } |
| 920 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 921 | for (CallbackRecord record : mCallbackRecords) { |
| 922 | final RemoteConnection connection = this; |
| 923 | final Callback callback = record.getCallback(); |
| 924 | record.getHandler().post(new Runnable() { |
| 925 | @Override |
| 926 | public void run() { |
| 927 | callback.onDestroyed(connection); |
| 928 | } |
| 929 | }); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 930 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 931 | mCallbackRecords.clear(); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 932 | |
| 933 | mConnected = false; |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | /** |
| 938 | * @hide |
| 939 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 940 | void setPostDialWait(final String remainingDigits) { |
| 941 | for (CallbackRecord record : mCallbackRecords) { |
| 942 | final RemoteConnection connection = this; |
| 943 | final Callback callback = record.getCallback(); |
| 944 | record.getHandler().post(new Runnable() { |
| 945 | @Override |
| 946 | public void run() { |
| 947 | callback.onPostDialWait(connection, remainingDigits); |
| 948 | } |
| 949 | }); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 950 | } |
| 951 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 952 | |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 953 | /** |
| 954 | * @hide |
| 955 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 956 | void onPostDialChar(final char nextChar) { |
| 957 | for (CallbackRecord record : mCallbackRecords) { |
| 958 | final RemoteConnection connection = this; |
| 959 | final Callback callback = record.getCallback(); |
| 960 | record.getHandler().post(new Runnable() { |
| 961 | @Override |
| 962 | public void run() { |
| 963 | callback.onPostDialWait(connection, String.valueOf(nextChar)); |
| 964 | } |
| 965 | }); |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 966 | } |
| 967 | } |
| 968 | |
| 969 | /** |
| 970 | * @hide |
| 971 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 972 | void setVideoState(final int videoState) { |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 973 | mVideoState = videoState; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 974 | for (CallbackRecord record : mCallbackRecords) { |
| 975 | final RemoteConnection connection = this; |
| 976 | final Callback callback = record.getCallback(); |
| 977 | record.getHandler().post(new Runnable() { |
| 978 | @Override |
| 979 | public void run() { |
| 980 | callback.onVideoStateChanged(connection, videoState); |
| 981 | } |
| 982 | }); |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 983 | } |
| 984 | } |
| 985 | |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 986 | /** |
| 987 | * @hide |
| 988 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 989 | void setVideoProvider(final VideoProvider videoProvider) { |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 990 | mVideoProvider = videoProvider; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 991 | for (CallbackRecord record : mCallbackRecords) { |
| 992 | final RemoteConnection connection = this; |
| 993 | final Callback callback = record.getCallback(); |
| 994 | record.getHandler().post(new Runnable() { |
| 995 | @Override |
| 996 | public void run() { |
| 997 | callback.onVideoProviderChanged(connection, videoProvider); |
| 998 | } |
| 999 | }); |
Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 1000 | } |
| 1001 | } |
| 1002 | |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1003 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1004 | void setIsVoipAudioMode(final boolean isVoip) { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1005 | mIsVoipAudioMode = isVoip; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1006 | for (CallbackRecord record : mCallbackRecords) { |
| 1007 | final RemoteConnection connection = this; |
| 1008 | final Callback callback = record.getCallback(); |
| 1009 | record.getHandler().post(new Runnable() { |
| 1010 | @Override |
| 1011 | public void run() { |
| 1012 | callback.onVoipAudioChanged(connection, isVoip); |
| 1013 | } |
| 1014 | }); |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1015 | } |
| 1016 | } |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1017 | |
| 1018 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1019 | void setStatusHints(final StatusHints statusHints) { |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1020 | mStatusHints = statusHints; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1021 | for (CallbackRecord record : mCallbackRecords) { |
| 1022 | final RemoteConnection connection = this; |
| 1023 | final Callback callback = record.getCallback(); |
| 1024 | record.getHandler().post(new Runnable() { |
| 1025 | @Override |
| 1026 | public void run() { |
| 1027 | callback.onStatusHintsChanged(connection, statusHints); |
| 1028 | } |
| 1029 | }); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1034 | void setAddress(final Uri address, final int presentation) { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1035 | mAddress = address; |
| 1036 | mAddressPresentation = presentation; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1037 | for (CallbackRecord record : mCallbackRecords) { |
| 1038 | final RemoteConnection connection = this; |
| 1039 | final Callback callback = record.getCallback(); |
| 1040 | record.getHandler().post(new Runnable() { |
| 1041 | @Override |
| 1042 | public void run() { |
| 1043 | callback.onAddressChanged(connection, address, presentation); |
| 1044 | } |
| 1045 | }); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1050 | void setCallerDisplayName(final String callerDisplayName, final int presentation) { |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1051 | mCallerDisplayName = callerDisplayName; |
| 1052 | mCallerDisplayNamePresentation = presentation; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1053 | for (CallbackRecord record : mCallbackRecords) { |
| 1054 | final RemoteConnection connection = this; |
| 1055 | final Callback callback = record.getCallback(); |
| 1056 | record.getHandler().post(new Runnable() { |
| 1057 | @Override |
| 1058 | public void run() { |
| 1059 | callback.onCallerDisplayNameChanged( |
| 1060 | connection, callerDisplayName, presentation); |
| 1061 | } |
| 1062 | }); |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1063 | } |
| 1064 | } |
Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 1065 | |
| 1066 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1067 | void setConferenceableConnections(final List<RemoteConnection> conferenceableConnections) { |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1068 | mConferenceableConnections.clear(); |
| 1069 | mConferenceableConnections.addAll(conferenceableConnections); |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1070 | for (CallbackRecord record : mCallbackRecords) { |
| 1071 | final RemoteConnection connection = this; |
| 1072 | final Callback callback = record.getCallback(); |
| 1073 | record.getHandler().post(new Runnable() { |
| 1074 | @Override |
| 1075 | public void run() { |
| 1076 | callback.onConferenceableConnectionsChanged( |
| 1077 | connection, mUnmodifiableconferenceableConnections); |
| 1078 | } |
| 1079 | }); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1084 | void setConference(final RemoteConference conference) { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1085 | if (mConference != conference) { |
| 1086 | mConference = conference; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1087 | for (CallbackRecord record : mCallbackRecords) { |
| 1088 | final RemoteConnection connection = this; |
| 1089 | final Callback callback = record.getCallback(); |
| 1090 | record.getHandler().post(new Runnable() { |
| 1091 | @Override |
| 1092 | public void run() { |
| 1093 | callback.onConferenceChanged(connection, conference); |
| 1094 | } |
| 1095 | }); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1096 | } |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1097 | } |
| 1098 | } |
| 1099 | |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1100 | /** |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1101 | * Create a RemoteConnection represents a failure, and which will be in |
| 1102 | * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost |
| 1103 | * certainly result in bad things happening. Do not do this. |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1104 | * |
| 1105 | * @return a failed {@link RemoteConnection} |
| 1106 | * |
| 1107 | * @hide |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1108 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1109 | public static RemoteConnection failure(DisconnectCause disconnectCause) { |
| 1110 | return new RemoteConnection(disconnectCause); |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1111 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1112 | |
| 1113 | private static final class CallbackRecord extends Callback { |
| 1114 | private final Callback mCallback; |
| 1115 | private final Handler mHandler; |
| 1116 | |
| 1117 | public CallbackRecord(Callback callback, Handler handler) { |
| 1118 | mCallback = callback; |
| 1119 | mHandler = handler; |
| 1120 | } |
| 1121 | |
| 1122 | public Callback getCallback() { |
| 1123 | return mCallback; |
| 1124 | } |
| 1125 | |
| 1126 | public Handler getHandler() { |
| 1127 | return mHandler; |
| 1128 | } |
| 1129 | } |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1130 | } |