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 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 19 | import android.os.RemoteException; |
| 20 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 21 | import com.android.internal.telecom.IInCallAdapter; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 22 | |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 23 | /** |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 24 | * Receives commands from {@link InCallService} implementations which should be executed by |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 25 | * 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] | 26 | * 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] | 27 | * 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] | 28 | * given call IDs to execute commands such as {@link #answerCall} for incoming calls or |
| 29 | * {@link #disconnectCall} for active calls the user would like to end. Some commands are only |
| 30 | * 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] | 31 | * <p> |
| 32 | * The adapter will stop functioning when there are no more calls. |
| 33 | * |
| 34 | * {@hide} |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 35 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 36 | public final class InCallAdapter { |
| 37 | private final IInCallAdapter mAdapter; |
| 38 | |
| 39 | /** |
| 40 | * {@hide} |
| 41 | */ |
| 42 | public InCallAdapter(IInCallAdapter adapter) { |
| 43 | mAdapter = adapter; |
| 44 | } |
| 45 | |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 46 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 47 | * Instructs Telecom to answer the specified call. |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 48 | * |
| 49 | * @param callId The identifier of the call to answer. |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 50 | * @param videoState The video state in which to answer the call. |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 51 | */ |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 52 | public void answerCall(String callId, int videoState) { |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 53 | try { |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 54 | mAdapter.answerCall(callId, videoState); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 55 | } catch (RemoteException e) { |
| 56 | } |
| 57 | } |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 58 | |
| 59 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 60 | * Instructs Telecom to reject the specified call. |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 61 | * |
| 62 | * @param callId The identifier of the call to reject. |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 63 | * @param rejectWithMessage Whether to reject with a text message. |
| 64 | * @param textMessage An optional text message with which to respond. |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 65 | */ |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 66 | public void rejectCall(String callId, boolean rejectWithMessage, String textMessage) { |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 67 | try { |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 68 | mAdapter.rejectCall(callId, rejectWithMessage, textMessage); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 69 | } catch (RemoteException e) { |
| 70 | } |
| 71 | } |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 72 | |
| 73 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 74 | * Instructs Telecom to disconnect the specified call. |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 75 | * |
| 76 | * @param callId The identifier of the call to disconnect. |
| 77 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 78 | public void disconnectCall(String callId) { |
| 79 | try { |
| 80 | mAdapter.disconnectCall(callId); |
| 81 | } catch (RemoteException e) { |
| 82 | } |
| 83 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 86 | * Instructs Telecom to put the specified call on hold. |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 87 | * |
| 88 | * @param callId The identifier of the call to put on hold. |
| 89 | */ |
| 90 | public void holdCall(String callId) { |
| 91 | try { |
| 92 | mAdapter.holdCall(callId); |
| 93 | } catch (RemoteException e) { |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 98 | * Instructs Telecom to release the specified call from hold. |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 99 | * |
| 100 | * @param callId The identifier of the call to release from hold. |
| 101 | */ |
| 102 | public void unholdCall(String callId) { |
| 103 | try { |
| 104 | mAdapter.unholdCall(callId); |
| 105 | } catch (RemoteException e) { |
| 106 | } |
| 107 | } |
Sailesh Nepal | 4cff392 | 2014-03-19 10:15:37 -0700 | [diff] [blame] | 108 | |
| 109 | /** |
| 110 | * Mute the microphone. |
| 111 | * |
| 112 | * @param shouldMute True if the microphone should be muted. |
| 113 | */ |
| 114 | public void mute(boolean shouldMute) { |
| 115 | try { |
| 116 | mAdapter.mute(shouldMute); |
| 117 | } catch (RemoteException e) { |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 122 | * Sets the audio route (speaker, bluetooth, etc...). See {@link AudioState}. |
Sailesh Nepal | 4cff392 | 2014-03-19 10:15:37 -0700 | [diff] [blame] | 123 | * |
| 124 | * @param route The audio route to use. |
| 125 | */ |
| 126 | public void setAudioRoute(int route) { |
| 127 | try { |
| 128 | mAdapter.setAudioRoute(route); |
| 129 | } catch (RemoteException e) { |
| 130 | } |
| 131 | } |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 134 | * 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] | 135 | * |
| 136 | * Any other currently playing DTMF tone in the specified call is immediately stopped. |
| 137 | * |
| 138 | * @param callId The unique ID of the call in which the tone will be played. |
| 139 | * @param digit A character representing the DTMF digit for which to play the tone. This |
| 140 | * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}. |
| 141 | */ |
| 142 | public void playDtmfTone(String callId, char digit) { |
| 143 | try { |
| 144 | mAdapter.playDtmfTone(callId, digit); |
| 145 | } catch (RemoteException e) { |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 150 | * 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] | 151 | * playing. |
| 152 | * |
| 153 | * DTMF tones are played by calling {@link #playDtmfTone(String,char)}. If no DTMF tone is |
| 154 | * currently playing, this method will do nothing. |
| 155 | * |
| 156 | * @param callId The unique ID of the call in which any currently playing tone will be stopped. |
| 157 | */ |
| 158 | public void stopDtmfTone(String callId) { |
| 159 | try { |
| 160 | mAdapter.stopDtmfTone(callId); |
| 161 | } catch (RemoteException e) { |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 166 | * Instructs Telecom to continue playing a post-dial DTMF string. |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 167 | * |
| 168 | * A post-dial DTMF string is a string of digits entered after a phone number, when dialed, |
| 169 | * 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] | 170 | * 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] | 171 | * is in the post dial state. |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 172 | * |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 173 | * 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] | 174 | * 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] | 175 | * |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 176 | * 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] | 177 | * 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] | 178 | * post dial wait state. When the user decides to continue the postdial sequence, the |
| 179 | * {@link InCallService} should invoke the {@link #postDialContinue(String,boolean)} method. |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 180 | * |
| 181 | * @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] | 182 | * @param proceed Whether or not to continue with the post-dial sequence. |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 183 | */ |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 184 | public void postDialContinue(String callId, boolean proceed) { |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 185 | try { |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 186 | mAdapter.postDialContinue(callId, proceed); |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 187 | } catch (RemoteException e) { |
| 188 | } |
| 189 | } |
Sailesh Nepal | b632e5b | 2014-04-03 12:54:33 -0700 | [diff] [blame] | 190 | |
| 191 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 192 | * Instructs Telecom to add a PhoneAccountHandle to the specified call |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 193 | * |
| 194 | * @param callId The identifier of the call |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 195 | * @param accountHandle The PhoneAccountHandle through which to place the call |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 196 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 197 | public void phoneAccountSelected(String callId, PhoneAccountHandle accountHandle) { |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 198 | try { |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 199 | mAdapter.phoneAccountSelected(callId, accountHandle); |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 200 | } catch (RemoteException e) { |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 205 | * Instructs Telecom to conference the specified call. |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 206 | * |
| 207 | * @param callId The unique ID of the call. |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 208 | * @hide |
| 209 | */ |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 210 | public void conference(String callId, String otherCallId) { |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 211 | try { |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 212 | mAdapter.conference(callId, otherCallId); |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 213 | } catch (RemoteException ignored) { |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 218 | * 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] | 219 | * connected. |
| 220 | * |
| 221 | * @param callId The unique ID of the call. |
| 222 | * @hide |
| 223 | */ |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 224 | public void splitFromConference(String callId) { |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 225 | try { |
| 226 | mAdapter.splitFromConference(callId); |
| 227 | } catch (RemoteException ignored) { |
| 228 | } |
| 229 | } |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 230 | |
| 231 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 232 | * Instructs Telecom to merge child calls of the specified conference call. |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 233 | */ |
| 234 | public void mergeConference(String callId) { |
| 235 | try { |
| 236 | mAdapter.mergeConference(callId); |
| 237 | } catch (RemoteException ignored) { |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 242 | * Instructs Telecom to swap the child calls of the specified conference call. |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 243 | */ |
| 244 | public void swapConference(String callId) { |
| 245 | try { |
| 246 | mAdapter.swapConference(callId); |
| 247 | } catch (RemoteException ignored) { |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 252 | * Instructs Telecom to turn the proximity sensor on. |
Yorke Lee | 0d6ea71 | 2014-07-28 14:39:23 -0700 | [diff] [blame] | 253 | */ |
| 254 | public void turnProximitySensorOn() { |
| 255 | try { |
| 256 | mAdapter.turnOnProximitySensor(); |
| 257 | } catch (RemoteException ignored) { |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 262 | * Instructs Telecom to turn the proximity sensor off. |
Yorke Lee | 0d6ea71 | 2014-07-28 14:39:23 -0700 | [diff] [blame] | 263 | * |
| 264 | * @param screenOnImmediately If true, the screen will be turned on immediately if it was |
| 265 | * previously off. Otherwise, the screen will only be turned on after the proximity sensor |
| 266 | * is no longer triggered. |
| 267 | */ |
| 268 | public void turnProximitySensorOff(boolean screenOnImmediately) { |
| 269 | try { |
| 270 | mAdapter.turnOffProximitySensor(screenOnImmediately); |
| 271 | } catch (RemoteException ignored) { |
| 272 | } |
| 273 | } |
Santos Cordon | 8f3fd30 | 2014-01-27 08:46:21 -0800 | [diff] [blame] | 274 | } |