From 12c4d5c3b438d12c6ec60524edb474fb8312c0c6 Mon Sep 17 00:00:00 2001 From: Patrik Flykt Date: Fri, 15 Jun 2012 14:13:48 +0300 Subject: [PATCH] wifi: Reset autoscan timer on a new scan Setting device scanning to false will clean up all networks not seen so far. If a user scan happens to be requested while the emulated background scan is running, the background scan will be cancelled and the non-discovered networks cleared. This causes unnecessary clearing and re-discovery of WiFi networks when the user scan is completed. Create a reset autoscan function that will only reset the autoscan parameters and not set device scanning to false. Call this function when starting a scan. --- plugins/wifi.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/plugins/wifi.c b/plugins/wifi.c index 05b8f5b..7cd5d81 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -203,7 +203,7 @@ static void remove_networks(struct connman_device *device, wifi->networks = NULL; } -static void stop_autoscan(struct connman_device *device) +static void reset_autoscan(struct connman_device *device) { struct wifi_data *wifi = connman_device_get_data(device); struct autoscan_params *autoscan; @@ -223,11 +223,16 @@ static void stop_autoscan(struct connman_device *device) autoscan->timeout = 0; autoscan->interval = 0; - connman_device_set_scanning(device, FALSE); - connman_device_unref(device); } +static void stop_autoscan(struct connman_device *device) +{ + reset_autoscan(device); + + connman_device_set_scanning(device, FALSE); +} + static void wifi_remove(struct connman_device *device) { struct wifi_data *wifi = connman_device_get_data(device); @@ -812,7 +817,7 @@ static int get_latest_connections(int max_ssids, static int wifi_scan(struct connman_device *device) { - stop_autoscan(device); + reset_autoscan(device); return throw_wifi_scan(device, scan_callback); } @@ -829,8 +834,6 @@ static int wifi_scan_fast(struct connman_device *device) if (wifi->tethering == TRUE) return 0; - stop_autoscan(device); - if (connman_device_get_scanning(device) == TRUE) return -EALREADY; @@ -851,6 +854,8 @@ static int wifi_scan_fast(struct connman_device *device) } connman_device_ref(device); + reset_autoscan(device); + ret = g_supplicant_interface_scan(wifi->interface, scan_params, scan_callback, device); if (ret == 0) @@ -886,8 +891,6 @@ static int wifi_scan_hidden(struct connman_device *device, if (ssid == NULL || ssid_len == 0 || ssid_len > 32) return -EINVAL; - stop_autoscan(device); - if (connman_device_get_scanning(device) == TRUE) return -EALREADY; @@ -920,6 +923,9 @@ static int wifi_scan_hidden(struct connman_device *device, wifi->hidden = hidden; connman_device_ref(device); + + reset_autoscan(device); + ret = g_supplicant_interface_scan(wifi->interface, scan_params, scan_callback, device); if (ret == 0) -- 2.7.4