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

Commit 91010ec5 authored by Andreas Miko's avatar Andreas Miko
Browse files

[SceneContainer] Log all transitions

Previously only manually triggered transitions would be logged. This CL
makes sure that all changes to ObservableState are logged.

Bug: NONE
Flag: com.android.systemui.scene_container
Test: NONE
Change-Id: I76568de0dad08a23f6c59e9fbff0e82622960077
parent dd7b1173
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn

/**
@@ -102,7 +103,14 @@ constructor(
     * 2. When transitioning, which scenes are being transitioned between.
     * 3. When transitioning, what the progress of the transition is.
     */
    val transitionState: StateFlow<ObservableTransitionState> = repository.transitionState
    val transitionState: StateFlow<ObservableTransitionState> =
        repository.transitionState
            .onEach { logger.logSceneTransition(it) }
            .stateIn(
                scope = applicationScope,
                started = SharingStarted.Eagerly,
                initialValue = repository.transitionState.value,
            )

    /**
     * The key of the scene that the UI is currently transitioning to or `null` if there is no
+25 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.scene.shared.logger

import com.android.compose.animation.scene.ObservableTransitionState
import com.android.compose.animation.scene.SceneKey
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
@@ -84,6 +85,30 @@ class SceneLogger @Inject constructor(@SceneFrameworkLog private val logBuffer:
        )
    }

    fun logSceneTransition(transitionState: ObservableTransitionState) {
        when (transitionState) {
            is ObservableTransitionState.Transition -> {
                logBuffer.log(
                    tag = TAG,
                    level = LogLevel.INFO,
                    messageInitializer = {
                        str1 = transitionState.fromScene.toString()
                        str2 = transitionState.toScene.toString()
                    },
                    messagePrinter = { "Scene transition started: $str1 → $str2" },
                )
            }
            is ObservableTransitionState.Idle -> {
                logBuffer.log(
                    tag = TAG,
                    level = LogLevel.INFO,
                    messageInitializer = { str1 = transitionState.currentScene.toString() },
                    messagePrinter = { "Scene transition idle on: $str1" },
                )
            }
        }
    }

    fun logVisibilityChange(
        from: Boolean,
        to: Boolean,