diff --git a/displaymgr.gni b/displaymgr.gni index 8815dfef0d88cedf4561d2205e7f124f043ab035..5e947aabca908727877031a767ca524cdd230963 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 0730c4e82fac917d0d37dbcb56cdd63fa5f3cc98..769ffcd86a75a0b570aaf55ad6e12bcb5685bb80 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 2c8af70604ec14cf2d253e9a145526b551bbe08d..de955957b0bd6e6e389026013c50837ef50ae1fe 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; }