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

Commit f8c81ad3 authored by Hao Dong's avatar Hao Dong Committed by Android (Google) Code Review
Browse files

Merge "Fix implict bp broken ui." into main

parents 54552737 91669d64
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
@@ -218,18 +218,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()

@@ -249,14 +243,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
@@ -1338,6 +1338,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,