diff --git a/src/com/android/telecomm/OutgoingCallProcessor.java b/src/com/android/telecomm/OutgoingCallProcessor.java index 0a2df043c..34649f08d 100644 --- a/src/com/android/telecomm/OutgoingCallProcessor.java +++ b/src/com/android/telecomm/OutgoingCallProcessor.java @@ -23,12 +23,12 @@ import com.google.common.collect.Lists; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; -import android.telecomm.CallInfo; import android.telecomm.CallState; import android.telecomm.CallServiceInfo; import android.telecomm.ICallServiceSelectionResponse; import android.telecomm.ICallServiceSelector; -import android.util.Log; + +import com.android.telecomm.ServiceBinder.BindCallback; import java.util.Iterator; import java.util.List; @@ -62,9 +62,9 @@ final class OutgoingCallProcessor { private final List mCallServiceInfos = Lists.newArrayList(); /** - * The map of currently-available call-service implementations keyed by call-service infos. + * The map of currently-available call-service implementations keyed by call-service ID. */ - private final Map mCallServicesByInfo = Maps.newHashMap(); + private final Map mCallServicesById = Maps.newHashMap(); /** * The set of currently-available call-service selector implementations. @@ -129,7 +129,7 @@ final class OutgoingCallProcessor { for (CallServiceWrapper callService : callServices) { CallServiceInfo info = callService.getInfo(); mCallServiceInfos.add(info); - mCallServicesByInfo.put(info, callService); + mCallServicesById.put(info.getCallServiceId(), callService); } } @@ -253,11 +253,19 @@ final class OutgoingCallProcessor { if (mCallServiceInfoIterator.hasNext()) { CallServiceInfo info = mCallServiceInfoIterator.next(); - mCallService = mCallServicesByInfo.get(info); + mCallService = mCallServicesById.get(info.getCallServiceId()); if (mCallService == null) { attemptNextCallService(); } else { - mCallService.call(mCall.toCallInfo()); + BindCallback callback = new BindCallback() { + @Override public void onSuccess() { + mCallService.call(mCall.toCallInfo()); + } + @Override public void onFailure() { + attemptNextSelector(); + } + }; + mCallService.bind(callback); } } else { mCallServiceInfoIterator = null; diff --git a/src/com/android/telecomm/ServiceBinder.java b/src/com/android/telecomm/ServiceBinder.java index c58791c3f..101b940cd 100644 --- a/src/com/android/telecomm/ServiceBinder.java +++ b/src/com/android/telecomm/ServiceBinder.java @@ -59,7 +59,8 @@ abstract class ServiceBinder { mServiceConnection = this; mBinder = binder; - handleSuccessfulConnection(binder); + setServiceInterface(binder); + handleSuccessfulConnection(); } @Override @@ -140,7 +141,7 @@ abstract class ServiceBinder { } } else { Preconditions.checkNotNull(mBinder); - handleSuccessfulConnection(mBinder); + handleSuccessfulConnection(); } return true; @@ -169,12 +170,8 @@ abstract class ServiceBinder { /** * Notifies all the outstanding callbacks that the service is successfully bound. The list of * outstanding callbacks is cleared afterwards. - * - * @param binder The actual bound service implementation. */ - private void handleSuccessfulConnection(IBinder binder) { - setServiceInterface(binder); - + private void handleSuccessfulConnection() { for (BindCallback callback : mCallbacks) { callback.onSuccess(); } diff --git a/src/com/android/telecomm/Switchboard.java b/src/com/android/telecomm/Switchboard.java index 32ef91409..017a8d582 100644 --- a/src/com/android/telecomm/Switchboard.java +++ b/src/com/android/telecomm/Switchboard.java @@ -114,10 +114,11 @@ final class Switchboard { void placeOutgoingCall(Call call) { ThreadUtil.checkOnMainThread(); - mLookupId++; + mNewOutgoingCalls.add(call); // We initialize a lookup every time because between calls the set of available call // services can change between calls. + mLookupId++; mCallServiceRepository.initiateLookup(mLookupId); mSelectorRepository.initiateLookup(mLookupId); }