blob: 2933f1780e8b486e9c229d2a410f0c82f2579e01 [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
17package android.telecomm;
18
Sailesh Nepalab5d2822014-03-08 18:01:06 -080019import android.os.RemoteException;
20
21import com.android.internal.telecomm.IInCallAdapter;
22
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
25 * Telecomm. When Telecomm 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
Sailesh Nepalab5d2822014-03-08 18:01:06 -080027 * the in-call service is notified of new calls ({@link InCallService#addCall}), 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.
31 * TODO(santoscordon): Needs more/better comments once the API is finalized.
32 * TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls.
Santos Cordon8f3fd302014-01-27 08:46:21 -080033 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080034public final class InCallAdapter {
35 private final IInCallAdapter mAdapter;
36
37 /**
38 * {@hide}
39 */
40 public InCallAdapter(IInCallAdapter adapter) {
41 mAdapter = adapter;
42 }
43
Santos Cordon8f3fd302014-01-27 08:46:21 -080044 /**
45 * Instructs Telecomm to answer the specified call.
46 *
47 * @param callId The identifier of the call to answer.
48 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080049 public void answerCall(String callId) {
50 try {
51 mAdapter.answerCall(callId);
52 } catch (RemoteException e) {
53 }
54 }
Santos Cordon8f3fd302014-01-27 08:46:21 -080055
56 /**
57 * Instructs Telecomm to reject the specified call.
58 * TODO(santoscordon): Add reject-with-text-message parameter when that feature
59 * is ported over.
60 *
61 * @param callId The identifier of the call to reject.
62 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080063 public void rejectCall(String callId) {
64 try {
65 mAdapter.rejectCall(callId);
66 } catch (RemoteException e) {
67 }
68 }
Santos Cordon8f3fd302014-01-27 08:46:21 -080069
70 /**
71 * Instructs Telecomm to disconnect the specified call.
72 *
73 * @param callId The identifier of the call to disconnect.
74 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080075 public void disconnectCall(String callId) {
76 try {
77 mAdapter.disconnectCall(callId);
78 } catch (RemoteException e) {
79 }
80 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -070081
82 /**
83 * Instructs Telecomm to put the specified call on hold.
84 *
85 * @param callId The identifier of the call to put on hold.
86 */
87 public void holdCall(String callId) {
88 try {
89 mAdapter.holdCall(callId);
90 } catch (RemoteException e) {
91 }
92 }
93
94 /**
95 * Instructs Telecomm to release the specified call from hold.
96 *
97 * @param callId The identifier of the call to release from hold.
98 */
99 public void unholdCall(String callId) {
100 try {
101 mAdapter.unholdCall(callId);
102 } catch (RemoteException e) {
103 }
104 }
Sailesh Nepal4cff3922014-03-19 10:15:37 -0700105
106 /**
107 * Mute the microphone.
108 *
109 * @param shouldMute True if the microphone should be muted.
110 */
111 public void mute(boolean shouldMute) {
112 try {
113 mAdapter.mute(shouldMute);
114 } catch (RemoteException e) {
115 }
116 }
117
118 /**
119 * Sets the audio route (speaker, bluetooth, etc...). See {@link CallAudioState}.
120 *
121 * @param route The audio route to use.
122 */
123 public void setAudioRoute(int route) {
124 try {
125 mAdapter.setAudioRoute(route);
126 } catch (RemoteException e) {
127 }
128 }
Ihab Awad2f236642014-03-10 15:33:45 -0700129
130 /**
131 * Instructs Telecomm to play a dual-tone multi-frequency signaling (DTMF) tone in a call.
132 *
133 * Any other currently playing DTMF tone in the specified call is immediately stopped.
134 *
135 * @param callId The unique ID of the call in which the tone will be played.
136 * @param digit A character representing the DTMF digit for which to play the tone. This
137 * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.
138 */
139 public void playDtmfTone(String callId, char digit) {
140 try {
141 mAdapter.playDtmfTone(callId, digit);
142 } catch (RemoteException e) {
143 }
144 }
145
146 /**
147 * Instructs Telecomm to stop any dual-tone multi-frequency signaling (DTMF) tone currently
148 * playing.
149 *
150 * DTMF tones are played by calling {@link #playDtmfTone(String,char)}. If no DTMF tone is
151 * currently playing, this method will do nothing.
152 *
153 * @param callId The unique ID of the call in which any currently playing tone will be stopped.
154 */
155 public void stopDtmfTone(String callId) {
156 try {
157 mAdapter.stopDtmfTone(callId);
158 } catch (RemoteException e) {
159 }
160 }
161
162 /**
163 * Instructs Telecomm to continue playing a post-dial DTMF string.
164 *
165 * A post-dial DTMF string is a string of digits entered after a phone number, when dialed,
166 * that are immediately sent as DTMF tones to the recipient as soon as the connection is made.
167 * While these tones are playing, Telecomm will notify the {@link InCallService} that the call
Evan Charlton8acdbb82014-04-01 13:50:07 -0700168 * is in the {@link InCallService#setPostDial(String,String)} state.
Ihab Awad2f236642014-03-10 15:33:45 -0700169 *
Evan Charlton8acdbb82014-04-01 13:50:07 -0700170 * If the DTMF string contains a {@link TelecommConstants#DTMF_CHARACTER_PAUSE} symbol, Telecomm
171 * will temporarily pause playing the tones for a pre-defined period of time.
Ihab Awad2f236642014-03-10 15:33:45 -0700172 *
Evan Charlton8acdbb82014-04-01 13:50:07 -0700173 * If the DTMF string contains a {@link TelecommConstants#DTMF_CHARACTER_WAIT} symbol, Telecomm
174 * will pause playing the tones and notify the {@link InCallService} that the call is in the
175 * {@link InCallService#setPostDialWait(String,String)} state. When the user decides to continue
176 * the postdial sequence, the {@link InCallService} should invoke the
Ihab Awad2f236642014-03-10 15:33:45 -0700177 * {@link #postDialContinue(String)} method.
178 *
179 * @param callId The unique ID of the call for which postdial string playing should continue.
180 */
181 public void postDialContinue(String callId) {
182 try {
183 mAdapter.postDialContinue(callId);
184 } catch (RemoteException e) {
185 }
186 }
Santos Cordon8f3fd302014-01-27 08:46:21 -0800187}