Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aabd499a authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

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
parent 0b49f269
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ open class ClockRegistry(
            override fun onPluginAttached(
                manager: PluginLifecycleManager<ClockProviderPlugin>
            ): 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,
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class PluginInstance<T extends Plugin> implements PluginLifecycleManager
        mComponentName = componentName;
        mPluginFactory = pluginFactory;
        mPlugin = plugin;
        mTag = TAG + mComponentName.toShortString()
        mTag = TAG + "[" + mComponentName.getShortClassName() + "]"
                + '@' + Integer.toHexString(hashCode());

        if (mPlugin != null) {