Loading services/core/java/com/android/server/wm/Task.java +6 −0 Original line number Diff line number Diff line Loading @@ -1994,6 +1994,12 @@ class Task extends TaskFragment { final boolean wasInMultiWindowMode = inMultiWindowMode(); final boolean wasInPictureInPicture = inPinnedWindowingMode(); super.onConfigurationChanged(newParentConfig); if (mDisplayContent == null) { // This should be initializing from Task.Builder. The onConfigurationChanged will be // called again when this task is attached to hierarchy. Early return here because the // following operations are no-op for a non-attached task. return; } // Only need to update surface size here since the super method will handle updating // surface position. updateSurfaceSize(getSyncTransaction()); Loading services/core/java/com/android/server/wm/WindowContainer.java +13 −7 Original line number Diff line number Diff line Loading @@ -202,8 +202,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< private int mLastLayer = 0; private SurfaceControl mLastRelativeToLayer = null; // TODO(b/132320879): Remove this from WindowContainers except DisplayContent. private final Transaction mPendingTransaction; private Transaction mPendingTransaction; /** * Windows that clients are waiting to have drawn. Loading Loading @@ -358,7 +357,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< WindowContainer(WindowManagerService wms) { mWmService = wms; mTransitionController = mWmService.mAtmService.getTransitionController(); mPendingTransaction = wms.mTransactionFactory.get(); mSyncTransaction = wms.mTransactionFactory.get(); mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished, wms); mSurfaceFreezer = new SurfaceFreezer(this, wms); Loading Loading @@ -580,6 +578,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< @Override public void onConfigurationChanged(Configuration newParentConfig) { super.onConfigurationChanged(newParentConfig); if (mParent == null) { // Avoid unnecessary surface operation before attaching to a parent. return; } updateSurfacePositionNonOrganized(); scheduleAnimation(); if (mOverlayHost != null) { Loading Loading @@ -1074,8 +1076,9 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } } mDisplayContent = dc; if (dc != null && dc != this) { if (dc != null && dc != this && mPendingTransaction != null) { dc.getPendingTransaction().merge(mPendingTransaction); mPendingTransaction = null; } for (int i = mChildren.size() - 1; i >= 0; --i) { final WindowContainer child = mChildren.get(i); Loading Loading @@ -2922,14 +2925,17 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< @Override public Transaction getPendingTransaction() { final DisplayContent displayContent = getDisplayContent(); if (displayContent != null && displayContent != this) { return displayContent.getPendingTransaction(); final WindowContainer<?> dc = mDisplayContent; if (dc != null && dc.mPendingTransaction != null) { return dc.mPendingTransaction; } // This WindowContainer has not attached to a display yet or this is a DisplayContent, so we // let the caller to save the surface operations within the local mPendingTransaction. // If this is not a DisplayContent, we will merge it to the pending transaction of its // display once it attaches to it. if (mPendingTransaction == null) { mPendingTransaction = mWmService.mTransactionFactory.get(); } return mPendingTransaction; } Loading services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +5 −4 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ public class WindowContainerTests extends WindowTestsBase { @Test public void testAddChildSetsSurfacePosition() { reset(mTransaction); try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mWm)) { try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mDisplayContent)) { WindowContainer child = new WindowContainer(mWm); child.setBounds(1, 1, 10, 10); Loading Loading @@ -266,7 +266,7 @@ public class WindowContainerTests extends WindowTestsBase { @Test public void testRemoveImmediatelyClearsLastSurfacePosition() { reset(mTransaction); try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mWm)) { try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mDisplayContent)) { final WindowContainer<WindowContainer> child1 = new WindowContainer(mWm); child1.setBounds(1, 1, 10, 10); Loading Loading @@ -1827,8 +1827,9 @@ public class WindowContainerTests extends WindowTestsBase { implements AutoCloseable { private final SurfaceSession mSession = new SurfaceSession(); MockSurfaceBuildingContainer(WindowManagerService wm) { super(wm); MockSurfaceBuildingContainer(DisplayContent dc) { super(dc.mWmService); onDisplayChanged(dc); } static class MockSurfaceBuilder extends SurfaceControl.Builder { Loading Loading
services/core/java/com/android/server/wm/Task.java +6 −0 Original line number Diff line number Diff line Loading @@ -1994,6 +1994,12 @@ class Task extends TaskFragment { final boolean wasInMultiWindowMode = inMultiWindowMode(); final boolean wasInPictureInPicture = inPinnedWindowingMode(); super.onConfigurationChanged(newParentConfig); if (mDisplayContent == null) { // This should be initializing from Task.Builder. The onConfigurationChanged will be // called again when this task is attached to hierarchy. Early return here because the // following operations are no-op for a non-attached task. return; } // Only need to update surface size here since the super method will handle updating // surface position. updateSurfaceSize(getSyncTransaction()); Loading
services/core/java/com/android/server/wm/WindowContainer.java +13 −7 Original line number Diff line number Diff line Loading @@ -202,8 +202,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< private int mLastLayer = 0; private SurfaceControl mLastRelativeToLayer = null; // TODO(b/132320879): Remove this from WindowContainers except DisplayContent. private final Transaction mPendingTransaction; private Transaction mPendingTransaction; /** * Windows that clients are waiting to have drawn. Loading Loading @@ -358,7 +357,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< WindowContainer(WindowManagerService wms) { mWmService = wms; mTransitionController = mWmService.mAtmService.getTransitionController(); mPendingTransaction = wms.mTransactionFactory.get(); mSyncTransaction = wms.mTransactionFactory.get(); mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished, wms); mSurfaceFreezer = new SurfaceFreezer(this, wms); Loading Loading @@ -580,6 +578,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< @Override public void onConfigurationChanged(Configuration newParentConfig) { super.onConfigurationChanged(newParentConfig); if (mParent == null) { // Avoid unnecessary surface operation before attaching to a parent. return; } updateSurfacePositionNonOrganized(); scheduleAnimation(); if (mOverlayHost != null) { Loading Loading @@ -1074,8 +1076,9 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } } mDisplayContent = dc; if (dc != null && dc != this) { if (dc != null && dc != this && mPendingTransaction != null) { dc.getPendingTransaction().merge(mPendingTransaction); mPendingTransaction = null; } for (int i = mChildren.size() - 1; i >= 0; --i) { final WindowContainer child = mChildren.get(i); Loading Loading @@ -2922,14 +2925,17 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< @Override public Transaction getPendingTransaction() { final DisplayContent displayContent = getDisplayContent(); if (displayContent != null && displayContent != this) { return displayContent.getPendingTransaction(); final WindowContainer<?> dc = mDisplayContent; if (dc != null && dc.mPendingTransaction != null) { return dc.mPendingTransaction; } // This WindowContainer has not attached to a display yet or this is a DisplayContent, so we // let the caller to save the surface operations within the local mPendingTransaction. // If this is not a DisplayContent, we will merge it to the pending transaction of its // display once it attaches to it. if (mPendingTransaction == null) { mPendingTransaction = mWmService.mTransactionFactory.get(); } return mPendingTransaction; } Loading
services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +5 −4 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ public class WindowContainerTests extends WindowTestsBase { @Test public void testAddChildSetsSurfacePosition() { reset(mTransaction); try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mWm)) { try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mDisplayContent)) { WindowContainer child = new WindowContainer(mWm); child.setBounds(1, 1, 10, 10); Loading Loading @@ -266,7 +266,7 @@ public class WindowContainerTests extends WindowTestsBase { @Test public void testRemoveImmediatelyClearsLastSurfacePosition() { reset(mTransaction); try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mWm)) { try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mDisplayContent)) { final WindowContainer<WindowContainer> child1 = new WindowContainer(mWm); child1.setBounds(1, 1, 10, 10); Loading Loading @@ -1827,8 +1827,9 @@ public class WindowContainerTests extends WindowTestsBase { implements AutoCloseable { private final SurfaceSession mSession = new SurfaceSession(); MockSurfaceBuildingContainer(WindowManagerService wm) { super(wm); MockSurfaceBuildingContainer(DisplayContent dc) { super(dc.mWmService); onDisplayChanged(dc); } static class MockSurfaceBuilder extends SurfaceControl.Builder { Loading