Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0203e7bf authored by Behnam Heydarshahi's avatar Behnam Heydarshahi
Browse files

Set qs expansion to zero on overscroll

This prevents a scence transition from QQS to QS when overscrolling.

Test: atest QSFragmentComposeViewModelTest
Bug: 414346597
Flag: com.android.systemui.no_expansion_on_overscroll
Change-Id: Ic3d72ae44ec1588edb5bcef00f9d4170f227e434
parent d00f1fb9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -285,6 +285,18 @@ flag {
    }
}

flag {
   name: "no_expansion_on_overscroll"
   namespace: "systemui"
   description: "Enable the fix where QS Expansion is set to zero on overscroll. This should"
        "prevent unnecessary work and remove jank when overscrolling."
   bug: "414346597"
  metadata {
      purpose: PURPOSE_BUGFIX
  }
}


flag {
   name: "flashlight_strength"
   namespace: "systemui"
+35 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper.RunWithLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.Flags.FLAG_QS_COMPOSE_FRAGMENT_EARLY_EXPANSION
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
import com.android.systemui.coroutines.collectLastValue
@@ -77,6 +78,40 @@ class QSFragmentComposeViewModelTest : AbstractQSFragmentComposeViewModelTest()
            }
        }

    @Test
    @EnableFlags(Flags.FLAG_NO_EXPANSION_ON_OVERSCROLL)
    fun qsExpansionValueChanges_whenOverScrolling_zeroExpansionState() =
        with(kosmos) {
            testScope.testWithinLifecycle {
                underTest.isStackScrollerOverscrolling = true
                underTest.setQsExpansionValue(0f)
                assertThat(underTest.expansionState.progress).isEqualTo(0f)

                underTest.setQsExpansionValue(0.3f)
                assertThat(underTest.expansionState.progress).isEqualTo(0f)

                underTest.setQsExpansionValue(1f)
                assertThat(underTest.expansionState.progress).isEqualTo(0f)
            }
        }

    @Test
    @DisableFlags(Flags.FLAG_NO_EXPANSION_ON_OVERSCROLL)
    fun qsExpansionValueChanges_whenOverScrolling_nonZeroExpansionState_withFlagOff() =
        with(kosmos) {
            testScope.testWithinLifecycle {
                underTest.isStackScrollerOverscrolling = true
                underTest.setQsExpansionValue(0f)
                assertThat(underTest.expansionState.progress).isEqualTo(0f)

                underTest.setQsExpansionValue(0.3f)
                assertThat(underTest.expansionState.progress).isEqualTo(0.3f)

                underTest.setQsExpansionValue(1f)
                assertThat(underTest.expansionState.progress).isEqualTo(1f)
            }
        }

    @Test
    fun qsExpansionValueChanges_clamped() =
        with(kosmos) {
+4 −1
Original line number Diff line number Diff line
@@ -219,7 +219,10 @@ constructor(
        if (forceQs) {
            QSExpansionState(1f)
        } else {
            QSExpansionState(qsExpansion.coerceIn(if (isQsExpanded) EARLY_EXPANSION else 0f, 1f))
            QSExpansionState(
                if (Flags.noExpansionOnOverscroll() && isStackScrollerOverscrolling) 0f
                else qsExpansion.coerceIn(if (isQsExpanded) EARLY_EXPANSION else 0f, 1f)
            )
        }
    }