From 717b2a58eff1442dc845dae312bd7d0de868d645 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 19 May 2021 18:49:53 +0800 Subject: [PATCH] Use current rotation for snapshot of canceling fixed rotation The display rotation doesn't change in the case (the app is rotated). So use the identity matrix for the snapshot surface. Also fix a potential case of app freeze timeout: (e.g. from AR#onCancelFixedRotationTransform) 1. Previous states: allDrawn=true, mLastAllDrawn=true. 2. Request redraw: AR#clearAllDrawn -> allDrawn=false, mLastAllDrawn=true 3. App reported drawn: AR#updateAllDrawn -> allDrawn=true, mLastAllDrawn=true 4. AR#checkAppWindowsReadyToShow skipped by allDrawn==mLastAllDrawn that missed to unfreeze even allDrawn was changed to true. Bug: 188615885 Test: Auto rotation enabled. Put device in landscape. Launch a rotatable app from portrait launcher and rotate the device to portrait immediately. The snapshot should keep the same rotation for animation. Change-Id: If9fe8e317669d3d9ef57af9acdbdbf53cd575efe --- .../java/com/android/server/wm/ActivityRecord.java | 1 + .../android/server/wm/ScreenRotationAnimation.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index b55e653eb1394..6d2b2d3c7bd4c 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4213,6 +4213,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A void clearAllDrawn() { allDrawn = false; + mLastAllDrawn = false; } /** diff --git a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java index d67a0d3716755..50749a961b270 100644 --- a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java +++ b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java @@ -253,7 +253,16 @@ class ScreenRotationAnimation { ProtoLog.i(WM_SHOW_SURFACE_ALLOC, " FREEZE %s: CREATE", mScreenshotLayer); - setRotation(t, realOriginalRotation); + if (originalRotation == realOriginalRotation) { + setRotation(t, realOriginalRotation); + } else { + // If the given original rotation is different from real original display rotation, + // this is playing non-zero degree rotation animation without display rotation change, + // so the snapshot doesn't need to be transformed. + mCurRotation = realOriginalRotation; + mSnapshotInitialMatrix.reset(); + setRotationTransform(t, mSnapshotInitialMatrix); + } t.apply(); }