blob: fd3cf2e12668d425ed4fb082e71c8b7163c4f751 [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
Sailesh Nepalab5d2822014-03-08 18:01:06 -080019import android.os.RemoteException;
20
Tyler Gunnef9f6f92014-09-12 22:16:17 -070021import com.android.internal.telecom.IInCallAdapter;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080022
Santos Cordon8f3fd302014-01-27 08:46:21 -080023/**
Sailesh Nepalab5d2822014-03-08 18:01:06 -080024 * Receives commands from {@link InCallService} implementations which should be executed by
Tyler Gunnef9f6f92014-09-12 22:16:17 -070025 * Telecom. When Telecom binds to a {@link InCallService}, an instance of this class is given to
Santos Cordon8f3fd302014-01-27 08:46:21 -080026 * the in-call service through which it can manipulate live (active, dialing, ringing) calls. When
Ihab Awade63fadb2014-07-09 21:52:04 -070027 * the in-call service is notified of new calls, it can use the
Santos Cordon8f3fd302014-01-27 08:46:21 -080028 * 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 Awadb19a0bc2014-08-07 19:46:01 -070031 * <p>
32 * The adapter will stop functioning when there are no more calls.
33 *
34 * {@hide}
Santos Cordon8f3fd302014-01-27 08:46:21 -080035 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080036public final class InCallAdapter {
37 private final IInCallAdapter mAdapter;
38
39 /**
40 * {@hide}
41 */
42 public InCallAdapter(IInCallAdapter adapter) {
43 mAdapter = adapter;
44 }
45
Santos Cordon8f3fd302014-01-27 08:46:21 -080046 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070047 * Instructs Telecom to answer the specified call.
Santos Cordon8f3fd302014-01-27 08:46:21 -080048 *
49 * @param callId The identifier of the call to answer.
Andrew Lee8da4c3c2014-07-16 10:11:42 -070050 * @param videoState The video state in which to answer the call.
Santos Cordon8f3fd302014-01-27 08:46:21 -080051 */
Andrew Lee8da4c3c2014-07-16 10:11:42 -070052 public void answerCall(String callId, int videoState) {
Sailesh Nepalab5d2822014-03-08 18:01:06 -080053 try {
Andrew Lee8da4c3c2014-07-16 10:11:42 -070054 mAdapter.answerCall(callId, videoState);
Sailesh Nepalab5d2822014-03-08 18:01:06 -080055 } catch (RemoteException e) {
56 }
57 }
Santos Cordon8f3fd302014-01-27 08:46:21 -080058
59 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070060 * Instructs Telecom to reject the specified call.
Santos Cordon8f3fd302014-01-27 08:46:21 -080061 *
62 * @param callId The identifier of the call to reject.
Ihab Awadc0677542014-06-10 13:29:47 -070063 * @param rejectWithMessage Whether to reject with a text message.
64 * @param textMessage An optional text message with which to respond.
Santos Cordon8f3fd302014-01-27 08:46:21 -080065 */
Ihab Awadc0677542014-06-10 13:29:47 -070066 public void rejectCall(String callId, boolean rejectWithMessage, String textMessage) {
Sailesh Nepalab5d2822014-03-08 18:01:06 -080067 try {
Ihab Awadc0677542014-06-10 13:29:47 -070068 mAdapter.rejectCall(callId, rejectWithMessage, textMessage);
Sailesh Nepalab5d2822014-03-08 18:01:06 -080069 } catch (RemoteException e) {
70 }
71 }
Santos Cordon8f3fd302014-01-27 08:46:21 -080072
73 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070074 * Instructs Telecom to disconnect the specified call.
Santos Cordon8f3fd302014-01-27 08:46:21 -080075 *
76 * @param callId The identifier of the call to disconnect.
77 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080078 public void disconnectCall(String callId) {
79 try {
80 mAdapter.disconnectCall(callId);
81 } catch (RemoteException e) {
82 }
83 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -070084
85 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070086 * Instructs Telecom to put the specified call on hold.
Yorke Lee81ccaaa2014-03-12 18:33:19 -070087 *
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 Gunnef9f6f92014-09-12 22:16:17 -070098 * Instructs Telecom to release the specified call from hold.
Yorke Lee81ccaaa2014-03-12 18:33:19 -070099 *
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 Nepal4cff3922014-03-19 10:15:37 -0700108
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 Awadb19a0bc2014-08-07 19:46:01 -0700122 * Sets the audio route (speaker, bluetooth, etc...). See {@link AudioState}.
Sailesh Nepal4cff3922014-03-19 10:15:37 -0700123 *
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 Awad2f236642014-03-10 15:33:45 -0700132
133 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700134 * Instructs Telecom to play a dual-tone multi-frequency signaling (DTMF) tone in a call.
Ihab Awad2f236642014-03-10 15:33:45 -0700135 *
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 Gunnef9f6f92014-09-12 22:16:17 -0700150 * Instructs Telecom to stop any dual-tone multi-frequency signaling (DTMF) tone currently
Ihab Awad2f236642014-03-10 15:33:45 -0700151 * 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 Gunnef9f6f92014-09-12 22:16:17 -0700166 * Instructs Telecom to continue playing a post-dial DTMF string.
Ihab Awad2f236642014-03-10 15:33:45 -0700167 *
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 Gunnef9f6f92014-09-12 22:16:17 -0700170 * While these tones are playing, Telecom will notify the {@link InCallService} that the call
Ihab Awade63fadb2014-07-09 21:52:04 -0700171 * is in the post dial state.
Ihab Awad2f236642014-03-10 15:33:45 -0700172 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700173 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, Telecom
Evan Charlton8acdbb82014-04-01 13:50:07 -0700174 * will temporarily pause playing the tones for a pre-defined period of time.
Ihab Awad2f236642014-03-10 15:33:45 -0700175 *
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700176 * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, Telecom
Evan Charlton8acdbb82014-04-01 13:50:07 -0700177 * will pause playing the tones and notify the {@link InCallService} that the call is in the
Ihab Awade63fadb2014-07-09 21:52:04 -0700178 * 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 Awad2f236642014-03-10 15:33:45 -0700180 *
181 * @param callId The unique ID of the call for which postdial string playing should continue.
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700182 * @param proceed Whether or not to continue with the post-dial sequence.
Ihab Awad2f236642014-03-10 15:33:45 -0700183 */
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700184 public void postDialContinue(String callId, boolean proceed) {
Ihab Awad2f236642014-03-10 15:33:45 -0700185 try {
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700186 mAdapter.postDialContinue(callId, proceed);
Ihab Awad2f236642014-03-10 15:33:45 -0700187 } catch (RemoteException e) {
188 }
189 }
Sailesh Nepalb632e5b2014-04-03 12:54:33 -0700190
191 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700192 * Instructs Telecom to add a PhoneAccountHandle to the specified call
Nancy Chen5da0fd52014-07-08 14:16:17 -0700193 *
194 * @param callId The identifier of the call
Evan Charlton8c8a0622014-07-20 12:31:00 -0700195 * @param accountHandle The PhoneAccountHandle through which to place the call
Nancy Chen5da0fd52014-07-08 14:16:17 -0700196 */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700197 public void phoneAccountSelected(String callId, PhoneAccountHandle accountHandle) {
Nancy Chen5da0fd52014-07-08 14:16:17 -0700198 try {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700199 mAdapter.phoneAccountSelected(callId, accountHandle);
Nancy Chen5da0fd52014-07-08 14:16:17 -0700200 } catch (RemoteException e) {
201 }
202 }
203
204 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700205 * Instructs Telecom to conference the specified call.
Santos Cordon980acb92014-05-31 10:31:19 -0700206 *
207 * @param callId The unique ID of the call.
Santos Cordon980acb92014-05-31 10:31:19 -0700208 * @hide
209 */
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700210 public void conference(String callId, String otherCallId) {
Santos Cordon980acb92014-05-31 10:31:19 -0700211 try {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700212 mAdapter.conference(callId, otherCallId);
Santos Cordon980acb92014-05-31 10:31:19 -0700213 } catch (RemoteException ignored) {
214 }
215 }
216
217 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700218 * Instructs Telecom to split the specified call from any conference call with which it may be
Santos Cordon980acb92014-05-31 10:31:19 -0700219 * connected.
220 *
221 * @param callId The unique ID of the call.
222 * @hide
223 */
Santos Cordonb6939982014-06-04 20:20:58 -0700224 public void splitFromConference(String callId) {
Santos Cordon980acb92014-05-31 10:31:19 -0700225 try {
226 mAdapter.splitFromConference(callId);
227 } catch (RemoteException ignored) {
228 }
229 }
Sailesh Nepal61203862014-07-11 14:50:13 -0700230
231 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700232 * Instructs Telecom to merge child calls of the specified conference call.
Santos Cordona4868042014-09-04 17:39:22 -0700233 */
234 public void mergeConference(String callId) {
235 try {
236 mAdapter.mergeConference(callId);
237 } catch (RemoteException ignored) {
238 }
239 }
240
241 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700242 * Instructs Telecom to swap the child calls of the specified conference call.
Santos Cordona4868042014-09-04 17:39:22 -0700243 */
244 public void swapConference(String callId) {
245 try {
246 mAdapter.swapConference(callId);
247 } catch (RemoteException ignored) {
248 }
249 }
250
251 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700252 * Instructs Telecom to turn the proximity sensor on.
Yorke Lee0d6ea712014-07-28 14:39:23 -0700253 */
254 public void turnProximitySensorOn() {
255 try {
256 mAdapter.turnOnProximitySensor();
257 } catch (RemoteException ignored) {
258 }
259 }
260
261 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700262 * Instructs Telecom to turn the proximity sensor off.
Yorke Lee0d6ea712014-07-28 14:39:23 -0700263 *
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 Cordon8f3fd302014-01-27 08:46:21 -0800274}