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

Commit 8f83165c authored by Orhan Uysal's avatar Orhan Uysal
Browse files

Treat freeform and fullscreen tasks as compatible.

In some scenarios where shell changes the windowing mode of fullscreen
launch to freeform, the activity would be launched on a seperate task
instead of the existing freeform task in recents.

This cl makes it so that we treat freeform and fullscreen as same.

Fix: 368515903
Test: atest RecentTasksTest
Flag: EXEMPT Bugfix
Change-Id: I168fe64a0574eede709d928b6b855eb81ec31ae3
parent caa2c9be
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ 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.ACTIVITY_TYPE_UNDEFINED;
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;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
@@ -2040,10 +2042,15 @@ class RecentTasks {
        final boolean isOtherUndefinedMode = otherWindowingMode == WINDOWING_MODE_UNDEFINED;

        // An activity type and windowing mode is compatible if they are the exact same type/mode,
        // or if one of the type/modes is undefined
        // or if one of the type/modes is undefined. This is with the exception of
        // freeform/fullscreen where both modes are assumed to be compatible with each other.
        final boolean isCompatibleType = activityType == otherActivityType
                || isUndefinedType || isOtherUndefinedType;
        final boolean isCompatibleMode = windowingMode == otherWindowingMode
                || (windowingMode == WINDOWING_MODE_FREEFORM
                && otherWindowingMode == WINDOWING_MODE_FULLSCREEN)
                || (windowingMode == WINDOWING_MODE_FULLSCREEN
                && otherWindowingMode == WINDOWING_MODE_FREEFORM)
                || isUndefinedMode || isOtherUndefinedMode;

        return isCompatibleType && isCompatibleMode;
+23 −0
Original line number Diff line number Diff line
@@ -431,6 +431,29 @@ public class RecentTasksTest extends WindowTestsBase {
        assertThat(mCallbacksRecorder.mRemoved).contains(task1);
    }

    @Test
    public void testAddTaskCompatibleWindowingMode_withFreeformAndFullscreen_expectRemove() {
        Task task1 = createTaskBuilder(".Task1")
                .setFlags(FLAG_ACTIVITY_NEW_TASK)
                .build();
        doReturn(WINDOWING_MODE_FREEFORM).when(task1).getWindowingMode();
        mRecentTasks.add(task1);
        mCallbacksRecorder.clear();

        Task task2 = createTaskBuilder(".Task1")
                .setWindowingMode(WINDOWING_MODE_FULLSCREEN)
                .setFlags(FLAG_ACTIVITY_NEW_TASK)
                .build();
        assertEquals(WINDOWING_MODE_FULLSCREEN, task2.getWindowingMode());
        mRecentTasks.add(task2);

        assertThat(mCallbacksRecorder.mAdded).hasSize(1);
        assertThat(mCallbacksRecorder.mAdded).contains(task2);
        assertThat(mCallbacksRecorder.mTrimmed).isEmpty();
        assertThat(mCallbacksRecorder.mRemoved).hasSize(1);
        assertThat(mCallbacksRecorder.mRemoved).contains(task1);
    }

    @Test
    public void testAddTaskIncompatibleWindowingMode_expectNoRemove() {
        Task task1 = createTaskBuilder(".Task1")