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
This commit is contained in:
Yunfan Chen
2023-03-02 15:17:39 +09:00
parent c949def472
commit 4ad1250bf5
2 changed files with 18 additions and 20 deletions

View File

@@ -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<NavigationBarView> 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<NavigationBarView> 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<NavigationBarView> 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.

View File

@@ -176,7 +176,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
private final OverviewProxyService mOverviewProxyService;
private final SysUiState mSysUiState;
private Runnable mStateChangeCallback;
private Consumer<Boolean> mButtonForceVisibleCallback;
private Consumer<Boolean> mButtonForcedVisibleCallback;
private final PluginManager mPluginManager;
private final ProtoTracer mProtoTracer;
@@ -243,7 +243,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
private boolean mGestureBlockingActivityRunning;
private boolean mIsNewBackAffordanceEnabled;
private boolean mIsTrackpadGestureBackEnabled;
private boolean mIsButtonForceVisible;
private boolean mIsButtonForcedVisible;
private InputMonitor mInputMonitor;
private InputChannelCompat.InputEventReceiver mInputEventReceiver;
@@ -410,8 +410,8 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
mStateChangeCallback = callback;
}
public void setButtonForceVisibleChangeCallback(Consumer<Boolean> callback) {
mButtonForceVisibleCallback = callback;
public void setButtonForcedVisibleChangeCallback(Consumer<Boolean> callback) {
mButtonForcedVisibleCallback = callback;
}
public int getEdgeWidthLeft() {
@@ -426,13 +426,14 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
Resources res = mNavigationModeController.getCurrentUserContext().getResources();
mEdgeWidthLeft = mGestureNavigationSettingsObserver.getLeftSensitivity(res);
mEdgeWidthRight = mGestureNavigationSettingsObserver.getRightSensitivity(res);
final boolean previousForceVisible = mIsButtonForceVisible;
mIsButtonForceVisible =
final boolean previousForcedVisible = mIsButtonForcedVisible;
mIsButtonForcedVisible =
mGestureNavigationSettingsObserver.areNavigationButtonForcedVisible();
if (previousForceVisible != mIsButtonForceVisible && mButtonForceVisibleCallback != null) {
mButtonForceVisibleCallback.accept(mIsButtonForceVisible);
if (previousForcedVisible != mIsButtonForcedVisible
&& mButtonForcedVisibleCallback != null) {
mButtonForcedVisibleCallback.accept(mIsButtonForcedVisible);
}
mIsBackGestureAllowed = !mIsButtonForceVisible;
mIsBackGestureAllowed = !mIsButtonForcedVisible;
final DisplayMetrics dm = res.getDisplayMetrics();
final float defaultGestureHeight = res.getDimension(
@@ -632,6 +633,10 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
return mIsEnabled && mIsBackGestureAllowed;
}
public boolean isButtonForcedVisible() {
return mIsButtonForcedVisible;
}
/**
* Update the PiP bounds, used for exclusion calculation.
*/