diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java index 1f49a4cc3ab90..fd1d0f9104acd 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java @@ -26,6 +26,7 @@ import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSIT import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT; import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_SIDE; import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_UNDEFINED; +import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS; import android.app.ActivityManager; import android.app.ActivityTaskManager; @@ -310,7 +311,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, public void startIntent(PendingIntent intent, Intent fillInIntent, @SplitPosition int position, @Nullable Bundle options) { - if (!Transitions.ENABLE_SHELL_TRANSITIONS) { + if (!ENABLE_SHELL_TRANSITIONS) { startIntentLegacy(intent, fillInIntent, position, options); return; } @@ -366,7 +367,8 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, } RemoteAnimationTarget[] onGoingToRecentsLegacy(boolean cancel, RemoteAnimationTarget[] apps) { - if (!isSplitScreenVisible()) return null; + if (ENABLE_SHELL_TRANSITIONS || apps.length < 2) return null; + // TODO(b/206487881): Integrate this with shell transition. final SurfaceControl.Builder builder = new SurfaceControl.Builder(new SurfaceSession()) .setContainerLayer() .setName("RecentsAnimationSplitTasks") diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java index af0ac5553c219..dde470df13c98 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java @@ -372,6 +372,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, void startTasksWithLegacyTransition(int mainTaskId, @Nullable Bundle mainOptions, int sideTaskId, @Nullable Bundle sideOptions, @SplitPosition int sidePosition, float splitRatio, RemoteAnimationAdapter adapter) { + // Init divider first to make divider leash for remote animation target. + mSplitLayout.init(); final WindowContainerTransaction wct = new WindowContainerTransaction(); // Need to add another wrapper here in shell so that we can inject the divider bar // and also manage the process elevation via setRunningRemote @@ -388,6 +390,15 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, augmentedNonApps[i] = nonApps[i]; } augmentedNonApps[augmentedNonApps.length - 1] = getDividerBarLegacyTarget(); + + IRemoteAnimationFinishedCallback wrapCallback = + new IRemoteAnimationFinishedCallback.Stub() { + @Override + public void onAnimationFinished() throws RemoteException { + mSyncQueue.runInSync(t -> setDividerVisibility(true, t)); + finishedCallback.onAnimationFinished(); + } + }; try { try { ActivityTaskManager.getService().setRunningRemoteTransitionDelegate( @@ -396,8 +407,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, Slog.e(TAG, "Unable to boost animation thread. This should only happen" + " during unit tests"); } - adapter.getRunner().onAnimationStart(transit, apps, wallpapers, nonApps, - finishedCallback); + adapter.getRunner().onAnimationStart(transit, apps, wallpapers, + augmentedNonApps, wrapCallback); } catch (RemoteException e) { Slog.e(TAG, "Error starting remote animation", e); } @@ -405,6 +416,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, @Override public void onAnimationCancelled() { + mSyncQueue.runInSync(t -> setDividerVisibility(true, t)); try { adapter.getRunner().onAnimationCancelled(); } catch (RemoteException e) { @@ -883,9 +895,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, private void applyDividerVisibility(SurfaceControl.Transaction t) { final SurfaceControl dividerLeash = mSplitLayout.getDividerLeash(); - if (dividerLeash == null) { - return; - } + if (dividerLeash == null) return; if (mDividerVisible) { t.show(dividerLeash); @@ -910,11 +920,15 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, } } else if (isSideStage) { final WindowContainerTransaction wct = new WindowContainerTransaction(); + mSplitLayout.init(); // Make sure the main stage is active. mMainStage.activate(getMainStageBounds(), wct, true /* reparent */); mSideStage.moveToTop(getSideStageBounds(), wct); mSyncQueue.queue(wct); - mSyncQueue.runInSync(t -> updateSurfaceBounds(mSplitLayout, t)); + mSyncQueue.runInSync(t -> { + updateSurfaceBounds(mSplitLayout, t); + setDividerVisibility(true, t); + }); } if (mMainStageListener.mHasChildren && mSideStageListener.mHasChildren) { mShouldUpdateRecents = true;