diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index d3243565997d3..3c2832eb96aac 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -1623,14 +1623,13 @@ public class DisplayPolicy { } /** - * @return Whether the top app should hide the statusbar based on the top fullscreen opaque - * window. + * @return Whether the top fullscreen app hides the given type of system bar. */ - boolean topAppHidesStatusBar() { + boolean topAppHidesSystemBar(@InsetsType int type) { if (mTopFullscreenOpaqueWindowState == null || mForceShowSystemBars) { return false; } - return !mTopFullscreenOpaqueWindowState.isRequestedVisible(Type.statusBars()); + return !mTopFullscreenOpaqueWindowState.isRequestedVisible(type); } /** @@ -2053,7 +2052,10 @@ public class DisplayPolicy { navColorWin != null && navColorWin == mDisplayContent.mInputMethodWindow; final int appearance = updateLightNavigationBarLw(win.mAttrs.insetsFlags.appearance, navColorWin) | opaqueAppearance; - final int behavior = win.mAttrs.insetsFlags.behavior; + final WindowState navBarControlWin = topAppHidesSystemBar(Type.navigationBars()) + ? mTopFullscreenOpaqueWindowState + : win; + final int behavior = navBarControlWin.mAttrs.insetsFlags.behavior; final String focusedApp = win.mAttrs.packageName; final boolean isFullscreen = !win.isRequestedVisible(Type.statusBars()) || !win.isRequestedVisible(Type.navigationBars()); @@ -2168,7 +2170,7 @@ public class DisplayPolicy { || mDisplayContent.getInsetsPolicy().remoteInsetsControllerControlsSystemBars(win); mDisplayContent.getInsetsPolicy().updateBarControlTarget(win); - final boolean topAppHidesStatusBar = topAppHidesStatusBar(); + final boolean topAppHidesStatusBar = topAppHidesSystemBar(Type.statusBars()); if (getStatusBar() != null) { final StatusBarManagerInternal statusBar = getStatusBarManagerInternal(); if (statusBar != null) { diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index 0b8af4a5dc3f4..25ce5699ab71c 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -532,7 +532,8 @@ class InsetsPolicy { // fake control to the client, so that it can re-show the bar during this scenario. return mDummyControlTarget; } - if (!canBeTopFullscreenOpaqueWindow(focusedWin) && mPolicy.topAppHidesStatusBar() + if (!canBeTopFullscreenOpaqueWindow(focusedWin) + && mPolicy.topAppHidesSystemBar(Type.statusBars()) && (notificationShade == null || !notificationShade.canReceiveKeys())) { // Non-fullscreen focused window should not break the state that the top-fullscreen-app // window hides status bar, unless the notification shade can receive keys. @@ -592,6 +593,14 @@ class InsetsPolicy { // fake control to the client, so that it can re-show the bar during this scenario. return mDummyControlTarget; } + final WindowState notificationShade = mPolicy.getNotificationShade(); + if (!canBeTopFullscreenOpaqueWindow(focusedWin) + && mPolicy.topAppHidesSystemBar(Type.navigationBars()) + && (notificationShade == null || !notificationShade.canReceiveKeys())) { + // Non-fullscreen focused window should not break the state that the top-fullscreen-app + // window hides navigation bar, unless the notification shade can receive keys. + return mPolicy.getTopFullscreenOpaqueWindow(); + } return focusedWin; }