From eccd6e40a27c0df728465b2fe1487ed1a5919c34 Mon Sep 17 00:00:00 2001 From: Winston Hung Date: Mon, 11 Jul 2022 12:59:00 +0800 Subject: [PATCH] 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 --- services/core/java/com/android/server/wm/RecentsAnimation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java index f840171b29b06..ffe3374e66584 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimation.java +++ b/services/core/java/com/android/server/wm/RecentsAnimation.java @@ -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()); } }