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

Commit 124ab11a authored by Jeremy Sim's avatar Jeremy Sim
Browse files

Fix flex split layout on landscape phones

Improves the calculation for apps that are extending offscreen.

Previously, offscreen bounds were calculated in a way that presumed symmetry (both left and right app having the same size in 50:50 split). But on phones in landscape orientation, we use a non-symmetric layout due to the camera cutout -- so the left app is actually larger in 50:50. This caused a bug.

Fixed in this CL by changing the way surface bounds are calculated.

Bug: 401396438
Flag: com.android.wm.shell.enable_flexible_two_app_split
Test: No longer fails test activityEmbeddingSplitSurfaceAreEven. Manually verified with smoke test and common flex split flows.
Change-Id: I1edbc2b052ab8f3dc770dcf789cc50536cc0a1d9
parent c3e2c0d0
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -559,7 +559,12 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                true /* setEffectBounds */);
    }

    /** Updates recording bounds of divider window and both of the splits. */
    /**
     * Updates the bounds of the divider window and both split apps.
     * @param position The left/top edge of the visual divider, where the edge of app A meets the
     *                 divider. Not to be confused with the actual divider surface, which is larger
     *                 and overlaps the apps a bit.
     */
    private void updateBounds(int position, Rect bounds1, Rect bounds2, Rect dividerBounds,
            boolean setEffectBounds) {
        dividerBounds.set(mRootBounds);
@@ -574,10 +579,11 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange

            // For flexible split, expand app offscreen as well
            if (mDividerSnapAlgorithm.areOffscreenRatiosSupported()) {
                if (position <= mDividerSnapAlgorithm.getMiddleTarget().position) {
                    bounds1.left = bounds1.right - bounds2.width();
                int distanceToCenter = position - mDividerSnapAlgorithm.getMiddleTarget().position;
                if (position < mDividerSnapAlgorithm.getMiddleTarget().position) {
                    bounds1.left += distanceToCenter * 2;
                } else {
                    bounds2.right = bounds2.left + bounds1.width();
                    bounds2.right += distanceToCenter * 2;
                }
            }

@@ -590,10 +596,11 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange

            // For flexible split, expand app offscreen as well
            if (mDividerSnapAlgorithm.areOffscreenRatiosSupported()) {
                if (position <= mDividerSnapAlgorithm.getMiddleTarget().position) {
                    bounds1.top = bounds1.bottom - bounds2.height();
                int distanceToCenter = position - mDividerSnapAlgorithm.getMiddleTarget().position;
                if (position < mDividerSnapAlgorithm.getMiddleTarget().position) {
                    bounds1.top += distanceToCenter * 2;
                } else {
                    bounds2.bottom = bounds2.top + bounds1.height();
                    bounds2.bottom += distanceToCenter * 2;
                }
            }
        }