preview: keep the phone awake while the car preview is open, and only then

This commit is contained in:
Seb3thehacker committed 2026-10-26 00:10:28 -07:00
1 parent c616f0203a
commit a1a0546b74
1 file changed
+8
@@ -71,6 +71,14 @@ fun CarPreviewScreen(onBack: () -> Unit) {
val projector = remember { ScreenProjector(context) }
// The preview is something to watch, like a map on a dash mount, so the phone stays awake on
// it. Only here: the flag goes with this screen, and every other screen sleeps as usual.
val view = androidx.compose.ui.platform.LocalView.current
DisposableEffect(view) {
view.keepScreenOn = true
onDispose { view.keepScreenOn = false }
}
DisposableEffect(width, height, density) {
CarEnvironment.start(context)
// No surface yet: the SurfaceView below hands its own over once it exists, and the