mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-10 16:02:25 +01:00
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.
This commit is contained in:
1 parent
9938efb706
commit
af4e979ab0
2 files changed
+11
-7
No files matched your search
@@ -88,8 +88,12 @@ object CarAudio {
|
|||||||
main.postDelayed(releaseWhenGone, CAR_GONE_MS)
|
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
|
* The car wants sound. Safe to call as often as the session likes: the consent dialog appears
|
||||||
|
|||||||
@@ -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
|
* Once per car: it waits on the phone, and the car screen says so once. A car that keeps its
|
||||||
* that was asked before, for one that keeps its screen until it knows the phone.
|
* screen isn't asked again on every drive: plenty of cars just wait for a tap on their icon.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
private fun askForAddress(device: BluetoothDevice, carAddress: String, again: Boolean = false) {
|
private fun askForAddress(device: BluetoothDevice, carAddress: String) {
|
||||||
val context = appContext ?: return
|
val context = appContext ?: return
|
||||||
val asked = AppSettings.getString(context, KEY_ADDRESS_ASKED, "").split(",").filter { it.isNotEmpty() }
|
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(","))
|
AppSettings.putString(context, KEY_ADDRESS_ASKED, (asked + hash(carAddress)).distinct().joinToString(","))
|
||||||
val name = runCatching { device.alias ?: device.name }.getOrNull()?.takeIf { it.isNotBlank() }
|
val name = runCatching { device.alias ?: device.name }.getOrNull()?.takeIf { it.isNotBlank() }
|
||||||
?: context.getString(R.string.bt_address_your_car)
|
?: context.getString(R.string.bt_address_your_car)
|
||||||
@@ -187,7 +187,7 @@ object CarBluetooth {
|
|||||||
val device = device() ?: return false
|
val device = device() ?: return false
|
||||||
return when {
|
return when {
|
||||||
device.bondState == BluetoothDevice.BOND_BONDED -> {
|
device.bondState == BluetoothDevice.BOND_BONDED -> {
|
||||||
askForAddress(device, c.service.carAddress, again = true)
|
askForAddress(device, c.service.carAddress)
|
||||||
announce("the car is keeping its screen")
|
announce("the car is keeping its screen")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user