diff options
| author | 2024-05-08 13:13:35 +0000 | |
|---|---|---|
| committer | 2024-05-08 13:13:35 +0000 | |
| commit | 24b59fca6675cc5bbe28dc11f1737d143df021bb (patch) | |
| tree | 57ac286f2c3c144d52c14104259d0a60a9cc8120 | |
| parent | a348348d05b99292077fd617432881bcbec4a097 (diff) | |
| parent | 349c46c498eeca75823d1853057193f60595db04 (diff) | |
Merge "Synchronize listeners in ConfigurationControllerImpl" into main
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerImpl.kt | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerImpl.kt index dea94162ad0e..2e1ab383538f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerImpl.kt @@ -59,7 +59,10 @@ class ConfigurationControllerImpl @Inject constructor( } override fun notifyThemeChanged() { - val listeners = ArrayList(listeners) + // Avoid concurrent modification exception + val listeners = synchronized(this.listeners) { + ArrayList(this.listeners) + } listeners.filterForEach({ this.listeners.contains(it) }) { it.onThemeChanged() @@ -68,8 +71,9 @@ class ConfigurationControllerImpl @Inject constructor( override fun onConfigurationChanged(newConfig: Configuration) { // Avoid concurrent modification exception - val listeners = ArrayList(listeners) - + val listeners = synchronized(this.listeners) { + ArrayList(this.listeners) + } listeners.filterForEach({ this.listeners.contains(it) }) { it.onConfigChanged(newConfig) } @@ -148,12 +152,16 @@ class ConfigurationControllerImpl @Inject constructor( } override fun addCallback(listener: ConfigurationListener) { - listeners.add(listener) + synchronized(listeners) { + listeners.add(listener) + } listener.onDensityOrFontScaleChanged() } override fun removeCallback(listener: ConfigurationListener) { - listeners.remove(listener) + synchronized(listeners) { + listeners.remove(listener) + } } override fun isLayoutRtl(): Boolean { |