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

Commit b70b45b9 authored by Orhan Uysal's avatar Orhan Uysal Committed by Android (Google) Code Review
Browse files

Merge "Treat freeform and fullscreen tasks as compatible." into main

parents feff969e 8f83165c
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")