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

Commit f0a236a4 authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Don't cancel animation if the previous insets hint was NONE" into main

parents f02aead5 09df71e3
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.internal.annotations.VisibleForTesting.Visibility.PACK

import android.annotation.IntDef;
import android.annotation.Nullable;
import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.Rect;
@@ -168,7 +169,8 @@ public class InsetsSourceConsumer {
            // Reset the applier to the default one which has the most lightweight implementation.
            setSurfaceParamsApplier(InsetsAnimationControlRunner.SurfaceParamsApplier.DEFAULT);
        } else {
            if (lastControl != null && InsetsSource.getInsetSide(lastControl.getInsetsHint())
            if (lastControl != null && !Insets.NONE.equals(lastControl.getInsetsHint())
                    && InsetsSource.getInsetSide(lastControl.getInsetsHint())
                            != InsetsSource.getInsetSide(control.getInsetsHint())) {
                // The source has been moved to a different side. The coordinates are stale.
                // Canceling existing animation if there is any.
+12 −6
Original line number Diff line number Diff line
@@ -123,15 +123,21 @@ public class InsetsSourceConsumerTest {
    @Test
    public void testSetControl_cancelAnimation() {
        InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
            final InsetsSourceControl newControl = new InsetsSourceControl(mConsumer.getControl());
            final int[] cancelTypes = {0};

            // Change the side of the insets hint.
            newControl.setInsetsHint(Insets.of(0, 0, 0, 100));
            // Change the side of the insets hint from NONE to BOTTOM.
            final InsetsSourceControl newControl1 = new InsetsSourceControl(mConsumer.getControl());
            newControl1.setInsetsHint(Insets.of(0, 0, 0, 100));
            mConsumer.setControl(newControl1, new int[1], new int[1], cancelTypes, new int[1]);

            int[] cancelTypes = {0};
            mConsumer.setControl(newControl, new int[1], new int[1], cancelTypes, new int[1]);
            assertEquals("The animation must not be cancelled", 0, cancelTypes[0]);

            assertEquals(statusBars(), cancelTypes[0]);
            // Change the side of the insets hint from BOTTOM to TOP.
            final InsetsSourceControl newControl2 = new InsetsSourceControl(mConsumer.getControl());
            newControl2.setInsetsHint(Insets.of(0, 100, 0, 0));
            mConsumer.setControl(newControl2, new int[1], new int[1], cancelTypes, new int[1]);

            assertEquals("The animation must be cancelled", statusBars(), cancelTypes[0]);
        });

    }