From c4e305f1ba84e9898da0ae75d10912f2637fe36e Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Fri, 28 Oct 2022 18:00:09 +0900 Subject: [PATCH 01/16] DA: Add get/set power-save state/mode APIs Change-Id: I02dc25fd89bd4ebdfa23de3ea41dca4256307a74 Signed-off-by: Jaehyun Kim --- include/wifi-manager-extension.h | 101 +++++++++++++++++++ src/network_dbus.c | 164 +++++++++++++++++++++++++++++++ src/network_dbus.h | 8 ++ src/network_interface.c | 98 ++++++++++++++++++ src/network_interface.h | 19 ++++ src/wifi_internal.c | 87 ++++++++++++++++ src/wifi_internal.h | 8 ++ src/wifi_manager.c | 98 ++++++++++++++++++ tools/manager-test/wman_test_extension.c | 90 +++++++++++++++++ tools/manager-test/wman_test_extension.h | 6 ++ tools/manager-test/wman_test_main.c | 20 ++++ 11 files changed, 699 insertions(+) diff --git a/include/wifi-manager-extension.h b/include/wifi-manager-extension.h index c927f83..7816134 100644 --- a/include/wifi-manager-extension.h +++ b/include/wifi-manager-extension.h @@ -88,6 +88,25 @@ typedef enum { WIFI_MANAGER_DHCP_STATE_FAILED = -1, /* DHCP Fail */ WIFI_MANAGER_DHCP_STATE_SUCCESS = 0, /* DHCP Success */ } wifi_manager_dhcp_state_e; + +/** + * @brief Enumeration for the Wi-Fi Power-save State. + * @since_tizen 7.5 + */ +typedef enum { + WIFI_MANAGER_PS_OFF = 0x00, + WIFI_MANAGER_PS_ON, +} wifi_manager_power_save_state_e; + +/** + * @brief Enumeration for the Wi-Fi Power-save Mode. + * @since_tizen 7.5 + */ +typedef enum { + WIFI_MANAGER_PS_MODE_DEFAULT_OFF = 0x00, + WIFI_MANAGER_PS_MODE_DEFAULT_ON, + WIFI_MANAGER_PS_MODE_DYNAMIC, +} wifi_manager_power_save_mode_e; #endif /* TIZEN_DA */ /** @@ -856,6 +875,88 @@ int wifi_manager_dhcp_set_event_cb(wifi_manager_h wifi, wifi_manager_dhcp_event_ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported */ int wifi_manager_dhcp_unset_event_cb(wifi_manager_h wifi); + +/** + * @brief Gets power-save state. + * @since_tizen 7.5 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * + * @param[in] wifi The Wi-Fi handle + * @param[out] ps_state @c WIFI_MANAGER_PS_OFF if power-save state is disabled + * @c WIFI_MANAGER_PS_ON if power-save state is enabled + * + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @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_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e *ps_state); + +/** + * @brief Sets power-save state. + * @since_tizen 7.5 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set + * + * @param[in] wifi The Wi-Fi handle + * @param[in] ps_state @c WIFI_MANAGER_PS_OFF to disable power-save + * @c WIFI_MANAGER_PS_ON to enable power-save + * + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @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_set_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e ps_state); + +/** + * @brief Gets power-save mode. + * @since_tizen 7.5 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * + * @param[in] wifi The Wi-Fi handle + * @param[out] ps_mode @c WIFI_MANAGER_PS_MODE_DEFAULT_OFF if power-save mode is default-off + * @c WIFI_MANAGER_PS_MODE_DEFAULT_ON if power-save mode is default-on + * @c WIFI_MANAGER_PS_MODE_DYNAMIC if power-save mode is dynamic + * + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @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_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e *ps_mode); + +/** + * @brief Sets power-save mode. + * @since_tizen 7.5 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set + * + * @param[in] wifi The Wi-Fi handle + * @param[in] ps_mode @c WIFI_MANAGER_PS_MODE_DEFAULT_OFF set power-save mode to default-off + * @c WIFI_MANAGER_PS_MODE_DEFAULT_ON set power-save mode to default-on + * @c WIFI_MANAGER_PS_MODE_DYNAMIC set power-save mode to dynamic + * + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @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_set_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e ps_mode); #endif /* TIZEN_DA */ /** diff --git a/src/network_dbus.c b/src/network_dbus.c index 4e60c18..129a834 100644 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -1054,6 +1054,64 @@ static void __net_set_passpoint_reply(GObject *source_object, GAsyncResult *res, __NETWORK_FUNC_EXIT__; } +//LCOV_EXCL_START +#if defined TIZEN_DA +static void __net_set_power_save_state_reply(GObject *source_object, GAsyncResult *res, gpointer user_data) +{ + __NETWORK_FUNC_ENTER__; + + GDBusConnection *conn = NULL; + GError *error = NULL; + net_err_e Error = NET_ERR_NONE; + GVariant *reply; + + conn = G_DBUS_CONNECTION(source_object); + reply = g_dbus_connection_call_finish(conn, res, &error); + if (error != NULL) { + Error = __net_netconfig_error_string_to_enum(error->message); + g_error_free(error); + } + + if (reply) + g_variant_unref(reply); + + if (Error != NET_ERR_NONE) + WIFI_LOG(WIFI_ERROR, "set power-save state failed[%d]", Error); + else + WIFI_LOG(WIFI_INFO, "set power-save state succeeded"); + + __NETWORK_FUNC_EXIT__; +} + +static void __net_set_power_save_mode_reply(GObject *source_object, GAsyncResult *res, gpointer user_data) +{ + __NETWORK_FUNC_ENTER__; + + GDBusConnection *conn = NULL; + GError *error = NULL; + net_err_e Error = NET_ERR_NONE; + GVariant *reply; + + conn = G_DBUS_CONNECTION(source_object); + reply = g_dbus_connection_call_finish(conn, res, &error); + if (error != NULL) { + Error = __net_netconfig_error_string_to_enum(error->message); + g_error_free(error); + } + + if (reply) + g_variant_unref(reply); + + if (Error != NET_ERR_NONE) + WIFI_LOG(WIFI_ERROR, "set power-save mode failed[%d]", Error); + else + WIFI_LOG(WIFI_INFO, "set power-save mode succeeded"); + + __NETWORK_FUNC_EXIT__; +} +#endif /* TIZEN_DA */ +//LCOV_EXCL_STOP + static char *__net_make_group_name(unsigned char *raw_ssid, int raw_ssid_len, const char *net_mode, const char *sec) { @@ -4751,3 +4809,109 @@ int _net_dbus_get_vconf_value(network_info_s *network_info, __NETWORK_FUNC_EXIT__; return ret_error; } + +//LCOV_EXCL_START +#if defined TIZEN_DA +int _net_dbus_get_power_save_state(network_info_s *network_info, unsigned int *ps_state) +{ + __NETWORK_FUNC_ENTER__; + + GVariant *params = NULL; + GVariant *message = NULL; + net_err_e Error = NET_ERR_NONE; + + params = g_variant_new("(s)", network_info->interface_name); + + message = _net_invoke_dbus_method(network_info, + NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, "GetPowerSaveState", + params, &Error); + + if (message == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to get power-save state"); + __NETWORK_FUNC_EXIT__; + return Error; + } + + g_variant_get(message, "(u)", ps_state); + + WIFI_LOG(WIFI_INFO, "Get Power-Save state : %d", *ps_state); + + if (message != NULL) + g_variant_unref(message); + + __NETWORK_FUNC_EXIT__; + return Error; +} + +int _net_dbus_set_power_save_state(network_info_s *network_info, net_wifi_power_save_state_e ps_state) +{ + __NETWORK_FUNC_ENTER__; + + GVariant *params = NULL; + net_err_e Error = NET_ERR_NONE; + + params = g_variant_new("(su)", network_info->interface_name, ps_state); + + Error = _net_invoke_dbus_method_nonblock(network_info, + NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, "SetPowerSaveState", + params, DBUS_REPLY_TIMEOUT, + __net_set_power_save_state_reply); + + __NETWORK_FUNC_EXIT__; + return Error; +} + +int _net_dbus_get_power_save_mode(network_info_s *network_info, unsigned int *ps_mode) +{ + __NETWORK_FUNC_ENTER__; + + GVariant *params = NULL; + GVariant *message = NULL; + net_err_e Error = NET_ERR_NONE; + + params = g_variant_new("(s)", network_info->interface_name); + + message = _net_invoke_dbus_method(network_info, + NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, "GetPowerSaveMode", + params, &Error); + + if (message == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to get power-save mode"); + __NETWORK_FUNC_EXIT__; + return Error; + } + + g_variant_get(message, "(u)", ps_mode); + + WIFI_LOG(WIFI_INFO, "Get Power-Save mode : %d", *ps_mode); + + if (message != NULL) + g_variant_unref(message); + + __NETWORK_FUNC_EXIT__; + return Error; +} + +int _net_dbus_set_power_save_mode(network_info_s *network_info, net_wifi_power_save_mode_e ps_mode) +{ + __NETWORK_FUNC_ENTER__; + + GVariant *params = NULL; + net_err_e Error = NET_ERR_NONE; + + params = g_variant_new("(su)", network_info->interface_name, ps_mode); + + Error = _net_invoke_dbus_method_nonblock(network_info, + NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, "SetPowerSaveMode", + params, DBUS_REPLY_TIMEOUT, + __net_set_power_save_mode_reply); + + __NETWORK_FUNC_EXIT__; + return Error; +} +#endif /* TIZEN_DA */ +//LCOV_EXCL_STOP diff --git a/src/network_dbus.h b/src/network_dbus.h index dd317d6..d617292 100644 --- a/src/network_dbus.h +++ b/src/network_dbus.h @@ -232,6 +232,14 @@ int _net_dbus_get_country_code(network_info_s *network_info, char **country); int _net_dbus_get_vconf_value(network_info_s *network_info, const char *key, const char *type, int *ret, int *int_value, char **str_value); +#if defined TIZEN_DA +int _net_dbus_get_power_save_state(network_info_s *network_info, unsigned int *ps_state); +int _net_dbus_set_power_save_state(network_info_s *network_info, net_wifi_power_save_state_e ps_state); + +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 */ + #ifdef __cplusplus } #endif diff --git a/src/network_interface.c b/src/network_interface.c index df7d211..d5ee6fd 100644 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -4112,3 +4112,101 @@ int net_wifi_get_country_code(network_info_s *network_info, char **country) __NETWORK_FUNC_EXIT__; return Error; } + +//LCOV_EXCL_START +#if defined TIZEN_DA +int net_wifi_get_power_save_state(network_info_s *network_info, unsigned int *ps_state) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + Error = __net_get_wifi_state(network_info); + if (Error != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE + __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE + return Error; //LCOV_EXCL_LINE + } + + if (network_info->wifi_state == WIFI_OFF) { + WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE + __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE + return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE + } + + Error = _net_dbus_get_power_save_state(network_info, ps_state); + if (Error != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, + "_net_dbus_get_power_save_state() failed. Error [%s]", + _net_print_error(Error)); + } + + __NETWORK_FUNC_EXIT__; + return Error; +} + +int net_wifi_set_power_save_state(network_info_s *network_info, net_wifi_power_save_state_e ps_state) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + Error = __net_get_wifi_state(network_info); + if (Error != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE + __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE + return Error; //LCOV_EXCL_LINE + } + + if (network_info->wifi_state == WIFI_OFF) { + WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE + __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE + return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE + } + + Error = _net_dbus_set_power_save_state(network_info, ps_state); + if (Error != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, + "_net_dbus_set_power_save_state() failed. Error [%s]", + _net_print_error(Error)); + } + + __NETWORK_FUNC_EXIT__; + return Error; +} + +int net_wifi_get_power_save_mode(network_info_s *network_info, unsigned int *ps_mode) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + Error = _net_dbus_get_power_save_mode(network_info, ps_mode); + if (Error != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, + "_net_dbus_get_power_save_mode() failed. Error [%s]", + _net_print_error(Error)); + } + + __NETWORK_FUNC_EXIT__; + return Error; +} + +int net_wifi_set_power_save_mode(network_info_s *network_info, net_wifi_power_save_mode_e ps_mode) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + Error = _net_dbus_set_power_save_mode(network_info, ps_mode); + if (Error != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, + "_net_dbus_set_power_save_mode() failed. Error [%s]", + _net_print_error(Error)); + } + + __NETWORK_FUNC_EXIT__; + return Error; +} +#endif /* TIZEN_DA */ +//LCOV_EXCL_STOP diff --git a/src/network_interface.h b/src/network_interface.h index 150d1de..b07c351 100644 --- a/src/network_interface.h +++ b/src/network_interface.h @@ -400,6 +400,25 @@ int net_wifi_get_random_mac_lifetime(network_info_s *network_info, unsigned int int net_wifi_set_country_code(network_info_s *network_info, const char *country); int net_wifi_get_country_code(network_info_s *network_info, char **country); +#if defined TIZEN_DA +typedef enum { + WIFI_POWER_SAVE_OFF = 0x00, + WIFI_POWER_SAVE_ON, +} net_wifi_power_save_state_e; + +typedef enum { + WIFI_POWER_SAVE_MODE_DEFAULT_OFF = 0x00, + WIFI_POWER_SAVE_MODE_DEFAULT_ON, + WIFI_POWER_SAVE_MODE_DYNAMIC, +} net_wifi_power_save_mode_e; + +int net_wifi_get_power_save_state(network_info_s *network_info, unsigned int *ps_state); +int net_wifi_set_power_save_state(network_info_s *network_info, net_wifi_power_save_state_e ps_state); + +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 */ + /** * \} */ diff --git a/src/wifi_internal.c b/src/wifi_internal.c index 4f9731b..6deafd3 100644 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -4221,3 +4221,90 @@ int _wifi_get_country_code(wifi_manager_h wifi, char **country) return WIFI_MANAGER_ERROR_NONE; } + +//LCOV_EXCL_START +#if defined TIZEN_DA +int _wifi_get_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e *ps_state) +{ + int rv = 0; + wifi_manager_handle_s *wifi_handle = wifi; + + rv = net_wifi_get_power_save_state(wifi_handle->network_info, ps_state); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_MANAGER_ERROR_PERMISSION_DENIED; + } else if (rv == NET_ERR_INVALID_OPERATION) { + return WIFI_MANAGER_ERROR_INVALID_OPERATION; + } else if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get power-save state"); + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + } + + if ((*ps_state != WIFI_MANAGER_PS_OFF) && (*ps_state != WIFI_MANAGER_PS_ON)) + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + + return WIFI_MANAGER_ERROR_NONE; +} + +int _wifi_set_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e ps_state) +{ + int rv = 0; + wifi_manager_handle_s *wifi_handle = wifi; + + rv = net_wifi_set_power_save_state(wifi_handle->network_info, ps_state); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_MANAGER_ERROR_PERMISSION_DENIED; + } else if (rv == NET_ERR_INVALID_OPERATION) { + return WIFI_MANAGER_ERROR_INVALID_OPERATION; + } else if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get power-save state"); + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + } + + return WIFI_MANAGER_ERROR_NONE; +} + +int _wifi_get_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e *ps_mode) +{ + int rv = 0; + wifi_manager_handle_s *wifi_handle = wifi; + + rv = net_wifi_get_power_save_mode(wifi_handle->network_info, ps_mode); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_MANAGER_ERROR_PERMISSION_DENIED; + } else if (rv == NET_ERR_INVALID_OPERATION) { + return WIFI_MANAGER_ERROR_INVALID_OPERATION; + } else if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get power-save mode"); + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + } + + if ((*ps_mode != WIFI_MANAGER_PS_MODE_DYNAMIC) && (*ps_mode != WIFI_MANAGER_PS_MODE_DEFAULT_OFF) + && (*ps_mode != WIFI_MANAGER_PS_MODE_DEFAULT_ON)) + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + + return WIFI_MANAGER_ERROR_NONE; +} + +int _wifi_set_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e ps_mode) +{ + int rv = 0; + wifi_manager_handle_s *wifi_handle = wifi; + + rv = net_wifi_set_power_save_mode(wifi_handle->network_info, ps_mode); + if (rv == NET_ERR_ACCESS_DENIED) { + WIFI_LOG(WIFI_ERROR, "Access denied"); + return WIFI_MANAGER_ERROR_PERMISSION_DENIED; + } else if (rv == NET_ERR_INVALID_OPERATION) { + return WIFI_MANAGER_ERROR_INVALID_OPERATION; + } else if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get power-save mode"); + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + } + + return WIFI_MANAGER_ERROR_NONE; +} +#endif /* TIZEN_DA */ +//LCOV_EXCL_STOP diff --git a/src/wifi_internal.h b/src/wifi_internal.h index 75a8a75..8b13efe 100644 --- a/src/wifi_internal.h +++ b/src/wifi_internal.h @@ -600,6 +600,14 @@ int _wifi_get_random_mac_lifetime(wifi_manager_h wifi, unsigned int *lifetime); int _wifi_set_country_code(wifi_manager_h wifi, const char *country); int _wifi_get_country_code(wifi_manager_h wifi, char **country); +#if defined TIZEN_DA +int _wifi_get_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e *ps_state); +int _wifi_set_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e ps_state); + +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 */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/wifi_manager.c b/src/wifi_manager.c index e66d21b..1fad8ee 100644 --- a/src/wifi_manager.c +++ b/src/wifi_manager.c @@ -2227,6 +2227,7 @@ EXPORT_API int wifi_manager_unset_roaming_cb(wifi_manager_h wifi) return WIFI_MANAGER_ERROR_NONE; } +//LCOV_EXCL_START #if defined TIZEN_DA static int __wifi_set_dhcp_event_cb(wifi_manager_h wifi, void *callback, void *user_data) @@ -2269,4 +2270,101 @@ EXPORT_API int wifi_manager_dhcp_unset_event_cb(wifi_manager_h wifi) __NETWORK_CAPI_FUNC_EXIT__; return __wifi_set_dhcp_event_cb(wifi, NULL, NULL); } + +EXPORT_API int wifi_manager_get_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e *ps_state) +{ + __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__); + + WIFI_LOG(WIFI_INFO, "[App-->TizenMW] get power-save state request"); + + if (ps_state == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE + __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + + rv = _wifi_get_power_save_state(wifi, ps_state); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} + +EXPORT_API int wifi_manager_set_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e ps_state) +{ + __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__); + + if ((ps_state != WIFI_MANAGER_PS_OFF) && (ps_state != WIFI_MANAGER_PS_ON)) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + __NETWORK_CAPI_FUNC_EXIT__; + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; + } + + WIFI_LOG(WIFI_INFO, "[App-->TizenMW] set power-save state request"); + + rv = _wifi_set_power_save_state(wifi, ps_state); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} + +EXPORT_API int wifi_manager_get_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e *ps_mode) +{ + __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__); + + WIFI_LOG(WIFI_INFO, "[App-->TizenMW] get power-save mode request"); + + if (ps_mode == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE + __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + + rv = _wifi_get_power_save_mode(wifi, ps_mode); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} + +EXPORT_API int wifi_manager_set_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e ps_mode) +{ + __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__); + + if ((ps_mode < WIFI_MANAGER_PS_MODE_DEFAULT_OFF) || (ps_mode > WIFI_MANAGER_PS_MODE_DYNAMIC)) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + __NETWORK_CAPI_FUNC_EXIT__; + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; + } + + WIFI_LOG(WIFI_INFO, "[App-->TizenMW] set power-save mode request"); + + rv = _wifi_set_power_save_mode(wifi, ps_mode); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} #endif /* TIZEN_DA */ +//LCOV_EXCL_STOP diff --git a/tools/manager-test/wman_test_extension.c b/tools/manager-test/wman_test_extension.c index 5f9f1d5..50832af 100644 --- a/tools/manager-test/wman_test_extension.c +++ b/tools/manager-test/wman_test_extension.c @@ -824,3 +824,93 @@ void wman_test_print_connection_mode(wifi_manager_ap_h ap) else printf("Fail to get operation mode\n"); } + +#if defined TIZEN_DA +int wman_test_get_power_save_state(wifi_manager_h wifi) +{ + int rv; + wifi_manager_power_save_state_e ps_state; + + rv = wifi_manager_get_power_save_state(wifi, &ps_state); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get power-save state [%s]\n", wman_test_strerror(rv)); + return -1; + } + + if (ps_state == WIFI_MANAGER_PS_ON) + printf("power-save state : On\n"); + else if (ps_state == WIFI_MANAGER_PS_OFF) + printf("power-save state : Off\n"); + else + printf("power-save state : Unknown\n"); + + return 1; +} + +int wman_test_set_power_save_state(wifi_manager_h wifi) +{ + int rv; + wifi_manager_power_save_state_e ps_state; + + printf("Set power-save state (1: enable, 0: disable): "); + rv = scanf("%u", &ps_state); + if (rv <= 0) + return -1; + + rv = wifi_manager_set_power_save_state(wifi, ps_state); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get power-save state [%s]\n", wman_test_strerror(rv)); + return -1; + } + + return 1; +} + +int wman_test_get_power_save_mode(wifi_manager_h wifi) +{ + int rv; + wifi_manager_power_save_mode_e ps_mode; + + rv = wifi_manager_get_power_save_mode(wifi, &ps_mode); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get power-save mode [%s]\n", wman_test_strerror(rv)); + return -1; + } + + switch (ps_mode) { + case WIFI_MANAGER_PS_MODE_DEFAULT_OFF: + printf("power-save mode : default off\n"); + break; + case WIFI_MANAGER_PS_MODE_DEFAULT_ON: + printf("power-save mode : default on\n"); + break; + case WIFI_MANAGER_PS_MODE_DYNAMIC: + printf("power-save mode : Dynamic \n"); + break; + default: + printf("power-save mode : Unknown\n"); + break; + } + + return 1; +} + +int wman_test_set_power_save_mode(wifi_manager_h wifi) +{ + int rv; + wifi_manager_power_save_state_e ps_mode; + + printf("Set power-save mode (0: Off, 1: On, 2: Dynamic): "); + rv = scanf("%u", &ps_mode); + if (rv <= 0) + return -1; + + rv = wifi_manager_set_power_save_mode(wifi, ps_mode); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get power-save mode [%s]\n", wman_test_strerror(rv)); + return -1; + } + + return 1; +} +#endif /* TIZEN_DA */ diff --git a/tools/manager-test/wman_test_extension.h b/tools/manager-test/wman_test_extension.h index 22ae231..0aa651e 100644 --- a/tools/manager-test/wman_test_extension.h +++ b/tools/manager-test/wman_test_extension.h @@ -41,3 +41,9 @@ int wman_test_set_country_code(wifi_manager_h wifi); int wman_test_get_country_code(wifi_manager_h wifi); int wman_test_check_supported_security_type(wifi_manager_h wifi); void wman_test_print_connection_mode(wifi_manager_ap_h ap); +#if defined TIZEN_DA +int wman_test_get_power_save_state(wifi_manager_h wifi); +int wman_test_set_power_save_state(wifi_manager_h wifi); +int wman_test_get_power_save_mode(wifi_manager_h wifi); +int wman_test_set_power_save_mode(wifi_manager_h wifi); +#endif /* TIZEN_DA */ diff --git a/tools/manager-test/wman_test_main.c b/tools/manager-test/wman_test_main.c index c4b35fa..d1b9d6d 100644 --- a/tools/manager-test/wman_test_main.c +++ b/tools/manager-test/wman_test_main.c @@ -331,6 +331,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("^ - Set country code\n"); printf("& - Get country code\n"); printf("* - Check available security type\n"); +#if defined TIZEN_DA + printf("( - Get power-save state\n"); + printf(") - Set power-save state\n"); + printf("- - Get power-save mode\n"); + printf("= - Set power-save mode\n"); +#endif /* TIZEN_DA */ printf(LOG_RED "0 - Exit \n" LOG_END); printf("ENTER - Show options menu.......\n"); @@ -544,6 +550,20 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) case '*': rv = wman_test_check_supported_security_type(wifi); break; +#if defined TIZEN_DA + case '(': + rv = wman_test_get_power_save_state(wifi); + break; + case ')': + rv = wman_test_set_power_save_state(wifi); + break; + case '-': + rv = wman_test_get_power_save_mode(wifi); + break; + case '=': + rv = wman_test_set_power_save_mode(wifi); + break; +#endif /* TIZEN_DA */ default: break; } -- 2.7.4 From 494c54f0da2cbf39919a4f8261fdf08613fc6d24 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 1 Nov 2022 14:26:52 +0900 Subject: [PATCH 02/16] DA: Applying secure log Change-Id: I12cff8da99c4a8822b5f05bf3db11b1e7ce74469 Signed-off-by: Jaehyun Kim --- src/network_signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network_signal.c b/src/network_signal.c index 441222a..b3e13be 100644 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -565,7 +565,7 @@ static int __net_handle_wifi_netlink_scan_rsp(network_info_s *network_info, bss->security_type = sec_type; bss->encryption_type = enc_type; - WIFI_LOG(WIFI_INFO, "BSSID: %s, Freq: %d, rssi: %d, SSID: %s," + SECURE_LOGD("BSSID: %s, Freq: %d, rssi: %d, SSID: %s," "Security type : %d, Encryption type: %d", bssid, freq, rssi, ssid, sec_type, enc_type); -- 2.7.4 From 6a49c87d09d7f2443d871991719eac1e82b86046 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Thu, 22 Dec 2022 12:44:38 +0900 Subject: [PATCH 03/16] Add APIs for setting background scan interval Change-Id: Ia71290f860cecb876fae398bab15979783d27a8b Signed-off-by: Jaehyun Kim --- include/wifi-manager-extension.h | 43 +++++++++++++++++++++ packaging/capi-network-wifi-manager.spec | 2 +- src/network_dbus.c | 66 ++++++++++++++++++++++++++++++++ src/network_dbus.h | 4 ++ src/network_interface.c | 51 ++++++++++++++++++++++++ src/network_interface.h | 4 ++ src/wifi_internal.c | 34 ++++++++++++++++ src/wifi_internal.h | 4 ++ src/wifi_manager.c | 52 +++++++++++++++++++++++++ tools/manager-test/wman_test_extension.c | 56 +++++++++++++++++++++++++++ tools/manager-test/wman_test_extension.h | 2 + tools/manager-test/wman_test_main.c | 8 ++++ 12 files changed, 325 insertions(+), 1 deletion(-) diff --git a/include/wifi-manager-extension.h b/include/wifi-manager-extension.h index 7816134..d96d4d7 100644 --- a/include/wifi-manager-extension.h +++ b/include/wifi-manager-extension.h @@ -326,6 +326,49 @@ int wifi_manager_get_autoscan_mode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e *mode); /** + * @brief Sets the interval of autoscan. + * @since_tizen 7.5 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set + * + * @param[in] wifi The Wi-Fi handle + * @param[in] mode The auto scan mode + * @param[in] interval The interval of autoscan + * + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized + * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported + * @pre This API needs wifi_manager_initialize() before use. + */ +int wifi_manager_set_autoscan_interval(wifi_manager_h wifi, + wifi_manager_autoscan_mode_e mode, int interval); + +/** + * @brief Gets the autoscan interval. + * @since_tizen 7.5 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * + * @param[in] wifi The Wi-Fi handle + * @param[in] mode The auto scan mode + * @param[out] interval The interval of autoscan + * + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized + * @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_interval(wifi_manager_h wifi, + wifi_manager_autoscan_mode_e mode, int *interval); + +/** * @brief Set BSSID to connman to be connected * @since_tizen 5.0 * @param[in] wifi The Wi-Fi handle diff --git a/packaging/capi-network-wifi-manager.spec b/packaging/capi-network-wifi-manager.spec index ab11824..3a6880e 100644 --- a/packaging/capi-network-wifi-manager.spec +++ b/packaging/capi-network-wifi-manager.spec @@ -1,6 +1,6 @@ Name: capi-network-wifi-manager Summary: Network Wi-Fi library in TIZEN C API -Version: 1.3.20 +Version: 1.3.21 Release: 0 Group: System/Network License: Apache-2.0 diff --git a/src/network_dbus.c b/src/network_dbus.c index 129a834..d31e36a 100644 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -1410,6 +1410,35 @@ int _net_dbus_set_bgscan_mode(network_info_s *network_info, return Error; } +int _net_dbus_set_bgscan_interval(network_info_s *network_info, + net_wifi_background_scan_mode_e mode, int interval) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + GVariant *message = NULL; + GVariant *params; + + if (mode == WIFI_BGSCAN_MODE_EXPONENTIAL) + params = g_variant_new("(ssu)", network_info->interface_name, "Exponential", interval); + else + params = g_variant_new("(ssu)", network_info->interface_name, "Periodic", interval); + + message = _net_invoke_dbus_method(network_info, + NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, "SetBgscanInterval", + params, &Error); + + if (Error != NET_ERR_NONE) + WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed"); //LCOV_EXCL_LINE + + if (message != NULL) + g_variant_unref(message); //LCOV_EXCL_LINE + + __NETWORK_FUNC_EXIT__; + return Error; +} + int _net_dbus_set_ip_conflict_period(network_info_s *network_info, unsigned int initial_time) { __NETWORK_FUNC_ENTER__; @@ -4294,6 +4323,43 @@ int _net_dbus_get_autoscanmode(network_info_s *network_info, return Error; } +int _net_dbus_get_autoscan_interval(network_info_s *network_info, + unsigned int autoscanmode, int *interval) +{ + __NETWORK_FUNC_ENTER__; + + GVariant *params = NULL; + GVariant *message = NULL; + net_err_e Error = NET_ERR_NONE; + + if (autoscanmode == WIFI_BGSCAN_MODE_EXPONENTIAL) + params = g_variant_new("(ss)", network_info->interface_name, "Exponential"); + else + params = g_variant_new("(ss)", network_info->interface_name, "Periodic"); + + message = _net_invoke_dbus_method(network_info, + NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, "GetBgscanInterval", + params, &Error); + if (message == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to Get Bgscan Interval"); + __NETWORK_FUNC_EXIT__; + return Error; + } + + /** Check Reply */ + int result = 0; + g_variant_get(message, "(u)", &result); + *interval = result; + + WIFI_LOG(WIFI_INFO, "Get Auto scan Interval Result: %d", result); + + g_variant_unref(message); + + __NETWORK_FUNC_EXIT__; + return Error; +} + static void __net_multi_scan_request_reply(GObject *source_object, GAsyncResult *res, gpointer user_data) { diff --git a/src/network_dbus.h b/src/network_dbus.h index d617292..a97a400 100644 --- a/src/network_dbus.h +++ b/src/network_dbus.h @@ -90,6 +90,8 @@ int _net_dbus_scan_request(network_info_s *network_info); int _net_dbus_get_scan_state(network_info_s *network_info, int *state); int _net_dbus_set_bgscan_mode(network_info_s *network_info, net_wifi_background_scan_mode_e mode); +int _net_dbus_set_bgscan_interval(network_info_s *network_info, + net_wifi_background_scan_mode_e mode, int interval); int _net_dbus_set_agent_passphrase_and_connect(network_info_s *network_info, const char *passphrase, const char *profilename); int _net_dbus_get_wps_generated_pin(network_info_s *network_info, char **wps_pin); @@ -179,6 +181,8 @@ int _net_dbus_resume_bgscan(network_info_s *network_info); int _net_dbus_pause_bgscan(network_info_s *network_info); int _net_dbus_get_autoscanmode(network_info_s *network_info, unsigned int *autoscanmode); +int _net_dbus_get_autoscan_interval(network_info_s *network_info, + unsigned int autoscanmode, int *interval); int _net_dbus_get_autoscan(network_info_s *network_info, gboolean *autoscan); int _net_dbus_add_vsie(network_info_s *network_info, diff --git a/src/network_interface.c b/src/network_interface.c index d5ee6fd..a4adaae 100644 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -3593,6 +3593,39 @@ int net_wifi_set_background_scan_mode(network_info_s *network_info, return NET_ERR_NONE; } +int net_wifi_set_background_scan_interval(network_info_s *network_info, + net_wifi_background_scan_mode_e scan_mode, int interval) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + Error = __net_get_wifi_state(network_info); + if (Error != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state"); //LCOV_EXCL_LINE + __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE + return Error; //LCOV_EXCL_LINE + } + + if (network_info->wifi_state == WIFI_OFF) { + WIFI_LOG(WIFI_ERROR, "Wi-Fi powered off!"); //LCOV_EXCL_LINE + __NETWORK_FUNC_EXIT__; //LCOV_EXCL_LINE + return NET_ERR_INVALID_OPERATION; //LCOV_EXCL_LINE + } + + if ((Error = _net_dbus_set_bgscan_interval(network_info, scan_mode, interval)) != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, + "Failed to set bgscan interval. Error [%s]", + _net_print_error(Error)); + + __NETWORK_FUNC_EXIT__; + return Error; + } + + __NETWORK_FUNC_EXIT__; + return NET_ERR_NONE; +} + int net_wifi_set_ip_conflict_period(network_info_s *network_info, unsigned int initial_time) { @@ -3702,6 +3735,24 @@ int net_wifi_get_autoscanmode(network_info_s *network_info, unsigned int *autosc return Error; } +int net_wifi_get_autoscan_interval(network_info_s *network_info, + unsigned int autoscanmode, int *interval) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + Error = _net_dbus_get_autoscan_interval(network_info, autoscanmode, interval); + if (Error != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, + "_net_dbus_get_autoscan_interval() failed. Error [%s]", + _net_print_error(Error)); + } + + __NETWORK_FUNC_EXIT__; + return Error; +} + int net_wifi_get_module_state(network_info_s *network_info, int *module_state) { GVariant *message = NULL, *variant; diff --git a/src/network_interface.h b/src/network_interface.h index b07c351..d215e40 100644 --- a/src/network_interface.h +++ b/src/network_interface.h @@ -340,8 +340,12 @@ int net_get_device_policy_wifi_profile(network_info_s *network_info); int net_wifi_set_autoscan(network_info_s *network_info, gboolean autoscan); int net_wifi_set_background_scan_mode(network_info_s *network_info, net_wifi_background_scan_mode_e scan_mode); +int net_wifi_set_background_scan_interval(network_info_s *network_info, + net_wifi_background_scan_mode_e scan_mode, int interval); int net_wifi_get_autoscan(network_info_s *network_info, gboolean *autoscan); int net_wifi_get_autoscanmode(network_info_s *network_info, unsigned int *autoscanmode); +int net_wifi_get_autoscan_interval(network_info_s *network_info, + unsigned int autoscanmode, int *interval); int net_wifi_get_module_state(network_info_s *network_info, int *module_state); int net_foreach_ipv6_address(GSList **ipv6_address_list); diff --git a/src/wifi_internal.c b/src/wifi_internal.c index 6deafd3..8e7b302 100644 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -3590,6 +3590,22 @@ int _wifi_set_background_scan_mode(wifi_manager_h wifi, return WIFI_MANAGER_ERROR_NONE; } +int _wifi_set_background_scan_interval(wifi_manager_h wifi, + wifi_manager_autoscan_mode_e mode, int interval) +{ + int rv = 0; + wifi_manager_handle_s *wifi_handle = wifi; + + rv = net_wifi_set_background_scan_interval(wifi_handle->network_info, mode, interval); + 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_ip_conflict_period(wifi_manager_h wifi, unsigned int initial_time) { int rv = 0; @@ -3641,6 +3657,24 @@ int _wifi_get_autoscanmode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e *au return WIFI_MANAGER_ERROR_NONE; } +int _wifi_get_autoscan_interval(wifi_manager_h wifi, + wifi_manager_autoscan_mode_e autoscanmode, int *interval) +{ + int rv; + wifi_manager_handle_s *wifi_handle = wifi; + + rv = net_wifi_get_autoscan_interval(wifi_handle->network_info, autoscanmode, interval); + 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 auto scan interval"); //LCOV_EXCL_LINE + return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE + } + + return WIFI_MANAGER_ERROR_NONE; +} + int _wifi_set_passpoint(wifi_manager_h wifi, int passpoint) { int rv; diff --git a/src/wifi_internal.h b/src/wifi_internal.h index 8b13efe..74567be 100644 --- a/src/wifi_internal.h +++ b/src/wifi_internal.h @@ -461,8 +461,12 @@ gchar *_wifi_eap_auth_type_to_string(wifi_manager_eap_auth_type_e eap_auth_type) int _wifi_set_autoscan(wifi_manager_h wifi, bool autoscan); int _wifi_set_background_scan_mode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e mode); +int _wifi_set_background_scan_interval(wifi_manager_h wifi, + wifi_manager_autoscan_mode_e mode, int interval); int _wifi_get_autoscan(wifi_manager_h wifi, bool *autoscan); int _wifi_get_autoscanmode(wifi_manager_h wifi, wifi_manager_autoscan_mode_e *autoscanmode); +int _wifi_get_autoscan_interval(wifi_manager_h wifi, + wifi_manager_autoscan_mode_e autoscanmode, int *interval); int _wifi_get_passpoint(wifi_manager_h wifi, int *passpoint); int _wifi_set_passpoint(wifi_manager_h wifi, int passpoint); int _wifi_get_module_state(wifi_manager_h wifi, wifi_manager_module_state_e *state); diff --git a/src/wifi_manager.c b/src/wifi_manager.c index 1fad8ee..84bab68 100644 --- a/src/wifi_manager.c +++ b/src/wifi_manager.c @@ -1394,6 +1394,33 @@ EXPORT_API int wifi_manager_set_autoscan_mode(wifi_manager_h wifi, return rv; } +EXPORT_API int wifi_manager_set_autoscan_interval(wifi_manager_h wifi, + wifi_manager_autoscan_mode_e mode, int interval) +{ + int rv; + + __NETWORK_CAPI_FUNC_ENTER__; + + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__); + + if (mode < WIFI_MANAGER_AUTOSCAN_MODE_EXPONENTIAL || + mode > WIFI_MANAGER_AUTOSCAN_MODE_PERIODIC || + interval < 0) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE + __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + + rv = _wifi_set_background_scan_interval(wifi, mode, interval); + if (rv != WIFI_MANAGER_ERROR_NONE) + WIFI_LOG(WIFI_ERROR, "Set background scan interval failed"); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} + EXPORT_API int wifi_manager_get_autoscan(wifi_manager_h wifi, bool *autoscan) { @@ -1440,6 +1467,31 @@ EXPORT_API int wifi_manager_get_autoscan_mode(wifi_manager_h wifi, return rv; } +EXPORT_API int wifi_manager_get_autoscan_interval(wifi_manager_h wifi, + wifi_manager_autoscan_mode_e mode, int *interval) +{ + int rv; + + __NETWORK_CAPI_FUNC_ENTER__; + + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__); + + if (mode < WIFI_MANAGER_AUTOSCAN_MODE_EXPONENTIAL || + mode > WIFI_MANAGER_AUTOSCAN_MODE_PERIODIC || + interval == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE + __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + + rv = _wifi_get_autoscan_interval(wifi, mode, interval); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} + EXPORT_API int wifi_manager_set_passpoint(wifi_manager_h wifi, int passpoint) { __NETWORK_CAPI_FUNC_ENTER__; diff --git a/tools/manager-test/wman_test_extension.c b/tools/manager-test/wman_test_extension.c index 50832af..ff199c7 100644 --- a/tools/manager-test/wman_test_extension.c +++ b/tools/manager-test/wman_test_extension.c @@ -78,6 +78,37 @@ int wman_test_set_autoscan_mode(wifi_manager_h wifi) return 1; } +int wman_test_set_autoscan_interval(wifi_manager_h wifi) +{ + int mode = 0; + int rv = 0; + int autoscan_interval = 0; + + printf("Input autoscan mode (0:exponential, 1:periodic): \n"); + rv = scanf(" %9d", &mode); + + if (rv <= 0) { + printf("Invalid input!\n"); + return -1; + } + + printf("Input autoscan interval: \n"); + rv = scanf(" %9d", &autoscan_interval); + + if (rv <= 0) { + printf("Invalid input!\n"); + return -1; + } + + rv = wifi_manager_set_autoscan_interval(wifi, mode, autoscan_interval); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("failed to set autoscan mode [%s]\n", wman_test_strerror(rv)); + return -1; + } + + return 1; +} + int wman_test_get_autoscan_state(wifi_manager_h wifi) { int rv = 0; @@ -110,6 +141,31 @@ int wman_test_get_autoscan_mode(wifi_manager_h wifi) return 1; } +int wman_test_get_autoscan_interval(wifi_manager_h wifi) +{ + int mode = 0; + int rv = 0; + int autoscan_interval = 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_get_autoscan_interval(wifi, mode, &autoscan_interval); + + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get auto scan interval [%s]\n", wman_test_strerror(rv)); + return -1; + } + + printf("Auto Scan Interval: %d\n", autoscan_interval); + return 1; +} + int wman_test_flush_bss(wifi_manager_h wifi) { int rv; diff --git a/tools/manager-test/wman_test_extension.h b/tools/manager-test/wman_test_extension.h index 0aa651e..1ed4047 100644 --- a/tools/manager-test/wman_test_extension.h +++ b/tools/manager-test/wman_test_extension.h @@ -19,8 +19,10 @@ int wman_test_set_autoscan_state(wifi_manager_h wifi); int wman_test_set_autoscan_mode(wifi_manager_h wifi); +int wman_test_set_autoscan_interval(wifi_manager_h wifi); int wman_test_get_autoscan_state(wifi_manager_h wifi); int wman_test_get_autoscan_mode(wifi_manager_h wifi); +int wman_test_get_autoscan_interval(wifi_manager_h wifi); int wman_test_flush_bss(wifi_manager_h wifi); int wman_test_set_auto_connect(wifi_manager_h wifi); int wman_test_get_auto_connect(wifi_manager_h wifi); diff --git a/tools/manager-test/wman_test_main.c b/tools/manager-test/wman_test_main.c index d1b9d6d..d84c44d 100644 --- a/tools/manager-test/wman_test_main.c +++ b/tools/manager-test/wman_test_main.c @@ -337,6 +337,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("- - Get power-save mode\n"); printf("= - Set power-save mode\n"); #endif /* TIZEN_DA */ + printf("[ - Get Interval of Auto Scan\n"); + printf("] - Set Interval of Auto Scan\n"); printf(LOG_RED "0 - Exit \n" LOG_END); printf("ENTER - Show options menu.......\n"); @@ -564,6 +566,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) rv = wman_test_set_power_save_mode(wifi); break; #endif /* TIZEN_DA */ + case '[': + rv = wman_test_get_autoscan_interval(wifi); + break; + case ']': + rv = wman_test_set_autoscan_interval(wifi); + break; default: break; } -- 2.7.4 From 0014e22bd62483f07331f27a659d9af1900dcdbc Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 9 Jan 2023 14:22:25 +0900 Subject: [PATCH 04/16] Add an API for removing all AP configurations Change-Id: I1b302c60b37dfb968d7fbaea70be5e71b9047614 Signed-off-by: Jaehyun Kim --- include/wifi-manager-extension.h | 15 +++++++++++++++ packaging/capi-network-wifi-manager.spec | 2 +- src/network_dbus.c | 23 +++++++++++++++++++++++ src/network_dbus.h | 1 + src/network_interface.c | 18 ++++++++++++++++++ src/network_interface.h | 1 + src/wifi_config.c | 19 +++++++++++++++++++ src/wifi_internal.c | 28 ++++++++++++++++++++++++++++ src/wifi_internal.h | 1 + tools/manager-test/wman_test_extension.c | 15 +++++++++++++++ tools/manager-test/wman_test_extension.h | 1 + tools/manager-test/wman_test_main.c | 4 ++++ 12 files changed, 127 insertions(+), 1 deletion(-) diff --git a/include/wifi-manager-extension.h b/include/wifi-manager-extension.h index d96d4d7..328dd04 100644 --- a/include/wifi-manager-extension.h +++ b/include/wifi-manager-extension.h @@ -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. diff --git a/packaging/capi-network-wifi-manager.spec b/packaging/capi-network-wifi-manager.spec index 3a6880e..b58e540 100644 --- a/packaging/capi-network-wifi-manager.spec +++ b/packaging/capi-network-wifi-manager.spec @@ -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 diff --git a/src/network_dbus.c b/src/network_dbus.c index d31e36a..f3baaec 100644 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -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 diff --git a/src/network_dbus.h b/src/network_dbus.h index a97a400..eef0dd9 100644 --- a/src/network_dbus.h +++ b/src/network_dbus.h @@ -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 } diff --git a/src/network_interface.c b/src/network_interface.c index a4adaae..93bd8f8 100644 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -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 diff --git a/src/network_interface.h b/src/network_interface.h index d215e40..1c4430d 100644 --- a/src/network_interface.h +++ b/src/network_interface.h @@ -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); /** * \} diff --git a/src/wifi_config.c b/src/wifi_config.c index cdb26f5..fbc891a 100644 --- a/src/wifi_config.c +++ b/src/wifi_config.c @@ -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, diff --git a/src/wifi_internal.c b/src/wifi_internal.c index 8e7b302..e107d5d 100644 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -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 diff --git a/src/wifi_internal.h b/src/wifi_internal.h index 74567be..cea5b4d 100644 --- a/src/wifi_internal.h +++ b/src/wifi_internal.h @@ -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 } diff --git a/tools/manager-test/wman_test_extension.c b/tools/manager-test/wman_test_extension.c index ff199c7..847304e 100644 --- a/tools/manager-test/wman_test_extension.c +++ b/tools/manager-test/wman_test_extension.c @@ -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; diff --git a/tools/manager-test/wman_test_extension.h b/tools/manager-test/wman_test_extension.h index 1ed4047..bdd4abf 100644 --- a/tools/manager-test/wman_test_extension.h +++ b/tools/manager-test/wman_test_extension.h @@ -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); diff --git a/tools/manager-test/wman_test_main.c b/tools/manager-test/wman_test_main.c index d84c44d..ed4d88c 100644 --- a/tools/manager-test/wman_test_main.c +++ b/tools/manager-test/wman_test_main.c @@ -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; } -- 2.7.4 From 86372c95b85cbf2868f55ef8550e4febccc59560 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Wed, 11 Jan 2023 18:26:35 +0900 Subject: [PATCH 05/16] Improve APIs that inform DHCP status Signal for DHCP start point has been added. And undefine TIZEN_DA for extension APIs. Change-Id: I64ab4d0f9a6b2feef1f541893c35a2d476790f52 Signed-off-by: Jaehyun Kim --- include/wifi-manager-extension.h | 26 ++++++++--------- packaging/capi-network-wifi-manager.spec | 2 +- src/network_dbus.c | 4 --- src/network_dbus.h | 2 -- src/network_info.h | 4 --- src/network_interface.c | 2 -- src/network_interface.h | 2 -- src/network_internal.h | 2 -- src/network_signal.c | 48 ++++++++++++++++++++------------ src/wifi_internal.c | 22 +++++++-------- src/wifi_internal.h | 4 --- src/wifi_manager.c | 6 ++-- tools/manager-test/wman_test_extension.c | 2 -- tools/manager-test/wman_test_extension.h | 3 +- tools/manager-test/wman_test_main.c | 22 ++++----------- 15 files changed, 62 insertions(+), 89 deletions(-) diff --git a/include/wifi-manager-extension.h b/include/wifi-manager-extension.h index 328dd04..2010a8b 100644 --- a/include/wifi-manager-extension.h +++ b/include/wifi-manager-extension.h @@ -79,14 +79,14 @@ typedef enum { WIFI_MANAGER_ROAM_SUCCESS, /**< Wi-Fi Roaming is successful. */ } wifi_manager_roam_e; -#if defined TIZEN_DA /** * @brief Enumeration for the Wi-Fi DHCP state. * @since_tizen 7.5 */ typedef enum { - WIFI_MANAGER_DHCP_STATE_FAILED = -1, /* DHCP Fail */ - WIFI_MANAGER_DHCP_STATE_SUCCESS = 0, /* DHCP Success */ + WIFI_MANAGER_DHCP_STATE_UNKNOWN = 0, /* Unknown state */ + WIFI_MANAGER_DHCP_STATE_STARTED = 1, /* DHCP is running */ + WIFI_MANAGER_DHCP_STATE_FINISHED = 2, /* DHCP is finished */ } wifi_manager_dhcp_state_e; /** @@ -107,7 +107,6 @@ typedef enum { WIFI_MANAGER_PS_MODE_DEFAULT_ON, WIFI_MANAGER_PS_MODE_DYNAMIC, } wifi_manager_power_save_mode_e; -#endif /* TIZEN_DA */ /** * @brief The Wi-Fi netlink scan handle. @@ -883,18 +882,20 @@ int wifi_manager_set_roaming_cb(wifi_manager_h wifi, */ int wifi_manager_unset_roaming_cb(wifi_manager_h wifi); -#if defined TIZEN_DA /** * @brief Called when the DHCP state is changed. + * @details The following error codes can be received: \n + * #WIFI_MANAGER_ERROR_NONE Successful \n + * #WIFI_MANAGER_ERROR_DHCP_FAILED DHCP failed \n * @since_tizen 7.5 * @param[in] state The DHCP state - * @param[in] lease_time The DHCP lease time + * @param[in] error_code The error code * @param[in] user_data The user data passed from the callback registration function - * @see wifi_manager_dhcp_set_event_cb() - * @see wifi_manager_dhcp_unset_event_cb() + * @see wifi_manager_set_dhcp_state_changed_cb() + * @see wifi_manager_unset_dhcp_state_changed_cb() */ - -typedef void(*wifi_manager_dhcp_event_cb)(wifi_manager_dhcp_state_e state, int lease_time, void *user_data); +typedef void(*wifi_manager_dhcp_event_cb)(wifi_manager_dhcp_state_e state, + wifi_manager_error_e error_code, void *user_data); /** * @brief set DHCP event callback @@ -914,7 +915,7 @@ typedef void(*wifi_manager_dhcp_event_cb)(wifi_manager_dhcp_state_e state, int l * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported */ -int wifi_manager_dhcp_set_event_cb(wifi_manager_h wifi, wifi_manager_dhcp_event_cb callback, void *user_data); +int wifi_manager_set_dhcp_state_changed_cb(wifi_manager_h wifi, wifi_manager_dhcp_event_cb callback, void *user_data); /** * @brief unset DHCP event callback @@ -932,7 +933,7 @@ int wifi_manager_dhcp_set_event_cb(wifi_manager_h wifi, wifi_manager_dhcp_event_ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported */ -int wifi_manager_dhcp_unset_event_cb(wifi_manager_h wifi); +int wifi_manager_unset_dhcp_state_changed_cb(wifi_manager_h wifi); /** * @brief Gets power-save state. @@ -1015,7 +1016,6 @@ int wifi_manager_get_power_save_mode(wifi_manager_h wifi, wifi_manager_power_sav * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported */ int wifi_manager_set_power_save_mode(wifi_manager_h wifi, wifi_manager_power_save_mode_e ps_mode); -#endif /* TIZEN_DA */ /** * @} diff --git a/packaging/capi-network-wifi-manager.spec b/packaging/capi-network-wifi-manager.spec index b58e540..3737a3a 100644 --- a/packaging/capi-network-wifi-manager.spec +++ b/packaging/capi-network-wifi-manager.spec @@ -1,6 +1,6 @@ Name: capi-network-wifi-manager Summary: Network Wi-Fi library in TIZEN C API -Version: 1.3.22 +Version: 1.3.23 Release: 0 Group: System/Network License: Apache-2.0 diff --git a/src/network_dbus.c b/src/network_dbus.c index f3baaec..77e7f65 100644 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -1055,7 +1055,6 @@ static void __net_set_passpoint_reply(GObject *source_object, GAsyncResult *res, } //LCOV_EXCL_START -#if defined TIZEN_DA static void __net_set_power_save_state_reply(GObject *source_object, GAsyncResult *res, gpointer user_data) { __NETWORK_FUNC_ENTER__; @@ -1109,7 +1108,6 @@ static void __net_set_power_save_mode_reply(GObject *source_object, GAsyncResult __NETWORK_FUNC_EXIT__; } -#endif /* TIZEN_DA */ //LCOV_EXCL_STOP static char *__net_make_group_name(unsigned char *raw_ssid, @@ -4877,7 +4875,6 @@ int _net_dbus_get_vconf_value(network_info_s *network_info, } //LCOV_EXCL_START -#if defined TIZEN_DA int _net_dbus_get_power_save_state(network_info_s *network_info, unsigned int *ps_state) { __NETWORK_FUNC_ENTER__; @@ -4979,7 +4976,6 @@ int _net_dbus_set_power_save_mode(network_info_s *network_info, net_wifi_power_s __NETWORK_FUNC_EXIT__; return Error; } -#endif /* TIZEN_DA */ int _net_dbus_reset_wifi_config(network_info_s *network_info) { diff --git a/src/network_dbus.h b/src/network_dbus.h index eef0dd9..19f3d93 100644 --- a/src/network_dbus.h +++ b/src/network_dbus.h @@ -236,13 +236,11 @@ int _net_dbus_get_country_code(network_info_s *network_info, char **country); int _net_dbus_get_vconf_value(network_info_s *network_info, const char *key, const char *type, int *ret, int *int_value, char **str_value); -#if defined TIZEN_DA int _net_dbus_get_power_save_state(network_info_s *network_info, unsigned int *ps_state); int _net_dbus_set_power_save_state(network_info_s *network_info, net_wifi_power_save_state_e ps_state); 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 diff --git a/src/network_info.h b/src/network_info.h index b50085a..1a7141b 100644 --- a/src/network_info.h +++ b/src/network_info.h @@ -72,10 +72,8 @@ typedef enum { NET_EVENT_WIFI_DPP_REMOVED, NET_EVENT_WIFI_DPP_EVENT_IND, /* TODO: Make this in detail */ NET_EVENT_WIFI_ROAM_STATE_IND, -#if defined TIZEN_DA NET_EVENT_WIFI_TIMEOUT_RSP, NET_EVENT_WIFI_DHCP_STATE_IND, -#endif /* TIZEN_DA */ } net_event_e; typedef struct { @@ -146,9 +144,7 @@ typedef struct { guint subscribe_id_connman_scanstarted; guint subscribe_id_connman_roaming; guint subscribe_id_netconfig_wifi; -#if defined TIZEN_DA guint subscribe_id_connman_dhcp; -#endif /* TIZEN_DA */ char interface_name[NET_WLAN_IF_NAME_LEN]; char mac_address[WIFI_MAC_ADDR_LEN + 1]; diff --git a/src/network_interface.c b/src/network_interface.c index 93bd8f8..f96235b 100644 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -4165,7 +4165,6 @@ int net_wifi_get_country_code(network_info_s *network_info, char **country) } //LCOV_EXCL_START -#if defined TIZEN_DA int net_wifi_get_power_save_state(network_info_s *network_info, unsigned int *ps_state) { __NETWORK_FUNC_ENTER__; @@ -4259,7 +4258,6 @@ int net_wifi_set_power_save_mode(network_info_s *network_info, net_wifi_power_sa __NETWORK_FUNC_EXIT__; return Error; } -#endif /* TIZEN_DA */ int net_wifi_reset_wifi_config(network_info_s *network_info) { diff --git a/src/network_interface.h b/src/network_interface.h index 1c4430d..f0b0a61 100644 --- a/src/network_interface.h +++ b/src/network_interface.h @@ -404,7 +404,6 @@ int net_wifi_get_random_mac_lifetime(network_info_s *network_info, unsigned int int net_wifi_set_country_code(network_info_s *network_info, const char *country); int net_wifi_get_country_code(network_info_s *network_info, char **country); -#if defined TIZEN_DA typedef enum { WIFI_POWER_SAVE_OFF = 0x00, WIFI_POWER_SAVE_ON, @@ -421,7 +420,6 @@ 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); /** diff --git a/src/network_internal.h b/src/network_internal.h index ff68827..2da01f2 100644 --- a/src/network_internal.h +++ b/src/network_internal.h @@ -87,9 +87,7 @@ extern "C" { #define SIGNAL_SCAN_DONE "ScanDone" #define SIGNAL_SCAN_CHANGED "ScanChanged" #define SIGNAL_ROAMING_STATE_CHANGED "RoamingStateChanged" -#if defined TIZEN_DA #define SIGNAL_DHCP_CHANGED "DhcpChanged" -#endif /* TIZEN_DA */ #define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/wifi" diff --git a/src/network_signal.c b/src/network_signal.c index b3e13be..ead76a9 100644 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -1957,13 +1957,14 @@ static int __net_handle_dpp_removed(network_info_s *network_info, return NET_ERR_NONE; } -#if defined TIZEN_DA static int __net_handle_dhcp_changed(network_info_s *network_info, GVariant *param) { __NETWORK_FUNC_ENTER__; const char *key = NULL; - int value = 0; + const gchar *value = NULL; + int err = NET_ERR_UNKNOWN; + int dhcp_started = 0; GVariant *var; net_event_info_s *event_data = NULL; @@ -1975,21 +1976,37 @@ static int __net_handle_dhcp_changed(network_info_s *network_info, GVariant *par g_variant_get(param, "(sv)", &key, &var); - if (g_strcmp0(key, "DHCP_SUCCESS") == 0 || g_strcmp0(key, "DHCP_FAIL") == 0) { - if (g_variant_is_of_type(var, G_VARIANT_TYPE_INT32)) - value = g_variant_get_int32(var); + if (g_strcmp0(key, "DHCP_STARTED") == 0) { + err = NET_ERR_NONE; + dhcp_started = 1; + } else if (g_strcmp0(key, "DHCP_SUCCESS") == 0) { + err = NET_ERR_NONE; + dhcp_started = 0; + } else if (g_strcmp0(key, "DHCP_FAIL") == 0) { + err = NET_ERR_CONNECTION_DHCP_FAILED; + dhcp_started = 0; + } else { + goto done; + } - WIFI_LOG(WIFI_INFO, "Key:[%s] value:[%d]", key, value); + if (g_variant_is_of_type(var, G_VARIANT_TYPE_STRING)) + value = g_variant_get_string(var, NULL); - event_data->Event = NET_EVENT_WIFI_DHCP_STATE_IND; - event_data->Error = NET_ERR_NONE; - event_data->Datalength = sizeof(gint); - event_data->Data = &value; + WIFI_LOG(WIFI_INFO, "Key:[%s] value:[%s] ifname:[%s]", + key, value, network_info->interface_name); - if (network_info->event_callback) - network_info->event_callback(event_data, network_info->user_data); - } + if (g_strcmp0(network_info->interface_name, value) != 0) + goto done; + event_data->Event = NET_EVENT_WIFI_DHCP_STATE_IND; + event_data->Error = err; + event_data->Datalength = sizeof(int *); + event_data->Data = &dhcp_started; + + if (network_info->event_callback) + network_info->event_callback(event_data, network_info->user_data); + +done: g_free(event_data); g_free((gchar *)key); @@ -2000,7 +2017,6 @@ static int __net_handle_dhcp_changed(network_info_s *network_info, GVariant *par __NETWORK_FUNC_EXIT__; return NET_ERR_NONE; } -#endif /* TIZEN_DA */ static void __net_connman_manager_signal_filter(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, @@ -2014,10 +2030,8 @@ static void __net_connman_manager_signal_filter(GDBusConnection *conn, __net_handle_scan_done(network_info, param); else if (g_strcmp0(sig, SIGNAL_ROAMING_STATE_CHANGED) == 0) __net_handle_roaming_changed(network_info, param); -#if defined TIZEN_DA else if (g_strcmp0(sig, SIGNAL_DHCP_CHANGED) == 0) __net_handle_dhcp_changed(network_info, param); -#endif /* TIZEN_DA */ } static void __net_netconfig_signal_filter(GDBusConnection *conn, @@ -2381,7 +2395,6 @@ int _net_register_signal(network_info_s *network_info) network_info, NULL); -#if defined TIZEN_DA /* Create connman service dhcp connection */ network_info->subscribe_id_connman_dhcp = g_dbus_connection_signal_subscribe( network_info->connection, @@ -2394,7 +2407,6 @@ int _net_register_signal(network_info_s *network_info) __net_connman_manager_signal_filter, network_info, NULL); -#endif /* TIZEN_DA */ /* LCOV_EXCL_START */ if (network_info->subscribe_id_connman_state == 0 || diff --git a/src/wifi_internal.c b/src/wifi_internal.c index e107d5d..0696213 100644 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -1258,20 +1258,19 @@ static void __dpp_removed_cb(wifi_manager_handle_s *wifi_handle, g_p_dpp_current = NULL; } -#if defined TIZEN_DA -static void __dhcp_state_cb(wifi_manager_handle_s *wifi_handle, int lease_time) +static void __dhcp_state_cb(wifi_manager_handle_s *wifi_handle, net_event_e err, int dhcp_started) { wifi_manager_dhcp_state_e state; - if (lease_time > 0) - state = WIFI_MANAGER_DHCP_STATE_SUCCESS; + if (dhcp_started) + state = WIFI_MANAGER_DHCP_STATE_STARTED; else - state = WIFI_MANAGER_DHCP_STATE_FAILED; + state = WIFI_MANAGER_DHCP_STATE_FINISHED; if (wifi_handle->dhcp_event_cb) - wifi_handle->dhcp_event_cb(state, lease_time, wifi_handle->dhcp_event_user_data); + wifi_handle->dhcp_event_cb(state, + __convert_to_ap_error_type(err), wifi_handle->dhcp_event_user_data); } -#endif /* TIZEN_DA */ static void __roaming_state_changed_cb(wifi_manager_handle_s *wifi_handle, net_roam_event_info_s *roam_event_info) @@ -1591,13 +1590,14 @@ static void _wifi_evt_cb(net_event_info_s *event_cb, void *user_data) __connected_cb(wifi_handle, result); break; +#endif /* TIZEN_DA */ case NET_EVENT_WIFI_DHCP_STATE_IND: { - int *lease_time = (int *)event_cb->Data; - __dhcp_state_cb(wifi_handle, *lease_time); + net_event_e err = event_cb->Error; + int *dhcp_started = (int *)event_cb->Data; + __dhcp_state_cb(wifi_handle, err, *dhcp_started); } break; -#endif /* TIZEN_DA */ //LCOV_EXCL_STOP default: break; @@ -4257,7 +4257,6 @@ int _wifi_get_country_code(wifi_manager_h wifi, char **country) } //LCOV_EXCL_START -#if defined TIZEN_DA int _wifi_get_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e *ps_state) { int rv = 0; @@ -4340,7 +4339,6 @@ 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) { diff --git a/src/wifi_internal.h b/src/wifi_internal.h index cea5b4d..5cef866 100644 --- a/src/wifi_internal.h +++ b/src/wifi_internal.h @@ -263,10 +263,8 @@ typedef struct { void *dpp_event_user_data; wifi_manager_roaming_state_changed_cb roaming_state_changed_cb; void *roaming_state_changed_user_data; -#if defined TIZEN_DA wifi_manager_dhcp_event_cb dhcp_event_cb; void *dhcp_event_user_data; -#endif /* TIZEN_DA */ network_info_s *network_info; char interface_name[NET_WLAN_IF_NAME_LEN]; @@ -604,13 +602,11 @@ int _wifi_get_random_mac_lifetime(wifi_manager_h wifi, unsigned int *lifetime); int _wifi_set_country_code(wifi_manager_h wifi, const char *country); int _wifi_get_country_code(wifi_manager_h wifi, char **country); -#if defined TIZEN_DA int _wifi_get_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e *ps_state); int _wifi_set_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e ps_state); 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 diff --git a/src/wifi_manager.c b/src/wifi_manager.c index 84bab68..6fdd4d2 100644 --- a/src/wifi_manager.c +++ b/src/wifi_manager.c @@ -2280,7 +2280,6 @@ EXPORT_API int wifi_manager_unset_roaming_cb(wifi_manager_h wifi) } //LCOV_EXCL_START -#if defined TIZEN_DA static int __wifi_set_dhcp_event_cb(wifi_manager_h wifi, void *callback, void *user_data) { @@ -2292,7 +2291,7 @@ static int __wifi_set_dhcp_event_cb(wifi_manager_h wifi, return WIFI_MANAGER_ERROR_NONE; } -EXPORT_API int wifi_manager_dhcp_set_event_cb(wifi_manager_h wifi, +EXPORT_API int wifi_manager_set_dhcp_state_changed_cb(wifi_manager_h wifi, wifi_manager_dhcp_event_cb callback, void *user_data) { __NETWORK_CAPI_FUNC_ENTER__; @@ -2311,7 +2310,7 @@ EXPORT_API int wifi_manager_dhcp_set_event_cb(wifi_manager_h wifi, return __wifi_set_dhcp_event_cb(wifi, callback, user_data); } -EXPORT_API int wifi_manager_dhcp_unset_event_cb(wifi_manager_h wifi) +EXPORT_API int wifi_manager_unset_dhcp_state_changed_cb(wifi_manager_h wifi) { __NETWORK_CAPI_FUNC_ENTER__; @@ -2418,5 +2417,4 @@ EXPORT_API int wifi_manager_set_power_save_mode(wifi_manager_h wifi, wifi_manage __NETWORK_CAPI_FUNC_EXIT__; return rv; } -#endif /* TIZEN_DA */ //LCOV_EXCL_STOP diff --git a/tools/manager-test/wman_test_extension.c b/tools/manager-test/wman_test_extension.c index 847304e..6a29433 100644 --- a/tools/manager-test/wman_test_extension.c +++ b/tools/manager-test/wman_test_extension.c @@ -896,7 +896,6 @@ void wman_test_print_connection_mode(wifi_manager_ap_h ap) printf("Fail to get operation mode\n"); } -#if defined TIZEN_DA int wman_test_get_power_save_state(wifi_manager_h wifi) { int rv; @@ -984,4 +983,3 @@ int wman_test_set_power_save_mode(wifi_manager_h wifi) return 1; } -#endif /* TIZEN_DA */ diff --git a/tools/manager-test/wman_test_extension.h b/tools/manager-test/wman_test_extension.h index bdd4abf..e2af2f4 100644 --- a/tools/manager-test/wman_test_extension.h +++ b/tools/manager-test/wman_test_extension.h @@ -44,9 +44,8 @@ int wman_test_set_country_code(wifi_manager_h wifi); int wman_test_get_country_code(wifi_manager_h wifi); int wman_test_check_supported_security_type(wifi_manager_h wifi); void wman_test_print_connection_mode(wifi_manager_ap_h ap); -#if defined TIZEN_DA int wman_test_get_power_save_state(wifi_manager_h wifi); int wman_test_set_power_save_state(wifi_manager_h wifi); int wman_test_get_power_save_mode(wifi_manager_h wifi); int wman_test_set_power_save_mode(wifi_manager_h wifi); -#endif /* TIZEN_DA */ + diff --git a/tools/manager-test/wman_test_main.c b/tools/manager-test/wman_test_main.c index ed4d88c..4fc185f 100644 --- a/tools/manager-test/wman_test_main.c +++ b/tools/manager-test/wman_test_main.c @@ -162,15 +162,11 @@ static void __test_roaming_state_changed_callback(wifi_manager_roam_e state, printf(", cur_bssid: %s, dst_bssid: %s\n", cur_bssid, dst_bssid); } -#if defined TIZEN_DA -static void __test_dhcp_changed_callback(wifi_manager_dhcp_state_e state, int lease_time, void *user_data) +static void __test_dhcp_changed_callback(wifi_manager_dhcp_state_e state, wifi_manager_error_e error_code, void *user_data) { - if (state == WIFI_MANAGER_DHCP_STATE_SUCCESS) - printf("[%s] DHCP state changed callback, state : Success, lease time : %d\n", (char *)user_data, lease_time); - else - printf("[%s] DHCP state changed callback, state : Fail\n", (char *)user_data); + printf("[%s] DHCP state changed callback, state : %d, error : %s\n", + (char *)user_data, state, wman_test_strerror(error_code)); } -#endif /* TIZEN_DA */ int wman_test_init(void) { @@ -187,9 +183,7 @@ int wman_test_init(void) wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "1"); wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "1"); wifi_manager_set_roaming_cb(wifi, __test_roaming_state_changed_callback, "1"); -#if defined TIZEN_DA - wifi_manager_dhcp_set_event_cb(wifi, __test_dhcp_changed_callback, "1"); -#endif /* TIZEN_DA */ + wifi_manager_set_dhcp_state_changed_cb(wifi, __test_dhcp_changed_callback, "1"); } else { printf("[1] Wifi init failed [%s]\n", wman_test_strerror(rv)); @@ -206,9 +200,7 @@ int wman_test_init(void) wifi_manager_tdls_set_state_changed_cb(wifi2, __test_tdls_state_callback, "2"); wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "2"); wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "2"); -#if defined TIZEN_DA - wifi_manager_dhcp_set_event_cb(wifi2, __test_dhcp_changed_callback, "2"); -#endif /* TIZEN_DA */ + wifi_manager_set_dhcp_state_changed_cb(wifi2, __test_dhcp_changed_callback, "2"); } else { printf("[2] Wifi init failed [%s]\n", wman_test_strerror(rv)); return -1; @@ -331,12 +323,10 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("^ - Set country code\n"); printf("& - Get country code\n"); printf("* - Check available security type\n"); -#if defined TIZEN_DA printf("( - Get power-save state\n"); printf(") - Set power-save state\n"); printf("- - Get power-save mode\n"); printf("= - Set power-save mode\n"); -#endif /* TIZEN_DA */ printf("[ - Get Interval of Auto Scan\n"); printf("] - Set Interval of Auto Scan\n"); printf("; - Remove All Wi-Fi configurations\n"); @@ -553,7 +543,6 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) case '*': rv = wman_test_check_supported_security_type(wifi); break; -#if defined TIZEN_DA case '(': rv = wman_test_get_power_save_state(wifi); break; @@ -566,7 +555,6 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) case '=': rv = wman_test_set_power_save_mode(wifi); break; -#endif /* TIZEN_DA */ case '[': rv = wman_test_get_autoscan_interval(wifi); break; -- 2.7.4 From 31b674c432538065c297870de5dd2fa894cf5ad8 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Thu, 26 Jan 2023 11:39:15 +0900 Subject: [PATCH 06/16] Remove DA extension package DA package has a potential dependency problem with other packages, so a separate DA package will not be created. And the patches that existed only in the DA package were reviewed and merged in the common package. Change-Id: I4b30870fd0dc901df0e68eeb3d95ae1f0acf8e9f Signed-off-by: Jaehyun Kim --- CMakeLists.txt | 4 --- packaging/capi-network-wifi-manager.spec | 54 +------------------------------- src/network_dbus.c | 33 +++++-------------- src/network_interface.c | 5 --- src/network_signal.c | 32 +++++-------------- src/network_signal.h | 2 -- src/wifi_internal.c | 6 ---- 7 files changed, 16 insertions(+), 120 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e6d6d9..f4fe1b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,10 +12,6 @@ pkg_check_modules(pkgs REQUIRED dlog vconf capi-base-common capi-system-info gli INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS}) LINK_DIRECTORIES(${pkgs_LIBRARY_DIRS}) -IF(TIZEN_DA) - ADD_DEFINITIONS("-DTIZEN_DA") -ENDIF(TIZEN_DA) - FILE(GLOB SRCS src/*.c) ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LIBRARIES}) diff --git a/packaging/capi-network-wifi-manager.spec b/packaging/capi-network-wifi-manager.spec index 3737a3a..57998a7 100644 --- a/packaging/capi-network-wifi-manager.spec +++ b/packaging/capi-network-wifi-manager.spec @@ -22,14 +22,6 @@ Requires(postun): /sbin/ldconfig %description Network Wi-Fi Manager library in Tizen C API -%package extension-da -Summary: Network Wi-Fi Manager library in Tizen C API for Appliance devices -Group: Network & Connectivity/Development -Requires: %{name} = %{version}-%{release} - -%description extension-da -Network Wi-Fi Manager library in Tizen C API for Appliance devices - %package devel Summary: Network Wi-Fi Manager library in Tizen C API (Development) Group: Network & Connectivity/Development @@ -46,14 +38,6 @@ Requires: %{name} = %{version} %description tool Test Application for Wi-Fi Manager -%package extension-da-tool -Summary: Test Application for Wi-Fi Manager (for Appliance devices) -Group: Network & Connectivity/Utilities -Requires: %{name} = %{version} - -%description extension-da-tool -Test Application for Wi-Fi Manager (for Appliance devices) - %if 0%{?gcov:1} %package gcov Summary: Coverage Data of %{name} @@ -86,22 +70,9 @@ export FFLAGS+=" -fprofile-arcs -ftest-coverage" MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -# Build for appliance -%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ - -DCMAKE_VERBOSE_MAKEFILE=OFF \ - -DTIZEN_DA=1 \ - -DBIN_INSTALL_DIR:PATH=%{_bindir} - -%make_install -mv %{buildroot}%{_libdir}/lib%{name}.so.%{version} %{_builddir}/%{name}-%{version}/lib%{name}.so.%{version}.da -mv %{buildroot}%{_bindir}/wifi_manager_test %{_builddir}/%{name}-%{version}/wifi_manager_test.da - -make %{?_smp_mflags} - # Build for common %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ -DCMAKE_VERBOSE_MAKEFILE=OFF \ - -DTIZEN_DA=0 \ -DBIN_INSTALL_DIR:PATH=%{_bindir} make %{?_smp_mflags} @@ -154,9 +125,6 @@ lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info genhtml %{name}.info -o out --legend --show-details %endif -mv %{_builddir}/%{name}-%{version}/lib%{name}.so.%{version}.da %{buildroot}%{_libdir} -mv %{_builddir}/%{name}-%{version}/wifi_manager_test.da %{buildroot}%{_bindir} - %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -164,7 +132,6 @@ mv %{_builddir}/%{name}-%{version}/wifi_manager_test.da %{buildroot}%{_bindir} %files %manifest %{name}.manifest %{_libdir}/lib%{name}.so.* -%exclude %{_libdir}/lib%{name}.so.%{version}.da %license LICENSE.APLv2 %files devel @@ -174,7 +141,6 @@ mv %{_builddir}/%{name}-%{version}/wifi_manager_test.da %{buildroot}%{_bindir} %files tool %manifest %{name}.manifest -%exclude %{_bindir}/wifi_manager_test.da %{_bindir}/wifi_manager_test %{_bindir}/wifi_mgr_tool %{_bindir}/wifi_connect_tool @@ -187,22 +153,4 @@ mv %{_builddir}/%{name}-%{version}/wifi_manager_test.da %{buildroot}%{_bindir} %files unittests %{_bindir}/gtest-wifi-manager -%{_bindir}/tizen-unittests/%{name}/run-unittest.sh - -%files extension-da -%{_libdir}/lib%{name}.so.%{version}.da - -%preun extension-da -rm %{_libdir}/lib%{name}.so.%{version} - -%post extension-da -mv %{_libdir}/lib%{name}.so.%{version}.da %{_libdir}/lib%{name}.so.%{version} - -%files extension-da-tool -%{_bindir}/wifi_manager_test.da - -%preun extension-da-tool -rm %{_bindir}/wifi_manager_test - -%post extension-da-tool -mv %{_bindir}/wifi_manager_test.da %{_bindir}/wifi_manager_test +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh \ No newline at end of file diff --git a/src/network_dbus.c b/src/network_dbus.c index 77e7f65..42b96ba 100644 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -32,7 +32,6 @@ #define WIFI_SECURITY_OWE "owe" #define WIFI_SECURITY_DPP "dpp" -#if defined TIZEN_DA #include "network_signal.h" __thread guint connection_cb_timer = 0; @@ -41,7 +40,6 @@ __thread guint full_scan_cb_timer = 0; __thread guint specific_scan_cb_timer = 0; __thread guint multi_scan_cb_timer = 0; __thread guint bssid_scan_cb_timer = 0; -#endif /* TIZEN_DA */ //LCOV_EXCL_START static int __net_error_string_to_enum(const char *error) @@ -267,9 +265,7 @@ static net_wifi_eap_auth_type_e __net_wifi_eap_auth_type_to_int(const gchar *typ return ret; } -#if defined TIZEN_DA static gboolean __check_connection_callback(gpointer data); -#endif /* TIZEN_DA */ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *res, gpointer user_data) { @@ -307,13 +303,12 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re g_variant_unref(reply); if (Error == NET_ERR_NONE) { -#if defined TIZEN_DA if (connection_cb_timer > 0) { g_source_remove(connection_cb_timer); connection_cb_timer = 0; } connection_cb_timer = g_timeout_add_seconds(50, __check_connection_callback, (void *)network_info); -#endif /* TIZEN_DA */ + __NETWORK_FUNC_EXIT__; return; } @@ -340,12 +335,12 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re if (open_info->flag == TRUE) { g_strlcpy(event_data->ProfileName, open_info->ProfileName, NET_PROFILE_NAME_LEN_MAX + 1); -#if defined TIZEN_DA + if (connection_cb_timer > 0) { g_source_remove(connection_cb_timer); connection_cb_timer = 0; } -#endif /* TIZEN_DA */ + memset(open_info, 0, sizeof(network_request_table_s)); event_data->Error = Error; @@ -414,7 +409,6 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re __NETWORK_FUNC_EXIT__; } -#if defined TIZEN_DA static gboolean __check_connection_callback(gpointer data) { net_event_info_s *event_data = NULL; @@ -597,7 +591,6 @@ static gboolean __check_bssid_scan_callback(gpointer data) return FALSE; } -#endif /* TIZEN_DA */ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer user_data) { @@ -640,7 +633,6 @@ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer if (reply) g_variant_unref(reply); -#if defined TIZEN_DA if (full_scan_cb_timer > 0) { g_source_remove(full_scan_cb_timer); full_scan_cb_timer = 0; @@ -650,7 +642,6 @@ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer g_source_remove(bssid_scan_cb_timer); bssid_scan_cb_timer = 0; } -#endif /* TIZEN_DA */ request_table = network_info->request_table; bssid_scan_info = &request_table[NETWORK_REQUEST_TYPE_BSSID_SCAN]; @@ -680,18 +671,15 @@ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) { WIFI_LOG(WIFI_INFO, "Full channel Scan pending"); network_info->scan_pending = TRUE; -#if defined TIZEN_DA + full_scan_cb_timer = g_timeout_add_seconds(10, __check_full_scan_callback, (void *)network_info); -#endif /* TIZEN_DA */ } else if (bssid_scan_info->flag == TRUE) { WIFI_LOG(WIFI_INFO, "BSSID Scan pending"); network_info->scan_pending = TRUE; -#if defined TIZEN_DA + bssid_scan_cb_timer = g_timeout_add_seconds(10, __check_bssid_scan_callback, (void *)network_info); -#endif /* TIZEN_DA */ } -#if defined TIZEN_DA wifi_manager_scan_state_e scan_state = WIFI_MANAGER_SCAN_STATE_SCANNING; event_data->Event = NET_EVENT_WIFI_SCAN_CHANGED; event_data->Data = &scan_state; @@ -705,7 +693,6 @@ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer __NETWORK_FUNC_EXIT__; return; -#endif /* TIZEN_DA */ } else if (Error != NET_ERR_NONE) { WIFI_LOG(WIFI_ERROR, "Scan failed. Error [%d]", Error); @@ -2423,12 +2410,10 @@ static void __net_specific_scan_request_reply(GObject *source_object, GAsyncResu if (reply) g_variant_unref(reply); -#if defined TIZEN_DA if (specific_scan_cb_timer > 0) { g_source_remove(specific_scan_cb_timer); specific_scan_cb_timer = 0; } -#endif /* TIZEN_DA */ request_table = network_info->request_table; @@ -2437,9 +2422,8 @@ static void __net_specific_scan_request_reply(GObject *source_object, GAsyncResu if (request_table[NETWORK_REQUEST_TYPE_SPECIFIC_SCAN].flag == TRUE) { WIFI_LOG(WIFI_INFO, "Specific Scan pending"); network_info->scan_pending = TRUE; -#if defined TIZEN_DA + specific_scan_cb_timer = g_timeout_add_seconds(10, __check_specific_scan_callback, (void *)network_info); -#endif /* TIZEN_DA */ } } else if (Error != NET_ERR_NONE) { WIFI_LOG(WIFI_ERROR, "Specific Scan failed. Error [%d]", Error); @@ -4398,12 +4382,10 @@ static void __net_multi_scan_request_reply(GObject *source_object, GAsyncResult if (reply) g_variant_unref(reply); -#if defined TIZEN_DA if (multi_scan_cb_timer > 0) { g_source_remove(multi_scan_cb_timer); multi_scan_cb_timer = 0; } -#endif /* TIZEN_DA */ request_table = network_info->request_table; @@ -4412,9 +4394,8 @@ static void __net_multi_scan_request_reply(GObject *source_object, GAsyncResult if (request_table[NETWORK_REQUEST_TYPE_MULTI_SCAN].flag == TRUE) { WIFI_LOG(WIFI_INFO, "Multi Scan pending"); network_info->scan_pending = TRUE; -#if defined TIZEN_DA + multi_scan_cb_timer = g_timeout_add_seconds(10, __check_multi_scan_callback, (void *)network_info); -#endif /* TIZEN_DA */ } } else if (Error != NET_ERR_NONE) { WIFI_LOG(WIFI_ERROR, "Multi Scan failed. Error [%d]", Error); diff --git a/src/network_interface.c b/src/network_interface.c index f96235b..af602dd 100644 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -28,15 +28,12 @@ #define DBUS_OBJECT_PATH_MAX 150 -#if defined TIZEN_DA - extern __thread guint connection_cb_timer; extern __thread guint full_scan_cb_timer; extern __thread guint specific_scan_cb_timer; extern __thread guint multi_scan_cb_timer; extern __thread guint bssid_scan_cb_timer; -#endif /* TIZEN_DA */ //LCOV_EXCL_START static int __net_check_get_privilege(network_info_s *network_info) @@ -2205,7 +2202,6 @@ int net_wifi_power_off(network_info_s *network_info) return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE } -#if defined TIZEN_DA if (connection_cb_timer > 0) { g_source_remove(connection_cb_timer); connection_cb_timer = 0; @@ -2227,7 +2223,6 @@ int net_wifi_power_off(network_info_s *network_info) g_source_remove(bssid_scan_cb_timer); bssid_scan_cb_timer = 0; } -#endif /* TIZEN_DA */ if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SCAN]), diff --git a/src/network_signal.c b/src/network_signal.c index ead76a9..a3e5c4b 100644 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -27,15 +27,12 @@ #define NET_WPS_EI_OPERATION_FAILED 1 #define NET_WPS_EI_SECURITY_WEP_PROHIBITED 2 -#if defined TIZEN_DA - extern __thread guint connection_cb_timer; extern __thread guint full_scan_cb_timer; extern __thread guint specific_scan_cb_timer; extern __thread guint multi_scan_cb_timer; extern __thread guint bssid_scan_cb_timer; -#endif /* TIZEN_DA */ struct cs_tid_info { int tid; @@ -49,9 +46,6 @@ struct cs_tid_info { static GSList *cs_tid_list = NULL; -#if !defined TIZEN_DA -static int __net_dbus_get_bssid_list(); -#endif /* !TIZEN_DA */ static int __net_dbus_get_technology_states(network_info_s *network_info); //LCOV_EXCL_START @@ -644,12 +638,12 @@ static void __net_handle_failure_ind(network_info_s *network_info, if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE && strstr(profile_info->ProfileName, svc_name1) != NULL) { -#if defined TIZEN_DA + if (connection_cb_timer > 0) { g_source_remove(connection_cb_timer); connection_cb_timer = 0; } -#endif /* TIZEN_DA */ + memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0, sizeof(network_request_table_s)); @@ -727,12 +721,12 @@ static void __net_handle_disconnect_ind(network_info_s *network_info, if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE && strstr(profile_info->ProfileName, svc_name2) != NULL) { -#if defined TIZEN_DA + if (connection_cb_timer > 0) { g_source_remove(connection_cb_timer); connection_cb_timer = 0; } -#endif /* TIZEN_DA */ + memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0, sizeof(network_request_table_s)); @@ -835,7 +829,6 @@ static int __net_handle_service_state_changed(network_info_s *network_info, if (old_state == new_state) return Error; -#if defined TIZEN_DA /* * Send connection state callback to upper layer. * This problem is that the target does not send the connection state callback to upper layer if its usb module is reattaced. @@ -844,7 +837,6 @@ static int __net_handle_service_state_changed(network_info_s *network_info, if ((old_state == NET_STATE_TYPE_READY || old_state == NET_STATE_TYPE_ONLINE) && new_state == NET_STATE_TYPE_CONFIGURATION) return Error; -#endif /* TIZEN_DA */ network_info->service_state = new_state; @@ -877,12 +869,12 @@ static int __net_handle_service_state_changed(network_info_s *network_info, if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE && strstr(sig_path, svc_name1) != NULL) { -#if defined TIZEN_DA + if (connection_cb_timer > 0) { g_source_remove(connection_cb_timer); connection_cb_timer = 0; } -#endif /* TIZEN_DA */ + memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0, sizeof(network_request_table_s)); @@ -1032,7 +1024,7 @@ static int __net_handle_scan_done(network_info_s *network_info, GVariant *param) if (network_info->scan_pending == TRUE) { net_err_e Error = NET_ERR_NONE; network_info->scan_pending = FALSE; -#if defined TIZEN_DA + if (full_scan_cb_timer > 0) { g_source_remove(full_scan_cb_timer); full_scan_cb_timer = 0; @@ -1049,7 +1041,6 @@ static int __net_handle_scan_done(network_info_s *network_info, GVariant *param) g_source_remove(bssid_scan_cb_timer); bssid_scan_cb_timer = 0; } -#endif /* TIZEN_DA */ int current_scan_type = -1; if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) @@ -1462,12 +1453,11 @@ static int __net_handle_wifi_connect_fail_event(network_info_s *network_info, WIFI_LOG(WIFI_ERROR, "Failed to connect WiFi"); if (open_info->flag == TRUE) { -#if defined TIZEN_DA if (connection_cb_timer > 0) { g_source_remove(connection_cb_timer); connection_cb_timer = 0; } -#endif /* TIZEN_DA */ + memset(open_info, 0, sizeof(network_request_table_s)); event_data->Error = NET_ERR_INVALID_OPERATION; event_data->Event = NET_EVENT_OPEN_RSP; @@ -2163,11 +2153,7 @@ static int __net_get_tech_states(network_info_s *network_info, GVariant *message return Error; } -#if defined TIZEN_DA int __net_dbus_get_bssid_list(network_info_s *network_info) -#else -static int __net_dbus_get_bssid_list(network_info_s *network_info) -#endif /* !TIZEN_DA */ { __NETWORK_FUNC_ENTER__; @@ -2450,10 +2436,8 @@ void _net_deregister_signal(network_info_s *network_info) network_info->subscribe_id_connman_roaming); g_dbus_connection_signal_unsubscribe(network_info->connection, network_info->subscribe_id_netconfig_wifi); -#if defined TIZEN_DA g_dbus_connection_signal_unsubscribe(network_info->connection, network_info->subscribe_id_connman_dhcp); -#endif /* TIZEN_DA */ } __NETWORK_FUNC_EXIT__; diff --git a/src/network_signal.h b/src/network_signal.h index 2a49513..57fad1e 100644 --- a/src/network_signal.h +++ b/src/network_signal.h @@ -31,9 +31,7 @@ int _net_init_service_state(network_info_s *network_info); void _net_set_cs_tid(network_info_s *network_info, int tid); void _net_unset_cs_tid(int tid); -#if defined TIZEN_DA int __net_dbus_get_bssid_list(network_info_s *network_info); -#endif /* TIZEN_DA */ #ifdef __cplusplus } diff --git a/src/wifi_internal.c b/src/wifi_internal.c index 0696213..0858865 100644 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -674,7 +674,6 @@ static void __state_changed_cb(wifi_manager_handle_s *wifi_handle, char *profile last_prof_info.bssid_list = NULL; } -#if defined TIZEN_DA /* * Fix connection callback issue. * It ignore configuration state after disconnection state in connection_state_changed_cb. @@ -687,7 +686,6 @@ static void __state_changed_cb(wifi_manager_handle_s *wifi_handle, char *profile } last_state = state; -#endif /* TIZEN_DA */ WIFI_LOG(WIFI_INFO, "%s state changed : %s", profile_name, __convert_ap_state_to_string(state)); @@ -1331,7 +1329,6 @@ static void _wifi_evt_cb(net_event_info_s *event_cb, void *user_data) if ((_wifi_check_profile_name_validity(event_cb->ProfileName) != true) && (event_cb->Error != NET_ERR_CONNECTION_CONNECT_FAILED) && -#if defined TIZEN_DA /* * Send the connection callback to upper layer when specific failure case. * It has the problem that does not connection callback to wifi-manager @@ -1339,7 +1336,6 @@ static void _wifi_evt_cb(net_event_info_s *event_cb, void *user_data) */ (event_cb->Error != NET_ERR_INVALID_OPERATION) && -#endif /* TIZEN_DA */ (event_cb->Error != NET_ERR_CONNECTION_WPS_TIMEOUT) && (event_cb->Error != @@ -1583,14 +1579,12 @@ static void _wifi_evt_cb(net_event_info_s *event_cb, void *user_data) case NET_EVENT_WIFI_ROAM_STATE_IND: __roaming_state_changed_cb(wifi_handle, (net_roam_event_info_s *)event_cb->Data); break; -#if defined TIZEN_DA case NET_EVENT_WIFI_TIMEOUT_RSP: result = __convert_to_ap_error_type(event_cb->Error); WIFI_LOG(WIFI_ERROR, "Connection close error %s", __convert_ap_error_type_to_string(result)); __connected_cb(wifi_handle, result); break; -#endif /* TIZEN_DA */ case NET_EVENT_WIFI_DHCP_STATE_IND: { net_event_e err = event_cb->Error; -- 2.7.4 From c029a709a5fadb700497aab2b47118f033a5f3a1 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Wed, 15 Feb 2023 12:02:58 +0900 Subject: [PATCH 07/16] Clear all callback timers when deinit Change-Id: I4bbd9d2e34378842ff5039552ac9795e5ba2f62a Signed-off-by: Jaehyun Kim --- src/network_interface.c | 51 +++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/network_interface.c b/src/network_interface.c index af602dd..28ee41b 100644 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -1277,6 +1277,34 @@ static int __net_extract_connected_profile(network_info_s *network_info, return err; } +static void _net_clear_cb_timers(void) +{ + if (connection_cb_timer > 0) { + g_source_remove(connection_cb_timer); + connection_cb_timer = 0; + } + + if (full_scan_cb_timer > 0) { + g_source_remove(full_scan_cb_timer); + full_scan_cb_timer = 0; + } + + if (specific_scan_cb_timer > 0) { + g_source_remove(specific_scan_cb_timer); + specific_scan_cb_timer = 0; + } + + if (multi_scan_cb_timer > 0) { + g_source_remove(multi_scan_cb_timer); + multi_scan_cb_timer = 0; + } + + if (bssid_scan_cb_timer > 0) { + g_source_remove(bssid_scan_cb_timer); + bssid_scan_cb_timer = 0; + } +} + void net_forget_ap_finished(network_info_s *network_info, net_err_e Error) { __NETWORK_FUNC_ENTER__; @@ -2202,27 +2230,7 @@ int net_wifi_power_off(network_info_s *network_info) return NET_ERR_IN_PROGRESS; //LCOV_EXCL_LINE } - if (connection_cb_timer > 0) { - g_source_remove(connection_cb_timer); - connection_cb_timer = 0; - } - - if (full_scan_cb_timer > 0) { - g_source_remove(full_scan_cb_timer); - full_scan_cb_timer = 0; - } - if (specific_scan_cb_timer > 0) { - g_source_remove(specific_scan_cb_timer); - specific_scan_cb_timer = 0; - } - if (multi_scan_cb_timer > 0) { - g_source_remove(multi_scan_cb_timer); - multi_scan_cb_timer = 0; - } - if (bssid_scan_cb_timer > 0) { - g_source_remove(bssid_scan_cb_timer); - bssid_scan_cb_timer = 0; - } + _net_clear_cb_timers(); if (network_info->request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) memset(&(network_info->request_table[NETWORK_REQUEST_TYPE_SCAN]), @@ -2944,6 +2952,7 @@ void net_deregister_client_ext(network_info_s *network_info) network_info->user_data = NULL; network_info->wifi_handle = NULL; + _net_clear_cb_timers(); _net_deregister_signal(network_info); _net_dbus_close_gdbus_call(network_info); _net_clear_request_table(network_info); -- 2.7.4 From 951c46bf2dff61681e35e130b4f308b35ce67a10 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 25 Jul 2023 18:20:04 +0900 Subject: [PATCH 08/16] Support multiple interfaces in test app Change-Id: I666bbab6d8534b4318fd03a435231e002d115393 Signed-off-by: Jaehyun Kim --- tools/manager-test/wman_test_main.c | 46 +++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/tools/manager-test/wman_test_main.c b/tools/manager-test/wman_test_main.c index 4fc185f..347057b 100644 --- a/tools/manager-test/wman_test_main.c +++ b/tools/manager-test/wman_test_main.c @@ -168,9 +168,19 @@ static void __test_dhcp_changed_callback(wifi_manager_dhcp_state_e state, wifi_m (char *)user_data, state, wman_test_strerror(error_code)); } -int wman_test_init(void) +int wman_test_init(const char *ifname) { - int rv = wifi_manager_initialize(&wifi); + int rv; + + if (wifi || wifi2) { + printf("Already initialized\n"); + return -1; + } + + if (!ifname) + rv = wifi_manager_initialize(&wifi); + else + rv = wifi_manager_initialize_with_interface_name(&wifi, ifname); if (rv == WIFI_MANAGER_ERROR_NONE) { wifi_manager_set_device_state_changed_cb(wifi, __test_device_state_callback, "1"); @@ -190,7 +200,10 @@ int wman_test_init(void) return -1; } - rv = wifi_manager_initialize(&wifi2); + if (!ifname) + rv = wifi_manager_initialize(&wifi2); + else + rv = wifi_manager_initialize_with_interface_name(&wifi2, ifname); if (rv == WIFI_MANAGER_ERROR_NONE) { wifi_manager_set_device_state_changed_cb(wifi2, __test_device_state_callback, "2"); @@ -203,6 +216,8 @@ int wman_test_init(void) wifi_manager_set_dhcp_state_changed_cb(wifi2, __test_dhcp_changed_callback, "2"); } else { printf("[2] Wifi init failed [%s]\n", wman_test_strerror(rv)); + wifi_manager_deinitialize(wifi); + wifi = NULL; return -1; } @@ -219,6 +234,8 @@ int wman_test_deinit(void) return -1; } + wifi = NULL; + rv = wifi_manager_deinitialize(wifi2); if (rv != WIFI_MANAGER_ERROR_NONE) { @@ -226,10 +243,27 @@ int wman_test_deinit(void) return -1; } + wifi2 = NULL; + printf("Wifi deinit succeeded\n"); return 1; } +int wman_test_init_with_ifname(void) +{ + int rv; + char ifname[33] = { 0, }; + + printf("Input interface name: "); + rv = scanf(" %32[^\n]s", ifname); + if (rv < 1) + return -1; + + rv = wman_test_init(ifname); + + return rv; +} + gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) { int rv; @@ -254,6 +288,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("Options..\n"); printf(LOG_BLUE "[Public APIs]\n" LOG_END); printf(LOG_GREEN "1 - Wi-Fi init and set callbacks\n" LOG_END); + printf(": - Wi-Fi init and set callbacks with interface name\n"); printf("2 - Wi-Fi deinit(unset callbacks automatically)\n"); printf(LOG_GREEN "3 - Activate Wi-Fi device\n" LOG_END); printf("4 - Deactivate Wi-Fi device\n"); @@ -338,7 +373,10 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) switch (a[0]) { /* Public API */ case '1': - rv = wman_test_init(); + rv = wman_test_init(NULL); + break; + case ':': + rv = wman_test_init_with_ifname(); break; case '2': rv = wman_test_deinit(); -- 2.7.4 From 5844348c8b220fabdba2d2f3b1a581169a669a8b Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Fri, 8 Sep 2023 15:46:35 +0900 Subject: [PATCH 09/16] Added CAPI to check for 6Ghz band support Change-Id: Ibb229a514d42ce84a4bcc173de24f87e65fba139 Signed-off-by: Jaehyun Kim --- include/wifi-manager.h | 18 ++++++++++++++++++ src/network_dbus.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/network_dbus.h | 1 + src/network_interface.c | 19 +++++++++++++++++++ src/network_interface.h | 1 + src/wifi_internal.c | 15 +++++++++++++++ src/wifi_internal.h | 1 + src/wifi_manager.c | 22 ++++++++++++++++++++++ 8 files changed, 122 insertions(+) mode change 100644 => 100755 include/wifi-manager.h mode change 100644 => 100755 src/network_dbus.c mode change 100644 => 100755 src/network_dbus.h diff --git a/include/wifi-manager.h b/include/wifi-manager.h old mode 100644 new mode 100755 index 7771739..780169f --- a/include/wifi-manager.h +++ b/include/wifi-manager.h @@ -4458,6 +4458,24 @@ int wifi_manager_get_ip_conflict_state(wifi_manager_h wifi, int wifi_manager_is_5ghz_band_supported(wifi_manager_h wifi, bool *supported); /** + * @brief Gets whether 6Ghz Wi-Fi band is supported. + * @since_tizen 8.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @param[in] wifi The Wi-Fi handle + * @param[out] supported @c true if 6Ghz Wi-Fi band is supported, + * otherwise @c false if 6Ghz Wi-Fi band is not supported. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized + * @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_is_6ghz_band_supported(wifi_manager_h wifi, bool *supported); + +/** * @} */ diff --git a/src/network_dbus.c b/src/network_dbus.c old mode 100644 new mode 100755 index 42b96ba..85128ec --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -2788,6 +2788,51 @@ int _net_dbus_get_5ghz_support(network_info_s *network_info, gboolean *supported return Error; } +int _net_dbus_get_6ghz_support(network_info_s *network_info, gboolean *supported) +{ + __NETWORK_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + GVariant *message = NULL; + GVariant *value = NULL; + GVariantIter *iter = NULL; + gchar *key = NULL; + gboolean is_6ghz_supported = FALSE; + + message = _net_invoke_dbus_method(network_info, + CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX, + CONNMAN_TECHNOLOGY_INTERFACE, "Get6GHzSupported", + NULL, &Error); + if (message == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to get technology properties"); + + __NETWORK_FUNC_EXIT__; + return Error; + } + + g_variant_get(message, "(a{sv})", &iter); + + while (g_variant_iter_loop(iter, "{sv}", &key, &value)) { + if (g_strcmp0(key, network_info->interface_name) == 0) { + is_6ghz_supported = g_variant_get_boolean(value); + g_variant_unref(value); + g_free(key); + break; + } + } + + *supported = is_6ghz_supported; + + WIFI_LOG(WIFI_INFO, "Successfully get 6GHz band supported: %d, ifname: %s", + *supported, network_info->interface_name); + + g_variant_iter_free(iter); + g_variant_unref(message); + + __NETWORK_FUNC_EXIT__; + return Error; +} + int _net_dbus_get_auto_connect_mode(network_info_s *network_info, int *connect_mode) { diff --git a/src/network_dbus.h b/src/network_dbus.h old mode 100644 new mode 100755 index 19f3d93..1ba146d --- a/src/network_dbus.h +++ b/src/network_dbus.h @@ -202,6 +202,7 @@ int _net_dbus_wifi_set_autoconnect(network_info_s *network_info, int _net_dbus_wifi_get_autoconnect(network_info_s *network_info, const char *profile_name, gboolean *autoconnect); int _net_dbus_get_5ghz_support(network_info_s *network_info, gboolean *supported); +int _net_dbus_get_6ghz_support(network_info_s *network_info, gboolean *supported); int _net_dbus_set_ip_conflict_period(network_info_s *network_info, unsigned int initial_time); int _net_dbus_dpp_enter_peer_uri(network_info_s *network_info, diff --git a/src/network_interface.c b/src/network_interface.c index 28ee41b..0fa4bd8 100644 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -2007,6 +2007,25 @@ EXPORT_API int net_wifi_get_5ghz_support(network_info_s *network_info, gboolean return NET_ERR_NONE; } +EXPORT_API int net_wifi_get_6ghz_support(network_info_s *network_info, gboolean *supported) +{ + __NETWORK_CAPI_FUNC_ENTER__; + + net_err_e Error = NET_ERR_NONE; + + if ((Error = _net_dbus_get_6ghz_support(network_info, supported)) != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, + "Failed to get 6 GHz band supported. Error [%s]", + _net_print_error(Error)); + + __NETWORK_CAPI_FUNC_EXIT__; + return Error; + } + + __NETWORK_CAPI_FUNC_EXIT__; + return NET_ERR_NONE; +} + EXPORT_API int net_wifi_get_auto_connect_mode(network_info_s *network_info, int *connect_mode) { diff --git a/src/network_interface.h b/src/network_interface.h index f0b0a61..74f2907 100644 --- a/src/network_interface.h +++ b/src/network_interface.h @@ -384,6 +384,7 @@ int net_wifi_get_ip_conflict_period(network_info_s *network_info, wifi_tech_state_e net_get_technology_state(network_info_s *network_info); int net_get_service_state(network_info_s *network_info); int net_wifi_get_5ghz_support(network_info_s *network_info, gboolean *supported); +int net_wifi_get_6ghz_support(network_info_s *network_info, gboolean *supported); int net_dpp_enter_peer_uri(network_info_s *network_info, guint32 peer_id, guint32 own_id, const char *uri); diff --git a/src/wifi_internal.c b/src/wifi_internal.c index 0858865..8dbe608 100644 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -2576,6 +2576,21 @@ int _wifi_get_5ghz_support(wifi_manager_h wifi, bool *supported) return rv; } +int _wifi_get_6ghz_support(wifi_manager_h wifi, bool *supported) +{ + int rv = NET_ERR_NONE; + wifi_manager_handle_s *wifi_handle = wifi; + gboolean is_supported = FALSE; + + rv = net_wifi_get_6ghz_support(wifi_handle->network_info, &is_supported); + rv = __convert_to_ap_error_type(rv); + + if (rv != WIFI_MANAGER_ERROR_NONE) + WIFI_LOG(WIFI_ERROR, "Failed to get 6 GHz band supported"); + + *supported = is_supported; + return rv; +} int _wifi_set_ap_auto_connect(wifi_manager_ap_h ap, bool autoconnect) { diff --git a/src/wifi_internal.h b/src/wifi_internal.h index 5cef866..9f7ef54 100644 --- a/src/wifi_internal.h +++ b/src/wifi_internal.h @@ -524,6 +524,7 @@ typedef enum { extern tizen_profile_t _get_tizen_profile(); int _wifi_get_service_state(wifi_manager_handle_s *wifi_handle); int _wifi_get_5ghz_support(wifi_manager_h wifi, bool *supported); +int _wifi_get_6ghz_support(wifi_manager_h wifi, bool *supported); /* WIFI DPP */ diff --git a/src/wifi_manager.c b/src/wifi_manager.c index 6fdd4d2..4394943 100644 --- a/src/wifi_manager.c +++ b/src/wifi_manager.c @@ -363,6 +363,28 @@ EXPORT_API int wifi_manager_is_5ghz_band_supported(wifi_manager_h wifi, bool *su return rv; } +EXPORT_API int wifi_manager_is_6ghz_band_supported(wifi_manager_h wifi, bool *supported) +{ + __NETWORK_CAPI_FUNC_ENTER__; + + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + int rv; + + RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__); + + if (supported == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE + __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + + rv = _wifi_get_6ghz_support(wifi, supported); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} + EXPORT_API int wifi_manager_is_activated(wifi_manager_h wifi, bool *activated) { __NETWORK_CAPI_FUNC_ENTER__; -- 2.7.4 From 361678b1310144b7217b006d4b41ea059847e01d Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Fri, 8 Sep 2023 16:48:09 +0900 Subject: [PATCH 10/16] Support NoCarrier error type When requesting a scan, if the wifi is down in another module, a NoCarrier error may occur depending on the timing. There is a need to handle this separately in the APP, so an error type is added. Change-Id: I89ed7c84a9e177a36596949c5460b720f0aaf4fb Signed-off-by: Jaehyun Kim --- include/wifi-manager.h | 5 +++++ src/network_dbus.c | 2 +- src/network_error.h | 3 ++- src/wifi_internal.c | 29 ++++++++++++----------------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/wifi-manager.h b/include/wifi-manager.h index 780169f..7eeba5c 100755 --- a/include/wifi-manager.h +++ b/include/wifi-manager.h @@ -187,6 +187,11 @@ typedef enum { * Association failed (Since 7.0) */ WIFI_MANAGER_ERROR_ASSOCIATION_FAILED = TIZEN_ERROR_WIFI_MANAGER|0x15, + + /** + * The wireless device is unavailable (Since 8.0) + */ + WIFI_MANAGER_ERROR_NO_CARRIER = TIZEN_ERROR_WIFI_MANAGER|0x16, } wifi_manager_error_e; diff --git a/src/network_dbus.c b/src/network_dbus.c index 85128ec..b628ac4 100755 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -71,7 +71,7 @@ static int __net_error_string_to_enum(const char *error) else if (NULL != strstr(error, "NotFound")) return NET_ERR_NOT_SUPPORTED; else if (NULL != strstr(error, "NoCarrier")) - return NET_ERR_NOT_SUPPORTED; + return NET_ERR_WIFI_NO_CARRIER; else if (NULL != strstr(error, "InProgress")) return NET_ERR_IN_PROGRESS; else if (NULL != strstr(error, "AlreadyExists")) diff --git a/src/network_error.h b/src/network_error.h index af6afd7..ba1e6cd 100644 --- a/src/network_error.h +++ b/src/network_error.h @@ -59,7 +59,8 @@ typedef enum { NET_ERR_SECURITY_RESTRICTED = -790, /** Operation is restricted */ NET_ERR_ALREADY_EXISTS = -789, /** Already exists */ NET_ERR_NO_PROFILE = -788, /** There is no profile */ - NET_ERR_OUT_OF_MEMORY = -787, /** Failed to allocate memory */ + NET_ERR_OUT_OF_MEMORY = -787, /** Failed to allocate memory */ + NET_ERR_WIFI_NO_CARRIER = -786, /** The wireless device is unavailable */ /** WiFi driver on/off failed */ NET_ERR_WIFI_DRIVER_FAILURE = -699, diff --git a/src/wifi_internal.c b/src/wifi_internal.c index 8dbe608..52f4f22 100644 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -70,6 +70,8 @@ static wifi_manager_error_e __convert_to_ap_error_type(net_err_e err_type) case NET_ERR_ACTIVE_CONNECTION_EXISTS: case NET_ERR_ALREADY_EXISTS: return WIFI_MANAGER_ERROR_ALREADY_EXISTS; + case NET_ERR_WIFI_NO_CARRIER: + return WIFI_MANAGER_ERROR_NO_CARRIER; /*Connection Failure Error Codes*/ case NET_ERR_CONNECTION_OUT_OF_RANGE: return WIFI_MANAGER_ERROR_OUT_OF_RANGE; @@ -840,12 +842,10 @@ static void __set_multi_scan_cb(wifi_manager_handle_s *wifi_handle, static void __scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb, bool is_requested) { - wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE; + wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error); - if (event_cb->Error != NET_ERR_NONE) { + if (error_code != WIFI_MANAGER_ERROR_NONE) WIFI_LOG(WIFI_ERROR, "Scan failed[%d]", event_cb->Error); - error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED; - } if (wifi_handle->scan_request_cb) { wifi_handle->scan_request_cb(error_code, wifi_handle->scan_request_user_data); @@ -873,13 +873,12 @@ static void __scan_changed_cb(wifi_manager_handle_s *wifi_handle, wifi_manager_s static void __specific_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb) { - wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE; + wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error); __clear_profile_list(&(wifi_handle->specific_profile_iterator)); - if (event_cb->Error != NET_ERR_NONE) { + if (error_code != WIFI_MANAGER_ERROR_NONE) { WIFI_LOG(WIFI_ERROR, "Specific scan failed!, Error [%d]", event_cb->Error); - error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED; } else if (event_cb->Data) { __update_specific_iterator(wifi_handle, (GSList *)event_cb->Data); WIFI_LOG(WIFI_INFO, "Specific AP count : %d", @@ -895,14 +894,13 @@ static void __specific_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_inf static void __bssid_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb) { - wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE; + wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error); __clear_profile_list(&(wifi_handle->bss_profile_iterator)); - if (event_cb->Error != NET_ERR_NONE) { + if (error_code != WIFI_MANAGER_ERROR_NONE) { WIFI_LOG(WIFI_ERROR, "BSSID scan failed!, Error [%d]", event_cb->Error); - error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED; } else if (event_cb->Data) { __update_bss_profile_iterator(wifi_handle, (GSList *)event_cb->Data); WIFI_LOG(WIFI_INFO, "BSS AP count : %d", @@ -944,14 +942,13 @@ static void __ip_conflict_cb(wifi_manager_handle_s *wifi_handle, net_event_info_ static void __netlink_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb) { - wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE; + wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error); __clear_profile_list(&(wifi_handle->bss_profile_iterator)); - if (event_cb->Error != NET_ERR_NONE) { + if (error_code != WIFI_MANAGER_ERROR_NONE) { WIFI_LOG(WIFI_ERROR, "NETLINK scan failed!, Error [%d]", event_cb->Error); - error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED; } else if (event_cb->Data) { __update_netlink_scan_profile_iterator(wifi_handle, (GSList *)event_cb->Data); WIFI_LOG(WIFI_INFO, "BSS AP count : %d", @@ -967,12 +964,10 @@ static void __netlink_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info static void __multi_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb) { - wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE; + wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error); - if (event_cb->Error != NET_ERR_NONE) { + if (error_code != WIFI_MANAGER_ERROR_NONE) WIFI_LOG(WIFI_ERROR, "Multi Scan failed[%d]", event_cb->Error); - error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED; - } if (wifi_handle->multi_scan_cb) wifi_handle->multi_scan_cb(error_code, wifi_handle->multi_scan_user_data); -- 2.7.4 From 8ce1977c079446d547588afc4b1eae88f4c35dc7 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 12 Sep 2023 17:56:29 +0900 Subject: [PATCH 11/16] Update test app to support new API Change-Id: Ie344986c681ced7b4fc5e66ff8c34969b1774b01 Signed-off-by: Jaehyun Kim --- tools/manager-test/wman_test_extension.c | 16 +++++++++++++--- tools/manager-test/wman_test_extension.h | 2 +- tools/manager-test/wman_test_main.c | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/manager-test/wman_test_extension.c b/tools/manager-test/wman_test_extension.c index 6a29433..7e7fd53 100644 --- a/tools/manager-test/wman_test_extension.c +++ b/tools/manager-test/wman_test_extension.c @@ -701,7 +701,7 @@ int wman_test_get_connection_mode(wifi_manager_h wifi) return 1; } -int wman_test_get_5ghz_band_supported(wifi_manager_h wifi) +int wman_test_get_5_6_ghz_band_supported(wifi_manager_h wifi) { int rv; bool supported; @@ -709,11 +709,21 @@ int wman_test_get_5ghz_band_supported(wifi_manager_h wifi) rv = wifi_manager_is_5ghz_band_supported(wifi, &supported); if (rv != WIFI_MANAGER_ERROR_NONE) { - printf("Fail to get 5ghz supported, rv = %d\n", rv); + printf("Fail to get 5GHz supported, rv = %d\n", rv); return 1; } - printf("Is 5Ghz supported = [%s]\n", supported ? "yes" : "no"); + printf("Is 5GHz supported = [%s]\n", supported ? "yes" : "no"); + + rv = wifi_manager_is_6ghz_band_supported(wifi, &supported); + + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get 6GHz supported, rv = %d\n", rv); + return 1; + } + + printf("Is 6GHz supported = [%s]\n", supported ? "yes" : "no"); + return 1; } diff --git a/tools/manager-test/wman_test_extension.h b/tools/manager-test/wman_test_extension.h index e2af2f4..824b29f 100644 --- a/tools/manager-test/wman_test_extension.h +++ b/tools/manager-test/wman_test_extension.h @@ -35,7 +35,7 @@ int wman_test_netlink_scan(wifi_manager_h wifi); int wman_test_get_passpoint_state(wifi_manager_h wifi); int wman_test_set_passpoint_enable(wifi_manager_h wifi); int wman_test_get_connection_mode(wifi_manager_h wifi); -int wman_test_get_5ghz_band_supported(wifi_manager_h wifi); +int wman_test_get_5_6_ghz_band_supported(wifi_manager_h wifi); int wman_test_set_mac_policy(wifi_manager_h wifi); int wman_test_set_preassoc_mac_policy(wifi_manager_h wifi); int wman_test_set_random_mac_lifetime(wifi_manager_h wifi); diff --git a/tools/manager-test/wman_test_main.c b/tools/manager-test/wman_test_main.c index 347057b..b44218d 100644 --- a/tools/manager-test/wman_test_main.c +++ b/tools/manager-test/wman_test_main.c @@ -350,7 +350,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("W - Get passpoint state\n"); printf("X - Set passpoint on/off\n"); printf("Y - Get Access Point Hardware Mode\n"); - printf("Z - Get 5Ghz supported\n"); + printf("Z - Get 5Ghz/6Ghz supported\n"); printf("! - Set mac policy\n"); printf("@ - Set preassoc mac policy\n"); printf("# - Set random mac lifetime\n"); @@ -558,7 +558,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) rv = wman_test_get_connection_mode(wifi); break; case 'Z': - rv = wman_test_get_5ghz_band_supported(wifi); + rv = wman_test_get_5_6_ghz_band_supported(wifi); break; case '!': rv = wman_test_set_mac_policy(wifi); -- 2.7.4 From 6d8e67ab9a228b8a723004c3eeb3d2118257bc9c Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Fri, 15 Sep 2023 11:39:11 +0900 Subject: [PATCH 12/16] Update unittest to fit changed error policy Change-Id: Ib0b7146443e53157cb89262b971601d2d37a34e4 Signed-off-by: Jaehyun Kim --- tests/gtest-wifi-manager-scan.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/gtest-wifi-manager-scan.cpp b/tests/gtest-wifi-manager-scan.cpp index 84087ce..7e8c09a 100755 --- a/tests/gtest-wifi-manager-scan.cpp +++ b/tests/gtest-wifi-manager-scan.cpp @@ -169,7 +169,7 @@ TEST_F(UtcWifiManagerScan, GetScanN4) EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan(handle, scan_finished_cb, nullptr)); mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED); testUtil.runMainLoop(); - EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, g_nCallbackRet); + EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, g_nCallbackRet); } TEST_F(UtcWifiManagerScan, GetScanN5) @@ -229,7 +229,7 @@ TEST_F(UtcWifiManagerScan, GetSpecificN5) EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan_specific_ap(handle, &essid, scan_finished_cb, nullptr)); mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED); testUtil.runMainLoop(); - EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, g_nCallbackRet); + EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, g_nCallbackRet); } TEST_F(UtcWifiManagerScan, GetSpecificN6) @@ -449,7 +449,7 @@ TEST_F(UtcWifiManagerScan, ScanSpecificApN3) EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan_specific_ap(handle, "TEMP_AP1", scan_finished_cb, nullptr)); mock_set_gdbus_error_msg(ERROR_SECURITY_RESTRICTED); testUtil.runMainLoop(); - EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, g_nCallbackRet); + EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, g_nCallbackRet); } TEST_F(UtcWifiManagerScan, ScanSpecificApN4) -- 2.7.4 From 540e856ec20ff8e6e0d5b02a0c34915569dfa80a Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 19 Sep 2023 21:37:06 +0900 Subject: [PATCH 13/16] Support 6GHz band in RSSI level getter Change-Id: Ifc0caab6aebc0a96d4f0108d6bb423b1c9cee0ce Signed-off-by: Jaehyun Kim --- src/wifi_ap.c | 33 ++++++++++++++++++++++++++++++++- tests/mocks/mock_gdbus.c | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/wifi_ap.c b/src/wifi_ap.c index f00dcd1..2b59ab9 100644 --- a/src/wifi_ap.c +++ b/src/wifi_ap.c @@ -25,6 +25,8 @@ #include "wifi_internal.h" #define MAX_PREFIX_LENGTH 6 +#define FREQUENCY_5G_BASE 5000 +#define FREQUENCY_6G_BASE 5925 //LCOV_EXCL_START static char *__ap_convert_ip_to_string(net_addr_s *ip_addr, @@ -219,6 +221,33 @@ static wifi_manager_rssi_level_e __ap_convert_dbm_to_level_50(int rssi_dbm) return rssi_level; } +static wifi_manager_rssi_level_e __ap_convert_dbm_to_level_60(int rssi_dbm) +{ + wifi_manager_rssi_level_e rssi_level = WIFI_MANAGER_RSSI_LEVEL_0; + + /* Wi-Fi Signal Strength Display (for 6G (dB)) + * + * Excellent : ~ -72 + * Good : -73 ~ -77 + * Weak : -78 ~ -82 + * Very weak : -83 ~ -88 + * No signal : -89 ~ + */ + + if (rssi_dbm >= -72) + rssi_level = WIFI_MANAGER_RSSI_LEVEL_4; + else if (rssi_dbm >= -78) + rssi_level = WIFI_MANAGER_RSSI_LEVEL_3; + else if (rssi_dbm >= -83) + rssi_level = WIFI_MANAGER_RSSI_LEVEL_2; + else if (rssi_dbm >= -88) + rssi_level = WIFI_MANAGER_RSSI_LEVEL_1; + else + rssi_level = WIFI_MANAGER_RSSI_LEVEL_0; + + return rssi_level; +} + static bool _wifi_set_profile_name_to_ap(net_profile_info_s *ap_info) { char *profile_name = NULL; @@ -610,7 +639,9 @@ EXPORT_API int wifi_manager_ap_get_rssi_level(wifi_manager_ap_h ap, wifi_manager net_profile_info_s *profile_info = ap; rssi_dbm = (int)(profile_info->Strength - 120); - if (profile_info->frequency > 4900) + if (profile_info->frequency > FREQUENCY_6G_BASE) + *rssi_level = __ap_convert_dbm_to_level_60(rssi_dbm); + else if (profile_info->frequency > FREQUENCY_5G_BASE) *rssi_level = __ap_convert_dbm_to_level_50(rssi_dbm); else *rssi_level = __ap_convert_dbm_to_level_24(rssi_dbm); diff --git a/tests/mocks/mock_gdbus.c b/tests/mocks/mock_gdbus.c index ae02f11..6851b4c 100644 --- a/tests/mocks/mock_gdbus.c +++ b/tests/mocks/mock_gdbus.c @@ -298,6 +298,7 @@ method_call_reply_s g_dbus_reply[] = { {"CheckGetPrivilege", __get_mock_variant_int}, {"GetMaxScanSsid", __get_mock_variant_get_scanstate}, {"Get5GhzSupported", __get_mock_variant_get_scanstate}, + {"Get6GHzSupported", __get_mock_variant_get_scanstate}, {"ResumeBgscan", __get_mock_variant_string}, {"PauseBgscan", __get_mock_variant_string}, {"AddVsie", __get_mock_variant_string}, -- 2.7.4 From 37469c13851369291cefbfde400a2977012df18a Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 16 Oct 2023 16:05:09 +0900 Subject: [PATCH 14/16] Add logs to track the life cycle of config handle Change-Id: I6a0de755c0dec0cbb8eada297ef02ab2620737f8 Signed-off-by: Jaehyun Kim --- src/wifi_config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wifi_config.c b/src/wifi_config.c index fbc891a..fe6afae 100644 --- a/src/wifi_config.c +++ b/src/wifi_config.c @@ -96,6 +96,8 @@ EXPORT_API int wifi_manager_config_create(wifi_manager_h wifi, const char *name, _wifi_add_to_config_list(h); *config = h; + WIFI_LOG(WIFI_INFO, "Configuration handle created [%p]", h); + __NETWORK_CAPI_FUNC_EXIT__; return WIFI_MANAGER_ERROR_NONE; @@ -207,6 +209,8 @@ EXPORT_API int wifi_manager_config_destroy(wifi_manager_config_h config) return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE } + WIFI_LOG(WIFI_INFO, "Destroy Configuration handle [%p]", h); + _wifi_remove_from_config_list(config); destroy_wifi_config(h); -- 2.7.4 From e1f7aa67b67f748c4b9a9f8663c5b939254546f6 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Wed, 6 Dec 2023 14:21:44 +0900 Subject: [PATCH 15/16] Add freq/rssi info to AP list in the test app Change-Id: Iddbe495f717b38a320b3a4021bb1d18f91fb8d89 Signed-off-by: Jaehyun Kim --- tools/manager-test/wman_test_ap.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/manager-test/wman_test_ap.c b/tools/manager-test/wman_test_ap.c index 4ee4e95..b0a8f0c 100644 --- a/tools/manager-test/wman_test_ap.c +++ b/tools/manager-test/wman_test_ap.c @@ -68,6 +68,8 @@ static const char* __test_print_state(wifi_manager_connection_state_e state) static bool __test_found_ap_cb(wifi_manager_ap_h ap, void *user_data) { int rv = 0; + int frequency = 0; + int rssi = 0; char *ap_name = NULL; wifi_manager_connection_state_e state; @@ -84,7 +86,23 @@ static bool __test_found_ap_cb(wifi_manager_ap_h ap, void *user_data) return false; } - printf("AP name : %s, state : %s\n", ap_name, __test_print_state(state)); + rv = wifi_manager_ap_get_frequency(ap, &frequency); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get Frequency [%s]\n", wman_test_strerror(rv)); + free(ap_name); + return false; + } + + rv = wifi_manager_ap_get_rssi(ap, &rssi); + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get RSSI [%s]\n", wman_test_strerror(rv)); + free(ap_name); + return false; + } + + printf("AP name : %s, state : %s, frequency : %d, RSSI : %d\n", + ap_name, __test_print_state(state), frequency, rssi); + free(ap_name); return true; -- 2.7.4 From a09486976553cf2e4b33a5d1a53dcef3d1464184 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 19 Dec 2023 20:01:20 +0900 Subject: [PATCH 16/16] Fix parsing of invalid devices If there are multiple devices, the remaining devices are parsed even after the desired device is found, so there is a problem in that the last parsed value is used as the final value. Therefore, it has been modified to not parse other devices if parsing of the desired device is completed. Change-Id: I90b77c2797a543dd4451252573dbd67a7213aca6 Signed-off-by: Jaehyun Kim --- src/network_internal.c | 8 +++++++- src/network_signal.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/network_internal.c b/src/network_internal.c index b9b3606..024a411 100644 --- a/src/network_internal.c +++ b/src/network_internal.c @@ -272,8 +272,14 @@ int _net_get_tech_state(network_info_s *network_info, sdata = g_variant_get_string(dev_var, NULL); WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, sdata); - if (g_strcmp0(dev_key, "Ifname") == 0) + if (g_strcmp0(dev_key, "Ifname") == 0) { + if (find) { + g_variant_unref(dev_var); + g_free(dev_key); + break; + } find = g_strcmp0(sdata, network_info->interface_name) == 0 ? TRUE : FALSE; + } } else if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_BOOLEAN)) { bdata = g_variant_get_boolean(dev_var); WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, bdata ? "True" : "False"); diff --git a/src/network_signal.c b/src/network_signal.c index a3e5c4b..4f5410c 100644 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -2122,10 +2122,16 @@ static int __net_get_tech_states(network_info_s *network_info, GVariant *message sdata = g_variant_get_string(dev_var, NULL); WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, sdata); - if (g_strcmp0(dev_key, "Ifname") == 0) + if (g_strcmp0(dev_key, "Ifname") == 0) { + if (find) { + g_variant_unref(dev_var); + g_free(dev_key); + break; + } find = g_strcmp0(sdata, network_info->interface_name) == 0 ? TRUE : FALSE; - else if (find && g_strcmp0(dev_key, "MAC.Address") == 0) + } else if (find && g_strcmp0(dev_key, "MAC.Address") == 0) { g_strlcpy(network_info->mac_address, sdata, WIFI_MAC_ADDR_LEN + 1); + } } else if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_BOOLEAN)) { bdata = g_variant_get_boolean(dev_var); WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, bdata ? "True" : "False"); -- 2.7.4