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

Commit 2a08adc5 authored by Simon (Qiong) Sun's avatar Simon (Qiong) Sun
Browse files

Remove redundant rotation in mSplitLayout

The mSplitLayout's `rotateTo` method was being called unnecessarily with `updateConfiguration`. The bounds retrieved from `configuration.windowConfiguration.getBounds()` already account for the new rotation, so a separate rotation call in `mSplitLayout` is not needed. This change prevents potential bugs related to double rotation.

Bug: 438459499
Flag: EXEMPT bug fix
Test: 1. Unfold device and split 2 apps at a 30:70 ratio. 2. Rotate to landscape mode. 3. Rotate the device, then unfold when the rotation to portrait mode is complete. 4. Repeat this process multiple times.
Change-Id: I2e6f9e6fba90d689ced63da26b9b2b88761a4814
parent b7138e53
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.bubbles.BubbleController;
import com.android.wm.shell.common.ComponentUtils;
import com.android.wm.shell.common.DisplayChangeController;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.common.DisplayInsetsController;
@@ -206,7 +207,8 @@ import java.util.function.Predicate;
 * - Both stages are put under a single-top root task.
 */
public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        DisplayController.OnDisplaysChangedListener, Transitions.TransitionHandler,
        DisplayController.OnDisplaysChangedListener,
        DisplayChangeController.OnDisplayChangingListener, Transitions.TransitionHandler,
        ShellTaskOrganizer.TaskListener, StageTaskListener.StageListenerCallbacks,
        SplitMultiDisplayProvider {

@@ -521,6 +523,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        mSplitTransitions = new SplitScreenTransitions(transactionPool, transitions,
                this::onTransitionAnimationComplete, this);
        mDisplayController.addDisplayWindowListener(this);
        mDisplayController.addDisplayChangingController(this);
        transitions.addHandler(this);
        mSplitUnsupportedToast = Toast.makeText(mContext,
                R.string.dock_non_resizeble_failed_to_dock_text, Toast.LENGTH_SHORT);
@@ -3034,14 +3037,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        mTaskOrganizer.applyTransaction(wct);
    }

    public void onDisplayAdded(int displayId) {
        if (displayId != DEFAULT_DISPLAY) {
            return;
        }
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onDisplayAdded: display=%d", displayId);
        mDisplayController.addDisplayChangingController(this::onDisplayChange);
    }

    /**
     * Update surfaces of the split screen layout based on the current state
     * @param transaction to write the updates to
@@ -3051,7 +3046,15 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        mSplitLayout.update(transaction, true /* resetImePosition */);
    }

    private void onDisplayChange(int displayId, int fromRotation, int toRotation,
    /**
     *
     * @param displayId display id of the display that is under the change
     * @param fromRotation rotation before the change
     * @param toRotation rotation after the change
     * @param newDisplayAreaInfo display area info after applying the update
     * @param wct A task transaction to populate.
     */
    public void onDisplayChange(int displayId, int fromRotation, int toRotation,
            @Nullable DisplayAreaInfo newDisplayAreaInfo, WindowContainerTransaction wct) {
        if (displayId != DEFAULT_DISPLAY || !isSplitActive()) {
            return;
@@ -3061,9 +3064,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                "onDisplayChange: display=%d fromRot=%d toRot=%d config=%s",
                displayId, fromRotation, toRotation,
                newDisplayAreaInfo != null ? newDisplayAreaInfo.configuration : null);
        mSplitLayout.rotateTo(toRotation);
        if (newDisplayAreaInfo != null) {
            mSplitLayout.updateConfiguration(newDisplayAreaInfo.configuration);
        } else {
            mSplitLayout.rotateTo(toRotation);
        }
        updateWindowBounds(mSplitLayout, wct);
        sendOnBoundsChanged();