Refine implementation of GSM conferences (1/3)

Bug: 17684223
Change-Id: I05d05b594803ea2c1da4247111b70ad5f870ac46
diff --git a/telecomm/java/android/telecom/RemoteConnectionService.java b/telecomm/java/android/telecom/RemoteConnectionService.java
index d959e50..328dc86 100644
--- a/telecomm/java/android/telecom/RemoteConnectionService.java
+++ b/telecomm/java/android/telecom/RemoteConnectionService.java
@@ -278,8 +278,13 @@
                 }
             }
 
-            findConnectionForAction(callId, "setConferenceableConnections")
-                    .setConferenceableConnections(conferenceable);
+            if (hasConnection(callId)) {
+                findConnectionForAction(callId, "setConferenceableConnections")
+                        .setConferenceableConnections(conferenceable);
+            } else {
+                findConferenceForAction(callId, "setConferenceableConnections")
+                        .setConferenceableConnections(conferenceable);
+            }
         }
     };
 
@@ -358,6 +363,10 @@
         }
     }
 
+    private boolean hasConnection(String callId) {
+        return mConferenceById.containsKey(callId);
+    }
+
     private RemoteConnection findConnectionForAction(
             String callId, String action) {
         if (mConnectionById.containsKey(callId)) {