mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-10 16:02:25 +01:00
Show the alias the driver gave a paired Bluetooth device
The car list and the wireless status messages read the device's own name, so a device renamed in Android's Bluetooth settings still showed its old name. Prefer the alias, and sort the list by the name it shows.
This commit is contained in:
1 parent
75f43c3e3d
commit
c07d73cc92
1 file changed
+2
-2
@@ -104,11 +104,11 @@ object WirelessLink {
|
|||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
fun pairedDevices(context: Context): List<BluetoothDevice> =
|
fun pairedDevices(context: Context): List<BluetoothDevice> =
|
||||||
context.getSystemService(BluetoothManager::class.java)?.adapter?.bondedDevices
|
context.getSystemService(BluetoothManager::class.java)?.adapter?.bondedDevices
|
||||||
?.sortedBy { it.name ?: it.address }
|
?.sortedBy { name(it) }
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
fun name(device: BluetoothDevice): String = device.name ?: device.address
|
fun name(device: BluetoothDevice): String = device.alias ?: device.name ?: device.address
|
||||||
|
|
||||||
fun start(context: Context, device: BluetoothDevice) {
|
fun start(context: Context, device: BluetoothDevice) {
|
||||||
stop(context)
|
stop(context)
|
||||||
|
|||||||
Reference in new issue
Block a user