blob: 52ef4a705e05fa9f465900e9c3c922b3ff6813cd [file] [log] [blame]
Santos Cordon8f3fd302014-01-27 08:46:21 -08001/*
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 Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Santos Cordon8f3fd302014-01-27 08:46:21 -080018
Tyler Gunn876dbfb2016-03-14 15:18:07 -070019import android.os.Bundle;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080020import android.os.RemoteException;
21
Tyler Gunnef9f6f92014-09-12 22:16:17 -070022import com.android.internal.telecom.IInCallAdapter;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080023
Santos Cordon8f3fd302014-01-27 08:46:21 -080024/**
Sailesh Nepalab5d2822014-03-08 18:01:06 -080025 * Receives commands from {@link InCallService} implementations which should be executed by
Tyler Gunnef9f6f92014-09-12 22:16:17 -070026 * Telecom. When Telecom binds to a {@link InCallService}, an instance of this class is given to
Santos Cordon8f3fd302014-01-27 08:46:21 -080027 * the in-call service through which it can manipulate live (active, dialing, ringing) calls. When
Ihab Awade63fadb2014-07-09 21:52:04 -070028 * the in-call service is notified of new calls, it can use the
Santos Cordon8f3fd302014-01-27 08:46:21 -080029 * given call IDs to execute commands such as {@link #answerCall} for incoming calls or
30 * {@link #disconnectCall} for active calls the user would like to end. Some commands are only
31 * appropriate for calls in certain states; please consult each method for such limitations.
Ihab Awadb19a0bc2014-08-07 19:46:01 -070032 * <p>
33 * The adapter will stop functioning when there are no more calls.
34 *
35 * {@hide}
Santos Cordon8f3fd302014-01-27 08:46:21 -080036 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080037public final class InCallAdapter {
38 private final IInCallAdapter mAdapter;
39
40 /**
41 * {@hide}
42 */
43 public InCallAdapter(IInCallAdapter adapter) {
44 mAdapter = adapter;
45 }
46
Santos Cordon8f3fd302014-01-27 08:46:21 -080047 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070048 * Instructs Telecom to answer the specified call.
Santos Cordon8f3fd302014-01-27 08:46:21 -080049 *
50 * @param callId The identifier of the call to answer.
Andrew Lee8da4c3c2014-07-16 10:11:42 -070051 * @param videoState The video state in which to answer the call.
Santos Cordon8f3fd302014-01-27 08:46:21 -080052 */
Andrew Lee8da4c3c2014-07-16 10:11:42 -070053 public void answerCall(String callId, int videoState) {
Sailesh Nepalab5d2822014-03-08 18:01:06 -080054 try {
Andrew Lee8da4c3c2014-07-16 10:11:42 -070055 mAdapter.answerCall(callId, videoState);
Sailesh Nepalab5d2822014-03-08 18:01:06 -080056 } catch (RemoteException e) {
57 }
58 }
Santos Cordon8f3fd302014-01-27 08:46:21 -080059
60 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070061 * Instructs Telecom to reject the specified call.
Santos Cordon8f3fd302014-01-27 08:46:21 -080062 *
63 * @param callId The identifier of the call to reject.
Ihab Awadc0677542014-06-10 13:29:47 -070064 * @param rejectWithMessage Whether to reject with a text message.
65 * @param textMessage An optional text message with which to respond.
Santos Cordon8f3fd302014-01-27 08:46:21 -080066 */
Ihab Awadc0677542014-06-10 13:29:47 -070067 public void rejectCall(String callId, boolean rejectWithMessage, String textMessage) {
Sailesh Nepalab5d2822014-03-08 18:01:06 -080068 try {
Ihab Awadc0677542014-06-10 13:29:47 -070069 mAdapter.rejectCall(callId, rejectWithMessage, textMessage);
Sailesh Nepalab5d2822014-03-08 18:01:06 -080070 } catch (RemoteException e) {
71 }
72 }
Santos Cordon8f3fd302014-01-27 08:46:21 -080073
74 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070075 * Instructs Telecom to disconnect the specified call.
Santos Cordon8f3fd302014-01-27 08:46:21 -080076 *
77 * @param callId The identifier of the call to disconnect.
78 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080079 public void disconnectCall(String callId) {
80 try {
81 mAdapter.disconnectCall(callId);
82 } catch (RemoteException e) {
83 }
84 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -070085
86 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070087 * Instructs Telecom to put the specified call on hold.
Yorke Lee81ccaaa2014-03-12 18:33:19 -070088 *
89 * @param callId The identifier of the call to put on hold.
90 */
91 public void holdCall(String callId) {
92 try {
93 mAdapter.holdCall(callId);
94 } catch (RemoteException e) {
95 }
96 }
97
98 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070099 * Instructs Telecom to release the specified call from hold.
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700100 *
101 * @param callId The identifier of the call to release from hold.
102 */
103 public void unholdCall(String callId) {
104 try {
105 mAdapter.unholdCall(callId);
106 } catch (RemoteException e) {
107 }
108 }
Sailesh Nepal4cff3922014-03-19 10:15:37 -0700109
110 /**
111 * Mute the microphone.
112 *
113 * @param shouldMute True if the microphone should be muted.
114 */
115 public void mute(boolean shouldMute) {
116 try {
117 mAdapter.mute(shouldMute);
118 } catch (RemoteException e) {
119 }
120 }
121
122 /**
Yorke Lee4af59352015-05-13 14:14:54 -0700123 * Sets the audio route (speaker, bluetooth, etc...). See {@link CallAudioState}.
Sailesh Nepal4cff3922014-03-19 10:15:37 -0700124 *
125 * @param route The audio route to use.
126 */
127 public void setAudioRoute(int route) {
128 try {
129 mAdapter.setAudioRoute(route);
130 } catch (RemoteException e) {
131 }
132 }
Ihab Awad2f236642014-03-10 15:33:45 -0700133
134 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700135 * Instructs Telecom to play a dual-tone multi-frequency signaling (DTMF) tone in a call.
Ihab Awad2f236642014-03-10 15:33:45 -0700136 *
137 * Any other currently playing DTMF tone in the specified call is immediately stopped.
138 *
139 * @param callId The unique ID of the call in which the tone will be played.
140 * @param digit A character representing the DTMF digit for which to play the tone. This
141 * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.
142 */
143 public void playDtmfTone(String callId, char digit) {
144 try {
145 mAdapter.playDtmfTone(callId, digit);
146 } catch (RemoteException e) {
147 }
148 }
149
150 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700151 * Instructs Telecom to stop any dual-tone multi-frequency signaling (DTMF) tone currently
Ihab Awad2f236642014-03-10 15:33:45 -0700152 * playing.
153 *
154 * DTMF tones are played by calling {@link #playDtmfTone(String,char)}. If no DTMF tone is
155 * currently playing, this method will do nothing.
156 *
157 * @param callId The unique ID of the call in which any currently playing tone will be stopped.
158 */
159 public void stopDtmfTone(String callId) {
160 try {
161 mAdapter.stopDtmfTone(callId);
162 } catch (RemoteException e) {
163 }
164 }
165
166 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700167 * Instructs Telecom to continue playing a post-dial DTMF string.
Ihab Awad2f236642014-03-10 15:33:45 -0700168 *
169 * A post-dial DTMF string is a string of digits entered after a phone number, when dialed,
170 * that are immediately sent as DTMF tones to the recipient as soon as the connection is made.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700171 * While these tones are playing, Telecom will notify the {@link InCallService} that the call
Ihab Awade63fadb2014-07-09 21:52:04 -0700172 * is in the post dial state.
Ihab Awad2f236642014-03-10 15:33:45 -0700173 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700174 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, Telecom
Evan Charlton8acdbb82014-04-01 13:50:07 -0700175 * will temporarily pause playing the tones for a pre-defined period of time.
Ihab Awad2f236642014-03-10 15:33:45 -0700176 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700177 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, Telecom
Evan Charlton8acdbb82014-04-01 13:50:07 -0700178 * will pause playing the tones and notify the {@link InCallService} that the call is in the
Ihab Awade63fadb2014-07-09 21:52:04 -0700179 * post dial wait state. When the user decides to continue the postdial sequence, the
180 * {@link InCallService} should invoke the {@link #postDialContinue(String,boolean)} method.
Ihab Awad2f236642014-03-10 15:33:45 -0700181 *
182 * @param callId The unique ID of the call for which postdial string playing should continue.
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700183 * @param proceed Whether or not to continue with the post-dial sequence.
Ihab Awad2f236642014-03-10 15:33:45 -0700184 */
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700185 public void postDialContinue(String callId, boolean proceed) {
Ihab Awad2f236642014-03-10 15:33:45 -0700186 try {
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700187 mAdapter.postDialContinue(callId, proceed);
Ihab Awad2f236642014-03-10 15:33:45 -0700188 } catch (RemoteException e) {
189 }
190 }
Sailesh Nepalb632e5b2014-04-03 12:54:33 -0700191
192 /**
Nancy Chen36c62f32014-10-21 18:36:39 -0700193 * Instructs Telecom to add a PhoneAccountHandle to the specified call.
Nancy Chen5da0fd52014-07-08 14:16:17 -0700194 *
Nancy Chen36c62f32014-10-21 18:36:39 -0700195 * @param callId The identifier of the call.
196 * @param accountHandle The PhoneAccountHandle through which to place the call.
197 * @param setDefault {@code True} if this account should be set as the default for calls.
Nancy Chen5da0fd52014-07-08 14:16:17 -0700198 */
Nancy Chen36c62f32014-10-21 18:36:39 -0700199 public void phoneAccountSelected(String callId, PhoneAccountHandle accountHandle,
200 boolean setDefault) {
Nancy Chen5da0fd52014-07-08 14:16:17 -0700201 try {
Nancy Chen36c62f32014-10-21 18:36:39 -0700202 mAdapter.phoneAccountSelected(callId, accountHandle, setDefault);
Nancy Chen5da0fd52014-07-08 14:16:17 -0700203 } catch (RemoteException e) {
204 }
205 }
206
207 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700208 * Instructs Telecom to conference the specified call.
Santos Cordon980acb92014-05-31 10:31:19 -0700209 *
210 * @param callId The unique ID of the call.
Santos Cordon980acb92014-05-31 10:31:19 -0700211 * @hide
212 */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700213 public void conference(String callId, String otherCallId) {
Santos Cordon980acb92014-05-31 10:31:19 -0700214 try {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700215 mAdapter.conference(callId, otherCallId);
Santos Cordon980acb92014-05-31 10:31:19 -0700216 } catch (RemoteException ignored) {
217 }
218 }
219
220 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700221 * Instructs Telecom to split the specified call from any conference call with which it may be
Santos Cordon980acb92014-05-31 10:31:19 -0700222 * connected.
223 *
224 * @param callId The unique ID of the call.
225 * @hide
226 */
Santos Cordonb6939982014-06-04 20:20:58 -0700227 public void splitFromConference(String callId) {
Santos Cordon980acb92014-05-31 10:31:19 -0700228 try {
229 mAdapter.splitFromConference(callId);
230 } catch (RemoteException ignored) {
231 }
232 }
Sailesh Nepal61203862014-07-11 14:50:13 -0700233
234 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700235 * Instructs Telecom to merge child calls of the specified conference call.
Santos Cordona4868042014-09-04 17:39:22 -0700236 */
237 public void mergeConference(String callId) {
238 try {
239 mAdapter.mergeConference(callId);
240 } catch (RemoteException ignored) {
241 }
242 }
243
244 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700245 * Instructs Telecom to swap the child calls of the specified conference call.
Santos Cordona4868042014-09-04 17:39:22 -0700246 */
247 public void swapConference(String callId) {
248 try {
249 mAdapter.swapConference(callId);
250 } catch (RemoteException ignored) {
251 }
252 }
253
254 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700255 * Instructs Telecom to pull an external call to the local device.
256 *
257 * @param callId The callId to pull.
258 */
259 public void pullExternalCall(String callId) {
260 try {
261 mAdapter.pullExternalCall(callId);
262 } catch (RemoteException ignored) {
263 }
264 }
265
266 /**
267 * Intructs Telecom to send a call event.
268 *
269 * @param callId The callId to send the event for.
270 * @param event The event.
271 * @param extras Extras associated with the event.
272 */
273 public void sendCallEvent(String callId, String event, Bundle extras) {
274 try {
275 mAdapter.sendCallEvent(callId, event, extras);
276 } catch (RemoteException ignored) {
277 }
278 }
279
280 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700281 * Instructs Telecom to turn the proximity sensor on.
Yorke Lee0d6ea712014-07-28 14:39:23 -0700282 */
283 public void turnProximitySensorOn() {
284 try {
285 mAdapter.turnOnProximitySensor();
286 } catch (RemoteException ignored) {
287 }
288 }
289
290 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700291 * Instructs Telecom to turn the proximity sensor off.
Yorke Lee0d6ea712014-07-28 14:39:23 -0700292 *
293 * @param screenOnImmediately If true, the screen will be turned on immediately if it was
294 * previously off. Otherwise, the screen will only be turned on after the proximity sensor
295 * is no longer triggered.
296 */
297 public void turnProximitySensorOff(boolean screenOnImmediately) {
298 try {
299 mAdapter.turnOffProximitySensor(screenOnImmediately);
300 } catch (RemoteException ignored) {
301 }
302 }
Santos Cordon8f3fd302014-01-27 08:46:21 -0800303}