Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce1457f1 authored by Tony Huang's avatar Tony Huang
Browse files

Fix screnshot null during rotation

We will cancent screenshot animation if it still running on next
time onResized, but we should cancel it before checking screenshot
null because we will release it on animation end.

Fix: 271797152
Test: manual
Test: pass existing tests
Change-Id: Iaac49415d90906de4c86e21f7cd3e62a92bbde94
parent b85665b3
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -247,11 +247,11 @@ public class SplitDecorManager extends WindowlessWindowManager {

    /** Stops showing resizing hint. */
    public void onResized(SurfaceControl.Transaction t, Runnable animFinishedCallback) {
        if (mScreenshot != null) {
        if (mScreenshotAnimator != null && mScreenshotAnimator.isRunning()) {
            mScreenshotAnimator.cancel();
        }

        if (mScreenshot != null) {
            t.setPosition(mScreenshot, mOffsetX, mOffsetY);

            final SurfaceControl.Transaction animT = new SurfaceControl.Transaction();
@@ -321,6 +321,10 @@ public class SplitDecorManager extends WindowlessWindowManager {
    /** Screenshot host leash and attach on it if meet some conditions */
    public void screenshotIfNeeded(SurfaceControl.Transaction t) {
        if (!mShown && mIsResizing && !mOldBounds.equals(mResizingBounds)) {
            if (mScreenshotAnimator != null && mScreenshotAnimator.isRunning()) {
                mScreenshotAnimator.cancel();
            }

            mTempRect.set(mOldBounds);
            mTempRect.offsetTo(0, 0);
            mScreenshot = ScreenshotUtils.takeScreenshot(t, mHostLeash, mTempRect,
@@ -333,6 +337,10 @@ public class SplitDecorManager extends WindowlessWindowManager {
        if (screenshot == null || !screenshot.isValid()) return;

        if (!mShown && mIsResizing && !mOldBounds.equals(mResizingBounds)) {
            if (mScreenshotAnimator != null && mScreenshotAnimator.isRunning()) {
                mScreenshotAnimator.cancel();
            }

            mScreenshot = screenshot;
            t.reparent(screenshot, mHostLeash);
            t.setLayer(screenshot, Integer.MAX_VALUE - 1);