Added new CAPI to support autoscan mode (Extension API) 03/118003/2
authorManeesh Jain <maneesh.jain@samsung.com>
Tue, 28 Feb 2017 10:34:44 +0000 (16:04 +0530)
committertaesub kim <taesub.kim@samsung.com>
Wed, 8 Mar 2017 08:38:51 +0000 (17:38 +0900)
1. wifi_manager_set_autoscan()
2. wifi_manager_set_autoscan_mode()
3. wifi_manager_get_autoscan()
4. wifi_manager_get_autoscan_mode()

Change-Id: I37b58c0c7b03e4c086162ff6d0cf54be691a4061
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
include/network_dbus.h
include/network_interface.h
include/network_internal.h
include/wifi-manager.h
include/wifi_internal.h
include/wifi_manager_extension.h [new file with mode: 0755]
src/network_dbus.c
src/network_interface.c
src/wifi_internal.c
src/wifi_manager.c
test/wifi_manager_test.c

index 1807276..c11b001 100755 (executable)
@@ -134,6 +134,12 @@ int _net_dbus_config_load_eap_configurations(const gchar *config_id,
 
 int _net_dbus_device_policy_get_wifi(int *state);
 int _net_dbus_device_policy_get_wifi_profile(int *state);
+int _net_dbus_resume_bgscan(void);
+int _net_dbus_pause_bgscan(void);
+int _net_dbus_get_autoscanmode(unsigned int *autoscanmode);
+int _net_dbus_get_autoscan(gboolean *autoscan);
+
+
 
 #ifdef __cplusplus
 }
index 9e7da3e..3a13463 100755 (executable)
@@ -220,7 +220,6 @@ int net_modify_profile(const char *profile_name, net_profile_info_s *prof_info);
 int net_delete_profile(const char *profile_name);
 
 int net_get_wifi_state(net_wifi_state_e *current_state);
-int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_e scan_mode);
 int net_init_profile_info(net_profile_info_s *ProfInfo);
 int net_specific_scan_wifi(const char *ssid);
 int net_get_wps_pin(char **wps_pin);
@@ -245,6 +244,12 @@ int net_wifi_tdls_connected_peer(char** peer_mac_addr);
 
 int net_get_device_policy_wifi(void);
 int net_get_device_policy_wifi_profile(void);
+int net_wifi_set_autoscan(gboolean autoscan);
+int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_e scan_mode);
+int net_wifi_get_autoscan(gboolean *autoscan);
+int net_wifi_get_autoscanmode(unsigned int *autoscanmode);
+
+
 
 int net_config_get_id_list(GSList **list);
 int net_config_set_field(const gchar *config_id, const gchar *key, const gchar *value);
index 9f77a0a..05dfa40 100755 (executable)
@@ -24,6 +24,7 @@
 #include <glib-object.h>
 
 #include "network_interface.h"
+#include "wifi_manager_extension.h"
 
 #ifdef __cplusplus
 extern "C" {
index 0f49cd9..5e7aa2c 100755 (executable)
@@ -1339,6 +1339,7 @@ int wifi_manager_set_rssi_level_changed_cb(wifi_manager_h wifi,
  */
 int wifi_manager_unset_rssi_level_changed_cb(wifi_manager_h wifi);
 
+
 /**
 * @}
 */
index 5cd7734..208af32 100755 (executable)
@@ -24,6 +24,7 @@
 
 #include "wifi-manager.h"
 #include "network_interface.h"
+#include "wifi_manager_extension.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -226,6 +227,12 @@ int _wifi_save_eap_configurations(const gchar *name, const gchar *passphrase,
                wifi_eap_config_s *eap_config, gboolean is_hidden);
 gchar *_wifi_eap_type_to_string(wifi_manager_eap_type_e eap_type);
 gchar *_wifi_eap_auth_type_to_string(wifi_manager_eap_auth_type_e eap_auth_type);
+int _wifi_set_autoscan(bool autoscan);
+int _wifi_set_background_scan_mode(wifi_manager_autoscan_mode_e mode);
+int _wifi_get_autoscan(bool *autoscan);
+int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode);
+
+
 
 /* WIFI Privilege Check */
 int _wifi_check_get_privilege();
