Pass extras between call intents and Telecomm for outgoing calls

Enable bundled extras for outgoing calls in order to pass
information from dialer or contacts to the incallui.

Bug: 15284651
Change-Id: Ic34c8a49bf599ebc2924c342eddde051216d3266
diff --git a/src/com/android/telecomm/CallActivity.java b/src/com/android/telecomm/CallActivity.java
index 0e231b0..a84f3e9 100644
--- a/src/com/android/telecomm/CallActivity.java
+++ b/src/com/android/telecomm/CallActivity.java
@@ -25,7 +25,6 @@
 import android.os.Bundle;
 import android.telecomm.PhoneAccountHandle;
 import android.telecomm.TelecommManager;
-import android.telecomm.TelecommManager;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
 
@@ -113,8 +112,16 @@
         PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(
                 TelecommManager.EXTRA_PHONE_ACCOUNT_HANDLE);
 
+        Bundle clientExtras = null;
+        if (intent.hasExtra(TelecommManager.EXTRA_OUTGOING_CALL_EXTRAS)) {
+            clientExtras = intent.getBundleExtra(TelecommManager.EXTRA_OUTGOING_CALL_EXTRAS);
+        }
+        if (clientExtras == null) {
+            clientExtras = Bundle.EMPTY;
+        }
+
         // Send to CallsManager to ensure the InCallUI gets kicked off before the broadcast returns
-        Call call = mCallsManager.startOutgoingCall(handle, phoneAccountHandle);
+        Call call = mCallsManager.startOutgoingCall(handle, phoneAccountHandle, clientExtras);
 
         NewOutgoingCallIntentBroadcaster broadcaster = new NewOutgoingCallIntentBroadcaster(
                 mCallsManager, call, intent, isDefaultDialer());
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index b7cc233..87d5f4e 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -288,8 +288,13 @@
      * NOTE: emergency calls will never pass through this because they call
      * placeOutgoingCall directly.
      *
+     * @param handle Handle to connect the call with.
+     * @param phoneAccountHandle The phone account which contains the component name of the connection
+     *                     service to use for this call.
+     * @param extras The optional extras Bundle passed with the intent used for the outgoing call.
+     *
      */
-    Call startOutgoingCall(Uri handle, PhoneAccountHandle phoneAccountHandle) {
+    Call startOutgoingCall(Uri handle, PhoneAccountHandle phoneAccountHandle, Bundle extras) {
         // We only allow a single outgoing call at any given time. Before placing a call, make sure
         // there doesn't already exist another outgoing call.
         Call call = getFirstCallWithState(CallState.NEW, CallState.DIALING);
@@ -309,6 +314,7 @@
                 phoneAccountHandle,
                 false /* isIncoming */,
                 false /* isConference */);
+        call.setExtras(extras);
         call.setState(CallState.CONNECTING);
 
         // TODO: Move this to be a part of addCall()
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index c94b656..5c36ca4 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -369,6 +369,7 @@
                 childCallIds,
                 call.getStatusHints(),
                 call.getVideoState(),
-                conferenceableCallIds);
+                conferenceableCallIds,
+                call.getExtras());
     }
 }