From 7ab66353f97478e11a9179cea237a429273b3071 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Fri, 11 Oct 2019 17:26:34 +0900 Subject: Try to auto-connect with favorite service before full channel scan Change-Id: Ia8027c0acf87c3bf2268fa0fc81fa15f8994241c Signed-off-by: hyunuk.tak --- plugins/wifi.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) mode change 100644 => 100755 plugins/wifi.c (limited to 'plugins') diff --git a/plugins/wifi.c b/plugins/wifi.c old mode 100644 new mode 100755 index 322cfa0a..911232ce --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -2091,6 +2091,12 @@ static void scan_callback(int result, GSupplicantInterface *interface, struct connman_device *device = user_data; struct wifi_data *wifi = connman_device_get_data(device); bool scanning; +#if defined TIZEN_EXT + GSList *list = NULL; + bool favorite_exists = false; + struct connman_network *network = NULL; + struct connman_service *service = NULL; +#endif DBG("result %d wifi %p", result, wifi); @@ -2138,18 +2144,35 @@ static void scan_callback(int result, GSupplicantInterface *interface, } #if defined TIZEN_EXT - if (wifi && wifi->allow_full_scan) { - int ret; - DBG("Trigger Full Channel Scan"); - wifi->allow_full_scan = FALSE; + if (wifi) { + for (list = wifi->networks; list; list = list->next) { + network = list->data; + service = connman_service_lookup_from_network(network); + + if (service != NULL && + (connman_service_get_favorite(service) == true) && + (connman_service_get_autoconnect(service) == true)) { + DBG("Favorite service exists [%s]", connman_network_get_string(network, "Name")); + favorite_exists = true; + break; + } + } + } - ret = g_supplicant_interface_scan(wifi->interface, NULL, - scan_callback_hidden, device); - if (ret == 0) - return; + if (favorite_exists == false) { + if (wifi && wifi->allow_full_scan) { + int ret; + DBG("Trigger full channel scan"); + wifi->allow_full_scan = false; - /* On error, let's recall scan_callback, which will cleanup */ - return scan_callback(ret, interface, user_data); + ret = g_supplicant_interface_scan(wifi->interface, NULL, + scan_callback_hidden, device); + if (ret == 0) + return; + + /* On error, let's recall scan_callback, which will cleanup */ + return scan_callback(ret, interface, user_data); + } } #endif -- cgit v1.2.3