Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +5 −2 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.view.SurfaceControl; import android.view.WindowManager; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import android.window.TaskSnapshotManager; import androidx.annotation.OptIn; Loading Loading @@ -968,7 +969,8 @@ public abstract class WMShellModule { DesktopState desktopState, DesktopConfig desktopConfig, VisualIndicatorUpdateScheduler visualIndicatorUpdateScheduler, Optional<DesktopFirstListenerManager> desktopFirstListenerManager) { Optional<DesktopFirstListenerManager> desktopFirstListenerManager, TaskSnapshotManager taskSnapshotManager) { return new DesktopTasksController( context, shellInit, Loading Loading @@ -1017,7 +1019,8 @@ public abstract class WMShellModule { desktopState, desktopConfig, visualIndicatorUpdateScheduler, desktopFirstListenerManager); desktopFirstListenerManager, taskSnapshotManager); } @WMSingleton Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +18 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.ActivityManager import android.app.ActivityManager.RecentTaskInfo import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityOptions import android.app.ActivityTaskManager import android.app.ActivityTaskManager.INVALID_TASK_ID import android.app.AppOpsManager import android.app.KeyguardManager Loading @@ -44,6 +45,7 @@ import android.os.Binder import android.os.Bundle import android.os.Handler import android.os.IBinder import android.os.RemoteException import android.os.Trace import android.os.UserHandle import android.os.UserManager Loading Loading @@ -78,6 +80,7 @@ import android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVI import android.window.DesktopModeFlags.ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS import android.window.RemoteTransition import android.window.SplashScreen.SPLASH_SCREEN_STYLE_ICON import android.window.TaskSnapshotManager import android.window.TransitionInfo import android.window.TransitionInfo.Change import android.window.TransitionRequestInfo Loading Loading @@ -255,6 +258,7 @@ class DesktopTasksController( private val desktopConfig: DesktopConfig, private val visualIndicatorUpdateScheduler: VisualIndicatorUpdateScheduler, private val desktopFirstListenerManager: Optional<DesktopFirstListenerManager>, private val taskSnapshotManager: TaskSnapshotManager, ) : RemoteCallable<DesktopTasksController>, Transitions.TransitionHandler, Loading Loading @@ -792,6 +796,20 @@ class DesktopTasksController( val wct = WindowContainerTransaction() addOnDisplayDisconnectChanges(wct, disconnectedDisplayId, destinationDisplayId) .invoke(transition) try { userRepositories.current.getExpandedTasksOrdered(disconnectedDisplayId).forEach { logD("addOnDisplayDisconnect: taking a snapshot of=$it before disconnect") if (Flags.reduceTaskSnapshotMemoryUsage()) { taskSnapshotManager.takeTaskSnapshot(it, true) } else { ActivityTaskManager.getService().getTaskSnapshot(it, false) } } } catch (e: RemoteException) { logE("addOnDisplayDisconnect: failed to take task snapshot", e) } return wct } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +8 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ import android.widget.Toast import android.window.DisplayAreaInfo import android.window.IWindowContainerToken import android.window.RemoteTransition import android.window.TaskSnapshotManager import android.window.TransitionInfo import android.window.TransitionRequestInfo import android.window.WindowContainerToken Loading Loading @@ -301,6 +302,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() @Mock private lateinit var mockAppOpsManager: AppOpsManager @Mock private lateinit var visualIndicatorUpdateScheduler: VisualIndicatorUpdateScheduler @Mock private lateinit var desktopFirstListenerManager: DesktopFirstListenerManager @Mock private lateinit var taskSnapshotManager: TaskSnapshotManager private lateinit var controller: DesktopTasksController private lateinit var shellInit: ShellInit Loading Loading @@ -535,6 +537,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() desktopConfig, visualIndicatorUpdateScheduler, Optional.of(desktopFirstListenerManager), taskSnapshotManager, ) @After Loading Loading @@ -11212,6 +11215,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() this.displayId == SECOND_DISPLAY } ) verify(taskSnapshotManager).takeTaskSnapshot(secondDisplayTask.taskId, true) } @Test Loading Loading @@ -11255,6 +11259,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() this.deskId == DISCONNECTED_DESK_ID } ) verify(taskSnapshotManager).takeTaskSnapshot(secondDisplayTask.taskId, true) } @Test Loading Loading @@ -11296,6 +11301,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() this.deskId == DISCONNECTED_DESK_ID } ) verify(taskSnapshotManager).takeTaskSnapshot(secondDisplayTask.taskId, true) } @Test Loading Loading @@ -11327,6 +11333,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() this.deskId == DISCONNECTED_DESK_ID } ) verify(taskSnapshotManager, never()).takeTaskSnapshot(any(), any()) } @Test Loading Loading @@ -11361,6 +11368,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() secondDisplayTask = secondDisplayTask, ) assertThat(findBoundsChange(wct, secondDisplayTask)).isEqualTo(Rect(33, 61, 299, 327)) verify(taskSnapshotManager).takeTaskSnapshot(secondDisplayTask.taskId, true) } private fun performDisplayDisconnectTransition( Loading services/core/java/com/android/server/wm/SnapshotController.java +5 −1 Original line number Diff line number Diff line Loading @@ -124,8 +124,12 @@ class SnapshotController { // Note that if this task is being transiently hidden, the snapshot will be captured at // the end of the transient transition (see Transition#finishTransition()), because IME // won't move be moved during the transition and the tasks are still live. // Also don't take the snapshot if there is a bounds change in a visible to invisible // transition as the app won't redraw. This can happen when a task is moving from one // display to another. if (task != null && !task.mCreatedByOrganizer && !task.isVisibleRequested() && !task.mTransitionController.isTransientHide(task)) { && !task.mTransitionController.isTransientHide(task) && task.getBounds().equals(info.mAbsoluteBounds)) { mTaskSnapshotController.recordSnapshot(task, info); } // Won't need to capture activity snapshot in close transition. Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +5 −2 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.view.SurfaceControl; import android.view.WindowManager; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import android.window.TaskSnapshotManager; import androidx.annotation.OptIn; Loading Loading @@ -968,7 +969,8 @@ public abstract class WMShellModule { DesktopState desktopState, DesktopConfig desktopConfig, VisualIndicatorUpdateScheduler visualIndicatorUpdateScheduler, Optional<DesktopFirstListenerManager> desktopFirstListenerManager) { Optional<DesktopFirstListenerManager> desktopFirstListenerManager, TaskSnapshotManager taskSnapshotManager) { return new DesktopTasksController( context, shellInit, Loading Loading @@ -1017,7 +1019,8 @@ public abstract class WMShellModule { desktopState, desktopConfig, visualIndicatorUpdateScheduler, desktopFirstListenerManager); desktopFirstListenerManager, taskSnapshotManager); } @WMSingleton Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +18 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.ActivityManager import android.app.ActivityManager.RecentTaskInfo import android.app.ActivityManager.RunningTaskInfo import android.app.ActivityOptions import android.app.ActivityTaskManager import android.app.ActivityTaskManager.INVALID_TASK_ID import android.app.AppOpsManager import android.app.KeyguardManager Loading @@ -44,6 +45,7 @@ import android.os.Binder import android.os.Bundle import android.os.Handler import android.os.IBinder import android.os.RemoteException import android.os.Trace import android.os.UserHandle import android.os.UserManager Loading Loading @@ -78,6 +80,7 @@ import android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVI import android.window.DesktopModeFlags.ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS import android.window.RemoteTransition import android.window.SplashScreen.SPLASH_SCREEN_STYLE_ICON import android.window.TaskSnapshotManager import android.window.TransitionInfo import android.window.TransitionInfo.Change import android.window.TransitionRequestInfo Loading Loading @@ -255,6 +258,7 @@ class DesktopTasksController( private val desktopConfig: DesktopConfig, private val visualIndicatorUpdateScheduler: VisualIndicatorUpdateScheduler, private val desktopFirstListenerManager: Optional<DesktopFirstListenerManager>, private val taskSnapshotManager: TaskSnapshotManager, ) : RemoteCallable<DesktopTasksController>, Transitions.TransitionHandler, Loading Loading @@ -792,6 +796,20 @@ class DesktopTasksController( val wct = WindowContainerTransaction() addOnDisplayDisconnectChanges(wct, disconnectedDisplayId, destinationDisplayId) .invoke(transition) try { userRepositories.current.getExpandedTasksOrdered(disconnectedDisplayId).forEach { logD("addOnDisplayDisconnect: taking a snapshot of=$it before disconnect") if (Flags.reduceTaskSnapshotMemoryUsage()) { taskSnapshotManager.takeTaskSnapshot(it, true) } else { ActivityTaskManager.getService().getTaskSnapshot(it, false) } } } catch (e: RemoteException) { logE("addOnDisplayDisconnect: failed to take task snapshot", e) } return wct } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +8 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ import android.widget.Toast import android.window.DisplayAreaInfo import android.window.IWindowContainerToken import android.window.RemoteTransition import android.window.TaskSnapshotManager import android.window.TransitionInfo import android.window.TransitionRequestInfo import android.window.WindowContainerToken Loading Loading @@ -301,6 +302,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() @Mock private lateinit var mockAppOpsManager: AppOpsManager @Mock private lateinit var visualIndicatorUpdateScheduler: VisualIndicatorUpdateScheduler @Mock private lateinit var desktopFirstListenerManager: DesktopFirstListenerManager @Mock private lateinit var taskSnapshotManager: TaskSnapshotManager private lateinit var controller: DesktopTasksController private lateinit var shellInit: ShellInit Loading Loading @@ -535,6 +537,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() desktopConfig, visualIndicatorUpdateScheduler, Optional.of(desktopFirstListenerManager), taskSnapshotManager, ) @After Loading Loading @@ -11212,6 +11215,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() this.displayId == SECOND_DISPLAY } ) verify(taskSnapshotManager).takeTaskSnapshot(secondDisplayTask.taskId, true) } @Test Loading Loading @@ -11255,6 +11259,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() this.deskId == DISCONNECTED_DESK_ID } ) verify(taskSnapshotManager).takeTaskSnapshot(secondDisplayTask.taskId, true) } @Test Loading Loading @@ -11296,6 +11301,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() this.deskId == DISCONNECTED_DESK_ID } ) verify(taskSnapshotManager).takeTaskSnapshot(secondDisplayTask.taskId, true) } @Test Loading Loading @@ -11327,6 +11333,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() this.deskId == DISCONNECTED_DESK_ID } ) verify(taskSnapshotManager, never()).takeTaskSnapshot(any(), any()) } @Test Loading Loading @@ -11361,6 +11368,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() secondDisplayTask = secondDisplayTask, ) assertThat(findBoundsChange(wct, secondDisplayTask)).isEqualTo(Rect(33, 61, 299, 327)) verify(taskSnapshotManager).takeTaskSnapshot(secondDisplayTask.taskId, true) } private fun performDisplayDisconnectTransition( Loading
services/core/java/com/android/server/wm/SnapshotController.java +5 −1 Original line number Diff line number Diff line Loading @@ -124,8 +124,12 @@ class SnapshotController { // Note that if this task is being transiently hidden, the snapshot will be captured at // the end of the transient transition (see Transition#finishTransition()), because IME // won't move be moved during the transition and the tasks are still live. // Also don't take the snapshot if there is a bounds change in a visible to invisible // transition as the app won't redraw. This can happen when a task is moving from one // display to another. if (task != null && !task.mCreatedByOrganizer && !task.isVisibleRequested() && !task.mTransitionController.isTransientHide(task)) { && !task.mTransitionController.isTransientHide(task) && task.getBounds().equals(info.mAbsoluteBounds)) { mTaskSnapshotController.recordSnapshot(task, info); } // Won't need to capture activity snapshot in close transition. Loading