From a1a0546b7412bda0647c55130b9ab224bf9f77bb Mon Sep 17 00:00:00 2001 From: Seb3thehacker Date: Mon, 26 Oct 2026 00:10:28 -0700 Subject: [PATCH] preview: keep the phone awake while the car preview is open, and only then --- .../app/seb3thehacker/gearslip/ui/CarPreviewScreen.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/ui/CarPreviewScreen.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/ui/CarPreviewScreen.kt index 1f6d1c1..9e228ba 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/ui/CarPreviewScreen.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/ui/CarPreviewScreen.kt @@ -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