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

Commit e984551f authored by Ben Lin's avatar Ben Lin
Browse files

SplitScrn: Check for all children visibility when updating mVisible.

Currently, mVisible is updated based on the latest #onTaskInfoChange's
task update. However there is no guarantee that this comes "in order";
for example if the Stage task gets a separate task on top that's covering
it, it's possible the new top task comes in first, and then the old,
now not-visible task update comes next. The root is actually still
visible, but because of this order, mVisible is now false.

This CL changes it so that when we get a new task update, we check
against all children tasks' visibility to get a final value for
visibility of the root/stage.

Bug: 358065655
Test: Open Gmail and Settings side by side, and start a Compose Mail
action (generates new task) for Gmail. Drag Desktop handle - no longer
crashes.
Flag: EXEMPT bugfix

Change-Id: I44279fbc6bcda75168127e2b85c5b0c7b3918983
parent 64078439
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -245,9 +245,9 @@ public class StageTaskListener implements ShellTaskOrganizer.TaskListener {
                return;
            }
            mChildrenTaskInfo.put(taskInfo.taskId, taskInfo);
            mVisible = taskInfo.isVisible && taskInfo.isVisibleRequested;
            mVisible = isStageVisible();
            mCallbacks.onChildTaskStatusChanged(this, taskInfo.taskId, true /* present */,
                    mVisible);
                    taskInfo.isVisible && taskInfo.isVisibleRequested);
        } else {
            throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
                    + "\n mRootTaskInfo: " + mRootTaskInfo);
@@ -293,6 +293,19 @@ public class StageTaskListener implements ShellTaskOrganizer.TaskListener {
        t.reparent(sc, findTaskSurface(taskId));
    }

    /**
     * Checks against all children task info and return true if any are marked as visible.
     */
    private boolean isStageVisible() {
        for (int i = mChildrenTaskInfo.size() - 1; i >= 0; --i) {
            if (mChildrenTaskInfo.valueAt(i).isVisible
                    && mChildrenTaskInfo.valueAt(i).isVisibleRequested) {
                return true;
            }
        }
        return false;
    }

    private SurfaceControl findTaskSurface(int taskId) {
        if (mRootTaskInfo.taskId == taskId) {
            return mRootLeash;