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