From ca4c1a34fd5d756b80ccac6a97efa37e68a6ace7 Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Tue, 13 Dec 2016 16:55:09 -0800 Subject: [PATCH] Get correct insets of the phone screen at boot Before places such as DockedStackDividerController.initSnapAlgorithmForRotations() tries to run getStableInsetsLw() will get no insets on boot (via onConfigurationChanged) because the navigationbar and statusbar have not been added yet. This would leads to some miscalculations until configuration changes such as rotating the screen. Test: manual - logged the inset values on bootup with adb logcat Change-Id: If07c8c007cb355dc418ff987fbb36ce104192379 --- .../java/com/android/server/policy/PhoneWindowManager.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index f48db05adbd0d..8312bca788384 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -6674,9 +6674,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Navigation bar and status bar. getNonDecorInsetsLw(displayRotation, displayWidth, displayHeight, outInsets); - if (mStatusBar != null) { - outInsets.top = mStatusBarHeight; - } + outInsets.top = mStatusBarHeight; } @Override @@ -6685,7 +6683,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { outInsets.setEmpty(); // Only navigation bar - if (mNavigationBar != null) { + if (mHasNavigationBar) { int position = navigationBarPosition(displayWidth, displayHeight, displayRotation); if (position == NAV_BAR_BOTTOM) { outInsets.bottom = getNavigationBarHeight(displayRotation, mUiMode);