diff options
| author | 2021-10-29 19:18:52 +0800 | |
|---|---|---|
| committer | 2021-11-01 16:43:26 +0800 | |
| commit | 7b04c3ba765bf4376008c1bf0e7751e18252f438 (patch) | |
| tree | b8ff93a472018e0a68b366e0c9a10f17c91f2dea | |
| parent | 28643db5fe08f391f0ea8cf28f04878a0bc9c7fe (diff) | |
Remove redundant operations of split screen
Make moveToSideStage doing reparent oeprations only and leave all the
other active operations to onStageHasChildren. Also make sure it evicts
original children.
Remove setLaunchRoot and setWindowingMode operations in MainStage since
it won't be set as launch root and won't change in between of fullscreen
and multi-window windowing mode anymore.
Fix: 204519739
Bug: 202740040
Test: atest WMShellUnitTests
Change-Id: I6199862502646056966412824a5be840a15e8726
5 files changed, 14 insertions, 31 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/MainStage.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/MainStage.java index 6440ef0b6b11..082fe9205be8 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/MainStage.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/MainStage.java @@ -16,8 +16,6 @@ package com.android.wm.shell.splitscreen; -import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; - import android.annotation.Nullable; import android.content.Context; import android.graphics.Rect; @@ -56,7 +54,6 @@ class MainStage extends StageTaskListener { final WindowContainerToken rootToken = mRootTaskInfo.token; wct.setBounds(rootToken, rootBounds) - .setWindowingMode(rootToken, WINDOWING_MODE_MULTI_WINDOW) // Moving the root task to top after the child tasks were re-parented , or the root // task cannot be visible and focused. .reorder(rootToken, true /* onTop */); @@ -83,11 +80,7 @@ class MainStage extends StageTaskListener { if (mRootTaskInfo == null) return; final WindowContainerToken rootToken = mRootTaskInfo.token; - wct.setLaunchRoot( - rootToken, - null, - null) - .reparentTasks( + wct.reparentTasks( rootToken, null /* newParent */, CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE, @@ -97,9 +90,4 @@ class MainStage extends StageTaskListener { // all its tasks. .reorder(rootToken, false /* onTop */); } - - void updateConfiguration(int windowingMode, Rect bounds, WindowContainerTransaction wct) { - wct.setBounds(mRootTaskInfo.token, bounds) - .setWindowingMode(mRootTaskInfo.token, windowingMode); - } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SideStage.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SideStage.java index d67f4a6077b6..f8c03044c5c9 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SideStage.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SideStage.java @@ -50,14 +50,8 @@ class SideStage extends StageTaskListener { wct.setBounds(rootToken, rootBounds).reorder(rootToken, true /* onTop */); } - void addTask(ActivityManager.RunningTaskInfo task, Rect rootBounds, - WindowContainerTransaction wct) { - final WindowContainerToken rootToken = mRootTaskInfo.token; - wct.setBounds(rootToken, rootBounds) - .reparent(task.token, rootToken, true /* onTop*/) - // Moving the root task to top after the child tasks were reparented , or the root - // task cannot be visible and focused. - .reorder(rootToken, true /* onTop */); + void addTask(ActivityManager.RunningTaskInfo task, WindowContainerTransaction wct) { + wct.reparent(task.token, mRootTaskInfo.token, true /* onTop*/); } boolean removeAllTasks(WindowContainerTransaction wct, boolean toTop) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java index 2cca41153ef0..7be199c75816 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java @@ -268,11 +268,14 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, boolean moveToSideStage(ActivityManager.RunningTaskInfo task, @SplitPosition int sideStagePosition) { final WindowContainerTransaction wct = new WindowContainerTransaction(); + final WindowContainerTransaction evictWct = new WindowContainerTransaction(); setSideStagePosition(sideStagePosition, wct); - mMainStage.activate(getMainStageBounds(), wct, true /* reparent */); - mSideStage.addTask(task, getSideStageBounds(), wct); - mSyncQueue.queue(wct); - mSyncQueue.runInSync(t -> updateSurfaceBounds(null /* layout */, t)); + mSideStage.evictAllChildren(evictWct); + mSideStage.addTask(task, wct); + if (!evictWct.isEmpty()) { + wct.merge(evictWct, true /* transfer */); + } + mTaskOrganizer.applyTransaction(wct); return true; } @@ -759,7 +762,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, // Make sure the main stage is active. mMainStage.activate(getMainStageBounds(), wct, true /* reparent */); mSideStage.moveToTop(getSideStageBounds(), wct); - mTaskOrganizer.applyTransaction(wct); + mSyncQueue.queue(wct); + mSyncQueue.runInSync(t -> updateSurfaceBounds(mSplitLayout, t)); } if (!mLogger.hasStartedSession() && mMainStageListener.mHasChildren && mSideStageListener.mHasChildren) { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SideStageTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SideStageTests.java index 1857faadb433..a31aa58bdc26 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SideStageTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SideStageTests.java @@ -74,7 +74,7 @@ public class SideStageTests extends ShellTestCase { public void testAddTask() { final ActivityManager.RunningTaskInfo task = new TestRunningTaskInfoBuilder().build(); - mSideStage.addTask(task, mRootTask.configuration.windowConfiguration.getBounds(), mWct); + mSideStage.addTask(task, mWct); verify(mWct).reparent(eq(task.token), eq(mRootTask.token), eq(true)); } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java index cd29220bb96a..617e94a4e0a4 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageCoordinatorTests.java @@ -113,10 +113,7 @@ public class StageCoordinatorTests extends ShellTestCase { mStageCoordinator.moveToSideStage(task, SPLIT_POSITION_BOTTOM_OR_RIGHT); - verify(mMainStage).activate(any(Rect.class), any(WindowContainerTransaction.class), - eq(true /* includingTopTask */)); - verify(mSideStage).addTask(eq(task), any(Rect.class), - any(WindowContainerTransaction.class)); + verify(mSideStage).addTask(eq(task), any(WindowContainerTransaction.class)); } @Test |