Add more conditions to excluding gesture

When QS is expanding in lockscreen or in split shade, there's no STL
transition, but BrightnessSlider is moving in the screen. This causes
the modifier to send a new rect (with global coordinates) on every
frame.

Instead, restrict this to only exclude gestures when QS is settled.

Test: manual, log calls to modifier lambda
Fixes: 401811481
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Change-Id: I3fc6754dc250524a3a40868a7ad557906a479d85
diff --git a/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt b/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt
index 05a60a6..1c37b8b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt
@@ -746,7 +746,16 @@
                                 Box(
                                     Modifier.systemGestureExclusionInShade(
                                         enabled = {
-                                            layoutState.transitionState is TransitionState.Idle
+                                            /*
+                                             * While we are transitioning into QS (either from QQS
+                                             * or from gone), the global position of the brightness
+                                             * slider will change in every frame. This causes
+                                             * the modifier to send a new gesture exclusion
+                                             * rectangle on every frame. Instead, only apply the
+                                             * modifier when this is settled.
+                                             */
+                                            layoutState.transitionState is TransitionState.Idle &&
+                                                viewModel.isNotTransitioning
                                         }
                                     )
                                 ) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt
index b61fa9c..b7e9c52 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt
@@ -312,6 +312,11 @@
             source = containerViewModel.editModeViewModel.isEditing,
         )
 
+    /** True if we are not in an expansion (from Gone to QQS/QS) animation. */
+    val isNotTransitioning by derivedStateOf {
+        viewTranslationY == 0f && viewAlpha == 1f && constrainedSquishinessFraction == 1f
+    }
+
     private val inFirstPage: Boolean
         get() = inFirstPageViewModel.inFirstPage