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