diff options
author | sangyun <sangyun@google.com> | 2023-01-17 14:06:26 +0900 |
---|---|---|
committer | sangyun <sangyun@google.com> | 2023-01-17 14:06:28 +0900 |
commit | 6adb79fba952735c0be89ea4d1fb4c1bdd18e377 (patch) | |
tree | c2065e5aa77da423d8cb7ede0e0297f7fec5c813 | |
parent | 5974687bc062e5396005fd147103673c61e86a5b (diff) | |
download | Telephony-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.java | 7 |
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(); |