diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn index 121d87b72..edcf1f20e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn @@ -28,7 +28,6 @@ local_base_sources = [ "sta_auto_connect_service.cpp", "sta_interface.cpp", "sta_monitor.cpp", - "sta_network_check.cpp", "sta_saved_device_appraisal.cpp", "sta_service.cpp", "sta_state_machine.cpp", @@ -156,7 +155,6 @@ if (defined(ohos_lite)) { "hilog:libhilog", "ipc:ipc_single", "netmanager_base:net_conn_manager_if", - "netstack:http_client", "samgr:samgr_proxy", ] diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/BUILD.gn index de103f760..626cb0b66 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/BUILD.gn @@ -38,6 +38,7 @@ local_base_sources = [ "net_helper/mac_address.cpp", "net_helper/network_interface.cpp", "net_helper/raw_socket.cpp", + "net_helper/sta_network_check.cpp", "utils/wifi_common_event_helper.cpp", "utils/wifi_encryption_util.cpp", "utils/wifi_global_func.cpp", @@ -49,6 +50,7 @@ local_base_include_dirs = [ "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/config", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta", "//commonlibrary/c_utils/base/include", "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", "$WIFI_ROOT_DIR/interfaces/inner_api", @@ -134,6 +136,7 @@ if (defined(ohos_lite)) { "eventhandler:libeventhandler", "hilog:libhilog", "huks:libhukssdk", + "netstack:http_client", ] if (defined(global_parts_info) && defined(global_parts_info.startup_init)) { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/sta_network_check.cpp similarity index 99% rename from wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check.cpp rename to wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/sta_network_check.cpp index 90d927bb1..d01e9bbb7 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/sta_network_check.cpp @@ -16,6 +16,10 @@ #include "sta_network_check.h" #include "wifi_logger.h" #include "wifi_settings.h" +#ifndef OHOS_ARCH_LITE +#include "http_client_request.h" +#include "http_client.h" +#endif DEFINE_WIFILOG_LABEL("StaNetworkCheck"); @@ -137,13 +141,7 @@ int StaNetworkCheck::HttpPortalDetection(const std::string &url) WIFI_LOGE("http create task failed !"); return -1; } - RegistHttpCallBack(task); - task->Start(); - return 0; -} -void StaNetworkCheck::RegistHttpCallBack(std::shared_ptr task) -{ task->OnSuccess([task, this](const NetStack::HttpClient::HttpClientRequest &request, const NetStack::HttpClient::HttpClientResponse &response) { std::string url = request.GetURL(); @@ -180,6 +178,9 @@ void StaNetworkCheck::RegistHttpCallBack(std::shared_ptrStart(); + return 0; } #endif void StaNetworkCheck::RunNetCheckThreadFunc() diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check.h b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/sta_network_check.h similarity index 94% rename from wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check.h rename to wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/sta_network_check.h index 72aa74dd9..2993c9d3e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/sta_network_check.h @@ -31,10 +31,6 @@ #include "arp_checker.h" #include "dns_checker.h" #include "wifi_internal_msg.h" -#ifndef OHOS_ARCH_LITE -#include "http_client_request.h" -#include "http_client.h" -#endif #define HTTP_DETECTION_TIMEOUT 10000 #define HTTP_BACKUP_TIMEOUT 3000 @@ -87,8 +83,6 @@ private: * */ int HttpPortalDetection(const std::string& url); - - void RegistHttpCallBack(std::shared_ptr task); #endif /** * @Description : NetCheck thread function diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn index db98575f6..b6880c029 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn @@ -37,7 +37,6 @@ ohos_unittest("wifi_sta_unittest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_auto_connect_service.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_monitor.cpp", - "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_saved_device_appraisal.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp", @@ -57,7 +56,6 @@ ohos_unittest("wifi_sta_unittest") { "sta_auto_connect_service_test.cpp", "sta_interface_test.cpp", "sta_monitor_test.cpp", - "sta_network_check_test.cpp", "sta_saved_device_appraisal_test.cpp", "sta_service_test.cpp", ] diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_network_check.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_network_check.cpp index 151ac6d24..5537e3573 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_network_check.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_network_check.cpp @@ -40,9 +40,5 @@ void MockStaNetworkCheck::SetHttpResultInfo(std::string url, int codeNum, int co { WIFI_LOGD("Enter SetHttpResultInfo::[%{public}s].", __FUNCTION__); } -void MockStaNetworkCheck::RegistHttpCallBack(std::shared_ptr task) -{ - WIFI_LOGD("Enter RegistHttpCallBack::[%{public}s].", __FUNCTION__); -} } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_network_check.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_network_check.h index e66861cf5..4b31a1c92 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_network_check.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_network_check.h @@ -30,7 +30,6 @@ public: void SignalNetCheckThread() override; void StopNetCheckThread() override; void ExitNetCheckThread() override; - void RegistHttpCallBack(std::shared_ptr task); void SetHttpResultInfo(std::string url, int codeNum, int codeLenNum); }; } // namespace OHOS diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/BUILD.gn b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/BUILD.gn index ebc59640f..1df7034a8 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/BUILD.gn +++ b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/BUILD.gn @@ -41,11 +41,13 @@ ohos_unittest("toolkit_unittest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/mac_address.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/network_interface.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/raw_socket.cpp", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/sta_network_check.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils/network_parser.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils/softap_parser.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils/wifi_encryption_util.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils/wifi_global_func.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils/xml_parser.cpp", + "../../wifi_manage/wifi_sta/Mock/mock_sta_network_check.cpp", "arp_checker_test.cpp", "base_address_test.cpp", "dhcpd_interface_test.cpp", @@ -58,6 +60,7 @@ ohos_unittest("toolkit_unittest") { "network_parser_test.cpp", "raw_socket_test.cpp", "softap_parser_test.cpp", + "sta_network_check_test.cpp", "wifi_config_file_test.cpp", "wifi_encryption_util_test.cpp", "wifi_global_func_test.cpp", @@ -73,6 +76,7 @@ ohos_unittest("toolkit_unittest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/log", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/config", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta", "$WIFI_ROOT_DIR/interfaces/inner_api", "$WIFI_ROOT_DIR/frameworks/native/interfaces", "$WIFI_ROOT_DIR/services/wifi_standard/include", @@ -85,6 +89,7 @@ ohos_unittest("toolkit_unittest") { ] deps = [ + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", "//third_party/libxml2:xml2", @@ -98,6 +103,7 @@ ohos_unittest("toolkit_unittest") { "c_utils:utils", "dhcp:dhcp_sdk", "hilog:libhilog", + "netstack:http_client", ] if (wifi_feature_with_encryption) { external_deps += [ "huks:libhukssdk" ] diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/sta_network_check_test.cpp similarity index 100% rename from wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_network_check_test.cpp rename to wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/sta_network_check_test.cpp