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

Commit 09df71e3 authored by Tiger Huang's avatar Tiger Huang
Browse files

Don't cancel animation if the previous insets hint was NONE

Before IME is visible, the insets hint of IME would be NONE. This
should not be considered as the side changing of a leash.

Fix: 387933048
Flag: EXEMPT bugfix
Test: atest ImeInsetsControllerTest#testChangeSizeWhileControlling
Test: Click the fullscreen button of a YouTube video in 3-button
      navigation mode, make sure nav bar is not visible during the
      rotation animation.
Change-Id: I7de1192da36c203708e54904948ec70cf2820b25
parent 20cdf105
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]);
        });

    }