fetch service UUIDs before checking UUIDs of a bluetooth device when starting service

This commit is contained in:
Kavish Devar
2025-01-06 14:26:13 +05:30
parent c941d0d320
commit 130b83c91a

View File

@@ -319,8 +319,13 @@ class AirPodsService: Service() {
val bluetoothAdapter = getSystemService(BluetoothManager::class.java).adapter
bluetoothAdapter.bondedDevices.forEach { device ->
device.fetchUuidsWithSdp()
if (device.uuids != null)
{
if (device.uuids.contains(ParcelUuid.fromString("74ec2172-0bad-4d01-8f77-997b2be0722a"))) {
bluetoothAdapter.getProfileProxy(this, object : BluetoothProfile.ServiceListener {
bluetoothAdapter.getProfileProxy(
this,
object : BluetoothProfile.ServiceListener {
override fun onServiceConnected(profile: Int, proxy: BluetoothProfile) {
if (profile == BluetoothProfile.A2DP) {
val connectedDevices = proxy.connectedDevices
@@ -335,7 +340,10 @@ class AirPodsService: Service() {
}
override fun onServiceDisconnected(profile: Int) {}
}, BluetoothProfile.A2DP)
},
BluetoothProfile.A2DP
)
}
}
}