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

Commit d8452083 authored by Chandru S's avatar Chandru S
Browse files

Trigger wallpaper and zoom out even when blur is not supported.

This mimics what NotificationShadeDepthController was doing previously, when blur gets disabled it sets blurRadius to 0 and still schedules a frame callback for applying the zoom out.
New blur implementation does not invoke onBlurApplied when blur is not supported due to battery saver.

Fixes: 403899890
Test: tracking here, b/381263619
Bug: 381263619
Flag: com.android.systemui.bouncer_ui_revamp
Change-Id: I7e1e2c58455055b17fa9fc07250b1d4c8bc765a9
parent d9dda7a7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.wm.shell.appzoomout.AppZoomOut
import com.google.common.truth.Truth.assertThat
import java.util.Optional
import java.util.function.Consumer
import kotlinx.coroutines.flow.MutableStateFlow
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -120,6 +121,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        `when`(blurUtils.supportsBlursOnWindows()).thenReturn(true)
        `when`(blurUtils.maxBlurRadius).thenReturn(maxBlur.toFloat())
        `when`(blurUtils.maxBlurRadius).thenReturn(maxBlur.toFloat())
        `when`(windowRootViewBlurInteractor.isBlurCurrentlySupported)
            .thenReturn(MutableStateFlow(true))

        notificationShadeDepthController =
            NotificationShadeDepthController(
+26 −6
Original line number Diff line number Diff line
@@ -334,6 +334,14 @@ constructor(

    private fun onBlurApplied(appliedBlurRadius: Int, zoomOutFromShadeRadius: Float) {
        lastAppliedBlur = appliedBlurRadius
        onZoomOutChanged(zoomOutFromShadeRadius)
        listeners.forEach { it.onBlurRadiusChanged(appliedBlurRadius) }
        notificationShadeWindowController.setBackgroundBlurRadius(appliedBlurRadius)
    }

    private fun onZoomOutChanged(zoomOutFromShadeRadius: Float) {
        TrackTracer.instantForGroup("shade", "zoom_out", zoomOutFromShadeRadius)
        Log.v(TAG, "onZoomOutChanged $zoomOutFromShadeRadius")
        wallpaperController.setNotificationShadeZoom(zoomOutFromShadeRadius)
        if (spatialModelAppPushback()) {
            appZoomOutOptional.ifPresent { appZoomOut ->
@@ -341,10 +349,13 @@ constructor(
            }
            keyguardInteractor.setZoomOut(zoomOutFromShadeRadius)
        }
        listeners.forEach {
            it.onBlurRadiusChanged(appliedBlurRadius)
    }
        notificationShadeWindowController.setBackgroundBlurRadius(appliedBlurRadius)

    private val applyZoomOutForFrame =
        Choreographer.FrameCallback {
            updateScheduled = false
            val (_, zoomOutFromShadeRadius) = computeBlurAndZoomOut()
            onZoomOutChanged(zoomOutFromShadeRadius)
        }

    /** Animate blurs when unlocking. */
@@ -627,10 +638,19 @@ constructor(
        val (blur, zoomOutFromShadeRadius) = computeBlurAndZoomOut()
        zoomOutCalculatedFromShadeRadius = zoomOutFromShadeRadius
        if (Flags.bouncerUiRevamp() || Flags.glanceableHubBlurredBackground()) {
            if (windowRootViewBlurInteractor.isBlurCurrentlySupported.value) {
                updateScheduled =
                    windowRootViewBlurInteractor.requestBlurForShade(blur, shouldBlurBeOpaque)
                return
            }
            // When blur is not supported, zoom out still needs to happen when scheduleUpdate
            // is invoked and a separate frame callback has to be wired-up to support that.
            if (!updateScheduled) {
                updateScheduled = true
                choreographer.postFrameCallback(applyZoomOutForFrame)
            }
            return
        }
        if (updateScheduled) {
            return
        }