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