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

Commit a19d741a authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge "Reset internal state in DepthController whenever blur gets disabled by...

Merge "Reset internal state in DepthController whenever blur gets disabled by battery saver" into main
parents 3ba5ef5d b3ab9ac7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ class WindowRootViewModelTest : SysuiTestCase() {

            assertThat(blurRadius).isEqualTo(0f)

            kosmos.windowRootViewBlurRepository.blurRadius.value = 60
            kosmos.windowRootViewBlurRepository.blurRequestedByShade.value = 60
            runCurrent()

            assertThat(blurRadius).isEqualTo(0f)
+23 −4
Original line number Diff line number Diff line
@@ -353,7 +353,9 @@ constructor(
                        interpolator = Interpolators.FAST_OUT_SLOW_IN
                        addUpdateListener { animation: ValueAnimator ->
                            wakeAndUnlockBlurData =
                                WakeAndUnlockBlurData(blurUtils.blurRadiusOfRatio(animation.animatedValue as Float))
                                WakeAndUnlockBlurData(
                                    blurUtils.blurRadiusOfRatio(animation.animatedValue as Float)
                                )
                        }
                        addListener(
                            object : AnimatorListenerAdapter() {
@@ -428,8 +430,10 @@ constructor(
        applicationScope.launch {
            wallpaperInteractor.wallpaperSupportsAmbientMode.collect { supported ->
                wallpaperSupportsAmbientMode = supported
                if (getNewWakeBlurRadius(prevDozeAmount) == wakeAndUnlockBlurData.radius
                    && !wakeAndUnlockBlurData.useZoom) {
                if (
                    getNewWakeBlurRadius(prevDozeAmount) == wakeAndUnlockBlurData.radius &&
                        !wakeAndUnlockBlurData.useZoom
                ) {
                    // Update wake and unlock radius only if the previous value comes from wake-up.
                    updateWakeBlurRadius(prevDozeAmount)
                }
@@ -452,6 +456,21 @@ constructor(
                scheduleUpdate()
            }
        }

        applicationScope.launch {
            windowRootViewBlurInteractor.isBlurCurrentlySupported.collect { supported ->
                if (supported) {
                    // when battery saver changes, try scheduling an update.
                    scheduleUpdate()
                } else {
                    // when blur becomes unsupported, no more updates will be scheduled,
                    // reset updateScheduled state.
                    updateScheduled = false
                    // reset blur and internal state to 0
                    onBlurApplied(0, 0.0f)
                }
            }
        }
    }

    fun addListener(listener: DepthListener) {
+1 −2
Original line number Diff line number Diff line
@@ -16,13 +16,12 @@

package com.android.systemui.window.data.repository

import com.android.systemui.window.data.repository.WindowRootViewBlurRepository
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow

class NoopWindowRootViewBlurRepository @Inject constructor() : WindowRootViewBlurRepository {
    override val blurRadius: MutableStateFlow<Int> = MutableStateFlow(0)
    override val blurRequestedByShade: MutableStateFlow<Int> = MutableStateFlow(0)
    override val isBlurOpaque: MutableStateFlow<Boolean> = MutableStateFlow(true)
    override val isBlurSupported: StateFlow<Boolean> = MutableStateFlow(false)
    override var blurAppliedListener: BlurAppliedListener? = null
+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ typealias BlurAppliedListener = Consumer<Int>

/** Repository that maintains state for the window blur effect. */
interface WindowRootViewBlurRepository {
    val blurRadius: MutableStateFlow<Int>
    val blurRequestedByShade: MutableStateFlow<Int>
    val isBlurOpaque: MutableStateFlow<Boolean>

    /** Is blur supported based on settings toggle and battery power saver mode. */
@@ -67,7 +67,7 @@ constructor(
    @Main private val executor: Executor,
    @Application private val scope: CoroutineScope,
) : WindowRootViewBlurRepository {
    override val blurRadius = MutableStateFlow(0)
    override val blurRequestedByShade = MutableStateFlow(0)

    override val isBlurOpaque = MutableStateFlow(false)

+2 −2
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ constructor(
    val isBlurCurrentlySupported: StateFlow<Boolean> = repository.isBlurSupported

    /** Radius of blur to be applied on the window root view. */
    val blurRadius: StateFlow<Int> = repository.blurRadius.asStateFlow()
    val blurRadiusRequestedByShade: StateFlow<Int> = repository.blurRequestedByShade.asStateFlow()

    /** Whether the blur applied is opaque or transparent. */
    val isBlurOpaque: Flow<Boolean> =
@@ -128,7 +128,7 @@ constructor(
            return false
        }
        Log.d(TAG, "requestingBlurForShade for $blurRadius $opaque")
        repository.blurRadius.value = blurRadius
        repository.blurRequestedByShade.value = blurRadius
        repository.isBlurOpaque.value = opaque
        return true
    }
Loading