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

Commit 1ecc9b91 authored by Joe Bolinger's avatar Joe Bolinger Committed by Android (Google) Code Review
Browse files

Merge "Revert "Fix race condition between PromptIconViewBinder and BiometricSizeBinder"" into main

parents 06ab2901 4171b4dd
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -403,13 +403,6 @@ public class AuthContainerView extends LinearLayout

            final BiometricPromptLayout view = (BiometricPromptLayout) layoutInflater.inflate(
                    R.layout.biometric_prompt_layout, null, false);
            /**
             * View is only set visible in BiometricViewSizeBinder once PromptSize is determined
             * that accounts for iconView size, to prevent prompt resizing being visible to the
             * user.
             * TODO(b/288175072): May be able to remove this once constraint layout is implemented
             */
            view.setVisibility(View.INVISIBLE);
            mBiometricView = BiometricViewBinder.bind(view, viewModel, mPanelController,
                    // TODO(b/201510778): This uses the wrong timeout in some cases
                    getJankListener(view, TRANSIT,
+1 −7
Original line number Diff line number Diff line
@@ -97,13 +97,7 @@ object BiometricViewBinder {

        val iconOverlayView = view.requireViewById<LottieAnimationView>(R.id.biometric_icon_overlay)
        val iconView = view.requireViewById<LottieAnimationView>(R.id.biometric_icon)
        /**
         * View is only set visible in BiometricViewSizeBinder once PromptSize is determined that
         * accounts for iconView size, to prevent prompt resizing being visible to the user.
         *
         * TODO(b/288175072): May be able to remove this once constraint layout is implemented
         */
        iconView.addLottieOnCompositionLoadedListener { viewModel.setIsIconViewLoaded(true) }

        PromptIconViewBinder.bind(
            iconView,
            iconOverlayView,
+3 −19
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import androidx.core.animation.addListener
import androidx.core.view.doOnLayout
import androidx.core.view.isGone
import androidx.lifecycle.lifecycleScope
import com.android.systemui.res.R
import com.android.systemui.biometrics.AuthPanelController
import com.android.systemui.biometrics.Utils
import com.android.systemui.biometrics.ui.BiometricPromptLayout
@@ -40,8 +41,6 @@ import com.android.systemui.biometrics.ui.viewmodel.isMedium
import com.android.systemui.biometrics.ui.viewmodel.isNullOrNotSmall
import com.android.systemui.biometrics.ui.viewmodel.isSmall
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.res.R
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch

/** Helper for [BiometricViewBinder] to handle resize transitions. */
@@ -93,22 +92,8 @@ object BiometricViewSizeBinder {
            // TODO(b/251476085): migrate the legacy panel controller and simplify this
            view.repeatWhenAttached {
                var currentSize: PromptSize? = null

                lifecycleScope.launch {
                    /**
                     * View is only set visible in BiometricViewSizeBinder once PromptSize is
                     * determined that accounts for iconView size, to prevent prompt resizing being
                     * visible to the user.
                     *
                     * TODO(b/288175072): May be able to remove isIconViewLoaded once constraint
                     *   layout is implemented
                     */
                    combine(viewModel.isIconViewLoaded, viewModel.size, ::Pair).collect {
                        (isIconViewLoaded, size) ->
                        if (!isIconViewLoaded) {
                            return@collect
                        }

                    viewModel.size.collect { size ->
                        // prepare for animated size transitions
                        for (v in viewsToHideWhenSmall) {
                            v.showTextOrHide(forceHide = size.isSmall)
@@ -211,9 +196,8 @@ object BiometricViewSizeBinder {
                                    }
                                }
                            }

                            currentSize = size
                            view.visibility = View.VISIBLE
                            viewModel.setIsIconViewLoaded(false)
                            notifyAccessibilityChanged()
                        }
                    }
+0 −22
Original line number Diff line number Diff line
@@ -192,28 +192,6 @@ constructor(
    val iconViewModel: PromptIconViewModel =
        PromptIconViewModel(this, displayStateInteractor, promptSelectorInteractor)

    private val _isIconViewLoaded = MutableStateFlow(false)

    /**
     * For prompts with an iconView, false until the prompt's iconView animation has been loaded in
     * the view, otherwise true by default. Used for BiometricViewSizeBinder to wait for the icon
     * 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
            }
        }

    // Sets whether the prompt's iconView animation has been loaded in the view yet.
    fun setIsIconViewLoaded(iconViewLoaded: Boolean) {
        _isIconViewLoaded.value = iconViewLoaded
    }

    /** Padding for prompt UI elements */
    val promptPadding: Flow<Rect> =
        combine(size, displayStateInteractor.currentRotation) { size, rotation ->