Loading core/java/android/view/InsetsSourceConsumer.java +4 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. Loading core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java +12 −6 Original line number Diff line number Diff line Loading @@ -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]); }); } Loading Loading
core/java/android/view/InsetsSourceConsumer.java +4 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. Loading
core/tests/coretests/src/android/view/InsetsSourceConsumerTest.java +12 −6 Original line number Diff line number Diff line Loading @@ -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]); }); } Loading