diff --git a/include/wifi_manager_extension.h b/include/wifi_manager_extension.h
new file mode 100755 (executable)
index 0000000..57cade3
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_WIFI_MANAGER_EXTENSION_H__
+#define __TIZEN_WIFI_MANAGER_EXTENSION_H__
+
+#include "wifi-manager.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file wifi_manager_extension.h
+ */
+
+
+/**
+ * @brief Enumeration for the Wi-Fi autoscan mode.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       /**
+        * Auto scan interval is increased exponentially like 4, 8, 16, ...128secs
+        */
+       WIFI_MANAGER_AUTOSCAN_MODE_EXPONENTIAL = 0x00,
+       /**
+        * Auto scan interval is fixed with 10secs(for mobile) / 15secs(for wearable)
+        */
+       WIFI_MANAGER_AUTOSCAN_MODE_PERIODIC
+} wifi_manager_autoscan_mode_e;
+
+/**
+* @}
+*/
+
+/**
+* @addtogroup CAPI_NETWORK_WIFI_MANAGER_MANAGEMENT_MODULE
+* @{
+*/
+
+/**
+ * @brief Enables or disables auto-scanning
+ * @details If auto-scanning is disabled, then background scan and wps scan don't work.
+ * By default, the auto-scanning is enabled automatically until disabling auto-scanning.
+ * Don't forget to enable again when you finish your works with disabled auto-scanning.
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ *            %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ *
+ * @param[in] autoscan   true to enable and false to disable
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                  Successful
+ * @retval #WIFI_ERROR_INVALID_OPERATION     Invalid operation
+ * @retval #WIFI_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #WIFI_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #WIFI_ERROR_PERMISSION_DENIED     Permission Denied
+ * @pre This API needs wifi_initialize() before use.
+ */
+int wifi_manager_set_autoscan(wifi_manager_h wifi, bool autoscan);
+
+/**
+ * @brief Sets the mode of autoscan.
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set
+ *
+ * @param[in] mode       The auto scan mode
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_ERROR_NONE                  Successful
+ * @retval #WIFI_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #WIFI_ERROR_INVALID_OPERATION     Invalid operation
+ * @retval #WIFI_ERROR_PERMISSION_DENIED     Permission Denied
+ * @pre This API needs wifi_initialize() before use.
+ */
+int wifi_manager_set_autoscan_mode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e mode);
+
+/**
+ * @brief Gets the autoscan state.
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi                The wifi handle
+ * @param[out] autoscan   The autoscan state(enable or disable)
+ * @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_OPERATION_FAILED     Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED    Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
+ */
+int wifi_manager_get_autoscan(wifi_manager_h wifi,
+               bool *autoscan);
+
+/**
+ * @brief Gets the autoscan mode.
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi                The wifi handle
+ * @param[out] mode   The mode of autoscan
+ * @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_OPERATION_FAILED     Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED    Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
+ */
+int wifi_manager_get_autoscan_mode(wifi_manager_h wifi,
+               wifi_manager_autoscan_mode_e *mode);
+
+/**
+* @}
+*/
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_WIFI_MANAGER_EXTENSION_H__ */
index be73a97..3c4736e 100755 (executable)
@@ -1205,9 +1205,10 @@ int _net_dbus_connect_service(const net_wifi_connect_service_info_t *wifi_connec
 
                        goto error;
                }
-       } else
+       } else {
                Error = _net_dbus_open_connection(prof_info->ProfileName);
        //LCOV_EXCL_STOP
+       }
 
 error:
        if (NET_ERR_NONE != Error) {
@@ -2405,5 +2406,108 @@ int _net_dbus_device_policy_get_wifi_profile(int *state)
        __NETWORK_FUNC_EXIT__;
        return Error;
 }
