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