From 88e90bb03db9be00878f0c23a911fc486bc521b1 Mon Sep 17 00:00:00 2001 From: xujianhang Date: Fri, 29 Nov 2024 16:57:13 +0800 Subject: [PATCH 1/6] tapi: sync changes to CMakeLists.txt --- CMakeLists.txt | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c18c3a8..0651873 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,6 @@ if(CONFIG_TELEPHONY) set(CSRCS) file(GLOB APPEND_FILES ${CMAKE_CURRENT_LIST_DIR}/src/*.c) list(APPEND CSRCS ${APPEND_FILES}) - list(REMOVE_ITEM CSRCS ${CMAKE_CURRENT_LIST_DIR}/tools/telephony_tool.c) set(INCDIR ${NUTTX_APPS_DIR}/external/dbus/dbus ${NUTTX_APPS_DIR}/external/ofono/include @@ -49,6 +48,36 @@ if(CONFIG_TELEPHONY) tapi) endif() + if(CONFIG_TELEPHONY_TEST) + file(GLOB APPEND_FILES ${CMAKE_CURRENT_LIST_DIR}/test/*.c) + list(APPEND CSRCS ${APPEND_FILES}) + list(REMOVE_ITEM CSRCS ${CMAKE_CURRENT_LIST_DIR}/test/cmocka_telephony_test.c + ${CMAKE_CURRENT_LIST_DIR}/test/product_telephony_test.c) + set(MAINSRC) + + if(CONFIG_GOLDFISH_RIL) + list(APPEND MAINSRC test/cmocka_telephony_test.c) + else() + list(APPEND MAINSRC test/product_telephony_test.c) + endif() + + nuttx_add_application( + MODULE + ${CONFIG_TELEPHONY_TEST} + NAME + cmocka_telephony_test + STACKSIZE + ${CONFIG_TELEPHONY_TEST_STACKSIZE} + PRIORITY + ${CONFIG_TELEPHONY_TEST_PRIORITY} + SRCS + ${MAINSRC} + INCLUDE_DIRECTORIES + ${INCDIR} + DEPENDS + tapi cmocka) + endif() + target_include_directories(tapi PRIVATE ${INCDIR}) target_sources(tapi PRIVATE ${CSRCS}) endif() From 03a10f7c1f9db519b3f7f0665c835afd65935ae5 Mon Sep 17 00:00:00 2001 From: xujianhang Date: Mon, 9 Dec 2024 17:41:47 +0800 Subject: [PATCH 2/6] telephony: support deflect call --- src/tapi_call.c | 2 -- tools/telephony_tool.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/tapi_call.c b/src/tapi_call.c index 8bb444e..47e11ca 100644 --- a/src/tapi_call.c +++ b/src/tapi_call.c @@ -207,8 +207,6 @@ static void deflect_param_append_0(DBusMessageIter* iter, void* user_data) dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &number); - - free(param); } static void separate_param_append(DBusMessageIter* iter, void* user_data) diff --git a/tools/telephony_tool.c b/tools/telephony_tool.c index 6c7787c..623ae02 100644 --- a/tools/telephony_tool.c +++ b/tools/telephony_tool.c @@ -1395,6 +1395,24 @@ static int telephonytool_cmd_get_default_voicecall_slot(tapi_context context, ch return 0; } +static int telephonytool_cmd_deflect_call(tapi_context context, char* pargs) +{ + char dst[3][MAX_INPUT_ARGS_LEN]; + int cnt = split_input(dst, 3, pargs, " "); + char* slot_id; + + if (cnt != 3) + return -EINVAL; + + slot_id = dst[0]; + if (!is_valid_slot_id_str(dst[0])) + return -EINVAL; + + syslog(LOG_DEBUG, "%s, slotId: %s, call_id: %s, phone_number: %s", __func__, slot_id, (char*)dst[1], (char*)dst[2]); + + return tapi_call_deflect_by_id(context, atoi(slot_id), (char*)dst[1], (char*)dst[2]); +} + static int telephonytool_cmd_query_modem_list(tapi_context context, char* pargs) { if (strlen(pargs) > 0) @@ -4487,6 +4505,9 @@ static struct telephonytool_cmd_s g_telephonytool_cmds[] = { { "get-voicecall-slot", CALL_CMD, telephonytool_cmd_get_default_voicecall_slot, "get default data slot (enter example : get-voicecall-slot)" }, + { "deflect", CALL_CMD, + telephonytool_cmd_deflect_call, + "call deflect (enter example : deflect 0 /ril_0/voicecall01 15512345678)" }, /* Data Command */ { "listen-data", DATA_CMD, From 474d157a23ba0bd8f45e1d0e78358634e0994cf7 Mon Sep 17 00:00:00 2001 From: xujianhang Date: Tue, 10 Dec 2024 18:57:31 +0800 Subject: [PATCH 3/6] tapi: support hangup-all-multiparty --- src/tapi_call.c | 2 +- tools/telephony_tool.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/tapi_call.c b/src/tapi_call.c index 47e11ca..5673548 100644 --- a/src/tapi_call.c +++ b/src/tapi_call.c @@ -1346,7 +1346,7 @@ int tapi_call_separate_call(tapi_context context, int tapi_call_hangup_multiparty(tapi_context context, int slot_id) { - return manage_call_proxy_method(context, slot_id, "multiparty_hangup"); + return manage_call_proxy_method(context, slot_id, "HangupMultiparty"); } int tapi_call_send_tones(void* context, int slot_id, char* tones) diff --git a/tools/telephony_tool.c b/tools/telephony_tool.c index 623ae02..8285530 100644 --- a/tools/telephony_tool.c +++ b/tools/telephony_tool.c @@ -1030,6 +1030,22 @@ static int telephonytool_cmd_hangup_all(tapi_context context, char* pargs) return tapi_call_hangup_all_calls(context, atoi(slot_id)); } +static int telephonytool_cmd_hangup_multiparty(tapi_context context, char* pargs) +{ + char* slot_id; + char* temp; + + if (strlen(pargs) == 0) + return -EINVAL; + + slot_id = strtok_r(pargs, " ", &temp); + if (!is_valid_slot_id_str(slot_id)) + return -EINVAL; + + syslog(LOG_DEBUG, "%s, slotId : %s\n", __func__, slot_id); + return tapi_call_hangup_multiparty(context, atoi(slot_id)); +} + static int telephonytool_cmd_hangup_by_id(tapi_context context, char* pargs) { char dst[2][MAX_INPUT_ARGS_LEN]; @@ -4465,6 +4481,9 @@ static struct telephonytool_cmd_s g_telephonytool_cmds[] = { { "hangup-all", CALL_CMD, telephonytool_cmd_hangup_all, "hangup all call (enter example : hangup-all 0 [slot_id])" }, + { "hangup-all-multiparty", CALL_CMD, + telephonytool_cmd_hangup_multiparty, + "hang up all multiparty calls (enter example : hangup-multiparty 0 [slot_id])" }, { "get-call", CALL_CMD, telephonytool_cmd_get_call, "get call list/call info (enter example : get-call 0 " From fe080bb75bf7e99a7d46cbea2f772152eb38e05d Mon Sep 17 00:00:00 2001 From: xujianhang Date: Mon, 16 Dec 2024 19:58:29 +0800 Subject: [PATCH 4/6] tapi: support send-ussd --- src/tapi_ss.c | 145 ++++++++++------------------------------- tools/telephony_tool.c | 16 +---- 2 files changed, 36 insertions(+), 125 deletions(-) diff --git a/src/tapi_ss.c b/src/tapi_ss.c index c94a0ee..57a2610 100644 --- a/src/tapi_ss.c +++ b/src/tapi_ss.c @@ -311,97 +311,6 @@ static void enable_fdn_param_append(DBusMessageIter* iter, void* user_data) dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &passwd); } -static void fill_ss_cb_cf_response_info(DBusMessageIter* iter, - tapi_ss_initiate_info* info) -{ - while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_DICT_ENTRY) { - DBusMessageIter entry, value; - - dbus_message_iter_recurse(iter, &entry); - dbus_message_iter_get_basic(&entry, &info->append_service); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - dbus_message_iter_get_basic(&value, &info->append_service_value); - - dbus_message_iter_next(iter); - } -} - -static void fill_ss_initiate_cb_or_cf_service(DBusMessageIter* iter, - tapi_ss_initiate_info* info) -{ - while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRUCT) { - DBusMessageIter entry, value, dict; - - dbus_message_iter_recurse(iter, &entry); - dbus_message_iter_get_basic(&entry, &info->ss_service_operation); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - dbus_message_iter_get_basic(&value, &info->service_operation_requested); - - dbus_message_iter_next(&value); - dbus_message_iter_recurse(&value, &dict); - - fill_ss_cb_cf_response_info(&dict, info); - - dbus_message_iter_next(iter); - } -} - -static void fill_ss_initiate_cw_append_service(DBusMessageIter* iter, - tapi_ss_initiate_info* info) -{ - while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_DICT_ENTRY) { - DBusMessageIter entry, value; - - dbus_message_iter_recurse(iter, &entry); - dbus_message_iter_get_basic(&entry, &info->append_service); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - dbus_message_iter_get_basic(&value, &info->append_service_value); - - dbus_message_iter_next(iter); - } -} - -static void fill_ss_initiate_cw_service(DBusMessageIter* iter, - tapi_ss_initiate_info* info) -{ - while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRUCT) { - DBusMessageIter entry, value; - - dbus_message_iter_recurse(iter, &entry); - dbus_message_iter_get_basic(&entry, &info->ss_service_operation); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - - fill_ss_initiate_cw_append_service(&value, info); - - dbus_message_iter_next(iter); - } -} - -static void fill_ss_initiate_cs_service(DBusMessageIter* iter, - tapi_ss_initiate_info* info) -{ - while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRUCT) { - DBusMessageIter entry, value; - - dbus_message_iter_recurse(iter, &entry); - dbus_message_iter_get_basic(&entry, &info->ss_service_operation); - - dbus_message_iter_next(&entry); - dbus_message_iter_recurse(&entry, &value); - dbus_message_iter_get_basic(&value, &info->call_setting_status); - - dbus_message_iter_next(iter); - } -} - static void method_call_complete(DBusMessage* message, void* user_data) { tapi_async_handler* handler = user_data; @@ -534,7 +443,8 @@ static void ss_initiate_complete(DBusMessage* message, void* user_data) tapi_async_handler* handler; tapi_async_result* ar; tapi_async_function cb; - DBusMessageIter iter, value, var; + const char* name; + DBusMessageIter iter, var; DBusError err; handler = user_data; @@ -576,25 +486,35 @@ static void ss_initiate_complete(DBusMessage* message, void* user_data) goto done; } - dbus_message_iter_recurse(&iter, &value); - dbus_message_iter_get_basic(&value, &info->ss_service_type); + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) { + tapi_log_error("message iter type is not string in %s", __func__); + ar->status = ERROR; + goto done; + } - dbus_message_iter_next(&value); - dbus_message_iter_recurse(&value, &var); + dbus_message_iter_get_basic(&iter, &name); + dbus_message_iter_next(&iter); - if (dbus_message_iter_get_arg_type(&var) == DBUS_TYPE_VARIANT) { - if (strcmp(info->ss_service_type, "CallBarring") == 0 - || strcmp(info->ss_service_type, "CallForwarding") == 0) { - fill_ss_initiate_cb_or_cf_service(&var, info); - } else if (strcmp(info->ss_service_type, "CallWaiting") == 0) { - fill_ss_initiate_cw_service(&var, info); - } else if (strcmp(info->ss_service_type, "USSD") == 0) { - dbus_message_iter_get_basic(&var, &info->ussd_response); - } else { - fill_ss_initiate_cs_service(&var, info); - } + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) { + tapi_log_error("message iter type is not variant in %s", __func__); + ar->status = ERROR; + goto done; + } + + dbus_message_iter_recurse(&iter, &var); + if (strcmp(name, "USSD")) { + tapi_log_error("reponse is not ussd str in %s", __func__); + ar->status = ERROR; + goto done; } + if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING) { + tapi_log_error("get ussd str failed in %s", __func__); + ar->status = ERROR; + goto done; + } + + dbus_message_iter_get_basic(&var, &info->ussd_response); ar->data = info; ar->status = OK; @@ -606,7 +526,7 @@ static void ss_initiate_complete(DBusMessage* message, void* user_data) static void ss_send_ussd_cb(DBusMessage* message, void* user_data) { - DBusMessageIter iter, value; + DBusMessageIter iter; tapi_async_handler* handler; tapi_async_result* ar; tapi_async_function cb; @@ -645,8 +565,13 @@ static void ss_send_ussd_cb(DBusMessage* message, void* user_data) goto done; } - dbus_message_iter_recurse(&iter, &value); - dbus_message_iter_get_basic(&value, &response); + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) { + tapi_log_error("message iter type is not string in %s", __func__); + ar->status = ERROR; + goto done; + } + + dbus_message_iter_get_basic(&iter, &response); ar->data = response; ar->status = OK; diff --git a/tools/telephony_tool.c b/tools/telephony_tool.c index 8285530..f3ff533 100644 --- a/tools/telephony_tool.c +++ b/tools/telephony_tool.c @@ -577,21 +577,7 @@ static void ss_event_response(tapi_async_result* result) break; case EVENT_INITIATE_SERVICE_DONE: info = (tapi_ss_initiate_info*)result->data; - if (strcmp(info->ss_service_type, "CallBarring") == 0 - || strcmp(info->ss_service_type, "CallForwarding") == 0) { - syslog(LOG_DEBUG, "service type : %s (%s, %s, %s, %s) \n", info->ss_service_type, - info->ss_service_operation, info->service_operation_requested, - info->append_service, info->append_service_value); - } else if (strcmp(info->ss_service_type, "CallWaiting") == 0) { - syslog(LOG_DEBUG, "service type : %s (%s, %s, %s) \n", info->ss_service_type, - info->ss_service_operation, info->append_service, info->append_service_value); - } else if (strcmp(info->ss_service_type, "USSD") == 0) { - syslog(LOG_DEBUG, "service type : %s (%s) \n", - info->ss_service_type, info->ussd_response); - } else { - syslog(LOG_DEBUG, "service type : %s (%s, %s) \n", info->ss_service_type, - info->ss_service_operation, info->call_setting_status); - } + syslog(LOG_DEBUG, "USSD response: %s", info->ussd_response); break; case EVENT_QUERY_FDN_DONE: syslog(LOG_DEBUG, "fdn enabled or disabled : %d \n", param); From 9bf8c4a3cd6af8a47c826b38dfae716d5b1abceb Mon Sep 17 00:00:00 2001 From: xujianhang Date: Fri, 17 Jan 2025 12:02:56 +0800 Subject: [PATCH 5/6] telephonytest: fix TestTeleFunc_CI_CallDialNumber crash --- test/cmocka_telephony_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cmocka_telephony_test.c b/test/cmocka_telephony_test.c index 0f8c56d..039da39 100644 --- a/test/cmocka_telephony_test.c +++ b/test/cmocka_telephony_test.c @@ -272,6 +272,7 @@ static void TestNuttxUnlockPin(void** state) { (void)state; int ret = tapi_sim_unlock_pin_test(0); + sleep(4); assert_int_equal(ret, OK); } From 501948be02bf25e5b7f68a5f6c1ec639b835758c Mon Sep 17 00:00:00 2001 From: xujianhang Date: Mon, 6 Jan 2025 09:30:28 +0800 Subject: [PATCH 6/6] telephonytest: fix the bug caused by uninitialized variables --- test/telephony_network_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/telephony_network_test.c b/test/telephony_network_test.c index 2547bb5..0d45857 100644 --- a/test/telephony_network_test.c +++ b/test/telephony_network_test.c @@ -154,7 +154,7 @@ int tapi_net_select_manual_test(int slot_id, char* mcc, char* mnc, char* tech) int res = 0; judge_data_init(); judge_data.expect = EVENT_REGISTER_MANUAL_DONE; - tapi_operator_info* network_info = malloc(sizeof(tapi_operator_info)); + tapi_operator_info* network_info = calloc(1, sizeof(tapi_operator_info)); if (network_info == NULL) { syslog(LOG_ERR, "tapi_operator_info is null in %s", __func__); return -ENOMEM;