[speech] copy client list to prevent concurrency

Calling removeClient modified the underlying map, resulting in a
ConcurrentModificationException. Copy the list of clients before
iterating through.

Bug: 278168500
Test: cts
Change-Id: I3759e94a45bb5957e4457272d32efed34dc67e21
diff --git a/services/core/java/com/android/server/speech/RemoteSpeechRecognitionService.java b/services/core/java/com/android/server/speech/RemoteSpeechRecognitionService.java
index 96f4a01..c2666f6 100644
--- a/services/core/java/com/android/server/speech/RemoteSpeechRecognitionService.java
+++ b/services/core/java/com/android/server/speech/RemoteSpeechRecognitionService.java
@@ -297,7 +297,8 @@
                     return;
                 }
 
-                for (ClientState clientState : mClients.values()) {
+
+                for (ClientState clientState : mClients.values().toArray(new ClientState[0])) {
                     tryRespondWithError(
                             clientState.mDelegatingListener.mRemoteListener,
                             SpeechRecognizer.ERROR_SERVER_DISCONNECTED);