Ignore repeated Bluetooth callbacks for proxies already released

This commit is contained in:
evgeny committed 2026-10-29 13:34:23 +01:00
1 parent 3d2e98b02e
commit f7ebf81061
1 file changed
+6
@@ -521,9 +521,15 @@ class CallAudioRouter {
val generation = ++btProfileGeneration
try {
val adapter = BluetoothAdapter.getDefaultAdapter() ?: return
val received = mutableSetOf<BluetoothProfile>() // Дубликат callback не возобновляет уже освобождённый proxy.
val accepted = adapter.getProfileProxy(ChatApplication.instance, object : BluetoothProfile.ServiceListener {
override fun onServiceConnected(profile: Int, proxy: BluetoothProfile) {
synchronized(this@CallAudioRouter) {
if (proxy in received && proxy !== btHeadset && proxy !in btProxies) {
LogManager.addLog("WARN", "CallAudioRouter", "released BT proxy callback ignored proxy=$proxy generation=$generation")
return
}
received.add(proxy)
btProxies[proxy] = adapter to profile
if (!started || generation != btProfileGeneration || profile != BluetoothProfile.HEADSET || proxy !is BluetoothHeadset) {
LogManager.addLog("WARN", "CallAudioRouter", "retired BT proxy received proxy=$proxy profile=$profile " +