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

Commit 3ca8828c authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Always refer to the latest TaskInfo

This CL ensures that the latest TaskInfo is used for the desktop first
policy check.
Currently, the returned TaskInfo of
FocusTransitionObserver#getFocusedTaskOnDisplay is not ensured to have
the up-to-date properties because the observer updates the cached
TaskInfo only when the focus is changed. It only guarantees to have the
proper taskId.

Flag: com.android.window.flags.enable_desktop_first_top_fullscreen_bugfix
Bug: 435258342
Test: DesktopTasksControllerTests
Change-Id: Idc94f562bddb8c193fc511501625a0a99a410cf2
parent f4412566
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -4095,7 +4095,11 @@ class DesktopTasksController(

        if (DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX.isTrue) {
            val anyDeskActive = repository.isAnyDeskActive(targetDisplayId)
            val focusedTask = focusTransitionObserver.getFocusedTaskOnDisplay(targetDisplayId)
            // TODO(b/436462692) - Make `getFocusedTaskOnDisplay` always returns the latest TaskInfo
            val focusedTask =
                focusTransitionObserver.getFocusedTaskOnDisplay(targetDisplayId)?.let {
                    shellTaskOrganizer.getRunningTaskInfo(it.taskId)
                }
            val isFullscreenFocused = focusedTask?.isFullscreen == true
            val isNonHomeFocused = focusedTask?.activityType != ACTIVITY_TYPE_HOME
            logV(
+3 −1
Original line number Diff line number Diff line
@@ -269,7 +269,8 @@ public class FocusTransitionObserver {
    }

    /**
     * Gets the focused task on a specific display.
     * Gets the focused task on a specific display. Be careful when you access the properties of the
     * returned value which may be stale (b/436462692).
     *
     * @param displayId The ID of the display.
     * @return The {@link RunningTaskInfo} of the focused task on the given display,
@@ -277,6 +278,7 @@ public class FocusTransitionObserver {
     */
    @Nullable
    public RunningTaskInfo getFocusedTaskOnDisplay(int displayId) {
        // TODO(b/436462692) - Make `getFocusedTaskOnDisplay` always returns the latest TaskInfo
        return mFocusedTaskOnDisplay.get(displayId);
    }

+2 −2
Original line number Diff line number Diff line
@@ -5864,7 +5864,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!!
        tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM

        val focusedFullscreenTask = createFullscreenTask()
        val focusedFullscreenTask = setUpFullscreenTask()
        whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any()))
            .thenReturn(focusedFullscreenTask)

@@ -6261,7 +6261,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!!
        tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM

        val focusedFullscreenTask = createFullscreenTask()
        val focusedFullscreenTask = setUpFullscreenTask()
        whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any()))
            .thenReturn(focusedFullscreenTask)