Add gateway support to Telecomm
Add OutgoingCallIntentBroadcaster into the outgoing call flow.
This class allows third party apps to intercept and modify
outgoing phone calls, and also allows for the ability to extract
gateway information from outgoing call intents to allow for calls
to be made via gateway providers.
Bug: 13477768
Change-Id: Iee6a466b3ae7380136c3d7feba48602a14bc8507
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index 57074b7..568d7c6 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -19,6 +19,7 @@
import android.net.Uri;
import android.telecomm.CallInfo;
import android.telecomm.CallState;
+import android.telecomm.GatewayInfo;
import com.google.android.collect.Sets;
import com.google.common.base.Preconditions;
@@ -57,6 +58,12 @@
/** The handle with which to establish this call. */
private Uri mHandle;
+ /** The gateway information associated with this call. This stores the original call handle
+ * that the user is attempting to connect to via the gateway, the actual handle to dial in
+ * order to connect the call via the gateway, as well as the package name of the gateway
+ * service. */
+ private final GatewayInfo mGatewayInfo;
+
/**
* The call service which is attempted or already connecting this call.
*/
@@ -67,9 +74,6 @@
*/
private CallServiceSelectorWrapper mCallServiceSelector;
- /** Read-only and parcelable version of this call. */
- private CallInfo mCallInfo;
-
/**
* The set of call services that were attempted in the process of placing/switching this call
* but turned out unsuitable. Only used in the context of call switching.
@@ -82,7 +86,7 @@
* @param isIncoming True if this is an incoming call.
*/
Call(boolean isIncoming) {
- this(null, null, isIncoming);
+ this(null, null, null, isIncoming);
}
/**
@@ -90,13 +94,15 @@
*
* @param handle The handle to dial.
* @param contactInfo Information about the entity being called.
+ * @param gatewayInfo Gateway information to use for the call.
* @param isIncoming True if this is an incoming call.
*/
- Call(Uri handle, ContactInfo contactInfo, boolean isIncoming) {
+ Call(Uri handle, ContactInfo contactInfo, GatewayInfo gatewayInfo, boolean isIncoming) {
mId = UUID.randomUUID().toString(); // UUIDs should provide sufficient uniqueness.
mState = CallState.NEW;
mHandle = handle;
mContactInfo = contactInfo;
+ mGatewayInfo = gatewayInfo;
mIsIncoming = isIncoming;
mCreationTime = new Date();
}
@@ -126,7 +132,6 @@
if (mState != newState) {
Log.v(this, "setState %s -> %s", mState, newState);
mState = newState;
- clearCallInfo();
}
}
@@ -138,6 +143,21 @@
mHandle = handle;
}
+ /**
+ * @return The original handle this call is associated with. In-call services should use this
+ * handle when indicating in their UI the handle that is being called.
+ */
+ public Uri getOriginalHandle() {
+ if (mGatewayInfo != null && !mGatewayInfo.isEmpty()) {
+ return mGatewayInfo.getOriginalHandle();
+ }
+ return getHandle();
+ }
+
+ GatewayInfo getGatewayInfo() {
+ return mGatewayInfo;
+ }
+
ContactInfo getContactInfo() {
return mContactInfo;
}
@@ -309,10 +329,7 @@
* @return An object containing read-only information about this call.
*/
CallInfo toCallInfo() {
- if (mCallInfo == null) {
- mCallInfo = new CallInfo(mId, mState, mHandle);
- }
- return mCallInfo;
+ return new CallInfo(mId, mState, mHandle, mGatewayInfo);
}
/**
@@ -327,13 +344,6 @@
return false;
}
- /**
- * Resets the cached read-only version of this call.
- */
- private void clearCallInfo() {
- mCallInfo = null;
- }
-
@SuppressWarnings("rawtypes")
private void decrementAssociatedCallCount(ServiceBinder binder) {
if (binder != null) {