Merge "Fix making outgoing calls" into master-nova-dev

This commit is contained in:
Sailesh Nepal 2014-02-19 01:42:04 +00:00 committed by Android (Google) Code Review
commit 4039aaf916
3 changed files with 21 additions and 15 deletions

View File

@ -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<CallServiceInfo> 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<CallServiceInfo, CallServiceWrapper> mCallServicesByInfo = Maps.newHashMap();
private final Map<String, CallServiceWrapper> 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;

View File

@ -59,7 +59,8 @@ abstract class ServiceBinder<ServiceInterface extends IInterface> {
mServiceConnection = this;
mBinder = binder;
handleSuccessfulConnection(binder);
setServiceInterface(binder);
handleSuccessfulConnection();
}
@Override
@ -140,7 +141,7 @@ abstract class ServiceBinder<ServiceInterface extends IInterface> {
}
} else {
Preconditions.checkNotNull(mBinder);
handleSuccessfulConnection(mBinder);
handleSuccessfulConnection();
}
return true;
@ -169,12 +170,8 @@ abstract class ServiceBinder<ServiceInterface extends IInterface> {
/**
* 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();
}

View File

@ -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);
}