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

Commit 4843b76c authored by Ben Lin's avatar Ben Lin
Browse files

PD/CD: Always show app header if window is in freeform.

When windows are in freeform, handle is never shown - only the header.
And although in Projected Display we should hide entry points such as
the app handle to enter desktop, if the user somehow has the window in
freeform (e.g. via other means, such as adb launch), we should not hide
the header in that case, which would leave it in a rather broken UI
state.

Bug: 384568161
Test: atest
Flag:com.android.window.flags.enable_projected_desktop_mode
Change-Id: Ifa4ad9a6078d9995a1a5089d5a27c7e2f8c090a2
parent be6999f4
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
@@ -44,23 +44,24 @@ class AppHandleAndHeaderVisibilityHelper (
     * handle/header should show or not for this task.
     */
    fun shouldShowAppHandleOrHeader(taskInfo: ActivityManager.RunningTaskInfo): Boolean {
        if (!ENABLE_BUG_FIXES_FOR_SECONDARY_DISPLAY.isTrue) {
            return allowedForTask(taskInfo)
        }
        return allowedForTask(taskInfo) && allowedForDisplay(taskInfo.displayId)
    }

    private fun allowedForTask(taskInfo: ActivityManager.RunningTaskInfo): Boolean {
        // TODO (b/382023296): Remove once we no longer rely on
        //  Flags.enableBugFixesForSecondaryDisplay as it is taken care of in #allowedForDisplay
        val display = displayController.getDisplay(taskInfo.displayId)
        val display = displayController.getDisplay(taskInfo.displayId) ?: return false
        if (display == null) {
            // If DisplayController doesn't have it tracked, it could be a private/managed display.
            return false
        }
        // All freeform windows should show the app header.
        if (taskInfo.windowingMode == WindowConfiguration.WINDOWING_MODE_FREEFORM) {
            return true
        }

        if (!ENABLE_BUG_FIXES_FOR_SECONDARY_DISPLAY.isTrue) {
            return allowedForTask(taskInfo, display)
        }
        return allowedForTask(taskInfo, display) && allowedForDisplay(display)
    }

    private fun allowedForTask(taskInfo: ActivityManager.RunningTaskInfo, display: Display): Boolean {
        if (splitScreenController?.isTaskRootOrStageRoot(taskInfo.taskId) == true) {
            return false
        }
@@ -96,13 +97,9 @@ class AppHandleAndHeaderVisibilityHelper (
                && !taskInfo.configuration.windowConfiguration.isAlwaysOnTop
    }

    private fun allowedForDisplay(displayId: Int): Boolean {
        // If DisplayController doesn't have it tracked, it could be a private/managed display.
        val display = displayController.getDisplay(displayId)
        if (display == null) return false

    private fun allowedForDisplay(display: Display): Boolean {
        if (display.type != Display.TYPE_INTERNAL
            && !displayController.isDisplayInTopology(displayId)) {
            && !displayController.isDisplayInTopology(display.displayId)) {
            return false
        }