From aabcd8317704be59db6bba0ad846117b151b7379 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Mon, 1 Jun 2026 23:00:20 +0300 Subject: [PATCH] Added filter to bluetooth receiver --- .../kotlin/com/tutpro/baresip/BaresipService.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 39702e5b..4c30ab0f 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -374,6 +374,18 @@ class BaresipService: Service() { } } + val bluetoothFilter = IntentFilter() + bluetoothFilter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED) + bluetoothFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED) + bluetoothFilter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED) + ContextCompat.registerReceiver( + this, + bluetoothReceiver, + bluetoothFilter, + ContextCompat.RECEIVER_EXPORTED + ) + bluetoothReceiverRegistered = true + telephonyManager = getSystemService(TELEPHONY_SERVICE) as TelephonyManager if (VERSION.SDK_INT >= 31) { telephonyCallback = object : TelephonyCallback(), TelephonyCallback.ServiceStateListener { @@ -2769,6 +2781,8 @@ class BaresipService: Service() { cm.unregisterNetworkCallback(networkCallback) if (this::androidContactsObserver.isInitialized) contentResolver.unregisterContentObserver(androidContactsObserver) + if (this::bluetoothReceiver.isInitialized) + unregisterReceiver(bluetoothReceiver) releaseAudioEffects() isServiceClean = true }