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

Commit ec7d7894 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Ensure dialogs from Quick Settings are always visible on the focused display

Previously, when a dialog was launched from a Quick Settings (QS) tile outside of the notification shade (e.g., from the all-apps list), it was incorrectly parented to the shade window. This caused the dialog to be invisible until the shade was pulled down.

This change ensures that such dialogs are opened on the currently focused display and are not parented to the shade. This allows the dialog to be visible immediately, regardless of the shade's status.

Note: While e2e tests cover QS dialogs opened from the shade, test coverage for the all-apps scenario is still needed.

Bug: 423929154
Flag: NONE - fix for broken functionality to cp on release branch
Test: OpenInternetQSDialogOnOtherDisplay, OpenQSBluetoothDialogOnOtherDisplay, OpenQSModesDialogOnOtherDisplay
Change-Id: I35320b667954dd2833221562423f04fb33ced259
parent 07f0a406
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" }) {