summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/Task.java6
-rw-r--r--services/core/java/com/android/server/wm/WindowContainer.java20
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java9
3 files changed, 24 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 787c5d6f7699..c72087bfbe5f 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -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());
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 70143bae9fb0..6dbd259b67c0 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -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.
@@ -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);
@@ -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) {
@@ -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);
@@ -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;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
index 4ebbf496b2a4..a94b58690775 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
@@ -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);
@@ -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);
@@ -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 {