Start background tasks via task instead of intent.
When the second app is selected, check if there is a background task
that matches the intent provided and start the task if there
is one.
This is done to correct an issue where freeform background tasks opened
via intent will open in the correct split stage but in freeform
windowing mode and bounds.
Bug: 338382550
Test: manual
Flag: EXEMPT bugfix
Change-Id: Ibefe4b5045cbcefdbc71c99c4eaba4fdf67d7a0e
diff --git a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java
index 4962367..bdfaa48 100644
--- a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java
@@ -48,8 +48,11 @@
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.quickstep.views.FloatingTaskView;
import com.android.quickstep.views.RecentsView;
+import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
+import java.util.Collections;
+
/** Handles when the stage split lands on the home screen. */
public class SplitToWorkspaceController {
@@ -133,10 +136,20 @@
// Use Launcher's default click handler
return false;
}
-
- mController.setSecondTask(intent, user, (ItemInfo) tag);
-
- startWorkspaceAnimation(view, null /*bitmap*/, bitmapInfo.newIcon(mLauncher));
+ // Check for background task matching this tag; if we find one, set second task
+ // via task instead of intent so the bounds and windowing mode will be corrected.
+ mController.findLastActiveTasksAndRunCallback(
+ Collections.singletonList(((ItemInfo) tag).getComponentKey()),
+ false /* findExactPairMatch */,
+ foundTasks -> {
+ Task foundTask = foundTasks[0];
+ if (foundTask != null) {
+ mController.setSecondTask(foundTask, (ItemInfo) tag);
+ } else {
+ mController.setSecondTask(intent, user, (ItemInfo) tag);
+ }
+ startWorkspaceAnimation(view, null /*bitmap*/, bitmapInfo.newIcon(mLauncher));
+ });
return true;
}