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

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

Merge "Ensure dialogs from Quick Settings are always visible on the focused display" into main

parents b15d1326 ec7d7894
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ 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.shade.ShadeDisplayAware
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
@@ -47,16 +47,15 @@ interface ShadeDialogContextInteractor {
class ShadeDialogContextInteractorImpl
@Inject
constructor(
    @ShadeDisplayAware private val shadeContext: Context,
    @Main private val defaultContext: Context,
    private val displayWindowPropertyRepository: Provider<DisplayWindowPropertiesRepository>,
    private val shadeDisplaysRepository: Provider<ShadeDisplaysRepository>,
    @Background private val bgScope: CoroutineScope,
    private val focusedDisplayRepository: FocusedDisplayRepository,
) : CoreStartable, ShadeDialogContextInteractor {

    override fun start() {
        if (ShadeWindowGoesAround.isUnexpectedlyInLegacyMode()) return
        if (!Flags.enableWindowContextOverrideType()) {
        bgScope.launchTraced(TAG) {
            shadeDisplaysRepository
                .get()
@@ -70,12 +69,11 @@ constructor(
                }
        }
    }
    }

    override val context: Context
        get() {
            if (Flags.enableWindowContextOverrideType()) {
                return shadeContext
                return focusedDisplayContext
            } else {
                if (!ShadeWindowGoesAround.isEnabled) {
                    return defaultContext
@@ -85,6 +83,10 @@ constructor(
            }
        }

    /** 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" }) {