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