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

Commit 86c2a00f authored by Chandru S's avatar Chandru S
Browse files

Blur NSSL view when opening the primary bouncer from the shade

Rest of the shade is blurred from NPVC but that doesn't seem to affect NSSL

Test: Unit tests added
Flag: com.android.systemui.bouncer_ui_revamp
Fixes: 385364857
Test: verified manually,
 1. Open shade
 2. Tap on notification to open alternate bouncer
 3. Swipe up to go to primary bouncer
 4. Notifications should be visible and blurred
Change-Id: I91638147cc0e8d4aa5f26feb4c4d1ab13ea996c1
parent af5b6ce5
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package com.android.systemui.keyguard.ui.viewmodel

import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_BOUNCER_UI_REVAMP
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectValues
import com.android.systemui.flags.BrokenWithSceneContainer
import com.android.systemui.flags.Flags
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
@@ -87,6 +90,25 @@ class AlternateBouncerToPrimaryBouncerTransitionViewModelTest : SysuiTestCase()
            )
        }

    @Test
    @EnableFlags(FLAG_BOUNCER_UI_REVAMP)
    @BrokenWithSceneContainer(388068805)
    fun notificationBlur_isNonZero_whenShadeIsExpanded() =
        testScope.runTest {
            val values by collectValues(underTest.notificationBlurRadius)

            kosmos.bouncerWindowBlurTestUtil.shadeExpanded(true)

            kosmos.bouncerWindowBlurTestUtil.assertTransitionToBlurRadius(
                transitionProgress = listOf(0f, 0f, 0.1f, 0.2f, 0.3f, 1f),
                startValue = kosmos.blurConfig.maxBlurRadiusPx / 3.0f,
                endValue = kosmos.blurConfig.maxBlurRadiusPx / 3.0f,
                transitionFactory = ::step,
                actualValuesProvider = { values },
                checkInterpolatedValues = false,
            )
        }

    @Test
    fun blurRadiusGoesFromMinToMaxWhenShadeIsNotExpanded() =
        testScope.runTest {
+23 −2
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@

package com.android.systemui.keyguard.ui.viewmodel

import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import androidx.test.filters.SmallTest
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.systemui.Flags.FLAG_BOUNCER_UI_REVAMP
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
@@ -153,7 +155,7 @@ class LockscreenToPrimaryBouncerTransitionViewModelTest(flags: FlagsParameteriza
        }

    @Test
    @BrokenWithSceneContainer(330311871)
    @BrokenWithSceneContainer(388068805)
    fun blurRadiusIsMaxWhenShadeIsExpanded() =
        testScope.runTest {
            val values by collectValues(underTest.windowBlurRadius)
@@ -170,7 +172,7 @@ class LockscreenToPrimaryBouncerTransitionViewModelTest(flags: FlagsParameteriza
        }

    @Test
    @BrokenWithSceneContainer(330311871)
    @BrokenWithSceneContainer(388068805)
    fun blurRadiusGoesFromMinToMaxWhenShadeIsNotExpanded() =
        testScope.runTest {
            val values by collectValues(underTest.windowBlurRadius)
@@ -185,6 +187,25 @@ class LockscreenToPrimaryBouncerTransitionViewModelTest(flags: FlagsParameteriza
            )
        }

    @Test
    @EnableFlags(FLAG_BOUNCER_UI_REVAMP)
    @BrokenWithSceneContainer(388068805)
    fun notificationBlur_isNonZero_whenShadeIsExpanded() =
        testScope.runTest {
            val values by collectValues(underTest.notificationBlurRadius)
            kosmos.bouncerWindowBlurTestUtil.shadeExpanded(true)
            runCurrent()

            kosmos.bouncerWindowBlurTestUtil.assertTransitionToBlurRadius(
                transitionProgress = listOf(0f, 0f, 0.1f, 0.2f, 0.3f, 1f),
                startValue = kosmos.blurConfig.maxBlurRadiusPx / 3.0f,
                endValue = kosmos.blurConfig.maxBlurRadiusPx / 3.0f,
                transitionFactory = ::step,
                actualValuesProvider = { values },
                checkInterpolatedValues = false,
            )
        }

    private fun step(
        value: Float,
        state: TransitionState = TransitionState.RUNNING,
+14 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.statusbar.notification.stack.domain.interactor.sharedNotificationContainerInteractor
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel.HorizontalPosition
import com.android.systemui.testKosmos
import com.android.systemui.window.ui.viewmodel.fakeBouncerTransitions
import com.google.common.collect.Range
import com.google.common.truth.Truth.assertThat
import kotlin.test.assertIs
@@ -1395,6 +1396,19 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
            assertThat(stackAbsoluteBottom).isEqualTo(100F)
        }

    @Test
    fun blurRadius_emitsValues_fromPrimaryBouncerTransitions() =
        testScope.runTest {
            val blurRadius by collectLastValue(underTest.blurRadius)
            assertThat(blurRadius).isEqualTo(0.0f)

            kosmos.fakeBouncerTransitions.first().notificationBlurRadius.value = 30.0f
            assertThat(blurRadius).isEqualTo(30.0f)

            kosmos.fakeBouncerTransitions.last().notificationBlurRadius.value = 40.0f
            assertThat(blurRadius).isEqualTo(40.0f)
        }

    private suspend fun TestScope.showLockscreen() {
        shadeTestUtil.setQsExpansion(0f)
        shadeTestUtil.setLockscreenShadeExpansion(0f)
+6 −0
Original line number Diff line number Diff line
@@ -23,4 +23,10 @@ data class BlurConfig(val minBlurRadiusPx: Float, val maxBlurRadiusPx: Float) {
    // No-op config that will be used by dagger of other SysUI variants which don't blur the
    // background surface.
    @Inject constructor() : this(0.0f, 0.0f)

    companion object {
        // Blur the shade much lesser than the background surface so that the surface is
        // distinguishable from the background.
        @JvmStatic fun Float.maxBlurRadiusToNotificationPanelBlurRadius(): Float = this / 3.0f
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@ interface PrimaryBouncerTransition {
    /** Radius of blur applied to the window's root view. */
    val windowBlurRadius: Flow<Float>

    /** Radius of blur applied to the notifications on expanded shade */
    val notificationBlurRadius: Flow<Float>

    fun transitionProgressToBlurRadius(
        starBlurRadius: Float,
        endBlurRadius: Float,
Loading