Merge changes from topic "cherrypicker-L01600000961894751:N92400001386673229" into udc-d1-dev am: 6ca41f39ff

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24025668

Change-Id: I84a885c1385c2a717745f3435765ac0254ca2f2d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2023-07-12 04:02:16 +00:00
committed by Automerger Merge Worker
2 changed files with 19 additions and 12 deletions

View File

@@ -372,7 +372,9 @@ constructor(
AuthBiometricView.STATE_AUTHENTICATED
}
vibrator.success(modality)
if (!needsUserConfirmation) {
vibrator.success(modality)
}
messageJob?.cancel()
messageJob = null
@@ -418,6 +420,8 @@ constructor(
_message.value = PromptMessage.Empty
_legacyState.value = AuthBiometricView.STATE_AUTHENTICATED
vibrator.success(authState.authenticatedModality)
messageJob?.cancel()
messageJob = null
}

View File

@@ -49,6 +49,7 @@ import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.mockito.Mock
import org.mockito.Mockito.never
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnit
@@ -131,20 +132,22 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
}
@Test
fun plays_haptic_on_authenticated() = runGenericTest {
viewModel.showAuthenticated(testCase.authenticatedModality, 1000L)
fun play_haptic_on_confirm_when_confirmation_required_otherwise_on_authenticated() =
runGenericTest {
val expectConfirmation = testCase.expectConfirmation(atLeastOneFailure = false)
verify(vibrator).vibrateAuthSuccess(any())
verify(vibrator, never()).vibrateAuthError(any())
}
viewModel.showAuthenticated(testCase.authenticatedModality, 1_000L)
@Test
fun plays_no_haptic_on_confirm() = runGenericTest {
viewModel.confirmAuthenticated()
verify(vibrator, if (expectConfirmation) never() else times(1))
.vibrateAuthSuccess(any())
verify(vibrator, never()).vibrateAuthSuccess(any())
verify(vibrator, never()).vibrateAuthError(any())
}
if (expectConfirmation) {
viewModel.confirmAuthenticated()
}
verify(vibrator).vibrateAuthSuccess(any())
verify(vibrator, never()).vibrateAuthError(any())
}
private suspend fun TestScope.showAuthenticated(
authenticatedModality: BiometricModality,