IMS: Fix for add participant issue

With l-mr1, callsManager runs in system server process and
callActivity runs in ui process because of which callActivity
cannot access callsManager instance.

Fix this by handling ADD_PARTICIPANT extras in callsManager.

Change-Id: I3095736b6307fa76646b0a69116557f6337d9bae
diff --git a/src/com/android/server/telecom/CallActivity.java b/src/com/android/server/telecom/CallActivity.java
index 63b801b..e650a70 100644
--- a/src/com/android/server/telecom/CallActivity.java
+++ b/src/com/android/server/telecom/CallActivity.java
@@ -90,27 +90,8 @@
         if (Intent.ACTION_CALL.equals(action) ||
                 Intent.ACTION_CALL_PRIVILEGED.equals(action) ||
                 Intent.ACTION_CALL_EMERGENCY.equals(action)) {
-        boolean isAddParticipant = intent.getBooleanExtra(
-                TelephonyProperties.ADD_PARTICIPANT_KEY, false);
-        Log.d(this, "isAddparticipant = "+isAddParticipant);
-        if (isAddParticipant) {
-            String number = PhoneNumberUtils.getNumberFromIntent(intent, this);
-            boolean isConferenceUri = intent.getBooleanExtra(
-                    TelephonyProperties.EXTRA_DIAL_CONFERENCE_URI, false);
-            if (!isConferenceUri) {
-                number = PhoneNumberUtils.stripSeparators(number);
-            }
-            CallsManager callsManager = CallsManager.getInstance();
-            if (callsManager != null) {
-                callsManager.addParticipant(number);
-                callsManager.getInCallController().bringToForeground(false);
-            } else {
-                Log.w(this, "CallsManager is null, can't process add Participant");
-            }
-        } else {
             processOutgoingCallIntent(intent);
         }
-        }
     }
 
     private void verifyCallAction(Intent intent) {
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index a1a8269..989591e 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -454,6 +454,15 @@
      * @param extras The optional extras Bundle passed with the intent used for the incoming call.
      */
     Call startOutgoingCall(Uri handle, PhoneAccountHandle phoneAccountHandle, Bundle extras) {
+
+        boolean isAddParticipant = ((extras != null) && (extras.getBoolean(
+                TelephonyProperties.ADD_PARTICIPANT_KEY, false)));
+        if (isAddParticipant) {
+            addParticipant(handle.toString());
+            mInCallController.bringToForeground(false);
+            return null;
+        }
+
         // Create a call with original handle. The handle may be changed when the call is attached
         // to a connection service, but in most cases will remain the same.
         Call call = new Call(