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
This commit is contained in:
armenk
2022-01-26 11:44:09 -08:00
parent 8981d131ca
commit 9060da6c38

View File

@@ -945,6 +945,10 @@ class TaskFragment extends WindowContainer<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 */);
}