Skip to content

Commit 6c52d0e

Browse files
András KuruczAndroid Build Coastguard Worker
authored andcommitted
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
1 parent 41b888f commit 6c52d0e

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ constructor(
4747
duration = TO_LOCKSCREEN_DURATION,
4848
onStep = { value -> -translatePx + value * translatePx },
4949
interpolator = EMPHASIZED_DECELERATE,
50+
onCancel = { 0f },
5051
)
5152
}
5253

packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/OccludedToLockscreenTransitionViewModelTest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ class OccludedToLockscreenTransitionViewModelTest : SysuiTestCase() {
9292
job.cancel()
9393
}
9494

95+
@Test
96+
fun lockscreenTranslationYResettedAfterJobCancelled() =
97+
runTest(UnconfinedTestDispatcher()) {
98+
val values = mutableListOf<Float>()
99+
100+
val pixels = 100
101+
val job =
102+
underTest.lockscreenTranslationY(pixels).onEach { values.add(it) }.launchIn(this)
103+
repository.sendTransitionStep(step(0.5f, TransitionState.CANCELED))
104+
105+
assertThat(values.last()).isEqualTo(0f)
106+
107+
job.cancel()
108+
}
109+
95110
private fun step(
96111
value: Float,
97112
state: TransitionState = TransitionState.RUNNING

0 commit comments

Comments
 (0)