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

Commit 91669d64 authored by Hao Dong's avatar Hao Dong
Browse files

Fix implict bp broken ui.

This CL fixes `isIconViewLoaded` logic by:
1. Check `modalities` to decide whether an icon should show.
2. If an icon should show, in `PromptIconViewBinder`, check `size` to
   update `_isIconViewLoaded` values. With this, when implicit face
   fails, size changes, `_isIconViewLoaded` could be updated to true.

Flag: N/A
Bug: 328677869
Bug: 328656309
Test: atest PromptViewModelTest
Change-Id: I04eb34ba3e2e118e4b4b9f5c8c023945880c38ff
parent 73dc5d51
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -86,7 +86,12 @@ object PromptIconViewBinder {
                launch {
                    var width = 0
                    var height = 0
                    viewModel.activeAuthType.collect { activeAuthType ->
                    combine(promptViewModel.size, viewModel.activeAuthType, ::Pair).collect {
                        (_, activeAuthType) ->
                        // Every time after bp shows, [isIconViewLoaded] is set to false in
                        // [BiometricViewSizeBinder]. Then when biometric prompt view is redrew
                        // (when size or activeAuthType changes), we need to update
                        // [isIconViewLoaded] here to keep it correct.
                        when (activeAuthType) {
                            AuthType.Fingerprint,
                            AuthType.Coex -> {
+10 −19
Original line number Diff line number Diff line
@@ -217,18 +217,12 @@ constructor(
     */
    val faceMode: Flow<Boolean> =
        combine(modalities, isConfirmationRequired, fingerprintStartMode) {
                modalities: BiometricModalities,
                isConfirmationRequired: Boolean,
                fingerprintStartMode: FingerprintStartMode ->
                if (modalities.hasFaceAndFingerprint) {
                    if (isConfirmationRequired) {
                        false
                    } else {
                        !fingerprintStartMode.isStarted
                    }
                } else {
                    false
                }
                modalities,
                isConfirmationRequired,
                fingerprintStartMode ->
                modalities.hasFaceAndFingerprint &&
                    !isConfirmationRequired &&
                    fingerprintStartMode == FingerprintStartMode.Pending
            }
            .distinctUntilChanged()

@@ -248,14 +242,11 @@ constructor(
     * asset to be loaded before determining the prompt size.
     */
    val isIconViewLoaded: Flow<Boolean> =
        combine(credentialKind, _isIconViewLoaded.asStateFlow()) { credentialKind, isIconViewLoaded
            ->
            if (credentialKind is PromptKind.Biometric) {
                isIconViewLoaded
            } else {
                true
            }
        combine(modalities, _isIconViewLoaded.asStateFlow()) { modalities, isIconViewLoaded ->
                val noIcon = modalities.isEmpty
                noIcon || isIconViewLoaded
            }
            .distinctUntilChanged()

    // Sets whether the prompt's iconView animation has been loaded in the view yet.
    fun setIsIconViewLoaded(iconViewLoaded: Boolean) {
+11 −0
Original line number Diff line number Diff line
@@ -1328,6 +1328,17 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
            assertThat(logoDescription).isEqualTo(logoDescriptionFromApp)
        }

    @Test
    fun iconViewLoaded() = runGenericTest {
        val isIconViewLoaded by collectLastValue(viewModel.isIconViewLoaded)
        // TODO(b/328677869): Add test for noIcon logic.
        assertThat(isIconViewLoaded).isFalse()

        viewModel.setIsIconViewLoaded(true)

        assertThat(isIconViewLoaded).isTrue()
    }

    /** Asserts that the selected buttons are visible now. */
    private suspend fun TestScope.assertButtonsVisible(
        tryAgain: Boolean = false,