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

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

Merge "Use the shade display instead of the focused one to open dialogs" into main

parents 607032e0 1bc0e9be
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -27,10 +27,8 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.display.data.repository.DisplayWindowPropertiesRepository
import com.android.systemui.display.data.repository.FocusedDisplayRepository
import com.android.systemui.shade.data.repository.ShadeDisplaysRepository
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.window.flags.Flags
import javax.inject.Inject
import javax.inject.Provider
import kotlinx.coroutines.CoroutineScope
@@ -51,7 +49,6 @@ constructor(
    private val displayWindowPropertyRepository: Provider<DisplayWindowPropertiesRepository>,
    private val shadeDisplaysRepository: Provider<ShadeDisplaysRepository>,
    @Background private val bgScope: CoroutineScope,
    private val focusedDisplayRepository: FocusedDisplayRepository,
) : CoreStartable, ShadeDialogContextInteractor {

    override fun start() {
@@ -71,22 +68,16 @@ constructor(
    }

    override val context: Context
        get() {
            if (Flags.enableWindowContextOverrideType()) {
                return focusedDisplayContext
            } else {
        get() = getContextOrDefault(shadeDisplayId)

    private val shadeDisplayId: Int
        get() =
            if (!ShadeWindowGoesAround.isEnabled) {
                    return defaultContext
                }
                val displayId = shadeDisplaysRepository.get().displayId.value
                return getContextOrDefault(displayId)
            }
                Display.DEFAULT_DISPLAY
            } else {
                shadeDisplaysRepository.get().displayId.value
            }

    /** Context that can be used to open a dialog on the focused display. */
    private val focusedDisplayContext: Context
        get() = getContextOrDefault(focusedDisplayRepository.focusedDisplayId.value)

    private fun getContextOrDefault(displayId: Int): Context {
        return try {
            traceSection({ "Getting dialog context for displayId=$displayId" }) {