summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsangyun <sangyun@google.com>2023-01-17 14:06:26 +0900
committersangyun <sangyun@google.com>2023-01-17 14:06:28 +0900
commit6adb79fba952735c0be89ea4d1fb4c1bdd18e377 (patch)
treec2065e5aa77da423d8cb7ede0e0297f7fec5c813
parent5974687bc062e5396005fd147103673c61e86a5b (diff)
downloadTelephony-6adb79fba952735c0be89ea4d1fb4c1bdd18e377.tar.gz
[QNS] Fix ConcurrentModificationException in QnsTelephonyListener
Changed to use the ConcurrentHashMap for QnsRegistrant in the QnsTelephonyListener. With rare probability, Register() or Unregister() can run on different threads while run in notify(). Bug: 265372291 Test: atest QualifiedNetworksServiceTests Change-Id: Ib2ba181ab7faa4cc13e23a756450c0692a341ce8
-rw-r--r--services/QualifiedNetworksService/src/com/android/telephony/qns/QnsTelephonyListener.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsTelephonyListener.java b/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsTelephonyListener.java
index 9cf7a86..51414e1 100644
--- a/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsTelephonyListener.java
+++ b/services/QualifiedNetworksService/src/com/android/telephony/qns/QnsTelephonyListener.java
@@ -47,6 +47,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
@@ -71,8 +72,10 @@ class QnsTelephonyListener {
List<Consumer<List<CallState>>> mCallStatesConsumerList = new ArrayList<>();
List<Consumer<Integer>> mSrvccStateConsumerList = new ArrayList<>();
List<Consumer<MediaQualityStatus>> mMediaQualityConsumerList = new ArrayList<>();
- protected HashMap<Integer, QnsRegistrantList> mQnsTelephonyInfoRegistrantMap = new HashMap<>();
- protected HashMap<Integer, QnsRegistrantList> mNetCapabilityRegistrantMap = new HashMap<>();
+ protected ConcurrentHashMap<Integer, QnsRegistrantList> mQnsTelephonyInfoRegistrantMap =
+ new ConcurrentHashMap<>();
+ protected ConcurrentHashMap<Integer, QnsRegistrantList> mNetCapabilityRegistrantMap =
+ new ConcurrentHashMap<>();
protected QnsTelephonyInfo mLastQnsTelephonyInfo = new QnsTelephonyInfo();
protected QnsTelephonyInfoIms mLastQnsTelephonyInfoIms = new QnsTelephonyInfoIms();
protected ServiceState mLastServiceState = new ServiceState();