Disable MANAGE_CONFERENCE in TelephonyConference.

This used to be in TelephonyConnection, but it wasn't called properly
there, and didn't make as much conceptual sense there.

Bug: 18241753
Change-Id: Iab52392c7c183255951636e735979d1e6b6ca9d5
diff --git a/src/com/android/services/telephony/TelephonyConference.java b/src/com/android/services/telephony/TelephonyConference.java
index 54529bb..21dac0c 100644
--- a/src/com/android/services/telephony/TelephonyConference.java
+++ b/src/com/android/services/telephony/TelephonyConference.java
@@ -130,6 +130,20 @@
     }
 
     @Override
+    public void onConnectionAdded(Connection connection) {
+        // If the conference was an IMS connection currently or before, disable MANAGE_CONFERENCE
+        // as the default behavior. If there is a conference event package, this may be overridden.
+        if (((TelephonyConnection) connection).wasImsConnection()) {
+            int capabilities = getCapabilities();
+            if (PhoneCapabilities.can(capabilities, PhoneCapabilities.MANAGE_CONFERENCE)) {
+                int newCapabilities =
+                        PhoneCapabilities.remove(capabilities, PhoneCapabilities.MANAGE_CONFERENCE);
+                setCapabilities(newCapabilities);
+            }
+        }
+    }
+
+    @Override
     public Connection getPrimaryConnection() {
         // Default to the first connection.
         Connection primaryConnection = getConnections().get(0);
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 0ed1070..ba9f96d 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -307,25 +307,6 @@
         }
     }
 
-    @Override
-    public void onConferenceChanged() {
-        Conference conference = getConference();
-        if (conference == null) {
-            return;
-        }
-
-        // If the conference was an IMS connection currently or before, disable MANAGE_CONFERENCE
-        // as the default behavior. If there is a conference event package, this may be overridden.
-        if (mWasImsConnection) {
-            int capabilities = conference.getCapabilities();
-            if (PhoneCapabilities.can(capabilities, PhoneCapabilities.MANAGE_CONFERENCE)) {
-                int newCapabilities =
-                        PhoneCapabilities.remove(capabilities, PhoneCapabilities.MANAGE_CONFERENCE);
-                conference.setCapabilities(newCapabilities);
-            }
-        }
-    }
-
     public void performHold() {
         Log.v(this, "performHold");
         // TODO: Can dialing calls be put on hold as well since they take up the
@@ -812,6 +793,15 @@
         return getOriginalConnection() instanceof ImsPhoneConnection;
     }
 
+    /**
+     * Whether the original connection was ever an IMS connection, either before or now.
+     * @return {@code True} if the original connection was ever an IMS connection, {@code false}
+     *     otherwise.
+     */
+    public boolean wasImsConnection() {
+        return mWasImsConnection;
+    }
+
     private static Uri getAddressFromNumber(String number) {
         // Address can be null for blocked calls.
         if (number == null) {