From c6d5af556e9e8b682d24e457e6236fe5ee11e2a6 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 26 Feb 2018 17:46:00 -0800 Subject: Handle surfaceInset changes with deferred transactions. First we have the client pass up the next frameNumber from relayoutWindow and then we simply deferTransactions at the WindowState level until this frame number is reached. This was always a little terrifying because deferring transaction effecftively meant we gave up control of the surface until the frame number was reached. However now we can still control the surface from the stack and other SurfaceControl nodes and so the window can still be moved around and animated even if the client is unresponsive. Bug: 70666541 Test: Manual. go/wm-smoke Change-Id: I2fecbeaa30fc0eb9cc8f08e1ea734dcc65da0aa0 --- core/java/android/view/ViewRootImpl.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 01d9265cc92c..098583c1e445 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -6440,18 +6440,24 @@ public final class ViewRootImpl implements ViewParent, params.backup(); mTranslator.translateWindowLayout(params); } + if (params != null) { if (DBG) Log.d(mTag, "WindowLayout in layoutWindow:" + params); - } - if (params != null && mOrigWindowType != params.type) { - // For compatibility with old apps, don't crash here. - if (mTargetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - Slog.w(mTag, "Window type can not be changed after " - + "the window is added; ignoring change of " + mView); - params.type = mOrigWindowType; + if (mOrigWindowType != params.type) { + // For compatibility with old apps, don't crash here. + if (mTargetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + Slog.w(mTag, "Window type can not be changed after " + + "the window is added; ignoring change of " + mView); + params.type = mOrigWindowType; + } + } + + if (mSurface.isValid()) { + params.frameNumber = mSurface.getNextFrameNumber(); } } + int relayoutResult = mWindowSession.relayout( mWindow, mSeq, params, (int) (mView.getMeasuredWidth() * appScale + 0.5f), -- cgit v1.2.3