From 4ad1250bf5830f914bd171955f23de5a7a7d38e4 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Thu, 2 Mar 2023 15:17:39 +0900 Subject: [PATCH] Use non-cached value when calculation button forced visible state The change is to make use of the button forced visible state in EdgeBackGestureHandler instead of the cached value in the Navigation bar. The value was only available through a callback and the cached value may be unpredictable when the value has not changed since system boots. That may cause the insets provided by the navigation bar wrong. When the device firstly boot into setup wizard the update user resource and the callback is not called. Keep the callback to reposition the navigation bar when necessary, but only use read value from the EdgeBackGestureHandler to fix the issue. Bug: 268210882 Test: Check setup wizard as stated in b/268210882 Change-Id: I31c6e06c0b1ab07aa8c2fdcacce216ca3ad61869 --- .../systemui/navigationbar/NavigationBar.java | 15 ++++-------- .../gestural/EdgeBackGestureHandler.java | 23 +++++++++++-------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java index 4db1da3f1c956..37c2233809170 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java @@ -164,6 +164,8 @@ import com.android.systemui.util.ViewController; import com.android.wm.shell.back.BackAnimation; import com.android.wm.shell.pip.Pip; +import dagger.Lazy; + import java.io.PrintWriter; import java.util.Locale; import java.util.Map; @@ -173,8 +175,6 @@ import java.util.function.Consumer; import javax.inject.Inject; -import dagger.Lazy; - /** * Contains logic for a navigation bar view. */ @@ -251,12 +251,6 @@ public class NavigationBar extends ViewController implements private boolean mTransientShown; private boolean mTransientShownFromGestureOnSystemBar; - /** - * This is to indicate whether the navigation bar button is forced visible. This is true - * when the setup wizard is on display. When that happens, the window frame should be provided - * as insets size directly. - */ - private boolean mIsButtonForceVisible; private int mNavBarMode = NAV_BAR_MODE_3BUTTON; private LightBarController mLightBarController; private final LightBarController mMainLightBarController; @@ -670,8 +664,7 @@ public class NavigationBar extends ViewController implements mView.setTouchHandler(mTouchHandler); setNavBarMode(mNavBarMode); mEdgeBackGestureHandler.setStateChangeCallback(mView::updateStates); - mEdgeBackGestureHandler.setButtonForceVisibleChangeCallback((forceVisible) -> { - mIsButtonForceVisible = forceVisible; + mEdgeBackGestureHandler.setButtonForcedVisibleChangeCallback((forceVisible) -> { repositionNavigationBar(mCurrentRotation); }); mNavigationBarTransitions.addListener(this::onBarTransition); @@ -1706,7 +1699,7 @@ public class NavigationBar extends ViewController implements private InsetsFrameProvider[] getInsetsFrameProvider(int insetsHeight, Context userContext) { final InsetsFrameProvider navBarProvider; - if (insetsHeight != -1 && !mIsButtonForceVisible) { + if (insetsHeight != -1 && !mEdgeBackGestureHandler.isButtonForcedVisible()) { navBarProvider = new InsetsFrameProvider( ITYPE_NAVIGATION_BAR, Insets.of(0, 0, 0, insetsHeight)); // Use window frame for IME. diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java index f3d60145a0578..ebb3a3a75c4e9 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java @@ -176,7 +176,7 @@ public class EdgeBackGestureHandler implements PluginListener mButtonForceVisibleCallback; + private Consumer mButtonForcedVisibleCallback; private final PluginManager mPluginManager; private final ProtoTracer mProtoTracer; @@ -243,7 +243,7 @@ public class EdgeBackGestureHandler implements PluginListener callback) { - mButtonForceVisibleCallback = callback; + public void setButtonForcedVisibleChangeCallback(Consumer callback) { + mButtonForcedVisibleCallback = callback; } public int getEdgeWidthLeft() { @@ -426,13 +426,14 @@ public class EdgeBackGestureHandler implements PluginListener