diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/GearslipRunner.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/GearslipRunner.kt index 4f99f62..7c55e17 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/GearslipRunner.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/GearslipRunner.kt @@ -373,6 +373,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 2f05169..242e1ef 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/audio/CarAudio.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/audio/CarAudio.kt @@ -167,6 +167,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") + } }