From aabd499a8719ea19238c048dab2df3f9590fd1d9 Mon Sep 17 00:00:00 2001 From: Hawkwood Glazier Date: Thu, 21 Sep 2023 18:53:25 +0000 Subject: Attempt to reload providers when selected provider is available but unloaded A more minor race may still be present, but this fix should reduce incidence of the issue and be safer than reorganizing the multithreading in verifyLoadedProviders. A subsequent change will address that more directly. Bug: 300671811 Test: Manually forced and checked race condition Change-Id: I5258dddd50b9c89f28340254c53bc1839351e28e --- .../src/com/android/systemui/shared/clocks/ClockRegistry.kt | 9 ++++++++- .../src/com/android/systemui/shared/plugins/PluginInstance.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt index fd4a723352e4..ecc0dbad70d0 100644 --- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt @@ -148,7 +148,7 @@ open class ClockRegistry( override fun onPluginAttached( manager: PluginLifecycleManager ): Boolean { - manager.isDebug = true + manager.isDebug = !keepAllLoaded if (keepAllLoaded) { // Always load new plugins if requested @@ -511,6 +511,12 @@ open class ClockRegistry( fun verifyLoadedProviders() { val shouldSchedule = isVerifying.compareAndSet(false, true) if (!shouldSchedule) { + logger.tryLog( + TAG, + LogLevel.VERBOSE, + {}, + { "verifyLoadedProviders: shouldSchedule=false" } + ) return } @@ -670,6 +676,7 @@ open class ClockRegistry( { str1 = clockId }, { "Clock $str1 not loaded; using default" } ) + verifyLoadedProviders() } else { logger.tryLog( TAG, diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInstance.java b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInstance.java index 7719e95b9416..f9f2c63c0469 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInstance.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginInstance.java @@ -73,7 +73,7 @@ public class PluginInstance implements PluginLifecycleManager mComponentName = componentName; mPluginFactory = pluginFactory; mPlugin = plugin; - mTag = TAG + mComponentName.toShortString() + mTag = TAG + "[" + mComponentName.getShortClassName() + "]" + '@' + Integer.toHexString(hashCode()); if (mPlugin != null) { -- cgit v1.2.3-59-g8ed1b