Fix broken transition when caceling enter split screen

Fallback both the following flows to cancel entering split by launching
a solo task to consolidate the cancel transition:
1. not supporting multi-instances split
2. click on the stashed app

Fix: 265736106
Bug: 265898485
Test: repro steps of the bug
Change-Id: I30ca6555dd260722f545538f4594b8b4e12c71d3
This commit is contained in:
Jerry Chang
2023-01-18 10:14:33 +00:00
parent 5bdad5d547
commit 7119861f92
2 changed files with 25 additions and 16 deletions

View File

@@ -18,6 +18,7 @@ package com.android.wm.shell.splitscreen;
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NO_USER_ACTION;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -535,17 +536,11 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "Adding MULTIPLE_TASK");
} else {
try {
adapter.getRunner().onAnimationCancelled(false /* isKeyguardOccluded */);
ActivityTaskManager.getService().startActivityFromRecents(taskId, options2);
} catch (RemoteException e) {
Slog.e(TAG, "Error starting remote animation", e);
}
taskId = INVALID_TASK_ID;
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();
return;
}
}
mStageCoordinator.startIntentAndTaskWithLegacyTransition(pendingIntent, fillInIntent,
@@ -586,17 +581,11 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
fillInIntent2.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "Adding MULTIPLE_TASK");
} else {
try {
adapter.getRunner().onAnimationCancelled(false /* isKeyguardOccluded */);
pendingIntent1.send();
} catch (RemoteException | PendingIntent.CanceledException e) {
Slog.e(TAG, "Error starting remote animation", e);
}
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();
return;
}
}
mStageCoordinator.startIntentsWithLegacyTransition(pendingIntent1, fillInIntent1, options1,

View File

@@ -629,9 +629,19 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
RemoteAnimationAdapter adapter, InstanceId instanceId) {
final WindowContainerTransaction wct = new WindowContainerTransaction();
if (options1 == null) options1 = new Bundle();
if (pendingIntent2 == null) {
// Launching a solo task.
ActivityOptions activityOptions = ActivityOptions.fromBundle(options1);
activityOptions.update(ActivityOptions.makeRemoteAnimation(adapter));
options1 = activityOptions.toBundle();
addActivityOptions(options1, null /* launchTarget */);
wct.sendPendingIntent(pendingIntent1, fillInIntent1, options1);
mSyncQueue.queue(wct);
return;
}
addActivityOptions(options1, mSideStage);
wct.sendPendingIntent(pendingIntent1, fillInIntent1, options1);
startWithLegacyTransition(wct, pendingIntent2, fillInIntent2, options2, splitPosition,
splitRatio, adapter, instanceId);
}
@@ -666,9 +676,19 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
InstanceId instanceId) {
final WindowContainerTransaction wct = new WindowContainerTransaction();
if (options1 == null) options1 = new Bundle();
if (taskId == INVALID_TASK_ID) {
// Launching a solo task.
ActivityOptions activityOptions = ActivityOptions.fromBundle(options1);
activityOptions.update(ActivityOptions.makeRemoteAnimation(adapter));
options1 = activityOptions.toBundle();
addActivityOptions(options1, null /* launchTarget */);
wct.startShortcut(mContext.getPackageName(), shortcutInfo, options1);
mSyncQueue.queue(wct);
return;
}
addActivityOptions(options1, mSideStage);
wct.startShortcut(mContext.getPackageName(), shortcutInfo, options1);
startWithLegacyTransition(wct, taskId, options2, splitPosition, splitRatio, adapter,
instanceId);
}