wifi: Reset autoscan timer on a new scan
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 15 Jun 2012 11:13:48 +0000 (14:13 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 18 Jun 2012 07:59:27 +0000 (10:59 +0300)
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

index 05b8f5b..7cd5d81 100644 (file)
@@ -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)