From 9060da6c38e211b9de29a9c0a608e9d2ed062cef Mon Sep 17 00:00:00 2001 From: armenk Date: Wed, 26 Jan 2022 11:44:09 -0800 Subject: [PATCH] Set focused app when top activity is resumed In a multi-resumed environment, like in a freeform device, the top activity can be resumed but it might not be the focused app. This causes some failures in Pip tests. To fix it, the top activity can be explicitly set to the focused app in TaskFragment.resumeTopActivity() function. Bug: 194224954 Test: atest PinnedStackTests#testEnterPictureInPictureMode Change-Id: I646c9950e74c589c155a32a787b5165598cecb61 --- services/core/java/com/android/server/wm/TaskFragment.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 177d2e61d5f08..a59d7b6e72198 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -945,6 +945,10 @@ class TaskFragment extends WindowContainer { // we still want to check if the visibility of other windows have changed (e.g. bringing // a fullscreen window forward to cover another freeform activity.) if (taskDisplayArea.inMultiWindowMode()) { + if (taskDisplayArea.mDisplayContent != null + && taskDisplayArea.mDisplayContent.mFocusedApp != next) { + taskDisplayArea.mDisplayContent.setFocusedApp(next); + } taskDisplayArea.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, false /* preserveWindows */, true /* notifyClients */); }