From 79e8d1799d360237997486c627eb1085b9aea30d Mon Sep 17 00:00:00 2001 From: Tomasz Mikolajewski Date: Tue, 21 Nov 2017 11:21:42 +0900 Subject: [PATCH] Speed up initiating resizing. This CL effectively starts resizing on mouse down click on the window edges by forcing reporting a resize before any bounds changes. As a result the app will kick in the backdrop renderer before configuration change applies, so before a potential activity restart. Test: Try to resize Play store quickly. Should resize smoother. Bug: 64327032 Change-Id: I668ea9f4c264e18ddee3ed9e8d03365631f10417 --- .../com/android/server/wm/TaskPositioner.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/services/core/java/com/android/server/wm/TaskPositioner.java b/services/core/java/com/android/server/wm/TaskPositioner.java index 12f6b5a20b474..650d6a4653b56 100644 --- a/services/core/java/com/android/server/wm/TaskPositioner.java +++ b/services/core/java/com/android/server/wm/TaskPositioner.java @@ -399,6 +399,27 @@ class TaskPositioner implements DimLayer.DimLayerUser { mStartOrientationWasLandscape = startBounds.width() >= startBounds.height(); mWindowOriginalBounds.set(startBounds); + // Notify the app that resizing has started, even though we haven't received any new + // bounds yet. This will guarantee that the app starts the backdrop renderer before + // configuration changes which could cause an activity restart. + if (mResizing) { + synchronized (mService.mWindowMap) { + notifyMoveLocked(startX, startY); + } + + // Perform the resize on the WMS handler thread when we don't have the WMS lock held + // to ensure that we don't deadlock WMS and AMS. Note that WindowPositionerEventReceiver + // callbacks are delivered on the same handler so this initial resize is always + // guaranteed to happen before subsequent drag resizes. + mService.mH.post(() -> { + try { + mService.mActivityManager.resizeTask( + mTask.mTaskId, startBounds, RESIZE_MODE_USER_FORCED); + } catch (RemoteException e) { + } + }); + } + // Make sure we always have valid drag bounds even if the drag ends before any move events // have been handled. mWindowDragBounds.set(startBounds);