Added CAPI to get device scanning status. 29/119929/7
authorNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 20 Mar 2017 14:29:08 +0000 (19:59 +0530)
committertaesub kim <taesub.kim@samsung.com>
Tue, 4 Apr 2017 23:10:08 +0000 (08:10 +0900)
Change-Id: Ia5553a37f4145f88af50744913a158e2ab4fbced
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
include/network_dbus.h
include/network_interface.h
include/wifi-manager.h
include/wifi_internal.h
src/network_dbus.c
src/network_interface.c
src/wifi_internal.c
src/wifi_manager.c
test/wifi_manager_test.c

index c11b001..f2f7474 100755 (executable)
@@ -79,6 +79,7 @@ typedef struct {
 int _net_dbus_open_connection(const char* profile_name);
 int _net_dbus_close_connection(const char* profile_name);
 int _net_dbus_scan_request(void);
+int _net_dbus_get_scan_state(int *state);
 int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_e mode);
 int _net_dbus_set_agent_passphrase_and_connect(
                const char *passphrase, const char *profilename);
index fe3a12d..2e5bf22 100755 (executable)
@@ -230,6 +230,7 @@ int net_get_wps_pin(char **wps_pin);
 int net_wps_scan_wifi(void);
 int net_wifi_get_passpoint(int *enable);
 int net_wifi_set_passpoint(int enable);
+int net_wifi_get_scan_state(int *scan_state);
 
 int net_wifi_cancel_wps(void);
 
