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

Commit 523e3e8c authored by Louis Chang's avatar Louis Chang
Browse files

Fix returning activity that not in the task

Illegal state warning logs were able to observe on normal
activity starts flow.

Also should only returning the activity if it is the descendant
of this task.

Bug: 156882835
Test: atest TaskTests
Change-Id: Ia44bbbd8254e3f05b440153c180a3317e4d79209
parent e39c2e7e
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -3766,11 +3766,7 @@ class Task extends WindowContainer<WindowContainer> {
        if (r == null) {
            return null;
        }
        final Task task = r.getRootTask();
        if (task != null && r.isDescendantOf(task)) {
            if (task != this) Slog.w(TAG, "Illegal state! task does not point to stack it is in. "
                    + "stack=" + this + " task=" + task + " r=" + r
                    + " callers=" + Debug.getCallers(15, "\n"));
        if (r.isDescendantOf(this)) {
            return r;
        }
        return null;
+12 −0
Original line number Diff line number Diff line
@@ -146,4 +146,16 @@ public class TaskTests extends WindowTestsBase {
        task.setBounds(bounds);
        assertEquals(new Point(bounds.left, bounds.top), task.getLastSurfacePosition());
    }

    @Test
    public void testIsInStack() {
        final Task task1 = createTaskStackOnDisplay(mDisplayContent);
        final Task task2 = createTaskStackOnDisplay(mDisplayContent);
        final ActivityRecord activity1 =
                WindowTestUtils.createActivityRecordInTask(mDisplayContent, task1);
        final ActivityRecord activity2 =
                WindowTestUtils.createActivityRecordInTask(mDisplayContent, task2);
        assertEquals(activity1, task1.isInTask(activity1));
        assertNull(task1.isInTask(activity2));
    }
}