From 931b6d9ad8d0bdc72c60878703c3c74fbc73f6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Wed, 11 Jun 2025 09:16:29 +0200 Subject: [PATCH] bluez5: hfp-hf: Fix condition for hfp_hf_swap_calls AT+CHLD=2 can be called even if there is no active call, the only condition is to have at least one held call. --- spa/plugins/bluez5/backend-native.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/spa/plugins/bluez5/backend-native.c b/spa/plugins/bluez5/backend-native.c index c670ec892..5f7d6f8e8 100644 --- a/spa/plugins/bluez5/backend-native.c +++ b/spa/plugins/bluez5/backend-native.c @@ -1623,7 +1623,6 @@ static void hfp_hf_swap_calls(void *data, enum spa_bt_telephony_error *err, uint struct rfcomm *rfcomm = data; struct impl *backend = rfcomm->backend; struct spa_bt_telephony_call *call; - bool found_active = false; bool found_held = false; char reply[20]; bool res; @@ -1637,18 +1636,14 @@ static void hfp_hf_swap_calls(void *data, enum spa_bt_telephony_error *err, uint } spa_list_for_each(call, &rfcomm->telephony_ag->call_list, link) { - if (call->state == CALL_STATE_WAITING) { - spa_log_debug(backend->log, "call waiting before swapping"); - *err = BT_TELEPHONY_ERROR_INVALID_STATE; - return; - } else if (call->state == CALL_STATE_ACTIVE) - found_active = true; - else if (call->state == CALL_STATE_HELD) + if (call->state == CALL_STATE_HELD) { found_held = true; + break; + } } - if (!found_active || !found_held) { - spa_log_debug(backend->log, "no active and held calls"); + if (!found_held) { + spa_log_debug(backend->log, "no held calls"); *err = BT_TELEPHONY_ERROR_INVALID_STATE; return; }