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