[connman] Notify 'ScanDone' signal with scan-type info. 89/147489/2
authorNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 4 Sep 2017 12:01:38 +0000 (17:31 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Thu, 7 Sep 2017 04:04:35 +0000 (09:34 +0530)
Description: In this patch added below changes-
1. Notify ScanDone signal with scan-type info.
2. If scanning is in-progress at connman return
error 'InProgress' to application.

Change-Id: If8427e185dd0ad811c1d1de72254f073babebbbf
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
src/device.c
src/technology.c

index acd68da..b5855cc 100755 (executable)
@@ -1129,7 +1129,7 @@ int __connman_device_request_specific_scan(enum connman_service_type type,
                }
 
                err = device_specific_scan(type, device, scan_type, specific_scan_list);
-               if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
+               if (err == 0 || err == -EINPROGRESS) {
                        success = true;
                } else {
                        last_err = err;
@@ -1180,7 +1180,15 @@ int __connman_device_request_scan(enum connman_service_type type)
                }
 
                err = device_scan(type, device);
+#if defined TIZEN_EXT
+               /* When Scan is already in progress then return Error so that
+                * wifi-manager can block the scan-done signal to be sent to
+                * application and start requested scan after scan already in progress
+                * is completed then notify to application about the scan event */
+               if (err == 0 || err == -EINPROGRESS) {
+#else
                if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
+#endif
                        success = true;
                } else {
                        last_err = err;
index c1eb3ed..94b99ea 100755 (executable)
@@ -43,6 +43,16 @@ static GHashTable *rfkill_list;
 
 static bool global_offlinemode;
 
+#if defined TIZEN_EXT
+typedef enum {
+       CONNMAN_SCAN_TYPE_FULL_CHANNEL = 0x00,
+       CONNMAN_SCAN_TYPE_SPECIFIC_AP,
+       CONNMAN_SCAN_TYPE_MULTI_AP,
+} connman_scan_type_e;
+
+static connman_scan_type_e g_scan_type = -1;
+#endif
+
 struct connman_rfkill {
        unsigned int index;
        enum connman_service_type type;
@@ -1099,17 +1109,24 @@ void __connman_technology_scan_stopped(struct connman_device *device,
 #if defined TIZEN_EXT
        if (count == 0) {
                DBusMessage *signal;
+               DBusMessageIter iter;
                dbus_bool_t status = 0;
                __connman_technology_notify_scan_changed("scan_done", &status);
 
                signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
-                                                                               CONNMAN_MANAGER_INTERFACE, "ScanDone");
+                               CONNMAN_MANAGER_INTERFACE, "ScanDone");
                if (!signal)
                        return;
 
+               dbus_message_iter_init_append(signal, &iter);
+               connman_dbus_property_append_basic(&iter, "Scantype",
+                               DBUS_TYPE_INT32, &g_scan_type);
+
                dbus_connection_send(connection, signal, NULL);
                dbus_message_unref(signal);
                reply_scan_pending(technology, 0);
+
+               DBG("Successfuly sent ScanDone signal");
        }
 #else
        if (count == 0)
@@ -1169,6 +1186,12 @@ static DBusMessage *scan(DBusConnection *conn, DBusMessage *msg, void *data)
        if (err < 0)
                reply_scan_pending(technology, err);
 
+#if defined TIZEN_EXT
+       if (err == 0) {
+               g_scan_type = CONNMAN_SCAN_TYPE_FULL_CHANNEL;
+               DBG("g_scan_type %d", g_scan_type);
+       }
+#endif
        return NULL;
 }
 
@@ -1240,6 +1263,15 @@ static DBusMessage *specific_scan(DBusConnection *conn, DBusMessage *msg, void *
        if (err < 0)
                reply_scan_pending(technology, err);
 
+       if (err == 0) {
+               guint list_size = g_slist_length(specific_scan_list);
+               if (list_size == 1)
+                       g_scan_type = CONNMAN_SCAN_TYPE_SPECIFIC_AP;
+               else
+                       g_scan_type = CONNMAN_SCAN_TYPE_MULTI_AP;
+               DBG("list_size %u g_scan_type %d", list_size, g_scan_type);
+       }
+
        if (scan_type == 1) {
                g_slist_free_full(specific_scan_list, g_free);
                scan_type = 0;