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

Commit b3349228 authored by Brad Hinegardner's avatar Brad Hinegardner
Browse files

When quick affordance enabled and device screen turns on or off, vibration always happens

Bug: 264918482
Test: manual - shortcut off, toggle it on, observe vibration
Test: manual - shortcut on, turn screen on and off, observe no vibration
Test: manual - shortcut off, turn screen on and off, observe no vibration
Test: manual - shortcut on, toggle it off, observe vibration
Change-Id: I281ee0b3d64d7861c504cb03121549828b5682d2
parent 9e732e64
Loading
Loading
Loading
Loading
+7 −25
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordanceViewMod
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.statusbar.VibratorHelper
import com.android.systemui.util.kotlin.pairwise
import kotlin.math.pow
import kotlin.math.sqrt
import kotlin.time.Duration.Companion.milliseconds
@@ -128,18 +127,6 @@ object KeyguardBottomAreaViewBinder {
                    }
                }

                launch {
                    viewModel.startButton
                        .map { it.isActivated }
                        .pairwise()
                        .collect { (prev, next) ->
                            when {
                                !prev && next -> vibratorHelper?.vibrate(Vibrations.Activated)
                                prev && !next -> vibratorHelper?.vibrate(Vibrations.Deactivated)
                            }
                        }
                }

                launch {
                    viewModel.endButton.collect { buttonModel ->
                        updateButton(
@@ -152,18 +139,6 @@ object KeyguardBottomAreaViewBinder {
                    }
                }

                launch {
                    viewModel.endButton
                        .map { it.isActivated }
                        .pairwise()
                        .collect { (prev, next) ->
                            when {
                                !prev && next -> vibratorHelper?.vibrate(Vibrations.Activated)
                                prev && !next -> vibratorHelper?.vibrate(Vibrations.Deactivated)
                            }
                        }
                }

                launch {
                    viewModel.isOverlayContainerVisible.collect { isVisible ->
                        overlayContainer.visibility =
@@ -383,6 +358,13 @@ object KeyguardBottomAreaViewBinder {
                                .setDuration(longPressDurationMs)
                                .withEndAction {
                                    view.setOnClickListener {
                                        vibratorHelper?.vibrate(
                                            if (viewModel.isActivated) {
                                                Vibrations.Activated
                                            } else {
                                                Vibrations.Deactivated
                                            }
                                        )
                                        viewModel.onClicked(
                                            KeyguardQuickAffordanceViewModel.OnClickedParameters(
                                                configKey = viewModel.configKey,