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

Commit 1651900f authored by Fengjiang Li's avatar Fengjiang Li Committed by Android (Google) Code Review
Browse files

Merge "[-1] Fix bug where connecting to external display prevents user from...

Merge "[-1] Fix bug where connecting to external display prevents user from swiping out of -1." into main
parents b74d1d59 746841c3
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.Display.DEFAULT_DISPLAY;

import static com.android.wm.shell.compatui.impl.CompatUIEventsKt.SIZE_COMPAT_RESTART_BUTTON_APPEARED;
import static com.android.wm.shell.compatui.impl.CompatUIEventsKt.SIZE_COMPAT_RESTART_BUTTON_CLICKED;
@@ -573,7 +574,7 @@ public class ShellTaskOrganizer extends TaskOrganizer {
            mUnfoldAnimationController.onTaskAppeared(info.getTaskInfo(), info.getLeash());
        }

        if (info.getTaskInfo().getActivityType() == ACTIVITY_TYPE_HOME) {
        if (isHomeTaskOnDefaultDisplay(info.getTaskInfo())) {
            ProtoLog.v(WM_SHELL_TASK_ORG, "Adding overlay to home task");
            final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
            t.setLayer(mHomeTaskOverlayContainer, Integer.MAX_VALUE);
@@ -675,7 +676,7 @@ public class ShellTaskOrganizer extends TaskOrganizer {
            notifyCompatUI(taskInfo, null /* taskListener */);
            // Notify the recent tasks that a task has been removed
            mRecentTasks.ifPresent(recentTasks -> recentTasks.onTaskRemoved(taskInfo));
            if (taskInfo.getActivityType() == ACTIVITY_TYPE_HOME) {
            if (isHomeTaskOnDefaultDisplay(taskInfo)) {
                SurfaceControl.Transaction t = new SurfaceControl.Transaction();
                t.reparent(mHomeTaskOverlayContainer, null);
                t.apply();
@@ -937,6 +938,17 @@ public class ShellTaskOrganizer extends TaskOrganizer {
        }
    }

    /**
     * Return true if {@link RunningTaskInfo} is Home/Launcher activity type, plus it's the one on
     * default display (rather than on external display). This is used to check if we need to
     * reparent mHomeTaskOverlayContainer that is used for -1 screen on default display.
     */
    @VisibleForTesting
    static boolean isHomeTaskOnDefaultDisplay(RunningTaskInfo taskInfo) {
        return taskInfo.getActivityType() == ACTIVITY_TYPE_HOME
                && taskInfo.displayId == DEFAULT_DISPLAY;
    }

    public void dump(@NonNull PrintWriter pw, String prefix) {
        synchronized (mLock) {
            final String innerPrefix = prefix + "  ";
+44 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.wm.shell;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
@@ -27,6 +30,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy;
import static com.android.wm.shell.ShellTaskOrganizer.TASK_LISTENER_TYPE_FULLSCREEN;
import static com.android.wm.shell.ShellTaskOrganizer.TASK_LISTENER_TYPE_MULTI_WINDOW;
import static com.android.wm.shell.ShellTaskOrganizer.TASK_LISTENER_TYPE_PIP;
import static com.android.wm.shell.ShellTaskOrganizer.isHomeTaskOnDefaultDisplay;
import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS;

import static org.junit.Assert.assertEquals;
@@ -667,6 +671,38 @@ public class ShellTaskOrganizerTests extends ShellTestCase {
        assertEquals(vanishedTasks[0], task1);
    }

    @Test
    public void testHomeTaskOnDefaultDisplay() {
        RunningTaskInfo taskInfo = createTaskInfo(
                /* taskId= */ 1, ACTIVITY_TYPE_HOME, DEFAULT_DISPLAY);

        assertTrue(isHomeTaskOnDefaultDisplay(taskInfo));
    }

    @Test
    public void testNonHomeTaskOnDefaultDisplay() {
        RunningTaskInfo taskInfo = createTaskInfo(
                /* taskId= */ 1, ACTIVITY_TYPE_DREAM, DEFAULT_DISPLAY);

        assertFalse(isHomeTaskOnDefaultDisplay(taskInfo));
    }

    @Test
    public void testHomeTaskOnExternalDisplay() {
        RunningTaskInfo taskInfo = createTaskInfo(
                /* taskId= */ 1, ACTIVITY_TYPE_HOME, /* displayId= */ 2);

        assertFalse(isHomeTaskOnDefaultDisplay(taskInfo));
    }

    @Test
    public void testRecentTaskOnExternalDisplay() {
        RunningTaskInfo taskInfo = createTaskInfo(
                /* taskId= */ 1, ACTIVITY_TYPE_RECENTS, /* displayId= */ 3);

        assertFalse(isHomeTaskOnDefaultDisplay(taskInfo));
    }

    private static RunningTaskInfo createTaskInfo(int taskId, int windowingMode) {
        RunningTaskInfo taskInfo = new RunningTaskInfo();
        taskInfo.taskId = taskId;
@@ -675,6 +711,14 @@ public class ShellTaskOrganizerTests extends ShellTestCase {
        return taskInfo;
    }

    private static RunningTaskInfo createTaskInfo(int taskId, int activityType, int displayId) {
        RunningTaskInfo taskInfo = new RunningTaskInfo();
        taskInfo.taskId = taskId;
        taskInfo.configuration.windowConfiguration.setActivityType(activityType);
        taskInfo.displayId = displayId;
        return taskInfo;
    }

    private static RunningTaskInfo createFreeformTaskInfo(int taskId) {
        RunningTaskInfo taskInfo = createTaskInfo(taskId, WINDOWING_MODE_FREEFORM);
        taskInfo.positionInParent = new Point(100, 100);