+
+int _net_dbus_resume_bgscan(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_e Error = NET_ERR_NONE;
+       GVariant *message = NULL;
+
+       char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
+
+       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, path,
+                       NETCONFIG_WIFI_INTERFACE, "ResumeBgscan", NULL, &Error);
+
+       if (Error != NET_ERR_NONE)
+               WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed");
+
+       if (message != NULL)
+               g_variant_unref(message);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+int _net_dbus_pause_bgscan(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_e Error = NET_ERR_NONE;
+       GVariant *message = NULL;
+
+       char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
+
+       message = _net_invoke_dbus_method(NETCONFIG_SERVICE, path,
+                       NETCONFIG_WIFI_INTERFACE, "PauseBgscan", NULL, &Error);
+
+       if (Error != NET_ERR_NONE)
+               WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed");
+
+       if (message != NULL)
+               g_variant_unref(message);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+int _net_dbus_get_autoscan(gboolean *autoscan)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       GVariant *message = NULL;
+       net_err_e Error = NET_ERR_NONE;
+
+       message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
+                       NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+                       "GetAutoscan", NULL, &Error);
+       if (message == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Failed to Get Passpoint");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       /** Check Reply */
+       int result = 0;
+       g_variant_get(message, "(b)", &result);
+       *autoscan = result;
+
+       WIFI_LOG(WIFI_INFO, "Get Auto scan state Result: %d", result);
+
+       g_variant_unref(message);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+int _net_dbus_get_autoscanmode(unsigned int *autoscanmode)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       GVariant *message = NULL;
+       net_err_e Error = NET_ERR_NONE;
+
+       message = _net_invoke_dbus_method(NETCONFIG_SERVICE,
+                       NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE,
+                       "GetAutoscanmode", NULL, &Error);
+       if (message == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Failed to Get Passpoint");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       /** Check Reply */
+       int result = 0;
+       g_variant_get(message, "(u)", &result);
+       *autoscanmode = result;
+
+       WIFI_LOG(WIFI_INFO, "Get Auto scan Mode Result: %d", result);
+
+       g_variant_unref(message);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
 //LCOV_EXCL_STOP
 
index 895da81..424ed7a 100755 (executable)
@@ -1821,39 +1821,6 @@ int net_get_wifi_state(net_wifi_state_e *current_state)
        __NETWORK_FUNC_EXIT__;
        return Error;
 }
-
-int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_e scan_mode)
-{
-       __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 is powered off!");
-                       __NETWORK_FUNC_EXIT__;
-                       return NET_ERR_INVALID_OPERATION;
-               }
-       }
-
-       if ((Error = _net_dbus_set_bgscan_mode(scan_mode)) != NET_ERR_NONE) {
-               WIFI_LOG(WIFI_ERROR,
-                               "Failed to set bgscan mode. Error [%s]",
-                               _net_print_error(Error));
-
-               __NETWORK_FUNC_EXIT__;
-               return Error;
-       }
-
-       __NETWORK_FUNC_EXIT__;
-       return NET_ERR_NONE;
-}
 //LCOV_EXCL_STOP
 
 int net_check_get_privilege()
@@ -2634,3 +2601,141 @@ int net_config_load_eap_configurations(const gchar *config_id,
 }
 //LCOV_EXCL_STOP
 
