From be8064ce32ff051bfdda80c5cb49c5d4362d1a79 Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Mon, 18 Nov 2024 14:02:12 -0800 Subject: Fix messed-up divider position when unlocking with IME showing Bug was happening because we didn't account for the case where the device is unlocked with the IME showing. So the layout was properly being adjusted for IME, but the divider showing animation (applyDividerVisibility) was erroneously setting the divider's position back to the center of the screen afterwards. Solution is for applyDividerVisibility() to update the full layout using updateSurfaceBounds() instead of just setting the position based on app bounds. Fixes: 378620695 Flag: EXEMPT bugfix Test: Bug no longer repros Change-Id: Ieb7be52a015099addf8fff94edf693b198dfcd17 --- .../src/com/android/wm/shell/splitscreen/StageCoordinator.java | 8 ++------ .../com/android/wm/shell/splitscreen/StageCoordinatorTests.java | 4 +++- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'libs') 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 81b96cd62b14..686099069c4f 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 @@ -1876,11 +1876,9 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, mDividerFadeInAnimator.cancel(); } - mSplitLayout.getRefDividerBounds(mTempRect1); if (t != null) { + updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */); t.setVisibility(dividerLeash, mDividerVisible); - t.setLayer(dividerLeash, Integer.MAX_VALUE); - t.setPosition(dividerLeash, mTempRect1.left, mTempRect1.top); } else if (mDividerVisible) { final SurfaceControl.Transaction transaction = mTransactionPool.acquire(); mDividerFadeInAnimator = ValueAnimator.ofFloat(0f, 1f); @@ -1900,11 +1898,9 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, mDividerFadeInAnimator.cancel(); return; } - mSplitLayout.getRefDividerBounds(mTempRect1); + updateSurfaceBounds(mSplitLayout, transaction, false /* applyResizingOffset */); transaction.show(dividerLeash); transaction.setAlpha(dividerLeash, 0); - transaction.setLayer(dividerLeash, Integer.MAX_VALUE); - transaction.setPosition(dividerLeash, mTempRect1.left, mTempRect1.top); transaction.apply(); } 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 a252a9db7095..54a887461872 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 @@ -33,6 +33,7 @@ import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.notNull; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -292,7 +293,8 @@ public class StageCoordinatorTests extends ShellTestCase { public void testFinishEnterSplitScreen_applySurfaceLayout() { mStageCoordinator.finishEnterSplitScreen(new SurfaceControl.Transaction()); - verify(mSplitLayout).applySurfaceChanges(any(), any(), any(), any(), any(), eq(false)); + verify(mSplitLayout, atLeastOnce()) + .applySurfaceChanges(any(), any(), any(), any(), any(), eq(false)); } @Test -- cgit v1.2.3-59-g8ed1b