Conference event package performance improvement.

- Instead of sending each participant to the telephony conference
controller, all participants are sent at once.  This way the conference
only needs to be recalculated once.

Bug: 18057361
Change-Id: I10ac8efef74db75a90d97577bcc95d55b827b28b
diff --git a/src/java/com/android/ims/ImsCall.java b/src/java/com/android/ims/ImsCall.java
index 9f58f0a..3bebbfa 100644
--- a/src/java/com/android/ims/ImsCall.java
+++ b/src/java/com/android/ims/ImsCall.java
@@ -18,7 +18,9 @@
 
 import com.android.internal.R;
 
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map.Entry;
 import java.util.Set;
 
@@ -304,13 +306,13 @@
         }
 
         /**
-         * Called when the state of an IMS conference participant has changed.
+         * Called when the state of IMS conference participant(s) has changed.
          *
          * @param call the call object that carries out the IMS call.
-         * @param participant the participant and its new state information.
+         * @param participants the participant(s) and their new state information.
          */
-        public void onConferenceParticipantStateChanged(ImsCall call,
-                ConferenceParticipant participant) {
+        public void onConferenceParticipantsStateChanged(ImsCall call,
+                List<ConferenceParticipant> participants) {
             // no-op
         }
 
@@ -1531,14 +1533,14 @@
     }
 
     private void notifyConferenceStateUpdated(ImsConferenceState state) {
-        Set<Entry<String, Bundle>> paticipants = state.mParticipants.entrySet();
+        Set<Entry<String, Bundle>> participants = state.mParticipants.entrySet();
 
-        if (paticipants == null) {
+        if (participants == null) {
             return;
         }
 
-        Iterator<Entry<String, Bundle>> iterator = paticipants.iterator();
-
+        Iterator<Entry<String, Bundle>> iterator = participants.iterator();
+        List<ConferenceParticipant> conferenceParticipants = new ArrayList<>(participants.size());
         while (iterator.hasNext()) {
             Entry<String, Bundle> entry = iterator.next();
 
@@ -1577,13 +1579,7 @@
 
                 ConferenceParticipant conferenceParticipant = new ConferenceParticipant(handle,
                         displayName, endpointUri, connectionState);
-                if (mListener != null) {
-                    try {
-                        mListener.onConferenceParticipantStateChanged(this, conferenceParticipant);
-                    } catch (Throwable t) {
-                        loge("notifyConferenceStateUpdated :: ", t);
-                    }
-                }
+                conferenceParticipants.add(conferenceParticipant);
                 continue;
             }
 
@@ -1612,6 +1608,14 @@
                 loge("notifyConferenceStateUpdated :: ", t);
             }
         }
+
+        if (!conferenceParticipants.isEmpty() && mListener != null) {
+            try {
+                mListener.onConferenceParticipantsStateChanged(this, conferenceParticipants);
+            } catch (Throwable t) {
+                loge("notifyConferenceStateUpdated :: ", t);
+            }
+        }
     }