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

Commit c88d3452 authored by Cicely Lambright's avatar Cicely Lambright Committed by Android (Google) Code Review
Browse files

Merge "Allow spacial depth zoom for tablets and foldables" into main

parents f14a1de3 4ac02372
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2218,3 +2218,13 @@ flag {
        purpose: PURPOSE_BUGFIX
   }
}

flag {
    name: "check_desktop_mode_for_spacial_model_app_pushback"
    namespace: "systemui"
    description: "Checks desktop mode for disabling spacial model as opposed to just checking if the screen is large"
    bug: "409529581"
   metadata {
        purpose: PURPOSE_BUGFIX
   }
}
+49 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.systemui.wallpapers.domain.interactor.WallpaperInteractor
import com.android.systemui.window.domain.interactor.WindowRootViewBlurInteractor
import com.android.systemui.window.domain.interactor.windowRootViewBlurInteractor
import com.android.wm.shell.appzoomout.AppZoomOut
import com.android.wm.shell.desktopmode.DesktopMode
import com.google.common.truth.Truth.assertThat
import java.util.Optional
import java.util.function.Consumer
@@ -98,6 +99,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    @Mock private lateinit var brightnessSpring: NotificationShadeDepthController.DepthAnimation
    @Mock private lateinit var listener: NotificationShadeDepthController.DepthListener
    @Mock private lateinit var dozeParameters: DozeParameters
    @Mock private lateinit var desktopMode: DesktopMode
    @Captor private lateinit var scrimVisibilityCaptor: ArgumentCaptor<Consumer<Int>>
    @JvmField @Rule val mockitoRule = MockitoJUnit.rule()

@@ -133,6 +135,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        `when`(windowRootViewBlurInteractor.isBlurCurrentlySupported)
            .thenReturn(MutableStateFlow(true))
        `when`(keyguardInteractor.isDreaming).thenReturn(dreamingFlow)
        `when`(desktopMode.isDisplayInDesktopMode(anyInt())).thenReturn(false)

        notificationShadeDepthController =
            NotificationShadeDepthController(
@@ -152,6 +155,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
                { shadeDisplayRepository },
                focusedDisplayRepository,
                applicationScope,
                Optional.of(desktopMode),
                dumpManager,
            )
        notificationShadeDepthController.shadeAnimation = shadeAnimation
@@ -290,6 +294,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_CHECK_DESKTOP_MODE_FOR_SPACIAL_MODEL_APP_PUSHBACK)
    fun expandPanel_inSplitShade_setsZoomToZero() {
        enableSplitShade()

@@ -300,6 +305,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_CHECK_DESKTOP_MODE_FOR_SPACIAL_MODEL_APP_PUSHBACK)
    fun expandPanel_notInSplitShade_setsZoomValue() {
        disableSplitShade()

@@ -327,6 +333,49 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
    }

    @Test
    @EnableFlags(
        Flags.FLAG_CHECK_DESKTOP_MODE_FOR_SPACIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
    )
    fun expandPanel_inSplitShade_notInDesktopMode_setsZoomValue() {
        enableSplitShade()

        notificationShadeDepthController.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
        )
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
    }

    @Test
    @EnableFlags(
        Flags.FLAG_CHECK_DESKTOP_MODE_FOR_SPACIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
    )
    fun expandPanel_inSplitShade_inDesktopMode_setsZoomToZero() {
        enableSplitShade()
        `when`(desktopMode.isDisplayInDesktopMode(anyInt())).thenReturn(true)

        notificationShadeDepthController.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
        )
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
    }

    @Test
    @EnableFlags(
        Flags.FLAG_CHECK_DESKTOP_MODE_FOR_SPACIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
    )
    fun expandPanel_notInSplitShade_inDesktopMode_setsZoomToZero() {
        disableSplitShade()

        notificationShadeDepthController.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
        )
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
    }

    @Test
    fun setFullShadeTransition_appliesBlur() {
        notificationShadeDepthController.transitionToFullShadeProgress = 1f
+25 −9
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.app.animation.Interpolators
import com.android.app.tracing.coroutines.TrackTracer
import com.android.systemui.Dumpable
import com.android.systemui.Flags
import com.android.systemui.Flags.checkDesktopModeForSpacialModelAppPushback
import com.android.systemui.Flags.spatialModelAppPushback
import com.android.systemui.animation.ShadeInterpolation
import com.android.systemui.dagger.SysUISingleton
@@ -58,6 +59,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 com.android.wm.shell.desktopmode.DesktopMode
import dagger.Lazy
import java.io.PrintWriter
import java.util.Optional
@@ -91,6 +93,7 @@ constructor(
    private val shadeDisplaysRepository: Lazy<ShadeDisplaysRepository>,
    private val focusedDisplayRepository: FocusedDisplayRepository,
    @Application private val applicationScope: CoroutineScope,
    private val desktopMode: Optional<DesktopMode>,
    dumpManager: DumpManager,
) : ShadeExpansionListener, Dumpable {
    companion object {
@@ -124,6 +127,7 @@ constructor(
    private var prevShadeVelocity = 0f
    private var prevDozeAmount: Float = 0f
    @VisibleForTesting var wallpaperSupportsAmbientMode: Boolean = false

    // tracks whether app launch transition is in progress. This involves two independent factors
    // that control blur, shade expansion and app launch animation from outside sysui.
    // They can complete out of order, this flag will be reset by the animation that finishes later.
@@ -315,21 +319,33 @@ constructor(
    }

    private fun blurRadiusToZoomOut(blurRadius: Float): Float {
        var zoomOut = MathUtils.saturate(blurUtils.ratioOfBlurRadius(blurRadius))
        if (shadeModeInteractor.isSplitShade) {
            zoomOut = 0f
        val disableZoomForMode =
            if (checkDesktopModeForSpacialModelAppPushback()) {
                desktopMode
                    .map { dm ->
                        dm.isDisplayInDesktopMode(shadeDisplaysRepository.get().displayId.value)
                    }
                    .orElse(false)
            } else {
                shadeModeInteractor.isSplitShade
            }

        if (scrimsVisible) {
            zoomOut = 0f
        val zoomOut =
            when {
                disableZoomForMode -> 0f
                scrimsVisible -> 0f
                else -> MathUtils.saturate(blurUtils.ratioOfBlurRadius(blurRadius))
            }
        return zoomOut
    }

    private val shouldBlurBeOpaque: Boolean
        get() =
            if (Flags.notificationShadeBlur()) false
            else scrimsVisible && !areBlursDisabledForAppLaunch
            if (Flags.notificationShadeBlur()) {
                false
            } else {
                scrimsVisible && !areBlursDisabledForAppLaunch
            }

    @VisibleForTesting
    fun zoomOutAsScale(zoomOutProgress: Float): Float =
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ var Kosmos.notificationShadeDepthController by Fixture {
            shadeDisplaysRepository = { shadeDisplaysRepository },
            focusedDisplayRepository = fakeFocusedDisplayRepository,
            applicationScope = applicationCoroutineScope,
            desktopMode = Optional.empty(),
            dumpManager = dumpManager,
        )
        .apply { root = mock<View>() }