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 d96d4d79befc9ac64fbae2a436cc8c5d011e1360..328dd0460b8589cc214eccb13bdd78fc0cb4bba4 100644 (file)
@@ -253,6 +253,21 @@ int wifi_manager_config_get_frequency(wifi_manager_config_h config,
 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.
index 3a6880e4d7b21cfe51868a6393731424949fb4b6..b58e540978be7f5fa82227fe1c66ea8c489c31af 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 d31e36a2f06feec3384550dfc22ec6ee8d01e9fc..f3baaec9dbfec83ba0f668c9ff03b94d52468bea 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 a97a400fdd615a32b9b4a4cdf8e02611021aad68..eef0dd9dd09222d40f07bd9a09acfe2403f2a4c8 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 a4adaae4d90d546ed5c1c95bbe583dc821c4745d..93bd8f897c80a8f71d9c45fc75d36730734d87a5 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 d215e40deb9aa8c5e2948fc013dcf0e3a710a5e2..1c4430d3d14163290357c3b13d2ac8081f4f229e 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 cdb26f5050f1212ad5a11146429cbace58a267b6..fbc891ad6017a0dafa4a178d2a47a348c1ab0dcb 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 8e7b302ef422cc3765e57509d9ebab543f5cff96..e107d5d6cf06cb68d7220044188f7eeb79d0488f 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 74567be9954cdb171321776bfe096827e942e7f5..cea5b4dee1916bcc78a1da4ae033fee1fbd3c2c3 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 ff199c7f02e61e00251025598dfc1343f55cd7e1..847304ef112c8b8102013b11162839bb2ed8ca8d 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 1ed40476bb9ff006b6b73c263a82f775fd486e13..bdd4abf1996d33b230e2576363c0acfd09d932e5 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 d84c44d3ee4097c608a2b80cd3a3444e8e0ad6dc..ed4d88c65421363c58d9db71f9de4cc90443e908 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;
        }