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

Commit 9991ab22 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Allowing state logic to progress from terminal states on touch down.

Action down events can now progress from terminal states (CLICK,
LONG_CLICK). In case tile updates and animations do not reset the state,
a new action down will not be unblocked by the terminal states.

Test: atest SystemUiRoboTests:QSLongPressEffectTest
Flag: com.android.systemui.quick_settings_visual_haptics_longpress
Bug: 353890656
Change-Id: I2194b2adab5e449a14bb0f12a9bcd99a4bc126ca
parent 006496c2
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -111,6 +111,26 @@ class QSLongPressEffectTest : SysuiTestCase() {
        assertThat(longPressEffect.state).isEqualTo(QSLongPressEffect.State.TIMEOUT_WAIT)
    }

    @Test
    fun onActionDown_whileClicked_startsWait() =
        testWhileInState(QSLongPressEffect.State.CLICKED) {
            // GIVEN an action down event occurs
            longPressEffect.handleActionDown()

            // THEN the effect moves to the TIMEOUT_WAIT state
            assertThat(longPressEffect.state).isEqualTo(QSLongPressEffect.State.TIMEOUT_WAIT)
        }

    @Test
    fun onActionDown_whileLongClicked_startsWait() =
        testWhileInState(QSLongPressEffect.State.LONG_CLICKED) {
            // GIVEN an action down event occurs
            longPressEffect.handleActionDown()

            // THEN the effect moves to the TIMEOUT_WAIT state
            assertThat(longPressEffect.state).isEqualTo(QSLongPressEffect.State.TIMEOUT_WAIT)
        }

    @Test
    fun onActionCancel_whileWaiting_goesIdle() =
        testWhileInState(QSLongPressEffect.State.TIMEOUT_WAIT) {
+5 −1
Original line number Diff line number Diff line
@@ -107,7 +107,11 @@ constructor(
    fun handleActionDown() {
        logEvent(qsTile?.tileSpec, state, "action down received")
        when (state) {
            State.IDLE -> {
            State.IDLE,
            // ACTION_DOWN typically only happens in State.IDLE but including CLICKED and
            // LONG_CLICKED just to be safe`b
            State.CLICKED,
            State.LONG_CLICKED -> {
                setState(State.TIMEOUT_WAIT)
            }
            State.RUNNING_BACKWARDS_FROM_UP,