From 491c07a9e0372bb90d2126600ff0a4a2caca25a2 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Fri, 25 Mar 2022 11:53:29 +0800 Subject: [PATCH] Check mAttachInfo.mSystemUiVisibility to see if a SysUI flag exists Previously, we checked info.globalVisibility to see if a system UI flag exists, but since updateCompatSysUiVisibility can process more than one type of one system bar, info.globalVisibility might be changed by one type before the other type checks it. For example, if we process ITYPE_CLIMATE_BAR first with visible=true and hasControl=false, and then, when we process ITYPE_STATUS_BAR with visible=true and hasControl=true, we cannot clear SYSTEM_UI_FLAG_FULLSCREEN by setting it to info.localChanges, because wasVisible is false now. Fix: 226555579 Bug: 225765490 Test: atest WindowInsetsControllerTests Change-Id: I820842c7fe14fc47141a4fa09cfddf68f89dbd41 --- core/java/android/view/ViewRootImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 2613c1a2992fc..9c3aabe495f28 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2331,10 +2331,9 @@ public final class ViewRootImpl implements ViewParent, final int systemUiFlag = publicType == Type.statusBars() ? View.SYSTEM_UI_FLAG_FULLSCREEN : View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - final boolean wasVisible = (info.globalVisibility & systemUiFlag) == 0; if (visible) { info.globalVisibility &= ~systemUiFlag; - if (!wasVisible && hasControl) { + if (hasControl && (mAttachInfo.mSystemUiVisibility & systemUiFlag) != 0) { // The local system UI visibility can only be cleared while we have the control. info.localChanges |= systemUiFlag; }