mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-03-24 07:00:48 +00:00
fetch service UUIDs before checking UUIDs of a bluetooth device when starting service
This commit is contained in:
@@ -319,23 +319,31 @@ class AirPodsService: Service() {
|
|||||||
|
|
||||||
val bluetoothAdapter = getSystemService(BluetoothManager::class.java).adapter
|
val bluetoothAdapter = getSystemService(BluetoothManager::class.java).adapter
|
||||||
bluetoothAdapter.bondedDevices.forEach { device ->
|
bluetoothAdapter.bondedDevices.forEach { device ->
|
||||||
if (device.uuids.contains(ParcelUuid.fromString("74ec2172-0bad-4d01-8f77-997b2be0722a"))) {
|
device.fetchUuidsWithSdp()
|
||||||
bluetoothAdapter.getProfileProxy(this, object : BluetoothProfile.ServiceListener {
|
if (device.uuids != null)
|
||||||
override fun onServiceConnected(profile: Int, proxy: BluetoothProfile) {
|
{
|
||||||
if (profile == BluetoothProfile.A2DP) {
|
if (device.uuids.contains(ParcelUuid.fromString("74ec2172-0bad-4d01-8f77-997b2be0722a"))) {
|
||||||
val connectedDevices = proxy.connectedDevices
|
bluetoothAdapter.getProfileProxy(
|
||||||
if (connectedDevices.isNotEmpty()) {
|
this,
|
||||||
connectToSocket(device)
|
object : BluetoothProfile.ServiceListener {
|
||||||
this@AirPodsService.sendBroadcast(
|
override fun onServiceConnected(profile: Int, proxy: BluetoothProfile) {
|
||||||
Intent(AirPodsNotifications.Companion.AIRPODS_CONNECTED)
|
if (profile == BluetoothProfile.A2DP) {
|
||||||
)
|
val connectedDevices = proxy.connectedDevices
|
||||||
|
if (connectedDevices.isNotEmpty()) {
|
||||||
|
connectToSocket(device)
|
||||||
|
this@AirPodsService.sendBroadcast(
|
||||||
|
Intent(AirPodsNotifications.Companion.AIRPODS_CONNECTED)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bluetoothAdapter.closeProfileProxy(profile, proxy)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
bluetoothAdapter.closeProfileProxy(profile, proxy)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onServiceDisconnected(profile: Int) { }
|
override fun onServiceDisconnected(profile: Int) {}
|
||||||
}, BluetoothProfile.A2DP)
|
},
|
||||||
|
BluetoothProfile.A2DP
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user