Merge "Add split screen API to start two split apps with intents" into tm-qpr-dev
This commit is contained in:
@@ -95,7 +95,7 @@ interface ISplitScreen {
|
|||||||
*/
|
*/
|
||||||
oneway void startShortcutAndTask(in ShortcutInfo shortcutInfo, in Bundle options1, int taskId,
|
oneway void startShortcutAndTask(in ShortcutInfo shortcutInfo, in Bundle options1, int taskId,
|
||||||
in Bundle options2, int splitPosition, float splitRatio,
|
in Bundle options2, int splitPosition, float splitRatio,
|
||||||
in RemoteTransition remoteTransition, in InstanceId instanceId) = 17;
|
in RemoteTransition remoteTransition, in InstanceId instanceId) = 17;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version of startTasks using legacy transition system.
|
* Version of startTasks using legacy transition system.
|
||||||
@@ -118,6 +118,21 @@ interface ISplitScreen {
|
|||||||
in Bundle options1, int taskId, in Bundle options2, int splitPosition, float splitRatio,
|
in Bundle options1, int taskId, in Bundle options2, int splitPosition, float splitRatio,
|
||||||
in RemoteAnimationAdapter adapter, in InstanceId instanceId) = 15;
|
in RemoteAnimationAdapter adapter, in InstanceId instanceId) = 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a pair of intents using legacy transition system.
|
||||||
|
*/
|
||||||
|
oneway void startIntentsWithLegacyTransition(in PendingIntent pendingIntent1,
|
||||||
|
in Bundle options1, in PendingIntent pendingIntent2, in Bundle options2,
|
||||||
|
int splitPosition, float splitRatio, in RemoteAnimationAdapter adapter,
|
||||||
|
in InstanceId instanceId) = 18;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocking call that notifies and gets additional split-screen targets when entering
|
* Blocking call that notifies and gets additional split-screen targets when entering
|
||||||
* recents (for example: the dividerBar).
|
* recents (for example: the dividerBar).
|
||||||
@@ -132,4 +147,4 @@ interface ISplitScreen {
|
|||||||
*/
|
*/
|
||||||
RemoteAnimationTarget[] onStartingSplitLegacy(in RemoteAnimationTarget[] appTargets) = 14;
|
RemoteAnimationTarget[] onStartingSplitLegacy(in RemoteAnimationTarget[] appTargets) = 14;
|
||||||
}
|
}
|
||||||
// Last id = 17
|
// Last id = 19
|
||||||
@@ -548,6 +548,24 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
options2, splitPosition, splitRatio, remoteTransition, instanceId);
|
options2, splitPosition, splitRatio, remoteTransition, instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startIntentsWithLegacyTransition(PendingIntent pendingIntent1,
|
||||||
|
@Nullable Bundle options1, PendingIntent pendingIntent2,
|
||||||
|
@Nullable Bundle options2, @SplitPosition int splitPosition,
|
||||||
|
float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) {
|
||||||
|
Intent fillInIntent1 = null;
|
||||||
|
Intent fillInIntent2 = null;
|
||||||
|
if (launchSameComponentAdjacently(pendingIntent1, pendingIntent2)
|
||||||
|
&& supportMultiInstancesSplit(pendingIntent1.getIntent().getComponent())) {
|
||||||
|
fillInIntent1 = new Intent();
|
||||||
|
fillInIntent1.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
|
fillInIntent2 = new Intent();
|
||||||
|
fillInIntent2.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
|
}
|
||||||
|
mStageCoordinator.startIntentsWithLegacyTransition(pendingIntent1, fillInIntent1, options1,
|
||||||
|
pendingIntent2, fillInIntent2, options2, splitPosition, splitRatio, adapter,
|
||||||
|
instanceId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startIntent(PendingIntent intent, @Nullable Intent fillInIntent,
|
public void startIntent(PendingIntent intent, @Nullable Intent fillInIntent,
|
||||||
@SplitPosition int position, @Nullable Bundle options) {
|
@SplitPosition int position, @Nullable Bundle options) {
|
||||||
@@ -621,6 +639,12 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
return Objects.equals(launchingActivity, pairedActivity);
|
return Objects.equals(launchingActivity, pairedActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean launchSameComponentAdjacently(PendingIntent pendingIntent1,
|
||||||
|
PendingIntent pendingIntent2) {
|
||||||
|
return Objects.equals(pendingIntent1.getIntent().getComponent(),
|
||||||
|
pendingIntent2.getIntent().getComponent());
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
/** Returns {@code true} if the component supports multi-instances split. */
|
/** Returns {@code true} if the component supports multi-instances split. */
|
||||||
boolean supportMultiInstancesSplit(@Nullable ComponentName launching) {
|
boolean supportMultiInstancesSplit(@Nullable ComponentName launching) {
|
||||||
@@ -985,6 +1009,27 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
instanceId));
|
instanceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startIntentsWithLegacyTransition(PendingIntent pendingIntent1,
|
||||||
|
@Nullable Bundle options1, PendingIntent pendingIntent2, @Nullable Bundle options2,
|
||||||
|
@SplitPosition int splitPosition, float splitRatio, RemoteAnimationAdapter adapter,
|
||||||
|
InstanceId instanceId) {
|
||||||
|
executeRemoteCallWithTaskPermission(mController, "startIntentsWithLegacyTransition",
|
||||||
|
(controller) ->
|
||||||
|
controller.startIntentsWithLegacyTransition(
|
||||||
|
pendingIntent1, options1, pendingIntent2, options2, splitPosition,
|
||||||
|
splitRatio, adapter, instanceId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startIntents(PendingIntent pendingIntent1, @Nullable Bundle options1,
|
||||||
|
PendingIntent pendingIntent2, @Nullable Bundle options2,
|
||||||
|
@SplitPosition int splitPosition, float splitRatio,
|
||||||
|
@Nullable RemoteTransition remoteTransition, InstanceId instanceId) {
|
||||||
|
// TODO(b/259368992): To be implemented.
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startShortcut(String packageName, String shortcutId, int position,
|
public void startShortcut(String packageName, String shortcutId, int position,
|
||||||
@Nullable Bundle options, UserHandle user, InstanceId instanceId) {
|
@Nullable Bundle options, UserHandle user, InstanceId instanceId) {
|
||||||
|
|||||||
@@ -589,8 +589,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
/** Starts a pair of tasks using legacy transition. */
|
/** Starts a pair of tasks using legacy transition. */
|
||||||
void startTasksWithLegacyTransition(int taskId1, @Nullable Bundle options1,
|
void startTasksWithLegacyTransition(int taskId1, @Nullable Bundle options1,
|
||||||
int taskId2, @Nullable Bundle options2, @SplitPosition int splitPosition,
|
int taskId2, @Nullable Bundle options2, @SplitPosition int splitPosition,
|
||||||
float splitRatio, RemoteAnimationAdapter adapter,
|
float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) {
|
||||||
InstanceId instanceId) {
|
|
||||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
if (options1 == null) options1 = new Bundle();
|
if (options1 == null) options1 = new Bundle();
|
||||||
addActivityOptions(options1, mSideStage);
|
addActivityOptions(options1, mSideStage);
|
||||||
@@ -600,7 +599,20 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
instanceId);
|
instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Starts a pair of intent and task using legacy transition. */
|
/** Starts a pair of intents using legacy transition. */
|
||||||
|
void startIntentsWithLegacyTransition(PendingIntent pendingIntent1, Intent fillInIntent1,
|
||||||
|
@Nullable Bundle options1, PendingIntent pendingIntent2, Intent fillInIntent2,
|
||||||
|
@Nullable Bundle options2, @SplitPosition int splitPosition, float splitRatio,
|
||||||
|
RemoteAnimationAdapter adapter, InstanceId instanceId) {
|
||||||
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
|
if (options1 == null) options1 = new Bundle();
|
||||||
|
addActivityOptions(options1, mSideStage);
|
||||||
|
wct.sendPendingIntent(pendingIntent1, fillInIntent1, options1);
|
||||||
|
|
||||||
|
startWithLegacyTransition(wct, pendingIntent2, fillInIntent2, options2, splitPosition,
|
||||||
|
splitRatio, adapter, instanceId);
|
||||||
|
}
|
||||||
|
|
||||||
void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, Intent fillInIntent,
|
void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, Intent fillInIntent,
|
||||||
@Nullable Bundle options1, int taskId, @Nullable Bundle options2,
|
@Nullable Bundle options1, int taskId, @Nullable Bundle options2,
|
||||||
@SplitPosition int splitPosition, float splitRatio, RemoteAnimationAdapter adapter,
|
@SplitPosition int splitPosition, float splitRatio, RemoteAnimationAdapter adapter,
|
||||||
@@ -628,12 +640,29 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
instanceId);
|
instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startWithLegacyTransition(WindowContainerTransaction wct,
|
||||||
|
@Nullable PendingIntent mainPendingIntent, @Nullable Intent mainFillInIntent,
|
||||||
|
@Nullable Bundle mainOptions, @SplitPosition int sidePosition, float splitRatio,
|
||||||
|
RemoteAnimationAdapter adapter, InstanceId instanceId) {
|
||||||
|
startWithLegacyTransition(wct, INVALID_TASK_ID, mainPendingIntent, mainFillInIntent,
|
||||||
|
mainOptions, sidePosition, splitRatio, adapter, instanceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startWithLegacyTransition(WindowContainerTransaction wct, int mainTaskId,
|
||||||
|
@Nullable Bundle mainOptions, @SplitPosition int sidePosition, float splitRatio,
|
||||||
|
RemoteAnimationAdapter adapter, InstanceId instanceId) {
|
||||||
|
startWithLegacyTransition(wct, mainTaskId, null /* mainPendingIntent */,
|
||||||
|
null /* mainFillInIntent */, mainOptions, sidePosition, splitRatio, adapter,
|
||||||
|
instanceId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wct transaction to start the first task
|
* @param wct transaction to start the first task
|
||||||
* @param instanceId if {@code null}, will not log. Otherwise it will be used in
|
* @param instanceId if {@code null}, will not log. Otherwise it will be used in
|
||||||
* {@link SplitscreenEventLogger#logEnter(float, int, int, int, int, boolean)}
|
* {@link SplitscreenEventLogger#logEnter(float, int, int, int, int, boolean)}
|
||||||
*/
|
*/
|
||||||
private void startWithLegacyTransition(WindowContainerTransaction wct, int mainTaskId,
|
private void startWithLegacyTransition(WindowContainerTransaction wct, int mainTaskId,
|
||||||
|
@Nullable PendingIntent mainPendingIntent, @Nullable Intent mainFillInIntent,
|
||||||
@Nullable Bundle mainOptions, @SplitPosition int sidePosition, float splitRatio,
|
@Nullable Bundle mainOptions, @SplitPosition int sidePosition, float splitRatio,
|
||||||
RemoteAnimationAdapter adapter, InstanceId instanceId) {
|
RemoteAnimationAdapter adapter, InstanceId instanceId) {
|
||||||
// Init divider first to make divider leash for remote animation target.
|
// Init divider first to make divider leash for remote animation target.
|
||||||
@@ -702,7 +731,11 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
if (mainOptions == null) mainOptions = new Bundle();
|
if (mainOptions == null) mainOptions = new Bundle();
|
||||||
addActivityOptions(mainOptions, mMainStage);
|
addActivityOptions(mainOptions, mMainStage);
|
||||||
updateWindowBounds(mSplitLayout, wct);
|
updateWindowBounds(mSplitLayout, wct);
|
||||||
wct.startTask(mainTaskId, mainOptions);
|
if (mainTaskId == INVALID_TASK_ID) {
|
||||||
|
wct.sendPendingIntent(mainPendingIntent, mainFillInIntent, mainOptions);
|
||||||
|
} else {
|
||||||
|
wct.startTask(mainTaskId, mainOptions);
|
||||||
|
}
|
||||||
wct.reorder(mRootTaskInfo.token, true);
|
wct.reorder(mRootTaskInfo.token, true);
|
||||||
wct.setForceTranslucent(mRootTaskInfo.token, false);
|
wct.setForceTranslucent(mRootTaskInfo.token, false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user