From 4ab706d96042c18e87e15b02fd78d832d58b58ff Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Wed, 26 Feb 2020 18:04:28 -0800 Subject: [PATCH] Prevent ConcurrentModificationException while accessing mTunableLookup. Swapped HashMap with ConcurrentHashMap to allow multi-threaded access to mTunableLookup. Bug: 131588251 Test: atest SystemUITests Change-Id: I318fbd591060305b0365163ac3d2242abeabfeea (cherry picked from commit 8dcb39ce05a0dbf95ee8d26f2fd9b55fadd326ea) --- .../src/com/android/systemui/tuner/TunerServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunerServiceImpl.java b/packages/SystemUI/src/com/android/systemui/tuner/TunerServiceImpl.java index b2a5f5bee5434..b2d4471289da4 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/TunerServiceImpl.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/TunerServiceImpl.java @@ -41,9 +41,9 @@ import com.android.systemui.settings.CurrentUserTracker; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.util.leak.LeakDetector; -import java.util.HashMap; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; import javax.inject.Singleton; @@ -69,7 +69,8 @@ public class TunerServiceImpl extends TunerService { // Map of Uris we listen on to their settings keys. private final ArrayMap mListeningUris = new ArrayMap<>(); // Map of settings keys to the listener. - private final HashMap> mTunableLookup = new HashMap<>(); + private final ConcurrentHashMap> mTunableLookup = + new ConcurrentHashMap<>(); // Set of all tunables, used for leak detection. private final HashSet mTunables = LeakDetector.ENABLED ? new HashSet<>() : null; private final Context mContext;