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

Commit 5ed00e9a authored by Jerry Chang's avatar Jerry Chang
Browse files

Update display layout when requesting display rotate

Make sure to update DisplayLayout when a display rotate transition
requested, so the transition handler can get an updated display layout
when handling the transition.

Fix: 286507067
Test: Observed display layout updated when requesting a display rotate,
      and the split divider won't be offseted.
Change-Id: Ia6a47f3e155511ea2033e05be2d0e7d6877999e0
parent 218a3807
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public class DisplayChangeController {
    }

    /** Query all listeners for changes that should happen on display change. */
    public void dispatchOnDisplayChange(WindowContainerTransaction outWct, int displayId,
    void dispatchOnDisplayChange(WindowContainerTransaction outWct, int displayId,
            int fromRotation, int toRotation, DisplayAreaInfo newDisplayAreaInfo) {
        for (OnDisplayChangingListener c : mDisplayChangeListener) {
            c.onDisplayChange(displayId, fromRotation, toRotation, newDisplayAreaInfo, outWct);
+21 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.view.Display;
import android.view.IDisplayWindowListener;
import android.view.IWindowManager;
import android.view.InsetsState;
import android.window.WindowContainerTransaction;

import androidx.annotation.BinderThread;

@@ -85,11 +86,6 @@ public class DisplayController {
        }
    }

    /** Get the DisplayChangeController. */
    public DisplayChangeController getChangeController() {
        return mChangeController;
    }

    /**
     * Gets a display by id from DisplayManager.
     */
@@ -195,6 +191,26 @@ public class DisplayController {
        }
    }


    /** Called when a display rotate requested. */
    public void onDisplayRotateRequested(WindowContainerTransaction wct, int displayId,
            int fromRotation, int toRotation) {
        synchronized (mDisplays) {
            final DisplayRecord dr = mDisplays.get(displayId);
            if (dr == null) {
                Slog.w(TAG, "Skipping Display rotate on non-added display.");
                return;
            }

            if (dr.mDisplayLayout != null) {
                dr.mDisplayLayout.rotateTo(dr.mContext.getResources(), toRotation);
            }

            mChangeController.dispatchOnDisplayChange(
                    wct, displayId, fromRotation, toRotation, null /* newDisplayAreaInfo */);
        }
    }

    private void onDisplayConfigurationChanged(int displayId, Configuration newConfig) {
        synchronized (mDisplays) {
            final DisplayRecord dr = mDisplays.get(displayId);
+2 −3
Original line number Diff line number Diff line
@@ -1086,9 +1086,8 @@ public class Transitions implements RemoteCallable<Transitions>,
                    if (wct == null) {
                        wct = new WindowContainerTransaction();
                    }
                    mDisplayController.getChangeController().dispatchOnDisplayChange(wct,
                            change.getDisplayId(), change.getStartRotation(),
                            change.getEndRotation(), null /* newDisplayAreaInfo */);
                    mDisplayController.onDisplayRotateRequested(wct, change.getDisplayId(),
                            change.getStartRotation(), change.getEndRotation());
                }
            }
        }