Loading core/java/android/view/InsetsAnimationControlImpl.java +5 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import static android.view.InsetsState.ISIDE_LEFT; import static android.view.InsetsState.ISIDE_RIGHT; import static android.view.InsetsState.ISIDE_TOP; import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE; import android.annotation.Nullable; import android.graphics.Insets; import android.graphics.Matrix; Loading Loading @@ -76,6 +78,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll private boolean mShownOnFinish; private float mCurrentAlpha = 1.0f; private float mPendingAlpha = 1.0f; @VisibleForTesting(visibility = PACKAGE) public boolean mReadyDispatched; @VisibleForTesting public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, Rect frame, Loading Loading @@ -214,7 +218,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll return; } mCancelled = true; mListener.onCancelled(this); mListener.onCancelled(mReadyDispatched ? this : null); releaseLeashes(); } Loading core/java/android/view/InsetsController.java +1 −4 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_BEHAVIOR_CONT import android.animation.AnimationHandler; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.TypeEvaluator; import android.animation.ValueAnimator; import android.annotation.IntDef; Loading @@ -39,11 +37,9 @@ import android.graphics.Rect; import android.os.CancellationSignal; import android.os.Handler; import android.os.RemoteException; import android.renderscript.Sampler.Value; import android.util.ArraySet; import android.util.Log; import android.util.Pair; import android.util.Property; import android.util.SparseArray; import android.view.InsetsSourceConsumer.ShowResult; import android.view.InsetsState.InternalInsetsType; Loading Loading @@ -1064,6 +1060,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } mViewRoot.mView.dispatchWindowInsetsAnimationStart(animation, bounds); mStartingAnimation = true; controller.mReadyDispatched = true; listener.onReady(controller, types); mStartingAnimation = false; return true; Loading core/java/android/view/WindowInsetsAnimation.java +2 −3 Original line number Diff line number Diff line Loading @@ -110,14 +110,13 @@ public final class WindowInsetsAnimation { * and 1. * </p> * @see #getFraction() for raw fraction. * @return The current interpolated progress of this animation. -1 if interpolator isn't * specified. * @return The current interpolated progress of this animation. */ public float getInterpolatedFraction() { if (mInterpolator != null) { return mInterpolator.getInterpolation(mFraction); } return -1; return mFraction; } /** Loading core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java +18 −2 Original line number Diff line number Diff line Loading @@ -20,14 +20,17 @@ import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.WindowInsets.Type.systemBars; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; 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.doNothing; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading @@ -43,6 +46,8 @@ import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams; import android.view.animation.LinearInterpolator; import android.view.test.InsetsModeSession; import androidx.test.runner.AndroidJUnit4; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; Loading @@ -54,8 +59,6 @@ import org.mockito.MockitoAnnotations; import java.util.List; import androidx.test.runner.AndroidJUnit4; /** * Tests for {@link InsetsAnimationControlImpl}. * Loading Loading @@ -124,6 +127,7 @@ public class InsetsAnimationControlImplTest { new Rect(0, 0, 500, 500), mInsetsState, mMockListener, systemBars(), mMockController, 10 /* durationMs */, new LinearInterpolator(), 0 /* animationType */); mController.mReadyDispatched = true; } @Test Loading Loading @@ -204,6 +208,18 @@ public class InsetsAnimationControlImplTest { assertTrue(mController.isCancelled()); verify(mMockListener).onCancelled(mController); mController.finish(true /* shown */); verify(mMockListener, never()).onFinished(any()); } @Test public void testCancelled_beforeReadyDispatched() { mController.mReadyDispatched = false; mController.cancel(); assertFalse(mController.isReady()); assertFalse(mController.isFinished()); assertTrue(mController.isCancelled()); verify(mMockListener).onCancelled(null); verify(mMockListener, never()).onFinished(any()); } private void assertPosition(Matrix m, Rect original, Rect transformed) { Loading Loading
core/java/android/view/InsetsAnimationControlImpl.java +5 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import static android.view.InsetsState.ISIDE_LEFT; import static android.view.InsetsState.ISIDE_RIGHT; import static android.view.InsetsState.ISIDE_TOP; import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE; import android.annotation.Nullable; import android.graphics.Insets; import android.graphics.Matrix; Loading Loading @@ -76,6 +78,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll private boolean mShownOnFinish; private float mCurrentAlpha = 1.0f; private float mPendingAlpha = 1.0f; @VisibleForTesting(visibility = PACKAGE) public boolean mReadyDispatched; @VisibleForTesting public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, Rect frame, Loading Loading @@ -214,7 +218,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll return; } mCancelled = true; mListener.onCancelled(this); mListener.onCancelled(mReadyDispatched ? this : null); releaseLeashes(); } Loading
core/java/android/view/InsetsController.java +1 −4 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_BEHAVIOR_CONT import android.animation.AnimationHandler; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.TypeEvaluator; import android.animation.ValueAnimator; import android.annotation.IntDef; Loading @@ -39,11 +37,9 @@ import android.graphics.Rect; import android.os.CancellationSignal; import android.os.Handler; import android.os.RemoteException; import android.renderscript.Sampler.Value; import android.util.ArraySet; import android.util.Log; import android.util.Pair; import android.util.Property; import android.util.SparseArray; import android.view.InsetsSourceConsumer.ShowResult; import android.view.InsetsState.InternalInsetsType; Loading Loading @@ -1064,6 +1060,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } mViewRoot.mView.dispatchWindowInsetsAnimationStart(animation, bounds); mStartingAnimation = true; controller.mReadyDispatched = true; listener.onReady(controller, types); mStartingAnimation = false; return true; Loading
core/java/android/view/WindowInsetsAnimation.java +2 −3 Original line number Diff line number Diff line Loading @@ -110,14 +110,13 @@ public final class WindowInsetsAnimation { * and 1. * </p> * @see #getFraction() for raw fraction. * @return The current interpolated progress of this animation. -1 if interpolator isn't * specified. * @return The current interpolated progress of this animation. */ public float getInterpolatedFraction() { if (mInterpolator != null) { return mInterpolator.getInterpolation(mFraction); } return -1; return mFraction; } /** Loading
core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java +18 −2 Original line number Diff line number Diff line Loading @@ -20,14 +20,17 @@ import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.WindowInsets.Type.systemBars; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; 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.doNothing; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading @@ -43,6 +46,8 @@ import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams; import android.view.animation.LinearInterpolator; import android.view.test.InsetsModeSession; import androidx.test.runner.AndroidJUnit4; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; Loading @@ -54,8 +59,6 @@ import org.mockito.MockitoAnnotations; import java.util.List; import androidx.test.runner.AndroidJUnit4; /** * Tests for {@link InsetsAnimationControlImpl}. * Loading Loading @@ -124,6 +127,7 @@ public class InsetsAnimationControlImplTest { new Rect(0, 0, 500, 500), mInsetsState, mMockListener, systemBars(), mMockController, 10 /* durationMs */, new LinearInterpolator(), 0 /* animationType */); mController.mReadyDispatched = true; } @Test Loading Loading @@ -204,6 +208,18 @@ public class InsetsAnimationControlImplTest { assertTrue(mController.isCancelled()); verify(mMockListener).onCancelled(mController); mController.finish(true /* shown */); verify(mMockListener, never()).onFinished(any()); } @Test public void testCancelled_beforeReadyDispatched() { mController.mReadyDispatched = false; mController.cancel(); assertFalse(mController.isReady()); assertFalse(mController.isFinished()); assertTrue(mController.isCancelled()); verify(mMockListener).onCancelled(null); verify(mMockListener, never()).onFinished(any()); } private void assertPosition(Matrix m, Rect original, Rect transformed) { Loading