+int net_wifi_set_autoscan(gboolean autoscan)
+{
+       __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;
+       }
+
+       WIFI_LOG(WIFI_INFO, "[%s] auto scan", autoscan ? "enable" : "disable");
+
+       if (autoscan)
+               Error = _net_dbus_resume_bgscan();
+       else
+               Error = _net_dbus_pause_bgscan();
+
+       if (Error != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR,
+                               "Failed to enable/disable auto scan Error [%s]",
+                               _net_print_error(Error));
+
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_e scan_mode)
+{
+       __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 is powered off!");
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_INVALID_OPERATION;
+               }
+       }
+
+       if ((Error = _net_dbus_set_bgscan_mode(scan_mode)) != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR,
+                               "Failed to set bgscan mode. Error [%s]",
+                               _net_print_error(Error));
+
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int net_wifi_get_autoscan(gboolean *autoscan)
+{
+       __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 is powered off!");
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_INVALID_OPERATION;
+               }
+       }
+
+       if (_net_dbus_is_pending_call_used() == TRUE) {
+               WIFI_LOG(WIFI_ERROR, "pending call in progress");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       Error = _net_dbus_get_autoscan(autoscan);
+       if (Error != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR,
+                               "_net_dbus_get_autoscan() failed. Error [%s]",
+                               _net_print_error(Error));
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+int net_wifi_get_autoscanmode(unsigned int *autoscanmode)
+{
+       __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 is powered off!");
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_INVALID_OPERATION;
+               }
+       }
+
+       if (_net_dbus_is_pending_call_used() == TRUE) {
+               WIFI_LOG(WIFI_ERROR, "pending call in progress");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       Error = _net_dbus_get_autoscanmode(autoscanmode);
+       if (Error != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR,
+                               "_net_dbus_get_autoscanmode() failed. Error [%s]",
+                               _net_print_error(Error));
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
index 143280c..c4adf82 100755 (executable)
@@ -1874,3 +1874,65 @@ tizen_profile_t _get_tizen_profile()
 
        return profile;
 }
+
+int _wifi_set_autoscan(bool autoscan)
+{
+       int rv = 0;
+
+       rv = net_wifi_set_autoscan(autoscan);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               WIFI_LOG(WIFI_ERROR, "Access denied");
+               return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE)
+               return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_set_background_scan_mode(wifi_manager_autoscan_mode_e mode)
+{
+       int rv = 0;
+
+       rv = net_wifi_set_background_scan_mode(mode);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               WIFI_LOG(WIFI_ERROR, "Access denied");
+               return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE)
+               return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_get_autoscan(bool *autoscan)
+{
+       int rv;
+       gboolean auto_scan = 0;;
+
+       rv = net_wifi_get_autoscan(&auto_scan);
+       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_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       *autoscan =  auto_scan;
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode)
+{
+       int rv;
+
+       rv = net_wifi_get_autoscanmode(autoscanmode);
+       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_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
index ec6ea69..600580c 100755 (executable)
@@ -23,6 +23,7 @@
 #include <glib.h>
 
 #include "wifi_internal.h"
+#include "wifi_manager_extension.h"
 
 #define WIFI_MAC_ADDR_LENGTH   17
 #define WIFI_MAC_ADDR_PATH             "/sys/class/net/wlan0/address"
@@ -656,3 +657,64 @@ EXPORT_API int wifi_manager_unset_rssi_level_changed_cb(wifi_manager_h wifi)
        return __wifi_set_rssi_level_changed_cb(wifi, NULL, NULL);
 }
 
+EXPORT_API int wifi_manager_set_autoscan(wifi_manager_h wifi, bool autoscan)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (!(__wifi_check_handle_validity(wifi))) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       return _wifi_set_autoscan(autoscan);
+}
+
+EXPORT_API int wifi_manager_set_autoscan_mode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e mode)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       int rv;
+
+       if (!(__wifi_check_handle_validity(wifi))) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+
+       if (mode < WIFI_MANAGER_AUTOSCAN_MODE_EXPONENTIAL || mode > WIFI_MANAGER_AUTOSCAN_MODE_PERIODIC) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       rv = _wifi_set_background_scan_mode(mode);
+       if (rv != WIFI_MANAGER_ERROR_NONE)
+               WIFI_LOG(WIFI_ERROR, "Set background scan mode failed");
+
+       return rv;
+}
+
+EXPORT_API int wifi_manager_get_autoscan(wifi_manager_h wifi,
+               bool *autoscan)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (autoscan == NULL || !(__wifi_check_handle_validity(wifi))) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       return _wifi_get_autoscan(autoscan);
+}
+
+EXPORT_API int wifi_manager_get_autoscan_mode(wifi_manager_h wifi,
+               wifi_manager_autoscan_mode_e *mode)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (mode == NULL || !(__wifi_check_handle_validity(wifi))) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       return _wifi_get_autoscanmode(mode);
+}
index c595d68..0d4f6b5 100755 (executable)
@@ -30,6 +30,8 @@
 #include <wifi-manager.h>
 #include <tizen_error.h>
 
