From 9a62da7465c41516e5bae10977091f1ed505a8bb Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Tue, 14 Apr 2020 19:26:02 +0800 Subject: [PATCH] Apply the transaction to the leash before it is sent to the client Otherwise, applying the transaction later at the server may overwrite the operations done by the client. For example, the client might hide the leash immediately when it obtains the control, but the 'show' operation in createAnimationLeash() has not been applied yet, so the 'show' operation at the server side can overwrite the 'hide' operation at the client side later. Fix: 153104643 Test: Steps in the bug. Change-Id: I9b3480ba17c2cd5396aed8a5412f2c8ba265db68 --- .../java/com/android/server/wm/InsetsSourceProvider.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index cb0d8536fe728..1ca82ceeb5703 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -266,7 +266,7 @@ class InsetsSourceProvider { if (getSource().getType() == ITYPE_IME) { setClientVisible(InsetsState.getDefaultVisibility(mSource.getType())); } - final Transaction t = mDisplayContent.getPendingTransaction(); + final Transaction t = mDisplayContent.mWmService.mTransactionFactory.get(); mWin.startAnimation(t, mAdapter, !mClientVisible /* hidden */, ANIMATION_TYPE_INSETS_CONTROL, null /* animationFinishedCallback */); final SurfaceControl leash = mAdapter.mCapturedLeash; @@ -281,6 +281,9 @@ class InsetsSourceProvider { t.deferTransactionUntil(mWin.getSurfaceControl(), barrier, frameNumber); t.deferTransactionUntil(leash, barrier, frameNumber); } + // Applying the transaction here can prevent the client from applying its transaction sooner + // than us which makes us overwrite the client's operation to the leash. + t.apply(); mControlTarget = target; mControl = new InsetsSourceControl(mSource.getType(), leash, new Point(mWin.getWindowFrames().mFrame.left, mWin.getWindowFrames().mFrame.top));