From c9619b0e1fc32f7f7e38ec93d1a9da3bceb30a52 Mon Sep 17 00:00:00 2001 From: Tiger Date: Thu, 9 Feb 2023 20:25:46 +0800 Subject: [PATCH] Don't exit immersive mode while showing a floating window While a floating window becomes the focused window, status bar would stay hidden if the top fullscreen app hides it. This is the existing logic. This CL applies the same logic to navigation bar. Fix: 225684651 Test: 1. Open Window Insets Test > Window Insets Controller. 2. Hide navigation bar. 3. Click on the drop-down menu. See if navigation bar stay hidden. Change-Id: I45ec5ec3312ea98f1c65886e509d2b3029603df7 --- .../java/com/android/server/wm/DisplayPolicy.java | 14 ++++++++------ .../java/com/android/server/wm/InsetsPolicy.java | 11 ++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) 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; }