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

Commit 2bed621c authored by Robert Carr's avatar Robert Carr Committed by Rob Carr
Browse files

WindowContainerTransaction: Support PIP Transition

We support the PIP transition by adding setChildWindowingMode
and setWindowingMode primitives. This allows the organizer to
replicate the old behavior during the enter pip animation of
switching the Task to PIP but having the activity continue to
render it's full-screen UI, or the opposite on the other
transition. This is a temporary solution to handle
the boundaries between Fullscreen and PIP states and the trade-off
between TaskOrg and WindowManager. Once TaskOrganizer controls
all windowing modes it won't be needed.

Bug: 149947030
Test: TaskOrganizerTests
Change-Id: I7eeb1b5fb8c5d00a00b6de976f61484f1d067048
parent d2d3e4d9
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -130,6 +130,31 @@ public class WindowContainerTransaction implements Parcelable {
        return this;
    }

    /**
     * Set the windowing mode of children of a given root task, without changing
     * the windowing mode of the Task itself. This can be used during transitions
     * for example to make the activity render it's fullscreen configuration
     * while the Task is still in PIP, so you can complete the animation.
     *
     * TODO(b/134365562): Can be removed once TaskOrg drives full-screen
     */
    public WindowContainerTransaction setActivityWindowingMode(IWindowContainer container,
            int windowingMode) {
        Change chg = getOrCreateChange(container.asBinder());
        chg.mActivityWindowingMode = windowingMode;
        return this;
    }

    /**
     * Sets the windowing mode of the given container.
     */
    public WindowContainerTransaction setWindowingMode(IWindowContainer container,
            int windowingMode) {
        Change chg = getOrCreateChange(container.asBinder());
        chg.mWindowingMode = windowingMode;
        return this;
    }

    /**
     * Sets whether a container or any of its children can be focusable. When {@code false}, no
     * child can be focused; however, when {@code true}, it is still possible for children to be
@@ -235,6 +260,9 @@ public class WindowContainerTransaction implements Parcelable {
        private Rect mPinnedBounds = null;
        private SurfaceControl.Transaction mBoundsChangeTransaction = null;

        private int mActivityWindowingMode = -1;
        private int mWindowingMode = -1;

        public Change() {}

        protected Change(Parcel in) {
@@ -251,6 +279,17 @@ public class WindowContainerTransaction implements Parcelable {
                mBoundsChangeTransaction =
                    SurfaceControl.Transaction.CREATOR.createFromParcel(in);
            }

            mWindowingMode = in.readInt();
            mActivityWindowingMode = in.readInt();
        }

        public int getWindowingMode() {
            return mWindowingMode;
        }

        public int getActivityWindowingMode() {
            return mActivityWindowingMode;
        }

        public Configuration getConfiguration() {
@@ -340,6 +379,9 @@ public class WindowContainerTransaction implements Parcelable {
            if (mBoundsChangeTransaction != null) {
                mBoundsChangeTransaction.writeToParcel(dest, flags);
            }

            dest.writeInt(mWindowingMode);
            dest.writeInt(mActivityWindowingMode);
        }

        @Override
+8 −0
Original line number Diff line number Diff line
@@ -4123,8 +4123,16 @@ class Task extends WindowContainer<WindowContainer> {
        return mMainWindowSizeChangeTransaction;
    }

    void setActivityWindowingMode(int windowingMode) {
        PooledConsumer c = PooledLambda.obtainConsumer(ActivityRecord::setWindowingMode,
            PooledLambda.__(ActivityRecord.class), windowingMode);
        forAllActivities(c);
        c.recycle();
    }

    @Override
    long getProtoFieldId() {
        return TASK;
    }

}
+12 −2
Original line number Diff line number Diff line
@@ -553,18 +553,28 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub
            WindowContainerTransaction.Change c) {
        int effects = sanitizeAndApplyChange(wc, c);

        final Task tr = wc.asTask();

        final SurfaceControl.Transaction t = c.getBoundsChangeTransaction();
        if (t != null) {
            Task tr = (Task) wc;
            tr.setMainWindowSizeChangeTransaction(t);
        }

        Rect enterPipBounds = c.getEnterPipBounds();
        if (enterPipBounds != null) {
            Task tr = (Task) wc;
            mService.mStackSupervisor.updatePictureInPictureMode(tr,
                    enterPipBounds, true);
        }

        final int windowingMode = c.getWindowingMode();
        if (windowingMode > -1) {
            tr.setWindowingMode(windowingMode);
        }
        final int childWindowingMode = c.getActivityWindowingMode();
        if (childWindowingMode > -1) {
            tr.setActivityWindowingMode(childWindowingMode);
        }

        return effects;
    }

+26 −0
Original line number Diff line number Diff line
@@ -240,6 +240,32 @@ public class TaskOrganizerTests extends WindowTestsBase {
        assertEquals(newBounds, stack.getBounds());
    }

    @Test
    public void testSetWindowingMode() {
        final ActivityStack stack = new ActivityTestsBase.StackBuilder(mWm.mRoot)
            .setWindowingMode(WINDOWING_MODE_FREEFORM).build();
        final WindowContainerTransaction t = new WindowContainerTransaction();

        t.setWindowingMode(stack.mRemoteToken, WINDOWING_MODE_FULLSCREEN);
        mWm.mAtmService.mTaskOrganizerController.applyContainerTransaction(t, null);

        assertEquals(WINDOWING_MODE_FULLSCREEN, stack.getWindowingMode());
    }

    @Test
    public void testSetActivityWindowingMode() {
        final ActivityRecord record = makePipableActivity();
        final ActivityStack stack = record.getStack();
        final WindowContainerTransaction t = new WindowContainerTransaction();

        t.setWindowingMode(stack.mRemoteToken, WINDOWING_MODE_PINNED);
        t.setActivityWindowingMode(stack.mRemoteToken, WINDOWING_MODE_FULLSCREEN);
        mWm.mAtmService.mTaskOrganizerController.applyContainerTransaction(t, null);

        assertEquals(WINDOWING_MODE_FULLSCREEN, record.getWindowingMode());
        assertEquals(WINDOWING_MODE_PINNED, stack.getWindowingMode());
    }

    @Test
    public void testContainerChanges() {
        removeGlobalMinSizeRestriction();