From af4e979ab0b99ea32293a2bd0971278075d4fbc9 Mon Sep 17 00:00:00 2001 From: Seb3thehacker Date: Fri, 6 Nov 2026 13:12:20 -0800 Subject: [PATCH] Screen sharing waits 30 seconds for the car to come back, and the address card shows once per car again A wireless reconnect takes longer than 3 seconds, which had the driver asked to share the screen again mid-drive. Cars that wait for a tap on their icon no longer get the address card every drive. --- .../java/app/seb3thehacker/gearslip/audio/CarAudio.kt | 8 ++++++-- .../app/seb3thehacker/gearslip/car/CarBluetooth.kt | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) 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 5b1da9d..7707806 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/audio/CarAudio.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/audio/CarAudio.kt @@ -88,8 +88,12 @@ object CarAudio { main.postDelayed(releaseWhenGone, CAR_GONE_MS) } - /** How long after the car leaves the capture waits for it to come back: a cable that slips. */ - private const val CAR_GONE_MS = 3_000L + /** + * How long after the car leaves the capture waits for it to come back: a cable that slips, or a + * wireless link that drops and reconnects, which can take well over 3 seconds. Stopping sooner + * would have Android ask the driver to share the screen again in the middle of a drive. + */ + private const val CAR_GONE_MS = 30_000L /** * The car wants sound. Safe to call as often as the session likes: the consent dialog appears diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarBluetooth.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarBluetooth.kt index 5a434f0..f38a339 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarBluetooth.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarBluetooth.kt @@ -106,14 +106,14 @@ object CarBluetooth { } /** - * Once per car: it waits on the phone, and the car screen says so once. [again] asks a car - * that was asked before, for one that keeps its screen until it knows the phone. + * Once per car: it waits on the phone, and the car screen says so once. A car that keeps its + * screen isn't asked again on every drive: plenty of cars just wait for a tap on their icon. */ @SuppressLint("MissingPermission") - private fun askForAddress(device: BluetoothDevice, carAddress: String, again: Boolean = false) { + private fun askForAddress(device: BluetoothDevice, carAddress: String) { val context = appContext ?: return val asked = AppSettings.getString(context, KEY_ADDRESS_ASKED, "").split(",").filter { it.isNotEmpty() } - if (hash(carAddress) in asked && !again) return + if (hash(carAddress) in asked) return AppSettings.putString(context, KEY_ADDRESS_ASKED, (asked + hash(carAddress)).distinct().joinToString(",")) val name = runCatching { device.alias ?: device.name }.getOrNull()?.takeIf { it.isNotBlank() } ?: context.getString(R.string.bt_address_your_car) @@ -187,7 +187,7 @@ object CarBluetooth { val device = device() ?: return false return when { device.bondState == BluetoothDevice.BOND_BONDED -> { - askForAddress(device, c.service.carAddress, again = true) + askForAddress(device, c.service.carAddress) announce("the car is keeping its screen") true }