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

Commit d8036eea authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Update some NotificationShadeDepthController and...

Update some NotificationShadeDepthController and NotificationShadeDepthControllerTest logic around the spatial_model_pushback_in_shader flag

Need this change to flip the flag with the tests passing

- Added another check on the spatial_model_pushback_in_shader flag
- Added flag conditions in the tests

Bug: 391463550
Test: manual
Flag: com.android.systemui.spatial_model_pushback_in_shader
Change-Id: Ia52266a641873ba297e7257e9ff698d4c68f4e69
parent a0ed7d03
Loading
Loading
Loading
Loading
+31 −8
Original line number Diff line number Diff line
@@ -484,7 +484,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    @DisableFlags(
        Flags.FLAG_BOUNCER_UI_REVAMP,
        Flags.FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND,
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_PUSHBACK_IN_SHADER
    )
    fun brightnessMirror_hidesShadeBlur() {
        // Brightness mirror is fully visible
@@ -499,12 +500,16 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false), anyFloat())
        verify(blurUtils).applyBlur(
            eq(viewRootImpl),
            eq(0),
            eq(false),
            eq(notificationShadeDepthController.zoomOutAsScale(0f)))
    }

    @Test
    @DisableFlags(Flags.FLAG_BOUNCER_UI_REVAMP, Flags.FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND)
    @EnableFlags(Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    @EnableFlags(Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK, Flags.FLAG_SPATIAL_MODEL_PUSHBACK_IN_SHADER)
    fun brightnessMirror_hidesShadeBlur_withAppPushback() {
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
@@ -518,12 +523,20 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false), anyFloat())
        verify(blurUtils).applyBlur(
            eq(viewRootImpl),
            eq(0),
            eq(false),
            eq(notificationShadeDepthController.zoomOutAsScale(0f))
        )
    }

    @Test
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP)
    @DisableFlags(Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    @DisableFlags(
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_PUSHBACK_IN_SHADER
    )
    fun brightnessMirror_hidesShadeBlur_withWindowBlurFlag() {
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
@@ -536,11 +549,18 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(eq(0), eq(1f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(
            eq(0),
            eq(notificationShadeDepthController.zoomOutAsScale(1f))
        )
    }

    @Test
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP, Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    @EnableFlags(
        Flags.FLAG_BOUNCER_UI_REVAMP,
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_PUSHBACK_IN_SHADER
    )
    fun brightnessMirror_hidesShadeBlur_withWindowBlurFlagAndAppPushback() {
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
@@ -553,7 +573,10 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(eq(0), eq(1f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(
            eq(0),
            eq(notificationShadeDepthController.zoomOutAsScale(0f))
        )
    }

    @Test
+5 −4
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ constructor(
            shadeRadius = 0f
        }

        if (spatialModelAppPushback()) {
        if (spatialModelAppPushback() || spatialModelPushbackInShader()) {
            // Brightness slider removes blur
            shadeRadius *= (1 - brightnessMirrorSpring.ratio)
        }
@@ -312,7 +312,7 @@ constructor(
            blur = 0
        }

        if (!spatialModelAppPushback()) {
        if (!spatialModelAppPushback() && !spatialModelPushbackInShader()) {
            // Brightness slider removes blur, but doesn't affect zooms. This is the legacy behavior
            // that zoom out is only applied to the wallpaper (no homescreen, app or all apps
            // zoom out). The new behavior is under the same flag when it's on a few lines above.
@@ -339,7 +339,8 @@ constructor(
            if (Flags.notificationShadeBlur()) false
            else scrimsVisible && !areBlursDisabledForAppLaunch

    private fun zoomOutAsScale(zoomOutProgress: Float): Float =
    @VisibleForTesting
    fun zoomOutAsScale(zoomOutProgress: Float): Float =
        if (!spatialModelPushbackInShader()) 1.0f
        else 1.0f - zoomOutProgress * getPushbackScale(isHomeFocused)

@@ -482,7 +483,7 @@ constructor(
        }
        shadeAnimation.setStiffness(SpringForce.STIFFNESS_LOW)
        shadeAnimation.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
        if (spatialModelAppPushback()) {
        if (spatialModelAppPushback() || spatialModelPushbackInShader()) {
            brightnessMirrorSpring.setStiffness(SpringForce.STIFFNESS_LOW)
            brightnessMirrorSpring.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
        }