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

Commit 2d242456 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Use correct context for Screen Record Dialog

The dialog was using the status bar context, which caused rendering issues when launched from the shade on an external display (the specified window type 2017 is not valid)

It now uses shadeDialogContextInteractor to ensure the correct context is always used. ( a DIALOG_WINDOW_TYPE context)

Bug: 422987559
Flag: com.android.systemui.shade_window_goes_around
Test: Open screen record on external display
Change-Id: I8ffc7a6776d737362093dbf7274c5cde3428a881
parent 9f21709b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.mediaprojection.permission.SINGLE_APP
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.res.R
import com.android.systemui.screenrecord.domain.interactor.screenRecordingStartStopInteractor
import com.android.systemui.shade.data.repository.shadeDialogContextInteractor
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.statusbar.phone.SystemUIDialogManager
@@ -103,8 +104,8 @@ class ScreenRecordPermissionDialogDelegateTest : SysuiTestCase() {
                systemUIDialogFactory,
                context,
                context.getSystemService(DisplayManager::class.java)!!,
                { fakeDisplayWindowPropertiesRepository },
                kosmos.screenRecordingStartStopInteractor,
                kosmos.shadeDialogContextInteractor,
            )
        dialog = underTest.createDialog()
    }
+5 −17
Original line number Diff line number Diff line
@@ -20,9 +20,7 @@ import android.hardware.display.DisplayManager
import android.os.Bundle
import android.os.UserHandle
import android.view.View
import android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR
import androidx.annotation.StyleRes
import com.android.systemui.display.data.repository.DisplayWindowPropertiesRepository
import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger
import com.android.systemui.mediaprojection.permission.BaseMediaProjectionPermissionContentManager
import com.android.systemui.mediaprojection.permission.BaseMediaProjectionPermissionDialogDelegate
@@ -32,9 +30,9 @@ import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.res.R
import com.android.systemui.screenrecord.domain.interactor.ScreenRecordingStartStopInteractor
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shade.domain.interactor.ShadeDialogContextInteractor
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.statusbar.phone.SystemUIDialog
import dagger.Lazy
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
@@ -52,8 +50,8 @@ class ScreenRecordPermissionDialogDelegate(
    @StyleRes private val theme: Int,
    private val context: Context,
    private val displayManager: DisplayManager,
    private val displayWindowPropertiesRepository: Lazy<DisplayWindowPropertiesRepository>,
    private val screenRecordingStartStopInteractor: ScreenRecordingStartStopInteractor,
    private val shadeDialogContextInteractor: ShadeDialogContextInteractor,
) :
    BaseMediaProjectionPermissionDialogDelegate<SystemUIDialog>(
        ScreenRecordPermissionContentManager.createOptionList(displayManager),
@@ -76,8 +74,8 @@ class ScreenRecordPermissionDialogDelegate(
        systemUIDialogFactory: SystemUIDialog.Factory,
        @ShadeDisplayAware context: Context,
        displayManager: DisplayManager,
        displayWindowPropertiesRepository: Lazy<DisplayWindowPropertiesRepository>,
        screenRecordingStartStopInteractor: ScreenRecordingStartStopInteractor,
        shadeDialogContextInteractor: ShadeDialogContextInteractor,
    ) : this(
        hostUserHandle,
        hostUid,
@@ -90,8 +88,8 @@ class ScreenRecordPermissionDialogDelegate(
        theme = SystemUIDialog.DEFAULT_THEME,
        context,
        displayManager,
        displayWindowPropertiesRepository,
        screenRecordingStartStopInteractor,
        shadeDialogContextInteractor,
    )

    @AssistedFactory
@@ -121,17 +119,7 @@ class ScreenRecordPermissionDialogDelegate(
    override fun createDialog(): SystemUIDialog {
        val displayContext =
            if (ShadeWindowGoesAround.isEnabled) {
                // This dialog needs to stay visible even if the notification shade closes,
                // for example, after unlocking the device. If we used the shade's own context, the
                // dialog would be tied to the shade and disappear when the shade collapses.
                // To avoid this, we get a context associated with the status bar on the current
                // display.  This ensures the dialog remains visible independently of the shade.
                displayWindowPropertiesRepository
                    .get()
                    .get(context.displayId, TYPE_STATUS_BAR)
                    ?.context
                    // falls back to the default context if the status bar context is not available
                    ?: context
                shadeDialogContextInteractor.context
            } else {
                context
            }