From 533f931958a59f4b58b61bb0f1ac48f09c0b9b3f Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 23 May 2023 22:27:51 +0800 Subject: [PATCH] Treat non-existing types as controllable types for compatibility If a device doesn't have a navigation bar, the legacy system UI flag framework would still work as if there is a navigation bar. This CL makes the behavior compatible. It has been broken since cfebf43afb4301099e615ad364b068f9617937c1 Fix: 283882543 Test: atest LayoutTests#testAddingImmersiveWindow Change-Id: I0f9f659f87222e081716c2093e187e10f7d3bdde --- core/java/android/view/InsetsController.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index d8bff1c4cb10f..f570c6d156727 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -658,6 +658,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation /** Set of inset types which cannot be controlled by the user animation */ private @InsetsType int mDisabledUserAnimationInsetsTypes; + /** Set of inset types which are existing */ + private @InsetsType int mExistingTypes = 0; + /** Set of inset types which are visible */ private @InsetsType int mVisibleTypes = WindowInsets.Type.defaultVisible(); @@ -906,6 +909,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } mVisibleTypes = visibleTypes; } + if (mExistingTypes != existingTypes) { + if (WindowInsets.Type.hasCompatSystemBars(mExistingTypes ^ existingTypes)) { + mCompatSysUiVisibilityStaled = true; + } + mExistingTypes = existingTypes; + } InsetsState.traverse(mState, newState, mRemoveGoneSources); updateDisabledUserAnimationTypes(disabledUserAnimationTypes); @@ -1662,7 +1671,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation if (mCompatSysUiVisibilityStaled) { mCompatSysUiVisibilityStaled = false; mHost.updateCompatSysUiVisibility( - mVisibleTypes, mRequestedVisibleTypes, mControllableTypes); + // Treat non-existing types as controllable types for compatibility. + mVisibleTypes, mRequestedVisibleTypes, mControllableTypes | ~mExistingTypes); } }