From 974769ca52f97507499b4f9c862670cbaee466c1 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 6 Jun 2022 17:08:26 +0000 Subject: [PATCH] Notify of new top task changes when a top task is moved to the back - Launcher currently relies on the current top task to cache the task for the next swipe gesture (skipping a synchronous binder call to fetch the top task, which can cause ANRs) Bug: 232423798 Test: Open task B from task A, go back, and ensure Launcher gets notified that A is moved to top Change-Id: Ia1ff90c776437c7443a472cea587b6bf78e332f0 --- .../core/java/com/android/server/wm/TaskDisplayArea.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index dd1b50fc5e0bc..ca91a742786a0 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -451,6 +451,14 @@ final class TaskDisplayArea extends DisplayArea { if (!toTop) { if (t.mTaskId == mLastLeafTaskToFrontId) { mLastLeafTaskToFrontId = INVALID_TASK_ID; + + // If the previous front-most task is moved to the back, then notify of the new + // front-most task. + final ActivityRecord topMost = getTopMostActivity(); + if (topMost != null) { + mAtmService.getTaskChangeNotificationController().notifyTaskMovedToFront( + topMost.getTask().getTaskInfo()); + } } return; }