blob: c2df63e1e43d037cf09184ff944fea567a8230ff [file] [log] [blame]
Santos Cordon8e8b8d22013-12-19 14:14:05 -08001/*
2 * Copyright 2013, 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
Ben Gilad9f2bed32013-12-12 17:43:26 -080017package com.android.telecomm;
18
Santos Cordon5b7b9b32014-03-26 14:00:22 -070019import android.content.ComponentName;
Evan Charltona05805b2014-03-05 08:21:46 -080020import android.os.Bundle;
Ben Gilad2313e622014-02-06 12:02:25 -080021import android.os.Handler;
22import android.os.Looper;
Sailesh Nepal810735e2014-03-18 18:15:46 -070023import android.telecomm.CallInfo;
Ben Giladc5b22692014-02-18 20:03:22 -080024import android.telecomm.CallServiceDescriptor;
Evan Charltona05805b2014-03-05 08:21:46 -080025import android.telecomm.TelecommConstants;
Santos Cordon8e8b8d22013-12-19 14:14:05 -080026
Santos Cordon5b7b9b32014-03-26 14:00:22 -070027import com.google.common.base.Preconditions;
28import com.google.common.collect.ImmutableCollection;
29import com.google.common.collect.ImmutableList;
30import com.google.common.collect.Sets;
31
32import java.util.Collection;
Ben Gilad8e55d1d2014-02-26 16:25:56 -080033import java.util.Iterator;
Ben Gilad0407fb22014-01-09 16:18:41 -080034import java.util.Set;
Ben Gilad9f2bed32013-12-12 17:43:26 -080035
Santos Cordon8e8b8d22013-12-19 14:14:05 -080036/**
Sailesh Nepal18386a82014-03-19 10:22:40 -070037 * Switchboard is responsible for:
Santos Cordon5b7b9b32014-03-26 14:00:22 -070038 * - gathering the {@link CallServiceWrapper}s and {@link CallServiceSelectorWrapper}s through
39 * which to place outgoing calls
40 * - starting outgoing calls (via {@link OutgoingCallsManager}
41 * - switching active calls between call services.
Santos Cordon8e8b8d22013-12-19 14:14:05 -080042 */
Ben Giladd17443c2014-01-06 11:04:15 -080043final class Switchboard {
Ben Gilad2495d572014-01-09 17:26:19 -080044
Santos Cordon681663d2014-01-30 04:32:15 -080045 private final CallsManager mCallsManager;
Ben Gilad2313e622014-02-06 12:02:25 -080046
Santos Cordon681663d2014-01-30 04:32:15 -080047 /** Used to place outgoing calls. */
48 private final OutgoingCallsManager mOutgoingCallsManager;
49
Santos Cordon493e8f22014-02-19 03:15:12 -080050 /** Used to retrieve incoming call details. */
Santos Cordon80d9bdc2014-02-13 18:28:46 -080051 private final IncomingCallsManager mIncomingCallsManager;
52
Santos Cordonc195e362014-02-11 17:05:31 -080053 private final CallServiceRepository mCallServiceRepository;
Santos Cordon681663d2014-01-30 04:32:15 -080054
Santos Cordonc195e362014-02-11 17:05:31 -080055 private final CallServiceSelectorRepository mSelectorRepository;
Ben Gilad2313e622014-02-06 12:02:25 -080056
Ben Gilad8e55d1d2014-02-26 16:25:56 -080057 private final BinderDeallocator mBinderDeallocator;
58
Ben Gilad2313e622014-02-06 12:02:25 -080059 /** Used to schedule tasks on the main (UI) thread. */
60 private final Handler mHandler = new Handler(Looper.getMainLooper());
61
62 /**
63 * Executes a single tick task and potentially schedules the next such that polling continues
64 * as long as necessary.
65 * NOTE(gilad): by design no two tick invocations should ever overlap.
66 */
67 private final Runnable mTicker = new Runnable() {
68 @Override
69 public void run() {
70 tick();
71 if (isTicking()) {
72 scheduleNextTick();
73 }
74 }
75 };
76
77 private final Set<Call> mNewOutgoingCalls = Sets.newLinkedHashSet();
78
79 private final Set<Call> mPendingOutgoingCalls = Sets.newLinkedHashSet();
Ben Giladb59769e2014-01-16 11:41:10 -080080
Ben Gilad03292d42014-01-16 15:06:16 -080081 /**
Ben Giladbb167cd2014-02-25 16:24:05 -080082 * The set of currently available call-service implementations, see
Ben Gilad37587232014-02-19 16:03:44 -080083 * {@link CallServiceRepository}. Populated during call-service lookup cycles as part of the
84 * {@link #placeOutgoingCall} flow and cleared upon zero-remaining new/pending outgoing calls.
Ben Gilad03292d42014-01-16 15:06:16 -080085 */
Evan Charltonf02e9882014-03-06 12:54:52 -080086 private final Set<CallServiceWrapper> mCallServices = Sets.newHashSet();
Ben Giladb59769e2014-01-16 11:41:10 -080087
Ben Gilad03292d42014-01-16 15:06:16 -080088 /**
89 * The set of currently available call-service-selector implementations,
Santos Cordonc195e362014-02-11 17:05:31 -080090 * see {@link CallServiceSelectorRepository}.
Evan Charltonf02e9882014-03-06 12:54:52 -080091 * TODO(gilad): Clear once the active-call count goes to zero.
Ben Gilad03292d42014-01-16 15:06:16 -080092 */
Sailesh Nepal18386a82014-03-19 10:22:40 -070093 private ImmutableCollection<CallServiceSelectorWrapper> mSelectors = ImmutableList.of();
Ben Gilad0407fb22014-01-09 16:18:41 -080094
Santos Cordon681663d2014-01-30 04:32:15 -080095 /**
Santos Cordonc195e362014-02-11 17:05:31 -080096 * The current lookup-cycle ID used with the repositories. Incremented with each invocation
Ben Gilad37587232014-02-19 16:03:44 -080097 * of {@link #placeOutgoingCall} and passed to the repositories via initiateLookup().
Santos Cordonc195e362014-02-11 17:05:31 -080098 */
99 private int mLookupId = 0;
100
101 /**
Santos Cordon681663d2014-01-30 04:32:15 -0800102 * Persists the specified parameters and initializes Switchboard.
103 */
Santos Cordon6242b132014-02-07 16:24:42 -0800104 Switchboard(CallsManager callsManager) {
105 mCallsManager = callsManager;
Santos Cordon681663d2014-01-30 04:32:15 -0800106 mOutgoingCallsManager = new OutgoingCallsManager(this);
Santos Cordon80d9bdc2014-02-13 18:28:46 -0800107 mIncomingCallsManager = new IncomingCallsManager(this);
Sailesh Nepal6ab6fb72014-04-01 20:03:19 -0700108 mSelectorRepository = new CallServiceSelectorRepository(this, mOutgoingCallsManager);
Santos Cordon493e8f22014-02-19 03:15:12 -0800109 mCallServiceRepository =
110 new CallServiceRepository(this, mOutgoingCallsManager, mIncomingCallsManager);
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800111
112 mBinderDeallocator = new BinderDeallocator();
Santos Cordon681663d2014-01-30 04:32:15 -0800113 }
Ben Giladd17443c2014-01-06 11:04:15 -0800114
Santos Cordon8e8b8d22013-12-19 14:14:05 -0800115 /**
Santos Cordonc195e362014-02-11 17:05:31 -0800116 * Starts the process of placing an outgoing call by searching for available call services
117 * through which the call can be placed. After a lookup for those services completes, execution
118 * returns to {@link #setCallServices} where the process of placing the call continues.
Santos Cordon8e8b8d22013-12-19 14:14:05 -0800119 *
Ben Gilad13329fd2014-02-11 17:20:29 -0800120 * @param call The yet-to-be-connected outgoing-call object.
Santos Cordon8e8b8d22013-12-19 14:14:05 -0800121 */
Santos Cordonc195e362014-02-11 17:05:31 -0800122 void placeOutgoingCall(Call call) {
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800123 mBinderDeallocator.acquireUsePermit();
Ben Giladb59769e2014-01-16 11:41:10 -0800124
Ben Giladbb167cd2014-02-25 16:24:05 -0800125 // Reset prior to initiating the next lookup. One case to consider is (1) placeOutgoingCall
126 // is invoked with call A, (2) the call-service lookup completes, but the one for selectors
127 // does not, (3) placeOutgoingCall is invoked again with call B, (4) mCallServices below is
128 // reset, (5) the selector lookup completes but the call-services are missing. This should
129 // be okay since the call-service lookup completed. Specifically the already-available call
130 // services are cached and will be provided in response to the second lookup cycle.
Evan Charltonf02e9882014-03-06 12:54:52 -0800131 mCallServices.clear();
Sailesh Nepal18386a82014-03-19 10:22:40 -0700132 mSelectors = ImmutableList.of();
Ben Giladbb167cd2014-02-25 16:24:05 -0800133
Sailesh Nepalb6141ae2014-02-18 08:45:26 -0800134 mNewOutgoingCalls.add(call);
Ben Giladb59769e2014-01-16 11:41:10 -0800135
Ben Giladebd9b662014-02-19 16:03:44 -0800136 // Initiate a lookup every time to account for newly-installed apps and/or updated settings.
Sailesh Nepalb6141ae2014-02-18 08:45:26 -0800137 mLookupId++;
Santos Cordonc195e362014-02-11 17:05:31 -0800138 mCallServiceRepository.initiateLookup(mLookupId);
139 mSelectorRepository.initiateLookup(mLookupId);
Ben Gilad0407fb22014-01-09 16:18:41 -0800140 }
Ben Gilad9f2bed32013-12-12 17:43:26 -0800141
Ben Gilad0407fb22014-01-09 16:18:41 -0800142 /**
Santos Cordon493e8f22014-02-19 03:15:12 -0800143 * Retrieves details about the incoming call through the incoming call manager. The incoming
144 * call manager will invoke either {@link #handleSuccessfulIncomingCall} or
145 * {@link #handleFailedIncomingCall} depending on the result of the retrieval.
Santos Cordon80d9bdc2014-02-13 18:28:46 -0800146 *
147 * @param call The call object.
Ben Giladc5b22692014-02-18 20:03:22 -0800148 * @param descriptor The relevant call-service descriptor.
Evan Charltona05805b2014-03-05 08:21:46 -0800149 * @param extras The optional extras passed via
Santos Cordon5b7b9b32014-03-26 14:00:22 -0700150 * {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}
Santos Cordon80d9bdc2014-02-13 18:28:46 -0800151 */
Evan Charltona05805b2014-03-05 08:21:46 -0800152 void retrieveIncomingCall(Call call, CallServiceDescriptor descriptor, Bundle extras) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -0800153 Log.d(this, "retrieveIncomingCall");
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800154 mBinderDeallocator.acquireUsePermit();
155
Ben Giladc5b22692014-02-18 20:03:22 -0800156 CallServiceWrapper callService = mCallServiceRepository.getCallService(descriptor);
Santos Cordon493e8f22014-02-19 03:15:12 -0800157 call.setCallService(callService);
Evan Charltona05805b2014-03-05 08:21:46 -0800158 mIncomingCallsManager.retrieveIncomingCall(call, extras);
Santos Cordon80d9bdc2014-02-13 18:28:46 -0800159 }
160
161 /**
Ben Gilad0bf5b912014-01-28 17:55:57 -0800162 * Persists the specified set of call services and attempts to place any pending outgoing
Santos Cordonc195e362014-02-11 17:05:31 -0800163 * calls. Intended to be invoked by {@link CallServiceRepository} exclusively.
Ben Gilad0407fb22014-01-09 16:18:41 -0800164 *
Ben Gilad03292d42014-01-16 15:06:16 -0800165 * @param callServices The potentially-partial set of call services. Partial since the lookup
166 * process is time-boxed, such that some providers/call-services may be slow to respond and
167 * hence effectively omitted from the specified list.
Ben Gilad0407fb22014-01-09 16:18:41 -0800168 */
Santos Cordonc195e362014-02-11 17:05:31 -0800169 void setCallServices(Set<CallServiceWrapper> callServices) {
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800170 mBinderDeallocator.updateBinders(mCallServices);
Ben Gilad0407fb22014-01-09 16:18:41 -0800171
Evan Charltonf02e9882014-03-06 12:54:52 -0800172 mCallServices.clear();
173 mCallServices.addAll(callServices);
Ben Gilad0bf5b912014-01-28 17:55:57 -0800174 processNewOutgoingCalls();
Ben Giladb59769e2014-01-16 11:41:10 -0800175 }
176
177 /**
178 * Persists the specified list of selectors and attempts to connect any pending outgoing
Santos Cordonc195e362014-02-11 17:05:31 -0800179 * calls. Intended to be invoked by {@link CallServiceSelectorRepository} exclusively.
Ben Giladb59769e2014-01-16 11:41:10 -0800180 *
Sailesh Nepal18386a82014-03-19 10:22:40 -0700181 * @param selectors Collection of selectors. The order of the collection determines the order in
182 * which the selectors are tried.
Ben Giladb59769e2014-01-16 11:41:10 -0800183 */
Sailesh Nepal18386a82014-03-19 10:22:40 -0700184 void setSelectors(ImmutableCollection<CallServiceSelectorWrapper> selectors) {
185 // TODO(santoscordon):: Need to invoke updateBinders(selectors).
Ben Giladb59769e2014-01-16 11:41:10 -0800186 ThreadUtil.checkOnMainThread();
Sailesh Nepal18386a82014-03-19 10:22:40 -0700187 Preconditions.checkNotNull(selectors);
Ben Giladb59769e2014-01-16 11:41:10 -0800188
Ben Gilad134cf092014-01-16 18:26:12 -0800189 // TODO(gilad): Add logic to include the built-in selectors (e.g. for dealing with
190 // emergency calls) and order the entire set prior to the assignment below. If the
191 // built-in selectors can be implemented in a manner that does not require binding,
Sailesh Nepal18386a82014-03-19 10:22:40 -0700192 // that's probably preferred.
193 mSelectors = selectors;
Ben Gilad0bf5b912014-01-28 17:55:57 -0800194 processNewOutgoingCalls();
Ben Giladb59769e2014-01-16 11:41:10 -0800195 }
196
197 /**
Ben Gilad0bf5b912014-01-28 17:55:57 -0800198 * Handles the case where an outgoing call has been successfully placed,
199 * see {@link OutgoingCallProcessor}.
Ben Giladb59769e2014-01-16 11:41:10 -0800200 */
Ben Gilad0bf5b912014-01-28 17:55:57 -0800201 void handleSuccessfulOutgoingCall(Call call) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -0800202 Log.d(this, "handleSuccessfulOutgoingCall");
Ben Gilad0bf5b912014-01-28 17:55:57 -0800203
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800204 mCallsManager.handleSuccessfulOutgoingCall(call);
205 finalizeOutgoingCall(call);
Ben Gilad0bf5b912014-01-28 17:55:57 -0800206 }
207
208 /**
209 * Handles the case where an outgoing call could not be proceed by any of the
210 * selector/call-service implementations, see {@link OutgoingCallProcessor}.
211 */
Sailesh Nepal810735e2014-03-18 18:15:46 -0700212 void handleFailedOutgoingCall(Call call, boolean isAborted) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -0800213 Log.d(this, "handleFailedOutgoingCall");
Ben Gilad0bf5b912014-01-28 17:55:57 -0800214
Sailesh Nepal810735e2014-03-18 18:15:46 -0700215 mCallsManager.handleUnsuccessfulOutgoingCall(call, isAborted);
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800216 finalizeOutgoingCall(call);
Ben Gilad0bf5b912014-01-28 17:55:57 -0800217 }
218
219 /**
Santos Cordon493e8f22014-02-19 03:15:12 -0800220 * Handles the case where we successfully receive details of an incoming call. Hands the
221 * resulting call to {@link CallsManager} as the final step in the incoming sequence. At that
222 * point, {@link CallsManager} should bring up the incoming-call UI.
Santos Cordon80d9bdc2014-02-13 18:28:46 -0800223 */
Sailesh Nepal810735e2014-03-18 18:15:46 -0700224 void handleSuccessfulIncomingCall(Call call, CallInfo callInfo) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -0800225 Log.d(this, "handleSuccessfulIncomingCall");
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800226
Sailesh Nepal810735e2014-03-18 18:15:46 -0700227 mCallsManager.handleSuccessfulIncomingCall(call, callInfo);
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800228 mBinderDeallocator.releaseUsePermit();
Santos Cordon80d9bdc2014-02-13 18:28:46 -0800229 }
230
231 /**
Santos Cordon493e8f22014-02-19 03:15:12 -0800232 * Handles the case where we failed to retrieve an incoming call after receiving an incoming-call
233 * intent via {@link CallActivity}.
Santos Cordon80d9bdc2014-02-13 18:28:46 -0800234 *
235 * @param call The call.
236 */
237 void handleFailedIncomingCall(Call call) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -0800238 Log.d(this, "handleFailedIncomingCall");
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800239
Santos Cordon493e8f22014-02-19 03:15:12 -0800240 // Since we set the call service before calling into incoming-calls manager, we clear it for
241 // good measure if an error is reported.
242 call.clearCallService();
243
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800244 mBinderDeallocator.releaseUsePermit();
245
Sailesh Nepal810735e2014-03-18 18:15:46 -0700246 mCallsManager.handleUnsuccessfulIncomingCall(call);
247
Santos Cordon493e8f22014-02-19 03:15:12 -0800248 // At the moment there is nothing more to do if an incoming call is not retrieved. We may at
249 // a future date bind to the in-call app optimistically during the incoming-call sequence
250 // and this method could tell {@link CallsManager} to unbind from the in-call app if the
251 // incoming call was not retrieved.
Santos Cordon80d9bdc2014-02-13 18:28:46 -0800252 }
253
254 /**
Ben Gilad2313e622014-02-06 12:02:25 -0800255 * @return True if ticking should continue (or be resumed) and false otherwise.
256 */
257 private boolean isTicking() {
258 // TODO(gilad): return true every time at least one outgoing call is pending (i.e. waiting
Sailesh Nepal6ab6fb72014-04-01 20:03:19 -0700259 // to be connected by a call service).
Ben Gilad2313e622014-02-06 12:02:25 -0800260 return false;
261 }
262
263 /**
264 * Schedules the next tick invocation.
265 */
266 private void scheduleNextTick() {
Evan Charlton1063e282014-03-05 19:31:21 -0800267 mHandler.postDelayed(mTicker, Timeouts.getTickMs());
Ben Gilad2313e622014-02-06 12:02:25 -0800268 }
269
270 /**
Ben Gilad0bf5b912014-01-28 17:55:57 -0800271 * Attempts to process the next new outgoing calls that have not yet been expired.
272 */
273 private void processNewOutgoingCalls() {
Evan Charltonf02e9882014-03-06 12:54:52 -0800274 if (mCallServices.isEmpty() || mSelectors.isEmpty()) {
Ben Gilad0bf5b912014-01-28 17:55:57 -0800275 // At least one call service and one selector are required to process outgoing calls.
276 return;
277 }
278
279 if (!mNewOutgoingCalls.isEmpty()) {
280 Call call = mNewOutgoingCalls.iterator().next();
281 mNewOutgoingCalls.remove(call);
282 mPendingOutgoingCalls.add(call);
283
284 // Specifically only attempt to place one call at a time such that call services
285 // can be freed from needing to deal with concurrent requests.
286 processNewOutgoingCall(call);
Ben Gilad0407fb22014-01-09 16:18:41 -0800287 }
Ben Gilad9f2bed32013-12-12 17:43:26 -0800288 }
289
Santos Cordon8e8b8d22013-12-19 14:14:05 -0800290 /**
Ben Giladb59769e2014-01-16 11:41:10 -0800291 * Attempts to place the specified call.
292 *
Ben Gilad0bf5b912014-01-28 17:55:57 -0800293 * @param call The call to place.
Ben Giladb59769e2014-01-16 11:41:10 -0800294 */
Ben Gilad0bf5b912014-01-28 17:55:57 -0800295 private void processNewOutgoingCall(Call call) {
Sailesh Nepal84fa5f82014-04-02 11:01:11 -0700296 Collection<CallServiceSelectorWrapper> selectors;
297
298 // Use the call's selector if it's already tied to one. This is the case for handoff calls.
299 if (call.getCallServiceSelector() != null) {
300 selectors = ImmutableList.of(call.getCallServiceSelector());
301 } else {
302 selectors = mSelectors;
303 }
Santos Cordon5b7b9b32014-03-26 14:00:22 -0700304
305 boolean useEmergencySelector =
306 EmergencyCallServiceSelector.shouldUseSelector(call.getHandle());
307 Log.d(this, "processNewOutgoingCall, isEmergency=%b", useEmergencySelector);
308
309 if (useEmergencySelector) {
310 // This is potentially an emergency call so add the emergency selector before the
311 // other selectors.
312 ImmutableList.Builder<CallServiceSelectorWrapper> selectorsBuilder =
313 ImmutableList.builder();
314
315 ComponentName componentName = new ComponentName(
316 TelecommApp.getInstance(), EmergencyCallServiceSelector.class);
317 CallServiceSelectorWrapper emergencySelector =
318 new CallServiceSelectorWrapper(
319 componentName.flattenToShortString(),
320 componentName,
321 mCallsManager,
322 mOutgoingCallsManager);
323
324 selectorsBuilder.add(emergencySelector);
Sailesh Nepal84fa5f82014-04-02 11:01:11 -0700325 selectorsBuilder.addAll(selectors);
Santos Cordon5b7b9b32014-03-26 14:00:22 -0700326 selectors = selectorsBuilder.build();
327 }
328
329 mOutgoingCallsManager.placeCall(call, mCallServices, selectors);
Ben Giladb59769e2014-01-16 11:41:10 -0800330 }
331
332 /**
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800333 * Finalizes the outgoing-call sequence, regardless if it succeeded or failed.
334 */
335 private void finalizeOutgoingCall(Call call) {
336 mPendingOutgoingCalls.remove(call);
337
338 mBinderDeallocator.releaseUsePermit();
339 processNewOutgoingCalls(); // Process additional (new) calls, if any.
340 }
341
342 /**
343 * Performs the set of tasks that needs to be executed on polling basis.
344 */
345 private void tick() {
346 // TODO(gilad): Add the necessary logic to support switching.
347
348 expireStaleOutgoingCalls(mNewOutgoingCalls);
349 expireStaleOutgoingCalls(mPendingOutgoingCalls);
350 }
351
352 /**
353 * Identifies stale calls and takes the necessary steps to mark these as expired.
354 *
355 * @param calls The set of calls to iterate through.
356 */
357 private void expireStaleOutgoingCalls(Set<Call> calls) {
358 if (calls.isEmpty()) {
359 return;
360 }
361
Evan Charlton1063e282014-03-05 19:31:21 -0800362 final long newCallTimeoutMs = Timeouts.getNewOutgoingCallMs();
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800363 Iterator<Call> iterator = calls.iterator();
364 while (iterator.hasNext()) {
365 Call call = iterator.next();
Evan Charlton1063e282014-03-05 19:31:21 -0800366 if (call.getAgeInMilliseconds() >= newCallTimeoutMs) {
Sailesh Nepale59bb192014-04-01 18:33:59 -0700367 Log.d(this, "Call %s timed out.", call);
Ben Gilad8e55d1d2014-02-26 16:25:56 -0800368 mOutgoingCallsManager.abort(call);
369 calls.remove(call);
370
371 // TODO(gilad): We may also have expired calls that are not yet associated with an
372 // OutgoingCallProcessor (e.g. when newer calls are "blocked" on older-yet-expired
373 // ones), in which case call.abort may need to be invoked directly. Alternatively
374 // we can also create an OutgoingCallsManager instance for every new call at intent-
375 // processing time.
376
377 // TODO(gilad): Notify the user in the relevant cases (at least outgoing).
378
379 mBinderDeallocator.releaseUsePermit();
380 }
381 }
382 }
Ben Gilad9f2bed32013-12-12 17:43:26 -0800383}