Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c895f7e4 authored by Candice's avatar Candice
Browse files

Fix the initialization of the system gesture top location

1. Initialize the system gesture top location in the constructor
2. Fix the calculation of system gesture top location when there is no
   botton inset

Bug: 380320995
Test: atest WindowMagnificationControllerTest
Test: atest WindowMagnificationAnimationControllerTest
Flag: com.android.systemui.update_window_magnifier_bottom_boundary
Change-Id: Ie6d97a6fe2be6b07ea9e1487f71d572f1d2fd397
parent 91989f88
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -296,6 +296,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
        mGestureDetector =
                new MagnificationGestureDetector(mContext, handler, this);
        mWindowInsetChangeRunnable = this::onWindowInsetChanged;
        mWindowInsetChangeRunnable.run();

        // Initialize listeners.
        mMirrorViewRunnable = new Runnable() {
@@ -367,8 +368,12 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
    private boolean updateSystemGestureInsetsTop() {
        final WindowMetrics windowMetrics = mWm.getCurrentWindowMetrics();
        final Insets insets = windowMetrics.getWindowInsets().getInsets(systemGestures());
        final int gestureTop =
                insets.bottom != 0 ? windowMetrics.getBounds().bottom - insets.bottom : -1;
        final int gestureTop;
        if (Flags.updateWindowMagnifierBottomBoundary()) {
            gestureTop = windowMetrics.getBounds().bottom - insets.bottom;
        } else {
            gestureTop = insets.bottom != 0 ? windowMetrics.getBounds().bottom - insets.bottom : -1;
        }
        if (gestureTop != mSystemGestureTop) {
            mSystemGestureTop = gestureTop;
            return true;
@@ -953,7 +958,6 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
                ? mSystemGestureTop - height + mOuterBorderSize
                : mWindowBounds.bottom - height + mOuterBorderSize;
        final int y = MathUtils.clamp(mMagnificationFrame.top - mMirrorSurfaceMargin, minY, maxY);

        if (computeWindowSize) {
            LayoutParams params = (LayoutParams) mMirrorView.getLayoutParams();
            params.width = width;