From fc64c8308e98470aadb91e742e72719685a9a7f4 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Tue, 4 Dec 2018 11:38:26 +0800 Subject: [PATCH] No status bar for external display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test cases were failed to get the VR display because the height of newly created display doesn’t match the expected size. We shouldn’t remove status bar size from the display’s height since there is no status bar on VR display (not even on any external displays yet). Bug: 117894098 Test: atest ActivityManagerVrDisplayTests Change-Id: If053d3102cfadf511f1065f6475f37468e1d1836 --- .../com/android/server/wm/DisplayPolicy.java | 26 ++++++++++++++----- .../server/wm/DisplayPolicyTestsBase.java | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index f1d77b9961cf1..a8e4085e59d56 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -222,6 +222,7 @@ public class DisplayPolicy { private volatile int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; private volatile boolean mHdmiPlugged; + private volatile boolean mHasStatusBar; private volatile boolean mHasNavigationBar; // Can the navigation bar ever move to the side? private volatile boolean mNavigationBarCanMove; @@ -523,6 +524,7 @@ public class DisplayPolicy { mNavigationBarCanMove = width != height && shortSizeDp < 600; if (mDisplayContent.isDefaultDisplay) { + mHasStatusBar = true; mHasNavigationBar = mContext.getResources().getBoolean(R.bool.config_showNavigationBar); // Allow a system property to override this. Used by the emulator. @@ -534,6 +536,7 @@ public class DisplayPolicy { mHasNavigationBar = true; } } else { + mHasStatusBar = false; mHasNavigationBar = mDisplayContent.getDisplay().supportsSystemDecorations(); } } @@ -589,6 +592,10 @@ public class DisplayPolicy { return mHasNavigationBar; } + public boolean hasStatusBar() { + return mHasStatusBar; + } + public boolean navigationBarCanMove() { return mNavigationBarCanMove; } @@ -2493,12 +2500,19 @@ public class DisplayPolicy { final int landscapeRotation = displayRotation.getLandscapeRotation(); final int seascapeRotation = displayRotation.getSeascapeRotation(); - mStatusBarHeightForRotation[portraitRotation] = - mStatusBarHeightForRotation[upsideDownRotation] = - res.getDimensionPixelSize(R.dimen.status_bar_height_portrait); - mStatusBarHeightForRotation[landscapeRotation] = - mStatusBarHeightForRotation[seascapeRotation] = - res.getDimensionPixelSize(R.dimen.status_bar_height_landscape); + if (hasStatusBar()) { + mStatusBarHeightForRotation[portraitRotation] = + mStatusBarHeightForRotation[upsideDownRotation] = + res.getDimensionPixelSize(R.dimen.status_bar_height_portrait); + mStatusBarHeightForRotation[landscapeRotation] = + mStatusBarHeightForRotation[seascapeRotation] = + res.getDimensionPixelSize(R.dimen.status_bar_height_landscape); + } else { + mStatusBarHeightForRotation[portraitRotation] = + mStatusBarHeightForRotation[upsideDownRotation] = + mStatusBarHeightForRotation[landscapeRotation] = + mStatusBarHeightForRotation[seascapeRotation] = 0; + } // Height of the navigation bar when presented horizontally at bottom mNavigationBarHeightForRotationDefault[portraitRotation] = diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java index 1d63c57e6cfe3..7be331cc8a060 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java @@ -79,6 +79,7 @@ public class DisplayPolicyTestsBase extends WindowTestsBase { resources.addOverride(R.dimen.navigation_bar_width, NAV_BAR_HEIGHT); when(mDisplayPolicy.getSystemUiContext()).thenReturn(context); when(mDisplayPolicy.hasNavigationBar()).thenReturn(true); + when(mDisplayPolicy.hasStatusBar()).thenReturn(true); final int shortSizeDp = Math.min(DISPLAY_WIDTH, DISPLAY_HEIGHT) * DENSITY_DEFAULT / DISPLAY_DENSITY;