Add an API for removing all AP configurations 01/286501/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Mon, 9 Jan 2023 05:22:25 +0000 (14:22 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 9 Jan 2023 05:22:25 +0000 (14:22 +0900)
Change-Id: I1b302c60b37dfb968d7fbaea70be5e71b9047614
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
12 files changed:
include/wifi-manager-extension.h
packaging/capi-network-wifi-manager.spec
src/network_dbus.c
src/network_dbus.h
src/network_interface.c
src/network_interface.h
src/wifi_config.c
src/wifi_internal.c
src/wifi_internal.h
tools/manager-test/wman_test_extension.c
tools/manager-test/wman_test_extension.h
tools/manager-test/wman_test_main.c

index d96d4d7..328dd04 100644 (file)
@@ -254,6 +254,21 @@ int wifi_manager_config_set_frequency(wifi_manager_config_h config,
                int frequency);
 
 /**
+ * @brief Reset all WiFi configurations
+ * @since_tizen 7.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile
+ * @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
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION    Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
+ */
+int wifi_manager_config_reset_configurations(wifi_manager_h wifi);
+
+/**
  * @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.
index 3a6880e..b58e540 100644 (file)
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi-manager
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.3.21
+Version:       1.3.22
 Release:       0
 Group:         System/Network
 License:       Apache-2.0
index d31e36a..f3baaec 100644 (file)
@@ -4980,4 +4980,27 @@ int _net_dbus_set_power_save_mode(network_info_s *network_info, net_wifi_power_s
        return Error;
 }
 #endif /* TIZEN_DA */
+
+int _net_dbus_reset_wifi_config(network_info_s *network_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_e Error = NET_ERR_NONE;
+       GVariant *message = NULL;
+
+       message = _net_invoke_dbus_method(network_info, NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+                       NETCONFIG_WIFI_INTERFACE, "ResetWifiConfig", NULL, &Error);
+
+       if (message == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Failed to reset wifi config");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       g_variant_unref(message);
+       WIFI_LOG(WIFI_INFO, "Successfully reset wifi config");
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
 //LCOV_EXCL_STOP
index a97a400..eef0dd9 100644 (file)
@@ -243,6 +243,7 @@ int _net_dbus_set_power_save_state(network_info_s *network_info, net_wifi_power_
 int _net_dbus_get_power_save_mode(network_info_s *network_info, unsigned int *ps_mode);
 int _net_dbus_set_power_save_mode(network_info_s *network_info, net_wifi_power_save_mode_e ps_mode);
 #endif /* TIZEN_DA */
+int _net_dbus_reset_wifi_config(network_info_s *network_info);
 
 #ifdef __cplusplus
 }
index a4adaae..93bd8f8 100644 (file)
@@ -4260,4 +4260,22 @@ int net_wifi_set_power_save_mode(network_info_s *network_info, net_wifi_power_sa
        return Error;
 }
 #endif /* TIZEN_DA */
+
+int net_wifi_reset_wifi_config(network_info_s *network_info)
+{
+       __NETWORK_CAPI_FUNC_ENTER__;
+
+       net_err_e Error = NET_ERR_NONE;
+
+       Error = _net_dbus_reset_wifi_config(network_info);
+       if (Error != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to reset wifi config. Error [%s]",
+                               _net_print_error(Error));
+               __NETWORK_CAPI_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_CAPI_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
 //LCOV_EXCL_STOP
index d215e40..1c4430d 100644 (file)
@@ -422,6 +422,7 @@ int net_wifi_set_power_save_state(network_info_s *network_info, net_wifi_power_s
 int net_wifi_get_power_save_mode(network_info_s *network_info, unsigned int *ps_mode);
 int net_wifi_set_power_save_mode(network_info_s *network_info, net_wifi_power_save_mode_e ps_mode);
 #endif /* TIZEN_DA */
+int net_wifi_reset_wifi_config(network_info_s *network_info);
 
 /**
  * \}
index cdb26f5..fbc891a 100644 (file)
@@ -915,6 +915,25 @@ EXPORT_API int wifi_manager_config_set_frequency(wifi_manager_config_h config,
        __NETWORK_CAPI_FUNC_EXIT__;
        return WIFI_MANAGER_ERROR_NONE;
 }
+
+EXPORT_API int wifi_manager_config_reset_configurations(wifi_manager_h wifi)
+{
+       __NETWORK_CAPI_FUNC_ENTER__;
+
+       int rv;
+
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+
+       rv = _wifi_reset_wifi_config(wifi);
+       if (rv != WIFI_MANAGER_ERROR_NONE)
+               WIFI_LOG(WIFI_ERROR, "Filed to reset wifi configurations. rv[%d]\n", rv);
+
+       __NETWORK_CAPI_FUNC_EXIT__;
+       return rv;
+
+}
 //LCOV_EXCL_STOP
 
 EXPORT_API int wifi_manager_config_get_eap_anonymous_identity(wifi_manager_config_h config,
index 8e7b302..e107d5d 100644 (file)
@@ -4341,4 +4341,32 @@ int _wifi_set_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_
        return WIFI_MANAGER_ERROR_NONE;
 }
 #endif /* TIZEN_DA */
+
+int _wifi_reset_wifi_config(wifi_manager_h wifi)
+{
+       net_tech_info_s tech_info;
+       int rv = NET_ERR_NONE;
+       wifi_manager_handle_s *wifi_handle = wifi;
+
+       rv = net_get_technology_properties(wifi_handle->network_info, &tech_info);
+       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 technology properties"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       if (!tech_info.powered)
+               rv = net_wifi_reset_wifi_config(wifi_handle->network_info);
+       else
+               rv = WIFI_MANAGER_ERROR_OPERATION_FAILED;
+
+       if (rv != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to reset wifi config");
+               return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+       }
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
 //LCOV_EXCL_STOP
index 74567be..cea5b4d 100644 (file)
@@ -611,6 +611,7 @@ int _wifi_set_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_stat
 int _wifi_get_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e *ps_mode);
 int _wifi_set_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e ps_mode);
 #endif /* TIZEN_DA */
+int _wifi_reset_wifi_config(wifi_manager_h wifi);
 
 #ifdef __cplusplus
 }
index ff199c7..847304e 100644 (file)
@@ -333,6 +333,21 @@ int wman_test_get_ap_auto_connect(wifi_manager_h wifi)
        return 1;
 }
 
+int wman_test_reset_wifi_configurations(wifi_manager_h wifi)
+{
+       int rv;
+
+       rv = wifi_manager_config_reset_configurations(wifi);
+
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("Fail to reset Wi-Fi configurations rv = %d\n", rv);
+               return -1;
+       }
+
+       printf("Request to reset Wi-Fi configurations\n");
+       return 1;
+}
+
 int wman_test_set_ip_conflict_period(wifi_manager_h wifi)
 {
        int rv = 0;
index 1ed4047..bdd4abf 100644 (file)
@@ -28,6 +28,7 @@ int wman_test_set_auto_connect(wifi_manager_h wifi);
 int wman_test_get_auto_connect(wifi_manager_h wifi);
 int wman_test_set_ap_auto_connect(wifi_manager_h wifi);
 int wman_test_get_ap_auto_connect(wifi_manager_h wifi);
+int wman_test_reset_wifi_configurations(wifi_manager_h wifi);
 int wman_test_set_ip_conflict_period(wifi_manager_h wifi);
 int wman_test_get_ip_conflict_period(wifi_manager_h wifi);
 int wman_test_netlink_scan(wifi_manager_h wifi);
index d84c44d..ed4d88c 100644 (file)
@@ -339,6 +339,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
 #endif /* TIZEN_DA */
                printf("[   - Get Interval of Auto Scan\n");
                printf("]   - Set Interval of Auto Scan\n");
+               printf(";   - Remove All Wi-Fi configurations\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
 
                printf("ENTER  - Show options menu.......\n");
@@ -572,6 +573,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case ']':
                rv = wman_test_set_autoscan_interval(wifi);
                break;
+       case ';':
+               rv = wman_test_reset_wifi_configurations(wifi);
+               break;
        default:
                break;
        }