From d55d0b00475fec8dad88833f4a23aba3ce5d48a7 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Mon, 19 Sep 2022 15:15:36 +0800 Subject: [PATCH] Skip enter split expanding animation by drag By our motion specs, drag drop to enter split case should show split contents after drop rather than run animation to enter split. We already have a function for drag drop tell split screen for logging events. Use this function to set a flag to skip next time entering animation and reset it after entering. Fix: 247108671 Test: manual Test: pass existing tests Change-Id: Ie1a511bc4846021a79db726ef7a42590b33b8afb --- .../splitscreen/SplitscreenEventLogger.java | 4 +++ .../shell/splitscreen/StageCoordinator.java | 31 ++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java index 033d743d8042f..2dc4a0441b068 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java @@ -87,6 +87,10 @@ public class SplitscreenEventLogger { return mLoggerSessionId != null; } + public boolean isEnterRequestedByDrag() { + return mEnterReason == ENTER_REASON_DRAG; + } + /** * May be called before logEnter() to indicate that the session was started from a drag. */ 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 c8dcf4acd7469..45b013a4c1965 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 @@ -503,6 +503,12 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, final WindowContainerTransaction wct = new WindowContainerTransaction(); options = resolveStartStage(STAGE_TYPE_UNDEFINED, position, options, wct); + // If split still not active, apply windows bounds first to avoid surface reset to + // wrong pos by SurfaceAnimator from wms. + if (!mMainStage.isActive() && mLogger.isEnterRequestedByDrag()) { + updateWindowBounds(mSplitLayout, wct); + } + wct.sendPendingIntent(intent, fillInIntent, options); mSyncQueue.queue(transition, WindowManager.TRANSIT_OPEN, wct); } @@ -1455,18 +1461,27 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } } } else if (isSideStage && hasChildren && !mMainStage.isActive()) { - // TODO (b/238697912) : Add the validation to prevent entering non-recovered status - onSplitScreenEnter(); final WindowContainerTransaction wct = new WindowContainerTransaction(); mSplitLayout.init(); - mSplitLayout.setDividerAtBorder(mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT); - mMainStage.activate(wct, true /* includingTopTask */); - updateWindowBounds(mSplitLayout, wct); - wct.reorder(mRootTaskInfo.token, true); - wct.setForceTranslucent(mRootTaskInfo.token, false); + if (mLogger.isEnterRequestedByDrag()) { + prepareEnterSplitScreen(wct); + } else { + // TODO (b/238697912) : Add the validation to prevent entering non-recovered status + onSplitScreenEnter(); + mSplitLayout.setDividerAtBorder(mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT); + mMainStage.activate(wct, true /* includingTopTask */); + updateWindowBounds(mSplitLayout, wct); + wct.reorder(mRootTaskInfo.token, true); + wct.setForceTranslucent(mRootTaskInfo.token, false); + } + mSyncQueue.queue(wct); mSyncQueue.runInSync(t -> { - mSplitLayout.flingDividerToCenter(); + if (mLogger.isEnterRequestedByDrag()) { + updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */); + } else { + mSplitLayout.flingDividerToCenter(); + } }); } if (mMainStageListener.mHasChildren && mSideStageListener.mHasChildren) {