Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 1 | /* |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 2 | * Copyright (C) 2014 The Android Open Source Project |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 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 | |
| 17 | package android.telecomm; |
| 18 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 19 | import android.os.RemoteException; |
| 20 | |
| 21 | import com.android.internal.telecomm.ICallServiceAdapter; |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 22 | |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 23 | import java.util.List; |
| 24 | |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 25 | /** |
| 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 Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 28 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 29 | public final class CallServiceAdapter { |
| 30 | private final ICallServiceAdapter mAdapter; |
| 31 | |
| 32 | /** |
| 33 | * {@hide} |
| 34 | */ |
| 35 | public CallServiceAdapter(ICallServiceAdapter adapter) { |
| 36 | mAdapter = adapter; |
| 37 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 38 | |
| 39 | /** |
Santos Cordon | 658c0cf | 2014-01-16 19:53:05 -0800 | [diff] [blame] | 40 | * Receives confirmation of a call service's ability to place a call. This method is used in |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 41 | * response to {@link CallService#isCompatibleWith}. |
Santos Cordon | 8986ef4 | 2014-01-14 14:43:35 -0800 | [diff] [blame] | 42 | * |
Santos Cordon | 658c0cf | 2014-01-16 19:53:05 -0800 | [diff] [blame] | 43 | * @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 Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 45 | * {@link CallService#isCompatibleWith}. |
Santos Cordon | 658c0cf | 2014-01-16 19:53:05 -0800 | [diff] [blame] | 46 | * @param isCompatible True if the call service can place the call. |
Santos Cordon | 8986ef4 | 2014-01-14 14:43:35 -0800 | [diff] [blame] | 47 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 48 | public void setIsCompatibleWith(String callId, boolean isCompatible) { |
| 49 | try { |
| 50 | mAdapter.setIsCompatibleWith(callId, isCompatible); |
| 51 | } catch (RemoteException e) { |
| 52 | } |
| 53 | } |
Santos Cordon | 8986ef4 | 2014-01-14 14:43:35 -0800 | [diff] [blame] | 54 | |
| 55 | /** |
Santos Cordon | b340c33 | 2014-02-19 01:59:32 -0800 | [diff] [blame] | 56 | * 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 Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 60 | * |
Santos Cordon | 805afaa | 2014-01-29 11:58:36 -0800 | [diff] [blame] | 61 | * @param callInfo The details of the relevant call. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 62 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 63 | public void notifyIncomingCall(CallInfo callInfo) { |
| 64 | try { |
| 65 | mAdapter.notifyIncomingCall(callInfo); |
| 66 | } catch (RemoteException e) { |
| 67 | } |
| 68 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 69 | |
| 70 | /** |
Santos Cordon | f6d868b | 2014-02-05 13:04:15 -0800 | [diff] [blame] | 71 | * 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 Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 74 | * |
Santos Cordon | f6d868b | 2014-02-05 13:04:15 -0800 | [diff] [blame] | 75 | * @param callId The ID of the outgoing call. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 76 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 77 | public void handleSuccessfulOutgoingCall(String callId) { |
| 78 | try { |
| 79 | mAdapter.handleSuccessfulOutgoingCall(callId); |
| 80 | } catch (RemoteException e) { |
| 81 | } |
| 82 | } |
Santos Cordon | f6d868b | 2014-02-05 13:04:15 -0800 | [diff] [blame] | 83 | |
| 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 Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 90 | public void handleFailedOutgoingCall(String callId, String errorMessage) { |
| 91 | try { |
| 92 | mAdapter.handleFailedOutgoingCall(callId, errorMessage); |
| 93 | } catch (RemoteException e) { |
| 94 | } |
| 95 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * Sets a call's state to active (e.g., an ongoing call where two parties can actively |
| 99 | * communicate). |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 100 | * |
| 101 | * @param callId The unique ID of the call whose state is changing to active. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 102 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 103 | public void setActive(String callId) { |
| 104 | try { |
| 105 | mAdapter.setActive(callId); |
| 106 | } catch (RemoteException e) { |
| 107 | } |
| 108 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Sets a call's state to ringing (e.g., an inbound ringing call). |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 112 | * |
| 113 | * @param callId The unique ID of the call whose state is changing to ringing. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 114 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 115 | public void setRinging(String callId) { |
| 116 | try { |
| 117 | mAdapter.setRinging(callId); |
| 118 | } catch (RemoteException e) { |
| 119 | } |
| 120 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * Sets a call's state to dialing (e.g., dialing an outbound call). |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 124 | * |
| 125 | * @param callId The unique ID of the call whose state is changing to dialing. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 126 | */ |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 127 | public void setDialing(String callId) { |
| 128 | try { |
| 129 | mAdapter.setDialing(callId); |
| 130 | } catch (RemoteException e) { |
| 131 | } |
| 132 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 133 | |
| 134 | /** |
| 135 | * Sets a call's state to disconnected. |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 136 | * |
| 137 | * @param callId The unique ID of the call whose state is changing to disconnected. |
Santos Cordon | 20e3f02 | 2014-03-27 12:15:38 -0700 | [diff] [blame] | 138 | * @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 Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 141 | */ |
Santos Cordon | 20e3f02 | 2014-03-27 12:15:38 -0700 | [diff] [blame] | 142 | public void setDisconnected(String callId, int disconnectCause, String disconnectMessage) { |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 143 | try { |
Santos Cordon | 20e3f02 | 2014-03-27 12:15:38 -0700 | [diff] [blame] | 144 | mAdapter.setDisconnected(callId, disconnectCause, disconnectMessage); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 145 | } catch (RemoteException e) { |
| 146 | } |
| 147 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 148 | |
| 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 Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 161 | /** |
| 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 Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 173 | |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 174 | /** |
| 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 Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame^] | 216 | |
| 217 | public void onPostDialWait(String callId, String remaining) { |
| 218 | try { |
| 219 | mAdapter.onPostDialWait(callId, remaining); |
| 220 | } catch (RemoteException ignored) { |
| 221 | } |
| 222 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 223 | } |