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

Commit b5f1daa4 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Don't read AnimatedState.value during composition

Fix: 318565100
Test: Manual
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I70b4e29578e4bab81fe32941280dd2d066ba3a4f
parent 79b8a00c
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -91,12 +91,19 @@ fun SceneScope.CollapsedShadeHeader(
    statusBarIconController: StatusBarIconController,
    modifier: Modifier = Modifier,
) {
    val formatProgress = animateSceneFloatAsState(0.0f, ShadeHeader.Keys.transitionProgress)
    val formatProgress =
        animateSceneFloatAsState(0f, ShadeHeader.Keys.transitionProgress)
            .unsafeCompositionState(initialValue = 0f)

    val cutoutWidth = LocalDisplayCutout.current.width()
    val cutoutLocation = LocalDisplayCutout.current.location

    val useExpandedFormat = formatProgress.value > 0.5f || cutoutLocation != CutoutLocation.CENTER
    val useExpandedFormat by
        remember(formatProgress) {
            derivedStateOf {
                cutoutLocation != CutoutLocation.CENTER || formatProgress.value > 0.5f
            }
        }

    // This layout assumes it is globally positioned at (0, 0) and is the
    // same size as the screen.
@@ -209,7 +216,9 @@ fun SceneScope.ExpandedShadeHeader(
    statusBarIconController: StatusBarIconController,
    modifier: Modifier = Modifier,
) {
    val formatProgress = animateSceneFloatAsState(1.0f, ShadeHeader.Keys.transitionProgress)
    val formatProgress =
        animateSceneFloatAsState(1f, ShadeHeader.Keys.transitionProgress)
            .unsafeCompositionState(initialValue = 1f)
    val useExpandedFormat by
        remember(formatProgress) { derivedStateOf { formatProgress.value > 0.5f } }