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

Commit 7bd21ad0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disable zoom out effect when the shade is on an external display" into main

parents 55340374 045c9008
Loading
Loading
Loading
Loading
+38 −5
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.shade.ShadeExpansionChangeEvent
import com.android.systemui.shade.data.repository.fakeShadeDisplaysRepository
import com.android.systemui.shade.domain.interactor.ShadeModeInteractor
import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.phone.DozeParameters
@@ -45,6 +46,8 @@ import com.android.systemui.wallpapers.domain.interactor.WallpaperInteractor
import com.android.systemui.window.domain.interactor.WindowRootViewBlurInteractor
import com.android.wm.shell.appzoomout.AppZoomOut
import com.google.common.truth.Truth.assertThat
import java.util.Optional
import java.util.function.Consumer
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -65,8 +68,6 @@ import org.mockito.Mockito.reset
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.junit.MockitoJUnit
import java.util.Optional
import java.util.function.Consumer

@RunWith(AndroidJUnit4::class)
@RunWithLooper
@@ -75,6 +76,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    private val kosmos = testKosmos()

    private val applicationScope = kosmos.testScope.backgroundScope
    private val shadeDisplayRepository = kosmos.fakeShadeDisplaysRepository
    @Mock private lateinit var statusBarStateController: StatusBarStateController
    @Mock private lateinit var blurUtils: BlurUtils
    @Mock private lateinit var biometricUnlockController: BiometricUnlockController
@@ -135,7 +137,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
                windowRootViewBlurInteractor,
                appZoomOutOptional,
                applicationScope,
                dumpManager
                dumpManager,
                { shadeDisplayRepository },
            )
        notificationShadeDepthController.shadeAnimation = shadeAnimation
        notificationShadeDepthController.brightnessMirrorSpring = brightnessSpring
@@ -354,6 +357,36 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(blurUtils).applyBlur(any(), anyInt(), eq(false))
    }

    @Test
    @EnableFlags(Flags.FLAG_SHADE_WINDOW_GOES_AROUND)
    fun updateBlurCallback_shadeInExternalDisplay_doesSetZeroZoom() {
        notificationShadeDepthController.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
        )
        notificationShadeDepthController.addListener(listener)
        shadeDisplayRepository.setDisplayId(1) // not default display.

        notificationShadeDepthController.updateBlurCallback.doFrame(0)

        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(listener).onWallpaperZoomOutChanged(eq(0f))
    }

    @Test
    @EnableFlags(Flags.FLAG_SHADE_WINDOW_GOES_AROUND)
    fun updateBlurCallback_shadeInDefaultDisplay_doesNotSetZeroZoom() {
        notificationShadeDepthController.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
        )
        notificationShadeDepthController.addListener(listener)
        shadeDisplayRepository.setDisplayId(0) // shade is in default display

        notificationShadeDepthController.updateBlurCallback.doFrame(0)

        verify(wallpaperController).setNotificationShadeZoom(floatThat { it != 0f })
        verify(listener).onWallpaperZoomOutChanged(floatThat { it != 0f })
    }

    @Test
    @DisableFlags(Flags.FLAG_NOTIFICATION_SHADE_BLUR)
    fun updateBlurCallback_setsOpaque_whenScrim() {
+21 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.util.IndentingPrintWriter
import android.util.Log
import android.util.MathUtils
import android.view.Choreographer
import android.view.Display
import android.view.View
import androidx.annotation.VisibleForTesting
import androidx.dynamicanimation.animation.FloatPropertyCompat
@@ -42,7 +43,9 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.shade.ShadeExpansionChangeEvent
import com.android.systemui.shade.ShadeExpansionListener
import com.android.systemui.shade.data.repository.ShadeDisplaysRepository
import com.android.systemui.shade.domain.interactor.ShadeModeInteractor
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK
import com.android.systemui.statusbar.phone.DozeParameters
@@ -52,6 +55,7 @@ import com.android.systemui.util.WallpaperController
import com.android.systemui.wallpapers.domain.interactor.WallpaperInteractor
import com.android.systemui.window.domain.interactor.WindowRootViewBlurInteractor
import com.android.wm.shell.appzoomout.AppZoomOut
import dagger.Lazy
import java.io.PrintWriter
import java.util.Optional
import javax.inject.Inject
@@ -83,6 +87,7 @@ constructor(
    private val appZoomOutOptional: Optional<AppZoomOut>,
    @Application private val applicationScope: CoroutineScope,
    dumpManager: DumpManager,
    private val shadeDisplaysRepository: Lazy<ShadeDisplaysRepository>,
) : ShadeExpansionListener, Dumpable {
    companion object {
        private const val WAKE_UP_ANIMATION_ENABLED = true
@@ -228,6 +233,14 @@ constructor(

    private data class WakeAndUnlockBlurData(val radius: Float, val useZoom: Boolean = true)

    private val isShadeOnDefaultDisplay: Boolean
        get() =
            if (ShadeWindowGoesAround.isEnabled) {
                shadeDisplaysRepository.get().displayId.value == Display.DEFAULT_DISPLAY
            } else {
                true
            }

    /** Blur radius of the wake and unlock animation on this frame, and whether to zoom out. */
    private var wakeAndUnlockBlurData = WakeAndUnlockBlurData(0f)
        set(value) {
@@ -265,9 +278,14 @@ constructor(
        var blur = shadeRadius.toInt()
        // If the blur comes from waking up, we don't want to zoom out the background
        val zoomOut =
            if (shadeRadius != wakeAndUnlockBlurData.radius || wakeAndUnlockBlurData.useZoom)
            when {
                // When the shade is in another display, we don't want to zoom out the background.
                // Only the default display is supported right now.
                !isShadeOnDefaultDisplay -> 0f
                shadeRadius != wakeAndUnlockBlurData.radius || wakeAndUnlockBlurData.useZoom ->
                    blurRadiusToZoomOut(blurRadius = shadeRadius)
            else 0f
                else -> 0f
            }
        // Make blur be 0 if it is necessary to stop blur effect.
        if (scrimsVisible) {
            if (!Flags.notificationShadeBlur()) {