From: Jaehyun Kim Date: Thu, 20 Oct 2022 07:52:40 +0000 (+0900) Subject: DA: Add scan callback timer X-Git-Tag: accepted/tizen/7.0/unified/20230126.170237~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F283201%2F1;p=platform%2Fcore%2Fapi%2Fwifi-manager.git DA: Add scan callback timer Send the callback to upper layer forcibly if it did not receive the scan callback from connman until 10 sec. Update bssid list from net-config when it could not get the bssid scan callback until 10 sec. Change-Id: I575f91c47d998990a497423cd17d75fbf8543559 Signed-off-by: Jaehyun Kim --- diff --git a/src/network_dbus.c b/src/network_dbus.c index e973600..d8aa29d 100644 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -32,6 +32,15 @@ #define WIFI_SECURITY_OWE "owe" #define WIFI_SECURITY_DPP "dpp" +#if defined TIZEN_DA +#include "network_signal.h" + +__thread guint full_scan_cb_timer = 0; +__thread guint specific_scan_cb_timer = 0; +__thread guint multi_scan_cb_timer = 0; +__thread guint bssid_scan_cb_timer = 0; +#endif /* TIZEN_DA */ + //LCOV_EXCL_START static int __net_error_string_to_enum(const char *error) { @@ -386,6 +395,140 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re __NETWORK_FUNC_EXIT__; } +#if defined TIZEN_DA +static gboolean __check_full_scan_callback(gpointer data) +{ + net_event_info_s *event_data = NULL; + network_info_s *network_info = (network_info_s *)data; + network_request_table_s *request_table = network_info->request_table; + + WIFI_LOG(WIFI_INFO, "Check the full scan callback."); + + if (network_info->scan_pending && (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)) { + event_data = g_try_malloc0(sizeof(net_event_info_s)); + if (event_data == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to allocate dynamic memory."); + return TRUE; + } + + WIFI_LOG(WIFI_INFO, "It did not receive the scan callback until 10 sec... send the callback forcibly."); + + network_info->scan_pending = FALSE; + + memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0, sizeof(network_request_table_s)); + event_data->Event = NET_EVENT_WIFI_SCAN_RSP; + + event_data->Error = NET_ERR_NONE; + event_data->Datalength = 0; + event_data->Data = NULL; + + if (network_info->event_callback) + network_info->event_callback(event_data, network_info->user_data); + + memset(event_data, 0, sizeof(net_event_info_s)); + + wifi_manager_scan_state_e scan_state = WIFI_MANAGER_SCAN_STATE_NOT_SCANNING; + event_data->Event = NET_EVENT_WIFI_SCAN_CHANGED; + event_data->Data = &scan_state; + event_data->Datalength = sizeof(wifi_manager_scan_state_e); + event_data->Error = NET_ERR_NONE; + + if (network_info->event_callback) + network_info->event_callback(event_data, network_info->user_data); + + g_free(event_data); + } + + full_scan_cb_timer = 0; + + return FALSE; +} + +static gboolean __check_specific_scan_callback(gpointer data) +{ + net_event_info_s *event_data = NULL; + network_info_s *network_info = (network_info_s *)data; + network_request_table_s *request_table = network_info->request_table; + + WIFI_LOG(WIFI_INFO, "Check the specific scan callback."); + + if (network_info->scan_pending && (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE)) { + event_data = g_try_malloc0(sizeof(net_event_info_s)); + if (event_data == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to allocate dynamic memory."); + return TRUE; + } + + WIFI_LOG(WIFI_INFO, "It did not receive the scan callback until 10 sec... send the callback forcibly."); + + network_info->scan_pending = FALSE; + + memset(&request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN], 0, sizeof(network_request_table_s)); + event_data->Event = NET_EVENT_WIFI_SPECIFIC_SCAN_RSP; + + event_data->Error = NET_ERR_NONE; + event_data->Datalength = 0; + event_data->Data = NULL; + + if (network_info->event_callback) + network_info->event_callback(event_data, network_info->user_data); + + g_free(event_data); + } + + specific_scan_cb_timer = 0; + + return FALSE; +} + +static gboolean __check_multi_scan_callback(gpointer data) +{ + net_event_info_s *event_data = NULL; + network_info_s *network_info = (network_info_s *)data; + network_request_table_s *request_table = network_info->request_table; + + WIFI_LOG(WIFI_INFO, "Check the multi scan callback."); + + if (network_info->scan_pending && (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE)) { + event_data = g_try_malloc0(sizeof(net_event_info_s)); + if (event_data == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to allocate dynamic memory."); + return TRUE; + } + + WIFI_LOG(WIFI_INFO, "It did not receive the scan callback until 10 sec... send the callback forcibly."); + + network_info->scan_pending = FALSE; + + memset(&request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN], 0, sizeof(network_request_table_s)); + event_data->Event = NET_EVENT_WIFI_MULTI_SCAN_RSP; + + event_data->Error = NET_ERR_NONE; + event_data->Datalength = 0; + event_data->Data = NULL; + + if (network_info->event_callback) + network_info->event_callback(event_data, network_info->user_data); + + g_free(event_data); + } + + multi_scan_cb_timer = 0; + + return FALSE; +} + +static gboolean __check_bssid_scan_callback(gpointer data) +{ + network_info_s *network_info = (network_info_s *)data; + + WIFI_LOG(WIFI_INFO, "BSSID Scan Completed"); + __net_dbus_get_bssid_list(network_info); + + return FALSE; +} +#endif /* TIZEN_DA */ + static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer user_data) { __NETWORK_FUNC_ENTER__; @@ -427,6 +570,18 @@ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer if (reply) g_variant_unref(reply); +#if defined TIZEN_DA + if (full_scan_cb_timer > 0) { + g_source_remove(full_scan_cb_timer); + full_scan_cb_timer = 0; + } + + if (bssid_scan_cb_timer > 0) { + g_source_remove(bssid_scan_cb_timer); + bssid_scan_cb_timer = 0; + } +#endif /* TIZEN_DA */ + request_table = network_info->request_table; bssid_scan_info = &request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN]; @@ -455,10 +610,32 @@ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) { WIFI_LOG(WIFI_INFO, "Full channel Scan pending"); network_info->scan_pending = TRUE; +#if defined TIZEN_DA + full_scan_cb_timer = g_timeout_add_seconds(10, __check_full_scan_callback, (void *)network_info); +#endif /* TIZEN_DA */ } else if (bssid_scan_info->flag == TRUE) { WIFI_LOG(WIFI_INFO, "BSSID Scan pending"); network_info->scan_pending = TRUE; +#if defined TIZEN_DA + bssid_scan_cb_timer = g_timeout_add_seconds(10, __check_bssid_scan_callback, (void *)network_info); +#endif /* TIZEN_DA */ } + +#if defined TIZEN_DA + wifi_manager_scan_state_e scan_state = WIFI_MANAGER_SCAN_STATE_SCANNING; + event_data->Event = NET_EVENT_WIFI_SCAN_CHANGED; + event_data->Data = &scan_state; + event_data->Datalength = sizeof(wifi_manager_scan_state_e); + event_data->Error = NET_ERR_NONE; + + if (network_info->event_callback) + network_info->event_callback(event_data, network_info->user_data); + + g_free(event_data); + + __NETWORK_FUNC_EXIT__; + return; +#endif /* TIZEN_DA */ } else if (Error != NET_ERR_NONE) { WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%d]", Error); @@ -2091,6 +2268,13 @@ static void __net_specific_scan_request_reply(GObject *source_object, GAsyncResu if (reply) g_variant_unref(reply); +#if defined TIZEN_DA + if (specific_scan_cb_timer > 0) { + g_source_remove(specific_scan_cb_timer); + specific_scan_cb_timer = 0; + } +#endif /* TIZEN_DA */ + request_table = network_info->request_table; if (Error == NET_ERR_IN_PROGRESS) { @@ -2098,6 +2282,9 @@ static void __net_specific_scan_request_reply(GObject *source_object, GAsyncResu if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) { WIFI_LOG(WIFI_INFO, "Specific Scan pending"); network_info->scan_pending = TRUE; +#if defined TIZEN_DA + specific_scan_cb_timer = g_timeout_add_seconds(10, __check_specific_scan_callback, (void *)network_info); +#endif /* TIZEN_DA */ } } else if (Error != NET_ERR_NONE) { WIFI_LOG(WIFI_ERROR, "Specific Scan failed. Error [%d]", Error); @@ -4019,6 +4206,13 @@ static void __net_multi_scan_request_reply(GObject *source_object, GAsyncResult if (reply) g_variant_unref(reply); +#if defined TIZEN_DA + if (multi_scan_cb_timer > 0) { + g_source_remove(multi_scan_cb_timer); + multi_scan_cb_timer = 0; + } +#endif /* TIZEN_DA */ + request_table = network_info->request_table; if (Error == NET_ERR_IN_PROGRESS) { @@ -4026,6 +4220,9 @@ static void __net_multi_scan_request_reply(GObject *source_object, GAsyncResult if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) { WIFI_LOG(WIFI_INFO, "Multi Scan pending"); network_info->scan_pending = TRUE; +#if defined TIZEN_DA + multi_scan_cb_timer = g_timeout_add_seconds(10, __check_multi_scan_callback, (void *)network_info); +#endif /* TIZEN_DA */ } } else if (Error != NET_ERR_NONE) { WIFI_LOG(WIFI_ERROR, "Multi Scan failed. Error [%d]", Error); diff --git a/src/network_interface.c b/src/network_interface.c index 932b495..62b4c69 100644 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -28,6 +28,13 @@ #define DBUS_OBJECT_PATH_MAX 150 +#if defined TIZEN_DA +extern __thread guint full_scan_cb_timer; +extern __thread guint specific_scan_cb_timer; +extern __thread guint multi_scan_cb_timer; +extern __thread guint bssid_scan_cb_timer; +#endif /* TIZEN_DA */ + //LCOV_EXCL_START static int __net_check_get_privilege(network_info_s *network_info) { @@ -2195,6 +2202,25 @@ int net_wifi_power_off(network_info_s *network_info) return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE } +#if defined TIZEN_DA + if (full_scan_cb_timer > 0) { + g_source_remove(full_scan_cb_timer); + full_scan_cb_timer = 0; + } + if (specific_scan_cb_timer > 0) { + g_source_remove(specific_scan_cb_timer); + specific_scan_cb_timer = 0; + } + if (multi_scan_cb_timer > 0) { + g_source_remove(multi_scan_cb_timer); + multi_scan_cb_timer = 0; + } + if (bssid_scan_cb_timer > 0) { + g_source_remove(bssid_scan_cb_timer); + bssid_scan_cb_timer = 0; + } +#endif /* TIZEN_DA */ + if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SCAN]), 0, sizeof(network_request_table_s)); diff --git a/src/network_signal.c b/src/network_signal.c index a46a075..a1d1630 100644 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -27,6 +27,13 @@ #define NET_WPS_EI_OPERATION_FAILED 1 #define NET_WPS_EI_SECURITY_WEP_PROHIBITED 2 +#if defined TIZEN_DA +extern __thread guint full_scan_cb_timer; +extern __thread guint specific_scan_cb_timer; +extern __thread guint multi_scan_cb_timer; +extern __thread guint bssid_scan_cb_timer; +#endif /* TIZEN_DA */ + struct cs_tid_info { int tid; guint subscribe_id_connman_state; @@ -39,7 +46,9 @@ struct cs_tid_info { static GSList *cs_tid_list = NULL; +#if !defined TIZEN_DA static int __net_dbus_get_bssid_list(); +#endif /* !TIZEN_DA */ static int __net_dbus_get_technology_states(network_info_s *network_info); //LCOV_EXCL_START @@ -991,6 +1000,24 @@ static int __net_handle_scan_done(network_info_s *network_info, GVariant *param) if (network_info->scan_pending == TRUE) { net_err_e Error = NET_ERR_NONE; network_info->scan_pending = FALSE; +#if defined TIZEN_DA + if (full_scan_cb_timer > 0) { + g_source_remove(full_scan_cb_timer); + full_scan_cb_timer = 0; + } + if (specific_scan_cb_timer > 0) { + g_source_remove(specific_scan_cb_timer); + specific_scan_cb_timer = 0; + } + if (multi_scan_cb_timer > 0) { + g_source_remove(multi_scan_cb_timer); + multi_scan_cb_timer = 0; + } + if (bssid_scan_cb_timer > 0) { + g_source_remove(bssid_scan_cb_timer); + bssid_scan_cb_timer = 0; + } +#endif /* TIZEN_DA */ int current_scan_type = -1; if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) @@ -2035,7 +2062,11 @@ static int __net_get_tech_states(network_info_s *network_info, GVariant *message return Error; } +#if defined TIZEN_DA +int __net_dbus_get_bssid_list(network_info_s *network_info) +#else static int __net_dbus_get_bssid_list(network_info_s *network_info) +#endif /* !TIZEN_DA */ { __NETWORK_FUNC_ENTER__; diff --git a/src/network_signal.h b/src/network_signal.h index 0110d0f..2a49513 100644 --- a/src/network_signal.h +++ b/src/network_signal.h @@ -31,6 +31,10 @@ int _net_init_service_state(network_info_s *network_info); void _net_set_cs_tid(network_info_s *network_info, int tid); void _net_unset_cs_tid(int tid); +#if defined TIZEN_DA +int __net_dbus_get_bssid_list(network_info_s *network_info); +#endif /* TIZEN_DA */ + #ifdef __cplusplus } #endif