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

Commit ece8a4fc authored by Matt Pietal's avatar Matt Pietal
Browse files

Ensure only distinct light reveal alpha gets processed

There was a race condition on boot with the light reveal animation
that could inproperly leave the light reveal in a transparent state
when it should be opaque.

Fixes: 414817175
Test: reboot and check foldable
Flag: com.android.systemui.shared.ambient_aod
Change-Id: Ibb3fef34b5a275c93ee6ef12871eaebf2f57e9c8
parent 11fae1bc
Loading
Loading
Loading
Loading
+14 −16
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ object LightRevealScrimViewBinder {
                    launch("$TAG#viewModel.maxAlpha") {
                        var animator: ValueAnimator? = null
                        viewModel.maxAlpha.collect { (alpha, animate) ->
                            if (alpha != revealScrim.alpha) {
                            animator?.cancel()
                            if (!animate) {
                                revealScrim.alpha = alpha
@@ -65,7 +64,6 @@ object LightRevealScrimViewBinder {
                        }
                    }
                }
                }

                launch("$TAG#viewModel.revealAmount") {
                    viewModel.revealAmount.collect { revealScrim.revealAmount = it }
+10 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.systemui.keyguard.domain.interactor.LightRevealScrimInteracto
import com.android.systemui.statusbar.LightRevealEffect
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map

/**
@@ -34,13 +35,15 @@ constructor(private val interactor: LightRevealScrimInteractor) {

    /** Max alpha for the scrim + whether to animate the change */
    val maxAlpha: Flow<Pair<Float, Boolean>> =
        interactor.maxAlpha.map { alpha ->
        interactor.maxAlpha
            .map { alpha ->
                Pair(
                    alpha,
                    // Darken immediately if going to be fully opaque
                    if (alpha == 1f) false else true,
                )
            }
            .distinctUntilChanged()

    fun setWallpaperSupportsAmbientMode(supportsAmbientMode: Boolean) {
        interactor.setWallpaperSupportsAmbientMode(supportsAmbientMode)