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

Commit 129e1a3a authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Adding MSDL feedback to the pattern credential view.

To be consistent with lockscreen bouncer surfaces, the cell pattern
feedback in the credential view also needs to play MSDL haptics.

Test: manual. Verified correct haptics play when dragging over the
  pattern credential view. Verified with the vibrator_manager dumpsys
Bug: 406774575
Flag: com.android.systemui.msdl_feedback
Change-Id: I950b51db70653c33295a007062364c0aa8cb4b8a
parent cda0f42f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import com.android.systemui.biometrics.domain.interactor.promptSelectorInteracto
import com.android.systemui.biometrics.promptInfo
import com.android.systemui.biometrics.shared.model.BiometricModalities
import com.android.systemui.biometrics.shared.model.PromptKind
import com.android.systemui.haptics.msdl.msdlPlayer
import com.android.systemui.kosmos.testScope
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.testKosmos
@@ -50,6 +51,7 @@ class CredentialViewModelTest : SysuiTestCase() {
                PromptCredentialInteractor(dispatcher, promptRepository, credentialInteractor),
                kosmos.shadeInteractor,
                kosmos.promptSelectorInteractor,
                kosmos.msdlPlayer,
            )

        kosmos.testScope.runCurrent()
+5 −0
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ object CredentialPatternViewBinder {

        view.repeatWhenAttached {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                if (com.android.systemui.Flags.msdlFeedback()) {
                    lockPatternView.setExternalHapticsPlayer {
                        viewModel.performPatternDotFeedback()
                    }
                }
                // observe credential validation attempts and submit/cancel buttons
                launch {
                    viewModel.header.collect { header ->
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ import com.android.systemui.biometrics.shared.model.WatchRangingState
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.res.R
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.google.android.msdl.data.model.MSDLToken
import com.google.android.msdl.domain.MSDLPlayer
import javax.inject.Inject
import kotlin.reflect.KClass
import kotlinx.coroutines.flow.Flow
@@ -37,6 +39,7 @@ constructor(
    private val promptCredentialInteractor: PromptCredentialInteractor,
    shadeInteractor: ShadeInteractor,
    private val promptSelectorInteractor: PromptSelectorInteractor,
    private val msdlPlayer: MSDLPlayer,
) {
    /**
     * Whether credential is allowed in the prompt True if bp caller requested credential and
@@ -243,6 +246,8 @@ constructor(
                )
        context.startActivity(intent)
    }

    fun performPatternDotFeedback() = msdlPlayer.playToken(MSDLToken.DRAG_INDICATOR_DISCRETE)
}

private fun Context.asBadCredentialErrorMessage(prompt: BiometricPromptRequest?): String =
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.biometrics.ui.viewmodel
import android.content.applicationContext
import com.android.systemui.biometrics.domain.interactor.promptCredentialInteractor
import com.android.systemui.biometrics.domain.interactor.promptSelectorInteractor
import com.android.systemui.haptics.msdl.msdlPlayer
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.shade.domain.interactor.shadeInteractor
@@ -29,5 +30,6 @@ val Kosmos.credentialViewModel by Fixture {
        promptCredentialInteractor,
        shadeInteractor,
        promptSelectorInteractor,
        msdlPlayer,
    )
}