summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2019-09-29 10:02:14 -0700
committerEtan Cohen <etancohen@google.com>2019-10-04 16:15:39 +0000
commitd1def087b15801002d0dad243841bda08886547d (patch)
tree68007367faef0b8284918b6e511664b60114d726 /service
parent7957387b5d459386191cf45ca90e45446ed13f93 (diff)
Add synchroniztaion to prevent concurrent modification exception
Fix unsynchronized concurrent use. Bug: 141503388 Test: atest com.android.server.wifi.HalDeviceManagerTest Change-Id: Ibe3ffccfca4d175e3f6eb57b202ae0d76d5f33ef (cherry picked from commit 175e0b8a9bbaf173d02bde574de5c22f82617f51)
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/HalDeviceManager.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index d2ad47f48..e10234f68 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -1723,9 +1723,11 @@ public class HalDeviceManager {
int requestedIfaceType, WifiIfaceInfo[][] currentIfaces, int numNecessaryInterfaces) {
// rule 0: check for any low priority interfaces
int numAvailableLowPriorityInterfaces = 0;
- for (InterfaceCacheEntry entry : mInterfaceInfoCache.values()) {
- if (entry.type == existingIfaceType && entry.isLowPriority) {
- numAvailableLowPriorityInterfaces++;
+ synchronized (mLock) {
+ for (InterfaceCacheEntry entry : mInterfaceInfoCache.values()) {
+ if (entry.type == existingIfaceType && entry.isLowPriority) {
+ numAvailableLowPriorityInterfaces++;
+ }
}
}
if (numAvailableLowPriorityInterfaces >= numNecessaryInterfaces) {
@@ -1780,8 +1782,10 @@ public class HalDeviceManager {
LongSparseArray<WifiIfaceInfo> orderedListLowPriority = new LongSparseArray<>();
LongSparseArray<WifiIfaceInfo> orderedList = new LongSparseArray<>();
for (WifiIfaceInfo info : interfaces) {
- InterfaceCacheEntry cacheEntry = mInterfaceInfoCache.get(
- Pair.create(info.name, getType(info.iface)));
+ InterfaceCacheEntry cacheEntry;
+ synchronized (mLock) {
+ cacheEntry = mInterfaceInfoCache.get(Pair.create(info.name, getType(info.iface)));
+ }
if (cacheEntry == null) {
Log.e(TAG,
"selectInterfacesToDelete: can't find cache entry with name=" + info.name);