Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +3 −2 Original line number Diff line number Diff line Loading @@ -1311,9 +1311,10 @@ public abstract class WMShellModule { DesktopState desktopState, @DynamicOverride DesktopUserRepositories desktopUserRepositories, FocusTransitionObserver focusTransitionObserver, ShellController shellController) { ShellController shellController, ShellTaskOrganizer shellTaskOrganizer) { return new ShellDesktopStateImpl(desktopState, desktopUserRepositories, focusTransitionObserver, shellController); focusTransitionObserver, shellController, shellTaskOrganizer); } @WMSingleton Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +3 −4 Original line number Diff line number Diff line Loading @@ -4162,11 +4162,10 @@ class DesktopTasksController( if (DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX.isTrue) { val anyDeskActive = repository.isAnyDeskActive(targetDisplayId) // TODO(b/436462692) - Make `getFocusedTaskOnDisplay` always returns the latest TaskInfo val focusedTask = focusTransitionObserver.getFocusedTaskOnDisplay(targetDisplayId)?.let { shellTaskOrganizer.getRunningTaskInfo(it.taskId) } shellTaskOrganizer.getRunningTaskInfo( focusTransitionObserver.getFocusedTaskIdOnDisplay(targetDisplayId) ) val isFullscreenFocused = focusedTask?.isFullscreen == true val isNonHomeFocused = focusedTask?.activityType != ACTIVITY_TYPE_HOME logV( Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ShellDesktopStateImpl.kt +6 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.desktopmode import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.shared.desktopmode.DesktopState import com.android.wm.shell.sysui.ShellController import com.android.wm.shell.transition.FocusTransitionObserver Loading @@ -25,6 +26,7 @@ class ShellDesktopStateImpl( private val desktopUserRepositories: DesktopUserRepositories, private val focusTransitionObserver: FocusTransitionObserver, private val shellController: ShellController, private val shellTaskOrganizer: ShellTaskOrganizer, ) : ShellDesktopState, DesktopState by desktopState { /** Checks if the given display has an active desktop session (i.e., running freeform tasks). */ private fun isInDesktop(displayId: Int): Boolean = Loading @@ -34,7 +36,10 @@ class ShellDesktopStateImpl( /** Checks if the currently focused task on the given display is the home screen. */ private fun isHomeFocused(displayId: Int): Boolean { val focusedTask = focusTransitionObserver.getFocusedTaskOnDisplay(displayId) val focusedTask = shellTaskOrganizer.getRunningTaskInfo( focusTransitionObserver.getFocusedTaskIdOnDisplay(displayId) ) if (focusedTask == null) { // A null focused task can occur if the Home activity launched before Shell was // fully initialized, and this display has not yet received focus. In this case, Loading libs/WindowManager/Shell/src/com/android/wm/shell/transition/FocusTransitionObserver.java +10 −8 Original line number Diff line number Diff line Loading @@ -269,17 +269,19 @@ public class FocusTransitionObserver { } /** * 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). * Gets the focused task ID on a specific display. * * @param displayId The ID of the display. * @return The {@link RunningTaskInfo} of the focused task on the given display, * or {@code null} if no task is focused or display not recorded in the observer. * @return The task ID of the focused task on the given display, * or {@code INVALID_TASK_ID} if no task is focused or display not recorded in the * observer. */ @Nullable public RunningTaskInfo getFocusedTaskOnDisplay(int displayId) { // TODO(b/436462692) - Make `getFocusedTaskOnDisplay` always returns the latest TaskInfo return mFocusedTaskOnDisplay.get(displayId); public int getFocusedTaskIdOnDisplay(int displayId) { final RunningTaskInfo taskInfo = mFocusedTaskOnDisplay.get(displayId); // Some properties of `taskInfo` can be stale as this observer only updates the cache when // the focus changes. So we here returns only taskId to ask callers to fetch the TaskInfo // if needed. return taskInfo != null ? taskInfo.taskId : INVALID_TASK_ID; } /** Dumps focused display and tasks. */ Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +4 −4 Original line number Diff line number Diff line Loading @@ -5869,8 +5869,8 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val focusedFullscreenTask = setUpFullscreenTask() whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any())) .thenReturn(focusedFullscreenTask) whenever(focusTransitionObserver.getFocusedTaskIdOnDisplay(any())) .thenReturn(focusedFullscreenTask.taskId) val fullscreenTask = createFullscreenTask() Loading Loading @@ -6267,8 +6267,8 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val focusedFullscreenTask = setUpFullscreenTask() whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any())) .thenReturn(focusedFullscreenTask) whenever(focusTransitionObserver.getFocusedTaskIdOnDisplay(any())) .thenReturn(focusedFullscreenTask.taskId) val freeformTask = createFreeformTask(displayId = DEFAULT_DISPLAY) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +3 −2 Original line number Diff line number Diff line Loading @@ -1311,9 +1311,10 @@ public abstract class WMShellModule { DesktopState desktopState, @DynamicOverride DesktopUserRepositories desktopUserRepositories, FocusTransitionObserver focusTransitionObserver, ShellController shellController) { ShellController shellController, ShellTaskOrganizer shellTaskOrganizer) { return new ShellDesktopStateImpl(desktopState, desktopUserRepositories, focusTransitionObserver, shellController); focusTransitionObserver, shellController, shellTaskOrganizer); } @WMSingleton Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +3 −4 Original line number Diff line number Diff line Loading @@ -4162,11 +4162,10 @@ class DesktopTasksController( if (DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX.isTrue) { val anyDeskActive = repository.isAnyDeskActive(targetDisplayId) // TODO(b/436462692) - Make `getFocusedTaskOnDisplay` always returns the latest TaskInfo val focusedTask = focusTransitionObserver.getFocusedTaskOnDisplay(targetDisplayId)?.let { shellTaskOrganizer.getRunningTaskInfo(it.taskId) } shellTaskOrganizer.getRunningTaskInfo( focusTransitionObserver.getFocusedTaskIdOnDisplay(targetDisplayId) ) val isFullscreenFocused = focusedTask?.isFullscreen == true val isNonHomeFocused = focusedTask?.activityType != ACTIVITY_TYPE_HOME logV( Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ShellDesktopStateImpl.kt +6 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.desktopmode import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.shared.desktopmode.DesktopState import com.android.wm.shell.sysui.ShellController import com.android.wm.shell.transition.FocusTransitionObserver Loading @@ -25,6 +26,7 @@ class ShellDesktopStateImpl( private val desktopUserRepositories: DesktopUserRepositories, private val focusTransitionObserver: FocusTransitionObserver, private val shellController: ShellController, private val shellTaskOrganizer: ShellTaskOrganizer, ) : ShellDesktopState, DesktopState by desktopState { /** Checks if the given display has an active desktop session (i.e., running freeform tasks). */ private fun isInDesktop(displayId: Int): Boolean = Loading @@ -34,7 +36,10 @@ class ShellDesktopStateImpl( /** Checks if the currently focused task on the given display is the home screen. */ private fun isHomeFocused(displayId: Int): Boolean { val focusedTask = focusTransitionObserver.getFocusedTaskOnDisplay(displayId) val focusedTask = shellTaskOrganizer.getRunningTaskInfo( focusTransitionObserver.getFocusedTaskIdOnDisplay(displayId) ) if (focusedTask == null) { // A null focused task can occur if the Home activity launched before Shell was // fully initialized, and this display has not yet received focus. In this case, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/transition/FocusTransitionObserver.java +10 −8 Original line number Diff line number Diff line Loading @@ -269,17 +269,19 @@ public class FocusTransitionObserver { } /** * 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). * Gets the focused task ID on a specific display. * * @param displayId The ID of the display. * @return The {@link RunningTaskInfo} of the focused task on the given display, * or {@code null} if no task is focused or display not recorded in the observer. * @return The task ID of the focused task on the given display, * or {@code INVALID_TASK_ID} if no task is focused or display not recorded in the * observer. */ @Nullable public RunningTaskInfo getFocusedTaskOnDisplay(int displayId) { // TODO(b/436462692) - Make `getFocusedTaskOnDisplay` always returns the latest TaskInfo return mFocusedTaskOnDisplay.get(displayId); public int getFocusedTaskIdOnDisplay(int displayId) { final RunningTaskInfo taskInfo = mFocusedTaskOnDisplay.get(displayId); // Some properties of `taskInfo` can be stale as this observer only updates the cache when // the focus changes. So we here returns only taskId to ask callers to fetch the TaskInfo // if needed. return taskInfo != null ? taskInfo.taskId : INVALID_TASK_ID; } /** Dumps focused display and tasks. */ Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +4 −4 Original line number Diff line number Diff line Loading @@ -5869,8 +5869,8 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val focusedFullscreenTask = setUpFullscreenTask() whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any())) .thenReturn(focusedFullscreenTask) whenever(focusTransitionObserver.getFocusedTaskIdOnDisplay(any())) .thenReturn(focusedFullscreenTask.taskId) val fullscreenTask = createFullscreenTask() Loading Loading @@ -6267,8 +6267,8 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val focusedFullscreenTask = setUpFullscreenTask() whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any())) .thenReturn(focusedFullscreenTask) whenever(focusTransitionObserver.getFocusedTaskIdOnDisplay(any())) .thenReturn(focusedFullscreenTask.taskId) val freeformTask = createFreeformTask(displayId = DEFAULT_DISPLAY) Loading