Use thread safe set for RemoteConnection.mListeners

Switch from HashSet to set backed by a ConcurrentHashMap to prevent
ConcurrentModificationExceptions.

(Relanding ag/521178. This got reveretd in ag/520450).

Bug: 16901565
Change-Id: I997898ed94f305d9b8c57eead04e0dfe6c04a884
diff --git a/telecomm/java/android/telecomm/RemoteConnection.java b/telecomm/java/android/telecomm/RemoteConnection.java
index 13b0834..d3972d3 100644
--- a/telecomm/java/android/telecomm/RemoteConnection.java
+++ b/telecomm/java/android/telecomm/RemoteConnection.java
@@ -24,9 +24,11 @@
 import android.telephony.DisconnectCause;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * A connection provided to a {@link ConnectionService} by another {@code ConnectionService}
@@ -182,7 +184,8 @@
 
     private IConnectionService mConnectionService;
     private final String mConnectionId;
-    private final Set<Listener> mListeners = new HashSet<>();
+    private final Set<Listener> mListeners = Collections.newSetFromMap(
+            new ConcurrentHashMap<Listener, Boolean>(2));
     private final Set<RemoteConnection> mConferenceableConnections = new HashSet<>();
 
     private int mState = Connection.STATE_NEW;