Fixing conference merge where only one party is added to conference.

- Adding check in TelephonyConnection to check for changes to the
multiparty bit and notifying listeners (in this case the conference
controller.
- In ImsConferenceController Responding to the onConferenceStarted
callback from the IMS layer by checking if a new ImsConference needs to
be created.

Bug: 18960042
Change-Id: I8dd2f32c442895fd6126b83f2d8ac889fd468fad
diff --git a/src/com/android/services/telephony/ImsConferenceController.java b/src/com/android/services/telephony/ImsConferenceController.java
index 5df7ea0..e93ebd4 100644
--- a/src/com/android/services/telephony/ImsConferenceController.java
+++ b/src/com/android/services/telephony/ImsConferenceController.java
@@ -68,6 +68,12 @@
         public void onDestroyed(Connection connection) {
             remove(connection);
         }
+
+        @Override
+        public void onConferenceStarted() {
+            Log.v(this, "onConferenceStarted");
+            recalculateConference();
+        }
     };
 
     /**
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 6198ce1..71e4cae 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -186,6 +186,11 @@
     private boolean mWasImsConnection;
 
     /**
+     * Tracks the multiparty state of the ImsCall so that changes in the bit state can be detected.
+     */
+    private boolean mIsMultiParty = false;
+
+    /**
      * Determines if the {@link TelephonyConnection} has local video capabilities.
      * This is used when {@link TelephonyConnection#updateConnectionCapabilities()}} is called,
      * ensuring the appropriate capabilities are set.  Since capabilities
@@ -483,6 +488,7 @@
         if (isImsConnection()) {
             mWasImsConnection = true;
         }
+        mIsMultiParty = mOriginalConnection.isMultiparty();
 
         fireOnOriginalConnectionConfigured();
         updateAddress();
@@ -633,6 +639,24 @@
         }
         updateConnectionCapabilities();
         updateAddress();
+        updateMultiparty();
+    }
+
+    /**
+     * Checks for changes to the multiparty bit.  If a conference has started, informs listeners.
+     */
+    private void updateMultiparty() {
+        if (mOriginalConnection == null) {
+            return;
+        }
+
+        if (mIsMultiParty != mOriginalConnection.isMultiparty()) {
+            mIsMultiParty = mOriginalConnection.isMultiparty();
+
+            if (mIsMultiParty) {
+                notifyConferenceStarted();
+            }
+        }
     }
 
     private void setActiveInternal() {