Fix crash caused by accessing finishing task

In our design, there are two existing recents task at the same time. If
start new recents while finishing previous recents, there are two subtasks under recents root task, one is newly created and the other
is finishing subtask. Try to get activity from finishing subtask would
be null and cause NPE when manipulate null activity.

Append non-finishing check could ensure we get activity record from
newly created subtask instead of finishing subtask.

Test: atest CtsWindowManagerDeviceTestCases

Change-Id: I3fe8357e57c4f1afe578c696e8371874be0ed45e
This commit is contained in:
Winston Hung
2022-07-11 12:59:00 +08:00
committed by Winson Chung
parent e2137ed5b3
commit eccd6e40a2

View File

@@ -520,7 +520,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan
}
private boolean matchesTarget(Task task) {
return task.mUserId == mUserId
return task.getNonFinishingActivityCount() > 0 && task.mUserId == mUserId
&& task.getBaseIntent().getComponent().equals(mTargetIntent.getComponent());
}
}