From: Jaehyun Kim Date: Fri, 27 Oct 2017 11:32:29 +0000 (+0900) Subject: Fixed wifi activation failure X-Git-Tag: accepted/tizen/4.0/unified/20171106.074035^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fnet-config.git;a=commitdiff_plain;h=0646b9c79823cb0818cec28e7d67339d4411de9d Fixed wifi activation failure Sometimes wifi is detected late after the wifi driver is loaded. So check the technology state before power on request. Change-Id: I108eb4099e7de454c260e7f47680534af4a7f0c3 Signed-off-by: Jaehyun Kim --- diff --git a/include/wifi-state.h b/include/wifi-state.h index 7e1e453..77e3931 100755 --- a/include/wifi-state.h +++ b/include/wifi-state.h @@ -70,6 +70,7 @@ wifi_service_state_e wifi_state_get_service_state(void); void wifi_state_set_tech_state(wifi_tech_state_e new_state); wifi_tech_state_e wifi_state_get_technology_state(void); +gboolean wifi_state_is_technology_available(void); void wifi_state_set_connected_essid(void); void wifi_state_get_connected_essid(gchar **essid); diff --git a/src/wifi-power.c b/src/wifi-power.c index 4dd968a..81e0eac 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -62,6 +62,9 @@ #define NET_EXEC_PATH "/sbin/ifconfig" #define OS_RANDOM_FILE "/dev/urandom" +#define NETCONFIG_TECH_WAITING_INTERVAL 500 +#define NETCONFIG_TECH_WAITING_COUNT 6 + static gboolean connman_wifi_technology_state = FALSE; static gboolean wifi_firmware_recovery_mode = FALSE; static int airplane_mode = 0; @@ -213,6 +216,41 @@ static int _remove_driver_and_supplicant(void) return 0; } +static gboolean __check_and_set_technology_enable(gpointer data) +{ + static int retry_count = NETCONFIG_TECH_WAITING_COUNT; + gboolean value_enable = TRUE; + gboolean reply = FALSE; + GVariant *param0 = NULL; + GVariant *params = NULL; + char key[] = "Powered"; + + if (wifi_state_is_technology_available() == FALSE) { + retry_count--; + if (retry_count > 0) + return TRUE; + } + + param0 = g_variant_new_boolean(value_enable); + params = g_variant_new("(sv)", key, param0); + + reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE, + CONNMAN_WIFI_TECHNOLOGY_PREFIX, + CONNMAN_TECHNOLOGY_INTERFACE, + "SetProperty", params, __technology_reply); + + if (reply != TRUE) { + ERR("Fail to set technology enable"); + wifi_state_update_power_state(FALSE); + + retry_count = NETCONFIG_TECH_WAITING_COUNT; + return FALSE; + } + + retry_count = NETCONFIG_TECH_WAITING_COUNT; + return FALSE; +} + static int _set_connman_technology_power(gboolean enable) { gboolean reply = FALSE; @@ -225,6 +263,13 @@ static int _set_connman_technology_power(gboolean enable) if (connman_wifi_technology_state == enable) return -EALREADY; + if (enable && wifi_state_is_technology_available() == FALSE) { + netconfig_start_timer(NETCONFIG_TECH_WAITING_INTERVAL, + __check_and_set_technology_enable, NULL, NULL); + connman_wifi_technology_state = enable; + return 0; + } + if (enable == TRUE) param0 = g_variant_new_boolean(value_enable); else diff --git a/src/wifi-state.c b/src/wifi-state.c index 40d0a95..304b091 100755 --- a/src/wifi-state.c +++ b/src/wifi-state.c @@ -711,6 +711,34 @@ wifi_tech_state_e wifi_state_get_technology_state(void) return g_tech_state; } +gboolean wifi_state_is_technology_available(void) +{ + GVariant *message = NULL; + GVariantIter *iter, *next; + const char *path; + gboolean ret = FALSE; + + message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, + CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, + "GetTechnologies", NULL); + if (message == NULL) { + ERR("Failed to get_technology_state"); + return FALSE; + } + + g_variant_get(message, "(a(oa{sv}))", &iter); + while (g_variant_iter_loop(iter, "(oa{sv})", &path, &next)) { + if (path != NULL && g_strcmp0(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == 0) + ret = TRUE; + } + + g_variant_unref(message); + g_variant_iter_free(iter); + + DBG("Wi-Fi technology is %s", ret ? "available" : "unavailable"); + return ret; +} + void wifi_state_set_connected_essid(void) { __set_wifi_connected_essid();