From 3d39bfcda7ea6011994da019a5e9e06b3dda3413 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Tue, 4 Oct 2022 14:41:26 +0000 Subject: [PATCH] Support starts a pair of intent/shortcut and task to split Add startIntentAndTask and startShortcutAndTask APIs to support starts a pair of intent/shortcut and task to split with shell-transition. Fix: 250875492 Test: atest WMShellFlickerTests Test: manual check start tasks or start intent/shortcut with task flow with shell-transition enabled Change-Id: Ibce60f3a10e2bbc99ef17185f45680dc23ef5f48 --- .../com/android/quickstep/SystemUiProxy.java | 28 ++++++++++++++ .../com/android/quickstep/TaskViewUtils.java | 7 ++-- .../util/SplitSelectStateController.java | 38 +++++++++++++------ 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 7186de702b..a07feff8d1 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -562,6 +562,34 @@ public class SystemUiProxy implements ISystemUiProxy { } } + public void startIntentAndTask(PendingIntent pendingIntent, Intent fillInIntent, + Bundle options1, int taskId, Bundle options2, + @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio, + RemoteTransitionCompat remoteTransition, InstanceId instanceId) { + if (mSystemUiProxy != null) { + try { + mSplitScreen.startIntentAndTask(pendingIntent, fillInIntent, options1, + taskId, options2, splitPosition, splitRatio, + remoteTransition.getTransition(), instanceId); + } catch (RemoteException e) { + Log.w(TAG, "Failed call startIntentAndTask"); + } + } + } + + public void startShortcutAndTask(ShortcutInfo shortcutInfo, Bundle options1, int taskId, + Bundle options2, @SplitConfigurationOptions.StagePosition int splitPosition, + float splitRatio, RemoteTransitionCompat remoteTransition, InstanceId instanceId) { + if (mSystemUiProxy != null) { + try { + mSplitScreen.startShortcutAndTask(shortcutInfo, options1, taskId, options2, + splitPosition, splitRatio, remoteTransition.getTransition(), instanceId); + } catch (RemoteException e) { + Log.w(TAG, "Failed call startShortcutAndTask"); + } + } + } + /** * Start multiple tasks in split-screen simultaneously. */ diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index a96524e186..73e9a28438 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -15,7 +15,6 @@ */ package com.android.quickstep; -import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_TO_FRONT; @@ -426,8 +425,10 @@ public final class TaskViewUtils { TransitionInfo.Change splitRoot2 = null; for (int i = 0; i < transitionInfo.getChanges().size(); ++i) { final TransitionInfo.Change change = transitionInfo.getChanges().get(i); - final int taskId = change.getTaskInfo() != null ? change.getTaskInfo().taskId : -1; + if (change.getTaskInfo() == null) continue; + final int taskId = change.getTaskInfo().taskId; final int mode = change.getMode(); + // Find the target tasks' root tasks since those are the split stages that need to // be animated (the tasks themselves are children and thus inherit animation). if (taskId == initialTaskId || taskId == secondTaskId) { @@ -440,7 +441,7 @@ public final class TaskViewUtils { + "root of " + taskId + " is already visible or has broken hierarchy."); } } - if (taskId == initialTaskId && initialTaskId != INVALID_TASK_ID) { + if (taskId == initialTaskId) { splitRoot1 = transitionInfo.getChange(change.getParent()); } if (taskId == secondTaskId) { diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index 19709d80b8..f07f9903c2 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -214,18 +214,36 @@ public class SplitSelectStateController { @Nullable InstanceId shellInstanceId) { TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "launchSplitTasks"); + final ActivityOptions options1 = ActivityOptions.makeBasic(); + if (freezeTaskList) { + options1.setFreezeRecentTasksReordering(); + } if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) { - RemoteSplitLaunchTransitionRunner animationRunner = + final RemoteSplitLaunchTransitionRunner animationRunner = new RemoteSplitLaunchTransitionRunner(taskId1, taskPendingIntent, taskId2, callback); - mSystemUiProxy.startTasks(taskId1, null /* options1 */, taskId2, - null /* options2 */, stagePosition, splitRatio, - new RemoteTransitionCompat(animationRunner, MAIN_EXECUTOR, - ActivityThread.currentActivityThread().getApplicationThread()), - shellInstanceId); - // TODO(b/237635859): handle intent/shortcut + task with shell transition + final RemoteTransitionCompat remoteTransition = new RemoteTransitionCompat( + animationRunner, MAIN_EXECUTOR, + ActivityThread.currentActivityThread().getApplicationThread()); + if (taskPendingIntent == null) { + mSystemUiProxy.startTasks(taskId1, options1.toBundle(), taskId2, + null /* options2 */, stagePosition, splitRatio, remoteTransition, + shellInstanceId); + } else { + final ShortcutInfo shortcutInfo = getShortcutInfo(mInitialTaskIntent, + taskPendingIntent.getCreatorUserHandle()); + if (shortcutInfo != null) { + mSystemUiProxy.startShortcutAndTask(shortcutInfo, + options1.toBundle(), taskId2, null /* options2 */, stagePosition, + splitRatio, remoteTransition, shellInstanceId); + } else { + mSystemUiProxy.startIntentAndTask(taskPendingIntent, + fillInIntent, options1.toBundle(), taskId2, null /* options2 */, + stagePosition, splitRatio, remoteTransition, shellInstanceId); + } + } } else { - RemoteSplitLaunchAnimationRunner animationRunner = + final RemoteSplitLaunchAnimationRunner animationRunner = new RemoteSplitLaunchAnimationRunner(taskId1, taskPendingIntent, taskId2, callback); final RemoteAnimationAdapter adapter = new RemoteAnimationAdapter( @@ -233,10 +251,6 @@ public class SplitSelectStateController { 300, 150, ActivityThread.currentActivityThread().getApplicationThread()); - ActivityOptions options1 = ActivityOptions.makeBasic(); - if (freezeTaskList) { - options1.setFreezeRecentTasksReordering(); - } if (taskPendingIntent == null) { mSystemUiProxy.startTasksWithLegacyTransition(taskId1, options1.toBundle(), taskId2, null /* options2 */, stagePosition, splitRatio, adapter,