index e8c6bef..b7cc2db 100755 (executable)
@@ -33,7 +33,7 @@ extern "C" {
 */
 
 /**
- * @brief The wifi manager handle.
+ * @brief The Wi-Fi manager handle.
  * @since_tizen 3.0
 */
 typedef void *wifi_manager_h;
@@ -780,7 +780,7 @@ typedef bool (*wifi_manager_config_list_cb)(const wifi_manager_config_h config,
  */
 
 /**
- * @brief Called when the WiFi TDLS state is changed.
+ * @brief Called when the Wi-Fi TDLS state is changed.
  * @since_tizen 3.0
  *
  * @param[in] state         The TDLS state
@@ -807,7 +807,7 @@ typedef void(*wifi_manager_tdls_state_changed_cb)(wifi_manager_tdls_state_e stat
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.get
  * @remarks You must release @a handle using wifi_manager_deinitialize().
- * @param[out] wifi        The wifi handle
+ * @param[out] wifi        The Wi-Fi handle
  * @return @c 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
  * @retval #WIFI_MANAGER_ERROR_ALREADY_INITIALIZED  Already initialized
@@ -823,7 +823,7 @@ int wifi_manager_initialize(wifi_manager_h *wifi);
 /**
  * @brief Deinitializes Wi-Fi.
  * @since_tizen 3.0
- * @param[in] wifi        The wifi handle
+ * @param[in] wifi        The Wi-Fi handle
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE               Successful
  * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
@@ -850,7 +850,7 @@ int wifi_manager_deinitialize(wifi_manager_h wifi);
  * @privilege %http://tizen.org/privilege/network.set \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi          The wifi handle
+ * @param[in] wifi          The Wi-Fi handle
  * @param[in] callback      The callback function to be called \n
  *            This can be @c NULL if you don't want to get the notification.
  * @param[in] user_data     The user data passed to the callback function
@@ -875,7 +875,7 @@ int wifi_manager_activate(wifi_manager_h wifi, wifi_manager_activated_cb callbac
  * @privilege %http://tizen.org/privilege/network.set \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi          The wifi handle
+ * @param[in] wifi          The Wi-Fi handle
  * @param[in] callback      The callback function to be called \n
  *            This can be @c NULL if you don't want to get the notification.
  * @param[in] user_data     The user data passed to the callback function
@@ -901,7 +901,7 @@ int wifi_manager_activate_with_wifi_picker_tested(wifi_manager_h wifi,
  * @privilege %http://tizen.org/privilege/network.set \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi          The wifi handle
+ * @param[in] wifi          The Wi-Fi handle
  * @param[in] callback      The callback function to be called \n
  *            This can be @c NULL if you don't want to get the notification.
  * @param[in] user_data     The user data passed to the callback function
@@ -923,7 +923,7 @@ int wifi_manager_deactivate(wifi_manager_h wifi, wifi_manager_deactivated_cb cal
  * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.get
- * @param[in] wifi        The wifi handle
+ * @param[in] wifi        The Wi-Fi handle
  * @param[out] activated  @c true if Wi-Fi is activated,
  *             otherwise @c false if Wi-Fi is not activated.
  * @return 0 on success, otherwise negative error value
@@ -939,7 +939,7 @@ int wifi_manager_is_activated(wifi_manager_h wifi, bool *activated);
  * @brief Gets the local MAC address.
  * @since_tizen 3.0
  * @remarks You must release @a mac_address using free().
- * @param[in] wifi          The wifi handle
+ * @param[in] wifi          The Wi-Fi handle
  * @param[out] mac_address  The MAC address
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
@@ -955,7 +955,7 @@ int wifi_manager_get_mac_address(wifi_manager_h wifi, char **mac_address);
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.get
  * @remarks You must release @a name using free().
- * @param[in] wifi        The wifi handle
+ * @param[in] wifi        The Wi-Fi handle
  * @param[out] name       The name of network interface
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
@@ -974,7 +974,7 @@ int wifi_manager_get_network_interface_name(wifi_manager_h wifi, char **name);
  * @privilege %http://tizen.org/privilege/network.set \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] callback        The callback function to be called
  * @param[in] user_data       The user data passed to the callback function
  * @return 0 on success, otherwise negative error value
@@ -989,13 +989,26 @@ int wifi_manager_get_network_interface_name(wifi_manager_h wifi, char **name);
 int wifi_manager_scan(wifi_manager_h wifi, wifi_manager_scan_finished_cb callback, void *user_data);
 
 /**
+ * @brief Gets the Wi-Fi scan state.
+ * @since_tizen 4.0
+ * @param[in] wifi            The Wi-Fi handle
+ * @param[in] scan_state      The Wi-Fi scan state
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION    Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
+ */
+int wifi_manager_get_scan_state(wifi_manager_h wifi, wifi_manager_scan_state_e *scan_state);
+
+/**
  * @brief Starts specific AP scan, asynchronously.
  * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.set \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] essid           The essid of specific AP
  * @param[in] callback        The callback function to be called
  * @param[in] user_data       The user data passed to the callback function
@@ -1044,7 +1057,7 @@ int wifi_manager_connect_hidden_ap(wifi_manager_h wifi,
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.get
  * @remarks You must release @a handle using wifi_manager_ap_destroy().
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[out] ap             The access point handle
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
@@ -1061,7 +1074,7 @@ int wifi_manager_get_connected_ap(wifi_manager_h wifi, wifi_manager_ap_h *ap);
  * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.get
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] callback        The callback to be called
  * @param[in] user_data       The user data passed to the callback function
  * @return 0 on success, otherwise negative error value
@@ -1079,7 +1092,7 @@ int wifi_manager_foreach_found_ap(wifi_manager_h wifi, wifi_manager_found_ap_cb
  * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.get
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] callback        The callback to be called
  * @param[in] user_data       The user data passed to the callback function
  * @return 0 on success, otherwise negative error value.
@@ -1101,7 +1114,7 @@ int wifi_manager_foreach_found_specific_ap(wifi_manager_h wifi,
  * @privilege %http://tizen.org/privilege/network.set \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] ap              The access point handle
  * @param[in] callback        The callback function to be called \n
  *            This can be @c NULL if you don't want to get the notification.
@@ -1128,7 +1141,7 @@ int wifi_manager_connect(wifi_manager_h wifi, wifi_manager_ap_h ap, wifi_manager
  * @privilege %http://tizen.org/privilege/network.set \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] ap              The access point handle
  * @param[in] callback        The callback function to be called \n
  *            This can be @c NULL if you don't want to get the notification.
@@ -1155,7 +1168,7 @@ int wifi_manager_disconnect(wifi_manager_h wifi, wifi_manager_ap_h ap, wifi_mana
  * @privilege %http://tizen.org/privilege/network.profile \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] ap              The access point handle
  * @param[in] callback        The callback function to be called \n
  *            This can be NULL if you don't want to get the notification.
@@ -1183,7 +1196,7 @@ int wifi_manager_connect_by_wps_pbc(wifi_manager_h wifi,
  * @privilege %http://tizen.org/privilege/network.profile \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] ap              The access point handle
  * @param[in] pin             The WPS PIN is a non-NULL string with length greater than 0 and less than or equal to 8
  * @param[in] callback        The callback function to be called (this can be NULL if you don't want to get the notification)
@@ -1289,7 +1302,7 @@ int wifi_manager_cancel_wps(wifi_manager_h wifi);
  * @privilege %http://tizen.org/privilege/network.profile \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] ap              The access point handle
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
@@ -1310,7 +1323,7 @@ int wifi_manager_forget_ap(wifi_manager_h wifi, wifi_manager_ap_h ap);
  * @privilege %http://tizen.org/privilege/network.profile \n
  *            %http://tizen.org/privilege/network.get
  * @remark This API needs both privileges.
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] ap              The access point handle
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
@@ -1335,7 +1348,7 @@ int wifi_manager_update_ap(wifi_manager_h wifi, wifi_manager_ap_h ap);
  * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.get
- * @param[in] wifi                The wifi handle
+ * @param[in] wifi                The Wi-Fi handle
  * @param[out] connection_state   The connection state
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
@@ -1350,7 +1363,7 @@ int wifi_manager_get_connection_state(wifi_manager_h wifi,
 /**
  * @brief Registers the callback called when the device state is changed.
  * @since_tizen 3.0
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] callback        The callback function to be called
  * @param[in] user_data       The user data passed to the callback function
  * @return 0 on success, otherwise negative error value
@@ -1365,7 +1378,7 @@ int wifi_manager_set_device_state_changed_cb(wifi_manager_h wifi,
 /**
  * @brief Unregisters the callback called when the device state is changed.
  * @since_tizen 3.0
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
  * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
@@ -1377,7 +1390,7 @@ int wifi_manager_unset_device_state_changed_cb(wifi_manager_h wifi);
 /**
  * @brief Registers the callback called when the background scan is finished.
  * @since_tizen 3.0
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] callback        The callback function to be called
  * @param[in] user_data       The user data passed to the callback function
  * @return 0 on success, otherwise negative error value
@@ -1392,7 +1405,7 @@ int wifi_manager_set_background_scan_cb(wifi_manager_h wifi,
 /**
  * @brief Unregisters the callback called when the scan is finished.
  * @since_tizen 3.0
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
  * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
@@ -1431,7 +1444,7 @@ int wifi_manager_unset_scan_state_changed_cb(wifi_manager_h wifi);
 /**
  * @brief Registers the callback called when the connection state is changed.
  * @since_tizen 3.0
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] callback        The callback function to be called
  * @param[in] user_data       The user data passed to the callback function
  * @return 0 on success, otherwise negative error value
@@ -1446,7 +1459,7 @@ int wifi_manager_set_connection_state_changed_cb(wifi_manager_h wifi,
 /**
  * @brief Unregisters the callback called when the connection state is changed.
  * @since_tizen 3.0
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
  * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
@@ -1458,7 +1471,7 @@ int wifi_manager_unset_connection_state_changed_cb(wifi_manager_h wifi);
 /**
  * @brief Registers callback called when the RSSI of connected Wi-Fi is changed.
  * @since_tizen 3.0
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] callback        The callback function to be called
  * @param[in] user_data       The user data passed to the callback function
  * @return 0 on success, otherwise negative error value
@@ -1473,7 +1486,7 @@ int wifi_manager_set_rssi_level_changed_cb(wifi_manager_h wifi,
 /**
  * @brief Unregisters callback called when the RSSI of connected Wi-Fi is changed.
  * @since_tizen 3.0
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @return 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
  * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
@@ -1497,7 +1510,7 @@ int wifi_manager_unset_rssi_level_changed_cb(wifi_manager_h wifi);
  * @brief Creates the access point handle.
  * @since_tizen 3.0
  * @remarks You must release @a AP using wifi_manager_ap_destroy().
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] essid           The ESSID (Extended Service Set Identifier) should be null-terminated and can be UTF-8 encoded
  * @param[out] ap             The access point handle
  * @return 0 on success, otherwise negative error value
@@ -1514,7 +1527,7 @@ int wifi_manager_ap_create(wifi_manager_h wifi, const char *essid, wifi_manager_
  * @brief Creates the hidden access point handle.
  * @since_tizen 3.0
  * @remarks You must release @a AP using wifi_manager_ap_destroy().
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] essid           The ESSID (Extended Service Set Identifier) should be null-terminated and can be UTF-8 encoded
  * @param[out] ap             The access point handle
  * @return 0 on success, otherwise negative error value
@@ -2360,7 +2373,7 @@ int wifi_manager_ap_set_prefix_length(wifi_manager_ap_h ap,
  * @since_tizen 3.0
  * @remarks You must release @a config using wifi_manager_config_destroy().
  *
- * @param[in] wifi              The wifi handle
+ * @param[in] wifi              The Wi-Fi handle
  * @param[in] name              The access point name
  * @param[in] passphrase        The access point passphrase
  * @param[in] security_type     The access point security type
@@ -2420,7 +2433,7 @@ int wifi_manager_config_destroy(wifi_manager_config_h config);
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.profile
  *
- * @param[in] wifi              The wifi handle
+ * @param[in] wifi              The Wi-Fi handle
  * @param[in] config            The access point configuration handle
  *
  * @return 0 on success, otherwise negative error value
@@ -2439,7 +2452,7 @@ int wifi_manager_config_save(wifi_manager_h wifi, wifi_manager_config_h config);
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.profile
  *
- * @param[in] wifi              The wifi handle
+ * @param[in] wifi              The Wi-Fi handle
  * @param[in] config            The access point configuration handle
  *
  * @return 0 on success, otherwise negative error value
@@ -2459,7 +2472,7 @@ int wifi_manager_config_remove(wifi_manager_h wifi, wifi_manager_config_h config
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.profile
  *
- * @param[in] wifi              The wifi handle
+ * @param[in] wifi              The Wi-Fi handle
  * @param[in] callback          The callback to be called
  * @param[in] user_data         The user data passed to the callback function
  *
@@ -2812,7 +2825,7 @@ int wifi_manager_config_set_eap_subject_match(wifi_manager_config_h config,
  * @privlevel public
  * @privilege %http://tizen.org/privilege/network.set
  *
- * @param[in] wifi                The wifi handle
+ * @param[in] wifi                The Wi-Fi handle
  * @param[in] peer_mac_addr       The MAC address of the connected peer
  *
  * @return @c 0 on success, otherwise negative error value
@@ -2832,7 +2845,7 @@ int wifi_manager_tdls_disconnect(wifi_manager_h wifi, const char *peer_mac_addr)
  * @privilege %http://tizen.org/privilege/network.get
  *
  * @remarks The @a peer_mac_addr should be freed using free().
- * @param[in] wifi                The wifi handle
+ * @param[in] wifi                The Wi-Fi handle
  * @param[out] peer_mac_addr      The MAC address of the connected peer
  *
  * @return @c 0 on success, otherwise negative error value
@@ -2850,7 +2863,7 @@ int wifi_manager_tdls_get_connected_peer(wifi_manager_h wifi, char **peer_mac_ad
  * @brief Registers the callback called when TDLS state is changed.
  * @since_tizen 3.0
  *
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @param[in] callback        The callback function to be called
  * @param[in] user_data       The user data passed to the callback function
  *
@@ -2867,7 +2880,7 @@ int wifi_manager_tdls_set_state_changed_cb(wifi_manager_h wifi,
  * @brief Unregisters the callback called when TDLS state is changed.
  * @since_tizen 3.0
  *
- * @param[in] wifi            The wifi handle
+ * @param[in] wifi            The Wi-Fi handle
  * @return @c 0 on success, otherwise negative error value
  * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
  * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
index a59fc12..0870c87 100755 (executable)
@@ -189,6 +189,7 @@ int _wifi_scan_request(wifi_manager_h wifi,
                wifi_manager_scan_finished_cb callback, void *user_data);
 int _wifi_scan_specific_ap(wifi_manager_h wifi, const char *essid,
                wifi_manager_scan_finished_cb callback, void *user_data);
+int _wifi_get_scan_state(wifi_manager_scan_state_e *scan_state);
 int _wifi_get_hidden_aps(wifi_manager_h wifi, const char* essid,
                wifi_manager_security_type_e sec_type, const char *passphrase,
                wifi_manager_connected_cb callback, void* user_data);
index d7f390d..9cd3865 100755 (executable)
@@ -772,6 +772,44 @@ int _net_dbus_scan_request(void)
        return Error;
 }
 
+int _net_dbus_get_scan_state(int *scanstate)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_e Error = NET_ERR_NONE;
+       GVariant *message = NULL;
+       GVariant *value = NULL;
+       GVariantIter *iter;
+       gchar *key;
+       const char *method = "GetScanState";
+
+       message = _net_invoke_dbus_method(
+                       CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+                       CONNMAN_TECHNOLOGY_INTERFACE, method, NULL, &Error);
+
+       if (message == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get scan state\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       g_variant_get(message, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+               if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
+                       if (g_strcmp0(key, "Scanstate") == 0)
+                               *scanstate = g_variant_get_boolean(value);
+               }
+       }
+
+       g_variant_iter_free(iter);
+       g_variant_unref(message);
+
+       WIFI_LOG(WIFI_INFO, "scan state: %d\n", *scanstate);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
 int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_e mode)
 {
        __NETWORK_FUNC_ENTER__;
index a3fc404..d558cf7 100755 (executable)
@@ -1778,6 +1778,46 @@ int net_scan_wifi(void)
        return NET_ERR_NONE;
 }
 
+int net_wifi_get_scan_state(int *scanstate)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_e Error = NET_ERR_NONE;
+
+       if (NetworkInfo.ref_count < 1) {
+               WIFI_LOG(WIFI_ERROR, "Application is not registered");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (NetworkInfo.wifi_state == WIFI_OFF) {
+               if ((NetworkInfo.wifi_state = _net_get_wifi_state(&Error)) == WIFI_OFF) {
+                       WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!");
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_INVALID_OPERATION;
+               }
+       }
+
+       if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+               WIFI_LOG(WIFI_ERROR, "Request in progress");
+               *scanstate = 1;
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NONE;
+       }
+
+       Error = _net_dbus_get_scan_state(scanstate);
+       if (Error != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get scan state. Error [%s]",
+                               _net_print_error(Error));
+
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
 //LCOV_EXCL_START
 int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_s *wps_info)
 {
index 7aab542..f77570f 100755 (executable)
@@ -1203,6 +1203,26 @@ int _wifi_scan_request(wifi_manager_h wifi,
        return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
 }
 
+int _wifi_get_scan_state(wifi_manager_scan_state_e *scan_state)
+{
+       int rv;
+       int state = 0;
+
+       rv = net_wifi_get_scan_state(&state);
+
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+       } else if (rv == NET_ERR_INVALID_OPERATION) {
+               return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+       } else if (rv == NET_ERR_NONE) {
+               *scan_state = state;
+               return WIFI_MANAGER_ERROR_NONE;
+       }
+
+       return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+}
+
 int _wifi_scan_specific_ap(wifi_manager_h wifi, const char *essid,
                                                        wifi_manager_scan_finished_cb callback, void *user_data)
 {
index f0d5a9a..e70a18b 100755 (executable)
@@ -357,6 +357,27 @@ EXPORT_API int wifi_manager_scan(wifi_manager_h wifi,
        return rv;
 }
 
+EXPORT_API int wifi_manager_get_scan_state(wifi_manager_h wifi,
+                       wifi_manager_scan_state_e *scan_state)
+{
+       int rv;
+
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (!(__wifi_check_handle_validity(wifi)) || scan_state == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       rv = _wifi_get_scan_state(scan_state);
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi scan state"); //LCOV_EXCL_LINE
+               return rv;
+       }
+
+       return rv;
+}
+
 EXPORT_API int wifi_manager_scan_specific_ap(wifi_manager_h wifi,
                const char* essid, wifi_manager_scan_finished_cb callback, void *user_data)
 {
index 88e652a..aa35e4f 100755 (executable)
@@ -2013,6 +2013,23 @@ int test_wifi_manager_get_autoscan_mode(void)
        return 1;
 }
 
+int test_wifi_manager_get_scan_state(void)
+{
+       int rv = 0;
+       wifi_manager_scan_state_e scan_state = -1;
+
+       rv = wifi_manager_get_scan_state(wifi, &scan_state);
+
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("Failed to get scan state [%s]\n", __test_convert_error_to_string(rv));
+               return -1;
+       }
+
+       printf("Scan state [%d]\n", scan_state);
+
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -2087,6 +2104,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("v   - Set Auto Scan Mode\n");
                printf("w   - Get Auto Scan Enable-Disable\n");
                printf("x   - Get Auto Scan Mode\n");
+               printf("y   - Get wifi scanning status\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
 
                printf("ENTER  - Show options menu.......\n");
@@ -2194,6 +2212,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'x':
                rv = test_wifi_manager_get_autoscan_mode();
                break;
+       case 'y':
+               rv = test_wifi_manager_get_scan_state();
+               break;
        default:
                break;
        }