Merge "IMS conference merge improvements." into oc-dev
am: c310bd7b26

Change-Id: I8ff2f43d4ca5b162e995a9e5e43880684ab268d7
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index eb1fccf..c5a0896 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -131,17 +131,6 @@
         }
 
         /**
-         * Handles destruction of the host connection; once the host connection has been
-         * destroyed, cleans up the conference participant connection.
-         *
-         * @param connection The host connection.
-         */
-        @Override
-        public void onDestroyed(android.telecom.Connection connection) {
-            disconnectConferenceParticipants();
-        }
-
-        /**
          * Handles changes to conference participant data as reported by the conference host
          * connection.
          *
@@ -416,6 +405,8 @@
             return;
         }
 
+        disconnectConferenceParticipants();
+
         Call call = mConferenceHost.getCall();
         if (call != null) {
             try {
@@ -743,8 +734,9 @@
             mConferenceParticipantConnections.put(new Pair<>(participant.getHandle(),
                     participant.getEndpoint()), connection);
         }
+
         mTelephonyConnectionService.addExistingConnection(mConferenceHostPhoneAccountHandle,
-                connection);
+                connection, this);
         addConnection(connection);
     }
 
diff --git a/src/com/android/services/telephony/ImsConferenceController.java b/src/com/android/services/telephony/ImsConferenceController.java
index c2319a7..501808f 100644
--- a/src/com/android/services/telephony/ImsConferenceController.java
+++ b/src/com/android/services/telephony/ImsConferenceController.java
@@ -16,6 +16,7 @@
 
 package com.android.services.telephony;
 
+import com.android.ims.ImsReasonInfo;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.phone.PhoneUtils;
@@ -382,7 +383,9 @@
         // disconnect tone is not played.
         connection.removeConnectionListener(mConnectionListener);
         connection.clearOriginalConnection();
-        connection.setDisconnected(new DisconnectCause(DisconnectCause.OTHER));
+        connection.setDisconnected(new DisconnectCause(DisconnectCause.OTHER,
+                android.telephony.DisconnectCause.toString(
+                        android.telephony.DisconnectCause.IMS_MERGED_SUCCESSFULLY)));
         connection.destroy();
         mImsConferences.add(conference);
     }
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 0c8c11c..e8c3ea8 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -98,6 +98,12 @@
                     .addExistingConnection(phoneAccountHandle, connection);
         }
         @Override
+        public void addExistingConnection(PhoneAccountHandle phoneAccountHandle,
+                Connection connection, Conference conference) {
+            TelephonyConnectionService.this
+                    .addExistingConnection(phoneAccountHandle, connection, conference);
+        }
+        @Override
         public void addConnectionToConferenceController(TelephonyConnection connection) {
             TelephonyConnectionService.this.addConnectionToConferenceController(connection);
         }
diff --git a/src/com/android/services/telephony/TelephonyConnectionServiceProxy.java b/src/com/android/services/telephony/TelephonyConnectionServiceProxy.java
index ee77b08..1ced34a 100644
--- a/src/com/android/services/telephony/TelephonyConnectionServiceProxy.java
+++ b/src/com/android/services/telephony/TelephonyConnectionServiceProxy.java
@@ -16,6 +16,7 @@
 
 package com.android.services.telephony;
 
+import android.telecom.Conference;
 import android.telecom.Connection;
 import android.telecom.PhoneAccountHandle;
 
@@ -31,6 +32,8 @@
     void addConference(ImsConference mImsConference);
     void removeConnection(Connection connection);
     void addExistingConnection(PhoneAccountHandle phoneAccountHandle,
-                               Connection connection);
+            Connection connection);
+    void addExistingConnection(PhoneAccountHandle phoneAccountHandle,
+                               Connection connection, Conference conference);
     void addConnectionToConferenceController(TelephonyConnection connection);
 }