From 73abde9d9341b62b683ee8fab478f58185dcd1ae Mon Sep 17 00:00:00 2001 From: chaviw Date: Mon, 18 May 2020 17:56:35 -0700 Subject: [PATCH] Force reportResized when useBlastSync enabled We need to always reportResized if using blastSync since the window waiting on a finishDrawing from the client. Therefore, always add the window to the resizing list even if bounds have not changed. Test: WindowStateTests#testRequestResizeForBlastSync Bug: 153579514 Change-Id: I87b459d95fac315b9a25f2d8e989fe3aaf0c0c85 --- .../com/android/server/wm/WindowState.java | 13 ++++++++++- .../android/server/wm/WindowStateTests.java | 23 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index e9aff88d0f80d..ec03f24c90cc7 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -334,6 +334,8 @@ class WindowState extends WindowContainer implements WindowManagerP private boolean mDragResizing; private boolean mDragResizingChangeReported = true; private int mResizeMode; + private boolean mResizeForBlastSyncReported; + /** * Special mode that is intended only for the rounded corner overlay: during rotation * transition, we un-rotate the window token such that the window appears as it did before the @@ -1370,11 +1372,14 @@ class WindowState extends WindowContainer implements WindowManagerP // variables, because mFrameSizeChanged only tracks the width and height changing. updateLastFrames(); + // Add a window that is using blastSync to the resizing list if it hasn't been reported + // already. This because the window is waiting on a finishDrawing from the client. if (didFrameInsetsChange || winAnimator.mSurfaceResized || configChanged || dragResizingChanged - || mReportOrientationChanged) { + || mReportOrientationChanged + || requestResizeForBlastSync()) { ProtoLog.v(WM_DEBUG_RESIZE, "Resize reasons for w=%s: %s surfaceResized=%b configChanged=%b " + "dragResizingChanged=%b reportOrientationChanged=%b", @@ -3483,6 +3488,7 @@ class WindowState extends WindowContainer implements WindowManagerP mReportOrientationChanged = false; mDragResizingChangeReported = true; mWinAnimator.mSurfaceResized = false; + mResizeForBlastSyncReported = true; mWindowFrames.resetInsetsChanged(); final Rect frame = mWindowFrames.mCompatFrame; @@ -5733,6 +5739,7 @@ class WindowState extends WindowContainer implements WindowManagerP if (!willSync) { return false; } + mResizeForBlastSyncReported = false; mLocalSyncId = mBLASTSyncEngine.startSyncSet(this); addChildrenToSyncSet(mLocalSyncId); @@ -5777,4 +5784,8 @@ class WindowState extends WindowContainer implements WindowManagerP mWaitingListener = null; return mWinAnimator.finishDrawingLocked(null); } + + private boolean requestResizeForBlastSync() { + return useBLASTSync() && !mResizeForBlastSyncReported; + } } diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java index 8ce5daa635f2e..e9ed20bd9683b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -602,6 +602,29 @@ public class WindowStateTests extends WindowTestsBase { assertFalse(win.getOrientationChanging()); } + @Test + public void testRequestResizeForBlastSync() { + final WindowState win = mChildAppWindowAbove; + makeWindowVisible(win, win.getParentWindow()); + win.mLayoutSeq = win.getDisplayContent().mLayoutSeq; + win.reportResized(); + win.updateResizingWindowIfNeeded(); + assertThat(mWm.mResizingWindows).doesNotContain(win); + + // Check that the window is in resizing if using blast sync. + win.reportResized(); + win.prepareForSync(mock(BLASTSyncEngine.TransactionReadyListener.class), 1); + win.updateResizingWindowIfNeeded(); + assertThat(mWm.mResizingWindows).contains(win); + + // Don't re-add the window again if it's been reported to the client and still waiting on + // the client draw for blast sync. + win.reportResized(); + mWm.mResizingWindows.remove(win); + win.updateResizingWindowIfNeeded(); + assertThat(mWm.mResizingWindows).doesNotContain(win); + } + @Test public void testGetTransformationMatrix() { final int PARENT_WINDOW_OFFSET = 1;