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

Commit a35a213e authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Check if there are duplicate scenes with the same key." into main

parents 40db1b6a bd33f597
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.Handler
import android.view.LayoutInflater
import android.view.ViewStub
import androidx.constraintlayout.motion.widget.MotionLayout
import com.android.compose.animation.scene.SceneKey
import com.android.keyguard.logging.ScrimLogger
import com.android.systemui.battery.BatteryMeterView
import com.android.systemui.battery.BatteryMeterViewController
@@ -86,6 +87,7 @@ abstract class ShadeViewProviderModule {
            sceneDataSourceDelegator: Provider<SceneDataSourceDelegator>,
        ): WindowRootView {
            return if (sceneContainerFlags.isEnabled()) {
                checkNoSceneDuplicates(scenesProvider.get())
                val sceneWindowRootView =
                    layoutInflater.inflate(R.layout.scene_window_root, null) as SceneWindowRootView
                sceneWindowRootView.init(
@@ -281,5 +283,21 @@ abstract class ShadeViewProviderModule {
        ): StatusIconContainer {
            return header.requireViewById(R.id.statusIcons)
        }

        private fun checkNoSceneDuplicates(scenes: Set<Scene>) {
            val keys = mutableSetOf<SceneKey>()
            val duplicates = mutableSetOf<SceneKey>()
            scenes
                .map { it.key }
                .forEach { sceneKey ->
                    if (keys.contains(sceneKey)) {
                        duplicates.add(sceneKey)
                    } else {
                        keys.add(sceneKey)
                    }
                }

            check(duplicates.isEmpty()) { "Duplicate scenes detected: $duplicates" }
        }
    }
}