From 264193355857e409e9e0c0410425b3a318b6979d Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Wed, 15 Sep 2021 18:38:03 +0900 Subject: [PATCH] Simulate extra navigation bar for fixed rotation The change is to consider extra navigation bar and all other windows providing insets when simulate display for fixed rotation. This change introduced a potential behavior divergence between flexible insets and the legacy one. For the legacy usage, the extra navigation bar will be layout during the simulated layout process for the display frame calculation, and all the insets without a window, insets of status bar, navigation bar and extra navigation bar will be included in the result. For the new flexible insets implementation, all the windows providing insets will be simulated. Currently, there's no actual difference, but the behavior will be different if there're more window providing insets during fixed rotation. Bug: 199472694 Test: Check fixed rotation behavior with taskbar. Test: Check result of DisplayPolicy#simulateLayoutDisplay(). Change-Id: I5db1cb78dee50e593d229922d39c8898d5d4eef7 --- .../com/android/server/wm/DisplayPolicy.java | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 3dff680c9497e..8ec912ea19747 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -1531,31 +1531,51 @@ public class DisplayPolicy { * some temporal states, but doesn't change the window frames used to show on screen. */ void simulateLayoutDisplay(DisplayFrames displayFrames, SparseArray barContentFrames) { - if (mNavigationBar != null) { - final WindowFrames simulatedWindowFrames = new WindowFrames(); - if (INSETS_LAYOUT_GENERALIZATION) { - simulateLayoutDecorWindow(mNavigationBar, displayFrames, simulatedWindowFrames, + if (INSETS_LAYOUT_GENERALIZATION) { + final InsetsStateController insetsStateController = + mDisplayContent.getInsetsStateController(); + for (int type = 0; type < InsetsState.SIZE; type++) { + final InsetsSourceProvider provider = + insetsStateController.peekSourceProvider(type); + if (provider == null || !provider.hasWindow() + || provider.mWin.getControllableInsetProvider() != provider) { + continue; + } + final WindowFrames simulatedWindowFrames = new WindowFrames(); + simulateLayoutDecorWindow(provider.mWin, displayFrames, simulatedWindowFrames, barContentFrames, contentFrame -> simulateLayoutForContentFrame(displayFrames, - mNavigationBar, contentFrame)); - } else { + provider.mWin, contentFrame)); + } + } else { + if (mNavigationBar != null) { + final WindowFrames simulatedWindowFrames = new WindowFrames(); simulateLayoutDecorWindow(mNavigationBar, displayFrames, simulatedWindowFrames, barContentFrames, contentFrame -> layoutNavigationBar(displayFrames, contentFrame)); } - } - if (mStatusBar != null) { - final WindowFrames simulatedWindowFrames = new WindowFrames(); - if (INSETS_LAYOUT_GENERALIZATION) { - simulateLayoutDecorWindow(mStatusBar, displayFrames, simulatedWindowFrames, - barContentFrames, - contentFrame -> simulateLayoutForContentFrame(displayFrames, - mStatusBar, contentFrame)); - } else { + if (mStatusBar != null) { + final WindowFrames simulatedWindowFrames = new WindowFrames(); simulateLayoutDecorWindow(mStatusBar, displayFrames, simulatedWindowFrames, barContentFrames, contentFrame -> layoutStatusBar(displayFrames, contentFrame)); } + if (mExtraNavBarAlt != null) { + // There's no pre-defined behavior for the extra navigation bar, we need to use the + // new flexible insets logic anyway. + final WindowFrames simulatedWindowFrames = new WindowFrames(); + simulateLayoutDecorWindow(mExtraNavBarAlt, displayFrames, simulatedWindowFrames, + barContentFrames, + contentFrame -> simulateLayoutForContentFrame(displayFrames, + mExtraNavBarAlt, contentFrame)); + } + if (mClimateBarAlt != null) { + final WindowFrames simulatedWindowFrames = new WindowFrames(); + simulateLayoutDecorWindow(mClimateBarAlt, displayFrames, simulatedWindowFrames, + barContentFrames, + contentFrame -> simulateLayoutForContentFrame(displayFrames, + mClimateBarAlt, contentFrame)); + } } }