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

Commit 660b1757 authored by Evan Rosky's avatar Evan Rosky
Browse files

Assign original activityType of Task to new undefined activity.

Was just re-assigning to itself (which was undefined) so it'd
remain undefined.

Bug: 154145745
Test: added testActivityAndTaskGetsProperType
Change-Id: I36183057a5d43f6845336d0e6bb6fc8101a1ecff
parent 73a8e537
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1378,6 +1378,9 @@ class Task extends WindowContainer<WindowContainer> {
    void addChild(WindowContainer child, int index) {
        // If this task had any child before we added this one.
        boolean hadChild = hasChild();
        // getActivityType() looks at the top child, so we need to read the type before adding
        // a new child in case the new child is on top and UNDEFINED.
        final int activityType = getActivityType();

        index = getAdjustedChildPosition(child, index);
        super.addChild(child, index);
@@ -1418,7 +1421,7 @@ class Task extends WindowContainer<WindowContainer> {
                    ActivityTaskManager.getMaxAppRecentsLimitStatic());
        } else {
            // Otherwise make all added activities match this one.
            r.setActivityType(getActivityType());
            r.setActivityType(activityType);
        }

        updateEffectiveIntent();
+18 −0
Original line number Diff line number Diff line
@@ -208,4 +208,22 @@ public class TaskStackTests extends WindowTestsBase {
        assertEquals(stackBounds.left - stackOutset, stack.getLastSurfacePosition().x);
        assertEquals(stackBounds.top - stackOutset, stack.getLastSurfacePosition().y);
    }

    @Test
    public void testActivityAndTaskGetsProperType() {
        final ActivityStack stack = createTaskStackOnDisplay(mDisplayContent);
        final Task task1 = createTaskInStack(stack, 0 /* userId */);
        ActivityRecord activity1 = WindowTestUtils.createTestActivityRecord(mDisplayContent);

        // First activity should become standard
        task1.addChild(activity1, 0);
        assertEquals(WindowConfiguration.ACTIVITY_TYPE_STANDARD, activity1.getActivityType());
        assertEquals(WindowConfiguration.ACTIVITY_TYPE_STANDARD, task1.getActivityType());

        // Second activity should also become standard
        ActivityRecord activity2 = WindowTestUtils.createTestActivityRecord(mDisplayContent);
        task1.addChild(activity2, WindowContainer.POSITION_TOP);
        assertEquals(WindowConfiguration.ACTIVITY_TYPE_STANDARD, activity2.getActivityType());
        assertEquals(WindowConfiguration.ACTIVITY_TYPE_STANDARD, task1.getActivityType());
    }
}