Fixing conference managment regression.

This CL restores ag/553714 and adds a check to allow IMS conferences with 0 connections.

Bug: 17632595, 19184963, 19184481
Change-Id: I6a4c5d05b14e89cc4b335f45ed078e928c57abb3
diff --git a/src/com/android/server/telecom/ConnectionServiceWrapper.java b/src/com/android/server/telecom/ConnectionServiceWrapper.java
index 758d2c3..d470737 100644
--- a/src/com/android/server/telecom/ConnectionServiceWrapper.java
+++ b/src/com/android/server/telecom/ConnectionServiceWrapper.java
@@ -202,6 +202,22 @@
                         ParcelableConference parcelableConference =
                                 (ParcelableConference) args.arg2;
 
+                        // Make sure that there's at least one valid call. For remote connections
+                        // we'll get a add conference msg from both the remote connection service
+                        // and from the real connection service.
+                        boolean hasValidCalls = false;
+                        for (String callId : parcelableConference.getConnectionIds()) {
+                            if (mCallIdMapper.getCall(callId) != null) {
+                                hasValidCalls = true;
+                            }
+                        }
+                        // But don't bail out if the connection count is 0, because that is a valid
+                        // IMS conference state.
+                        if (!hasValidCalls && parcelableConference.getConnectionIds().size() > 0) {
+                            Log.d(this, "Attempting to add a conference with no valid calls");
+                            break;
+                        }
+
                         // need to create a new Call
                         PhoneAccountHandle phAcc = null;
                         if (parcelableConference != null &&