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