mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-16 11:16:12 -04:00
fix: Trigger AAP connection when classic Bluetooth connects
initialConnect() only ran on profile changes, so if the L2CAP connection failed at service start (device not yet connected), it was never retried. Now also triggers on connectedDevices changes. Also fix reconnect BLE address comparison: was comparing BLE RPA with bonded BR/EDR address (never matches), now uses profile address.
This commit is contained in:
@@ -12,6 +12,7 @@ import eu.darken.capod.pods.core.apple.aap.AapPodState
|
||||
import eu.darken.capod.profiles.core.DeviceProfilesRepo
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.merge
|
||||
@@ -33,7 +34,10 @@ class AapAutoConnect @Inject constructor(
|
||||
reconnectOnDisconnect(),
|
||||
)
|
||||
|
||||
private fun initialConnect(): Flow<Unit> = profilesRepo.profiles
|
||||
private fun initialConnect(): Flow<Unit> = combine(
|
||||
profilesRepo.profiles,
|
||||
bluetoothManager.connectedDevices,
|
||||
) { profiles, _ -> profiles }
|
||||
.map { profiles ->
|
||||
val bondedDevices = bluetoothManager.bondedDevices().first()
|
||||
|
||||
@@ -88,7 +92,7 @@ class AapAutoConnect @Inject constructor(
|
||||
|
||||
// Check if still visible in BLE
|
||||
val bleDevices = blePodMonitor.devices.first()
|
||||
if (bleDevices.none { it.address == address }) {
|
||||
if (bleDevices.none { it.meta?.profile?.address == address }) {
|
||||
log(TAG) { "AAP reconnect: $address no longer visible in BLE, stopping" }
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user