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

Commit 38448827 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Automerger Merge Worker
Browse files

Merge "Fix missing finish callback to fix running animation leak" into rvc-dev...

Merge "Fix missing finish callback to fix running animation leak" into rvc-dev am: 526632d1 am: d49d6f50 am: 2dfb499d am: 159b76cd

Change-Id: Icbeea792b5645981cf32b839fd87a4176676f044
parents 1573d487 159b76cd
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -140,7 +140,12 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll

    @Override
    public void setInsetsAndAlpha(Insets insets, float alpha, float fraction) {
        if (mFinished) {
        setInsetsAndAlpha(insets, alpha, fraction, false /* allowWhenFinished */);
    }

    private void setInsetsAndAlpha(Insets insets, float alpha, float fraction,
            boolean allowWhenFinished) {
        if (!allowWhenFinished && mFinished) {
            throw new IllegalStateException(
                    "Can't change insets on an animation that is finished.");
        }
@@ -201,8 +206,9 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
            return;
        }
        mShownOnFinish = shown;
        setInsetsAndAlpha(shown ? mShownInsets : mHiddenInsets, 1f /* alpha */, 1f /* fraction */);
        mFinished = true;
        setInsetsAndAlpha(shown ? mShownInsets : mHiddenInsets, 1f /* alpha */, 1f /* fraction */,
                true /* allowWhenFinished */);
        mListener.onFinished(this);
    }

+17 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -222,6 +223,22 @@ public class InsetsAnimationControlImplTest {
        verify(mMockListener, never()).onFinished(any());
    }

    @Test
    public void testFinish_immediately() {
        when(mMockController.getState()).thenReturn(mInsetsState);
        doAnswer(invocation -> {
            mController.applyChangeInsets(mInsetsState);
            return null;
        }).when(mMockController).scheduleApplyChangeInsets();
        mController.finish(true /* shown */);
        assertEquals(Insets.of(0, 100, 100, 0), mController.getCurrentInsets());
        verify(mMockController).notifyFinished(eq(mController), eq(true /* shown */));
        assertFalse(mController.isReady());
        assertTrue(mController.isFinished());
        assertFalse(mController.isCancelled());
        verify(mMockListener).onFinished(mController);
    }

    private void assertPosition(Matrix m, Rect original, Rect transformed) {
        RectF rect = new RectF(original);
        rect.offsetTo(0, 0);
+0 −1
Original line number Diff line number Diff line
@@ -367,7 +367,6 @@ class InsetsPolicy {
        @Override
        protected void onAnimationFinish() {
            super.onAnimationFinish();
            mControlCallbacks.mAnimationControl.finish(mAnimatingShown);
            DisplayThread.getHandler().post(mFinishCallback);
        }