Fix metro clock animation triggers twice when going to AOD
The reason is that we have single source for dozeAmount with flag off
And we have more than one source with flag on, and we'll encounter changing from 1.0 to 1.0, which won't be triggered with flag off from my manual testing
And in AnimationState,
from LS to AOD, newFraction < fraction, we'll return isActive as true, which will trigger animation;
from AOD to LS, newFraction > fraction, we'll return isActive as false. That's why only LS -> AOD will trigger animation twice.
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint STAGING
Bug: 331820776
Test: manual
Change-Id: I910fd8f433be88f23778806c126639d28bf1eb51
diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt
index 8a18efc..70182c1 100644
--- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt
+++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt
@@ -544,7 +544,9 @@
step.copy(value = 1f - step.value)
},
keyguardTransitionInteractor.lockscreenToAodTransition,
- )
+ ).filter {
+ it.transitionState != TransitionState.FINISHED
+ }
.collect { handleDoze(it.value) }
}
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt
index 6a35340..ca55dd8 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt
@@ -330,7 +330,8 @@
TransitionStep(
from = KeyguardState.LOCKSCREEN,
to = KeyguardState.AOD,
- value = 0.4f
+ value = 0.4f,
+ transitionState = TransitionState.RUNNING,
)
yield()