From: Maneesh Jain Date: Wed, 29 Jul 2015 11:38:40 +0000 (+0530) Subject: [net-config]: Fix WiFi Activation issue X-Git-Tag: accepted/tizen/mobile/20150731.102653^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F23%2F44923%2F2;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git [net-config]: Fix WiFi Activation issue Description: wpas v2.4 does not start using service file. Due to this reason, wifi was not getting activated. This patch start the wpa supplicant while activating the wifi. Change-Id: I33ac84d5f3956130d31779bc06dc3bb699526e45 Signed-off-by: Maneesh Jain --- diff --git a/packaging/net-config.spec b/packaging/net-config.spec index d033364..e33bfc6 100644 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -1,6 +1,6 @@ Name: net-config Summary: TIZEN Network Configuration Module -Version: 0.1.90_35 +Version: 0.1.90_36 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/wifi-power.c b/src/wifi-power.c index 3818709..fc1abc2 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -42,6 +42,7 @@ #define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh" +#define WLAN_SUPPLICANT_SCRIPT "/usr/sbin/wpa_supp.sh" static gboolean power_in_progress = FALSE; static gboolean fm_waiting = FALSE; @@ -112,6 +113,33 @@ static gboolean __netconfig_wifi_disable_technology(void) return reply; } +static int __netconfig_wifi_supplicant(gboolean enable) +{ + int rv = 0; + const char *path = WLAN_SUPPLICANT_SCRIPT; + char *const args_enable[] = { "/usr/sbin/wpa_supp.sh", "start", NULL }; + char *const args_disable[] = { "/usr/sbin/wpa_supp.sh", "stop", NULL }; + char *const envs[] = { NULL }; + static gboolean enabled = FALSE; + + if (enabled == enable) + return -EALREADY; + + if (enable == TRUE) + rv = netconfig_execute_file(path, args_enable, envs); + else + rv = netconfig_execute_file(path, args_disable, envs); + if (rv < 0) + return -EIO; + + DBG("wpa_supplicant %s", enable == TRUE ? "started" : "stopped"); + + enabled = enable; + + return 0; +} + + static gboolean __netconfig_wifi_load_driver(void) { gboolean rv = FALSE; @@ -129,8 +157,16 @@ static gboolean __netconfig_wifi_load_driver(void) DBG("Failed to load wireless device driver"); return FALSE; } +#else + /*start the Supplicant Daemon*/ + int err = 0; + err = __netconfig_wifi_supplicant(TRUE); + if (err < 0 && err != -EALREADY) + return err; + #endif + DBG("Successfully loaded wireless device driver"); return TRUE; } @@ -152,8 +188,16 @@ gboolean netconfig_wifi_remove_driver(void) DBG("Failed to remove wireless device driver"); return FALSE; } +#else + /*Stop the Supplicant Daemon*/ + int err = 0; + err = __netconfig_wifi_supplicant(FALSE); + if (err < 0 && err != -EALREADY) + return err; + #endif + DBG("Successfully removed wireless device driver"); return TRUE; } @@ -231,6 +275,7 @@ static gboolean __netconfig_wifi_direct_power_off(void) static int __netconfig_wifi_try_to_load_driver(void) { + if (netconfig_is_wifi_allowed() != TRUE) return -EPERM;