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

Commit 023fe00b authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "Workaround missing display leashes" into main

parents ec742a7b 1357e7a8
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.wm.shell.sysui.ShellInit;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.Executor;

/** Display area organizer for the root/default TaskDisplayAreas */
@@ -125,10 +126,17 @@ public class RootTaskDisplayAreaOrganizer extends DisplayAreaOrganizer {

    /**
     * Sets the layer of {@param sc} to be relative to the TDA on {@param displayId}.
     *
     * @throws NoSuchElementException if {@param displayId} has not appeared or has been removed.
     */
    public void relZToDisplayArea(int displayId, SurfaceControl sc, SurfaceControl.Transaction t,
            int z) {
        t.setRelativeLayer(sc, mLeashes.get(displayId), z);
        final SurfaceControl dsc = mLeashes.get(displayId);
        if (dsc != null) {
            t.setRelativeLayer(sc, dsc, z);
        } else {
            throw new NoSuchElementException("Display " + displayId + " is not registered");
        }
    }

    /**
+14 −5
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ import com.android.wm.shell.shared.animation.Interpolators;
import com.android.wm.shell.sysui.ShellInit;

import java.util.ArrayList;
import java.util.NoSuchElementException;

/** The default handler that handles anything not already handled. */
public class DefaultTransitionHandler implements Transitions.TransitionHandler {
@@ -693,6 +694,12 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        final Color bgColor = Color.valueOf(color);
        final float[] colorArray = new float[] { bgColor.red(), bgColor.green(), bgColor.blue() };

        boolean isSplitTaskInvolved = false;
        for (var change : info.getChanges()) {
            isSplitTaskInvolved |= (change.getTaskInfo() != null
                    && change.getTaskInfo().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW);
        }

        for (int i = 0; i < info.getRootCount(); ++i) {
            final int displayId = info.getRoot(i).getDisplayId();
            final SurfaceControl backgroundSurface = new SurfaceControl.Builder()
@@ -709,12 +716,14 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
            // Attaching the background surface to the transition root could unexpectedly make it
            // cover one of the split root tasks. To avoid this, put the background surface just
            // above the display area when split is on.
            final boolean isSplitTaskInvolved =
                    info.getChanges().stream().anyMatch(c-> c.getTaskInfo() != null
                            && c.getTaskInfo().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW);
            if (isSplitTaskInvolved) {
                mRootTDAOrganizer.relZToDisplayArea(displayId, backgroundSurface, startTransaction,
                        -1);
                try {
                    mRootTDAOrganizer.relZToDisplayArea(
                            displayId, backgroundSurface, startTransaction, -1);
                } catch (NoSuchElementException e) {
                    ProtoLog.wtf(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
                            "Unable to add background because display %d does not exist",displayId);
                }
            }

            finishTransaction.remove(backgroundSurface);