NSSL - Only apply y translation when on keyguard

... and not when the shade is expanded at all. This ensures the
correct collpase animation runs.

Fixes: 319499695
Test: atest SharedNotificationContainerViewModelTest
Flag: ACONFIG com.android.systemui.keyguard_shade_migration_nssl
DEVELOPMENT

Change-Id: I4eee27b6309c9104f145b133b92a3d20f8d254b6
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt
index 5ee38be..a48fb45 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt
@@ -240,13 +240,13 @@
      */
     val translationY: Flow<Float> =
         combine(
-            isOnLockscreen,
+            isOnLockscreenWithoutShade,
             merge(
                 keyguardInteractor.keyguardTranslationY,
                 occludedToLockscreenTransitionViewModel.lockscreenTranslationY,
             )
-        ) { isOnLockscreen, translationY ->
-            if (isOnLockscreen) {
+        ) { isOnLockscreenWithoutShade, translationY ->
+            if (isOnLockscreenWithoutShade) {
                 translationY
             } else {
                 0f
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt
index 20020f2..96bef10 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt
@@ -408,6 +408,46 @@
         }
 
     @Test
+    fun translationYUpdatesOnKeyguard() =
+        testScope.runTest {
+            val translationY by collectLastValue(underTest.translationY)
+
+            configurationRepository.setDimensionPixelSize(
+                R.dimen.keyguard_translate_distance_on_swipe_up,
+                -100
+            )
+            configurationRepository.onAnyConfigurationChange()
+
+            // legacy expansion means the user is swiping up, usually for the bouncer
+            shadeRepository.setLegacyShadeExpansion(0.5f)
+
+            showLockscreen()
+
+            // The translation values are negative
+            assertThat(translationY).isLessThan(0f)
+        }
+
+    @Test
+    fun translationYDoesNotUpdateWhenShadeIsExpanded() =
+        testScope.runTest {
+            val translationY by collectLastValue(underTest.translationY)
+
+            configurationRepository.setDimensionPixelSize(
+                R.dimen.keyguard_translate_distance_on_swipe_up,
+                -100
+            )
+            configurationRepository.onAnyConfigurationChange()
+
+            // legacy expansion means the user is swiping up, usually for the bouncer but also for
+            // shade collapsing
+            shadeRepository.setLegacyShadeExpansion(0.5f)
+
+            showLockscreenWithShadeExpanded()
+
+            assertThat(translationY).isEqualTo(0f)
+        }
+
+    @Test
     fun updateBounds_fromKeyguardRoot() =
         testScope.runTest {
             val bounds by collectLastValue(underTest.bounds)