+#include "wifi_manager_extension.h"
+
 #define LOG_RED "\033[0;31m"
 #define LOG_GREEN "\033[0;32m"
 #define LOG_BROWN "\033[0;33m"
@@ -1743,6 +1745,95 @@ int test_wifi_manager_connect_hidden_ap(void)
        return 1;
 }
 
+int test_wifi_manager_set_autoscan_state(void)
+{
+       int autoscan = 0;
+       int rv = 0;
+
+       printf("Input enable/disable for autoscan (0:enable, 1:disable) :\n");
+       rv = scanf("%9d", &autoscan);
+
+       if (rv <= 0) {
+               printf("Invalid input!\n");
+               return -1;
+       }
+
+       switch (autoscan) {
+       case 0:
+               rv = wifi_manager_set_autoscan(wifi, true);
+               break;
+
+       case 1:
+               rv = wifi_manager_set_autoscan(wifi, false);
+               break;
+
+       default:
+               printf("Invalid input!\n");
+               return -1;
+       }
+
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("failed to set autoscan [%s]\n", __test_convert_error_to_string(rv));
+               return -1;
+       }
+
+       return 1;
+}
+
+int test_wifi_manager_set_autoscan_mode(void)
+{
+       int mode = 0;
+       int rv = 0;
+
+       printf("Input autoscan mode (0:exponential, 1:periodic) :\n");
+       rv = scanf("%9d", &mode);
+
+       if (rv <= 0) {
+               printf("Invalid input!\n");
+               return -1;
+       }
+
+       rv = wifi_manager_set_autoscan_mode(wifi, mode);
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("failed to set  autoscan mode [%s]\n", __test_convert_error_to_string(rv));
+               return -1;
+       }
+
+       return 1;
+}
+
+int test_wifi_manager_get_autoscan_state(void)
+{
+       int rv = 0;
+       bool autoscan = FALSE;
+
+       rv = wifi_manager_get_autoscan(wifi, &autoscan);
+
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("Fail to get auto scan status [%s]\n", __test_convert_error_to_string(rv));
+               return -1;
+       }
+
+       printf("Auto Scan Status (0:enable, 1:disable) : %d\n", autoscan);
+       return 1;
+}
+
+int test_wifi_manager_get_autoscan_mode(void)
+{
+       int rv = 0;
+       wifi_manager_autoscan_mode_e autoscan_mode;
+
+       rv = wifi_manager_get_autoscan_mode(wifi, &autoscan_mode);
+
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("Fail to get auto scan mode [%s]\n", __test_convert_error_to_string(rv));
+               return -1;
+       }
+
+       printf("Auto Scan Mode (0:exponential, 1:periodic) : %d\n", autoscan_mode);
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -1808,12 +1899,17 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("o   - TDLS TearDown\n");
                printf("p   - TDLS Get Connected Peer\n");
                printf("q   - Connect Hidden AP\n");
+               printf("r   - Set Auto Scan Enable-Disable\n");
+               printf("s   - Set Auto Scan Mode\n");
+               printf("t   - Get Auto Scan Enable-Disable\n");
+               printf("u   - Get Auto Scan Mode\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
 
                printf("ENTER  - Show options menu.......\n");
        }
 
        switch (a[0]) {
+/* Public API */
        case '1':
                rv = test_wifi_manager_init();
                break;
@@ -1892,6 +1988,19 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'q':
                rv = test_wifi_manager_connect_hidden_ap();
                break;
+/* Extension API */
+       case 'r':
+               rv = test_wifi_manager_set_autoscan_state();
+               break;
+       case 's':
+               rv = test_wifi_manager_set_autoscan_mode();
+               break;
+       case 't':
+               rv = test_wifi_manager_get_autoscan_state();
+       break;
+       case 'u':
+               rv = test_wifi_manager_get_autoscan_mode();
+       break;
 
        default:
                break;