| 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 | |
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame^] | 413 | private final int mTargetSdkVersion; |
| 414 | |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 415 | /** |
| 416 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 417 | * load factor before resizing, 1 means we only expect a single thread to |
| 418 | * access the map so make only a single shard |
| 419 | */ |
| Tyler Gunn | a2df925 | 2015-05-29 10:05:46 -0700 | [diff] [blame] | 420 | private final Set<Callback> mCallbacks = Collections.newSetFromMap( |
| 421 | new ConcurrentHashMap<Callback, Boolean>(8, 0.9f, 1)); |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 422 | |
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame^] | 423 | VideoProvider(IVideoProvider videoProviderBinder, String callingPackage, |
| 424 | int targetSdkVersion) { |
| 425 | |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 426 | mVideoProviderBinder = videoProviderBinder; |
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 427 | mCallingPackage = callingPackage; |
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame^] | 428 | mTargetSdkVersion = targetSdkVersion; |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 429 | try { |
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 430 | mVideoProviderBinder.addVideoCallback(mVideoCallbackServant.getStub().asBinder()); |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 431 | } catch (RemoteException e) { |
| 432 | } |
| 433 | } |
| 434 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 435 | /** |
| 436 | * Registers a callback to receive commands and state changes for video calls. |
| 437 | * |
| 438 | * @param l The video call callback. |
| 439 | */ |
| Tyler Gunn | a2df925 | 2015-05-29 10:05:46 -0700 | [diff] [blame] | 440 | public void registerCallback(Callback l) { |
| 441 | mCallbacks.add(l); |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 442 | } |
| 443 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 444 | /** |
| 445 | * Clears the video call callback set via {@link #registerCallback}. |
| 446 | * |
| 447 | * @param l The video call callback to clear. |
| 448 | */ |
| Tyler Gunn | a2df925 | 2015-05-29 10:05:46 -0700 | [diff] [blame] | 449 | public void unregisterCallback(Callback l) { |
| 450 | mCallbacks.remove(l); |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 451 | } |
| 452 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 453 | /** |
| 454 | * Sets the camera to be used for the outgoing video for the |
| 455 | * {@link RemoteConnection.VideoProvider}. |
| 456 | * |
| 457 | * @param cameraId The id of the camera (use ids as reported by |
| 458 | * {@link CameraManager#getCameraIdList()}). |
| 459 | * @see Connection.VideoProvider#onSetCamera(String) |
| 460 | */ |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 461 | public void setCamera(String cameraId) { |
| 462 | try { |
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame^] | 463 | mVideoProviderBinder.setCamera(cameraId, mCallingPackage, mTargetSdkVersion); |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 464 | } catch (RemoteException e) { |
| 465 | } |
| 466 | } |
| 467 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 468 | /** |
| 469 | * Sets the surface to be used for displaying a preview of what the user's camera is |
| 470 | * currently capturing for the {@link RemoteConnection.VideoProvider}. |
| 471 | * |
| 472 | * @param surface The {@link Surface}. |
| 473 | * @see Connection.VideoProvider#onSetPreviewSurface(Surface) |
| 474 | */ |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 475 | public void setPreviewSurface(Surface surface) { |
| 476 | try { |
| 477 | mVideoProviderBinder.setPreviewSurface(surface); |
| 478 | } catch (RemoteException e) { |
| 479 | } |
| 480 | } |
| 481 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 482 | /** |
| 483 | * Sets the surface to be used for displaying the video received from the remote device for |
| 484 | * the {@link RemoteConnection.VideoProvider}. |
| 485 | * |
| 486 | * @param surface The {@link Surface}. |
| 487 | * @see Connection.VideoProvider#onSetDisplaySurface(Surface) |
| 488 | */ |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 489 | public void setDisplaySurface(Surface surface) { |
| 490 | try { |
| 491 | mVideoProviderBinder.setDisplaySurface(surface); |
| 492 | } catch (RemoteException e) { |
| 493 | } |
| 494 | } |
| 495 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 496 | /** |
| 497 | * Sets the device orientation, in degrees, for the {@link RemoteConnection.VideoProvider}. |
| 498 | * Assumes that a standard portrait orientation of the device is 0 degrees. |
| 499 | * |
| 500 | * @param rotation The device orientation, in degrees. |
| 501 | * @see Connection.VideoProvider#onSetDeviceOrientation(int) |
| 502 | */ |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 503 | public void setDeviceOrientation(int rotation) { |
| 504 | try { |
| 505 | mVideoProviderBinder.setDeviceOrientation(rotation); |
| 506 | } catch (RemoteException e) { |
| 507 | } |
| 508 | } |
| 509 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 510 | /** |
| 511 | * Sets camera zoom ratio for the {@link RemoteConnection.VideoProvider}. |
| 512 | * |
| 513 | * @param value The camera zoom ratio. |
| 514 | * @see Connection.VideoProvider#onSetZoom(float) |
| 515 | */ |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 516 | public void setZoom(float value) { |
| 517 | try { |
| 518 | mVideoProviderBinder.setZoom(value); |
| 519 | } catch (RemoteException e) { |
| 520 | } |
| 521 | } |
| 522 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 523 | /** |
| 524 | * Issues a request to modify the properties of the current video session for the |
| 525 | * {@link RemoteConnection.VideoProvider}. |
| 526 | * |
| 527 | * @param fromProfile The video profile prior to the request. |
| 528 | * @param toProfile The video profile with the requested changes made. |
| 529 | * @see Connection.VideoProvider#onSendSessionModifyRequest(VideoProfile, VideoProfile) |
| 530 | */ |
| Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 531 | public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 532 | try { |
| Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 533 | mVideoProviderBinder.sendSessionModifyRequest(fromProfile, toProfile); |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 534 | } catch (RemoteException e) { |
| 535 | } |
| 536 | } |
| 537 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 538 | /** |
| 539 | * Provides a response to a request to change the current call video session |
| 540 | * properties for the {@link RemoteConnection.VideoProvider}. |
| 541 | * |
| 542 | * @param responseProfile The response call video properties. |
| 543 | * @see Connection.VideoProvider#onSendSessionModifyResponse(VideoProfile) |
| 544 | */ |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 545 | public void sendSessionModifyResponse(VideoProfile responseProfile) { |
| 546 | try { |
| 547 | mVideoProviderBinder.sendSessionModifyResponse(responseProfile); |
| 548 | } catch (RemoteException e) { |
| 549 | } |
| 550 | } |
| 551 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 552 | /** |
| 553 | * Issues a request to retrieve the capabilities of the current camera for the |
| 554 | * {@link RemoteConnection.VideoProvider}. |
| 555 | * |
| 556 | * @see Connection.VideoProvider#onRequestCameraCapabilities() |
| 557 | */ |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 558 | public void requestCameraCapabilities() { |
| 559 | try { |
| 560 | mVideoProviderBinder.requestCameraCapabilities(); |
| 561 | } catch (RemoteException e) { |
| 562 | } |
| 563 | } |
| 564 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 565 | /** |
| 566 | * Issues a request to retrieve the data usage (in bytes) of the video portion of the |
| 567 | * {@link RemoteConnection} for the {@link RemoteConnection.VideoProvider}. |
| 568 | * |
| 569 | * @see Connection.VideoProvider#onRequestConnectionDataUsage() |
| 570 | */ |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 571 | public void requestCallDataUsage() { |
| 572 | try { |
| 573 | mVideoProviderBinder.requestCallDataUsage(); |
| 574 | } catch (RemoteException e) { |
| 575 | } |
| 576 | } |
| 577 | |
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 578 | /** |
| 579 | * Sets the {@link Uri} of an image to be displayed to the peer device when the video signal |
| 580 | * is paused, for the {@link RemoteConnection.VideoProvider}. |
| 581 | * |
| 582 | * @see Connection.VideoProvider#onSetPauseImage(Uri) |
| 583 | */ |
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 584 | public void setPauseImage(Uri uri) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 585 | try { |
| 586 | mVideoProviderBinder.setPauseImage(uri); |
| 587 | } catch (RemoteException e) { |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 592 | private IConnectionService mConnectionService; |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 593 | private final String mConnectionId; |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 594 | /** |
| 595 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 596 | * load factor before resizing, 1 means we only expect a single thread to |
| 597 | * access the map so make only a single shard |
| 598 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 599 | private final Set<CallbackRecord> mCallbackRecords = Collections.newSetFromMap( |
| 600 | new ConcurrentHashMap<CallbackRecord, Boolean>(8, 0.9f, 1)); |
| Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 601 | private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>(); |
| 602 | private final List<RemoteConnection> mUnmodifiableconferenceableConnections = |
| 603 | Collections.unmodifiableList(mConferenceableConnections); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 604 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 605 | private int mState = Connection.STATE_NEW; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 606 | private DisconnectCause mDisconnectCause; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 607 | private boolean mRingbackRequested; |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 608 | private boolean mConnected; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 609 | private int mConnectionCapabilities; |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 610 | private int mConnectionProperties; |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 611 | private int mVideoState; |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 612 | private VideoProvider mVideoProvider; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 613 | private boolean mIsVoipAudioMode; |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 614 | private StatusHints mStatusHints; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 615 | private Uri mAddress; |
| 616 | private int mAddressPresentation; |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 617 | private String mCallerDisplayName; |
| 618 | private int mCallerDisplayNamePresentation; |
| Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 619 | private RemoteConference mConference; |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 620 | private Bundle mExtras; |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 621 | |
| 622 | /** |
| 623 | * @hide |
| 624 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 625 | RemoteConnection( |
| 626 | String id, |
| 627 | IConnectionService connectionService, |
| 628 | ConnectionRequest request) { |
| 629 | mConnectionId = id; |
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 630 | mConnectionService = connectionService; |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 631 | mConnected = true; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 632 | mState = Connection.STATE_INITIALIZING; |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | /** |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 636 | * @hide |
| 637 | */ |
| 638 | RemoteConnection(String callId, IConnectionService connectionService, |
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame^] | 639 | ParcelableConnection connection, String callingPackage, int targetSdkVersion) { |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 640 | mConnectionId = callId; |
| 641 | mConnectionService = connectionService; |
| 642 | mConnected = true; |
| 643 | mState = connection.getState(); |
| 644 | mDisconnectCause = connection.getDisconnectCause(); |
| 645 | mRingbackRequested = connection.isRingbackRequested(); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 646 | mConnectionCapabilities = connection.getConnectionCapabilities(); |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 647 | mConnectionProperties = connection.getConnectionProperties(); |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 648 | mVideoState = connection.getVideoState(); |
| Tyler Gunn | 9c2c583 | 2016-09-16 15:08:50 -0700 | [diff] [blame] | 649 | IVideoProvider videoProvider = connection.getVideoProvider(); |
| 650 | if (videoProvider != null) { |
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame^] | 651 | mVideoProvider = new RemoteConnection.VideoProvider(videoProvider, callingPackage, |
| 652 | targetSdkVersion); |
| Tyler Gunn | 9c2c583 | 2016-09-16 15:08:50 -0700 | [diff] [blame] | 653 | } else { |
| 654 | mVideoProvider = null; |
| 655 | } |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 656 | mIsVoipAudioMode = connection.getIsVoipAudioMode(); |
| 657 | mStatusHints = connection.getStatusHints(); |
| 658 | mAddress = connection.getHandle(); |
| 659 | mAddressPresentation = connection.getHandlePresentation(); |
| 660 | mCallerDisplayName = connection.getCallerDisplayName(); |
| 661 | mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation(); |
| 662 | mConference = null; |
| Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 663 | putExtras(connection.getExtras()); |
| 664 | |
| 665 | // Stash the original connection ID as it exists in the source ConnectionService. |
| 666 | // Telecom will use this to avoid adding duplicates later. |
| 667 | // See comments on Connection.EXTRA_ORIGINAL_CONNECTION_ID for more information. |
| 668 | Bundle newExtras = new Bundle(); |
| 669 | newExtras.putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId); |
| 670 | putExtras(newExtras); |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | /** |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 674 | * Create a RemoteConnection which is used for failed connections. Note that using it for any |
| 675 | * "real" purpose will almost certainly fail. Callers should note the failure and act |
| 676 | * accordingly (moving on to another RemoteConnection, for example) |
| 677 | * |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 678 | * @param disconnectCause The reason for the failed connection. |
| 679 | * @hide |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 680 | */ |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 681 | RemoteConnection(DisconnectCause disconnectCause) { |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 682 | mConnectionId = "NULL"; |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 683 | mConnected = false; |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 684 | mState = Connection.STATE_DISCONNECTED; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 685 | mDisconnectCause = disconnectCause; |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 686 | } |
| 687 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 688 | /** |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 689 | * Adds a callback to this {@code RemoteConnection}. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 690 | * |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 691 | * @param callback A {@code Callback}. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 692 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 693 | public void registerCallback(Callback callback) { |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 694 | registerCallback(callback, new Handler()); |
| 695 | } |
| 696 | |
| 697 | /** |
| 698 | * Adds a callback to this {@code RemoteConnection}. |
| 699 | * |
| 700 | * @param callback A {@code Callback}. |
| 701 | * @param handler A {@code Handler} which command and status changes will be delivered to. |
| 702 | */ |
| 703 | public void registerCallback(Callback callback, Handler handler) { |
| 704 | unregisterCallback(callback); |
| 705 | if (callback != null && handler != null) { |
| 706 | mCallbackRecords.add(new CallbackRecord(callback, handler)); |
| 707 | } |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 708 | } |
| 709 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 710 | /** |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 711 | * Removes a callback from this {@code RemoteConnection}. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 712 | * |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 713 | * @param callback A {@code Callback}. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 714 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 715 | public void unregisterCallback(Callback callback) { |
| 716 | if (callback != null) { |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 717 | for (CallbackRecord record : mCallbackRecords) { |
| 718 | if (record.getCallback() == callback) { |
| 719 | mCallbackRecords.remove(record); |
| 720 | break; |
| 721 | } |
| 722 | } |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 723 | } |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 724 | } |
| 725 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 726 | /** |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 727 | * Obtains the state of this {@code RemoteConnection}. |
| 728 | * |
| 729 | * @return A state value, chosen from the {@code STATE_*} constants. |
| 730 | */ |
| Sailesh Nepal | ade3f25 | 2014-07-01 17:25:37 -0700 | [diff] [blame] | 731 | public int getState() { |
| 732 | return mState; |
| 733 | } |
| 734 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 735 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 736 | * Obtains the reason why this {@code RemoteConnection} may have been disconnected. |
| 737 | * |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 738 | * @return For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 739 | * disconnect cause expressed as a code chosen from among those declared in |
| 740 | * {@link DisconnectCause}. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 741 | */ |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 742 | public DisconnectCause getDisconnectCause() { |
| 743 | return mDisconnectCause; |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -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 capabilities of this {@code RemoteConnection}. |
| 748 | * |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 749 | * @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] | 750 | * the {@code CAPABILITY_*} constants in class {@link Connection}. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 751 | */ |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 752 | public int getConnectionCapabilities() { |
| 753 | return mConnectionCapabilities; |
| Sailesh Nepal | 1a7061b | 2014-07-09 21:03:20 -0700 | [diff] [blame] | 754 | } |
| 755 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 756 | /** |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 757 | * Obtains the properties of this {@code RemoteConnection}. |
| 758 | * |
| 759 | * @return A bitmask of the properties of the {@code RemoteConnection}, as defined in the |
| 760 | * {@code PROPERTY_*} constants in class {@link Connection}. |
| 761 | */ |
| 762 | public int getConnectionProperties() { |
| 763 | return mConnectionProperties; |
| 764 | } |
| 765 | |
| 766 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 767 | * Determines if the audio mode of this {@code RemoteConnection} is VOIP. |
| 768 | * |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 769 | * @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP. |
| 770 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 771 | public boolean isVoipAudioMode() { |
| 772 | return mIsVoipAudioMode; |
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 773 | } |
| 774 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 775 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 776 | * Obtains status hints pertaining to this {@code RemoteConnection}. |
| 777 | * |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 778 | * @return The current {@link StatusHints} of this {@code RemoteConnection}, |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 779 | * or {@code null} if none have been set. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 780 | */ |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 781 | public StatusHints getStatusHints() { |
| 782 | return mStatusHints; |
| 783 | } |
| 784 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 785 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 786 | * Obtains the address of this {@code RemoteConnection}. |
| 787 | * |
| 788 | * @return The address (e.g., phone number) to which the {@code RemoteConnection} |
| 789 | * is currently connected. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 790 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 791 | public Uri getAddress() { |
| 792 | return mAddress; |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 793 | } |
| 794 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 795 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 796 | * Obtains the presentation requirements for the address of this {@code RemoteConnection}. |
| 797 | * |
| 798 | * @return The presentation requirements for the address. See |
| 799 | * {@link TelecomManager} for valid values. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 800 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 801 | public int getAddressPresentation() { |
| 802 | return mAddressPresentation; |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 803 | } |
| 804 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 805 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 806 | * Obtains the display name for this {@code RemoteConnection}'s caller. |
| 807 | * |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 808 | * @return The display name for the caller. |
| 809 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 810 | public CharSequence getCallerDisplayName() { |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 811 | return mCallerDisplayName; |
| 812 | } |
| 813 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 814 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 815 | * Obtains the presentation requirements for this {@code RemoteConnection}'s |
| 816 | * caller's display name. |
| 817 | * |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 818 | * @return The presentation requirements for the caller display name. See |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 819 | * {@link TelecomManager} for valid values. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 820 | */ |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 821 | public int getCallerDisplayNamePresentation() { |
| 822 | return mCallerDisplayNamePresentation; |
| 823 | } |
| 824 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 825 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 826 | * Obtains the video state of this {@code RemoteConnection}. |
| 827 | * |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 828 | * @return The video state of the {@code RemoteConnection}. See {@link VideoProfile}. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 829 | */ |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 830 | public int getVideoState() { |
| 831 | return mVideoState; |
| 832 | } |
| 833 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 834 | /** |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 835 | * Obtains the video provider of this {@code RemoteConnection}. |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 836 | * @return The video provider associated with this {@code RemoteConnection}. |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 837 | */ |
| 838 | public final VideoProvider getVideoProvider() { |
| 839 | return mVideoProvider; |
| 840 | } |
| 841 | |
| 842 | /** |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 843 | * Obtain the extras associated with this {@code RemoteConnection}. |
| 844 | * |
| 845 | * @return The extras for this connection. |
| 846 | */ |
| 847 | public final Bundle getExtras() { |
| 848 | return mExtras; |
| 849 | } |
| 850 | |
| 851 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 852 | * Determines whether this {@code RemoteConnection} is requesting ringback. |
| 853 | * |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 854 | * @return Whether the {@code RemoteConnection} is requesting that the framework play a |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 855 | * ringback tone on its behalf. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 856 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 857 | public boolean isRingbackRequested() { |
| Santos Cordon | 15d63c7 | 2015-06-02 15:08:26 -0700 | [diff] [blame] | 858 | return mRingbackRequested; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | /** |
| 862 | * Instructs this {@code RemoteConnection} to abort. |
| 863 | */ |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 864 | public void abort() { |
| 865 | try { |
| 866 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 867 | mConnectionService.abort(mConnectionId, null /*Session.Info*/); |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 868 | } |
| 869 | } catch (RemoteException ignored) { |
| 870 | } |
| 871 | } |
| 872 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 873 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 874 | * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer. |
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 875 | */ |
| 876 | public void answer() { |
| 877 | try { |
| 878 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 879 | mConnectionService.answer(mConnectionId, null /*Session.Info*/); |
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 880 | } |
| 881 | } catch (RemoteException ignored) { |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | /** |
| 886 | * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 887 | * @param videoState The video state in which to answer the call. |
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 888 | * @hide |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 889 | */ |
| Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 890 | public void answer(int videoState) { |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 891 | try { |
| 892 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 893 | mConnectionService.answerVideo(mConnectionId, videoState, null /*Session.Info*/); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 894 | } |
| 895 | } catch (RemoteException ignored) { |
| 896 | } |
| 897 | } |
| 898 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 899 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 900 | * Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to reject. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 901 | */ |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 902 | public void reject() { |
| 903 | try { |
| 904 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 905 | mConnectionService.reject(mConnectionId, null /*Session.Info*/); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 906 | } |
| 907 | } catch (RemoteException ignored) { |
| 908 | } |
| 909 | } |
| 910 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 911 | /** |
| 912 | * Instructs this {@code RemoteConnection} to go on hold. |
| 913 | */ |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 914 | public void hold() { |
| 915 | try { |
| 916 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 917 | mConnectionService.hold(mConnectionId, null /*Session.Info*/); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 918 | } |
| 919 | } catch (RemoteException ignored) { |
| 920 | } |
| 921 | } |
| 922 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 923 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 924 | * Instructs this {@link Connection#STATE_HOLDING} call to release from hold. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 925 | */ |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 926 | public void unhold() { |
| 927 | try { |
| 928 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 929 | mConnectionService.unhold(mConnectionId, null /*Session.Info*/); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 930 | } |
| 931 | } catch (RemoteException ignored) { |
| 932 | } |
| 933 | } |
| 934 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 935 | /** |
| 936 | * Instructs this {@code RemoteConnection} to disconnect. |
| 937 | */ |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 938 | public void disconnect() { |
| 939 | try { |
| 940 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 941 | mConnectionService.disconnect(mConnectionId, null /*Session.Info*/); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 942 | } |
| 943 | } catch (RemoteException ignored) { |
| 944 | } |
| 945 | } |
| 946 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 947 | /** |
| 948 | * Instructs this {@code RemoteConnection} to play a dual-tone multi-frequency signaling |
| 949 | * (DTMF) tone. |
| 950 | * |
| 951 | * Any other currently playing DTMF tone in the specified call is immediately stopped. |
| 952 | * |
| 953 | * @param digit A character representing the DTMF digit for which to play the tone. This |
| 954 | * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}. |
| 955 | */ |
| 956 | public void playDtmfTone(char digit) { |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 957 | try { |
| 958 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 959 | mConnectionService.playDtmfTone(mConnectionId, digit, null /*Session.Info*/); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 960 | } |
| 961 | } catch (RemoteException ignored) { |
| 962 | } |
| 963 | } |
| 964 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 965 | /** |
| 966 | * Instructs this {@code RemoteConnection} to stop any dual-tone multi-frequency signaling |
| 967 | * (DTMF) tone currently playing. |
| 968 | * |
| 969 | * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is |
| 970 | * currently playing, this method will do nothing. |
| 971 | */ |
| 972 | public void stopDtmfTone() { |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 973 | try { |
| 974 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 975 | mConnectionService.stopDtmfTone(mConnectionId, null /*Session.Info*/); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 976 | } |
| 977 | } catch (RemoteException ignored) { |
| 978 | } |
| 979 | } |
| 980 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 981 | /** |
| 982 | * Instructs this {@code RemoteConnection} to continue playing a post-dial DTMF string. |
| 983 | * |
| 984 | * 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] | 985 | * {@link TelecomManager#DTMF_CHARACTER_WAIT} or {@link TelecomManager#DTMF_CHARACTER_PAUSE}. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 986 | * These digits are immediately sent as DTMF tones to the recipient as soon as the |
| 987 | * connection is made. |
| 988 | * |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 989 | * 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] | 990 | * {@code RemoteConnection} will temporarily pause playing the tones for a pre-defined period |
| 991 | * of time. |
| 992 | * |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 993 | * 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] | 994 | * {@code RemoteConnection} will pause playing the tones and notify callbacks via |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 995 | * {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 996 | * should display to the user an indication of this state and an affordance to continue |
| 997 | * the postdial sequence. When the user decides to continue the postdial sequence, the in-call |
| 998 | * app should invoke the {@link #postDialContinue(boolean)} method. |
| 999 | * |
| 1000 | * @param proceed Whether or not to continue with the post-dial sequence. |
| 1001 | */ |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1002 | public void postDialContinue(boolean proceed) { |
| 1003 | try { |
| 1004 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1005 | mConnectionService.onPostDialContinue(mConnectionId, proceed, |
| 1006 | null /*Session.Info*/); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1007 | } |
| 1008 | } catch (RemoteException ignored) { |
| 1009 | } |
| 1010 | } |
| 1011 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1012 | /** |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1013 | * Instructs this {@link RemoteConnection} to pull itself to the local device. |
| 1014 | * <p> |
| 1015 | * See {@link Call#pullExternalCall()} for more information. |
| 1016 | */ |
| 1017 | public void pullExternalCall() { |
| 1018 | try { |
| 1019 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1020 | mConnectionService.pullExternalCall(mConnectionId, null /*Session.Info*/); |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1021 | } |
| 1022 | } catch (RemoteException ignored) { |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | /** |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1027 | * Set the audio state of this {@code RemoteConnection}. |
| 1028 | * |
| 1029 | * @param state The audio state of this {@code RemoteConnection}. |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1030 | * @hide |
| 1031 | * @deprecated Use {@link #setCallAudioState(CallAudioState) instead. |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1032 | */ |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1033 | @SystemApi |
| 1034 | @Deprecated |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1035 | public void setAudioState(AudioState state) { |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1036 | setCallAudioState(new CallAudioState(state)); |
| 1037 | } |
| 1038 | |
| 1039 | /** |
| 1040 | * Set the audio state of this {@code RemoteConnection}. |
| 1041 | * |
| 1042 | * @param state The audio state of this {@code RemoteConnection}. |
| 1043 | */ |
| 1044 | public void setCallAudioState(CallAudioState state) { |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1045 | try { |
| 1046 | if (mConnected) { |
| Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1047 | mConnectionService.onCallAudioStateChanged(mConnectionId, state, |
| 1048 | null /*Session.Info*/); |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1049 | } |
| 1050 | } catch (RemoteException ignored) { |
| 1051 | } |
| 1052 | } |
| 1053 | |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1054 | /** |
| Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1055 | * Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be |
| 1056 | * successfully asked to create a conference with. |
| 1057 | * |
| 1058 | * @return The {@code RemoteConnection}s with which this {@code RemoteConnection} may be |
| 1059 | * merged into a {@link RemoteConference}. |
| 1060 | */ |
| 1061 | public List<RemoteConnection> getConferenceableConnections() { |
| 1062 | return mUnmodifiableconferenceableConnections; |
| 1063 | } |
| 1064 | |
| 1065 | /** |
| 1066 | * Obtain the {@code RemoteConference} that this {@code RemoteConnection} may be a part |
| 1067 | * of, or {@code null} if there is no such {@code RemoteConference}. |
| 1068 | * |
| 1069 | * @return A {@code RemoteConference} or {@code null}; |
| 1070 | */ |
| 1071 | public RemoteConference getConference() { |
| 1072 | return mConference; |
| 1073 | } |
| 1074 | |
| 1075 | /** {@hide} */ |
| 1076 | String getId() { |
| 1077 | return mConnectionId; |
| 1078 | } |
| 1079 | |
| 1080 | /** {@hide} */ |
| 1081 | IConnectionService getConnectionService() { |
| 1082 | return mConnectionService; |
| 1083 | } |
| 1084 | |
| 1085 | /** |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1086 | * @hide |
| 1087 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1088 | void setState(final int state) { |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1089 | if (mState != state) { |
| 1090 | mState = state; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1091 | for (CallbackRecord record: mCallbackRecords) { |
| 1092 | final RemoteConnection connection = this; |
| 1093 | final Callback callback = record.getCallback(); |
| 1094 | record.getHandler().post(new Runnable() { |
| 1095 | @Override |
| 1096 | public void run() { |
| 1097 | callback.onStateChanged(connection, state); |
| 1098 | } |
| 1099 | }); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1100 | } |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | /** |
| 1105 | * @hide |
| 1106 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1107 | void setDisconnected(final DisconnectCause disconnectCause) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1108 | if (mState != Connection.STATE_DISCONNECTED) { |
| 1109 | mState = Connection.STATE_DISCONNECTED; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1110 | mDisconnectCause = disconnectCause; |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1111 | |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1112 | for (CallbackRecord record : mCallbackRecords) { |
| 1113 | final RemoteConnection connection = this; |
| 1114 | final Callback callback = record.getCallback(); |
| 1115 | record.getHandler().post(new Runnable() { |
| 1116 | @Override |
| 1117 | public void run() { |
| 1118 | callback.onDisconnected(connection, disconnectCause); |
| 1119 | } |
| 1120 | }); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1121 | } |
| 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | /** |
| 1126 | * @hide |
| 1127 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1128 | void setRingbackRequested(final boolean ringback) { |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1129 | if (mRingbackRequested != ringback) { |
| 1130 | mRingbackRequested = ringback; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1131 | for (CallbackRecord record : mCallbackRecords) { |
| 1132 | final RemoteConnection connection = this; |
| 1133 | final Callback callback = record.getCallback(); |
| 1134 | record.getHandler().post(new Runnable() { |
| 1135 | @Override |
| 1136 | public void run() { |
| 1137 | callback.onRingbackRequested(connection, ringback); |
| 1138 | } |
| 1139 | }); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1140 | } |
| 1141 | } |
| 1142 | } |
| 1143 | |
| 1144 | /** |
| 1145 | * @hide |
| 1146 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1147 | void setConnectionCapabilities(final int connectionCapabilities) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1148 | mConnectionCapabilities = connectionCapabilities; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1149 | for (CallbackRecord record : mCallbackRecords) { |
| 1150 | final RemoteConnection connection = this; |
| 1151 | final Callback callback = record.getCallback(); |
| 1152 | record.getHandler().post(new Runnable() { |
| 1153 | @Override |
| 1154 | public void run() { |
| 1155 | callback.onConnectionCapabilitiesChanged(connection, connectionCapabilities); |
| 1156 | } |
| 1157 | }); |
| Sailesh Nepal | 1a7061b | 2014-07-09 21:03:20 -0700 | [diff] [blame] | 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | /** |
| 1162 | * @hide |
| 1163 | */ |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1164 | void setConnectionProperties(final int connectionProperties) { |
| 1165 | mConnectionProperties = connectionProperties; |
| 1166 | for (CallbackRecord record : mCallbackRecords) { |
| 1167 | final RemoteConnection connection = this; |
| 1168 | final Callback callback = record.getCallback(); |
| 1169 | record.getHandler().post(new Runnable() { |
| 1170 | @Override |
| 1171 | public void run() { |
| 1172 | callback.onConnectionPropertiesChanged(connection, connectionProperties); |
| 1173 | } |
| 1174 | }); |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | /** |
| 1179 | * @hide |
| 1180 | */ |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1181 | void setDestroyed() { |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1182 | if (!mCallbackRecords.isEmpty()) { |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1183 | // 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] | 1184 | if (mState != Connection.STATE_DISCONNECTED) { |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1185 | setDisconnected( |
| 1186 | new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed.")); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1187 | } |
| 1188 | |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1189 | for (CallbackRecord record : mCallbackRecords) { |
| 1190 | final RemoteConnection connection = this; |
| 1191 | final Callback callback = record.getCallback(); |
| 1192 | record.getHandler().post(new Runnable() { |
| 1193 | @Override |
| 1194 | public void run() { |
| 1195 | callback.onDestroyed(connection); |
| 1196 | } |
| 1197 | }); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1198 | } |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1199 | mCallbackRecords.clear(); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1200 | |
| 1201 | mConnected = false; |
| 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | /** |
| 1206 | * @hide |
| 1207 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1208 | void setPostDialWait(final String remainingDigits) { |
| 1209 | for (CallbackRecord record : mCallbackRecords) { |
| 1210 | final RemoteConnection connection = this; |
| 1211 | final Callback callback = record.getCallback(); |
| 1212 | record.getHandler().post(new Runnable() { |
| 1213 | @Override |
| 1214 | public void run() { |
| 1215 | callback.onPostDialWait(connection, remainingDigits); |
| 1216 | } |
| 1217 | }); |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1218 | } |
| 1219 | } |
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1220 | |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1221 | /** |
| 1222 | * @hide |
| 1223 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1224 | void onPostDialChar(final char nextChar) { |
| 1225 | for (CallbackRecord record : mCallbackRecords) { |
| 1226 | final RemoteConnection connection = this; |
| 1227 | final Callback callback = record.getCallback(); |
| 1228 | record.getHandler().post(new Runnable() { |
| 1229 | @Override |
| 1230 | public void run() { |
| Sailesh Nepal | 40451b3 | 2015-05-14 17:39:41 -0700 | [diff] [blame] | 1231 | callback.onPostDialChar(connection, nextChar); |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1232 | } |
| 1233 | }); |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | /** |
| 1238 | * @hide |
| 1239 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1240 | void setVideoState(final int videoState) { |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1241 | mVideoState = videoState; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1242 | for (CallbackRecord record : mCallbackRecords) { |
| 1243 | final RemoteConnection connection = this; |
| 1244 | final Callback callback = record.getCallback(); |
| 1245 | record.getHandler().post(new Runnable() { |
| 1246 | @Override |
| 1247 | public void run() { |
| 1248 | callback.onVideoStateChanged(connection, videoState); |
| 1249 | } |
| 1250 | }); |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1251 | } |
| 1252 | } |
| 1253 | |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 1254 | /** |
| 1255 | * @hide |
| 1256 | */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1257 | void setVideoProvider(final VideoProvider videoProvider) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 1258 | mVideoProvider = videoProvider; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1259 | for (CallbackRecord record : mCallbackRecords) { |
| 1260 | final RemoteConnection connection = this; |
| 1261 | final Callback callback = record.getCallback(); |
| 1262 | record.getHandler().post(new Runnable() { |
| 1263 | @Override |
| 1264 | public void run() { |
| 1265 | callback.onVideoProviderChanged(connection, videoProvider); |
| 1266 | } |
| 1267 | }); |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 1268 | } |
| 1269 | } |
| 1270 | |
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1271 | /** @hide */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1272 | void setIsVoipAudioMode(final boolean isVoip) { |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1273 | mIsVoipAudioMode = isVoip; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1274 | for (CallbackRecord record : mCallbackRecords) { |
| 1275 | final RemoteConnection connection = this; |
| 1276 | final Callback callback = record.getCallback(); |
| 1277 | record.getHandler().post(new Runnable() { |
| 1278 | @Override |
| 1279 | public void run() { |
| 1280 | callback.onVoipAudioChanged(connection, isVoip); |
| 1281 | } |
| 1282 | }); |
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1283 | } |
| 1284 | } |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1285 | |
| 1286 | /** @hide */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1287 | void setStatusHints(final StatusHints statusHints) { |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1288 | mStatusHints = statusHints; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1289 | for (CallbackRecord record : mCallbackRecords) { |
| 1290 | final RemoteConnection connection = this; |
| 1291 | final Callback callback = record.getCallback(); |
| 1292 | record.getHandler().post(new Runnable() { |
| 1293 | @Override |
| 1294 | public void run() { |
| 1295 | callback.onStatusHintsChanged(connection, statusHints); |
| 1296 | } |
| 1297 | }); |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1298 | } |
| 1299 | } |
| 1300 | |
| 1301 | /** @hide */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1302 | void setAddress(final Uri address, final int presentation) { |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1303 | mAddress = address; |
| 1304 | mAddressPresentation = presentation; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1305 | for (CallbackRecord record : mCallbackRecords) { |
| 1306 | final RemoteConnection connection = this; |
| 1307 | final Callback callback = record.getCallback(); |
| 1308 | record.getHandler().post(new Runnable() { |
| 1309 | @Override |
| 1310 | public void run() { |
| 1311 | callback.onAddressChanged(connection, address, presentation); |
| 1312 | } |
| 1313 | }); |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | /** @hide */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1318 | void setCallerDisplayName(final String callerDisplayName, final int presentation) { |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1319 | mCallerDisplayName = callerDisplayName; |
| 1320 | mCallerDisplayNamePresentation = presentation; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1321 | for (CallbackRecord record : mCallbackRecords) { |
| 1322 | final RemoteConnection connection = this; |
| 1323 | final Callback callback = record.getCallback(); |
| 1324 | record.getHandler().post(new Runnable() { |
| 1325 | @Override |
| 1326 | public void run() { |
| 1327 | callback.onCallerDisplayNameChanged( |
| 1328 | connection, callerDisplayName, presentation); |
| 1329 | } |
| 1330 | }); |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1331 | } |
| 1332 | } |
| Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 1333 | |
| 1334 | /** @hide */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1335 | void setConferenceableConnections(final List<RemoteConnection> conferenceableConnections) { |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1336 | mConferenceableConnections.clear(); |
| 1337 | mConferenceableConnections.addAll(conferenceableConnections); |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1338 | for (CallbackRecord record : mCallbackRecords) { |
| 1339 | final RemoteConnection connection = this; |
| 1340 | final Callback callback = record.getCallback(); |
| 1341 | record.getHandler().post(new Runnable() { |
| 1342 | @Override |
| 1343 | public void run() { |
| 1344 | callback.onConferenceableConnectionsChanged( |
| 1345 | connection, mUnmodifiableconferenceableConnections); |
| 1346 | } |
| 1347 | }); |
| Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | /** @hide */ |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1352 | void setConference(final RemoteConference conference) { |
| Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1353 | if (mConference != conference) { |
| 1354 | mConference = conference; |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1355 | for (CallbackRecord record : mCallbackRecords) { |
| 1356 | final RemoteConnection connection = this; |
| 1357 | final Callback callback = record.getCallback(); |
| 1358 | record.getHandler().post(new Runnable() { |
| 1359 | @Override |
| 1360 | public void run() { |
| 1361 | callback.onConferenceChanged(connection, conference); |
| 1362 | } |
| 1363 | }); |
| Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1364 | } |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1365 | } |
| 1366 | } |
| 1367 | |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1368 | /** @hide */ |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1369 | void putExtras(final Bundle extras) { |
| Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 1370 | if (extras == null) { |
| 1371 | return; |
| 1372 | } |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1373 | if (mExtras == null) { |
| 1374 | mExtras = new Bundle(); |
| 1375 | } |
| 1376 | mExtras.putAll(extras); |
| 1377 | |
| 1378 | notifyExtrasChanged(); |
| 1379 | } |
| 1380 | |
| 1381 | /** @hide */ |
| 1382 | void removeExtras(List<String> keys) { |
| 1383 | if (mExtras == null || keys == null || keys.isEmpty()) { |
| 1384 | return; |
| 1385 | } |
| 1386 | for (String key : keys) { |
| 1387 | mExtras.remove(key); |
| 1388 | } |
| 1389 | |
| 1390 | notifyExtrasChanged(); |
| 1391 | } |
| 1392 | |
| 1393 | private void notifyExtrasChanged() { |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1394 | for (CallbackRecord record : mCallbackRecords) { |
| 1395 | final RemoteConnection connection = this; |
| 1396 | final Callback callback = record.getCallback(); |
| 1397 | record.getHandler().post(new Runnable() { |
| 1398 | @Override |
| 1399 | public void run() { |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1400 | callback.onExtrasChanged(connection, mExtras); |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1401 | } |
| 1402 | }); |
| 1403 | } |
| 1404 | } |
| 1405 | |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1406 | /** @hide */ |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1407 | void onConnectionEvent(final String event, final Bundle extras) { |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1408 | for (CallbackRecord record : mCallbackRecords) { |
| 1409 | final RemoteConnection connection = this; |
| 1410 | final Callback callback = record.getCallback(); |
| 1411 | record.getHandler().post(new Runnable() { |
| 1412 | @Override |
| 1413 | public void run() { |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1414 | callback.onConnectionEvent(connection, event, extras); |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1415 | } |
| 1416 | }); |
| 1417 | } |
| 1418 | } |
| 1419 | |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1420 | /** |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1421 | * Create a RemoteConnection represents a failure, and which will be in |
| 1422 | * {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost |
| 1423 | * certainly result in bad things happening. Do not do this. |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1424 | * |
| 1425 | * @return a failed {@link RemoteConnection} |
| 1426 | * |
| 1427 | * @hide |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1428 | */ |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1429 | public static RemoteConnection failure(DisconnectCause disconnectCause) { |
| 1430 | return new RemoteConnection(disconnectCause); |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1431 | } |
| Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1432 | |
| 1433 | private static final class CallbackRecord extends Callback { |
| 1434 | private final Callback mCallback; |
| 1435 | private final Handler mHandler; |
| 1436 | |
| 1437 | public CallbackRecord(Callback callback, Handler handler) { |
| 1438 | mCallback = callback; |
| 1439 | mHandler = handler; |
| 1440 | } |
| 1441 | |
| 1442 | public Callback getCallback() { |
| 1443 | return mCallback; |
| 1444 | } |
| 1445 | |
| 1446 | public Handler getHandler() { |
| 1447 | return mHandler; |
| 1448 | } |
| 1449 | } |
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1450 | } |