Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | |
| 17 | package com.android.telecomm; |
| 18 | |
Evan Charlton | a05805b | 2014-03-05 08:21:46 -0800 | [diff] [blame] | 19 | import android.os.Bundle; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 20 | import android.os.Handler; |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 21 | import android.os.IBinder; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 22 | import android.os.Message; |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 23 | import android.os.RemoteException; |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 24 | import android.telecomm.CallAudioState; |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 25 | import android.telecomm.CallInfo; |
Evan Charlton | a05805b | 2014-03-05 08:21:46 -0800 | [diff] [blame] | 26 | import android.telecomm.CallService; |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 27 | import android.telecomm.CallServiceDescriptor; |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 28 | import android.telecomm.ConnectionRequest; |
Sailesh Nepal | 83cfe7c | 2014-03-11 19:54:22 -0700 | [diff] [blame] | 29 | import android.telecomm.TelecommConstants; |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 30 | import android.telephony.DisconnectCause; |
Sailesh Nepal | a439e1b | 2014-03-11 18:19:58 -0700 | [diff] [blame] | 31 | |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 32 | import com.android.internal.os.SomeArgs; |
Sailesh Nepal | a439e1b | 2014-03-11 18:19:58 -0700 | [diff] [blame] | 33 | import com.android.internal.telecomm.ICallService; |
| 34 | import com.android.internal.telecomm.ICallServiceAdapter; |
| 35 | import com.android.internal.telecomm.ICallServiceProvider; |
Sailesh Nepal | 0e5410a | 2014-04-04 01:20:58 -0700 | [diff] [blame] | 36 | import com.google.common.base.Preconditions; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 37 | import com.google.common.collect.ImmutableList; |
| 38 | import com.google.common.collect.Sets; |
| 39 | |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 40 | import org.apache.http.conn.ClientConnectionRequest; |
| 41 | |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 42 | import java.util.HashMap; |
Santos Cordon | 8f3282c | 2014-06-01 13:56:02 -0700 | [diff] [blame] | 43 | import java.util.List; |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 44 | import java.util.Map; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 45 | import java.util.Set; |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * Wrapper for {@link ICallService}s, handles binding to {@link ICallService} and keeps track of |
| 49 | * when the object can safely be unbound. Other classes should not use {@link ICallService} directly |
| 50 | * and instead should use this class to invoke methods of {@link ICallService}. |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 51 | */ |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 52 | final class CallServiceWrapper extends ServiceBinder<ICallService> { |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 53 | |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 54 | private final class Adapter extends ICallServiceAdapter.Stub { |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 55 | private static final int MSG_NOTIFY_INCOMING_CALL = 1; |
| 56 | private static final int MSG_HANDLE_SUCCESSFUL_OUTGOING_CALL = 2; |
| 57 | private static final int MSG_HANDLE_FAILED_OUTGOING_CALL = 3; |
| 58 | private static final int MSG_SET_ACTIVE = 4; |
| 59 | private static final int MSG_SET_RINGING = 5; |
| 60 | private static final int MSG_SET_DIALING = 6; |
| 61 | private static final int MSG_SET_DISCONNECTED = 7; |
| 62 | private static final int MSG_SET_ON_HOLD = 8; |
Ihab Awad | 50a5713 | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 63 | private static final int MSG_SET_REQUESTING_RINGBACK = 9; |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 64 | private static final int MSG_ON_POST_DIAL_WAIT = 10; |
Sailesh Nepal | 6098d2c | 2014-06-06 10:56:53 -0700 | [diff] [blame^] | 65 | private static final int MSG_HANDOFF_CALL = 11; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 66 | |
| 67 | private final Handler mHandler = new Handler() { |
| 68 | @Override |
| 69 | public void handleMessage(Message msg) { |
| 70 | Call call; |
| 71 | switch (msg.what) { |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 72 | case MSG_NOTIFY_INCOMING_CALL: |
| 73 | CallInfo clientCallInfo = (CallInfo) msg.obj; |
| 74 | call = mCallIdMapper.getCall(clientCallInfo.getId()); |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 75 | if (call != null && mPendingIncomingCalls.remove(call) && |
| 76 | call.isIncoming()) { |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 77 | CallInfo callInfo = new CallInfo(null, clientCallInfo.getState(), |
| 78 | clientCallInfo.getHandle()); |
| 79 | mIncomingCallsManager.handleSuccessfulIncomingCall(call, callInfo); |
| 80 | } else { |
| 81 | Log.w(this, "notifyIncomingCall, unknown incoming call: %s, id: %s", |
| 82 | call, |
| 83 | clientCallInfo.getId()); |
| 84 | } |
| 85 | break; |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 86 | case MSG_HANDLE_SUCCESSFUL_OUTGOING_CALL: { |
| 87 | String callId = (String) msg.obj; |
| 88 | if (mPendingOutgoingCalls.containsKey(callId)) { |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 89 | mPendingOutgoingCalls.remove(callId).onResult(true, 0, null); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 90 | } else { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 91 | Log.w(this, "handleSuccessfulOutgoingCall, unknown call: %s", callId); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 92 | } |
| 93 | break; |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 94 | } |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 95 | case MSG_HANDLE_FAILED_OUTGOING_CALL: { |
| 96 | SomeArgs args = (SomeArgs) msg.obj; |
| 97 | try { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 98 | String callId = (String) args.arg1; |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 99 | int statusCode = args.argi1; |
| 100 | String statusMsg = (String) args.arg2; |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 101 | // TODO(santoscordon): Do something with 'reason' or get rid of it. |
| 102 | |
| 103 | if (mPendingOutgoingCalls.containsKey(callId)) { |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 104 | mPendingOutgoingCalls.remove(callId).onResult( |
| 105 | false, statusCode, statusMsg); |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 106 | mCallIdMapper.removeCall(callId); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 107 | } else { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 108 | Log.w(this, "handleFailedOutgoingCall, unknown call: %s", callId); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 109 | } |
| 110 | } finally { |
| 111 | args.recycle(); |
| 112 | } |
| 113 | break; |
| 114 | } |
| 115 | case MSG_SET_ACTIVE: |
| 116 | call = mCallIdMapper.getCall(msg.obj); |
| 117 | if (call != null) { |
| 118 | mCallsManager.markCallAsActive(call); |
| 119 | } else { |
| 120 | Log.w(this, "setActive, unknown call id: %s", msg.obj); |
| 121 | } |
| 122 | break; |
| 123 | case MSG_SET_RINGING: |
| 124 | call = mCallIdMapper.getCall(msg.obj); |
| 125 | if (call != null) { |
| 126 | mCallsManager.markCallAsRinging(call); |
| 127 | } else { |
| 128 | Log.w(this, "setRinging, unknown call id: %s", msg.obj); |
| 129 | } |
| 130 | break; |
| 131 | case MSG_SET_DIALING: |
| 132 | call = mCallIdMapper.getCall(msg.obj); |
| 133 | if (call != null) { |
| 134 | mCallsManager.markCallAsDialing(call); |
| 135 | } else { |
| 136 | Log.w(this, "setDialing, unknown call id: %s", msg.obj); |
| 137 | } |
| 138 | break; |
| 139 | case MSG_SET_DISCONNECTED: { |
| 140 | SomeArgs args = (SomeArgs) msg.obj; |
| 141 | try { |
| 142 | call = mCallIdMapper.getCall(args.arg1); |
| 143 | String disconnectMessage = (String) args.arg2; |
| 144 | int disconnectCause = args.argi1; |
| 145 | if (call != null) { |
| 146 | mCallsManager.markCallAsDisconnected(call, disconnectCause, |
| 147 | disconnectMessage); |
| 148 | } else { |
| 149 | Log.w(this, "setDisconnected, unknown call id: %s", args.arg1); |
| 150 | } |
| 151 | } finally { |
| 152 | args.recycle(); |
| 153 | } |
| 154 | break; |
| 155 | } |
| 156 | case MSG_SET_ON_HOLD: |
| 157 | call = mCallIdMapper.getCall(msg.obj); |
| 158 | if (call != null) { |
| 159 | mCallsManager.markCallAsOnHold(call); |
| 160 | } else { |
| 161 | Log.w(this, "setOnHold, unknown call id: %s", msg.obj); |
| 162 | } |
| 163 | break; |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 164 | case MSG_SET_REQUESTING_RINGBACK: { |
Ihab Awad | 50a5713 | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 165 | SomeArgs args = (SomeArgs) msg.obj; |
| 166 | try { |
| 167 | call = mCallIdMapper.getCall(args.arg1); |
| 168 | boolean ringback = (boolean) args.arg2; |
| 169 | if (call != null) { |
| 170 | call.setRequestingRingback(ringback); |
| 171 | } else { |
| 172 | Log.w(this, "setRingback, unknown call id: %s", args.arg1); |
| 173 | } |
| 174 | } finally { |
| 175 | args.recycle(); |
| 176 | } |
| 177 | break; |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 178 | } |
| 179 | case MSG_ON_POST_DIAL_WAIT: |
| 180 | SomeArgs args = (SomeArgs) msg.obj; |
| 181 | try { |
| 182 | call = mCallIdMapper.getCall(args.arg1); |
| 183 | if (call != null) { |
| 184 | String remaining = (String) args.arg2; |
| 185 | call.onPostDialWait(remaining); |
| 186 | } else { |
| 187 | Log.w(this, "onPostDialWait, unknown call id: %s", args.arg1); |
| 188 | } |
| 189 | } finally { |
| 190 | args.recycle(); |
| 191 | } |
Sailesh Nepal | 6098d2c | 2014-06-06 10:56:53 -0700 | [diff] [blame^] | 192 | case MSG_HANDOFF_CALL: |
| 193 | call = mCallIdMapper.getCall(msg.obj); |
| 194 | if (call != null) { |
| 195 | mCallsManager.startHandoffForCall(call); |
| 196 | } else { |
| 197 | Log.w(this, "handoffCall, unknown call id: %s", msg.obj); |
| 198 | } |
| 199 | break; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 200 | } |
| 201 | } |
| 202 | }; |
| 203 | |
| 204 | /** {@inheritDoc} */ |
| 205 | @Override |
| 206 | public void setIsCompatibleWith(String callId, boolean isCompatible) { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 207 | Log.wtf(this, "Not expected."); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /** {@inheritDoc} */ |
| 211 | @Override |
| 212 | public void notifyIncomingCall(CallInfo callInfo) { |
| 213 | mCallIdMapper.checkValidCallId(callInfo.getId()); |
| 214 | mHandler.obtainMessage(MSG_NOTIFY_INCOMING_CALL, callInfo).sendToTarget(); |
| 215 | } |
| 216 | |
| 217 | /** {@inheritDoc} */ |
| 218 | @Override |
| 219 | public void handleSuccessfulOutgoingCall(String callId) { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 220 | Log.d(this, "handleSuccessfulOutgoingCall %s", callId); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 221 | mCallIdMapper.checkValidCallId(callId); |
| 222 | mHandler.obtainMessage(MSG_HANDLE_SUCCESSFUL_OUTGOING_CALL, callId).sendToTarget(); |
| 223 | } |
| 224 | |
| 225 | /** {@inheritDoc} */ |
| 226 | @Override |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 227 | public void handleFailedOutgoingCall( |
| 228 | ConnectionRequest request, |
| 229 | int errorCode, |
| 230 | String errorMsg) { |
| 231 | mCallIdMapper.checkValidCallId(request.getCallId()); |
| 232 | Log.d(this, "handleFailedOutgoingCall %s", request.getCallId()); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 233 | SomeArgs args = SomeArgs.obtain(); |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 234 | args.arg1 = request.getCallId(); |
| 235 | args.argi1 = errorCode; |
| 236 | args.arg2 = errorMsg; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 237 | mHandler.obtainMessage(MSG_HANDLE_FAILED_OUTGOING_CALL, args).sendToTarget(); |
| 238 | } |
| 239 | |
| 240 | /** {@inheritDoc} */ |
| 241 | @Override |
| 242 | public void setActive(String callId) { |
| 243 | mCallIdMapper.checkValidCallId(callId); |
| 244 | mHandler.obtainMessage(MSG_SET_ACTIVE, callId).sendToTarget(); |
| 245 | } |
| 246 | |
| 247 | /** {@inheritDoc} */ |
| 248 | @Override |
| 249 | public void setRinging(String callId) { |
| 250 | mCallIdMapper.checkValidCallId(callId); |
| 251 | mHandler.obtainMessage(MSG_SET_RINGING, callId).sendToTarget(); |
| 252 | } |
| 253 | |
| 254 | /** {@inheritDoc} */ |
| 255 | @Override |
| 256 | public void setDialing(String callId) { |
| 257 | mCallIdMapper.checkValidCallId(callId); |
| 258 | mHandler.obtainMessage(MSG_SET_DIALING, callId).sendToTarget(); |
| 259 | } |
| 260 | |
| 261 | /** {@inheritDoc} */ |
| 262 | @Override |
| 263 | public void setDisconnected( |
| 264 | String callId, int disconnectCause, String disconnectMessage) { |
| 265 | mCallIdMapper.checkValidCallId(callId); |
| 266 | SomeArgs args = SomeArgs.obtain(); |
| 267 | args.arg1 = callId; |
| 268 | args.arg2 = disconnectMessage; |
| 269 | args.argi1 = disconnectCause; |
| 270 | mHandler.obtainMessage(MSG_SET_DISCONNECTED, args).sendToTarget(); |
| 271 | } |
| 272 | |
| 273 | /** {@inheritDoc} */ |
| 274 | @Override |
| 275 | public void setOnHold(String callId) { |
| 276 | mCallIdMapper.checkValidCallId(callId); |
| 277 | mHandler.obtainMessage(MSG_SET_ON_HOLD, callId).sendToTarget(); |
| 278 | } |
Ihab Awad | 50a5713 | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 279 | |
| 280 | /** {@inheritDoc} */ |
| 281 | @Override |
| 282 | public void setRequestingRingback(String callId, boolean ringback) { |
| 283 | mCallIdMapper.checkValidCallId(callId); |
| 284 | SomeArgs args = SomeArgs.obtain(); |
| 285 | args.arg1 = callId; |
| 286 | args.arg2 = ringback; |
| 287 | mHandler.obtainMessage(MSG_SET_REQUESTING_RINGBACK, args).sendToTarget(); |
| 288 | } |
Santos Cordon | 8f3282c | 2014-06-01 13:56:02 -0700 | [diff] [blame] | 289 | |
| 290 | /** ${inheritDoc} */ |
| 291 | @Override |
| 292 | public void removeCall(String callId) { |
| 293 | } |
| 294 | |
| 295 | /** ${inheritDoc} */ |
| 296 | @Override |
| 297 | public void setCanConferenceWith(String callId, List<String> conferenceCapableCallIds) { |
| 298 | } |
| 299 | |
| 300 | /** ${inheritDoc} */ |
| 301 | @Override |
| 302 | public void setIsConferenced(String conferenceCallId, String callId, boolean isConferenced) { |
| 303 | } |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 304 | |
| 305 | @Override |
| 306 | public void onPostDialWait(String callId, String remaining) throws RemoteException { |
| 307 | mCallIdMapper.checkValidCallId(callId); |
| 308 | SomeArgs args = SomeArgs.obtain(); |
| 309 | args.arg1 = callId; |
| 310 | args.arg2 = remaining; |
| 311 | mHandler.obtainMessage(MSG_ON_POST_DIAL_WAIT, args).sendToTarget(); |
| 312 | } |
Sailesh Nepal | 6098d2c | 2014-06-06 10:56:53 -0700 | [diff] [blame^] | 313 | |
| 314 | /** {@inheritDoc} */ |
| 315 | @Override |
| 316 | public void handoffCall(String callId) { |
| 317 | mCallIdMapper.checkValidCallId(callId); |
| 318 | mHandler.obtainMessage(MSG_HANDOFF_CALL, callId).sendToTarget(); |
| 319 | } |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | private final Adapter mAdapter = new Adapter(); |
| 323 | private final CallsManager mCallsManager = CallsManager.getInstance(); |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 324 | private final Set<Call> mPendingIncomingCalls = Sets.newHashSet(); |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 325 | private final CallServiceDescriptor mDescriptor; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 326 | private final CallIdMapper mCallIdMapper = new CallIdMapper("CallService"); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 327 | private final IncomingCallsManager mIncomingCallsManager; |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 328 | private final Map<String, AsyncResultCallback<Boolean>> mPendingOutgoingCalls = new HashMap<>(); |
Santos Cordon | c195e36 | 2014-02-11 17:05:31 -0800 | [diff] [blame] | 329 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 330 | private Binder mBinder = new Binder(); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 331 | private ICallService mServiceInterface; |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 332 | |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 333 | /** |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 334 | * Creates a call-service for the specified descriptor. |
Santos Cordon | c195e36 | 2014-02-11 17:05:31 -0800 | [diff] [blame] | 335 | * |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 336 | * @param descriptor The call-service descriptor from |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 337 | * {@link ICallServiceProvider#lookupCallServices}. |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 338 | * @param incomingCallsManager Manages the incoming call initialization flow. |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 339 | */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 340 | CallServiceWrapper( |
| 341 | CallServiceDescriptor descriptor, |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 342 | IncomingCallsManager incomingCallsManager) { |
Sailesh Nepal | a439e1b | 2014-03-11 18:19:58 -0700 | [diff] [blame] | 343 | super(TelecommConstants.ACTION_CALL_SERVICE, descriptor.getServiceComponent()); |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 344 | mDescriptor = descriptor; |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 345 | mIncomingCallsManager = incomingCallsManager; |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 346 | } |
| 347 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 348 | CallServiceDescriptor getDescriptor() { |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 349 | return mDescriptor; |
Santos Cordon | c195e36 | 2014-02-11 17:05:31 -0800 | [diff] [blame] | 350 | } |
| 351 | |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 352 | /** See {@link ICallService#setCallServiceAdapter}. */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 353 | private void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 354 | if (isServiceValid("setCallServiceAdapter")) { |
| 355 | try { |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 356 | mServiceInterface.setCallServiceAdapter(callServiceAdapter); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 357 | } catch (RemoteException e) { |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 358 | } |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 359 | } |
| 360 | } |
| 361 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 362 | /** |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 363 | * Attempts to place the specified call, see {@link ICallService#call}. Returns the result |
| 364 | * asynchronously through the specified callback. |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 365 | */ |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 366 | void call(final Call call, final AsyncResultCallback<Boolean> resultCallback) { |
| 367 | Log.d(this, "call(%s) via %s.", call, getComponentName()); |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 368 | BindCallback callback = new BindCallback() { |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 369 | @Override |
| 370 | public void onSuccess() { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 371 | String callId = mCallIdMapper.getCallId(call); |
| 372 | mPendingOutgoingCalls.put(callId, resultCallback); |
| 373 | |
| 374 | try { |
| 375 | CallInfo callInfo = call.toCallInfo(callId); |
| 376 | mServiceInterface.call(callInfo); |
| 377 | } catch (RemoteException e) { |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 378 | mPendingOutgoingCalls.remove(callId).onResult( |
| 379 | false, DisconnectCause.ERROR_UNSPECIFIED, e.toString()); |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 380 | } |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 381 | } |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 382 | |
| 383 | @Override |
| 384 | public void onFailure() { |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 385 | resultCallback.onResult(false, DisconnectCause.ERROR_UNSPECIFIED, null); |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 386 | } |
| 387 | }; |
| 388 | |
| 389 | mBinder.bind(callback); |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 390 | } |
| 391 | |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 392 | /** @see CallService#abort(String) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 393 | void abort(Call call) { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 394 | // Clear out any pending outgoing call data |
| 395 | String callId = mCallIdMapper.getCallId(call); |
| 396 | |
| 397 | // If still bound, tell the call service to abort. |
Ben Gilad | 28e8ad6 | 2014-03-06 17:01:54 -0800 | [diff] [blame] | 398 | if (isServiceValid("abort")) { |
| 399 | try { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 400 | mServiceInterface.abort(callId); |
Ben Gilad | 28e8ad6 | 2014-03-06 17:01:54 -0800 | [diff] [blame] | 401 | } catch (RemoteException e) { |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 402 | } |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 403 | } |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 404 | |
| 405 | removeCall(call); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 406 | } |
| 407 | |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 408 | /** @see CallService#hold(String) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 409 | void hold(Call call) { |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 410 | if (isServiceValid("hold")) { |
| 411 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 412 | mServiceInterface.hold(mCallIdMapper.getCallId(call)); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 413 | } catch (RemoteException e) { |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 418 | /** @see CallService#unhold(String) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 419 | void unhold(Call call) { |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 420 | if (isServiceValid("unhold")) { |
| 421 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 422 | mServiceInterface.unhold(mCallIdMapper.getCallId(call)); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 423 | } catch (RemoteException e) { |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | } |
| 427 | |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 428 | /** @see CallService#onAudioStateChanged(String,CallAudioState) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 429 | void onAudioStateChanged(Call activeCall, CallAudioState audioState) { |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 430 | if (isServiceValid("onAudioStateChanged")) { |
| 431 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 432 | mServiceInterface.onAudioStateChanged(mCallIdMapper.getCallId(activeCall), |
| 433 | audioState); |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 434 | } catch (RemoteException e) { |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 439 | /** |
| 440 | * Starts retrieval of details for an incoming call. Details are returned through the |
| 441 | * call-service adapter using the specified call ID. Upon failure, the specified error callback |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 442 | * is invoked. Can be invoked even when the call service is unbound. See |
| 443 | * {@link ICallService#setIncomingCallId}. |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 444 | * |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 445 | * @param call The call used for the incoming call. |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 446 | * @param extras The {@link CallService}-provided extras which need to be sent back. |
| 447 | * @param errorCallback The callback to invoke upon failure. |
| 448 | */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 449 | void setIncomingCallId(final Call call, final Bundle extras, final Runnable errorCallback) { |
| 450 | Log.d(this, "setIncomingCall(%s) via %s.", call, getComponentName()); |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 451 | BindCallback callback = new BindCallback() { |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 452 | @Override |
| 453 | public void onSuccess() { |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 454 | if (isServiceValid("setIncomingCallId")) { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 455 | mPendingIncomingCalls.add(call); |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 456 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 457 | mServiceInterface.setIncomingCallId(mCallIdMapper.getCallId(call), |
| 458 | extras); |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 459 | } catch (RemoteException e) { |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 460 | } |
| 461 | } |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 462 | } |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 463 | |
| 464 | @Override |
| 465 | public void onFailure() { |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 466 | errorCallback.run(); |
| 467 | } |
| 468 | }; |
| 469 | |
| 470 | mBinder.bind(callback); |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 471 | } |
| 472 | |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 473 | /** @see CallService#disconnect(String) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 474 | void disconnect(Call call) { |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 475 | if (isServiceValid("disconnect")) { |
| 476 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 477 | mServiceInterface.disconnect(mCallIdMapper.getCallId(call)); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 478 | } catch (RemoteException e) { |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 479 | } |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 480 | } |
| 481 | } |
Santos Cordon | 5c12c6e | 2014-02-13 14:35:31 -0800 | [diff] [blame] | 482 | |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 483 | /** @see CallService#answer(String) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 484 | void answer(Call call) { |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 485 | if (isServiceValid("answer")) { |
| 486 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 487 | mServiceInterface.answer(mCallIdMapper.getCallId(call)); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 488 | } catch (RemoteException e) { |
Santos Cordon | 7917d38 | 2014-02-14 02:31:18 -0800 | [diff] [blame] | 489 | } |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 493 | /** @see CallService#reject(String) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 494 | void reject(Call call) { |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 495 | if (isServiceValid("reject")) { |
| 496 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 497 | mServiceInterface.reject(mCallIdMapper.getCallId(call)); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 498 | } catch (RemoteException e) { |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 499 | } |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | /** @see CallService#playDtmfTone(String,char) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 504 | void playDtmfTone(Call call, char digit) { |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 505 | if (isServiceValid("playDtmfTone")) { |
| 506 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 507 | mServiceInterface.playDtmfTone(mCallIdMapper.getCallId(call), digit); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 508 | } catch (RemoteException e) { |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | /** @see CallService#stopDtmfTone(String) */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 514 | void stopDtmfTone(Call call) { |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 515 | if (isServiceValid("stopDtmfTone")) { |
| 516 | try { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 517 | mServiceInterface.stopDtmfTone(mCallIdMapper.getCallId(call)); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 518 | } catch (RemoteException e) { |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 519 | } |
Santos Cordon | 7917d38 | 2014-02-14 02:31:18 -0800 | [diff] [blame] | 520 | } |
| 521 | } |
| 522 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 523 | void addCall(Call call) { |
| 524 | mCallIdMapper.addCall(call); |
Santos Cordon | 7917d38 | 2014-02-14 02:31:18 -0800 | [diff] [blame] | 525 | } |
| 526 | |
Sailesh Nepal | 0e5410a | 2014-04-04 01:20:58 -0700 | [diff] [blame] | 527 | /** |
| 528 | * Associates newCall with this call service by replacing callToReplace. |
| 529 | */ |
| 530 | void replaceCall(Call newCall, Call callToReplace) { |
| 531 | Preconditions.checkState(callToReplace.getCallService() == this); |
| 532 | mCallIdMapper.replaceCall(newCall, callToReplace); |
| 533 | } |
| 534 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 535 | void removeCall(Call call) { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 536 | mPendingIncomingCalls.remove(call); |
| 537 | |
| 538 | AsyncResultCallback<Boolean> outgoingResultCallback = |
| 539 | mPendingOutgoingCalls.remove(mCallIdMapper.getCallId(call)); |
| 540 | if (outgoingResultCallback != null) { |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 541 | outgoingResultCallback.onResult(false, DisconnectCause.ERROR_UNSPECIFIED, null); |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 542 | } |
| 543 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 544 | mCallIdMapper.removeCall(call); |
Yorke Lee | adee12d | 2014-03-13 12:08:30 -0700 | [diff] [blame] | 545 | } |
| 546 | |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 547 | void onPostDialContinue(Call call, boolean proceed) { |
| 548 | if (isServiceValid("onPostDialContinue")) { |
| 549 | try { |
| 550 | mServiceInterface.onPostDialContinue(mCallIdMapper.getCallId(call), proceed); |
| 551 | } catch (RemoteException ignored) { |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | |
Santos Cordon | 5c12c6e | 2014-02-13 14:35:31 -0800 | [diff] [blame] | 556 | /** {@inheritDoc} */ |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 557 | @Override |
| 558 | protected void setServiceInterface(IBinder binder) { |
Santos Cordon | 4b2c119 | 2014-03-19 18:15:38 -0700 | [diff] [blame] | 559 | if (binder == null) { |
| 560 | // We have lost our service connection. Notify the world that this call service is done. |
| 561 | // We must notify the adapter before CallsManager. The adapter will force any pending |
| 562 | // outgoing calls to try the next call service. This needs to happen before CallsManager |
| 563 | // tries to clean up any calls still associated with this call service. |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 564 | handleCallServiceDeath(); |
Santos Cordon | 4b2c119 | 2014-03-19 18:15:38 -0700 | [diff] [blame] | 565 | CallsManager.getInstance().handleCallServiceDeath(this); |
| 566 | mServiceInterface = null; |
| 567 | } else { |
| 568 | mServiceInterface = ICallService.Stub.asInterface(binder); |
| 569 | setCallServiceAdapter(mAdapter); |
| 570 | } |
Santos Cordon | 5c12c6e | 2014-02-13 14:35:31 -0800 | [diff] [blame] | 571 | } |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 572 | |
| 573 | /** |
| 574 | * Called when the associated call service dies. |
| 575 | */ |
| 576 | private void handleCallServiceDeath() { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 577 | if (!mPendingOutgoingCalls.isEmpty()) { |
| 578 | for (AsyncResultCallback<Boolean> callback : mPendingOutgoingCalls.values()) { |
Ihab Awad | a3cb9e3 | 2014-06-03 18:45:05 -0700 | [diff] [blame] | 579 | callback.onResult(false, DisconnectCause.ERROR_UNSPECIFIED, null); |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 580 | } |
| 581 | mPendingOutgoingCalls.clear(); |
| 582 | } |
| 583 | |
| 584 | if (!mPendingIncomingCalls.isEmpty()) { |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 585 | // Iterate through a copy because the code inside the loop will modify the original |
| 586 | // list. |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 587 | for (Call call : ImmutableList.copyOf(mPendingIncomingCalls)) { |
| 588 | Preconditions.checkState(call.isIncoming()); |
| 589 | mIncomingCallsManager.handleFailedIncomingCall(call); |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 590 | } |
| 591 | |
Santos Cordon | 8f3282c | 2014-06-01 13:56:02 -0700 | [diff] [blame] | 592 | if (!mPendingIncomingCalls.isEmpty()) { |
| 593 | Log.wtf(this, "Pending calls did not get cleared."); |
| 594 | mPendingIncomingCalls.clear(); |
| 595 | } |
Santos Cordon | 3d3b405 | 2014-05-05 12:05:36 -0700 | [diff] [blame] | 596 | } |
Santos Cordon | 8f3282c | 2014-06-01 13:56:02 -0700 | [diff] [blame] | 597 | |
| 598 | mCallIdMapper.clear(); |
| 599 | } |
Santos Cordon | 63aeb16 | 2014-02-10 09:20:40 -0800 | [diff] [blame] | 600 | } |