blob: 3526f4634170a19e10ea390824312ee73c13e945 [file] [log] [blame]
Ben Giladbb69b0c2013-12-12 18:32:02 -08001/*
Sailesh Nepalab5d2822014-03-08 18:01:06 -08002 * Copyright (C) 2014 The Android Open Source Project
Ben Giladbb69b0c2013-12-12 18:32:02 -08003 *
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.ICallServiceAdapter;
Ben Giladbb69b0c2013-12-12 18:32:02 -080022
Santos Cordon980acb92014-05-31 10:31:19 -070023import java.util.List;
24
Ben Giladbb69b0c2013-12-12 18:32:02 -080025/**
26 * Provides methods for ICallService implementations to interact with the system phone app.
27 * TODO(santoscordon): Need final public-facing comments in this file.
Ben Giladbb69b0c2013-12-12 18:32:02 -080028 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080029public final class CallServiceAdapter {
30 private final ICallServiceAdapter mAdapter;
31
32 /**
33 * {@hide}
34 */
35 public CallServiceAdapter(ICallServiceAdapter adapter) {
36 mAdapter = adapter;
37 }
Ben Giladbb69b0c2013-12-12 18:32:02 -080038
39 /**
Santos Cordon658c0cf2014-01-16 19:53:05 -080040 * Receives confirmation of a call service's ability to place a call. This method is used in
Sailesh Nepalab5d2822014-03-08 18:01:06 -080041 * response to {@link CallService#isCompatibleWith}.
Santos Cordon8986ef42014-01-14 14:43:35 -080042 *
Santos Cordon658c0cf2014-01-16 19:53:05 -080043 * @param callId The identifier of the call for which compatibility is being received. This ID
44 * should correspond to the ID given as part of the call information in
Sailesh Nepalab5d2822014-03-08 18:01:06 -080045 * {@link CallService#isCompatibleWith}.
Santos Cordon658c0cf2014-01-16 19:53:05 -080046 * @param isCompatible True if the call service can place the call.
Santos Cordon8986ef42014-01-14 14:43:35 -080047 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080048 public void setIsCompatibleWith(String callId, boolean isCompatible) {
49 try {
50 mAdapter.setIsCompatibleWith(callId, isCompatible);
51 } catch (RemoteException e) {
52 }
53 }
Santos Cordon8986ef42014-01-14 14:43:35 -080054
55 /**
Santos Cordonb340c332014-02-19 01:59:32 -080056 * Provides Telecomm with the details of an incoming call. An invocation of this method must
57 * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon
58 * the invocation of this method, Telecomm will bring up the incoming-call interface where the
59 * user can elect to answer or reject a call.
Santos Cordon37841332013-12-17 13:30:53 -080060 *
Santos Cordon805afaa2014-01-29 11:58:36 -080061 * @param callInfo The details of the relevant call.
Ben Giladbb69b0c2013-12-12 18:32:02 -080062 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080063 public void notifyIncomingCall(CallInfo callInfo) {
64 try {
65 mAdapter.notifyIncomingCall(callInfo);
66 } catch (RemoteException e) {
67 }
68 }
Ben Giladbb69b0c2013-12-12 18:32:02 -080069
70 /**
Santos Cordonf6d868b2014-02-05 13:04:15 -080071 * Tells Telecomm that an attempt to place the specified outgoing call succeeded.
72 * TODO(santoscordon): Consider adding a CallState parameter in case this outgoing call is
73 * somehow no longer in the DIALING state.
Santos Cordon37841332013-12-17 13:30:53 -080074 *
Santos Cordonf6d868b2014-02-05 13:04:15 -080075 * @param callId The ID of the outgoing call.
Ben Giladbb69b0c2013-12-12 18:32:02 -080076 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080077 public void handleSuccessfulOutgoingCall(String callId) {
78 try {
79 mAdapter.handleSuccessfulOutgoingCall(callId);
80 } catch (RemoteException e) {
81 }
82 }
Santos Cordonf6d868b2014-02-05 13:04:15 -080083
84 /**
85 * Tells Telecomm that an attempt to place the specified outgoing call failed.
86 *
87 * @param callId The ID of the outgoing call.
88 * @param errorMessage The error associated with the failed call attempt.
89 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -080090 public void handleFailedOutgoingCall(String callId, String errorMessage) {
91 try {
92 mAdapter.handleFailedOutgoingCall(callId, errorMessage);
93 } catch (RemoteException e) {
94 }
95 }
Ben Giladbb69b0c2013-12-12 18:32:02 -080096
97 /**
98 * Sets a call's state to active (e.g., an ongoing call where two parties can actively
99 * communicate).
Santos Cordon37841332013-12-17 13:30:53 -0800100 *
101 * @param callId The unique ID of the call whose state is changing to active.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800102 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800103 public void setActive(String callId) {
104 try {
105 mAdapter.setActive(callId);
106 } catch (RemoteException e) {
107 }
108 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800109
110 /**
111 * Sets a call's state to ringing (e.g., an inbound ringing call).
Santos Cordon37841332013-12-17 13:30:53 -0800112 *
113 * @param callId The unique ID of the call whose state is changing to ringing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800114 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800115 public void setRinging(String callId) {
116 try {
117 mAdapter.setRinging(callId);
118 } catch (RemoteException e) {
119 }
120 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800121
122 /**
123 * Sets a call's state to dialing (e.g., dialing an outbound call).
Santos Cordon37841332013-12-17 13:30:53 -0800124 *
125 * @param callId The unique ID of the call whose state is changing to dialing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800126 */
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800127 public void setDialing(String callId) {
128 try {
129 mAdapter.setDialing(callId);
130 } catch (RemoteException e) {
131 }
132 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800133
134 /**
135 * Sets a call's state to disconnected.
Santos Cordon37841332013-12-17 13:30:53 -0800136 *
137 * @param callId The unique ID of the call whose state is changing to disconnected.
Santos Cordon20e3f022014-03-27 12:15:38 -0700138 * @param disconnectCause The reason for the disconnection, any of
139 * {@link android.telephony.DisconnectCause}.
140 * @param disconnectMessage Optional call-service-provided message about the disconnect.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800141 */
Santos Cordon20e3f022014-03-27 12:15:38 -0700142 public void setDisconnected(String callId, int disconnectCause, String disconnectMessage) {
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800143 try {
Santos Cordon20e3f022014-03-27 12:15:38 -0700144 mAdapter.setDisconnected(callId, disconnectCause, disconnectMessage);
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800145 } catch (RemoteException e) {
146 }
147 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700148
149 /**
150 * Sets a call's state to be on hold.
151 *
152 * @param callId - The unique ID of the call whose state is changing to be on hold.
153 */
154 public void setOnHold(String callId) {
155 try {
156 mAdapter.setOnHold(callId);
157 } catch (RemoteException e) {
158 }
159 }
160
Ihab Awadf8358972014-05-28 16:46:42 -0700161 /**
162 * Asks Telecomm to start or stop a ringback tone for a call.
163 *
164 * @param callId The unique ID of the call whose ringback is being changed.
165 * @param ringback Whether Telecomm should start playing a ringback tone.
166 */
167 public void setRequestingRingback(String callId, boolean ringback) {
168 try {
169 mAdapter.setRequestingRingback(callId, ringback);
170 } catch (RemoteException e) {
171 }
172 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700173
Santos Cordon980acb92014-05-31 10:31:19 -0700174 /**
175 * Indicates that the specified call can conference with any of the specified list of calls.
176 *
177 * @param callId The unique ID of the call.
178 * @param conferenceCapableCallIds The unique IDs of the calls which can be conferenced.
179 * @hide
180 */
181 public void setCanConferenceWith(String callId, List<String> conferenceCapableCallIds) {
182 try {
183 mAdapter.setCanConferenceWith(callId, conferenceCapableCallIds);
184 } catch (RemoteException ignored) {
185 }
186 }
187
188 /**
189 * Indicates whether or not the specified call is currently conferenced into the specified
190 * conference call.
191 *
192 * @param conferenceCallId The unique ID of the conference call.
193 * @param callId The unique ID of the call being conferenced.
194 * @hide
195 */
196 public void setIsConferenced(String conferenceCallId, String callId, boolean isConferenced) {
197 try {
198 mAdapter.setIsConferenced(conferenceCallId, callId, isConferenced);
199 } catch (RemoteException ignored) {
200 }
201 }
202
203 /**
204 * Indicates that the call no longer exists. Can be used with either a call or a conference
205 * call.
206 *
207 * @param callId The unique ID of the call.
208 * @hide
209 */
210 public void removeCall(String callId) {
211 try {
212 mAdapter.removeCall(callId);
213 } catch (RemoteException ignored) {
214 }
215 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700216
217 public void onPostDialWait(String callId, String remaining) {
218 try {
219 mAdapter.onPostDialWait(callId, remaining);
220 } catch (RemoteException ignored) {
221 }
222 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800223}