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