From ef4c8ca81c1b5b52e2b4d05422d01fe398a5e96e Mon Sep 17 00:00:00 2001 From: chenkai008 Date: Tue, 22 Oct 2024 15:24:30 +0800 Subject: [PATCH] build: Modify hiview dependency issues Signed-off-by: chenkai008 --- displaymgr.gni | 8 ++++++++ state_manager/frameworks/napi/BUILD.gn | 5 ++++- state_manager/frameworks/napi/brightness_module.cpp | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/displaymgr.gni b/displaymgr.gni index 8815dfe..5e947aa 100644 --- a/displaymgr.gni +++ b/displaymgr.gni @@ -31,6 +31,14 @@ declare_args() { } else { has_hiviewdfx_hisysevent_part = false } + + if (!defined(global_parts_info) || + defined(global_parts_info.hiviewdfx_hiview)) { + has_dfx_hiview_part = true + defines += [ "HAS_DFX_HIVIEW_PART" ] + } else { + has_dfx_hiview_part = false + } } displaymgr_part_name = "display_manager" diff --git a/state_manager/frameworks/napi/BUILD.gn b/state_manager/frameworks/napi/BUILD.gn index 0730c4e..769ffcd 100644 --- a/state_manager/frameworks/napi/BUILD.gn +++ b/state_manager/frameworks/napi/BUILD.gn @@ -33,12 +33,15 @@ ohos_shared_library("brightness") { "c_utils:utils", "ets_runtime:libark_jsruntime", "hilog:libhilog", - "hiview:libxpower_event_js", "ipc:ipc_core", "napi:ace_napi", "power_manager:powermgr_client", ] + if (has_dfx_hiview_part) { + external_deps += [ "hiview:libxpower_event_js" ] + } + relative_install_dir = "module" subsystem_name = "powermgr" diff --git a/state_manager/frameworks/napi/brightness_module.cpp b/state_manager/frameworks/napi/brightness_module.cpp index 2c8af70..de95595 100644 --- a/state_manager/frameworks/napi/brightness_module.cpp +++ b/state_manager/frameworks/napi/brightness_module.cpp @@ -30,7 +30,9 @@ #include "display_common.h" #include "display_log.h" #include "power_mgr_client.h" +#ifdef HAS_DFX_HIVIEW_PART #include "xpower_event_js.h" +#endif using namespace OHOS::DisplayPowerMgr; using namespace OHOS::PowerMgr; @@ -108,7 +110,9 @@ static napi_value SetValue(napi_env env, napi_callback_info info) if (res != nullptr) { Brightness brightness(env); brightness.SetValue(info); +#ifdef HAS_DFX_HIVIEW_PART OHOS::HiviewDFX::ReportXPowerJsStackSysEvent(env, "Brightness::SetValue"); +#endif } return nullptr; } -- Gitee