From 629e7ba7c964a62c97f6a882bffaec3c8490bb1e Mon Sep 17 00:00:00 2001 From: hai007 Date: Wed, 25 Oct 2023 11:33:42 -0700 Subject: [PATCH] Disable Intel PIE for github Opensource repo PiperOrigin-RevId: 576593321 --- .../platform/implementation/windows/BUILD | 7 ++++-- .../implementation/windows/wifi_intel.cc | 23 +++++++++++++++++-- .../implementation/windows/wifi_intel.h | 11 +++++++-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/internal/platform/implementation/windows/BUILD b/internal/platform/implementation/windows/BUILD index e58ad6a9..dbacfd8e 100644 --- a/internal/platform/implementation/windows/BUILD +++ b/internal/platform/implementation/windows/BUILD @@ -105,6 +105,7 @@ cc_library( "wifi_intel.h", "wifi_lan.h", ], + copts = ["-DNO_INTEL_PIE"], visibility = ["//visibility:private"], deps = [ "//internal/platform:base", @@ -114,7 +115,6 @@ cc_library( "//internal/platform/implementation:comm", "//internal/platform/implementation:types", "//internal/platform/implementation/windows/generated:types", - "//third_party/intel/pie", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", @@ -189,7 +189,10 @@ cc_library( ], # This is the temporary solution to solve compilation error of Win32 WFDxxx() related API. # WFD API is only support after _WIN32_WINNT_WIN8, but the current lexan _WIN32_WINNT is set to _WIN32_WINNT_WIN7 - copts = ["-Ithird_party/nearby/internal/platform/implementation/windows/generated -D_WIN32_WINNT=_WIN32_WINNT_WIN10 -DWINVER=_WIN32_WINNT_WIN10"], + copts = [ + "-DNO_INTEL_PIE", + "-Ithird_party/nearby/internal/platform/implementation/windows/generated -D_WIN32_WINNT=_WIN32_WINNT_WIN10 -DWINVER=_WIN32_WINNT_WIN10", + ], defines = ["_SILENCE_CLANG_COROUTINE_MESSAGE"], visibility = [ "//connections:__subpackages__", diff --git a/internal/platform/implementation/windows/wifi_intel.cc b/internal/platform/implementation/windows/wifi_intel.cc index 688b09fb..432c1a3d 100644 --- a/internal/platform/implementation/windows/wifi_intel.cc +++ b/internal/platform/implementation/windows/wifi_intel.cc @@ -32,11 +32,13 @@ #include #include +#ifndef NO_INTEL_PIE #include "absl/strings/str_format.h" #include "third_party/intel/pie/include/PieApiTypes.h" #include "third_party/intel/pie/include/PieDefinitions.h" #include "third_party/intel/pie/include/PieErrorMacro.h" #include "internal/platform/logging.h" +#endif namespace nearby { namespace windows { @@ -81,12 +83,14 @@ namespace { } \ } +#ifndef NO_INTEL_PIE #define PIE_API_DLL L"\\MurocApi.dll" #define ERROR_ const wchar_t PIE_HW_ID_[] = L"SWC\\VID_8086&PID_PIE&SID_0001\0"; const wchar_t PIE_DLL_PATH_HINT[] = L"PiePathHint"; +#endif } // namespace - +#ifndef NO_INTEL_PIE typedef MUROC_RET(APIENTRY* WIFIGETADAPTERLIST)( // NOLINT PINTEL_WIFI_HEADER pHeader, void** pAdapterList); typedef MUROC_RET(APIENTRY* REGISTERINTELCB)( @@ -124,6 +128,7 @@ void WINAPI IntelEventHandler(MurocDefs::INTEL_EVENT iEvent, // NOLINT // because the CB comes from another thread MurocDefs::INTEL_CALLBACK g_intel_event_cb_handle = {IntelEventHandler, nullptr}; +#endif WifiIntel& WifiIntel::GetInstance() { static std::aligned_storage_t storage; @@ -133,6 +138,7 @@ WifiIntel& WifiIntel::GetInstance() { void WifiIntel::Start() { NEARBY_LOGS(INFO) << "WifiIntel::Start()"; +#ifndef NO_INTEL_PIE muroc_api_dll_handle_ = PIEDllLoader(); if ((muroc_api_dll_handle_ != nullptr)) { NEARBY_LOGS(INFO) << "Load PIE_API_DLL completed successfully"; @@ -146,10 +152,14 @@ void WifiIntel::Start() { SAFEFREELIBRARY(muroc_api_dll_handle_); } } +#else + NEARBY_LOGS(INFO) << "NO_INTEL_PIE found, skip"; +#endif } void WifiIntel::Stop() { NEARBY_LOGS(INFO) << "WifiIntel::Stop()"; +#ifndef NO_INTEL_PIE if (intel_wifi_valid_) { NEARBY_LOGS(INFO) << "Deregister Intel Callback, free Adapters Memory " "List, free Muroc Api Dll handler."; @@ -157,9 +167,13 @@ void WifiIntel::Stop() { FreeMemoryList(muroc_api_dll_handle_, p_all_adapters_); SAFEFREELIBRARY(muroc_api_dll_handle_); } +#else + NEARBY_LOGS(INFO) << "NO_INTEL_PIE found, skip"; +#endif } uint8_t WifiIntel::GetGOChannel() { +#ifndef NO_INTEL_PIE WIFIPANQUERYPREFFEDCHANNELSETTING WifiPanQueryPreferredChannelSettingFunc = nullptr; uint8_t channel = 0; @@ -205,8 +219,13 @@ uint8_t WifiIntel::GetGOChannel() { } return channel; +#else + NEARBY_LOGS(INFO) << "NO_INTEL_PIE found, return -1"; + return -1; +#endif } +#ifndef NO_INTEL_PIE wchar_t* GetEntireRegistryDeviceList() { CONFIGRET configRet = CR_SUCCESS; wchar_t* pDeviceList = nullptr; @@ -573,6 +592,6 @@ void FreeMemoryList(HINSTANCE murocApiDllHandle, void* ptr) { } } } - +#endif } // namespace windows } // namespace nearby diff --git a/internal/platform/implementation/windows/wifi_intel.h b/internal/platform/implementation/windows/wifi_intel.h index c7995aad..03562b12 100644 --- a/internal/platform/implementation/windows/wifi_intel.h +++ b/internal/platform/implementation/windows/wifi_intel.h @@ -18,18 +18,22 @@ // clang-format off #include #include +#include // clang-format on // Intel WIFI PIE headers +#ifndef NO_INTEL_PIE #include "third_party/intel/pie/include/IntelSdkVersionInfo.h" #include "third_party/intel/pie/include/PieApiErrors.h" #include "third_party/intel/pie/include/PieDefinitions.h" +#endif #include "internal/platform/logging.h" namespace nearby { namespace windows { - +#ifndef NO_INTEL_PIE using ::MurocDefs::PINTEL_ADAPTER_LIST_V120; +#endif // Container of Intel WIFI to utilize Intel PIE SDK API class WifiIntel { @@ -42,6 +46,7 @@ class WifiIntel { void Start(); void Stop(); uint8_t GetGOChannel(); + private: // This is a singleton object, for which destructor will never be called. // Constructor will be invoked once from Instance() static method. @@ -50,12 +55,14 @@ class WifiIntel { WifiIntel() = default; ~WifiIntel() = default; +#ifndef NO_INTEL_PIE HINSTANCE PIEDllLoader(); - bool intel_wifi_valid_ = false; HINSTANCE muroc_api_dll_handle_ = nullptr; HADAPTER wifi_adapter_handle_ = 0; PINTEL_ADAPTER_LIST_V120 p_all_adapters_ = nullptr; +#endif + bool intel_wifi_valid_ = false; }; } // namespace windows