Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -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 | |
Ben Gilad | d88323b | 2014-01-29 19:03:19 -0800 | [diff] [blame] | 19 | import android.os.Handler; |
| 20 | import android.os.Looper; |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 21 | import android.os.RemoteException; |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 22 | import android.telecomm.CallState; |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 23 | import android.telecomm.CallServiceDescriptor; |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame^] | 24 | import android.telecomm.CallServiceSelector.CallServiceSelectionResponse; |
Sailesh Nepal | b6141ae | 2014-02-18 08:45:26 -0800 | [diff] [blame] | 25 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 26 | import com.google.android.collect.Sets; |
| 27 | import com.google.common.collect.Maps; |
| 28 | import com.google.common.collect.Lists; |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 29 | |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame^] | 30 | import java.util.Collection; |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 31 | import java.util.Iterator; |
| 32 | import java.util.List; |
| 33 | import java.util.Map; |
| 34 | import java.util.Set; |
| 35 | |
| 36 | /** |
| 37 | * Utility class to place a call using the specified set of call-services and ordered selectors. |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 38 | * Iterates through the selectors and gets a sorted list of supported call-service descriptors |
| 39 | * for each selector. Upon receiving each sorted list (one list per selector), each of the |
| 40 | * corresponding call services is then attempted until either the outgoing call is placed, the |
| 41 | * attempted call is aborted (by the switchboard), or the list is exhausted -- whichever occurs |
| 42 | * first. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 43 | * |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 44 | * Except for the abort case, all other scenarios should terminate with the switchboard notified |
| 45 | * of the result. |
Ben Gilad | d88323b | 2014-01-29 19:03:19 -0800 | [diff] [blame] | 46 | * |
| 47 | * NOTE(gilad): Currently operating under the assumption that we'll have one timeout per (outgoing) |
| 48 | * call attempt. If we (also) like to timeout individual selectors and/or call services, the code |
| 49 | * here will need to be re-factored (quite a bit) to support that. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 50 | */ |
| 51 | final class OutgoingCallProcessor { |
| 52 | |
| 53 | /** |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 54 | * The outgoing call this processor is tasked with placing. |
| 55 | */ |
| 56 | private final Call mCall; |
| 57 | |
| 58 | /** |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 59 | * The duplicate-free list of currently-available call-service descriptors. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 60 | */ |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 61 | private final List<CallServiceDescriptor> mCallServiceDescriptors = Lists.newArrayList(); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 62 | |
| 63 | /** |
Sailesh Nepal | b6141ae | 2014-02-18 08:45:26 -0800 | [diff] [blame] | 64 | * The map of currently-available call-service implementations keyed by call-service ID. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 65 | */ |
Sailesh Nepal | b6141ae | 2014-02-18 08:45:26 -0800 | [diff] [blame] | 66 | private final Map<String, CallServiceWrapper> mCallServicesById = Maps.newHashMap(); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 69 | * The set of attempted call services, used to ensure services are attempted at most once per |
| 70 | * outgoing-call attempt. |
| 71 | */ |
| 72 | private final Set<CallServiceWrapper> mAttemptedCallServices = Sets.newHashSet(); |
| 73 | |
| 74 | /** |
| 75 | * The set of incompatible call services, used to suppress unnecessary call switching attempts. |
| 76 | */ |
| 77 | private final Set<CallServiceWrapper> mIncompatibleCallServices = Sets.newHashSet(); |
| 78 | |
| 79 | /** |
Ben Gilad | 28e8ad6 | 2014-03-06 17:01:54 -0800 | [diff] [blame] | 80 | * The list of currently-available call-service selector implementations. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 81 | */ |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame^] | 82 | private final Collection<CallServiceSelectorWrapper> mSelectors; |
Ben Gilad | d88323b | 2014-01-29 19:03:19 -0800 | [diff] [blame] | 83 | |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 84 | /** Manages all outgoing call processors. */ |
| 85 | private final OutgoingCallsManager mOutgoingCallsManager; |
| 86 | |
| 87 | private final Switchboard mSwitchboard; |
| 88 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 89 | private final Runnable mNextCallServiceCallback = new Runnable() { |
| 90 | @Override public void run() { |
| 91 | attemptNextCallService(); |
| 92 | } |
| 93 | }; |
| 94 | |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame^] | 95 | private final Runnable mNextSelectorCallback = new Runnable() { |
| 96 | @Override public void run() { |
| 97 | attemptNextSelector(); |
| 98 | } |
| 99 | }; |
| 100 | |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 101 | /** |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 102 | * The iterator over the currently-selected ordered list of call-service descriptors. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 103 | */ |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 104 | private Iterator<CallServiceDescriptor> mCallServiceDescriptorIterator; |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 105 | |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame^] | 106 | private Iterator<CallServiceSelectorWrapper> mSelectorIterator; |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 107 | |
| 108 | private boolean mIsAborted = false; |
| 109 | |
| 110 | /** |
| 111 | * Persists the specified parameters and iterates through the prioritized list of selectors |
| 112 | * passing to each selector (read-only versions of) the call object and all available call- |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 113 | * service descriptors. Stops once a matching selector is found. Calls with no matching |
| 114 | * selectors will eventually be killed by the cleanup/monitor switchboard handler, which will |
| 115 | * in turn call the abort method of this processor via {@link OutgoingCallsManager}. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 116 | * |
| 117 | * @param call The call to place. |
| 118 | * @param callServices The available call-service implementations. |
| 119 | * @param selectors The available call-service selector implementations. |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 120 | * @param outgoingCallsManager Manager of all outgoing call processors. |
| 121 | * @param switchboard The switchboard. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 122 | */ |
| 123 | OutgoingCallProcessor( |
| 124 | Call call, |
Santos Cordon | c195e36 | 2014-02-11 17:05:31 -0800 | [diff] [blame] | 125 | Set<CallServiceWrapper> callServices, |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame^] | 126 | Collection<CallServiceSelectorWrapper> selectors, |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 127 | OutgoingCallsManager outgoingCallsManager, |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 128 | Switchboard switchboard) { |
| 129 | |
Ben Gilad | d88323b | 2014-01-29 19:03:19 -0800 | [diff] [blame] | 130 | ThreadUtil.checkOnMainThread(); |
| 131 | |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 132 | mCall = call; |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 133 | mSelectors = selectors; |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 134 | mOutgoingCallsManager = outgoingCallsManager; |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 135 | mSwitchboard = switchboard; |
| 136 | |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 137 | // Populate the list and map of call-service descriptors. The list is needed since |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 138 | // it's being passed down to selectors. |
Santos Cordon | c195e36 | 2014-02-11 17:05:31 -0800 | [diff] [blame] | 139 | for (CallServiceWrapper callService : callServices) { |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 140 | CallServiceDescriptor descriptor = callService.getDescriptor(); |
| 141 | mCallServiceDescriptors.add(descriptor); |
| 142 | mCallServicesById.put(descriptor.getCallServiceId(), callService); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Initiates the attempt to place the call. No-op beyond the first invocation. |
| 148 | */ |
| 149 | void process() { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 150 | Log.v(this, "process, mIsAborted: %b", mIsAborted); |
Ben Gilad | 28e8ad6 | 2014-03-06 17:01:54 -0800 | [diff] [blame] | 151 | if (!mIsAborted) { |
| 152 | // Only process un-aborted calls. |
| 153 | ThreadUtil.checkOnMainThread(); |
Ben Gilad | d88323b | 2014-01-29 19:03:19 -0800 | [diff] [blame] | 154 | |
Ben Gilad | 28e8ad6 | 2014-03-06 17:01:54 -0800 | [diff] [blame] | 155 | if (mSelectorIterator == null) { |
| 156 | mSelectorIterator = mSelectors.iterator(); |
| 157 | attemptNextSelector(); |
| 158 | } |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
| 162 | /** |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 163 | * Handles the specified compatibility status from the call-service implementation. |
| 164 | * TODO(gilad): Consider making this class stateful, potentially rejecting out-of-order/ |
| 165 | * unexpected invocations (i.e. beyond checking for unexpected call IDs). |
| 166 | * |
| 167 | * @param callId The ID of the call. |
| 168 | * @param isCompatible True if the call-service is compatible with the corresponding call and |
| 169 | * false otherwise. |
| 170 | */ |
| 171 | void setIsCompatibleWith(String callId, boolean isCompatible) { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 172 | Log.v(this, "setIsCompatibleWith, callId: %s, isCompatible: %b", callId, isCompatible); |
| 173 | if (!callId.equals(mCall.getId())) { |
| 174 | Log.wtf(this, "setIsCompatibleWith invoked with unexpected call ID: %s - expected call" |
Yorke Lee | adee12d | 2014-03-13 12:08:30 -0700 | [diff] [blame] | 175 | + " ID: %s", callId, mCall.getId()); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 176 | return; |
| 177 | } |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 178 | |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 179 | if (!mIsAborted) { |
| 180 | CallServiceWrapper callService = mCall.getCallService(); |
| 181 | if (callService != null) { |
| 182 | if (isCompatible) { |
| 183 | callService.call(mCall.toCallInfo(), mNextCallServiceCallback); |
| 184 | return; |
| 185 | } |
| 186 | mIncompatibleCallServices.add(callService); |
| 187 | } |
| 188 | attemptNextCallService(); |
| 189 | } |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | /** |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 193 | * Aborts the attempt to place the relevant call. Intended to be invoked by |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 194 | * switchboard through the outgoing-calls manager. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 195 | */ |
| 196 | void abort() { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 197 | Log.v(this, "abort"); |
Ben Gilad | 9c23411 | 2014-03-04 16:07:33 -0800 | [diff] [blame] | 198 | ThreadUtil.checkOnMainThread(); |
| 199 | if (!mIsAborted) { |
Ben Gilad | 9c23411 | 2014-03-04 16:07:33 -0800 | [diff] [blame] | 200 | mIsAborted = true; |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 201 | mOutgoingCallsManager.handleFailedOutgoingCall(mCall, true /* isAborted */); |
Ben Gilad | 9c23411 | 2014-03-04 16:07:33 -0800 | [diff] [blame] | 202 | } |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /** |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 206 | * Completes the outgoing call sequence by setting the call service on the call object. This is |
| 207 | * invoked when the call service adapter receives positive confirmation that the call service |
| 208 | * placed the call. |
| 209 | */ |
| 210 | void handleSuccessfulCallAttempt() { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 211 | Log.v(this, "handleSuccessfulCallAttempt"); |
Ben Gilad | 8e55d1d | 2014-02-26 16:25:56 -0800 | [diff] [blame] | 212 | ThreadUtil.checkOnMainThread(); |
| 213 | |
| 214 | if (mIsAborted) { |
| 215 | // TODO(gilad): Ask the call service to drop the call? |
| 216 | return; |
| 217 | } |
| 218 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 219 | for (CallServiceWrapper callService : mIncompatibleCallServices) { |
| 220 | mCall.addIncompatibleCallService(callService); |
| 221 | } |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 222 | mSwitchboard.handleSuccessfulOutgoingCall(mCall); |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Attempts the next call service if the specified call service is the one currently being |
| 227 | * attempted. |
| 228 | * |
| 229 | * @param reason The call-service supplied reason for the failed call attempt. |
| 230 | */ |
| 231 | void handleFailedCallAttempt(String reason) { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 232 | Log.v(this, "handleFailedCallAttempt"); |
Ben Gilad | 28e8ad6 | 2014-03-06 17:01:54 -0800 | [diff] [blame] | 233 | if (!mIsAborted) { |
| 234 | ThreadUtil.checkOnMainThread(); |
Ben Gilad | 8e55d1d | 2014-02-26 16:25:56 -0800 | [diff] [blame] | 235 | |
Ben Gilad | 28e8ad6 | 2014-03-06 17:01:54 -0800 | [diff] [blame] | 236 | mCall.clearCallService(); |
| 237 | mCall.clearCallServiceSelector(); |
| 238 | attemptNextCallService(); |
| 239 | } |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | /** |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 243 | * Attempts to place the call using the next selector, no-op if no other selectors |
| 244 | * are available. |
| 245 | */ |
| 246 | private void attemptNextSelector() { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 247 | Log.v(this, "attemptNextSelector, mIsAborted: %b", mIsAborted); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 248 | if (mIsAborted) { |
| 249 | return; |
| 250 | } |
| 251 | |
| 252 | if (mSelectorIterator.hasNext()) { |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame^] | 253 | CallServiceSelectorWrapper selector = mSelectorIterator.next(); |
Ben Gilad | 8e55d1d | 2014-02-26 16:25:56 -0800 | [diff] [blame] | 254 | mCall.setCallServiceSelector(selector); |
| 255 | |
Sailesh Nepal | 18386a8 | 2014-03-19 10:22:40 -0700 | [diff] [blame^] | 256 | CallServiceSelectionResponse responseCallback = new CallServiceSelectionResponse() { |
| 257 | @Override |
| 258 | public void setSelectedCallServices(List<CallServiceDescriptor> callServices) { |
| 259 | processSelectedCallServiceDescriptors(callServices); |
| 260 | } |
| 261 | }; |
| 262 | selector.select(mCall.toCallInfo(), mCallServiceDescriptors, responseCallback, |
| 263 | mNextSelectorCallback); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 264 | } else { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 265 | Log.v(this, "attemptNextSelector, no more selectors, failing"); |
| 266 | mOutgoingCallsManager.handleFailedOutgoingCall(mCall, false /* isAborted */); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | |
| 270 | /** |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 271 | * Persists the ordered-list of call-service descriptor as selected by the current selector and |
| 272 | * starts iterating through the corresponding call services continuing the attempt to place the |
| 273 | * call. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 274 | * |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 275 | * @selectedCallServiceDescriptors The (ordered) list of call-service descriptor. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 276 | */ |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 277 | private void processSelectedCallServiceDescriptors( |
| 278 | List<CallServiceDescriptor> selectedCallServiceDescriptors) { |
| 279 | |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 280 | Log.v(this, "processSelectedCallServiceDescriptors"); |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 281 | if (selectedCallServiceDescriptors == null || selectedCallServiceDescriptors.isEmpty()) { |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 282 | attemptNextSelector(); |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 283 | } else if (mCallServiceDescriptorIterator == null) { |
| 284 | mCallServiceDescriptorIterator = selectedCallServiceDescriptors.iterator(); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 285 | attemptNextCallService(); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | /** |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 290 | * Attempts to place the call using the call service specified by the next call-service |
| 291 | * descriptor of mCallServiceDescriptorIterator. If there are no more call services to |
| 292 | * attempt, the process continues to the next call-service selector via |
| 293 | * {@link #attemptNextSelector}. |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 294 | */ |
| 295 | private void attemptNextCallService() { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 296 | Log.v(this, "attemptNextCallService, mIsAborted: %b", mIsAborted); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 297 | if (mIsAborted) { |
| 298 | return; |
| 299 | } |
| 300 | |
Evan Charlton | f02e988 | 2014-03-06 12:54:52 -0800 | [diff] [blame] | 301 | if (mCallServiceDescriptorIterator != null && mCallServiceDescriptorIterator.hasNext()) { |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 302 | CallServiceDescriptor descriptor = mCallServiceDescriptorIterator.next(); |
Ben Gilad | 8e55d1d | 2014-02-26 16:25:56 -0800 | [diff] [blame] | 303 | final CallServiceWrapper callService = |
| 304 | mCallServicesById.get(descriptor.getCallServiceId()); |
| 305 | |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 306 | if (callService == null || mAttemptedCallServices.contains(callService)) { |
| 307 | // The next call service is either null or has already been attempted, fast forward |
| 308 | // to the next. |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 309 | attemptNextCallService(); |
| 310 | } else { |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 311 | mAttemptedCallServices.add(callService); |
Ben Gilad | 8e55d1d | 2014-02-26 16:25:56 -0800 | [diff] [blame] | 312 | mCall.setCallService(callService); |
Ben Gilad | 6192561 | 2014-03-11 19:06:36 -0700 | [diff] [blame] | 313 | callService.isCompatibleWith(mCall.toCallInfo(), mNextCallServiceCallback); |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 314 | } |
| 315 | } else { |
Ben Gilad | c5b2269 | 2014-02-18 20:03:22 -0800 | [diff] [blame] | 316 | mCallServiceDescriptorIterator = null; |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 317 | attemptNextSelector(); |
| 318 | } |
| 319 | } |
Ben Gilad | 0bf5b91 | 2014-01-28 17:55:57 -0800 | [diff] [blame] | 320 | } |