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

Commit 32676912 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Only playing non-msdl shortcut haptics with user long-presses.

This change makes sure that non-MSDL haptics only play when the user
long-presses a shortcut in lockscreen. This avoids strange haptics from
playing when the activated history of the affordance changes.

Test: Unit tests
Test: manual. Turned off com.android.systemui.msdl_feedback and verfied
  that activated and deactivated haptics only play when long-pressing
  lockscreen shortcuts.
Test: manual. Verified the above with flexiglass on.
Flag: com.android.systemui.msdl_feedback
Bug: 410576808
Change-Id: Ib379fd948c2a77ebafdfc2bddb75821c5bffba49
parent a453f06d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -136,9 +136,9 @@ class KeyguardQuickAffordanceHapticViewModelTest : SysuiTestCase() {
        }

    private fun toggleQuickAffordance(on: Boolean) {
        underTest.onQuickAffordanceLongPress()
        underTest.onQuickAffordanceLongPress(isActivated = false)
        underTest.updateActivatedHistory(!on)
        underTest.onQuickAffordanceLongPress()
        underTest.onQuickAffordanceLongPress(isActivated = true)
        underTest.updateActivatedHistory(on)
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ constructor(
            }

            if (viewModel.configKey != null) {
                hapticsViewModel.onQuickAffordanceLongPress()
                hapticsViewModel.onQuickAffordanceLongPress(viewModel.isActivated)
                viewModel.onClicked(
                    KeyguardQuickAffordanceViewModel.OnClickedParameters(
                        configKey = viewModel.configKey,
+10 −7
Original line number Diff line number Diff line
@@ -40,19 +40,22 @@ constructor(private val msdlPlayer: MSDLPlayer, private val vibratorHelper: Vibr

        if (Flags.msdlFeedback()) {
            playMSDLToggleHaptics(toggleOn, toggleOff)
        } else {
            vibratorHelper.vibrate(
        }
    }

    fun onQuickAffordanceLongPress(isActivated: Boolean) {
        longPressed = true
        if (!Flags.msdlFeedback()) {
            // Without MSDL, we need to play haptics on long-press instead of when the activated
            // history updates.
            val vibration =
                if (isActivated) {
                    KeyguardBottomAreaVibrations.Activated
                } else {
                    KeyguardBottomAreaVibrations.Deactivated
                }
            )
        }
            vibratorHelper.vibrate(vibration)
        }

    fun onQuickAffordanceLongPress() {
        longPressed = true
    }

    fun onQuickAffordanceClick() {