From 2af1cde04dde9313d5b39e858985fbb4d82937cb Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Thu, 10 Jun 2021 09:01:20 +0000 Subject: [PATCH] Fix not updating split bounds after devices unfolded When the default display changed due to unfolded the device, the split root tasks might be changed to invisible before reporting display info changed to split component. This causing the split component didn't update split layout due to the divider bar is not "initialized" after released with stage roots changed to invisible. This makes sure to update split layout while the split is activated no matter the divider bar is initialized or not. Fix: 189726605 Test: atest WMShellUnitTests Test: check the split bounds updated properly after the device unfolded. Change-Id: I722b08116a97b8482ea6e25b60ffe71005076cd7 --- .../src/com/android/wm/shell/common/split/SplitLayout.java | 5 ++--- .../com/android/wm/shell/splitscreen/StageCoordinator.java | 3 ++- .../com/android/wm/shell/common/split/SplitLayoutTests.java | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java index a445707d85a07..d844dd87438ce 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java @@ -172,13 +172,12 @@ public final class SplitLayout { affectsLayout = true; } - if (mInitialized && affectsLayout) { + if (mInitialized) { release(); init(); - return true; } - return false; + return affectsLayout; } /** Updates recording bounds of divider window and both of the splits. */ 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 bb1d06fbbbf2e..1f12deefb6b5f 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 @@ -602,7 +602,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, public void onDisplayAreaInfoChanged(DisplayAreaInfo displayAreaInfo) { mDisplayAreaInfo = displayAreaInfo; if (mSplitLayout != null - && mSplitLayout.updateConfiguration(mDisplayAreaInfo.configuration)) { + && mSplitLayout.updateConfiguration(mDisplayAreaInfo.configuration) + && mMainStage.isActive()) { onBoundsChanged(mSplitLayout); } } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java index d865f71db5b6d..e138595c47f38 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java @@ -72,7 +72,6 @@ public class SplitLayoutTests extends ShellTestCase { @UiThreadTest public void testUpdateConfiguration() { final Configuration config = getConfiguration(); - mSplitLayout.init(); // Verify it returns true if new config won't affect split layout. assertThat(mSplitLayout.updateConfiguration(config)).isFalse();