Disable Intel PIE for github Opensource repo

PiperOrigin-RevId: 576593321
This commit is contained in:
hai007
2023-10-25 11:34:34 -07:00
committed by Copybara-Service
parent f93959fd15
commit 629e7ba7c9
3 changed files with 35 additions and 6 deletions
@@ -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__",
@@ -32,11 +32,13 @@
#include <string>
#include <type_traits>
#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<sizeof(WifiIntel), alignof(WifiIntel)> 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
@@ -18,18 +18,22 @@
// clang-format off
#include <windows.h>
#include <wtypes.h>
#include <cstdint>
// 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