diff options
author | AndrĂ¡s Kurucz <kurucz@google.com> | 2023-04-14 16:49:31 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-04-17 20:13:30 +0000 |
commit | 6c52d0e7bbd34e1b3eb499c8cdca6e608343d81e (patch) | |
tree | a95a803e5ffa3e39930dc7eea483d56b9b642d58 | |
parent | 41b888f32c83452f1401d6febc0176dacba10819 (diff) | |
download | base-6c52d0e7bbd34e1b3eb499c8cdca6e608343d81e.tar.gz |
Reset NSSL translationY after a transision gets cancelled
We update the translationY of the NSSL upon multiple transitions. If the
Occluded -> LockScreen transition is cancelled, there is no other
transition that is taking over. It causes the NSSL to get stuck with some negative translateY value. This caused the Notifications and the NotificationShelf to be shifted slightly upwards.
This fix resets the translation to 0 if the transition was interrupted
and not completed successfully.
Fixes: 273591201
Test: atest OccludedToLockscreenTransitionViewModelTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3a23e91c1a76f22ac0da52e942e405525c539b2a)
Merged-In: If0c162a7f1b8a2cf3d261692f5ce333331c36a7b
Change-Id: If0c162a7f1b8a2cf3d261692f5ce333331c36a7b
2 files changed, 16 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModel.kt index 5770f3ee8876..ddce516a0fb2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModel.kt @@ -47,6 +47,7 @@ constructor( duration = TO_LOCKSCREEN_DURATION, onStep = { value -> -translatePx + value * translatePx }, interpolator = EMPHASIZED_DECELERATE, + onCancel = { 0f }, ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModelTest.kt index 0c4e84521a36..efa5f0c966e3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModelTest.kt @@ -92,6 +92,21 @@ class OccludedToLockscreenTransitionViewModelTest : SysuiTestCase() { job.cancel() } + @Test + fun lockscreenTranslationYResettedAfterJobCancelled() = + runTest(UnconfinedTestDispatcher()) { + val values = mutableListOf<Float>() + + val pixels = 100 + val job = + underTest.lockscreenTranslationY(pixels).onEach { values.add(it) }.launchIn(this) + repository.sendTransitionStep(step(0.5f, TransitionState.CANCELED)) + + assertThat(values.last()).isEqualTo(0f) + + job.cancel() + } + private fun step( value: Float, state: TransitionState = TransitionState.RUNNING |