mm-modem-helpers: only parse calls in voice mode

Calls in a CLCC response in data-only or fax-only mode
do not count as actuall calls.
This commit is contained in:
Dylan Van Assche
2021-09-08 07:59:16 +00:00
committed by Aleksander Morgado
parent 97d15c49a3
commit 92ad38432c
2 changed files with 49 additions and 0 deletions
+23
View File
@@ -645,6 +645,29 @@ mm_3gpp_parse_clcc_response (const gchar *str,
}
call_info->state = call_state[aux];
if (!mm_get_uint_from_match_info (match_info, 4, &aux)) {
mm_obj_warn (log_object, "couldn't parse mode from +CLCC line");
goto next;
}
/*
* Skip calls in Fax-only and DATA-only mode (3GPP TS 27.007):
* 0: Voice
* 1: Data
* 2: Fax
* 3: Voice followed by data, voice mode
* 4: Alternating voice/data, voice mode
* 5: Alternating voice/fax, voice mode
* 6: Voice followed by data, data mode
* 7: Alternating voice/data, data mode
* 8: Alternating voice/fax, fax mode
* 9: unknown
*/
if (aux != 0 && aux != 3 && aux != 4 && aux != 5) {
mm_obj_dbg (log_object, "+CLCC line is not a voice call, skipping.");
goto next;
}
if (g_match_info_get_match_count (match_info) >= 7)
call_info->number = mm_get_string_unquoted_from_match_info (match_info, 6);
+26
View File
@@ -4356,6 +4356,31 @@ test_clcc_response_multiple (void)
common_test_clcc_response (response, expected_call_info_list, G_N_ELEMENTS (expected_call_info_list));
}
static void
test_clcc_response_ignore_non_voice (void)
{
static const MMCallInfo expected_call_info_list[] = {
{ 1, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_RINGING_IN, (gchar *) "987654321" },
{ 4, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_RINGING_IN, (gchar *) "111111111" },
{ 5, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_RINGING_IN, (gchar *) "222222222" },
{ 6, MM_CALL_DIRECTION_INCOMING, MM_CALL_STATE_RINGING_IN, (gchar *) "333333333" },
};
const gchar *response =
"+CLCC: 1,1,4,0,0,\"987654321\",161\r\n" /* voice mode */
"+CLCC: 2,1,4,1,0,\"123456789\",161\r\n" /* data mode, skip */
"+CLCC: 3,1,4,2,0,\"000000000\",161\r\n" /* fax data, skip */
"+CLCC: 4,1,4,3,0,\"111111111\",161\r\n" /* voice followed by data, voice mode */
"+CLCC: 5,1,4,4,0,\"222222222\",161\r\n" /* alternating voice/data, voice mode */
"+CLCC: 6,1,4,5,0,\"333333333\",161\r\n" /* alternating voice/fax, voice mode */
"+CLCC: 7,1,4,6,0,\"444444444\",161\r\n" /* voice followed by data, data mode, skip */
"+CLCC: 8,1,4,7,0,\"555555555\",161\r\n" /* alternating voice/data, data mode, skip */
"+CLCC: 9,1,4,8,0,\"666666666\",161\r\n" /* alternating voice/fax, fax mode, skip */
"+CLCC: 10,1,4,9,0,\"777777777\",161\r\n"; /* unknown mode, skip */
common_test_clcc_response (response, expected_call_info_list, G_N_ELEMENTS (expected_call_info_list));
}
/*****************************************************************************/
/* Test +CRSM EF_ECC read data parsing */
@@ -4795,6 +4820,7 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_clcc_response_single, NULL));
g_test_suite_add (suite, TESTCASE (test_clcc_response_single_long, NULL));
g_test_suite_add (suite, TESTCASE (test_clcc_response_multiple, NULL));
g_test_suite_add (suite, TESTCASE (test_clcc_response_ignore_non_voice, NULL));
g_test_suite_add (suite, TESTCASE (test_emergency_numbers, NULL));