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

Commit a4d8162a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add flag to not use the immediate kotlin coroutine dispatcher" into main

parents 8274f9e0 93add87c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2077,6 +2077,16 @@ flag {
    is_fixed_read_only: true
}

flag {
    name: "do_not_use_immediate_coroutine_dispatcher"
    namespace: "systemui"
    description: "Uses the Main coroutine dispatcher (not immediate) when enabled"
    bug: "411091082"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "qs_wifi_config"
    namespace: "desktop_connectivity"
+13 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.util.kotlin

import com.android.systemui.Flags
import com.android.systemui.coroutines.newTracingContext
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
@@ -43,12 +44,20 @@ class GlobalCoroutinesModule {
        "Use @Main CoroutineContext instead",
        ReplaceWith("mainCoroutineContext()", "kotlin.coroutines.CoroutineContext"),
    )
    fun mainDispatcher(): CoroutineDispatcher = Dispatchers.Main.immediate
    fun mainDispatcher(): CoroutineDispatcher =
        if (Flags.doNotUseImmediateCoroutineDispatcher()) {
            Dispatchers.Main
        } else {
            Dispatchers.Main.immediate
        }

    @Provides
    @Singleton
    @Main
    fun mainCoroutineContext(): CoroutineContext {
        return Dispatchers.Main.immediate
    fun mainCoroutineContext(): CoroutineContext =
        if (Flags.doNotUseImmediateCoroutineDispatcher()) {
            Dispatchers.Main
        } else {
            Dispatchers.Main.immediate
        }
}