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