From f23642b9af19de68c46b7fec5550cf5eb36f061f Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 7 Dec 2022 10:22:47 +0000 Subject: [PATCH] Do not recreate navigation bar for screen layout change According to the document, the screenLayout can be changed if orientation is changed: If you want to manually handle orientation changes in your app you must declare the "orientation", "screenSize", and "screenLayout" values in the android:configChanges attributes. The activity configuration follows the behavior for years, so [1] makes the calculation of display screen layout (sent to application) consistent, instead of computing a smallest value. NavigationBar was configured to recreate if it detects a screen layout change, then it may trigger an additional display config change since [2] considers the insets of decor windows as a factor to affect screen size. The InterestingConfigChanges flags of NavigationBar was just reused from [3] which is not added for NavigationBar. So a simple redraw is enough for screen layout change, that is also more efficient. [1]: If806e2a42a6c3c548d93ba43c1aed69889901193 [2]: If966bcc8125300d47d5cd631f7db17ff027e5261 [3]: I48af51cc4694ba5c492794631a1e1a54a60fce0b Bug: 233855302 Test: Simulate screen layout change (LONG) of rotation adb shell wm size 720x1280 adb shell wm density 320 atest ConfigChangeTests#testRotation90NoRelaunch Test: Simulate large screen change (width>600dp) The navigation bar shows correctly with adb shell wm size 2600x2200 Switch navigation mode / rotate device. adb shell wm size reset Change-Id: I7c47faabc66ac117a8429ca4d856865e581e1a3d --- .../android/systemui/navigationbar/NavigationBarController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java index 3fd1aa73c0332..ea0c2c9935fc3 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java @@ -98,7 +98,7 @@ public class NavigationBarController implements // Tracks config changes that will actually recreate the nav bar private final InterestingConfigChanges mConfigChanges = new InterestingConfigChanges( - ActivityInfo.CONFIG_FONT_SCALE | ActivityInfo.CONFIG_SCREEN_LAYOUT + ActivityInfo.CONFIG_FONT_SCALE | ActivityInfo.CONFIG_UI_MODE); @Inject