[Re-land] Implement two intents or shortcuts to active split
Implement two intents or shortcuts to active split with shell transition. Fix: 259368992 Test: manual Test: pass existing tests Change-Id: I1d665fa6ea8ac37e3b9e560033c76b403d7c38da
This commit is contained in:
@@ -129,9 +129,10 @@ interface ISplitScreen {
|
||||
/**
|
||||
* Start a pair of intents in one transition.
|
||||
*/
|
||||
oneway void startIntents(in PendingIntent pendingIntent1, in Bundle options1,
|
||||
in PendingIntent pendingIntent2, in Bundle options2, int splitPosition,
|
||||
float splitRatio, in RemoteTransition remoteTransition, in InstanceId instanceId) = 19;
|
||||
oneway void startIntents(in PendingIntent pendingIntent1, in ShortcutInfo shortcutInfo1,
|
||||
in Bundle options1, in PendingIntent pendingIntent2, in ShortcutInfo shortcutInfo2,
|
||||
in Bundle options2, int splitPosition, float splitRatio,
|
||||
in RemoteTransition remoteTransition, in InstanceId instanceId) = 19;
|
||||
|
||||
/**
|
||||
* Blocking call that notifies and gets additional split-screen targets when entering
|
||||
|
||||
@@ -626,6 +626,35 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
||||
splitPosition, splitRatio, adapter, instanceId);
|
||||
}
|
||||
|
||||
private void startIntents(PendingIntent pendingIntent1,
|
||||
@Nullable ShortcutInfo shortcutInfo1, @Nullable Bundle options1,
|
||||
PendingIntent pendingIntent2, @Nullable ShortcutInfo shortcutInfo2,
|
||||
@Nullable Bundle options2, @SplitPosition int splitPosition, float splitRatio,
|
||||
@Nullable RemoteTransition remoteTransition, InstanceId instanceId) {
|
||||
Intent fillInIntent1 = null;
|
||||
Intent fillInIntent2 = null;
|
||||
final String packageName1 = SplitScreenUtils.getPackageName(pendingIntent1);
|
||||
final String packageName2 = SplitScreenUtils.getPackageName(pendingIntent2);
|
||||
if (samePackage(packageName1, packageName2)) {
|
||||
if (supportMultiInstancesSplit(packageName1)) {
|
||||
fillInIntent1 = new Intent();
|
||||
fillInIntent1.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
fillInIntent2 = new Intent();
|
||||
fillInIntent2.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "Adding MULTIPLE_TASK");
|
||||
} else {
|
||||
pendingIntent2 = null;
|
||||
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN,
|
||||
"Cancel entering split as not supporting multi-instances");
|
||||
Toast.makeText(mContext, R.string.dock_multi_instances_not_supported_text,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
mStageCoordinator.startIntents(pendingIntent1, fillInIntent1, shortcutInfo1, options1,
|
||||
pendingIntent2, fillInIntent2, shortcutInfo2, options2, splitPosition, splitRatio,
|
||||
remoteTransition, instanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startIntent(PendingIntent intent, @Nullable Intent fillInIntent,
|
||||
@SplitPosition int position, @Nullable Bundle options) {
|
||||
@@ -1066,11 +1095,17 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startIntents(PendingIntent pendingIntent1, @Nullable Bundle options1,
|
||||
PendingIntent pendingIntent2, @Nullable Bundle options2,
|
||||
public void startIntents(PendingIntent pendingIntent1, @Nullable ShortcutInfo shortcutInfo1,
|
||||
@Nullable Bundle options1, PendingIntent pendingIntent2,
|
||||
@Nullable ShortcutInfo shortcutInfo2, @Nullable Bundle options2,
|
||||
@SplitPosition int splitPosition, float splitRatio,
|
||||
@Nullable RemoteTransition remoteTransition, InstanceId instanceId) {
|
||||
// TODO(b/259368992): To be implemented.
|
||||
executeRemoteCallWithTaskPermission(mController, "startIntents",
|
||||
(controller) ->
|
||||
controller.startIntents(pendingIntent1, shortcutInfo1,
|
||||
options1, pendingIntent2, shortcutInfo2, options2,
|
||||
splitPosition, splitRatio, remoteTransition, instanceId)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -682,6 +682,46 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
setEnterInstanceId(instanceId);
|
||||
}
|
||||
|
||||
void startIntents(PendingIntent pendingIntent1, Intent fillInIntent1,
|
||||
@Nullable ShortcutInfo shortcutInfo1, @Nullable Bundle options1,
|
||||
PendingIntent pendingIntent2, Intent fillInIntent2,
|
||||
@Nullable ShortcutInfo shortcutInfo2, @Nullable Bundle options2,
|
||||
@SplitPosition int splitPosition, float splitRatio,
|
||||
@Nullable RemoteTransition remoteTransition, InstanceId instanceId) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
if (!mMainStage.isActive()) {
|
||||
// Build a request WCT that will launch both apps such that task 0 is on the main stage
|
||||
// while task 1 is on the side stage.
|
||||
mMainStage.activate(wct, false /* reparent */);
|
||||
}
|
||||
|
||||
prepareEvictChildTasksIfSplitActive(wct);
|
||||
mSplitLayout.setDivideRatio(splitRatio);
|
||||
updateWindowBounds(mSplitLayout, wct);
|
||||
wct.reorder(mRootTaskInfo.token, true);
|
||||
setRootForceTranslucent(false, wct);
|
||||
|
||||
setSideStagePosition(splitPosition, wct);
|
||||
options1 = options1 != null ? options1 : new Bundle();
|
||||
addActivityOptions(options1, mSideStage);
|
||||
if (shortcutInfo1 != null) {
|
||||
wct.startShortcut(mContext.getPackageName(), shortcutInfo1, options1);
|
||||
} else {
|
||||
wct.sendPendingIntent(pendingIntent1, fillInIntent1, options1);
|
||||
}
|
||||
options2 = options2 != null ? options2 : new Bundle();
|
||||
addActivityOptions(options2, mMainStage);
|
||||
if (shortcutInfo2 != null) {
|
||||
wct.startShortcut(mContext.getPackageName(), shortcutInfo2, options2);
|
||||
} else {
|
||||
wct.sendPendingIntent(pendingIntent2, fillInIntent2, options2);
|
||||
}
|
||||
|
||||
mSplitTransitions.startEnterTransition(
|
||||
TRANSIT_SPLIT_SCREEN_PAIR_OPEN, wct, remoteTransition, this, null, null);
|
||||
setEnterInstanceId(instanceId);
|
||||
}
|
||||
|
||||
/** Starts a pair of tasks using legacy transition. */
|
||||
void startTasksWithLegacyTransition(int taskId1, @Nullable Bundle options1,
|
||||
int taskId2, @Nullable Bundle options2, @SplitPosition int splitPosition,
|
||||
|
||||
Reference in New Issue
Block a user