From 0be469b9b1a7a0c7a1d012f6614c5879da7bdc49 Mon Sep 17 00:00:00 2001 From: xujianhang Date: Thu, 7 Nov 2024 13:52:41 +0800 Subject: [PATCH 1/6] add tapi debug log: tapi_phonebook.c --- src/tapi_phonebook.c | 206 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 173 insertions(+), 33 deletions(-) diff --git a/src/tapi_phonebook.c b/src/tapi_phonebook.c index a83db57..2d7f11f 100644 --- a/src/tapi_phonebook.c +++ b/src/tapi_phonebook.c @@ -83,21 +83,31 @@ static void load_adn_entries_cb(DBusMessage* message, void* user_data) char* entries; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -122,21 +132,31 @@ static void load_fdn_entries_cb(DBusMessage* message, void* user_data) int index; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); + return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -184,8 +204,13 @@ static void insert_fdn_record_append(DBusMessageIter* iter, void* user_data) char* number; char* pin2; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid pin argument in %s!", __func__); return; } @@ -208,21 +233,31 @@ static void insert_fdn_record_cb(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -242,8 +277,13 @@ static void delete_fdn_record_append(DBusMessageIter* iter, void* user_data) int fdn_idx; char* pin2; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid pin argument in %s!", __func__); return; } @@ -264,8 +304,13 @@ static void update_fdn_record_append(DBusMessageIter* iter, void* user_data) int fdn_idx; char* pin2; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid pin argument in %s!", __func__); return; } @@ -288,20 +333,26 @@ static void method_call_complete(DBusMessage* message, void* user_data) tapi_async_function cb; DBusError err; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s error %s: %s \n", __func__, err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -325,18 +376,25 @@ int tapi_phonebook_load_adn_entries(tapi_context context, tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_PHONEBOOK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return -ENOMEM; } ar->msg_id = event_id; @@ -344,6 +402,7 @@ int tapi_phonebook_load_adn_entries(tapi_context context, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(ar); return -ENOMEM; } @@ -352,6 +411,7 @@ int tapi_phonebook_load_adn_entries(tapi_context context, if (!g_dbus_proxy_method_call(proxy, "Import", NULL, load_adn_entries_cb, user_data, handler_free)) { + tapi_log_error("method call failed in %s", __func__); handler_free(user_data); return -EINVAL; } @@ -367,18 +427,25 @@ int tapi_phonebook_load_fdn_entries(tapi_context context, tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_PHONEBOOK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return -ENOMEM; } ar->msg_id = event_id; @@ -388,6 +455,7 @@ int tapi_phonebook_load_fdn_entries(tapi_context context, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(ar); return -ENOMEM; } @@ -396,6 +464,7 @@ int tapi_phonebook_load_fdn_entries(tapi_context context, if (!g_dbus_proxy_method_call(proxy, "ImportFdn", NULL, load_fdn_entries_cb, user_data, handler_free)) { + tapi_log_error("method call failed in %s", __func__); handler_free(user_data); return -EINVAL; } @@ -412,19 +481,40 @@ int tapi_phonebook_insert_fdn_entry(tapi_context context, int slot_id, tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || name == NULL || number == NULL || pin2 == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (name == NULL) { + tapi_log_error("name in %s is null", __func__); + return -EINVAL; + } + + if (number == NULL) { + tapi_log_error("number in %s is null", __func__); + return -EINVAL; + } + + if (pin2 == NULL) { + tapi_log_error("pin2 in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_PHONEBOOK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } fdn_record = malloc(sizeof(fdn_record_param)); if (fdn_record == NULL) { + tapi_log_error("fdn record in %s is null", __func__); return -ENOMEM; } fdn_record->tag = name; @@ -433,6 +523,7 @@ int tapi_phonebook_insert_fdn_entry(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(fdn_record); return -ENOMEM; } @@ -442,6 +533,7 @@ int tapi_phonebook_insert_fdn_entry(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(fdn_record); free(ar); return -ENOMEM; @@ -452,6 +544,7 @@ int tapi_phonebook_insert_fdn_entry(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "InsertFdn", insert_fdn_record_append, insert_fdn_record_cb, user_data, phonebook_event_data_free)) { phonebook_event_data_free(user_data); + tapi_log_error("method call failed in %s", __func__); return -EINVAL; } @@ -467,19 +560,35 @@ int tapi_phonebook_delete_fdn_entry(tapi_context context, int slot_id, tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || fdn_idx < 1 || pin2 == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (fdn_idx < 1) { + tapi_log_error("invalid fdn idx in %s", __func__); + return -EINVAL; + } + + if (pin2 == NULL) { + tapi_log_error("pin2 in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_PHONEBOOK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } fdn_record = malloc(sizeof(fdn_record_param)); if (fdn_record == NULL) { + tapi_log_error("fdn record in %s is null", __func__); return -ENOMEM; } fdn_record->fdn_idx = fdn_idx; @@ -487,6 +596,7 @@ int tapi_phonebook_delete_fdn_entry(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(fdn_record); return -ENOMEM; } @@ -496,6 +606,7 @@ int tapi_phonebook_delete_fdn_entry(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(fdn_record); free(ar); return -ENOMEM; @@ -505,6 +616,7 @@ int tapi_phonebook_delete_fdn_entry(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "DeleteFdn", delete_fdn_record_append, method_call_complete, user_data, phonebook_event_data_free)) { + tapi_log_error("method call failed in %s", __func__); phonebook_event_data_free(user_data); return -EINVAL; } @@ -521,20 +633,45 @@ int tapi_phonebook_update_fdn_entry(tapi_context context, int slot_id, int event tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || fdn_idx < 1 || new_name == NULL - || new_number == NULL || pin2 == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (fdn_idx < 1) { + tapi_log_error("invalid fdn idx in %s", __func__); + return -EINVAL; + } + + if (new_name == NULL) { + tapi_log_error("new name in %s is null", __func__); + return -EINVAL; + } + + if (new_number == NULL) { + tapi_log_error("new number in %s is null", __func__); + return -EINVAL; + } + + if (pin2 == NULL) { + tapi_log_error("pin2 in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_PHONEBOOK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } fdn_record = malloc(sizeof(fdn_record_param)); if (fdn_record == NULL) { + tapi_log_error("fdn record in %s is null", __func__); return -ENOMEM; } fdn_record->fdn_idx = fdn_idx; @@ -544,6 +681,7 @@ int tapi_phonebook_update_fdn_entry(tapi_context context, int slot_id, int event ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(fdn_record); return -ENOMEM; } @@ -553,6 +691,7 @@ int tapi_phonebook_update_fdn_entry(tapi_context context, int slot_id, int event user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(fdn_record); free(ar); return -ENOMEM; @@ -563,6 +702,7 @@ int tapi_phonebook_update_fdn_entry(tapi_context context, int slot_id, int event if (!g_dbus_proxy_method_call(proxy, "UpdateFdn", update_fdn_record_append, method_call_complete, user_data, phonebook_event_data_free)) { phonebook_event_data_free(user_data); + tapi_log_error("method call failed in %s", __func__); return -EINVAL; } From 9f032e79e7eb53aeaed870c43c85e57e098db2ea Mon Sep 17 00:00:00 2001 From: xujianhang Date: Thu, 7 Nov 2024 17:36:42 +0800 Subject: [PATCH 2/6] add tapi debug log: tapi_sim.c --- src/tapi_sim.c | 557 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 451 insertions(+), 106 deletions(-) diff --git a/src/tapi_sim.c b/src/tapi_sim.c index 1546aed..0f62b9c 100644 --- a/src/tapi_sim.c +++ b/src/tapi_sim.c @@ -74,18 +74,25 @@ static int sim_property_changed(DBusConnection* connection, DBusMessageIter iter, var; const char* property; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return 0; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return 0; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return 0; + } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); return 0; } @@ -144,8 +151,13 @@ static void change_pin_param_append(DBusMessageIter* iter, void* user_data) char* old_pin; char* new_pin; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; } @@ -166,20 +178,26 @@ static void method_call_complete(DBusMessage* message, void* user_data) tapi_async_function cb; DBusError err; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s error %s: %s \n", __func__, err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -200,21 +218,31 @@ static void open_logical_channel_cb(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); + return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -238,21 +266,31 @@ static void transmit_apdu_cb(DBusMessage* message, void* user_data) int len; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -275,8 +313,13 @@ static void enter_pin_param_append(DBusMessageIter* iter, void* user_data) char* pin_type; char* pin; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; } @@ -296,8 +339,13 @@ static void reset_pin_param_append(DBusMessageIter* iter, void* user_data) char* new_pin; char* puk; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid pin argument in %s!", __func__); return; } @@ -318,8 +366,13 @@ static void lock_pin_param_append(DBusMessageIter* iter, void* user_data) char* pin_type; char* pin; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid pin argument in %s!", __func__); return; } @@ -338,8 +391,13 @@ static void unlock_pin_param_append(DBusMessageIter* iter, void* user_data) char* pin_type; char* pin; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid pin argument in %s!", __func__); return; } @@ -360,8 +418,13 @@ static void open_channel_param_append(DBusMessageIter* iter, void* user_data) int len; int i; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid argument in %s!", __func__); return; } @@ -383,8 +446,13 @@ static void close_channel_param_append(DBusMessageIter* iter, void* user_data) tapi_async_handler* param = user_data; int session_id; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid argument in %s!", __func__); return; } @@ -402,8 +470,13 @@ static void transmit_apdu_param_append(DBusMessageIter* iter, void* user_data) unsigned char* pdu; int i; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid argument in %s!", __func__); return; } @@ -432,8 +505,13 @@ static void transmit_apdu_basic_channel_param_append(DBusMessageIter* iter, void unsigned char* pdu; int i; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid argument in %s!", __func__); return; } @@ -461,16 +539,24 @@ int tapi_sim_has_icc_card(tapi_context context, int slot_id, bool* out) DBusMessageIter iter; int result; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -481,6 +567,7 @@ int tapi_sim_has_icc_card(tapi_context context, int slot_id, bool* out) return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -490,25 +577,33 @@ int tapi_sim_get_sim_state(tapi_context context, int slot_id, int* out) GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (g_dbus_proxy_get_property(proxy, "SimState", &iter)) { dbus_message_iter_get_basic(&iter, out); - return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -519,24 +614,32 @@ int tapi_sim_get_sim_iccid(tapi_context context, int slot_id, char** out) DBusMessageIter iter; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } has_icc_card = false; tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -545,6 +648,7 @@ int tapi_sim_get_sim_iccid(tapi_context context, int slot_id, char** out) return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -557,14 +661,28 @@ int tapi_sim_get_sim_operator(tapi_context context, int slot_id, int length, cha char* mcc; char* mnc; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } + + if (out == NULL) { + tapi_log_error("out in %s is null", __func__); + return -EINVAL; + } - if (out == NULL || length < (MAX_MCC_LENGTH + MAX_MNC_LENGTH + 1)) { + if (length < (MAX_MCC_LENGTH + MAX_MNC_LENGTH + 1)) { + tapi_log_error("length in %s is too small", __func__); return -EINVAL; } @@ -572,13 +690,13 @@ int tapi_sim_get_sim_operator(tapi_context context, int slot_id, int length, cha tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -592,8 +710,15 @@ int tapi_sim_get_sim_operator(tapi_context context, int slot_id, int length, cha dbus_message_iter_get_basic(&iter, &mnc); } - if (mcc == NULL || mnc == NULL) + if (mcc == NULL) { + tapi_log_error("mcc is null in %s", __func__); return -EIO; + } + + if (mnc == NULL) { + tapi_log_error("mnc is null in %s", __func__); + return -EIO; + } for (int i = 0; i < MAX_MCC_LENGTH; i++) *out++ = *mcc++; @@ -611,24 +736,32 @@ int tapi_sim_get_sim_operator_name(tapi_context context, int slot_id, char** out DBusMessageIter iter; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } has_icc_card = false; tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -637,6 +770,7 @@ int tapi_sim_get_sim_operator_name(tapi_context context, int slot_id, char** out return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -647,24 +781,32 @@ int tapi_sim_get_subscriber_id(tapi_context context, int slot_id, char** out) DBusMessageIter iter; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } has_icc_card = false; tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -673,6 +815,7 @@ int tapi_sim_get_subscriber_id(tapi_context context, int slot_id, char** out) return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -685,24 +828,37 @@ int tapi_sim_register(tapi_context context, int slot_id, const char* modem_path; int watch_id = 0; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || msg < MSG_SIM_STATE_CHANGE_IND || msg > MSG_SIM_ICCID_CHANGE_IND) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (msg < MSG_SIM_STATE_CHANGE_IND || msg > MSG_SIM_ICCID_CHANGE_IND) { + tapi_log_error("invalid msg type in %s", __func__); return -EINVAL; } modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("modem path is null in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } handler->cb_function = p_handle; ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -725,6 +881,7 @@ int tapi_sim_register(tapi_context context, int slot_id, } if (watch_id == 0) { + tapi_log_error("add signal watch failed in %s, msg_id: %d", __func__, (int)msg); handler_free(handler); return -EINVAL; } @@ -736,11 +893,20 @@ int tapi_sim_unregister(tapi_context context, int watch_id) { dbus_context* ctx = context; - if (ctx == NULL || watch_id <= 0) + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; + } - if (!g_dbus_remove_watch(ctx->connection, watch_id)) + if (watch_id <= 0) { + tapi_log_error("invalid watch id in %s", __func__); return -EINVAL; + } + + if (!g_dbus_remove_watch(ctx->connection, watch_id)) { + tapi_log_error("remove signal watch failed in %s", __func__); + return -EINVAL; + } return OK; } @@ -755,8 +921,28 @@ int tapi_sim_change_pin(tapi_context context, int slot_id, GDBusProxy* proxy; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || pin_type == NULL || old_pin == NULL || new_pin == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (pin_type == NULL) { + tapi_log_error("pin type is null in %s", __func__); + return -EINVAL; + } + + if (old_pin == NULL) { + tapi_log_error("old pin is null in %s", __func__); + return -EINVAL; + } + + if (new_pin == NULL) { + tapi_log_error("new pin is null in %s", __func__); return -EINVAL; } @@ -764,18 +950,19 @@ int tapi_sim_change_pin(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } change_pin_param = malloc(sizeof(sim_pin_param)); if (change_pin_param == NULL) { + tapi_log_error("change_pin_param in %s is null", __func__); return -ENOMEM; } change_pin_param->pin_type = pin_type; @@ -784,6 +971,7 @@ int tapi_sim_change_pin(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(change_pin_param); return -ENOMEM; } @@ -793,6 +981,7 @@ int tapi_sim_change_pin(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(change_pin_param); free(ar); return -ENOMEM; @@ -802,6 +991,7 @@ int tapi_sim_change_pin(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "ChangePin", change_pin_param_append, method_call_complete, user_data, sim_event_data_free)) { + tapi_log_error("method call failed in %s", __func__); sim_event_data_free(user_data); return -EINVAL; } @@ -819,8 +1009,23 @@ int tapi_sim_enter_pin(tapi_context context, int slot_id, GDBusProxy* proxy; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || pin_type == NULL || pin == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (pin_type == NULL) { + tapi_log_error("pin type is null in %s", __func__); + return -EINVAL; + } + + if (pin == NULL) { + tapi_log_error("pin is null in %s", __func__); return -EINVAL; } @@ -828,18 +1033,19 @@ int tapi_sim_enter_pin(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } enter_pin_param = malloc(sizeof(sim_pin_param)); if (enter_pin_param == NULL) { + tapi_log_error("enter_pin_param in %s is null", __func__); return -ENOMEM; } enter_pin_param->pin_type = pin_type; @@ -847,6 +1053,7 @@ int tapi_sim_enter_pin(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(enter_pin_param); return -ENOMEM; } @@ -856,6 +1063,7 @@ int tapi_sim_enter_pin(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(enter_pin_param); free(ar); return -ENOMEM; @@ -866,6 +1074,7 @@ int tapi_sim_enter_pin(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "EnterPin", enter_pin_param_append, method_call_complete, user_data, sim_event_data_free)) { sim_event_data_free(user_data); + tapi_log_error("method call failed in %s", __func__); return -EINVAL; } @@ -882,8 +1091,28 @@ int tapi_sim_reset_pin(tapi_context context, int slot_id, GDBusProxy* proxy; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || puk_type == NULL || puk == NULL || new_pin == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (puk_type == NULL) { + tapi_log_error("puk type is null in %s", __func__); + return -EINVAL; + } + + if (puk == NULL) { + tapi_log_error("puk is null in %s", __func__); + return -EINVAL; + } + + if (new_pin == NULL) { + tapi_log_error("new pin is null in %s", __func__); return -EINVAL; } @@ -891,18 +1120,19 @@ int tapi_sim_reset_pin(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } reset_pin_param = malloc(sizeof(sim_pin_param)); if (reset_pin_param == NULL) { + tapi_log_error("reset_pin_param in %s is null", __func__); return -ENOMEM; } reset_pin_param->puk_type = puk_type; @@ -911,6 +1141,7 @@ int tapi_sim_reset_pin(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(reset_pin_param); return -ENOMEM; } @@ -920,6 +1151,7 @@ int tapi_sim_reset_pin(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(reset_pin_param); free(ar); return -ENOMEM; @@ -929,6 +1161,7 @@ int tapi_sim_reset_pin(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "ResetPin", reset_pin_param_append, method_call_complete, user_data, sim_event_data_free)) { + tapi_log_error("method call failed in %s", __func__); sim_event_data_free(user_data); return -EINVAL; } @@ -946,8 +1179,23 @@ int tapi_sim_lock_pin(tapi_context context, int slot_id, tapi_async_result* ar; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || pin_type == NULL || pin == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (pin_type == NULL) { + tapi_log_error("pin_type in %s is null ", __func__); + return -EINVAL; + } + + if (pin == NULL) { + tapi_log_error("pin in %s is null", __func__); return -EINVAL; } @@ -955,18 +1203,19 @@ int tapi_sim_lock_pin(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } lock_pin_param = malloc(sizeof(sim_pin_param)); if (lock_pin_param == NULL) { + tapi_log_error("lock_pin_param in %s is null", __func__); return -ENOMEM; } lock_pin_param->pin_type = pin_type; @@ -974,6 +1223,7 @@ int tapi_sim_lock_pin(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(lock_pin_param); return -ENOMEM; } @@ -983,6 +1233,7 @@ int tapi_sim_lock_pin(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(lock_pin_param); free(ar); return -ENOMEM; @@ -992,6 +1243,7 @@ int tapi_sim_lock_pin(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "LockPin", lock_pin_param_append, method_call_complete, user_data, sim_event_data_free)) { + tapi_log_error("method call failed in %s", __func__); sim_event_data_free(user_data); return -EINVAL; } @@ -1009,8 +1261,23 @@ int tapi_sim_unlock_pin(tapi_context context, int slot_id, tapi_async_result* ar; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || pin_type == NULL || pin == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (pin_type == NULL) { + tapi_log_error("pin_type in %s is null", __func__); + return -EINVAL; + } + + if (pin == NULL) { + tapi_log_error("pin in %s is null", __func__); return -EINVAL; } @@ -1018,18 +1285,19 @@ int tapi_sim_unlock_pin(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } unlock_pin_param = malloc(sizeof(sim_pin_param)); if (unlock_pin_param == NULL) { + tapi_log_error("unlock_pin_param in %s is null", __func__); return -ENOMEM; } unlock_pin_param->pin_type = pin_type; @@ -1037,6 +1305,7 @@ int tapi_sim_unlock_pin(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(unlock_pin_param); return -ENOMEM; } @@ -1046,6 +1315,7 @@ int tapi_sim_unlock_pin(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(unlock_pin_param); free(ar); return -ENOMEM; @@ -1055,6 +1325,7 @@ int tapi_sim_unlock_pin(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "UnlockPin", unlock_pin_param_append, method_call_complete, user_data, sim_event_data_free)) { + tapi_log_error("method call failed in %s", __func__); sim_event_data_free(user_data); return -EINVAL; } @@ -1072,8 +1343,18 @@ int tapi_sim_open_logical_channel(tapi_context context, int slot_id, GDBusProxy* proxy; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || aid == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (aid == NULL) { + tapi_log_error("aid in %s is null", __func__); return -EINVAL; } @@ -1081,18 +1362,19 @@ int tapi_sim_open_logical_channel(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } open_channel_param = malloc(sizeof(sim_transmit_apdu_param)); if (open_channel_param == NULL) { + tapi_log_error("open_channel_param in %s is null", __func__); return -ENOMEM; } open_channel_param->apdu_data = aid; @@ -1100,6 +1382,7 @@ int tapi_sim_open_logical_channel(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(open_channel_param); return -ENOMEM; } @@ -1109,6 +1392,7 @@ int tapi_sim_open_logical_channel(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(open_channel_param); free(ar); return -ENOMEM; @@ -1118,6 +1402,7 @@ int tapi_sim_open_logical_channel(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "OpenLogicalChannel", open_channel_param_append, open_logical_channel_cb, user_data, handler_free)) { + tapi_log_error("method call failed in %s", __func__); handler_free(user_data); free(open_channel_param); return -EINVAL; @@ -1135,7 +1420,13 @@ int tapi_sim_close_logical_channel(tapi_context context, int slot_id, GDBusProxy* proxy; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } @@ -1143,18 +1434,19 @@ int tapi_sim_close_logical_channel(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return -ENOMEM; } ar->msg_id = event_id; @@ -1163,6 +1455,7 @@ int tapi_sim_close_logical_channel(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(ar); return -ENOMEM; } @@ -1171,6 +1464,7 @@ int tapi_sim_close_logical_channel(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "CloseLogicalChannel", close_channel_param_append, method_call_complete, user_data, handler_free)) { + tapi_log_error("method call failed in %s", __func__); handler_free(user_data); return -EINVAL; } @@ -1189,8 +1483,18 @@ int tapi_sim_transmit_apdu_logical_channel(tapi_context context, int slot_id, GDBusProxy* proxy; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || pdu == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (pdu == NULL) { + tapi_log_error("pdu in %s is null", __func__); return -EINVAL; } @@ -1198,18 +1502,19 @@ int tapi_sim_transmit_apdu_logical_channel(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } transmit_apdu_param = malloc(sizeof(sim_transmit_apdu_param)); if (transmit_apdu_param == NULL) { + tapi_log_error("transmit_apdu_param in %s is null", __func__); return -ENOMEM; } transmit_apdu_param->session_id = session_id; @@ -1218,6 +1523,7 @@ int tapi_sim_transmit_apdu_logical_channel(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(transmit_apdu_param); return -ENOMEM; } @@ -1227,6 +1533,7 @@ int tapi_sim_transmit_apdu_logical_channel(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(transmit_apdu_param); free(ar); return -ENOMEM; @@ -1236,6 +1543,7 @@ int tapi_sim_transmit_apdu_logical_channel(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "TransmitApduLogicalChannel", transmit_apdu_param_append, transmit_apdu_cb, user_data, handler_free)) { + tapi_log_error("method call failed in %s", __func__); handler_free(user_data); free(transmit_apdu_param); return -EINVAL; @@ -1254,7 +1562,18 @@ int tapi_sim_transmit_apdu_basic_channel(tapi_context context, int slot_id, GDBusProxy* proxy; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || pdu == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (pdu == NULL) { + tapi_log_error("pdu in %s is null", __func__); return -EINVAL; } @@ -1262,18 +1581,19 @@ int tapi_sim_transmit_apdu_basic_channel(tapi_context context, int slot_id, tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } transmit_apdu_param = malloc(sizeof(sim_transmit_apdu_param)); if (transmit_apdu_param == NULL) { + tapi_log_error("transmit_apdu_param in %s is null", __func__); return -ENOMEM; } transmit_apdu_param->apdu_data = pdu; @@ -1281,6 +1601,7 @@ int tapi_sim_transmit_apdu_basic_channel(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(transmit_apdu_param); return -ENOMEM; } @@ -1290,6 +1611,7 @@ int tapi_sim_transmit_apdu_basic_channel(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); free(transmit_apdu_param); free(ar); return -ENOMEM; @@ -1300,6 +1622,7 @@ int tapi_sim_transmit_apdu_basic_channel(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "TransmitApduBasicChannel", transmit_apdu_basic_channel_param_append, transmit_apdu_cb, user_data, handler_free)) { + tapi_log_error("method call failed in %s", __func__); handler_free(user_data); free(transmit_apdu_param); return -EINVAL; @@ -1316,29 +1639,39 @@ int tapi_sim_get_uicc_enablement(tapi_context context, int slot_id, tapi_sim_uic bool has_icc_card; int result; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client not ready in %s", __func__); return -EAGAIN; + } has_icc_card = false; tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } - if (!g_dbus_proxy_get_property(proxy, "UiccActive", &iter)) + if (!g_dbus_proxy_get_property(proxy, "UiccActive", &iter)) { + tapi_log_error("get property failed in %s", __func__); return ERROR; + } dbus_message_iter_get_basic(&iter, &result); *out = result; @@ -1355,33 +1688,44 @@ int tapi_sim_set_uicc_enablement(tapi_context context, int value = state; bool has_icc_card; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client not ready in %s", __func__); return -EAGAIN; + } has_icc_card = false; tapi_sim_has_icc_card(context, slot_id, &has_icc_card); if (!has_icc_card) { - tapi_log_error("Error: no sim, return!!! \n"); + tapi_log_error("Error: no sim in %s, return!!!", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1393,6 +1737,7 @@ int tapi_sim_set_uicc_enablement(tapi_context context, if (!g_dbus_proxy_set_property_basic(proxy, "UiccActive", DBUS_TYPE_INT32, &value, property_set_done, handler, handler_free)) { + tapi_log_error("set property failed in %s", __func__); handler_free(handler); return -EINVAL; } From 03b404eb5a66bf8eb0b2da6e01dccb00fd07b45f Mon Sep 17 00:00:00 2001 From: xujianhang Date: Thu, 7 Nov 2024 19:23:51 +0800 Subject: [PATCH 3/6] add tapi debug log: tapi_sms.c --- src/tapi_sms.c | 276 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 223 insertions(+), 53 deletions(-) diff --git a/src/tapi_sms.c b/src/tapi_sms.c index 2d8c278..d30350d 100644 --- a/src/tapi_sms.c +++ b/src/tapi_sms.c @@ -81,8 +81,15 @@ static void send_message_param_append(DBusMessageIter* iter, void* user_data) tapi_async_handler* param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); return; + } + + if (param->result == NULL) { + tapi_log_error("invalid message argument in %s!", __func__); + return; + } msg_param = param->result->data; @@ -98,8 +105,15 @@ static void send_data_message_param_append(DBusMessageIter* iter, void* user_dat tapi_async_handler* param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); return; + } + + if (param->result == NULL) { + tapi_log_error("invalid message argument in %s!", __func__); + return; + } message = param->result->data; @@ -135,26 +149,33 @@ static void send_sms_callback(DBusMessage* message, void* user_data) DBusError err; char* uuid; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -184,8 +205,10 @@ static char* proxy_get_string(GDBusProxy* proxy, const char* property) DBusMessageIter iter; char* str; - if (!g_dbus_proxy_get_property(proxy, property, &iter)) + if (!g_dbus_proxy_get_property(proxy, property, &iter)) { + tapi_log_error("failed to get property %s", property); return NULL; + } dbus_message_iter_get_basic(&iter, &str); return str; @@ -205,32 +228,43 @@ static int unsol_sms_message(DBusConnection* connection, tapi_async_function cb; tapi_message_info* message_info = NULL; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return 0; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return 0; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return 0; + } - if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL) + if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL) { + tapi_log_error("message type is not signal in %s", __func__); return 0; + } sender = dbus_message_get_sender(message); if (sender == NULL) { + tapi_log_error("sender in %s is null", __func__); ar->status = ERROR; goto done; } if (!dbus_message_iter_init(message, &iter)) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) { + tapi_log_error("message iter get arg type failed in %s", __func__); ar->status = ERROR; goto done; } @@ -245,6 +279,7 @@ static int unsol_sms_message(DBusConnection* connection, message_info = malloc(sizeof(tapi_message_info)); if (message_info == NULL) { + tapi_log_error("message_info in %s is null", __func__); ar->status = ERROR; goto done; } @@ -297,19 +332,27 @@ static int sms_property_changed(DBusConnection* connection, const char* property; const char* slot; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return 0; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return 0; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return 0; + } - if (dbus_message_iter_init(message, &iter) == false) + if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); return 0; + } dbus_message_iter_get_basic(&iter, &property); dbus_message_iter_next(&iter); @@ -375,31 +418,41 @@ static void message_list_query_complete(DBusMessage* message, void* user_data) int message_count = 0; DBusError err; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } ar->status = ERROR; cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } // start to handle response message. dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); goto done; } - if (dbus_message_has_signature(message, "a(oa{sv})") == false) + if (dbus_message_has_signature(message, "a(oa{sv})") == false) { + tapi_log_error("message signature is invalid in %s", __func__); goto done; + } - if (dbus_message_iter_init(message, &args) == false) + if (dbus_message_iter_init(message, &args) == false) { + tapi_log_error("message iter init failed in %s", __func__); goto done; + } dbus_message_iter_recurse(&args, &list); @@ -486,29 +539,44 @@ int tapi_sms_send_message(tapi_context context, int slot_id, int sms_id, report_data_logging_for_sms(ctx, tapi_sms_get_op_code(context, slot_id), OFONO_SMS_TYPE_UNKNOW, OFONO_SMS_SEND, OFONO_SMS_NORMAL); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } - if (number == NULL || text == NULL) { + if (number == NULL) { + tapi_log_error("number in %s is null", __func__); + return -EINVAL; + } + + if (text == NULL) { + tapi_log_error("text in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } message = calloc(1, sizeof(message_param)); - if (message == NULL) + if (message == NULL) { + tapi_log_error("message in %s is null", __func__); return -EINVAL; + } message->number = strdup0(number); message->text = strdup0(text); ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); message_free(message); return -ENOMEM; } @@ -519,6 +587,7 @@ int tapi_sms_send_message(tapi_context context, int slot_id, int sms_id, handler = malloc(sizeof(tapi_async_handler)); if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); message_free(message); free(ar); return -ENOMEM; @@ -528,6 +597,7 @@ int tapi_sms_send_message(tapi_context context, int slot_id, int sms_id, if (!g_dbus_proxy_method_call(proxy, "SendMessage", send_message_param_append, send_sms_callback, handler, handler_free)) { + tapi_log_error("method call failed in %s", __func__); report_data_logging_for_sms(ctx, tapi_sms_get_op_code(context, slot_id), OFONO_CS_SMS, OFONO_SMS_SEND, OFONO_SMS_FAIL); handler_free(handler); @@ -550,23 +620,37 @@ int tapi_sms_send_data_message(tapi_context context, int slot_id, int sms_id, report_data_logging_for_sms(ctx, tapi_sms_get_op_code(context, slot_id), OFONO_SMS_TYPE_UNKNOW, OFONO_SMS_SEND, OFONO_SMS_NORMAL); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (dest_addr == NULL) { + tapi_log_error("dest_addr in %s is null", __func__); return -EINVAL; } - if (dest_addr == NULL || text == NULL) { + if (text == NULL) { + tapi_log_error("text in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } data_message = calloc(1, sizeof(data_message_param)); - if (data_message == NULL) + if (data_message == NULL) { + tapi_log_error("data_message in %s is null", __func__); return -ENOMEM; + } data_message->dest_addr = strdup0(dest_addr); data_message->data = strdup0(text); @@ -574,6 +658,7 @@ int tapi_sms_send_data_message(tapi_context context, int slot_id, int sms_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); data_message_free(data_message); return -ENOMEM; } @@ -585,6 +670,7 @@ int tapi_sms_send_data_message(tapi_context context, int slot_id, int sms_id, handler = malloc(sizeof(tapi_async_handler)); if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); data_message_free(data_message); free(ar); return -ENOMEM; @@ -595,6 +681,7 @@ int tapi_sms_send_data_message(tapi_context context, int slot_id, int sms_id, if (!g_dbus_proxy_method_call(proxy, "SendDataMessage", send_data_message_param_append, send_sms_callback, handler, handler_free)) { + tapi_log_error("method call failed in %s", __func__); report_data_logging_for_sms(ctx, tapi_sms_get_op_code(context, slot_id), OFONO_IMS_SMS, OFONO_SMS_SEND, OFONO_SMS_FAIL); handler_free(handler); @@ -610,25 +697,35 @@ bool tapi_sms_set_service_center_address(tapi_context context, int slot_id, char dbus_context* ctx = context; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } if (number == NULL) { + tapi_log_error("number in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (!g_dbus_proxy_set_property_basic(proxy, "ServiceCenterAddress", DBUS_TYPE_STRING, &number, NULL, NULL, NULL)) { + tapi_log_error("set property failed in %s", __func__); return -EINVAL; } @@ -640,13 +737,19 @@ int tapi_sms_get_service_center_address(tapi_context context, int slot_id, char* dbus_context* ctx = context; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -662,23 +765,32 @@ int tapi_sms_get_all_messages_from_sim(tapi_context context, int slot_id, tapi_async_handler* user_data; tapi_async_result* ar; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } user_data = malloc(sizeof(tapi_async_handler)); - if (user_data == NULL) + if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); return -ENOMEM; + } user_data->cb_function = p_handle; ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(user_data); return -ENOMEM; } @@ -689,6 +801,7 @@ int tapi_sms_get_all_messages_from_sim(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "GetAllMessagesFromSim", NULL, message_list_query_complete, user_data, handler_free)) { + tapi_log_error("method call failed in %s", __func__); handler_free(user_data); return -EINVAL; } @@ -703,23 +816,42 @@ int tapi_sms_copy_message_to_sim(tapi_context context, int slot_id, GDBusProxy* proxy; tapi_message_info* message_info; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (number == NULL) { + tapi_log_error("number in %s is null", __func__); + return -EINVAL; + } + + if (text == NULL) { + tapi_log_error("text in %s is null", __func__); return -EINVAL; } - if (number == NULL || text == NULL || send_time == NULL) { + if (send_time == NULL) { + tapi_log_error("send_time in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } message_info = calloc(1, sizeof(tapi_message_info)); - if (message_info == NULL) + if (message_info == NULL) { + tapi_log_error("message_info in %s is null", __func__); return -ENOMEM; + } message_info->text = strdup0(text); message_info->sender = strdup0(number); @@ -728,6 +860,7 @@ int tapi_sms_copy_message_to_sim(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "InsertMessageToSim", copy_message_param_append, NULL, message_info, message_info_free)) { + tapi_log_error("method call failed in %s", __func__); message_info_free(message_info); return -EINVAL; } @@ -740,22 +873,30 @@ int tapi_sms_delete_message_from_sim(tapi_context context, int slot_id, int inde dbus_context* ctx = context; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; } if (index < 0) { + tapi_log_error("invalid index in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (!g_dbus_proxy_method_call(proxy, "DeleteMessageFromSim", delete_message_param_append, no_operate_callback, (void*)(intptr_t)index, NULL)) { + tapi_log_error("method call failed in %s", __func__); return -EINVAL; } @@ -771,24 +912,37 @@ int tapi_sms_register(tapi_context context, int slot_id, tapi_async_result* ar; int watch_id = 0; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || msg_type < MSG_INCOMING_MESSAGE_IND || msg_type > MSG_DEFAULT_SMS_SLOT_CHANGED_IND) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id in %s", __func__); + return -EINVAL; + } + + if (msg_type < MSG_INCOMING_MESSAGE_IND || msg_type > MSG_DEFAULT_SMS_SLOT_CHANGED_IND) { + tapi_log_error("invalid msg type in %s, msg_type: %d", __func__, msg_type); return -EINVAL; } path = tapi_utils_get_modem_path(slot_id); if (path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } user_data = malloc(sizeof(tapi_async_handler)); - if (user_data == NULL) + if (user_data == NULL) { + tapi_log_error("user data in %s is null", __func__); return -ENOMEM; + } user_data->cb_function = p_handle; ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(user_data); return -ENOMEM; } @@ -825,6 +979,7 @@ int tapi_sms_register(tapi_context context, int slot_id, } if (watch_id == 0) { + tapi_log_error("watch id is 0 in %s, msg_id: %d", __func__, (int)msg_type); handler_free(user_data); return -EINVAL; } @@ -840,19 +995,24 @@ int tapi_sms_set_default_slot(tapi_context context, int slot_id) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("proxy in %s is null", __func__); return -EIO; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } - if (!tapi_is_valid_slotid(slot_id) && slot_id != -1) + if (!tapi_is_valid_slotid(slot_id) && slot_id != -1) { + tapi_log_error("invalid slot id in %s", __func__); return -EINVAL; + } modem_path = tapi_utils_get_modem_path(slot_id); if (!g_dbus_proxy_set_property_basic(proxy, "SmsSlot", DBUS_TYPE_STRING, &modem_path, NULL, NULL, NULL)) { + tapi_log_error("set property failed in %s", __func__); return -EINVAL; } @@ -868,12 +1028,14 @@ int tapi_sms_get_default_slot(tapi_context context, int* out) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } if (g_dbus_proxy_get_property(proxy, "SmsSlot", &iter)) { dbus_message_iter_get_basic(&iter, &modem_path); @@ -881,14 +1043,22 @@ int tapi_sms_get_default_slot(tapi_context context, int* out) return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } int tapi_sms_unregister(tapi_context context, int watch_id) { dbus_context* ctx = context; - if (ctx == NULL || watch_id <= 0) + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; + } + + if (watch_id <= 0) { + tapi_log_error("invalid watch id in %s, watch_id: %d", __func__, watch_id); + return -EINVAL; + } return g_dbus_remove_watch(ctx->connection, watch_id); } From 96e54a2186ee0286060c5018b1ec48b0a4b4f100 Mon Sep 17 00:00:00 2001 From: xujianhang Date: Fri, 8 Nov 2024 13:55:23 +0800 Subject: [PATCH 4/6] add tapi debug log: tapi_ss.c --- src/tapi_ss.c | 728 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 585 insertions(+), 143 deletions(-) diff --git a/src/tapi_ss.c b/src/tapi_ss.c index 12dc298..f035d06 100644 --- a/src/tapi_ss.c +++ b/src/tapi_ss.c @@ -55,8 +55,13 @@ static void set_clir_append(DBusMessageIter* iter, void* user_data) tapi_clir_status status; const char* clir_status; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid clir value !!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid clir value in %s !!", __func__); return; } @@ -70,8 +75,13 @@ static void set_call_waiting_append(DBusMessageIter* iter, void* user_data) tapi_async_handler* param = user_data; int enable; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid call waiting value!!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid call waiting value in %s!!", __func__); return; } @@ -85,8 +95,13 @@ static void query_call_forwarding_option_append(DBusMessageIter* iter, void* use int option; int cls; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid call forwarding option !!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid call forwarding option in %s!!", __func__); return; } @@ -104,8 +119,13 @@ static void set_call_forwarding_option_append(DBusMessageIter* iter, void* user_ int cls; char* number; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid call forwarding option !!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid call forwarding option in %s!!", __func__); return; } @@ -125,8 +145,15 @@ static void cb_request_param_append(DBusMessageIter* iter, void* user_data) DBusMessageIter value; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } set_property_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &set_property_param->key); @@ -146,8 +173,15 @@ static void cb_change_passwd_append(DBusMessageIter* iter, void* user_data) char* new_passwd; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); + return; + } change_passwd_param = param->result->data; old_passwd = change_passwd_param->old_passwd; @@ -163,8 +197,15 @@ static void disable_all_cb_param_append(DBusMessageIter* iter, void* user_data) tapi_async_handler* param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } disable_all_cb_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &disable_all_cb_param); @@ -176,8 +217,15 @@ static void disable_all_incoming_param_append(DBusMessageIter* iter, void* user_ tapi_async_handler* param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } disable_all_incoming_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &disable_all_incoming_param); @@ -189,8 +237,15 @@ static void disable_all_outgoing_param_append(DBusMessageIter* iter, void* user_ tapi_async_handler* param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); + return; + } disable_all_outgoing_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &disable_all_outgoing_param); @@ -202,8 +257,15 @@ static void ss_initiate_param_append(DBusMessageIter* iter, void* user_data) char* ss_initiate_param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } ss_initiate_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &ss_initiate_param); @@ -215,8 +277,15 @@ static void send_ussd_param_append(DBusMessageIter* iter, void* user_data) char* send_ussd_param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } send_ussd_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &send_ussd_param); @@ -228,8 +297,15 @@ static void enable_fdn_param_append(DBusMessageIter* iter, void* user_data) char* passwd; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); + return; + } passwd = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &passwd); @@ -333,20 +409,26 @@ static void method_call_complete(DBusMessage* message, void* user_data) tapi_async_function cb; DBusError err; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s error %s: %s \n", __func__, err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -386,30 +468,39 @@ static void call_forwarding_query_complete(DBusMessage* message, void* user_data DBusError err; tapi_call_forward_info* cf_condition; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } cf_condition = malloc(sizeof(tapi_call_forward_info)); - if (cf_condition == NULL) + if (cf_condition == NULL) { + tapi_log_error("cf_condition in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s error %s: %s \n", __func__, err.name, err.message); + tapi_log_error("error from mesage in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &args) == false) { + tapi_log_error("dbus message iter init fail in %s", __func__); ar->status = ERROR; goto done; } @@ -447,33 +538,40 @@ static void ss_initiate_complete(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } info = malloc(sizeof(tapi_ss_initiate_info)); if (info == NULL) { - tapi_log_error("no memory ... \n"); + tapi_log_error("info in %s is null", __func__); ar->status = ERROR; goto done; } @@ -516,26 +614,33 @@ static void ss_send_ussd_cb(DBusMessage* message, void* user_data) char* response; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -559,21 +664,31 @@ static void query_fdn_cb(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -595,21 +710,31 @@ static void query_call_waiting_cb(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -631,21 +756,31 @@ static void query_clir_cb(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -687,30 +822,38 @@ static int call_barring_property_changed(DBusConnection* connection, DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return false; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return false; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return false; + } if (ar->msg_id != MSG_CALL_BARRING_PROPERTY_CHANGE_IND) { + tapi_log_error("msg id in %s is invalid", __func__); return false; } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -719,7 +862,7 @@ static int call_barring_property_changed(DBusConnection* connection, cb_value = malloc(sizeof(tapi_call_barring_info)); if (cb_value == NULL) { - tapi_log_error("no memory ... \n"); + tapi_log_error("cb_value in %s is null", __func__); ar->status = ERROR; goto done; } @@ -766,30 +909,38 @@ static int ussd_state_changed(DBusConnection* connection, char* ussd_state; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return false; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return false; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return false; + } if (ar->msg_id != MSG_USSD_PROPERTY_CHANGE_IND) { + tapi_log_error("msg id in %s is invalid", __func__); return false; } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -836,16 +987,22 @@ static int ussd_notification_received(DBusConnection* connection, DBusMessageIter iter; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return false; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return false; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return false; + } if (is_ussd_signal_message(message, &iter, DBUS_TYPE_STRING)) { char* notification_message; @@ -869,16 +1026,22 @@ static int ussd_request_received(DBusConnection* connection, DBusMessageIter iter; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return false; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return false; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return false; + } if (is_ussd_signal_message(message, &iter, DBUS_TYPE_STRING)) { char* request_message; @@ -932,22 +1095,36 @@ int tapi_ss_initiate_service(tapi_context context, int slot_id, int event_id, report_data_logging_for_ss(ctx, "ss:ussd:request", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || command == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (command == NULL) { + tapi_log_error("command in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -961,7 +1138,7 @@ int tapi_ss_initiate_service(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, "Initiate", ss_initiate_param_append, ss_initiate_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:ussd:request", "dbus method fail"); - tapi_log_error("failed to initiate service \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -980,22 +1157,31 @@ int tapi_ss_request_call_barring(tapi_context context, int slot_id, int event_id report_data_logging_for_ss(ctx, "ss:request callbarring", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1008,7 +1194,7 @@ int tapi_ss_request_call_barring(tapi_context context, int slot_id, int event_id if (!g_dbus_proxy_method_call(proxy, "GetProperties", NULL, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:request callbarring", "dbus method fail"); - tapi_log_error("failed to request callbarring \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1030,23 +1216,41 @@ int tapi_ss_set_call_barring_option(tapi_context context, int slot_id, int event report_data_logging_for_ss(ctx, "ss:set callbarring", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || facility == NULL || pin2 == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (facility == NULL) { + tapi_log_error("facility in %s is null", __func__); + return -EINVAL; + } + + if (pin2 == NULL) { + tapi_log_error("pin2 in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1054,6 +1258,7 @@ int tapi_ss_set_call_barring_option(tapi_context context, int slot_id, int event param = malloc(sizeof(cb_request_param)); if (param == NULL) { + tapi_log_error("param in %s is null", __func__); free(handler); free(ar); return -ENOMEM; @@ -1092,7 +1297,7 @@ int tapi_ss_set_call_barring_option(tapi_context context, int slot_id, int event if (!g_dbus_proxy_method_call(proxy, "SetProperty", cb_request_param_append, method_call_complete, handler, ss_event_data_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring", "dbus method fail"); - tapi_log_error("failed to set callbarring \n"); + tapi_log_error("method call fail in %s", __func__); ss_event_data_free(handler); return -EINVAL; } @@ -1106,16 +1311,29 @@ int tapi_ss_get_call_barring_option(tapi_context context, int slot_id, const cha DBusMessageIter iter; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || service_type == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (service_type == NULL) { + tapi_log_error("service_type in %s is null", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1124,6 +1342,7 @@ int tapi_ss_get_call_barring_option(tapi_context context, int slot_id, const cha return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -1138,23 +1357,41 @@ int tapi_ss_change_call_barring_password(tapi_context context, int slot_id, int report_data_logging_for_ss(ctx, "ss:set callbarring:change password", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || old_passwd == NULL || new_passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (old_passwd == NULL) { + tapi_log_error("old_passwd in %s is null", __func__); + return -EINVAL; + } + + if (new_passwd == NULL) { + tapi_log_error("new_passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1162,6 +1399,7 @@ int tapi_ss_change_call_barring_password(tapi_context context, int slot_id, int param = malloc(sizeof(cb_change_passwd_param)); if (param == NULL) { + tapi_log_error("param in %s is null", __func__); free(handler); free(ar); return -ENOMEM; @@ -1178,7 +1416,7 @@ int tapi_ss_change_call_barring_password(tapi_context context, int slot_id, int if (!g_dbus_proxy_method_call(proxy, "ChangePassword", cb_change_passwd_append, method_call_complete, handler, ss_event_data_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring:change password", "dbus method fail"); - tapi_log_error("failed to change callbarring passward \n"); + tapi_log_error("method call fail in %s", __func__); ss_event_data_free(handler); return -EINVAL; } @@ -1196,22 +1434,36 @@ int tapi_ss_disable_all_call_barrings(tapi_context context, int slot_id, int eve report_data_logging_for_ss(ctx, "ss:set callbarring:disable all", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (passwd == NULL) { + tapi_log_error("passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1225,7 +1477,7 @@ int tapi_ss_disable_all_call_barrings(tapi_context context, int slot_id, int eve if (!g_dbus_proxy_method_call(proxy, "DisableAll", disable_all_cb_param_append, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring:disable all", "dbus method fail"); - tapi_log_error("failed to disable all callbarring \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1243,22 +1495,36 @@ int tapi_ss_disable_all_incoming(tapi_context context, int slot_id, report_data_logging_for_ss(ctx, "ss:set callbarring:disable all incoming", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (passwd == NULL) { + tapi_log_error("passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1272,7 +1538,7 @@ int tapi_ss_disable_all_incoming(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "DisableAllIncoming", disable_all_incoming_param_append, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring:disable all incoming", "dbus method fail"); - tapi_log_error("failed to disable all incoming \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1290,22 +1556,36 @@ int tapi_ss_disable_all_outgoing(tapi_context context, int slot_id, report_data_logging_for_ss(ctx, "ss:set callbarring:disable all outgoing", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (passwd == NULL) { + tapi_log_error("passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1319,7 +1599,7 @@ int tapi_ss_disable_all_outgoing(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "DisableAllOutgoing", disable_all_outgoing_param_append, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring:disable all outgoing", "dbus method fail"); - tapi_log_error("failed to disable all outgoing \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1338,26 +1618,36 @@ int tapi_ss_query_call_forwarding_option(tapi_context context, int slot_id, int report_data_logging_for_ss(ctx, "ss:query call forwarding", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } if (option < CF_REASON_UNCONDITIONAL || option > CF_REASON_NOT_REACHABLE) { + tapi_log_error("option %d in %s is invalid", option, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_FORWARDING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1372,7 +1662,7 @@ int tapi_ss_query_call_forwarding_option(tapi_context context, int slot_id, int query_call_forwarding_option_append, call_forwarding_query_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:query call forwarding", "dbus method fail"); - tapi_log_error("failed to request callforwarding \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1391,29 +1681,46 @@ int tapi_ss_set_call_forwarding_option(tapi_context context, int slot_id, int ev report_data_logging_for_ss(ctx, "ss:set call forwarding", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || number == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (number == NULL) { + tapi_log_error("number in %s is null", __func__); return -EINVAL; } if (option < CF_REASON_UNCONDITIONAL || option > CF_REASON_NOT_REACHABLE) { + tapi_log_error("option %d in %s is invalid", option, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_FORWARDING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1427,6 +1734,7 @@ int tapi_ss_set_call_forwarding_option(tapi_context context, int slot_id, int ev if (!g_dbus_proxy_method_call(proxy, "SetCallForwarding", set_call_forwarding_option_append, method_call_complete, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:set call forwarding", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1444,16 +1752,24 @@ int tapi_get_ussd_state(tapi_context context, int slot_id, char** out) report_data_logging_for_ss(ctx, "ss:ussd:get state", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1462,6 +1778,7 @@ int tapi_get_ussd_state(tapi_context context, int slot_id, char** out) return OK; } + tapi_log_error("get property fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:ussd:get state", "dbus method fail"); return -EINVAL; } @@ -1476,22 +1793,36 @@ int tapi_ss_send_ussd(tapi_context context, int slot_id, int event_id, char* rep report_data_logging_for_ss(ctx, "ss:ussd:response", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || reply == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (reply == NULL) { + tapi_log_error("reply in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1505,7 +1836,7 @@ int tapi_ss_send_ussd(tapi_context context, int slot_id, int event_id, char* rep if (!g_dbus_proxy_method_call(proxy, "Respond", send_ussd_param_append, ss_send_ussd_cb, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:ussd:response", "dbus method fail"); - tapi_log_error("failed to send ussd \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1523,22 +1854,31 @@ int tapi_ss_cancel_ussd(tapi_context context, int slot_id, int event_id, report_data_logging_for_ss(ctx, "ss:ussd:cancel", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1551,7 +1891,7 @@ int tapi_ss_cancel_ussd(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, "Cancel", NULL, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:ussd:cancel", "dbus method fail"); - tapi_log_error("failed to cancel ussd \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1570,25 +1910,36 @@ int tapi_ss_set_call_waiting(tapi_context context, int slot_id, int event_id, bo report_data_logging_for_ss(ctx, "ss:set call waiting", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1601,6 +1952,7 @@ int tapi_ss_set_call_waiting(tapi_context context, int slot_id, int event_id, bo if (!g_dbus_proxy_method_call(proxy, "SetCallWaiting", set_call_waiting_append, method_call_complete, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:set call waiting", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1619,22 +1971,32 @@ int tapi_ss_get_call_waiting(tapi_context context, int slot_id, int event_id, report_data_logging_for_ss(ctx, "ss:get call waiting", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { @@ -1649,6 +2011,7 @@ int tapi_ss_get_call_waiting(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, "GetCallWaiting", NULL, query_call_waiting_cb, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:get call waiting", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1667,16 +2030,24 @@ int tapi_ss_get_calling_line_presentation_info(tapi_context context, int slot_id report_data_logging_for_ss(ctx, "ss:get clip", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1686,6 +2057,7 @@ int tapi_ss_get_calling_line_presentation_info(tapi_context context, int slot_id return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -1700,25 +2072,36 @@ int tapi_ss_set_calling_line_restriction(tapi_context context, int slot_id, int report_data_logging_for_ss(ctx, "ss:set clir", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1731,6 +2114,7 @@ int tapi_ss_set_calling_line_restriction(tapi_context context, int slot_id, int if (!g_dbus_proxy_method_call(proxy, "SetClir", set_clir_append, method_call_complete, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:set clir", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1749,25 +2133,36 @@ int tapi_ss_get_calling_line_restriction_info(tapi_context context, int slot_id, report_data_logging_for_ss(ctx, "ss:get clir", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1779,6 +2174,7 @@ int tapi_ss_get_calling_line_restriction_info(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "GetClir", NULL, query_clir_cb, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:get clir", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1795,22 +2191,36 @@ int tapi_ss_enable_fdn(tapi_context context, int slot_id, int event_id, tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (passwd == NULL) { + tapi_log_error("passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1823,7 +2233,7 @@ int tapi_ss_enable_fdn(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, enable ? "EnableFdn" : "DisableFdn", enable_fdn_param_append, method_call_complete, handler, handler_free)) { - tapi_log_error("failed to enable fdn \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1839,22 +2249,31 @@ int tapi_ss_query_fdn(tapi_context context, int slot_id, int event_id, tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1866,7 +2285,7 @@ int tapi_ss_query_fdn(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, "QueryFdn", NULL, query_fdn_cb, handler, handler_free)) { - tapi_log_error("failed to query fdn \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1883,25 +2302,38 @@ int tapi_ss_register(tapi_context context, const char* modem_path; int watch_id = 0; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || msg < MSG_CALL_BARRING_PROPERTY_CHANGE_IND || msg > MSG_USSD_PROPERTY_CHANGE_IND) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (msg < MSG_CALL_BARRING_PROPERTY_CHANGE_IND || msg > MSG_USSD_PROPERTY_CHANGE_IND) { + tapi_log_error("msg %d in %s is invalid", msg, __func__); return -EINVAL; } modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } handler->cb_function = p_handle; ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1937,6 +2369,7 @@ int tapi_ss_register(tapi_context context, } if (watch_id == 0) { + tapi_log_error("add signal watch fail in %s, msg_id: %d", __func__, (int)msg); handler_free(handler); return -EINVAL; } @@ -1947,11 +2380,20 @@ int tapi_ss_register(tapi_context context, int tapi_ss_unregister(tapi_context context, int watch_id) { dbus_context* ctx = context; - if (ctx == NULL || watch_id <= 0) + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; + } - if (!g_dbus_remove_watch(ctx->connection, watch_id)) + if (watch_id <= 0) { + tapi_log_error("watch id %d in %s is invalid", watch_id, __func__); return -EINVAL; + } + + if (!g_dbus_remove_watch(ctx->connection, watch_id)) { + tapi_log_error("remove signal watch fail in %s, watch_id: %d", __func__, watch_id); + return -EINVAL; + } return OK; } From 48975681d79c4fee200c265f79753b4a59c0091b Mon Sep 17 00:00:00 2001 From: xujianhang Date: Fri, 8 Nov 2024 16:23:33 +0800 Subject: [PATCH 5/6] add tapi debug log: tapi_stk.c --- CMakeLists.txt | 6 +- Makefile | 5 +- README.md | 88 +-- README_zh-cn.md | 85 +-- include/tapi.h | 2 +- include/tapi_stk.h | 12 +- src/tapi_call.c => tapi_call.c | 0 src/tapi_cbs.c => tapi_cbs.c | 0 src/tapi_data.c => tapi_data.c | 0 src/tapi_ims.c => tapi_ims.c | 0 src/tapi_internal.h => tapi_internal.h | 0 src/tapi_manager.c => tapi_manager.c | 0 src/tapi_network.c => tapi_network.c | 0 src/tapi_phonebook.c => tapi_phonebook.c | 0 src/tapi_sim.c => tapi_sim.c | 0 src/tapi_sms.c => tapi_sms.c | 0 src/tapi_ss.c => tapi_ss.c | 0 src/tapi_stk.c => tapi_stk.c | 779 ++++++++++++++++----- src/tapi_utils.c => tapi_utils.c | 27 +- tools/telephony_tool.c => telephony_tool.c | 2 +- 20 files changed, 693 insertions(+), 313 deletions(-) rename src/tapi_call.c => tapi_call.c (100%) rename src/tapi_cbs.c => tapi_cbs.c (100%) rename src/tapi_data.c => tapi_data.c (100%) rename src/tapi_ims.c => tapi_ims.c (100%) rename src/tapi_internal.h => tapi_internal.h (100%) rename src/tapi_manager.c => tapi_manager.c (100%) rename src/tapi_network.c => tapi_network.c (100%) rename src/tapi_phonebook.c => tapi_phonebook.c (100%) rename src/tapi_sim.c => tapi_sim.c (100%) rename src/tapi_sms.c => tapi_sms.c (100%) rename src/tapi_ss.c => tapi_ss.c (100%) rename src/tapi_stk.c => tapi_stk.c (67%) rename src/tapi_utils.c => tapi_utils.c (95%) rename tools/telephony_tool.c => telephony_tool.c (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c18c3a8..ec30ae1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,9 +20,9 @@ if(CONFIG_TELEPHONY) APPEND PROPERTY NUTTX_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/include) set(CSRCS) - file(GLOB APPEND_FILES ${CMAKE_CURRENT_LIST_DIR}/src/*.c) + file(GLOB APPEND_FILES ${CMAKE_CURRENT_LIST_DIR}/*.c) list(APPEND CSRCS ${APPEND_FILES}) - list(REMOVE_ITEM CSRCS ${CMAKE_CURRENT_LIST_DIR}/tools/telephony_tool.c) + list(REMOVE_ITEM CSRCS ${CMAKE_CURRENT_LIST_DIR}/telephony_tool.c) set(INCDIR ${NUTTX_APPS_DIR}/external/dbus/dbus ${NUTTX_APPS_DIR}/external/ofono/include @@ -42,7 +42,7 @@ if(CONFIG_TELEPHONY) PRIORITY ${CONFIG_TELEPHONY_TOOL_PRIORITY} SRCS - tools/telephony_tool.c + telephony_tool.c INCLUDE_DIRECTORIES ${INCDIR} DEPENDS diff --git a/Makefile b/Makefile index 2705df7..7733fef 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,11 @@ CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/ofono/include CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/system/utils/gdbus CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/telephony -CSRCS += $(wildcard src/*.c) +CSRCS += tapi_manager.c tapi_utils.c tapi_call.c tapi_data.c tapi_sim.c tapi_stk.c +CSRCS += tapi_cbs.c tapi_sms.c tapi_network.c tapi_ss.c tapi_ims.c tapi_phonebook.c ifneq ($(CONFIG_TELEPHONY_TOOL),) - MAINSRC += tools/telephony_tool.c + MAINSRC += telephony_tool.c PROGNAME += telephonytool PRIORITY += $(CONFIG_TELEPHONY_TOOL_PRIORITY) STACKSIZE += $(CONFIG_TELEPHONY_TOOL_STACKSIZE) diff --git a/README.md b/README.md index f300076..d528721 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ ## **Overview** -Telephony is a framework and API set for handling phone and communication functions in the `openvela` operating system. `Framework/telephony` is the interface layer provided by `openvela` communication to the application layer, also known as `TAPI (Telephony API)`. +Telephony is a framework and API set for handling call and communication functions in the Vela system. Framework/telephony is the interface layer that Vela provides to upper-layer applications, also known as TAPI (Telephony API). -`TAPI` provides a set of feature-rich tools and interfaces, covering network services, call services, SMS services, data services, SIM card services and other related functions. These interface designs allow application developers to easily obtain information related to Telephony and complete application development by calling `API` without having to deeply understand the internal business logic of Telephony (Telephony internal business is implemented by `Ofono`). In addition, Telephony also supports flexible expansion and customization to meet changing communication needs. +TAPI provides a set of feature-rich tools and interfaces, covering network services, call services, SMS services, data services, SIM card services and other related functions. These interface allow application developers to easily obtain Telephony-related information and complete application development by calling APIs without having to deeply understand the internal implementation of Telephony (Telephony is implemented by Ofono). In addition, Telephony also supports flexible expansion and customization to realize ever-changing communication requirements. ![TelephonyFramework](./TelephonyFramework.jpg) -## **Code Directory** +## **Project Directory** ```tree ├── include │   ├── tapi_call.h @@ -25,40 +25,18 @@ Telephony is a framework and API set for handling phone and communication functi │   ├── tapi_sms.h │   ├── tapi_ss.h │   └── tapi_stk.h -├── src -│   ├── tapi_call.c -│   ├── tapi_cbs.c -│   ├── tapi_data.c -│   ├── tapi_ims.c -│   ├── tapi_manager.c -│   ├── tapi_network.c -│   ├── tapi_phonebook.c -│   ├── tapi_sim.c -│   ├── tapi_sms.c -│   ├── tapi_ss.c -│   ├── tapi_stk.c -│   └── tapi_utils.c -├── tools -│   └── telephony_tool.c -├── test -│   ├── cmocka_telephony_test.c -│   ├── telephony_call_test.c -│   ├── telephony_call_test.h -│   ├── telephony_common_test.c -│   ├── telephony_common_test.h -│   ├── telephony_data_test.c -│   ├── telephony_data_test.h -│   ├── telephony_ims_test.c -│   ├── telephony_ims_test.h -│   ├── telephony_network_test.c -│   ├── telephony_network_test.h -│   ├── telephony_sim_test.c -│   ├── telephony_sim_test.h -│   ├── telephony_sms_test.c -│   ├── telephony_sms_test.h -│   ├── telephony_ss_test.c -│   ├── telephony_ss_test.h -│   └── telephony_test.h +├── tapi_call.c +├── tapi_cbs.c +├── tapi_data.c +├── tapi_ims.c +├── tapi_manager.c +├── tapi_network.c +├── tapi_phonebook.c +├── tapi_sim.c +├── tapi_sms.c +├── tapi_ss.c +├── tapi_stk.c +├── tapi_utils.c ├── README.md └── README_zh-cn.md ``` @@ -77,15 +55,13 @@ Telephony is a framework and API set for handling phone and communication functi | SMS | tapi_sms.c/h | SMS service interface | | IMS | tapi_ims.c/h | IMS service interface | | Phonebook | tapi_phonebook.c/h | Phonebook interface | -|
Telephony Utils| tapi_utils.c |Telephony util interface | -| Telephony Tools| telephony_tool.c | Telephony internal interface test | -| Telephony Test Case| test/* | Telephony internal test case | +|
Utils| tapi_utils.c/h |Telephony util interface | ### **Function Introduction** #### Common Api - Telephony service interface: provides an interface for obtaining and releasing Telephony services. -- Obtain communications equipment related information: such as `IMEI`, `MODEL`, `MSISDN`, `PhoneNumber`, `Modem` parameters, etc. +- Obtain communications equipment related information: such as IMEI, MODEL, MSISDN, PhoneNumber, Modem parameters, etc. - Communication capability management: turn on/off flight mode, turn on/off cellular communication capability, etc. #### Call Api @@ -124,38 +100,32 @@ Telephony is a framework and API set for handling phone and communication functi #### Phonebook Api - SIM card contact management: perform operations related to adding, deleting, modifying and checking contacts on the SIM card. -#### Telephony Utils Api +#### Utils Api - Bidirectional data type conversion: Bidirectional conversion between Telephony internal structure parameters and basic types to meet different data processing requirements. -#### Telephony Tools -- Internal interface test: Used for testing all internal TAPI interfaces. - -#### Telephony Test Case -- Internal test case: Used for testing all internal Telephony scenarios. - ## **TAPI Workflow** ![TelephonyApi](./TapiEn.jpg) -## **TAPI code demonstration** -### **Usage steps** -1. Call the `tapi_open` function to get the `tapi_context`. - ```c +## **TAPI Code Demonstration** +### **How to use** +1. Call tapi_open function to get tapi_context +```c tapi_context context; char* dbus_name = "vela.telephony.tool"; context = tapi_open(dbus_name, on_tapi_client_ready, NULL); - ``` +``` -2. Pass the `tapi_context` parameter to the `TAPI` interface function to operate the `Telephony` service. - ```c +2. Transfer parameters to TAPI interface functions through tapi_context to operate Telephony services +```c tapi_radio_state current = RADIO_STATE_UNAVAILABLE; tapi_get_radio_state(t_context, get_used_slot_id(), ¤t); - ``` +``` -3. Call the `tapi_close` function to release the `tapi_context`. - ```c +3. Call tapi_close function to release tapi_context +```c tapi_close(context); - ``` +``` ### **Complete sample code** ```c diff --git a/README_zh-cn.md b/README_zh-cn.md index 1796e9c..512832b 100644 --- a/README_zh-cn.md +++ b/README_zh-cn.md @@ -5,13 +5,13 @@ ## **概述** -Telephony 是 `openvela` 操作系统中用于处理电话和通信功能的框架和 `API` 集合。`Framework/telephony` 是 `openvela` 通信对应用层提供的接口层,又称为 `TAPI(Telephony API)`。 +Telephony 是 Vela 操作系统中用于处理电话和通信功能的框架和 API 集合。Framework/telephony 是 Vela 通信对应用层提供的接口层,又称为 TAPI(Telephony API)。 -`TAPI` 提供了一组功能丰富的工具和接口,涵盖网络服务、通话服务、短信服务、数据服务、SIM 卡服务及其他相关功能。这些接口设计使得应用开发者无需深入了解 Telephony 的内部业务逻辑(Telephony 内部业务由 `Ofono` 实现),只需调用 API 即可轻松获取与 Telephony 相关的信息,完成应用开发。另外,Telephony 还支持灵活的扩展和定制,可满足不断变化的通信需求。 +TAPI 提供了一组功能丰富的工具和接口,涵盖网络服务、通话服务、短信服务、数据服务、SIM 卡服务及其他相关功能。这些接口设计使得应用开发者无需深入了解 Telephony 的内部业务逻辑(Telephony 内部业务由 Ofono 实现),只需调用 API 即可轻松获取与 Telephony 相关的信息,完成应用开发。另外,Telephony 还支持灵活的扩展和定制,可满足不断变化的通信需求。 ![Telephony架构图](./TelephonyFramework.jpg) -## **代码目录** +## **项目目录** ```tree ├── include │   ├── tapi_call.h @@ -26,40 +26,18 @@ Telephony 是 `openvela` 操作系统中用于处理电话和通信功能的框 │   ├── tapi_sms.h │   ├── tapi_ss.h │   └── tapi_stk.h -├── src -│   ├── tapi_call.c -│   ├── tapi_cbs.c -│   ├── tapi_data.c -│   ├── tapi_ims.c -│   ├── tapi_manager.c -│   ├── tapi_network.c -│   ├── tapi_phonebook.c -│   ├── tapi_sim.c -│   ├── tapi_sms.c -│   ├── tapi_ss.c -│   ├── tapi_stk.c -│   └── tapi_utils.c -├── tools -│   └── telephony_tool.c -├── test -│   ├── cmocka_telephony_test.c -│   ├── telephony_call_test.c -│   ├── telephony_call_test.h -│   ├── telephony_common_test.c -│   ├── telephony_common_test.h -│   ├── telephony_data_test.c -│   ├── telephony_data_test.h -│   ├── telephony_ims_test.c -│   ├── telephony_ims_test.h -│   ├── telephony_network_test.c -│   ├── telephony_network_test.h -│   ├── telephony_sim_test.c -│   ├── telephony_sim_test.h -│   ├── telephony_sms_test.c -│   ├── telephony_sms_test.h -│   ├── telephony_ss_test.c -│   ├── telephony_ss_test.h -│   └── telephony_test.h +├── tapi_call.c +├── tapi_cbs.c +├── tapi_data.c +├── tapi_ims.c +├── tapi_manager.c +├── tapi_network.c +├── tapi_phonebook.c +├── tapi_sim.c +├── tapi_sms.c +├── tapi_ss.c +├── tapi_stk.c +├── tapi_utils.c ├── README.md └── README_zh-cn.md ``` @@ -78,15 +56,13 @@ Telephony 是 `openvela` 操作系统中用于处理电话和通信功能的框 | SMS | tapi_sms.c/h | 短信服务接口 | | IMS | tapi_ims.c/h | IMS 服务接口 | | Phonebook | tapi_phonebook.c/h | 电话簿接口 | -|
Telephony Utils| tapi_utils.c | Telephony 工具类接口 | -| Telephony Tools| telephony_tool.c | Telephony 内部接口测试 | -| Telephony Test Case| test/* | Telephony 内部测试用例 | +|
Telephony 工具类| tapi_utils.c/h | Telephony 工具类接口 | ### **功能介绍** #### Common Api - Telephony 服务接口:提供 Telephony 服务获取以及释放的接口。 -- 获取通讯设备相关信息:如 `IMEI`、`MODEL`、`MSISDN`、`PhoneNumber`、`Modem` 参数等信息。 +- 获取通讯设备相关信息:如 IMEI、MODEL、MSISDN、PhoneNumber、Modem 参数等信息。 - 设备通讯能力管理:开启/关闭飞行模式、蜂窝通信能力等功能。 #### Call Api @@ -125,39 +101,32 @@ Telephony 是 `openvela` 操作系统中用于处理电话和通信功能的框 #### Phonebook Api - SIM 卡联系人管理:SIM 卡上的联系人进行增删改查的相关操作。 -#### Telephony Utils Api +#### Utils Api - 双向数据类型转换:Telephony 内部结构体参数与基本类型之间的双向转换,以满足不同数据处理需求。 -#### Telephony Tools -- 内部接口测试:用于内部所有 TAPI 接口测试。 - -#### Telephony Test Case -- 内部测试用例: 用于内部所有 Telephony 场景的测试用例。 - - ## **TAPI 工作模型** ![TelephonyApi](./TapiZh.jpg) ## **TAPI 代码演示** ### **使用步骤** -1. 调用 `tapi_open` 函数获取 `tapi_context`。 - ```c +1. 调用 tapi_open 函数获取 tapi_context +```c tapi_context context; char* dbus_name = "vela.telephony.tool"; context = tapi_open(dbus_name, on_tapi_client_ready, NULL); - ``` +``` -2. 通过 `tapi_context` 传参到 `TAPI` 接口函数进行 `Telephony` 服务的操作。 - ```c +2. 通过 tapi_context 传参到TAPI接口函数进行 Telephony 服务的操作 +```c tapi_radio_state current = RADIO_STATE_UNAVAILABLE; tapi_get_radio_state(t_context, get_used_slot_id(), ¤t); - ``` +``` -3. 调用 `tapi_close` 函数释放 `tapi_context`。 - ```c +3. 调用 tapi_close 函数释放 tapi_context +```c tapi_close(context); - ``` +``` ### **完整示例代码** ```c diff --git a/include/tapi.h b/include/tapi.h index 164765c..c0dbaea 100644 --- a/include/tapi.h +++ b/include/tapi.h @@ -315,7 +315,7 @@ typedef void* tapi_context; const char* tapi_utils_network_mode_to_string(tapi_pref_net_mode mode); tapi_pref_net_mode tapi_utils_network_mode_from_string(const char* mode); tapi_network_type tapi_utils_network_type_from_ril_tech(int type); -const char* tapi_utils_get_registration_status_string(int status); +const char* tapi_utils_registration_status_to_string(int status); tapi_registration_state tapi_utils_registration_status_from_string(const char* status); tapi_selection_mode tapi_utils_registration_mode_from_string(const char* mode); tapi_operator_status tapi_utils_operator_status_from_string(const char* mode); diff --git a/include/tapi_stk.h b/include/tapi_stk.h index 3928bac..048a062 100644 --- a/include/tapi_stk.h +++ b/include/tapi_stk.h @@ -46,10 +46,10 @@ typedef struct { } tapi_stk_menu_item; typedef struct { - char* info; + char* text; unsigned char icon_id; int urgent; -} tapi_stk_display_info_params; +} tapi_stk_display_text_params; typedef struct { char* alpha; @@ -60,14 +60,14 @@ typedef struct { char* alpha; char* def_input; char icon_id; - char min_len; - char max_len; + char min_chars; + char max_chars; int hide_typing; } tapi_stk_request_input_params; typedef struct { char* tone; - char* info; + char* text; unsigned char icon_id; } tapi_stk_play_tone_params; @@ -79,7 +79,7 @@ typedef struct { } tapi_stk_request_selection_params; typedef struct { - char* info; + char* information; unsigned char icon_id; char* url; } tapi_stk_confirm_launch_browser_params; diff --git a/src/tapi_call.c b/tapi_call.c similarity index 100% rename from src/tapi_call.c rename to tapi_call.c diff --git a/src/tapi_cbs.c b/tapi_cbs.c similarity index 100% rename from src/tapi_cbs.c rename to tapi_cbs.c diff --git a/src/tapi_data.c b/tapi_data.c similarity index 100% rename from src/tapi_data.c rename to tapi_data.c diff --git a/src/tapi_ims.c b/tapi_ims.c similarity index 100% rename from src/tapi_ims.c rename to tapi_ims.c diff --git a/src/tapi_internal.h b/tapi_internal.h similarity index 100% rename from src/tapi_internal.h rename to tapi_internal.h diff --git a/src/tapi_manager.c b/tapi_manager.c similarity index 100% rename from src/tapi_manager.c rename to tapi_manager.c diff --git a/src/tapi_network.c b/tapi_network.c similarity index 100% rename from src/tapi_network.c rename to tapi_network.c diff --git a/src/tapi_phonebook.c b/tapi_phonebook.c similarity index 100% rename from src/tapi_phonebook.c rename to tapi_phonebook.c diff --git a/src/tapi_sim.c b/tapi_sim.c similarity index 100% rename from src/tapi_sim.c rename to tapi_sim.c diff --git a/src/tapi_sms.c b/tapi_sms.c similarity index 100% rename from src/tapi_sms.c rename to tapi_sms.c diff --git a/src/tapi_ss.c b/tapi_ss.c similarity index 100% rename from src/tapi_ss.c rename to tapi_ss.c diff --git a/src/tapi_stk.c b/tapi_stk.c similarity index 67% rename from src/tapi_stk.c rename to tapi_stk.c index a38dd39..aa04787 100644 --- a/src/tapi_stk.c +++ b/tapi_stk.c @@ -59,25 +59,25 @@ static DBusMessage* stk_agent_release(DBusConnection* conn, DBusMessage* msg, void* user_data); static DBusMessage* stk_agent_cancel(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_show_information(DBusConnection* conn, +static DBusMessage* stk_agent_display_text(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, +static DBusMessage* stk_agent_request_digit(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, +static DBusMessage* stk_agent_request_key(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, +static DBusMessage* stk_agent_request_confirmation(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, +static DBusMessage* stk_agent_request_input(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, +static DBusMessage* stk_agent_request_digits(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, +static DBusMessage* stk_agent_play_tone(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, +static DBusMessage* stk_agent_loop_tone(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, +static DBusMessage* stk_agent_request_selection(DBusConnection* conn, DBusMessage* msg, void* user_data); -static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, +static DBusMessage* stk_agent_request_quick_digit(DBusConnection* conn, DBusMessage* msg, void* user_data); static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, DBusMessage* msg, void* user_data); @@ -94,58 +94,58 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, * Private Data ****************************************************************************/ -static const GDBusMethodTable agent_methods[] = { - { GDBUS_METHOD("AgentRelease", NULL, NULL, stk_agent_release) }, - { GDBUS_ASYNC_METHOD("ConfirmCallSetup", - GDBUS_ARGS({ "info", "s" }, { "icon_id", "y" }), - GDBUS_ARGS({ "confirm", "b" }), stk_agent_confirm_call_setup) }, - { GDBUS_ASYNC_METHOD("ConfirmLaunchBrowser", - GDBUS_ARGS({ "info", "s" }, { "icon_id", "y" }, { "url", "s" }), - GDBUS_ARGS({ "confirm", "b" }), stk_agent_confirm_launch_browser) }, - { GDBUS_ASYNC_METHOD("ConfirmOpenChannel", - GDBUS_ARGS({ "info", "s" }, { "icon_id", "y" }), - GDBUS_ARGS({ "confirm", "b" }), stk_agent_confirm_open_channel) }, - { GDBUS_ASYNC_METHOD("ConfirmRequest", +static const GDBusMethodTable stk_agent_methods[] = { + { GDBUS_METHOD("Release", NULL, NULL, stk_agent_release) }, + { GDBUS_ASYNC_METHOD("DisplayText", + GDBUS_ARGS({ "text", "s" }, { "icon_id", "y" }, { "urgent", "b" }), + NULL, stk_agent_display_text) }, + { GDBUS_ASYNC_METHOD("RequestDigit", GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }), - GDBUS_ARGS({ "confirmation", "b" }), stk_agent_handle_request_confirmation) }, - { GDBUS_ASYNC_METHOD("DisplayAction", - GDBUS_ARGS({ "info", "s" }, { "icon_id", "y" }), - NULL, stk_agent_display_action) }, - { GDBUS_ASYNC_METHOD("DisplayActionInformation", - GDBUS_ARGS({ "info", "s" }, { "icon_id", "y" }), - NULL, stk_agent_display_action_information) }, - { GDBUS_ASYNC_METHOD("RequestLoopTone", - GDBUS_ARGS({ "tone", "s" }, { "info", "s" }, { "icon_id", "y" }), - NULL, stk_agent_handle_loop_tone) }, - { GDBUS_ASYNC_METHOD("RequestPlayTone", - GDBUS_ARGS({ "tone", "s" }, { "info", "s" }, { "icon_id", "y" }), - NULL, stk_agent_handle_play_tone) }, - { GDBUS_ASYNC_METHOD("RequestQuickDigit", + GDBUS_ARGS({ "digit", "s" }), stk_agent_request_digit) }, + { GDBUS_ASYNC_METHOD("RequestKey", GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }), - GDBUS_ARGS({ "digit", "s" }), stk_agent_handle_request_quick_digit) }, - { GDBUS_ASYNC_METHOD("RequestSelection", - GDBUS_ARGS({ "title", "s" }, { "icon_id", "y" }, - { "items", "a(sy)" }, { "default", "n" }), - GDBUS_ARGS({ "selection", "y" }), stk_agent_handle_request_selection) }, - { GDBUS_ASYNC_METHOD("RequestWithDigit", + GDBUS_ARGS({ "key", "s" }), stk_agent_request_key) }, + { GDBUS_ASYNC_METHOD("RequestConfirmation", GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }), - GDBUS_ARGS({ "digit", "s" }), stk_agent_handle_request_digit) }, - { GDBUS_ASYNC_METHOD("RequestWithDigits", + GDBUS_ARGS({ "confirmation", "b" }), stk_agent_request_confirmation) }, + { GDBUS_ASYNC_METHOD("RequestInput", GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }, - { "default", "s" }, { "min_len", "y" }, - { "max_len", "y" }, { "hide_typing", "b" }), - GDBUS_ARGS({ "digits", "s" }), stk_agent_handle_request_digits) }, - { GDBUS_ASYNC_METHOD("RequestWithInput", + { "default", "s" }, { "min_chars", "y" }, + { "max_chars", "y" }, { "hide_typing", "b" }), + GDBUS_ARGS({ "input", "s" }), stk_agent_request_input) }, + { GDBUS_ASYNC_METHOD("RequestDigits", GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }, - { "default", "s" }, { "min_len", "y" }, - { "max_len", "y" }, { "hide_typing", "b" }), - GDBUS_ARGS({ "input", "s" }), stk_agent_handle_request_input) }, - { GDBUS_ASYNC_METHOD("RequestWithKey", + { "default", "s" }, { "min_chars", "y" }, + { "max_chars", "y" }, { "hide_typing", "b" }), + GDBUS_ARGS({ "digits", "s" }), stk_agent_request_digits) }, + { GDBUS_ASYNC_METHOD("PlayTone", + GDBUS_ARGS({ "tone", "s" }, { "text", "s" }, { "icon_id", "y" }), + NULL, stk_agent_play_tone) }, + { GDBUS_ASYNC_METHOD("LoopTone", + GDBUS_ARGS({ "tone", "s" }, { "text", "s" }, { "icon_id", "y" }), + NULL, stk_agent_loop_tone) }, + { GDBUS_ASYNC_METHOD("RequestSelection", + GDBUS_ARGS({ "title", "s" }, { "icon_id", "y" }, + { "items", "a(sy)" }, { "default", "n" }), + GDBUS_ARGS({ "selection", "y" }), stk_agent_request_selection) }, + { GDBUS_ASYNC_METHOD("RequestQuickDigit", GDBUS_ARGS({ "alpha", "s" }, { "icon_id", "y" }), - GDBUS_ARGS({ "key", "s" }), stk_agent_handle_request_key) }, - { GDBUS_ASYNC_METHOD("ShowInformation", - GDBUS_ARGS({ "info", "s" }, { "icon_id", "y" }, { "urgent", "b" }), - NULL, stk_agent_show_information) }, + GDBUS_ARGS({ "digit", "s" }), stk_agent_request_quick_digit) }, + { GDBUS_ASYNC_METHOD("ConfirmCallSetup", + GDBUS_ARGS({ "information", "s" }, { "icon_id", "y" }), + GDBUS_ARGS({ "confirm", "b" }), stk_agent_confirm_call_setup) }, + { GDBUS_ASYNC_METHOD("DisplayActionInformation", + GDBUS_ARGS({ "text", "s" }, { "icon_id", "y" }), + NULL, stk_agent_display_action_information) }, + { GDBUS_ASYNC_METHOD("ConfirmLaunchBrowser", + GDBUS_ARGS({ "information", "s" }, { "icon_id", "y" }, { "url", "s" }), + GDBUS_ARGS({ "confirm", "b" }), stk_agent_confirm_launch_browser) }, + { GDBUS_ASYNC_METHOD("DisplayAction", + GDBUS_ARGS({ "text", "s" }, { "icon_id", "y" }), + NULL, stk_agent_display_action) }, + { GDBUS_ASYNC_METHOD("ConfirmOpenChannel", + GDBUS_ARGS({ "information", "s" }, { "icon_id", "y" }), + GDBUS_ARGS({ "confirm", "b" }), stk_agent_confirm_open_channel) }, { GDBUS_NOREPLY_METHOD("Cancel", NULL, NULL, stk_agent_cancel) }, {}, }; @@ -182,15 +182,25 @@ static void method_call_complete(DBusMessage* message, void* user_data) tapi_async_function cb; DBusError err; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s error %s: %s \n", __func__, err.name, err.message); + tapi_log_error("error from message in %s, error %s: %s", + __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -205,9 +215,18 @@ static void method_call_complete(DBusMessage* message, void* user_data) static bool stk_agent_dbus_pending_reply(DBusConnection* conn, DBusMessage** msg, DBusMessage* reply) { + if (conn == NULL) { + tapi_log_error("conn in %s is null", __func__); + return false; + } - if (conn == NULL || msg == NULL || reply == NULL) { - tapi_log_error("failed to send message ...\n"); + if (msg == NULL) { + tapi_log_error("msg in %s is null", __func__); + return false; + } + + if (reply == NULL) { + tapi_log_error("reply in %s is null", __func__); return false; } @@ -224,8 +243,13 @@ static void stk_agent_register_param_append(DBusMessageIter* iter, void* user_da tapi_async_handler* param = user_data; char* agent_id; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; } @@ -240,8 +264,13 @@ static void stk_select_item_param_append(DBusMessageIter* iter, void* user_data) unsigned char item; char* agent_id; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid stk input argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; } @@ -300,15 +329,25 @@ static DBusMessage* stk_agent_release(DBusConnection* conn, tapi_log_info("stk agent release method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } reply = dbus_message_new_method_return(msg); ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; @@ -340,21 +379,32 @@ static DBusMessage* stk_agent_cancel(DBusConnection* conn, tapi_log_info("stk agent cancel method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); dbus_message_unref(ctx->pending); ctx->pending = NULL; } @@ -369,11 +419,11 @@ static DBusMessage* stk_agent_cancel(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_show_information(DBusConnection* conn, +static DBusMessage* stk_agent_display_text(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; - tapi_stk_display_info_params* params; + tapi_stk_display_text_params* params; tapi_async_function cb; tapi_async_result* ar; DBusMessage* reply; @@ -381,11 +431,20 @@ static DBusMessage* stk_agent_show_information(DBusConnection* conn, tapi_log_info("stk agent display text method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_DISPLAY_TEXT_IND; @@ -393,28 +452,32 @@ static DBusMessage* stk_agent_show_information(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; } - params = malloc(sizeof(tapi_stk_display_info_params)); + params = malloc(sizeof(tapi_stk_display_text_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; } - if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->info, + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->text, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_BOOLEAN, ¶ms->urgent, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -433,7 +496,7 @@ static DBusMessage* stk_agent_show_information(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, +static DBusMessage* stk_agent_request_digit(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; @@ -445,11 +508,20 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, tapi_log_info("stk agent request digit method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_DIGIT_IND; @@ -457,12 +529,14 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -470,6 +544,7 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -478,6 +553,7 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -496,7 +572,7 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, +static DBusMessage* stk_agent_request_key(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; @@ -508,11 +584,20 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, tapi_log_info("stk agent request key method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_KEY_IND; @@ -520,12 +605,14 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -533,6 +620,7 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -541,6 +629,7 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -559,7 +648,7 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, +static DBusMessage* stk_agent_request_confirmation(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; @@ -571,11 +660,20 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, tapi_log_info("stk agent request confirmation is method\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_CONFIRMATION_IND; @@ -583,12 +681,14 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -596,6 +696,7 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -604,6 +705,7 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -622,7 +724,7 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, +static DBusMessage* stk_agent_request_input(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; @@ -634,11 +736,20 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, tapi_log_info("stk agent request input method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_INPUT_IND; @@ -646,12 +757,14 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -659,6 +772,7 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_input_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -667,10 +781,11 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_STRING, ¶ms->def_input, - DBUS_TYPE_BYTE, ¶ms->min_len, - DBUS_TYPE_BYTE, ¶ms->max_len, + DBUS_TYPE_BYTE, ¶ms->min_chars, + DBUS_TYPE_BYTE, ¶ms->max_chars, DBUS_TYPE_BOOLEAN, ¶ms->hide_typing, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -689,7 +804,7 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, +static DBusMessage* stk_agent_request_digits(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; @@ -701,11 +816,20 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, tapi_log_info("stk agent request input digits is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_DIGITS_IND; @@ -713,12 +837,14 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -726,6 +852,7 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_input_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -734,10 +861,11 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_STRING, ¶ms->def_input, - DBUS_TYPE_BYTE, ¶ms->min_len, - DBUS_TYPE_BYTE, ¶ms->max_len, + DBUS_TYPE_BYTE, ¶ms->min_chars, + DBUS_TYPE_BYTE, ¶ms->max_chars, DBUS_TYPE_BOOLEAN, ¶ms->hide_typing, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -756,7 +884,7 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, +static DBusMessage* stk_agent_play_tone(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; @@ -768,11 +896,20 @@ static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, tapi_log_info("stk agent play tone method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_PLAY_TONE_IND; @@ -780,12 +917,14 @@ static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -793,15 +932,17 @@ static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, params = malloc(sizeof(tapi_stk_play_tone_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; } if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->tone, - DBUS_TYPE_STRING, ¶ms->info, + DBUS_TYPE_STRING, ¶ms->text, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -820,7 +961,7 @@ static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, +static DBusMessage* stk_agent_loop_tone(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; @@ -832,11 +973,20 @@ static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, tapi_log_info("stk agent loop tone method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_LOOP_TONE_IND; @@ -844,12 +994,14 @@ static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -857,15 +1009,17 @@ static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, params = malloc(sizeof(tapi_stk_play_tone_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; } if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->tone, - DBUS_TYPE_STRING, ¶ms->info, + DBUS_TYPE_STRING, ¶ms->text, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -884,7 +1038,7 @@ static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, +static DBusMessage* stk_agent_request_selection(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_stk_request_selection_params* params; @@ -901,11 +1055,20 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, tapi_log_info("stk agent request selection method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_SELECTION_IND; @@ -913,7 +1076,7 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, reply = NULL; dbus_error_init(&err); if (dbus_set_error_from_message(&err, msg) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; reply = stk_agent_error_failed(msg); @@ -921,6 +1084,7 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, } if (dbus_message_iter_init(msg, &iter) == false) { + tapi_log_error("dbus message iter init failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -928,12 +1092,14 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -941,6 +1107,7 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_selection_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -995,7 +1162,7 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, return reply; } -static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, +static DBusMessage* stk_agent_request_quick_digit(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; @@ -1007,11 +1174,20 @@ static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, tapi_log_info("stk agent request quick digit method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_QUICK_DIGIT_IND; @@ -1019,12 +1195,14 @@ static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1032,6 +1210,7 @@ static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1040,6 +1219,7 @@ static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1070,11 +1250,20 @@ static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, tapi_log_info("stk agent confirm call setup method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_CONFIRM_CALL_SETUP_IND; @@ -1082,12 +1271,14 @@ static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1095,6 +1286,7 @@ static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1103,6 +1295,7 @@ static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1125,7 +1318,7 @@ static DBusMessage* stk_agent_display_action_information(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; - tapi_stk_display_info_params* params; + tapi_stk_display_text_params* params; tapi_async_function cb; tapi_async_result* ar; DBusMessage* reply; @@ -1133,11 +1326,20 @@ static DBusMessage* stk_agent_display_action_information(DBusConnection* conn, tapi_log_info("stk agent display action information method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_DISPLAY_ACTION_INFORMATION_IND; @@ -1145,27 +1347,31 @@ static DBusMessage* stk_agent_display_action_information(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; } - params = malloc(sizeof(tapi_stk_display_info_params)); + params = malloc(sizeof(tapi_stk_display_text_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; } - if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->info, + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->text, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1196,11 +1402,20 @@ static DBusMessage* stk_agent_confirm_launch_browser(DBusConnection* conn, tapi_log_info("stk agent confirm launch browser method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_CONFIRM_LAUNCH_BROWSER_IND; @@ -1208,12 +1423,14 @@ static DBusMessage* stk_agent_confirm_launch_browser(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1221,15 +1438,17 @@ static DBusMessage* stk_agent_confirm_launch_browser(DBusConnection* conn, params = malloc(sizeof(tapi_stk_confirm_launch_browser_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; } - if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->info, + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->information, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_STRING, ¶ms->url, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1252,7 +1471,7 @@ static DBusMessage* stk_agent_display_action(DBusConnection* conn, DBusMessage* msg, void* user_data) { tapi_async_handler* handler = user_data; - tapi_stk_display_info_params* params; + tapi_stk_display_text_params* params; tapi_async_function cb; tapi_async_result* ar; DBusMessage* reply; @@ -1260,11 +1479,20 @@ static DBusMessage* stk_agent_display_action(DBusConnection* conn, tapi_log_info("stk agent display action method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_DISPLAY_ACTION_IND; @@ -1272,27 +1500,31 @@ static DBusMessage* stk_agent_display_action(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; } - params = malloc(sizeof(tapi_stk_display_info_params)); + params = malloc(sizeof(tapi_stk_display_text_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; } - if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->info, + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->text, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1323,11 +1555,20 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, tapi_log_info("stk agent confirm open channel method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_CONFIRM_OPEN_CHANNEL_IND; @@ -1335,12 +1576,14 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1348,6 +1591,7 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1356,6 +1600,7 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1385,16 +1630,25 @@ int tapi_stk_agent_interface_register(tapi_context context, int slot_id, dbus_context* ctx = context; tapi_async_result* ar; - if (ctx == NULL || agent_id == NULL) + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; + } user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user_data in %s is null", __func__); return -ENOMEM; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(user_data); return -ENOMEM; } @@ -1403,10 +1657,11 @@ int tapi_stk_agent_interface_register(tapi_context context, int slot_id, user_data->result = ar; user_data->cb_function = p_handle; - tapi_log_debug("starting stk agent interface slot : %d, agent id : %s\n", slot_id, agent_id); + tapi_log_debug("starting stk agent interface in %s, slot : %d, agent id : %s", + __func__, slot_id, agent_id); if (!g_dbus_register_interface(ctx->connection, agent_id, OFONO_SIM_APP_INTERFACE, - agent_methods, NULL, NULL, user_data, handler_free)) { - tapi_log_error("Unable to register stk agent %s\n", agent_id); + stk_agent_methods, NULL, NULL, user_data, handler_free)) { + tapi_log_error("Unable to register stk agent %s in %s", agent_id, __func__); return -EINVAL; } @@ -1417,13 +1672,20 @@ int tapi_stk_agent_interface_unregister(tapi_context context, char* agent_id) { dbus_context* ctx = context; - if (ctx == NULL || agent_id == NULL) + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; + } - tapi_log_debug("stopping stk agent interface agent id : %s\n", agent_id); + tapi_log_debug("stopping stk agent interface in %s, agent id : %s", __func__, agent_id); if (!g_dbus_unregister_interface(ctx->connection, agent_id, OFONO_SIM_APP_INTERFACE)) { - tapi_log_error("Unable to unregister stk agent %s\n", agent_id); + tapi_log_error("Unable to unregister stk agent %s in %s", agent_id, __func__); return -EINVAL; } @@ -1436,7 +1698,13 @@ int tapi_stk_default_agent_interface_register(tapi_context context, int slot_id, dbus_context* ctx = context; char* agent_path; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1455,7 +1723,13 @@ int tapi_stk_default_agent_interface_unregister(tapi_context context, int slot_i dbus_context* ctx = context; char* agent_path; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1477,24 +1751,36 @@ int tapi_stk_agent_register(tapi_context context, int slot_id, GDBusProxy* proxy; tapi_async_result* ar; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || agent_id == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("proxy in %s is null", __func__); return -EIO; } user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user_data in %s is null", __func__); return -ENOMEM; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(user_data); return -ENOMEM; } @@ -1507,7 +1793,7 @@ int tapi_stk_agent_register(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "RegisterAgent", stk_agent_register_param_append, method_call_complete, user_data, handler_free)) { - tapi_log_error("failed to register agent\n"); + tapi_log_error("dbus method call fail in %s", __func__); handler_free(user_data); return -EINVAL; } @@ -1523,24 +1809,36 @@ int tapi_stk_agent_unregister(tapi_context context, int slot_id, GDBusProxy* proxy; tapi_async_result* ar; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || agent_id == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user_data in %s is null", __func__); return -ENOMEM; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(user_data); return -ENOMEM; } @@ -1553,7 +1851,7 @@ int tapi_stk_agent_unregister(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "UnregisterAgent", stk_agent_register_param_append, method_call_complete, user_data, handler_free)) { - tapi_log_error("failed to unregister agent\n"); + tapi_log_error("dbus method call fail in %s", __func__); handler_free(user_data); return -EINVAL; } @@ -1567,7 +1865,13 @@ int tapi_stk_default_agent_register(tapi_context context, int slot_id, dbus_context* ctx = context; char* agent_path; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1587,7 +1891,13 @@ int tapi_stk_default_agent_unregister(tapi_context context, int slot_id, dbus_context* ctx = context; char* agent_path; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1610,18 +1920,30 @@ int tapi_stk_select_item(tapi_context context, int slot_id, GDBusProxy* proxy; tapi_async_result* ar; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || agent_id == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } select_item_param = malloc(sizeof(stk_select_item_param)); if (select_item_param == NULL) { + tapi_log_error("select_item_param in %s is null", __func__); return -ENOMEM; } select_item_param->item = item; @@ -1629,6 +1951,7 @@ int tapi_stk_select_item(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(select_item_param); return -ENOMEM; } @@ -1638,6 +1961,7 @@ int tapi_stk_select_item(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user_data in %s is null", __func__); free(select_item_param); free(ar); return -ENOMEM; @@ -1648,7 +1972,7 @@ int tapi_stk_select_item(tapi_context context, int slot_id, tapi_log_info("tapi_stk_select_item item : %d, path : %s\n", item, agent_id); if (!g_dbus_proxy_method_call(proxy, "SelectItem", stk_select_item_param_append, method_call_complete, user_data, stk_event_data_free)) { - tapi_log_error("failed to select item\n"); + tapi_log_error("dbus method call fail in %s", __func__); stk_event_data_free(user_data); return -EINVAL; } @@ -1662,16 +1986,24 @@ int tapi_stk_get_idle_mode_text(tapi_context context, int slot_id, char** text) GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1680,6 +2012,7 @@ int tapi_stk_get_idle_mode_text(tapi_context context, int slot_id, char** text) return OK; } + tapi_log_error("dbus get property fail in %s", __func__); return ERROR; } @@ -1689,16 +2022,24 @@ int tapi_stk_get_idle_mode_icon(tapi_context context, int slot_id, char** icon) GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1707,6 +2048,7 @@ int tapi_stk_get_idle_mode_icon(tapi_context context, int slot_id, char** icon) return OK; } + tapi_log_error("dbus get property fail in %s", __func__); return ERROR; } @@ -1719,21 +2061,34 @@ int tapi_stk_get_main_menu(tapi_context context, int slot_id, int length, tapi_s char* text; int index; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || length <= 0) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (length <= 0) { + tapi_log_error("invalid length %d in %s", length, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (!g_dbus_proxy_get_property(proxy, "MainMenu", &array)) { + tapi_log_error("dbus get property fail in %s", __func__); return -EIO; } @@ -1772,16 +2127,24 @@ int tapi_stk_get_main_menu_title(tapi_context context, int slot_id, char** title GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1790,6 +2153,7 @@ int tapi_stk_get_main_menu_title(tapi_context context, int slot_id, char** title return OK; } + tapi_log_error("dbus get property fail in %s", __func__); return ERROR; } @@ -1799,16 +2163,24 @@ int tapi_stk_get_main_menu_icon(tapi_context context, int slot_id, char** icon) GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1817,6 +2189,7 @@ int tapi_stk_get_main_menu_icon(tapi_context context, int slot_id, char** icon) return OK; } + tapi_log_error("dbus get property fail in %s", __func__); return ERROR; } @@ -1825,7 +2198,18 @@ int tapi_stk_handle_agent_display_text(tapi_context context, tapi_stk_agent_oper dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -1859,7 +2243,18 @@ int tapi_stk_handle_agent_request_key(tapi_context context, dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -1895,7 +2290,18 @@ int tapi_stk_handle_agent_request_confirmation(tapi_context context, int confirm; bool flag = false; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -1930,7 +2336,18 @@ int tapi_stk_handle_agent_request_input(tapi_context context, dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -1969,7 +2386,18 @@ int tapi_stk_handle_agent_play_tone(tapi_context context, tapi_stk_agent_operato dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -2003,7 +2431,18 @@ int tapi_stk_handle_agent_request_selection(tapi_context context, dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } diff --git a/src/tapi_utils.c b/tapi_utils.c similarity index 95% rename from src/tapi_utils.c rename to tapi_utils.c index d6cc6d4..b230f3f 100644 --- a/src/tapi_utils.c +++ b/tapi_utils.c @@ -160,27 +160,28 @@ tapi_network_type tapi_utils_network_type_from_ril_tech(int type) return NETWORK_TYPE_UNKNOWN; } -const char* tapi_utils_get_registration_status_string(int status) +const char* tapi_utils_registration_status_to_string(int status) { - if (status == NETWORK_REGISTRATION_STATUS_NOT_REGISTERED) { - return "not_registered"; - } else if (status == NETWORK_REGISTRATION_STATUS_REGISTERED) { + switch (status) { + case NETWORK_REGISTRATION_STATUS_NOT_REGISTERED: + return "unregistered"; + case NETWORK_REGISTRATION_STATUS_REGISTERED: return "registered"; - } else if (status == NETWORK_REGISTRATION_STATUS_SEARCHING) { + case NETWORK_REGISTRATION_STATUS_SEARCHING: return "searching"; - } else if (status == NETWORK_REGISTRATION_STATUS_DENIED) { + case NETWORK_REGISTRATION_STATUS_DENIED: return "denied"; - } else if (status == NETWORK_REGISTRATION_STATUS_UNKNOWN) { + case NETWORK_REGISTRATION_STATUS_UNKNOWN: return "unknown"; - } else if (status == NETWORK_REGISTRATION_STATUS_ROAMING) { + case NETWORK_REGISTRATION_STATUS_ROAMING: return "roaming"; - } else if (status == NETWORK_REGISTRATION_STATUS_NOT_REGISTERED_EM) { - return "not_registered_em"; - } else if (status == NETWORK_REGISTRATION_STATUS_SEARCHING_EM) { + case NETWORK_REGISTRATION_STATUS_NOT_REGISTERED_EM: + return "unregistered_em"; + case NETWORK_REGISTRATION_STATUS_SEARCHING_EM: return "searching_em"; - } else if (status == NETWORK_REGISTRATION_STATUS_DENIED_EM) { + case NETWORK_REGISTRATION_STATUS_DENIED_EM: return "denied_em"; - } else if (status == NETWORK_REGISTRATION_STATUS_UNKNOWN_EM) { + case NETWORK_REGISTRATION_STATUS_UNKNOWN_EM: return "unknown_em"; } diff --git a/tools/telephony_tool.c b/telephony_tool.c similarity index 99% rename from tools/telephony_tool.c rename to telephony_tool.c index 6c7787c..13a8349 100644 --- a/tools/telephony_tool.c +++ b/telephony_tool.c @@ -33,7 +33,7 @@ #include #include -#include "src/tapi_internal.h" +#include "tapi_internal.h" /**************************************************************************** * Pre-processor Definitions From 1ad67fe02ff699ae04dc5a24769ea2e86ed00d23 Mon Sep 17 00:00:00 2001 From: xujianhang Date: Mon, 11 Nov 2024 10:03:19 +0800 Subject: [PATCH 6/6] optimize tapi debug log --- tapi_call.c | 107 +++++++++++++++++++++++++-------------- tapi_cbs.c | 10 ++-- tapi_data.c | 58 +++++++++++----------- tapi_ims.c | 16 +++--- tapi_manager.c | 132 ++++++++++++++++++++++++------------------------- tapi_network.c | 56 ++++++++++++--------- tapi_ss.c | 5 +- 7 files changed, 214 insertions(+), 170 deletions(-) diff --git a/tapi_call.c b/tapi_call.c index 759a92d..8bb444e 100644 --- a/tapi_call.c +++ b/tapi_call.c @@ -76,7 +76,18 @@ static int tapi_call_property_change(DBusMessage* message, tapi_async_handler* h static int call_strcpy(char* dst, const char* src, int dst_size) { - if (dst == NULL || src == NULL || strlen(src) > dst_size) { + if (dst == NULL) { + tapi_log_error("dst in %s is null", __func__); + return -EINVAL; + } + + if (src == NULL) { + tapi_log_error("src in %s is null", __func__); + return -EINVAL; + } + + if (strlen(src) > dst_size) { + tapi_log_error("src length is too long"); return -EINVAL; } @@ -100,8 +111,18 @@ static void call_param_append(DBusMessageIter* iter, void* user_data) call_param* param; char* number; - if (handler == NULL || handler->result == NULL || handler->result->data == NULL) { - tapi_log_error("invalid dial request argument !!"); + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if (handler->result == NULL) { + tapi_log_error("result in %s is null", __func__); + return; + } + + if (handler->result->data == NULL) { + tapi_log_error("data in %s is null", __func__); return; } @@ -131,7 +152,7 @@ static void answer_hangup_param_append(DBusMessageIter* iter, void* user_data) char* path = user_data; if (path == NULL) { - tapi_log_error("invalid answer_hangup request argument !!"); + tapi_log_error("invalid answer_hangup request argument in %s!!", __func__); return; } @@ -145,8 +166,18 @@ static void dtmf_param_append(DBusMessageIter* iter, void* user_data) unsigned char digit; int flag; - if (handler == NULL || handler->result == NULL || handler->result->data == NULL) { - tapi_log_error("invalid dtmf request argument !!"); + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if (handler->result == NULL) { + tapi_log_error("result in %s is null", __func__); + return; + } + + if (handler->result->data == NULL) { + tapi_log_error("data in %s is null", __func__); return; } @@ -167,7 +198,7 @@ static void deflect_param_append_0(DBusMessageIter* iter, void* user_data) char *path, *number; if (param == NULL) { - tapi_log_error("invalid deflect request argument !!"); + tapi_log_error("param in %s is null", __func__); return; } @@ -203,7 +234,7 @@ static void conference_param_append(DBusMessageIter* iter, void* user_data) ims_conference_participants = user_data; if (ims_conference_participants == NULL) { - tapi_log_error("invalid conference request argument !!"); + tapi_log_error("ims_conference_participants in %s is null", __func__); return; } @@ -244,7 +275,7 @@ static int tapi_call_default_voicecall_slot_change(DBusMessage* message, tapi_as } if (!dbus_message_iter_init(message, &iter)) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); return false; } @@ -287,7 +318,6 @@ static int ring_back_tone_change(DBusMessage* message, tapi_async_handler* handl if (is_call_signal_message(message, &iter, DBUS_TYPE_INT32)) { dbus_message_iter_get_basic(&iter, &ar->arg2); - ar->status = OK; cb(ar); } @@ -356,7 +386,7 @@ static int call_state_changed(DBusConnection* connection, DBusMessage* message, } if (!dbus_message_iter_init(message, &iter)) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); return 0; } @@ -398,14 +428,14 @@ static void dial_call_callback(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -447,7 +477,7 @@ static void play_dtmf_callback(DBusMessage* message, void* user_data) ar->status = OK; dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; } @@ -484,20 +514,20 @@ static void merge_call_complete(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_has_signature(message, "ao") == false) { - tapi_log_error("dbus message has wrong signature"); + tapi_log_error("dbus message has wrong signature in %s", __func__); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -550,18 +580,18 @@ static void call_list_query_complete(DBusMessage* message, void* user_data) // start to handle response message. dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); goto done; } if (dbus_message_has_signature(message, "a(oa{sv})") == false) { - tapi_log_error("dbus message has wrong signature"); + tapi_log_error("dbus message has wrong signature in %s", __func__); goto done; } if (dbus_message_iter_init(message, &args) == false) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); goto done; } @@ -758,13 +788,13 @@ static int tapi_register_manager_call_signal(tapi_context context, int slot_id, member = get_call_signal_member(msg); if (member == NULL) { - tapi_log_error("no signal member found ...\n"); + tapi_log_error("member in %s is null", __func__); return -EINVAL; } modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("modem_path in %s is null", __func__); return -EIO; } @@ -866,11 +896,12 @@ static int manage_call_proxy_method(tapi_context context, int slot_id, const cha proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (!g_dbus_proxy_method_call(proxy, member, NULL, no_operate_callback, NULL, NULL)) { + tapi_log_error("dbus method call fail in %s", __func__); report_data_logging_for_call_if(!strcmp("HangupAll", member), ctx, OFONO_CALL_TYPE_UNKNOW, OFONO_DIRECTION_UNKNOW, OFONO_VOICE, OFONO_HANGUP_FAIL, "dbus method call fail"); report_data_logging_for_call_if(!strcmp("ReleaseAndAnswer", member) @@ -911,7 +942,7 @@ static int manager_conference(tapi_context context, int slot_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -953,7 +984,7 @@ static int call_play_dtmf(tapi_context context, int slot_id, unsigned char digit proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1025,7 +1056,7 @@ int tapi_call_dial(tapi_context context, int slot_id, char* number, int hide_cal proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1169,7 +1200,7 @@ int tapi_call_get_all_calls(tapi_context context, int slot_id, int event_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1224,7 +1255,7 @@ int tapi_call_merge_call(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1283,7 +1314,7 @@ int tapi_call_separate_call(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1337,7 +1368,7 @@ int tapi_call_send_tones(void* context, int slot_id, char* tones) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1374,7 +1405,7 @@ int tapi_call_get_ecc_list(tapi_context context, int slot_id, ecc_info* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1382,7 +1413,7 @@ int tapi_call_get_ecc_list(tapi_context context, int slot_id, ecc_info* out) syslog(LOG_DEBUG, "no EmergencyNumbers in CALL,use default"); proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (!g_dbus_proxy_get_property(proxy, "EmergencyNumbers", &list)) { @@ -1567,7 +1598,7 @@ int tapi_call_register_call_state_change(tapi_context context, int slot_id, modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } @@ -1626,7 +1657,7 @@ int tapi_call_answer_by_id(tapi_context context, int slot_id, char* call_id) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1663,7 +1694,7 @@ int tapi_call_hangup_by_id(tapi_context context, int slot_id, char* call_id) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1706,7 +1737,7 @@ int tapi_call_deflect_by_id(tapi_context context, int slot_id, char* call_id, ch proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1749,7 +1780,7 @@ int tapi_call_set_default_slot(tapi_context context, int slot_id) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1783,7 +1814,7 @@ int tapi_call_get_default_slot(tapi_context context, int* out) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } diff --git a/tapi_cbs.c b/tapi_cbs.c index 8310218..c85d2aa 100644 --- a/tapi_cbs.c +++ b/tapi_cbs.c @@ -173,7 +173,7 @@ int tapi_sms_set_cell_broadcast_power_on(tapi_context context, int slot_id, bool proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CBS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -203,7 +203,7 @@ int tapi_sms_get_cell_broadcast_power_on(tapi_context context, int slot_id, bool proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CBS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EISCONN; } @@ -238,7 +238,7 @@ int tapi_sms_set_cell_broadcast_topics(tapi_context context, int slot_id, char* proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CBS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -268,7 +268,7 @@ int tapi_sms_get_cell_broadcast_topics(tapi_context context, int slot_id, char** proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CBS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EISCONN; } @@ -302,7 +302,7 @@ int tapi_cbs_register(tapi_context context, int slot_id, tapi_indication_msg msg path = tapi_utils_get_modem_path(slot_id); if (path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } diff --git a/tapi_data.c b/tapi_data.c index 2d61e6e..6aae7a5 100644 --- a/tapi_data.c +++ b/tapi_data.c @@ -478,7 +478,7 @@ static void apn_list_loaded(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -558,7 +558,7 @@ static void apn_list_changed(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; } @@ -587,7 +587,7 @@ static void apn_context_append(DBusMessageIter* iter, void* user_data) dc = ar->data; if (dc == NULL) { - tapi_log_error("invalid apn settings ... \n"); + tapi_log_error("dc in %s is null", __func__); return; } @@ -668,7 +668,7 @@ static void apn_context_edit(DBusMessageIter* iter, void* user_data) dc = ar->data; if (dc == NULL) { - tapi_log_error("invalid apn settings ... \n"); + tapi_log_error("dc in %s is null", __func__); return; } @@ -734,7 +734,7 @@ static void data_connection_list_query_done(DBusMessage* message, void* user_dat dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -837,7 +837,7 @@ int tapi_data_load_apn_contexts(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -893,13 +893,13 @@ int tapi_data_add_apn_context(tapi_context context, } if (tapi_utils_apn_type_to_string(apn->type) == NULL) { - tapi_log_error("invalid apn argument ...\n"); + tapi_log_error("invalid apn argument in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -957,7 +957,7 @@ int tapi_data_remove_apn_context(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1014,13 +1014,13 @@ int tapi_data_edit_apn_context(tapi_context context, } if (tapi_utils_apn_type_to_string(apn->type) == NULL) { - tapi_log_error("invalid apn argument ...\n"); + tapi_log_error("invalid apn argument in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1073,7 +1073,7 @@ int tapi_data_reset_apn_contexts(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1129,7 +1129,7 @@ int tapi_data_is_registered(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1169,7 +1169,7 @@ int tapi_data_is_data_emergency_only(tapi_context context, int slot_id, bool* ou proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1211,7 +1211,7 @@ int tapi_data_get_network_type(tapi_context context, int slot_id, tapi_network_t proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1250,7 +1250,7 @@ int tapi_data_is_data_roaming(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1287,7 +1287,7 @@ int tapi_data_request_network(tapi_context context, int slot_id, const char* typ proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1322,7 +1322,7 @@ int tapi_data_release_network(tapi_context context, int slot_id, const char* typ proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1355,7 +1355,7 @@ int tapi_data_get_data_connection_list(tapi_context context, int slot_id, int ev proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1415,7 +1415,7 @@ int tapi_data_set_preferred_apn(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1452,7 +1452,7 @@ int tapi_data_get_preferred_apn(tapi_context context, int slot_id, char** out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1486,7 +1486,7 @@ int tapi_data_enable_data(tapi_context context, bool enabled) for (int i = 0; i < CONFIG_MODEM_ACTIVE_COUNT; i++) { proxy = ctx->dbus_proxy[i][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1519,7 +1519,7 @@ int tapi_data_get_enabled(tapi_context context, bool* out) proxy = ctx->dbus_proxy[DEFAULT_SLOT_ID][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1555,7 +1555,7 @@ int tapi_data_enable_roaming(tapi_context context, bool enabled) for (int i = 0; i < CONFIG_MODEM_ACTIVE_COUNT; i++) { proxy = ctx->dbus_proxy[i][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1588,7 +1588,7 @@ int tapi_data_get_roaming_enabled(tapi_context context, bool* out) proxy = ctx->dbus_proxy[DEFAULT_SLOT_ID][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1611,7 +1611,7 @@ int tapi_data_set_default_slot(tapi_context context, int slot_id) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1644,7 +1644,7 @@ int tapi_data_get_default_slot(tapi_context context, int* out) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1689,7 +1689,7 @@ int tapi_data_set_data_allow(tapi_context context, int slot_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1746,7 +1746,7 @@ int tapi_data_register(tapi_context context, modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } diff --git a/tapi_ims.c b/tapi_ims.c index 7def7bc..d0434f2 100644 --- a/tapi_ims.c +++ b/tapi_ims.c @@ -67,7 +67,7 @@ static int tapi_ims_enable(tapi_context context, int slot_id, int state) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -184,7 +184,7 @@ int tapi_ims_set_service_status(tapi_context context, int slot_id, int capabilit proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -218,7 +218,7 @@ int tapi_ims_register_registration_change(tapi_context context, int slot_id, voi path = tapi_utils_get_modem_path(slot_id); if (path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } @@ -287,7 +287,7 @@ int tapi_ims_get_registration(tapi_context context, int slot_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -338,7 +338,7 @@ int tapi_ims_is_registered(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -377,7 +377,7 @@ int tapi_ims_is_volte_available(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -422,7 +422,7 @@ int tapi_ims_get_subscriber_uri_number(tapi_context context, int slot_id, char** proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -459,7 +459,7 @@ int tapi_ims_get_enabled(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } diff --git a/tapi_manager.c b/tapi_manager.c index d308115..6114756 100644 --- a/tapi_manager.c +++ b/tapi_manager.c @@ -1065,7 +1065,7 @@ static int tapi_modem_register(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1360,18 +1360,18 @@ int tapi_set_pref_net_mode(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_RADIO]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1419,18 +1419,18 @@ int tapi_get_pref_net_mode(tapi_context context, int slot_id, tapi_pref_net_mode } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_RADIO]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1457,18 +1457,18 @@ int tapi_send_modem_power(tapi_context context, int slot_id, bool state) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1493,18 +1493,18 @@ int tapi_get_imei(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1529,18 +1529,18 @@ int tapi_get_imeisv(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1565,18 +1565,18 @@ int tapi_get_modem_manufacturer(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1601,18 +1601,18 @@ int tapi_get_modem_model(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1637,18 +1637,18 @@ int tapi_get_modem_revision(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1674,18 +1674,18 @@ int tapi_get_phone_state(tapi_context context, int slot_id, tapi_phone_state* st } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1714,18 +1714,18 @@ int tapi_set_radio_power(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1770,18 +1770,18 @@ int tapi_get_radio_power(tapi_context context, int slot_id, bool* out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1809,18 +1809,18 @@ int tapi_get_radio_state(tapi_context context, int slot_id, tapi_radio_state* ou } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1846,18 +1846,18 @@ int tapi_get_msisdn_number(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1896,13 +1896,13 @@ int tapi_get_modem_activity_info(tapi_context context, int slot_id, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1950,7 +1950,7 @@ int tapi_invoke_oem_ril_request_raw(tapi_context context, int slot_id, int event } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1966,7 +1966,7 @@ int tapi_invoke_oem_ril_request_raw(tapi_context context, int slot_id, int event proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2025,7 +2025,7 @@ int tapi_invoke_oem_ril_request_strings(tapi_context context, int slot_id, int e } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2041,7 +2041,7 @@ int tapi_invoke_oem_ril_request_strings(tapi_context context, int slot_id, int e proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2099,13 +2099,13 @@ int tapi_enable_modem(tapi_context context, int slot_id, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2152,13 +2152,13 @@ int tapi_enable_modem_abnormal_event(tapi_context context, int slot_id, bool ena } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2219,13 +2219,13 @@ int tapi_get_modem_status(tapi_context context, int slot_id, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2270,7 +2270,7 @@ int tapi_get_modem_status_sync(tapi_context context, int slot_id, tapi_modem_sta } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2281,7 +2281,7 @@ int tapi_get_modem_status_sync(tapi_context context, int slot_id, tapi_modem_sta proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2351,7 +2351,7 @@ static int tapi_manager_register_data_loging(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2397,7 +2397,7 @@ static int trigger_modem_load_ecc_list(tapi_context context, int slot_id) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2512,13 +2512,13 @@ int tapi_handle_command(tapi_context context, int slot_id, int atom, int command } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2564,7 +2564,7 @@ int tapi_set_fast_dormancy(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2575,7 +2575,7 @@ int tapi_set_fast_dormancy(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_RADIO]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2641,7 +2641,7 @@ int tapi_get_carrier_config_bool(tapi_context context, int slot_id, char* key, b } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2657,7 +2657,7 @@ int tapi_get_carrier_config_bool(tapi_context context, int slot_id, char* key, b proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2711,7 +2711,7 @@ int tapi_get_carrier_config_int(tapi_context context, int slot_id, char* key, in } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2727,7 +2727,7 @@ int tapi_get_carrier_config_int(tapi_context context, int slot_id, char* key, in proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2780,7 +2780,7 @@ int tapi_get_carrier_config_string(tapi_context context, int slot_id, char* key, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2796,7 +2796,7 @@ int tapi_get_carrier_config_string(tapi_context context, int slot_id, char* key, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } diff --git a/tapi_network.c b/tapi_network.c index b6f0417..2c3f5e7 100644 --- a/tapi_network.c +++ b/tapi_network.c @@ -35,8 +35,15 @@ static void parse_nitz(const char* str, tapi_network_time* info) char* pch; char* orig; - if (str == NULL || info == NULL) + if (str == NULL) { + tapi_log_error("str in %s is null", __func__); return; + } + + if (info == NULL) { + tapi_log_error("info in %s is null", __func__); + return; + } p = &info->sec; orig = strdup(str); @@ -60,8 +67,13 @@ static void register_param_append(DBusMessageIter* iter, void* user_data) tapi_operator_info* network_info; char *mcc, *mnc, *tech; - if (handler == NULL || handler->result == NULL) { - tapi_log_error("invalid network register argument !!"); + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if (handler->result == NULL) { + tapi_log_error("async result in %s is null", __func__); return; } @@ -569,7 +581,7 @@ static void network_register_cb(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; } @@ -615,7 +627,7 @@ static void cell_list_request_complete(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -710,7 +722,7 @@ static void registration_info_query_done(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -815,7 +827,7 @@ static void operator_scan_complete(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -922,7 +934,7 @@ int tapi_network_select_auto(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -979,7 +991,7 @@ int tapi_network_select_manual(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1038,7 +1050,7 @@ int tapi_network_scan(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1090,7 +1102,7 @@ int tapi_network_get_serving_cellinfos(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETMON]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1142,7 +1154,7 @@ int tapi_network_get_neighbouring_cellinfos(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETMON]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1242,7 +1254,7 @@ int tapi_network_is_voice_emergency_only(tapi_context context, int slot_id, bool proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1285,7 +1297,7 @@ int tapi_network_get_voice_network_type(tapi_context context, int slot_id, tapi_ proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1325,7 +1337,7 @@ int tapi_network_is_voice_roaming(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1364,7 +1376,7 @@ int tapi_network_get_mcc(tapi_context context, int slot_id, char** mcc) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1400,7 +1412,7 @@ int tapi_network_get_mnc(tapi_context context, int slot_id, char** mnc) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1436,7 +1448,7 @@ int tapi_network_get_display_name(tapi_context context, int slot_id, char** out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1472,7 +1484,7 @@ int tapi_network_get_signalstrength(tapi_context context, int slot_id, tapi_sign proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1539,7 +1551,7 @@ int tapi_network_get_registration_info(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1592,7 +1604,7 @@ int tapi_network_set_cell_info_list_rate(tapi_context context, int slot_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETMON]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1652,7 +1664,7 @@ int tapi_network_register(tapi_context context, modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } diff --git a/tapi_ss.c b/tapi_ss.c index f035d06..c94a0ee 100644 --- a/tapi_ss.c +++ b/tapi_ss.c @@ -966,12 +966,12 @@ static bool is_ussd_signal_message(DBusMessage* message, DBusMessageIter* iter, int msg_type) { if (!dbus_message_iter_init(message, iter)) { - tapi_log_error("ussd_signal message has no param"); + tapi_log_error("message iter init failed in %s", __func__); return false; } if (dbus_message_iter_get_arg_type(iter) != msg_type) { - tapi_log_error("ussd_signal param is not right"); + tapi_log_error("arg type in %s is invalid", __func__); return false; } @@ -2000,6 +2000,7 @@ int tapi_ss_get_call_waiting(tapi_context context, int slot_id, int event_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; }