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

Commit b6a5bf31 authored by Chris Li's avatar Chris Li
Browse files

Transfer PipContentOverlay when swipe to home with Shell transition

Swipe to home animation is played by launcher, but the entering PIP
transition will finished by PipTransition. As a result, we need to
reparent the overlay and fade out the overlay in PipTransition when
enter PIP is finalized, otherwise the overlay will be removed with the
remote transition leash and cause flicker.

Bug: 222030101
Test: verify with swipe to home with Shell transition
Change-Id: Idde3414e3cc5e8193cf7d4da9818e59dc6b4b1c5
parent d985a179
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -103,11 +103,17 @@ public class ShellTaskOrganizer extends TaskOrganizer implements
            // All TaskListeners should support compat UI except PIP.
            return true;
        }
        /** Attaches the a child window surface to the task surface. */
        /** Attaches a child window surface to the task surface. */
        default void attachChildSurfaceToTask(int taskId, SurfaceControl.Builder b) {
            throw new IllegalStateException(
                    "This task listener doesn't support child surface attachment.");
        }
        /** Reparents a child window surface to the task surface. */
        default void reparentChildSurfaceToTask(int taskId, SurfaceControl sc,
                SurfaceControl.Transaction t) {
            throw new IllegalStateException(
                    "This task listener doesn't support child surface reparent.");
        }
        default void dump(@NonNull PrintWriter pw, String prefix) {};
    }

@@ -620,6 +626,23 @@ public class ShellTaskOrganizer extends TaskOrganizer implements
        updateCameraCompatControlState(info.getTaskInfo().token, state);
    }

    /** Reparents a child window surface to the task surface. */
    public void reparentChildSurfaceToTask(int taskId, SurfaceControl sc,
            SurfaceControl.Transaction t) {
        final TaskListener taskListener;
        synchronized (mLock) {
            taskListener = mTasks.contains(taskId)
                    ? getTaskListener(mTasks.get(taskId).getTaskInfo())
                    : null;
        }
        if (taskListener == null) {
            ProtoLog.w(WM_SHELL_TASK_ORG, "Failed to find Task to reparent surface taskId=%d",
                    taskId);
            return;
        }
        taskListener.reparentChildSurfaceToTask(taskId, sc, t);
    }

    private void logSizeCompatRestartButtonEventReported(@NonNull TaskAppearedInfo info,
            int event) {
        ActivityInfo topActivityInfo = info.getTaskInfo().topActivityInfo;
+12 −2
Original line number Diff line number Diff line
@@ -367,10 +367,20 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,

    @Override
    public void attachChildSurfaceToTask(int taskId, SurfaceControl.Builder b) {
        if (mTaskInfo.taskId != taskId) {
        b.setParent(findTaskSurface(taskId));
    }

    @Override
    public void reparentChildSurfaceToTask(int taskId, SurfaceControl sc,
            SurfaceControl.Transaction t) {
        t.reparent(sc, findTaskSurface(taskId));
    }

    private SurfaceControl findTaskSurface(int taskId) {
        if (mTaskInfo == null || mTaskLeash == null || mTaskInfo.taskId != taskId) {
            throw new IllegalArgumentException("There is no surface for taskId=" + taskId);
        }
        b.setParent(mTaskLeash);
        return mTaskLeash;
    }

    @Override
+13 −3
Original line number Diff line number Diff line
@@ -275,12 +275,22 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou

    @Override
    public void attachChildSurfaceToTask(int taskId, SurfaceControl.Builder b) {
        b.setParent(findTaskSurface(taskId));
    }

    @Override
    public void reparentChildSurfaceToTask(int taskId, SurfaceControl sc,
            SurfaceControl.Transaction t) {
        t.reparent(sc, findTaskSurface(taskId));
    }

    private SurfaceControl findTaskSurface(int taskId) {
        if (getRootTaskId() == taskId) {
            b.setParent(mRootTaskLeash);
            return mRootTaskLeash;
        } else if (getTaskId1() == taskId) {
            b.setParent(mTaskLeash1);
            return mTaskLeash1;
        } else if (getTaskId2() == taskId) {
            b.setParent(mTaskLeash2);
            return mTaskLeash2;
        } else {
            throw new IllegalArgumentException("There is no surface for taskId=" + taskId);
        }
+18 −0
Original line number Diff line number Diff line
@@ -109,6 +109,24 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener {
        });
    }

    @Override
    public void attachChildSurfaceToTask(int taskId, SurfaceControl.Builder b) {
        b.setParent(findTaskSurface(taskId));
    }

    @Override
    public void reparentChildSurfaceToTask(int taskId, SurfaceControl sc,
            SurfaceControl.Transaction t) {
        t.reparent(sc, findTaskSurface(taskId));
    }

    private SurfaceControl findTaskSurface(int taskId) {
        if (!mTasks.contains(taskId)) {
            throw new IllegalArgumentException("There is no surface for taskId=" + taskId);
        }
        return mTasks.get(taskId).mLeash;
    }

    @Override
    public void dump(PrintWriter pw, String prefix) {
        final String innerPrefix = prefix + "  ";
+11 −1
Original line number Diff line number Diff line
@@ -133,10 +133,20 @@ public class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener {

    @Override
    public void attachChildSurfaceToTask(int taskId, SurfaceControl.Builder b) {
        b.setParent(findTaskSurface(taskId));
    }

    @Override
    public void reparentChildSurfaceToTask(int taskId, SurfaceControl sc,
            SurfaceControl.Transaction t) {
        t.reparent(sc, findTaskSurface(taskId));
    }

    private SurfaceControl findTaskSurface(int taskId) {
        if (!mDataByTaskId.contains(taskId)) {
            throw new IllegalArgumentException("There is no surface for taskId=" + taskId);
        }
        b.setParent(mDataByTaskId.get(taskId).surface);
        return mDataByTaskId.get(taskId).surface;
    }

    @Override
Loading