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

Commit 8abee260 authored by Ben Lin's avatar Ben Lin
Browse files

Don't allow app handle/header on displays not in topology.

Bug: 400555497
Test: None
Flag: com.android.window.flags.enable_projected_display_desktop_mode
Change-Id: I9aa4b894a6f1164b90a0527fa582d56048d76564
parent 724fa3f4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -111,6 +111,14 @@ public class DisplayController {
        return mDisplayManager.getDisplay(displayId);
    }

    /**
     * Returns true if the display with the given displayId is part of the topology.
     */
    public boolean isDisplayInTopology(int displayId) {
        return mDisplayTopology != null
                && mDisplayTopology.findDisplay(displayId, mDisplayTopology.getRoot()) != null;
    }

    /**
     * Gets the DisplayLayout associated with a display.
     */
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.windowdecor.common
import android.app.ActivityManager
import android.app.WindowConfiguration
import android.content.Context
import android.view.Display
import android.view.WindowManager
import android.window.DesktopExperienceFlags.ENABLE_BUG_FIXES_FOR_SECONDARY_DISPLAY
import com.android.wm.shell.common.DisplayController
@@ -99,6 +100,11 @@ class AppHandleAndHeaderVisibilityHelper (
        val display = displayController.getDisplay(displayId)
        if (display == null) return false

        if (display.type != Display.TYPE_INTERNAL
            && !displayController.isDisplayInTopology(displayId)) {
            return false
        }

        if (DesktopModeStatus.isDesktopModeSupportedOnDisplay(context, display)) {
            return true
        }
+20 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ class DesktopModeWindowDecorViewModelAppHandleOnlyTest :
        doReturn(true).`when` { DesktopModeStatus.overridesShowAppHandle(any())}
        setUpCommon()
        whenever(mockDisplayController.getDisplay(anyInt())).thenReturn(mockDisplay)
        setDisplayInTopology(true)
    }

    @Test
@@ -169,6 +170,21 @@ class DesktopModeWindowDecorViewModelAppHandleOnlyTest :
        assertFalse(windowDecorByTaskIdSpy.contains(task.taskId))
    }

    @Test
    fun testAppHandleShowsOnlyOnDisplayInTopology() {
        val task = createTask()
        val taskSurface = SurfaceControl()
        setUpMockDecorationForTask(task)
        onTaskOpening(task, taskSurface)
        assertTrue(windowDecorByTaskIdSpy.contains(task.taskId))


        setDisplayInTopology(false)
        setUpMockDecorationForTask(task)
        onTaskChanging(task, taskSurface)
        assertFalse(windowDecorByTaskIdSpy.contains(task.taskId))
    }

    private fun createTask(
        displayId: Int = DEFAULT_DISPLAY,
        @WindowingMode windowingMode: Int = WINDOWING_MODE_FULLSCREEN,
@@ -187,4 +203,8 @@ class DesktopModeWindowDecorViewModelAppHandleOnlyTest :
        val size: Float = if (large) 1000f else 100f
        whenever(mockDisplay.getMinSizeDimensionDp()).thenReturn(size)
    }

    private fun setDisplayInTopology(inTopology: Boolean) {
        whenever(mockDisplayController.isDisplayInTopology(anyInt())).thenReturn(inTopology)
    }
}