From fa2a7e4095d18ed625157b42b2f484009fe03e45 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Mon, 15 Aug 2022 17:28:34 +0800 Subject: [PATCH] Let notification shade control system bar visibility When immersive mode confirmation dialog is shown, we choose notfication shade as the system bar controlling window as long as it can receive key events. Fix: 241872473 Test: 1. Show immersive mode confirmation dialog in landscape mode. 2. Enter AOD mode without entering lockscreen mode. Change-Id: I2b9fb12f051bef47cbd21786c6d22e86c1351879 --- .../com/android/server/wm/DisplayPolicy.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 07694065cbd79..185a5a7eb5977 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -2384,18 +2384,19 @@ public class DisplayPolicy { return; } - // The immersive mode confirmation should never affect the system bar visibility, otherwise + // Immersive mode confirmation should never affect the system bar visibility, otherwise // it will unhide the navigation bar and hide itself. if (winCandidate.getAttrs().token == mImmersiveModeConfirmation.getWindowToken()) { - - // The immersive mode confirmation took the focus from mLastFocusedWindow which was - // controlling the system ui visibility. So if mLastFocusedWindow can still receive - // keys, we let it keep controlling the visibility. - final boolean lastFocusCanReceiveKeys = - (mLastFocusedWindow != null && mLastFocusedWindow.canReceiveKeys()); - winCandidate = isKeyguardShowing() && !isKeyguardOccluded() ? mNotificationShade - : lastFocusCanReceiveKeys ? mLastFocusedWindow - : mTopFullscreenOpaqueWindowState; + if (mNotificationShade != null && mNotificationShade.canReceiveKeys()) { + // Let notification shade control the system bar visibility. + winCandidate = mNotificationShade; + } else if (mLastFocusedWindow != null && mLastFocusedWindow.canReceiveKeys()) { + // Immersive mode confirmation took the focus from mLastFocusedWindow which was + // controlling the system bar visibility. Let it keep controlling the visibility. + winCandidate = mLastFocusedWindow; + } else { + winCandidate = mTopFullscreenOpaqueWindowState; + } if (winCandidate == null) { return; }