From ae1617f9fcac07bc424a5026a185366c0632aac5 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 20 May 2020 16:21:42 -0700 Subject: [PATCH] Prevent ZBoost of TaskDisplayArea Before, when an activity needs z boost, the whole TDA is moved above other windows of ABOVE_TASKS. Now, we don't move TDA anymore. Fix: 149651594 Test: manual: open app and expand notification before app fully start, the app no longer moves above notification. Test: atest WmTests:TaskDisplayAreaTests#testActivityWithZBoost_TaskDisplayAreaDoesNotMovedUp Change-Id: Ie1eae7a5566fc8988cd3ca9f4a56332743facf52 --- .../com/android/server/wm/DisplayArea.java | 6 +++++ .../server/wm/TaskDisplayAreaTests.java | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/services/core/java/com/android/server/wm/DisplayArea.java b/services/core/java/com/android/server/wm/DisplayArea.java index a45a15ba2012c..8260cb31acda0 100644 --- a/services/core/java/com/android/server/wm/DisplayArea.java +++ b/services/core/java/com/android/server/wm/DisplayArea.java @@ -106,6 +106,12 @@ public class DisplayArea extends WindowContainer { } } + @Override + boolean needsZBoost() { + // Z Boost should only happen at or below the ActivityStack level. + return false; + } + @Override boolean fillsParent() { return true; diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java index 52a51875427f6..512042cdf7b95 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskDisplayAreaTests.java @@ -40,6 +40,9 @@ import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; import android.platform.test.annotations.Presubmit; @@ -81,6 +84,25 @@ public class TaskDisplayAreaTests extends WindowTestsBase { mPinnedStack.removeImmediately(); } + @Test + public void testActivityWithZBoost_taskDisplayAreaDoesNotMoveUp() { + final ActivityStack stack = createTaskStackOnDisplay( + WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, mDisplayContent); + final Task task = createTaskInStack(stack, 0 /* userId */); + final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(mDisplayContent); + task.addChild(activity, 0 /* addPos */); + final TaskDisplayArea taskDisplayArea = activity.getDisplayArea(); + activity.mNeedsAnimationBoundsLayer = true; + activity.mNeedsZBoost = true; + spyOn(taskDisplayArea.mSurfaceAnimator); + + mDisplayContent.assignChildLayers(mTransaction); + + assertThat(activity.needsZBoost()).isTrue(); + assertThat(taskDisplayArea.needsZBoost()).isFalse(); + verify(taskDisplayArea.mSurfaceAnimator, never()).setLayer(eq(mTransaction), anyInt()); + } + @Test public void testStackPositionChildAt() { // Test that always-on-top stack can't be moved to position other than top.