From 2e6e4355e684d610884d4e3ee33d003a95e10562 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Mon, 8 Nov 2021 18:48:13 +0900 Subject: [PATCH] Do not let snapshot window control the bar The snapshot window will sometime take over the system bar control as the top fullscreen opaque window. To avoid the window take the control if the window is not focusable to avoid the bar flickering issue when the snapshot window has a different insets visibility with the current controller. Test: Launch sticky immersive app from recent. The bar hidden animation works correctly. No flickering. Test: atest MultiDisplayPolicyTests Test: ActivityStarterTests Bug: 203017444 Change-Id: I3d7ba6b7d78c0508ddeccbf1d3408d723bd8e2c0 --- .../core/java/com/android/server/wm/DisplayPolicy.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index eab1aaf0d9fb8..c16b64946fefa 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -2665,10 +2665,15 @@ public class DisplayPolicy { } void updateSystemBarAttributes() { + WindowState winCandidate = mFocusedWindow; + if (winCandidate == null && mTopFullscreenOpaqueWindowState != null + && (mTopFullscreenOpaqueWindowState.mAttrs.flags + & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0) { + // Only focusable window can take system bar control. + winCandidate = mTopFullscreenOpaqueWindowState; + } // If there is no window focused, there will be nobody to handle the events // anyway, so just hang on in whatever state we're in until things settle down. - WindowState winCandidate = mFocusedWindow != null ? mFocusedWindow - : mTopFullscreenOpaqueWindowState; if (winCandidate == null) { return; }