| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [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 | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 18 | |
| Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 19 | import android.annotation.NonNull; |
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 20 | import android.bluetooth.BluetoothDevice; |
| Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 21 | import android.net.Uri; |
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 22 | import android.os.Binder; |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 23 | import android.os.Bundle; |
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 24 | import android.os.OutcomeReceiver; |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 25 | import android.os.RemoteException; |
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 26 | import android.os.ResultReceiver; |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 27 | |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 28 | import com.android.internal.telecom.IInCallAdapter; |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 29 | |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 30 | import java.util.List; |
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 31 | import java.util.concurrent.Executor; |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 32 | |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 33 | /** |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 34 | * Receives commands from {@link InCallService} implementations which should be executed by |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 35 | * Telecom. When Telecom binds to a {@link InCallService}, an instance of this class is given to |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 36 | * the in-call service through which it can manipulate live (active, dialing, ringing) calls. When |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 37 | * the in-call service is notified of new calls, it can use the |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 38 | * given call IDs to execute commands such as {@link #answerCall} for incoming calls or |
| 39 | * {@link #disconnectCall} for active calls the user would like to end. Some commands are only |
| 40 | * appropriate for calls in certain states; please consult each method for such limitations. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 41 | * <p> |
| 42 | * The adapter will stop functioning when there are no more calls. |
| 43 | * |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 44 | * @hide |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 45 | */ |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 46 | public final class InCallAdapter { |
| 47 | private final IInCallAdapter mAdapter; |
| 48 | |
| 49 | /** |
| 50 | * {@hide} |
| 51 | */ |
| 52 | public InCallAdapter(IInCallAdapter adapter) { |
| 53 | mAdapter = adapter; |
| 54 | } |
| 55 | |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 56 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 57 | * Instructs Telecom to answer the specified call. |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 58 | * |
| 59 | * @param callId The identifier of the call to answer. |
| Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 60 | * @param videoState The video state in which to answer the call. |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 61 | */ |
| Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 62 | public void answerCall(String callId, int videoState) { |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 63 | try { |
| Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 64 | mAdapter.answerCall(callId, videoState); |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 65 | } catch (RemoteException e) { |
| 66 | } |
| 67 | } |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 68 | |
| 69 | /** |
| Pooja Jain | d34698d | 2017-12-28 14:15:31 +0530 | [diff] [blame] | 70 | * Instructs Telecom to deflect the specified call. |
| 71 | * |
| 72 | * @param callId The identifier of the call to deflect. |
| 73 | * @param address The address to deflect. |
| 74 | */ |
| 75 | public void deflectCall(String callId, Uri address) { |
| 76 | try { |
| 77 | mAdapter.deflectCall(callId, address); |
| 78 | } catch (RemoteException e) { |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 83 | * Instructs Telecom to reject the specified call. |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 84 | * |
| 85 | * @param callId The identifier of the call to reject. |
| Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 86 | * @param rejectWithMessage Whether to reject with a text message. |
| 87 | * @param textMessage An optional text message with which to respond. |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 88 | */ |
| Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 89 | public void rejectCall(String callId, boolean rejectWithMessage, String textMessage) { |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 90 | try { |
| Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 91 | mAdapter.rejectCall(callId, rejectWithMessage, textMessage); |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 92 | } catch (RemoteException e) { |
| 93 | } |
| 94 | } |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 95 | |
| 96 | /** |
| Tyler Gunn | facfdee | 2020-01-23 13:10:37 -0800 | [diff] [blame] | 97 | * Instructs Telecom to reject the specified call. |
| 98 | * |
| 99 | * @param callId The identifier of the call to reject. |
| 100 | * @param rejectReason The reason the call was rejected. |
| 101 | */ |
| 102 | public void rejectCall(String callId, @Call.RejectReason int rejectReason) { |
| 103 | try { |
| 104 | mAdapter.rejectCallWithReason(callId, rejectReason); |
| 105 | } catch (RemoteException e) { |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /** |
| Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 110 | * Instructs Telecom to transfer the specified call. |
| 111 | * |
| 112 | * @param callId The identifier of the call to transfer. |
| 113 | * @param targetNumber The address to transfer to. |
| Tyler Gunn | 460360d | 2020-07-29 10:21:45 -0700 | [diff] [blame] | 114 | * @param isConfirmationRequired if {@code true} it will initiate a confirmed transfer, |
| 115 | * if {@code false}, it will initiate unconfirmed transfer. |
| Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 116 | */ |
| 117 | public void transferCall(@NonNull String callId, @NonNull Uri targetNumber, |
| 118 | boolean isConfirmationRequired) { |
| 119 | try { |
| 120 | mAdapter.transferCall(callId, targetNumber, isConfirmationRequired); |
| 121 | } catch (RemoteException e) { |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Instructs Telecom to transfer the specified call to another ongoing call. |
| 127 | * |
| 128 | * @param callId The identifier of the call to transfer. |
| 129 | * @param otherCallId The identifier of the other call to which this will be transferred. |
| 130 | */ |
| 131 | public void transferCall(@NonNull String callId, @NonNull String otherCallId) { |
| 132 | try { |
| 133 | mAdapter.consultativeTransfer(callId, otherCallId); |
| 134 | } catch (RemoteException e) { |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 139 | * Instructs Telecom to disconnect the specified call. |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 140 | * |
| 141 | * @param callId The identifier of the call to disconnect. |
| 142 | */ |
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 143 | public void disconnectCall(String callId) { |
| 144 | try { |
| 145 | mAdapter.disconnectCall(callId); |
| 146 | } catch (RemoteException e) { |
| 147 | } |
| 148 | } |
| Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 151 | * Instructs Telecom to put the specified call on hold. |
| Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 152 | * |
| 153 | * @param callId The identifier of the call to put on hold. |
| 154 | */ |
| 155 | public void holdCall(String callId) { |
| 156 | try { |
| 157 | mAdapter.holdCall(callId); |
| 158 | } catch (RemoteException e) { |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 163 | * Instructs Telecom to release the specified call from hold. |
| Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 164 | * |
| 165 | * @param callId The identifier of the call to release from hold. |
| 166 | */ |
| 167 | public void unholdCall(String callId) { |
| 168 | try { |
| 169 | mAdapter.unholdCall(callId); |
| 170 | } catch (RemoteException e) { |
| 171 | } |
| 172 | } |
| Sailesh Nepal | 4cff392 | 2014-03-19 10:15:37 -0700 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * Mute the microphone. |
| 176 | * |
| 177 | * @param shouldMute True if the microphone should be muted. |
| 178 | */ |
| 179 | public void mute(boolean shouldMute) { |
| 180 | try { |
| 181 | mAdapter.mute(shouldMute); |
| 182 | } catch (RemoteException e) { |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 187 | * Sets the audio route (speaker, bluetooth, etc...). See {@link CallAudioState}. |
| Sailesh Nepal | 4cff392 | 2014-03-19 10:15:37 -0700 | [diff] [blame] | 188 | * |
| 189 | * @param route The audio route to use. |
| 190 | */ |
| 191 | public void setAudioRoute(int route) { |
| 192 | try { |
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 193 | mAdapter.setAudioRoute(route, null); |
| 194 | } catch (RemoteException e) { |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | /** |
| Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 199 | * @see Call#enterBackgroundAudioProcessing() |
| 200 | */ |
| 201 | public void enterBackgroundAudioProcessing(String callId) { |
| 202 | try { |
| 203 | mAdapter.enterBackgroundAudioProcessing(callId); |
| 204 | } catch (RemoteException e) { |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * @see Call#exitBackgroundAudioProcessing(boolean) |
| 210 | */ |
| 211 | public void exitBackgroundAudioProcessing(String callId, boolean shouldRing) { |
| 212 | try { |
| 213 | mAdapter.exitBackgroundAudioProcessing(callId, shouldRing); |
| 214 | } catch (RemoteException e) { |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | /** |
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 219 | * Request audio routing to a specific bluetooth device. Calling this method may result in |
| 220 | * the device routing audio to a different bluetooth device than the one specified. A list of |
| 221 | * available devices can be obtained via {@link CallAudioState#getSupportedBluetoothDevices()} |
| 222 | * |
| 223 | * @param bluetoothAddress The address of the bluetooth device to connect to, as returned by |
| 224 | * {@link BluetoothDevice#getAddress()}, or {@code null} if no device is preferred. |
| 225 | */ |
| 226 | public void requestBluetoothAudio(String bluetoothAddress) { |
| 227 | try { |
| 228 | mAdapter.setAudioRoute(CallAudioState.ROUTE_BLUETOOTH, bluetoothAddress); |
| Sailesh Nepal | 4cff392 | 2014-03-19 10:15:37 -0700 | [diff] [blame] | 229 | } catch (RemoteException e) { |
| 230 | } |
| 231 | } |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 232 | |
| 233 | /** |
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 234 | * Request audio routing to a specific CallEndpoint.. See {@link CallEndpoint}. |
| 235 | * |
| 236 | * @param endpoint The call endpoint to use. |
| 237 | * @param executor The executor of where the callback will execute. |
| 238 | * @param callback The callback to notify the result of the endpoint change. |
| 239 | */ |
| 240 | public void requestCallEndpointChange(CallEndpoint endpoint, Executor executor, |
| 241 | OutcomeReceiver<Void, CallEndpointException> callback) { |
| 242 | try { |
| 243 | mAdapter.requestCallEndpointChange(endpoint, new ResultReceiver(null) { |
| 244 | @Override |
| 245 | protected void onReceiveResult(int resultCode, Bundle result) { |
| 246 | super.onReceiveResult(resultCode, result); |
| 247 | final long identity = Binder.clearCallingIdentity(); |
| 248 | try { |
| 249 | if (resultCode == CallEndpoint.ENDPOINT_OPERATION_SUCCESS) { |
| 250 | executor.execute(() -> callback.onResult(null)); |
| 251 | } else { |
| 252 | executor.execute(() -> callback.onError( |
| 253 | result.getParcelable(CallEndpointException.CHANGE_ERROR, |
| 254 | CallEndpointException.class))); |
| 255 | } |
| 256 | } finally { |
| 257 | Binder.restoreCallingIdentity(identity); |
| 258 | } |
| 259 | } |
| 260 | }); |
| 261 | } catch (RemoteException e) { |
| 262 | Log.d(this, "Remote exception calling requestCallEndpointChange"); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 267 | * Instructs Telecom to play a dual-tone multi-frequency signaling (DTMF) tone in a call. |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 268 | * |
| 269 | * Any other currently playing DTMF tone in the specified call is immediately stopped. |
| 270 | * |
| 271 | * @param callId The unique ID of the call in which the tone will be played. |
| 272 | * @param digit A character representing the DTMF digit for which to play the tone. This |
| 273 | * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}. |
| 274 | */ |
| 275 | public void playDtmfTone(String callId, char digit) { |
| 276 | try { |
| 277 | mAdapter.playDtmfTone(callId, digit); |
| 278 | } catch (RemoteException e) { |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 283 | * Instructs Telecom to stop any dual-tone multi-frequency signaling (DTMF) tone currently |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 284 | * playing. |
| 285 | * |
| 286 | * DTMF tones are played by calling {@link #playDtmfTone(String,char)}. If no DTMF tone is |
| 287 | * currently playing, this method will do nothing. |
| 288 | * |
| 289 | * @param callId The unique ID of the call in which any currently playing tone will be stopped. |
| 290 | */ |
| 291 | public void stopDtmfTone(String callId) { |
| 292 | try { |
| 293 | mAdapter.stopDtmfTone(callId); |
| 294 | } catch (RemoteException e) { |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 299 | * Instructs Telecom to continue playing a post-dial DTMF string. |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 300 | * |
| 301 | * A post-dial DTMF string is a string of digits entered after a phone number, when dialed, |
| 302 | * that are immediately sent as DTMF tones to the recipient as soon as the connection is made. |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 303 | * While these tones are playing, Telecom will notify the {@link InCallService} that the call |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 304 | * is in the post dial state. |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 305 | * |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 306 | * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, Telecom |
| Evan Charlton | 8acdbb8 | 2014-04-01 13:50:07 -0700 | [diff] [blame] | 307 | * will temporarily pause playing the tones for a pre-defined period of time. |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 308 | * |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 309 | * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, Telecom |
| Evan Charlton | 8acdbb8 | 2014-04-01 13:50:07 -0700 | [diff] [blame] | 310 | * will pause playing the tones and notify the {@link InCallService} that the call is in the |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 311 | * post dial wait state. When the user decides to continue the postdial sequence, the |
| 312 | * {@link InCallService} should invoke the {@link #postDialContinue(String,boolean)} method. |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 313 | * |
| 314 | * @param callId The unique ID of the call for which postdial string playing should continue. |
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 315 | * @param proceed Whether or not to continue with the post-dial sequence. |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 316 | */ |
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 317 | public void postDialContinue(String callId, boolean proceed) { |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 318 | try { |
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 319 | mAdapter.postDialContinue(callId, proceed); |
| Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 320 | } catch (RemoteException e) { |
| 321 | } |
| 322 | } |
| Sailesh Nepal | b632e5b | 2014-04-03 12:54:33 -0700 | [diff] [blame] | 323 | |
| 324 | /** |
| Nancy Chen | 36c62f3 | 2014-10-21 18:36:39 -0700 | [diff] [blame] | 325 | * Instructs Telecom to add a PhoneAccountHandle to the specified call. |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 326 | * |
| Nancy Chen | 36c62f3 | 2014-10-21 18:36:39 -0700 | [diff] [blame] | 327 | * @param callId The identifier of the call. |
| 328 | * @param accountHandle The PhoneAccountHandle through which to place the call. |
| 329 | * @param setDefault {@code True} if this account should be set as the default for calls. |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 330 | */ |
| Nancy Chen | 36c62f3 | 2014-10-21 18:36:39 -0700 | [diff] [blame] | 331 | public void phoneAccountSelected(String callId, PhoneAccountHandle accountHandle, |
| 332 | boolean setDefault) { |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 333 | try { |
| Nancy Chen | 36c62f3 | 2014-10-21 18:36:39 -0700 | [diff] [blame] | 334 | mAdapter.phoneAccountSelected(callId, accountHandle, setDefault); |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 335 | } catch (RemoteException e) { |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 340 | * Instructs Telecom to conference the specified call. |
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 341 | * |
| 342 | * @param callId The unique ID of the call. |
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 343 | * @hide |
| 344 | */ |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 345 | public void conference(String callId, String otherCallId) { |
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 346 | try { |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 347 | mAdapter.conference(callId, otherCallId); |
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 348 | } catch (RemoteException ignored) { |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | /** |
| Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 353 | * Instructs Telecom to pull participants to existing call |
| 354 | * |
| 355 | * @param callId The unique ID of the call. |
| 356 | * @param participants participants to be pulled to existing call. |
| 357 | */ |
| 358 | public void addConferenceParticipants(String callId, List<Uri> participants) { |
| 359 | try { |
| 360 | mAdapter.addConferenceParticipants(callId, participants); |
| 361 | } catch (RemoteException ignored) { |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | |
| 366 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 367 | * Instructs Telecom to split the specified call from any conference call with which it may be |
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 368 | * connected. |
| 369 | * |
| 370 | * @param callId The unique ID of the call. |
| 371 | * @hide |
| 372 | */ |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 373 | public void splitFromConference(String callId) { |
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 374 | try { |
| 375 | mAdapter.splitFromConference(callId); |
| 376 | } catch (RemoteException ignored) { |
| 377 | } |
| 378 | } |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 379 | |
| 380 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 381 | * Instructs Telecom to merge child calls of the specified conference call. |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 382 | */ |
| 383 | public void mergeConference(String callId) { |
| 384 | try { |
| 385 | mAdapter.mergeConference(callId); |
| 386 | } catch (RemoteException ignored) { |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 391 | * Instructs Telecom to swap the child calls of the specified conference call. |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 392 | */ |
| 393 | public void swapConference(String callId) { |
| 394 | try { |
| 395 | mAdapter.swapConference(callId); |
| 396 | } catch (RemoteException ignored) { |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | /** |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 401 | * Instructs Telecom to pull an external call to the local device. |
| 402 | * |
| 403 | * @param callId The callId to pull. |
| 404 | */ |
| 405 | public void pullExternalCall(String callId) { |
| 406 | try { |
| 407 | mAdapter.pullExternalCall(callId); |
| 408 | } catch (RemoteException ignored) { |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * Intructs Telecom to send a call event. |
| 414 | * |
| 415 | * @param callId The callId to send the event for. |
| 416 | * @param event The event. |
| Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 417 | * @param targetSdkVer Target sdk version of the app calling this api |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 418 | * @param extras Extras associated with the event. |
| 419 | */ |
| Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 420 | public void sendCallEvent(String callId, String event, int targetSdkVer, Bundle extras) { |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 421 | try { |
| Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 422 | mAdapter.sendCallEvent(callId, event, targetSdkVer, extras); |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 423 | } catch (RemoteException ignored) { |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | /** |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 428 | * Intructs Telecom to add extras to a call. |
| 429 | * |
| 430 | * @param callId The callId to add the extras to. |
| 431 | * @param extras The extras. |
| 432 | */ |
| 433 | public void putExtras(String callId, Bundle extras) { |
| 434 | try { |
| 435 | mAdapter.putExtras(callId, extras); |
| 436 | } catch (RemoteException ignored) { |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * Intructs Telecom to add an extra to a call. |
| 442 | * |
| 443 | * @param callId The callId to add the extras to. |
| 444 | * @param key The extra key. |
| 445 | * @param value The extra value. |
| 446 | */ |
| 447 | public void putExtra(String callId, String key, boolean value) { |
| 448 | try { |
| 449 | Bundle bundle = new Bundle(); |
| 450 | bundle.putBoolean(key, value); |
| 451 | mAdapter.putExtras(callId, bundle); |
| 452 | } catch (RemoteException ignored) { |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Intructs Telecom to add an extra to a call. |
| 458 | * |
| 459 | * @param callId The callId to add the extras to. |
| 460 | * @param key The extra key. |
| 461 | * @param value The extra value. |
| 462 | */ |
| 463 | public void putExtra(String callId, String key, int value) { |
| 464 | try { |
| 465 | Bundle bundle = new Bundle(); |
| 466 | bundle.putInt(key, value); |
| 467 | mAdapter.putExtras(callId, bundle); |
| 468 | } catch (RemoteException ignored) { |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * Intructs Telecom to add an extra to a call. |
| 474 | * |
| 475 | * @param callId The callId to add the extras to. |
| 476 | * @param key The extra key. |
| 477 | * @param value The extra value. |
| 478 | */ |
| 479 | public void putExtra(String callId, String key, String value) { |
| 480 | try { |
| 481 | Bundle bundle = new Bundle(); |
| 482 | bundle.putString(key, value); |
| 483 | mAdapter.putExtras(callId, bundle); |
| 484 | } catch (RemoteException ignored) { |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | /** |
| 489 | * Intructs Telecom to remove extras from a call. |
| 490 | * @param callId The callId to remove the extras from. |
| 491 | * @param keys The extra keys to remove. |
| 492 | */ |
| 493 | public void removeExtras(String callId, List<String> keys) { |
| 494 | try { |
| 495 | mAdapter.removeExtras(callId, keys); |
| 496 | } catch (RemoteException ignored) { |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 501 | * Instructs Telecom to turn the proximity sensor on. |
| Yorke Lee | 0d6ea71 | 2014-07-28 14:39:23 -0700 | [diff] [blame] | 502 | */ |
| 503 | public void turnProximitySensorOn() { |
| 504 | try { |
| 505 | mAdapter.turnOnProximitySensor(); |
| 506 | } catch (RemoteException ignored) { |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 511 | * Instructs Telecom to turn the proximity sensor off. |
| Yorke Lee | 0d6ea71 | 2014-07-28 14:39:23 -0700 | [diff] [blame] | 512 | * |
| 513 | * @param screenOnImmediately If true, the screen will be turned on immediately if it was |
| 514 | * previously off. Otherwise, the screen will only be turned on after the proximity sensor |
| 515 | * is no longer triggered. |
| 516 | */ |
| 517 | public void turnProximitySensorOff(boolean screenOnImmediately) { |
| 518 | try { |
| 519 | mAdapter.turnOffProximitySensor(screenOnImmediately); |
| 520 | } catch (RemoteException ignored) { |
| 521 | } |
| 522 | } |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 523 | |
| 524 | /** |
| 525 | * Sends an RTT upgrade request to the remote end of the connection. |
| 526 | */ |
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 527 | public void sendRttRequest(String callId) { |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 528 | try { |
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 529 | mAdapter.sendRttRequest(callId); |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 530 | } catch (RemoteException ignored) { |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * Responds to an RTT upgrade request initiated from the remote end. |
| 536 | * |
| 537 | * @param id the ID of the request as specified by Telecom |
| 538 | * @param accept Whether the request should be accepted. |
| 539 | */ |
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 540 | public void respondToRttRequest(String callId, int id, boolean accept) { |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 541 | try { |
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 542 | mAdapter.respondToRttRequest(callId, id, accept); |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 543 | } catch (RemoteException ignored) { |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * Instructs Telecom to shut down the RTT communication channel. |
| 549 | */ |
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 550 | public void stopRtt(String callId) { |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 551 | try { |
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 552 | mAdapter.stopRtt(callId); |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 553 | } catch (RemoteException ignored) { |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Sets the RTT audio mode. |
| 559 | * @param mode the desired RTT audio mode |
| 560 | */ |
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 561 | public void setRttMode(String callId, int mode) { |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 562 | try { |
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 563 | mAdapter.setRttMode(callId, mode); |
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 564 | } catch (RemoteException ignored) { |
| 565 | } |
| 566 | } |
| Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 567 | |
| 568 | |
| 569 | /** |
| 570 | * Initiates a handover of this {@link Call} to the {@link ConnectionService} identified |
| 571 | * by destAcct. |
| 572 | * @param callId The callId of the Call which calls this function. |
| 573 | * @param destAcct ConnectionService to which the call should be handed over. |
| 574 | * @param videoState The video state desired after the handover. |
| 575 | * @param extras Extra information to be passed to ConnectionService |
| 576 | */ |
| 577 | public void handoverTo(String callId, PhoneAccountHandle destAcct, int videoState, |
| 578 | Bundle extras) { |
| 579 | try { |
| 580 | mAdapter.handoverTo(callId, destAcct, videoState, extras); |
| 581 | } catch (RemoteException ignored) { |
| 582 | } |
| 583 | } |
| Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 584 | } |