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

Commit da520dbc authored by Matt Casey's avatar Matt Casey
Browse files

Derive WindowManager reference from window context

That way it uses the correct Display.

Bug: 399644508
Test: manual test that window shows up on the correct Display with
      connected display
Flag: com.android.systemui.screenshot_multidisplay_focus_change
Change-Id: I38d23a7f7da0e6b49b3de7d74ed92d8bf727f235
parent 3e4db3f4
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -39,11 +39,7 @@ import dagger.assisted.AssistedInject
/** Creates and manages the window in which the screenshot UI is displayed. */
/** Creates and manages the window in which the screenshot UI is displayed. */
class ScreenshotWindow
class ScreenshotWindow
@AssistedInject
@AssistedInject
constructor(
constructor(context: Context, @Assisted private val display: Display) {
    private val windowManager: WindowManager,
    private val context: Context,
    @Assisted private val display: Display,
) {


    val window: PhoneWindow =
    val window: PhoneWindow =
        PhoneWindow(
        PhoneWindow(
@@ -51,6 +47,10 @@ constructor(
                .createDisplayContext(display)
                .createDisplayContext(display)
                .createWindowContext(WindowManager.LayoutParams.TYPE_SCREENSHOT, null)
                .createWindowContext(WindowManager.LayoutParams.TYPE_SCREENSHOT, null)
        )
        )

    // WindowManager reference must be derived from the window context such that it applies to the
    // correct Display.
    private val windowManager = window.context.getSystemService(WindowManager::class.java)
    private val params =
    private val params =
        WindowManager.LayoutParams(
        WindowManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
@@ -64,7 +64,7 @@ constructor(
                    WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH or
                    WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH or
                    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
                    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
                    WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                    WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                PixelFormat.TRANSLUCENT
                PixelFormat.TRANSLUCENT,
            )
            )
            .apply {
            .apply {
                layoutInDisplayCutoutMode =
                layoutInDisplayCutoutMode =