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

Commit a495a4e1 authored by Nick Chameyev's avatar Nick Chameyev
Browse files

[Unfold animation] Do not animate first progress value in remote provider

Updates unfold remote filter to start animating
values only after the first progress event has received.

Currently the default value is 1f and when
unfolding we might see launcher animating from progress
1f to the current progress and then back to 1f.

Bug: 271099882
Test: atest com.android.systemui.unfold.progress.UnfoldRemoteFilterTest
Test: manual testing fold/unfold with removed black overlay
Test: check that laucher progress perfetto trace doesn't have a jump
Change-Id: I4880d19034cdfd91faebf754939d7906c813a315
parent 39421eea
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -39,13 +39,33 @@ class UnfoldRemoteFilterTest : SysuiTestCase() {
    }

    @Test
    fun onTransitionProgress_withInterval_propagated() {
    fun onTransitionProgress_firstProgressEvent_propagatedImmediately() {
        progressProvider.onTransitionStarted()
        progressProvider.onTransitionProgress(0.5f)

        listener.assertLastProgress(0.5f)
    }

    @Test
    fun onTransitionProgress_secondProgressEvent_isNotPropagatedImmediately() =
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            progressProvider.onTransitionStarted()
            progressProvider.onTransitionProgress(0.5f)
            progressProvider.onTransitionProgress(0.8f)

            // 0.8f should be set only later, after the animation
            listener.assertLastProgress(0.5f)
        }

    @Test
    fun onTransitionProgress_severalProgressEventsWithInterval_propagated() {
        runOnMainThreadWithInterval(
            { progressProvider.onTransitionStarted() },
            { progressProvider.onTransitionProgress(0.5f) }
            { progressProvider.onTransitionProgress(0.5f) },
            { progressProvider.onTransitionProgress(0.8f) }
        )

        listener.assertLastProgress(0.5f)
        listener.assertLastProgress(0.8f)
    }

    @Test
+12 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ class UnfoldRemoteFilter(
        }

    private var inProgress = false
    private var receivedProgressEvent = false

    private var processedProgress: Float = 1.0f
        set(newProgress) {
@@ -54,7 +55,16 @@ class UnfoldRemoteFilter(
    override fun onTransitionProgress(progress: Float) {
        logCounter({ "$TAG#plain_remote_progress" }, progress)
        if (inProgress) {
            if (receivedProgressEvent) {
                // We have received at least one progress event, animate from the previous
                // progress to the current
                springAnimation.animateToFinalPosition(progress)
            } else {
                // This is the first progress event after starting the animation, send it
                // straightaway and set the spring value without animating it
                processedProgress = progress
                receivedProgressEvent = true
            }
        } else {
            Log.e(TAG, "Progress received while not in progress.")
        }
@@ -62,6 +72,7 @@ class UnfoldRemoteFilter(

    override fun onTransitionFinished() {
        inProgress = false
        receivedProgressEvent = false
        listener.onTransitionFinished()
    }