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

Commit 87ed2f11 authored by Jerry Chang's avatar Jerry Chang
Browse files

Fix not tracking splitting tasks correctly

When drag-to-repace one of the splitting tasks, it might reports to
TopTaskTracker the original task changed to undefined after repoting the
new task appeared in a split pair. Result to clear the split tasks
record unexpectedly in TopTaskTracker. This makes sure to clear the
correct stage and prevent override the correct split record.

Fix: 277982233
Test: manual check the behavior and verify the reocrd in TopTaskTracker
Change-Id: Ifce2efdde6d99508f1afa844b3ad424071e13a8f
parent 606c4bfc
Loading
Loading
Loading
Loading
+4 −15
Original line number Diff line number Diff line
@@ -127,23 +127,16 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta

    @Override
    public void onTaskStageChanged(int taskId, @StageType int stage, boolean visible) {
        // If task is not visible but we are tracking it, stop tracking it
        if (!visible) {
        // If a task is not visible anymore or has been moved to undefined, stop tracking it.
        if (!visible || stage == SplitConfigurationOptions.STAGE_TYPE_UNDEFINED) {
            if (mMainStagePosition.taskId == taskId) {
                resetTaskId(mMainStagePosition);
                mMainStagePosition.taskId = INVALID_TASK_ID;
            } else if (mSideStagePosition.taskId == taskId) {
                resetTaskId(mSideStagePosition);
                mSideStagePosition.taskId = INVALID_TASK_ID;
            } // else it's an un-tracked child
            return;
        }

        // If stage has moved to undefined, stop tracking the task
        if (stage == SplitConfigurationOptions.STAGE_TYPE_UNDEFINED) {
            resetTaskId(taskId == mMainStagePosition.taskId
                    ? mMainStagePosition : mSideStagePosition);
            return;
        }

        if (stage == SplitConfigurationOptions.STAGE_TYPE_MAIN) {
            mMainStagePosition.taskId = taskId;
        } else {
@@ -161,10 +154,6 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta
        mPinnedTaskId = INVALID_TASK_ID;
    }

    private void resetTaskId(SplitStageInfo taskPosition) {
        taskPosition.taskId = -1;
    }

    /**
     * @return index 0 will be task in left/top position, index 1 in right/bottom position.
     *         Will return empty array if device is not in staged split