[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
This commit is contained in:
@@ -39,15 +39,35 @@ class UnfoldRemoteFilterTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onTransitionProgress_withInterval_propagated() {
|
||||
runOnMainThreadWithInterval(
|
||||
{ progressProvider.onTransitionStarted() },
|
||||
{ progressProvider.onTransitionProgress(0.5f) }
|
||||
)
|
||||
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.8f) }
|
||||
)
|
||||
|
||||
listener.assertLastProgress(0.8f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onTransitionEnded_propagated() {
|
||||
runOnMainThreadWithInterval(
|
||||
|
||||
@@ -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) {
|
||||
springAnimation.animateToFinalPosition(progress)
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user