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

Commit d5f6e7bd authored by Lingyu Feng's avatar Lingyu Feng
Browse files

Check parent TDA in TaskDisplayArea#shouldKeepNoTask()

Bug: 426459518
Test: TaskDisplayAreaTests
Flag: com.android.server.display.feature.flags.enable_display_content_mode_management
Change-Id: I925ec0a20b40f6614e6081e9a837d9e63f4841ea
parent e403e450
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1627,7 +1627,14 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
    }

    boolean shouldKeepNoTask() {
        return mShouldKeepNoTask;
        if (mShouldKeepNoTask) {
            return true;
        }

        // A TaskDisplayArea can have another child TaskDisplayArea, so we should check all it's
        // parent TaskDisplayArea.
        return getParent() != null && getParent().asTaskDisplayArea() != null
                && getParent().asTaskDisplayArea().shouldKeepNoTask();
    }

    @Override
+12 −0
Original line number Diff line number Diff line
@@ -586,6 +586,18 @@ public class TaskDisplayAreaTests extends WindowTestsBase {
        assertTrue(defaultTaskDisplayArea.mChildren.contains(task));
    }

    @Test
    public void testPrepareForRemoval_childTaskDisplayAreaShouldKeepNoTask() {
        final TaskDisplayArea parentTDA = mDefaultDisplay.getDefaultTaskDisplayArea();
        final TaskDisplayArea childTDA = new TaskDisplayArea(mWm, "childTDA",
                FEATURE_VENDOR_FIRST, false /* createdByOrganizer */, true /* canHostHomeTask */);
        parentTDA.addChild(childTDA, POSITION_TOP);
        parentTDA.prepareForRemoval();

        assertTrue(parentTDA.shouldKeepNoTask());
        assertTrue(childTDA.shouldKeepNoTask());
    }

    private void assertGetOrCreateRootTask(int windowingMode, int activityType, Task candidateTask,
            boolean reuseCandidate) {
        final TaskDisplayArea taskDisplayArea = candidateTask.getDisplayArea();