Add IncomingCallsMangager to perform the incoming call sequence.
IncomingCallsManager binds to the call service and asks it to confirm
the call. If the call service cannot be bound or it failed to confirm
within the timeout, we handle the incoming call as if it failed. The
code to do the actual confirmation is NYI.
Also add handleSuccess/Failed methods to Switchboard.
This still needs some changes to ICallService, ICallServiceAdapter, and
CallServiceWrapper before it will be fully functional.
Change-Id: Ibfd92ce17fb2054e2e0cb209738ad5375bf01492
diff --git a/src/com/android/telecomm/Switchboard.java b/src/com/android/telecomm/Switchboard.java
index 32ef914..b5925cc 100644
--- a/src/com/android/telecomm/Switchboard.java
+++ b/src/com/android/telecomm/Switchboard.java
@@ -20,9 +20,9 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import android.content.Context;
import android.os.Handler;
import android.os.Looper;
+import android.telecomm.CallServiceInfo;
import android.telecomm.ICallServiceSelector;
import java.util.Collection;
@@ -47,6 +47,9 @@
/** Used to place outgoing calls. */
private final OutgoingCallsManager mOutgoingCallsManager;
+ /** Used to confirm incoming calls. */
+ private final IncomingCallsManager mIncomingCallsManager;
+
private final CallServiceRepository mCallServiceRepository;
private final CallServiceSelectorRepository mSelectorRepository;
@@ -100,6 +103,7 @@
Switchboard(CallsManager callsManager) {
mCallsManager = callsManager;
mOutgoingCallsManager = new OutgoingCallsManager(this);
+ mIncomingCallsManager = new IncomingCallsManager(this);
mCallServiceRepository = new CallServiceRepository(this, mOutgoingCallsManager);
mSelectorRepository = new CallServiceSelectorRepository(this);
}
@@ -123,6 +127,21 @@
}
/**
+ * Confirms with incoming call manager that an incoming call exists for the specified call
+ * service and call token. The incoming call manager will invoke either
+ * {@link #handleSuccessfulIncomingCall} or {@link #handleFailedIncomingCall} depending
+ * on the result.
+ *
+ * @param call The call object.
+ * @param callServiceInfo The details of the call service.
+ * @param callToken The token used by the call service to identify the incoming call.
+ */
+ void confirmIncomingCall(Call call, CallServiceInfo callServiceInfo, String callToken) {
+ CallServiceWrapper callService = mCallServiceRepository.getCallService(callServiceInfo);
+ mIncomingCallsManager.confirmIncomingCall(call, callService, callToken);
+ }
+
+ /**
* Persists the specified set of call services and attempts to place any pending outgoing
* calls. Intended to be invoked by {@link CallServiceRepository} exclusively.
*
@@ -181,6 +200,29 @@
}
/**
+ * Handles the case where we received confirmation of an incoming call. Hands the resulting
+ * call to {@link CallsManager} as the final step in the incoming sequence. At that point,
+ * {@link CallsManager} should bring up the incoming-call UI.
+ */
+ void handleSuccessfulIncomingCall(Call call) {
+ mCallsManager.handleSuccessfulIncomingCall(call);
+ }
+
+ /**
+ * Handles the case where we failed to confirm an incoming call after receiving an incoming-call
+ * intent via {@link TelecommReceiver}.
+ *
+ * @param call The call.
+ */
+ void handleFailedIncomingCall(Call call) {
+ // At the moment there is nothing to do if an incoming call is not confirmed. We may at a
+ // future date bind to the in-call app optimistically during the incoming-call sequence and
+ // this method could tell {@link CallsManager} to unbind from the in-call app if the
+ // incoming call was not confirmed. It's worth keeping this method for parity with the
+ // outgoing call sequence.
+ }
+
+ /**
* @return True if ticking should continue (or be resumed) and false otherwise.
*/
private boolean isTicking() {