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

Commit a804e49b authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Notify ITaskStackListener#onTaskMovedToFront when root task moves" into main

parents f2e7e93f 51969ae4
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -1285,8 +1285,8 @@ class Task extends TaskFragment {
        EventLogTags.writeWmTaskMoved(mTaskId, getRootTaskId(), getDisplayId(), toTop ? 1 : 0,
                position);
        final TaskDisplayArea taskDisplayArea = getDisplayArea();
        if (taskDisplayArea != null && isLeafTask()) {
            taskDisplayArea.onLeafTaskMoved(this, toTop, toBottom);
        if (taskDisplayArea != null) {
            taskDisplayArea.onTaskMoved(this, toTop, toBottom);
        }
        if (isPersistable) {
            mLastTimeMoved = System.currentTimeMillis();
@@ -6141,9 +6141,7 @@ class Task extends TaskFragment {

        if (canBeLaunchedOnDisplay(newParent.getDisplayId())) {
            reparent(newParent, onTop ? POSITION_TOP : POSITION_BOTTOM);
            if (isLeafTask()) {
                newParent.onLeafTaskMoved(this, onTop, !onTop);
            }
            newParent.onTaskMoved(this, onTop, !onTop);
        } else {
            Slog.w(TAG, "Task=" + this + " can't reparent to " + newParent);
        }
+14 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ROOT_TASK;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

import android.annotation.ColorInt;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.WindowConfiguration;
@@ -435,7 +436,19 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
        }
    }

    void onLeafTaskMoved(Task t, boolean toTop, boolean toBottom) {
    void onTaskMoved(@NonNull Task t, boolean toTop, boolean toBottom) {
        if (toBottom && !t.isLeafTask()) {
            // Return early when a non-leaf task moved to bottom, to prevent sending duplicated
            // leaf task movement callback if the leaf task is moved along with its parent tasks.
            // Unless, we also track the task id, like `mLastLeafTaskToFrontId`.
            return;
        }

        final Task topLeafTask = t.getTopLeafTask();
        onLeafTaskMoved(topLeafTask, toTop, toBottom);
    }

    void onLeafTaskMoved(@NonNull Task t, boolean toTop, boolean toBottom) {
        if (toBottom) {
            mAtmService.getTaskChangeNotificationController().notifyTaskMovedToBack(
                    t.getTaskInfo());
+14 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.window.DisplayAreaOrganizer.FEATURE_VENDOR_FIRST;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.server.wm.ActivityRecord.State.RESUMED;
@@ -50,6 +51,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

@@ -839,4 +841,16 @@ public class TaskDisplayAreaTests extends WindowTestsBase {
                0 /* launchFlags */, pinnedTask /* candidateTask */);
        assertNull(actualRootTask);
    }

    @Test
    public void testMovedRootTaskToFront() {
        final TaskDisplayArea tda = mDefaultDisplay.getDefaultTaskDisplayArea();
        final Task rootTask = createTask(tda, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD,
                true /* onTop */, true /* createActivity */, true /* twoLevelTask */);
        final Task leafTask = rootTask.getTopLeafTask();

        clearInvocations(tda);
        tda.onTaskMoved(rootTask, true /* toTop */, false /* toBottom */);
        verify(tda).onLeafTaskMoved(eq(leafTask), anyBoolean(), anyBoolean());
    }
}