From 5bdd3e27fb04a4cbba97cccb9562f520c4f2949d Mon Sep 17 00:00:00 2001 From: Charles Chen Date: Tue, 18 Dec 2018 17:51:56 +0800 Subject: [PATCH] Fix navigation bar flaky tests The flakiness is because the timing issue on hasNavigationBar. When a new display is added, onDisplayAdded is called and we may try to add nav bar before DisplayPolicy#configure is called, which sets mHasNavigationBar value. Therefore, we may get false from hasNavigationBar even if a display does support system decorations. Fixes: 120748674 Test: atest ActivityManagerMultiDisplayTests Test: atest ActivityManagerMultiDisplayTests#testNavBarShowingOnDisplayWithDecor * 100 Change-Id: Idb3c3d0874c15a466d179cc471ade5cea890e20e --- .../com/android/server/wm/DisplayPolicy.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 8b8cadc7a4a67..6d3c69385a098 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -505,23 +505,6 @@ public class DisplayPolicy { // TODO: Make it can take screenshot on external display mScreenshotHelper = displayContent.isDefaultDisplay ? new ScreenshotHelper(mContext) : null; - } - - void systemReady() { - mSystemGestures.systemReady(); - } - - private int getDisplayId() { - return mDisplayContent.getDisplayId(); - } - - void onDisplayRemoved() { - mDisplayContent.unregisterPointerEventListener(mSystemGestures); - } - - void configure(int width, int height, int shortSizeDp) { - // Allow the navigation bar to move on non-square small devices (phones). - mNavigationBarCanMove = width != height && shortSizeDp < 600; if (mDisplayContent.isDefaultDisplay) { mHasStatusBar = true; @@ -541,6 +524,23 @@ public class DisplayPolicy { } } + void systemReady() { + mSystemGestures.systemReady(); + } + + private int getDisplayId() { + return mDisplayContent.getDisplayId(); + } + + void onDisplayRemoved() { + mDisplayContent.unregisterPointerEventListener(mSystemGestures); + } + + void configure(int width, int height, int shortSizeDp) { + // Allow the navigation bar to move on non-square small devices (phones). + mNavigationBarCanMove = width != height && shortSizeDp < 600; + } + void updateConfigurationDependentBehaviors() { mNavBarOpacityMode = mContext.getResources().getInteger(R.integer.config_navBarOpacityMode); }