DA: Add connection callback timer 11/283211/2
authorJaehyun Kim <jeik01.kim@samsung.com>
Thu, 20 Oct 2022 09:06:27 +0000 (18:06 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Thu, 20 Oct 2022 09:10:08 +0000 (18:10 +0900)
Send the callback to upper layer forcibly
if it did not receive the connection callback until 50 sec.

Invoke connection request and status callback
if it did not receive connection response.

Change-Id: I35caefdd24bc899db057c1d3a28ecf465e80b58e
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
src/network_dbus.c
src/network_info.h
src/network_interface.c
src/network_signal.c
src/wifi_internal.c

index d8aa29de7e2a2bbe924d815104e903c4bfaff59e..4e60c18ff89b215c8adb24534b0945a54cc8bd58 100644 (file)
@@ -35,6 +35,8 @@
 #if defined TIZEN_DA
 #include "network_signal.h"
 
+__thread guint connection_cb_timer = 0;
+
 __thread guint full_scan_cb_timer = 0;
 __thread guint specific_scan_cb_timer = 0;
 __thread guint multi_scan_cb_timer = 0;
@@ -265,6 +267,10 @@ static net_wifi_eap_auth_type_e __net_wifi_eap_auth_type_to_int(const gchar *typ
        return ret;
 }
 
+#if defined TIZEN_DA
+static gboolean __check_connection_callback(gpointer data);
+#endif /* TIZEN_DA */
+
 static void __net_open_connection_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
        __NETWORK_FUNC_ENTER__;
@@ -301,6 +307,13 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re
                g_variant_unref(reply);
 
        if (Error == NET_ERR_NONE) {
+#if defined TIZEN_DA
+               if (connection_cb_timer > 0) {
+                       g_source_remove(connection_cb_timer);
+                       connection_cb_timer = 0;
+               }
+               connection_cb_timer = g_timeout_add_seconds(50, __check_connection_callback, (void *)network_info);
+#endif /* TIZEN_DA */
                __NETWORK_FUNC_EXIT__;
                return;
        }
@@ -327,6 +340,12 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re
        if (open_info->flag == TRUE) {
                g_strlcpy(event_data->ProfileName, open_info->ProfileName,
                                NET_PROFILE_NAME_LEN_MAX + 1);
+#if defined TIZEN_DA
+               if (connection_cb_timer > 0) {
+                       g_source_remove(connection_cb_timer);
+                       connection_cb_timer = 0;
+               }
+#endif /* TIZEN_DA */
                memset(open_info, 0, sizeof(network_request_table_s));
 
                event_data->Error = Error;
@@ -396,6 +415,57 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re
 }
 
 #if defined TIZEN_DA
+static gboolean __check_connection_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;
+       net_err_e Error = NET_ERR_NONE;
+
+       WIFI_LOG(WIFI_INFO, "Check the connection callback.");
+
+       if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+               WIFI_LOG(WIFI_INFO, "It did not receive the connection callback until 50 sec... send the callback forcibly.");
+
+               request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag = TRUE;
+               g_strlcpy(request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName,
+                               request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName, NET_PROFILE_NAME_LEN_MAX + 1);
+
+               Error = _net_dbus_close_connection(network_info, request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName);
+               if (Error != NET_ERR_NONE) {
+                       WIFI_LOG(WIFI_ERROR, "Failed to request close connection, Error [%s]", _net_print_error(Error));
+                       memset(&(request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION]), 0, sizeof(network_request_table_s));
+                       return 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;
+               }
+
+               g_strlcpy(event_data->ProfileName, request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName,
+                                 NET_PROFILE_NAME_LEN_MAX + 1);
+               memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0, sizeof(network_request_table_s));
+
+               event_data->Event = NET_EVENT_WIFI_TIMEOUT_RSP;
+               event_data->Error = NET_ERR_CONNECTION_CONNECT_FAILED;
+               event_data->Datalength = 0;
+               event_data->Data = NULL;
+
+               network_info->service_state = NET_STATE_TYPE_IDLE;
+
+               if (network_info->event_callback)
+                       network_info->event_callback(event_data, network_info->user_data);
+
+               g_free(event_data);
+       }
+
+       connection_cb_timer = 0;
+
+       return FALSE;
+}
+
 static gboolean __check_full_scan_callback(gpointer data)
 {
        net_event_info_s *event_data = NULL;
index 8098747c0b1149fd70fca8e22117893c11d055b1..9e13e2c0908955bc6fa20b7763deeb1100236402 100644 (file)
@@ -72,6 +72,9 @@ typedef enum {
        NET_EVENT_WIFI_DPP_REMOVED,
        NET_EVENT_WIFI_DPP_EVENT_IND, /* TODO: Make this in detail */
        NET_EVENT_WIFI_ROAM_STATE_IND,
+#if defined TIZEN_DA
+       NET_EVENT_WIFI_TIMEOUT_RSP,
+#endif /* TIZEN_DA */
 } net_event_e;
 
 typedef struct {
index 62b4c69b1bfb947f42c5ba9b56509779736b24d2..df7d21177f4821c4025e3c4e03a70340aa0210ae 100644 (file)
@@ -29,6 +29,9 @@
 #define DBUS_OBJECT_PATH_MAX   150
 
 #if defined TIZEN_DA
+
+extern __thread guint connection_cb_timer;
+
 extern __thread guint full_scan_cb_timer;
 extern __thread guint specific_scan_cb_timer;
 extern __thread guint multi_scan_cb_timer;
@@ -2203,6 +2206,11 @@ int net_wifi_power_off(network_info_s *network_info)
        }
 
 #if defined TIZEN_DA
+       if (connection_cb_timer > 0) {
+               g_source_remove(connection_cb_timer);
+               connection_cb_timer = 0;
+       }
+
        if (full_scan_cb_timer > 0) {
                g_source_remove(full_scan_cb_timer);
                full_scan_cb_timer = 0;
index a1d1630df0075b3f15b40aa231b005760d05b9ef..b66b9e55d9afaae68e6930568ffafe6a84037d82 100644 (file)
@@ -28,6 +28,9 @@
 #define NET_WPS_EI_SECURITY_WEP_PROHIBITED 2
 
 #if defined TIZEN_DA
+
+extern __thread guint connection_cb_timer;
+
 extern __thread guint full_scan_cb_timer;
 extern __thread guint specific_scan_cb_timer;
 extern __thread guint multi_scan_cb_timer;
@@ -641,6 +644,12 @@ static void __net_handle_failure_ind(network_info_s *network_info,
 
        if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
                        strstr(profile_info->ProfileName, svc_name1) != NULL) {
+#if defined TIZEN_DA
+               if (connection_cb_timer > 0) {
+                       g_source_remove(connection_cb_timer);
+                       connection_cb_timer = 0;
+               }
+#endif /* TIZEN_DA */
                memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
                                sizeof(network_request_table_s));
 
@@ -718,6 +727,12 @@ static void __net_handle_disconnect_ind(network_info_s *network_info,
 
        if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
                        strstr(profile_info->ProfileName, svc_name2) != NULL) {
+#if defined TIZEN_DA
+               if (connection_cb_timer > 0) {
+                       g_source_remove(connection_cb_timer);
+                       connection_cb_timer = 0;
+               }
+#endif /* TIZEN_DA */
                memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
                                sizeof(network_request_table_s));
 
@@ -851,6 +866,12 @@ static int __net_handle_service_state_changed(network_info_s *network_info,
 
                        if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
                                        strstr(sig_path, svc_name1) != NULL) {
+#if defined TIZEN_DA
+                               if (connection_cb_timer > 0) {
+                                       g_source_remove(connection_cb_timer);
+                                       connection_cb_timer = 0;
+                               }
+#endif /* TIZEN_DA */
                                memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
                                                sizeof(network_request_table_s));
 
@@ -1430,6 +1451,12 @@ static int __net_handle_wifi_connect_fail_event(network_info_s *network_info,
        WIFI_LOG(WIFI_ERROR, "Failed to connect WiFi");
 
        if (open_info->flag == TRUE) {
+#if defined TIZEN_DA
+               if (connection_cb_timer > 0) {
+                       g_source_remove(connection_cb_timer);
+                       connection_cb_timer = 0;
+               }
+#endif /* TIZEN_DA */
                memset(open_info, 0, sizeof(network_request_table_s));
                event_data->Error = NET_ERR_INVALID_OPERATION;
                event_data->Event = NET_EVENT_OPEN_RSP;
index 7030dd4a70cedb6015da8c126d41bf6f1e755b42..b26399c6cd9fbdcbf8ec1bfecbc273eb775db1d2 100644 (file)
@@ -1535,6 +1535,14 @@ static void _wifi_evt_cb(net_event_info_s *event_cb, void *user_data)
        case NET_EVENT_WIFI_ROAM_STATE_IND:
                __roaming_state_changed_cb(wifi_handle, (net_roam_event_info_s *)event_cb->Data);
                break;
+#if defined TIZEN_DA
+       case NET_EVENT_WIFI_TIMEOUT_RSP:
+               result = __convert_to_ap_error_type(event_cb->Error);
+               WIFI_LOG(WIFI_ERROR, "Connection close error %s", __convert_ap_error_type_to_string(result));
+
+               __connected_cb(wifi_handle, result);
+               break;
+#endif /* TIZEN_DA */
        //LCOV_EXCL_STOP
        default:
                break;