From 4e9cbcdb899963d55b6bdcf935f1c595e99c3a85 Mon Sep 17 00:00:00 2001 From: Kuba Pawlak Date: Tue, 18 Aug 2015 19:53:28 +0200 Subject: [PATCH] hfp: Handle extra CCWA event When a call is waitng, CCWA event is sent and call object in state WAITING is created. on ReleaseAndAnswer it is promoted to INCOMING and later to ACTIVE. iPhones send an extra CCWA event when active call is ended. This extra event is creating a second call object in state WAITING. It is not possible to have two WAITING calls, but previously waiting call was already promoted to INCOMING. For a brief time we have two calls from the same number, one INCOMING and one WAITING. Later WAITING one is removed. As we cannot have a waiting and incoming call at the same time, ignore CCWA when there is already an INCOMING call. < \r\n+CIEV: 3,3\r\n < \r\n+CIEV: 2,1\r\n < \r\n+CIEV: 3,0\r\n < \r\n+CCWA: "01234567890",129,1,"Me"\r\n < \r\n+CIEV: 3,1\r\n > AT+CLCC\r < \r\n+CLCC: 1,0,0,0,0,"09876543210",129,"Me"\r\n < \r\n+CLCC: 2,1,5,0,0,"01234567890",129,"Me"\r\n < \r\nOK\r\n < \r\n+CIEV: 2,0\r\n < \r\n+CCWA: "01234567890",129,1,"Me"\r\n < \r\n+CIEV: 2,1\r\n < \r\n+CIEV: 3,0\r\n > AT+CLCC\r < \r\n+CLCC: 2,1,0,0,0,"01234567890",129,"Me"\r\n < \r\nOK\r\n --- drivers/hfpmodem/voicecall.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c index f1e90969..d0e93537 100644 --- a/drivers/hfpmodem/voicecall.c +++ b/drivers/hfpmodem/voicecall.c @@ -715,6 +715,16 @@ static void ccwa_notify(GAtResult *result, gpointer user_data) at_util_call_compare_by_status)) return; + /* some phones may send extra CCWA after active call is ended + * this would trigger creation of second call in state 'WAITING' + * as our previous WAITING call has been promoted to INCOMING + */ + if (g_slist_find_custom(vd->calls, + GINT_TO_POINTER(CALL_STATUS_INCOMING), + at_util_call_compare_by_status)) + return; + + g_at_result_iter_init(&iter, result); if (!g_at_result_iter_next(&iter, "+CCWA:")) -- 2.34.1