From c7ba9506df1d3a9eb429afd9edf95a24f35a11e3 Mon Sep 17 00:00:00 2001 From: Hawk <28853569+WebF1yin@users.noreply.github.com> Date: Mon, 23 Nov 2026 12:19:05 -0800 Subject: [PATCH] When the car leaves for good, the phone stops sharing its screen and gets its speaker back at once The capture waits 30 seconds after the car goes, so a cable that slips or a wireless link that drops and comes back doesn't ask the driver to share the screen again. It waited after every drive too: a SOOEMAKA said goodbye at 12:15:40 and the phone stayed muted and sharing its screen until 12:16:10. A car that says goodbye, or whose Bluetooth goes with it, isn't coming back in a moment, so the capture now stops then. A drop with the car's Bluetooth still there keeps the 30 seconds. The music is paused first, so the phone's speaker comes back only after it has stopped. Co-Authored-By: Claude Opus 5.5 --- .../app/seb3thehacker/gearslip/GearslipRunner.kt | 2 ++ .../app/seb3thehacker/gearslip/audio/CarAudio.kt | 14 ++++++++++++++ .../gearslip/wireless/CarPresenceService.kt | 5 ++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/GearslipRunner.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/GearslipRunner.kt index 46b0e4b..30fcbf9 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/GearslipRunner.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/GearslipRunner.kt @@ -355,6 +355,8 @@ class GearslipRunner( drainWriterOnExit = true running = false SessionStatus.disconnected() + // The car said goodbye, so it isn't coming back in a moment: see CarAudio.carLeft. + app.seb3thehacker.gearslip.audio.CarAudio.carLeft("the car said goodbye") } private fun onVersionRequest(body: ByteArray) { diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/audio/CarAudio.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/audio/CarAudio.kt index 7707806..877f09a 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/audio/CarAudio.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/audio/CarAudio.kt @@ -152,6 +152,20 @@ object CarAudio { _capture.value = Capture.OFF } + /** + * The car has gone for good, not dropped for a moment: it said goodbye, or its Bluetooth went + * with it. The capture, and the phone's muted speaker with it, stop now rather than after + * [CAR_GONE_MS]: a SOOEMAKA's goodbye left the phone silent and sharing its screen for 30 s. + */ + fun carLeft(why: String) { + if (!wanted && _capture.value == Capture.OFF) return + GearslipLog.i("audio: $why - stopping the capture now") + // The music stops first: giving the speaker back before the pause reached the app + // could let a moment of it play from the phone. + runCatching { app.seb3thehacker.gearslip.car.CarServices.pausePhoneMedia(why) } + main.post { release() } + } + fun denied() { _capture.value = Capture.DENIED } diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/wireless/CarPresenceService.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/wireless/CarPresenceService.kt index cd2f045..e0cb86a 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/wireless/CarPresenceService.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/wireless/CarPresenceService.kt @@ -11,5 +11,8 @@ class CarPresenceService : CompanionDeviceService() { } @Deprecated("Deprecated in Java") - override fun onDeviceDisappeared(address: String) {} + override fun onDeviceDisappeared(address: String) { + // The car's Bluetooth went with it, so it isn't coming back in a moment: see CarAudio.carLeft. + app.seb3thehacker.gearslip.audio.CarAudio.carLeft("the car's Bluetooth went") + } }