From 1d45696be2a41c5e157296a8871535dbab4affa7 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Mon, 25 Apr 2022 19:55:31 +0000 Subject: [PATCH] Revert "Revert "Remove check for preventing re-parenting non-spl..." Revert "Revert "Use new onStartSplitLegacy when starting split f..." Revert submission 17918609-revert-17779173-startSplitLegacy-OOWPZEFFGI Reason for revert: Running through TH Reverted Changes: I6d81e0584:Revert "Use new onStartSplitLegacy when starting s... I754bc308f:Revert "Remove check for preventing re-parenting n... Change-Id: I190cc9bda28c85a675c3bd8edc2ca2bb43ed677c --- .../wm/shell/splitscreen/ISplitScreen.aidl | 11 ++++--- .../splitscreen/SplitScreenController.java | 32 +++++++++++++++---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/ISplitScreen.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/ISplitScreen.aidl index 9adf1961ebf51..51921e747f1a1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/ISplitScreen.aidl +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/ISplitScreen.aidl @@ -98,11 +98,14 @@ interface ISplitScreen { /** * Blocking call that notifies and gets additional split-screen targets when entering * recents (for example: the dividerBar). - * @param cancel is true if leaving recents back to split (eg. the gesture was cancelled). * @param appTargets apps that will be re-parented to display area */ - RemoteAnimationTarget[] onGoingToRecentsLegacy(boolean cancel, - in RemoteAnimationTarget[] appTargets) = 13; - + RemoteAnimationTarget[] onGoingToRecentsLegacy(in RemoteAnimationTarget[] appTargets) = 13; + /** + * Blocking call that notifies and gets additional split-screen targets when entering + * recents (for example: the dividerBar). Different than the method above in that this one + * does not expect split to currently be running. + */ + RemoteAnimationTarget[] onStartingSplitLegacy(in RemoteAnimationTarget[] appTargets) = 14; } 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 dd2634ca36d94..ac76d17e2a512 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 @@ -413,9 +413,22 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, mSyncQueue.queue(transition, WindowManager.TRANSIT_OPEN, wct); } - RemoteAnimationTarget[] onGoingToRecentsLegacy(boolean cancel, RemoteAnimationTarget[] apps) { - if (ENABLE_SHELL_TRANSITIONS || !isSplitScreenVisible()) return null; + RemoteAnimationTarget[] onGoingToRecentsLegacy(RemoteAnimationTarget[] apps) { + return reparentSplitTasksForAnimation(apps, true /*splitExpectedToBeVisible*/); + } + + RemoteAnimationTarget[] onStartingSplitLegacy(RemoteAnimationTarget[] apps) { + return reparentSplitTasksForAnimation(apps, false /*splitExpectedToBeVisible*/); + } + + private RemoteAnimationTarget[] reparentSplitTasksForAnimation(RemoteAnimationTarget[] apps, + boolean splitExpectedToBeVisible) { + if (ENABLE_SHELL_TRANSITIONS) return null; // TODO(b/206487881): Integrate this with shell transition. + if (splitExpectedToBeVisible && !isSplitScreenVisible()) return null; + // Split not visible, but not enough apps to have split, also return null + if (!splitExpectedToBeVisible && apps.length < 2) return null; + SurfaceControl.Transaction transaction = new SurfaceControl.Transaction(); if (mSplitTasksContainerLayer != null) { // Remove the previous layer before recreating @@ -442,7 +455,6 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, transaction.close(); return new RemoteAnimationTarget[]{mStageCoordinator.getDividerBarLegacyTarget()}; } - /** * Sets drag info to be logged when splitscreen is entered. */ @@ -707,11 +719,19 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, } @Override - public RemoteAnimationTarget[] onGoingToRecentsLegacy(boolean cancel, - RemoteAnimationTarget[] apps) { + public RemoteAnimationTarget[] onGoingToRecentsLegacy(RemoteAnimationTarget[] apps) { final RemoteAnimationTarget[][] out = new RemoteAnimationTarget[][]{null}; executeRemoteCallWithTaskPermission(mController, "onGoingToRecentsLegacy", - (controller) -> out[0] = controller.onGoingToRecentsLegacy(cancel, apps), + (controller) -> out[0] = controller.onGoingToRecentsLegacy(apps), + true /* blocking */); + return out[0]; + } + + @Override + public RemoteAnimationTarget[] onStartingSplitLegacy(RemoteAnimationTarget[] apps) { + final RemoteAnimationTarget[][] out = new RemoteAnimationTarget[][]{null}; + executeRemoteCallWithTaskPermission(mController, "onStartingSplitLegacy", + (controller) -> out[0] = controller.onStartingSplitLegacy(apps), true /* blocking */); return out[0]; }