diff --git a/interfaces/innerkits/common/BUILD.gn b/interfaces/innerkits/common/BUILD.gn index 837fb697d014faa475dbb0677fb7152b05b674e3..280d097b6fa9c27620aaa32dd2fb6f5f46856352 100644 --- a/interfaces/innerkits/common/BUILD.gn +++ b/interfaces/innerkits/common/BUILD.gn @@ -72,6 +72,7 @@ ohos_shared_library("samgr_common") { "c_utils:utils", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", ] diff --git a/services/dfx/include/hisysevent_adapter.h b/services/dfx/include/hisysevent_adapter.h index e8a71392c3ba2beee99e85d92349d139bd5d9561..700fa59a2b04b9882fb5e883ac53652309643752 100644 --- a/services/dfx/include/hisysevent_adapter.h +++ b/services/dfx/include/hisysevent_adapter.h @@ -49,6 +49,6 @@ void ReportProcessStartDuration(const std::string& processName, int32_t pid, int void ReportProcessStopDuration(const std::string& processName, int32_t pid, int32_t uid, int64_t duration); -void ReportSAIdle(int32_t said, const std::string& reason); +void ReportSAIdle(const char* reason); } // OHOS #endif // SAMGR_SERVICES_DFX_INCLUDE__HISYSEVENT_ADAPTER_H diff --git a/services/dfx/source/hisysevent_adapter.cpp b/services/dfx/source/hisysevent_adapter.cpp index 6bb315b4cef8107b678d59d0761214f072f6a263..949cbcbc4ea24f81524a9ea0f77ef05ab41f1b09 100644 --- a/services/dfx/source/hisysevent_adapter.cpp +++ b/services/dfx/source/hisysevent_adapter.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ #include "hisysevent_adapter.h" +#include "hisysevent_easy.h" #include @@ -293,15 +294,11 @@ void WatchDogSendEvent(int32_t pid, uint32_t uid, const std::string& sendMsg, } } -void ReportSAIdle(int32_t said, const std::string& reason) +void ReportSAIdle(const char* reason) { - int ret = HiSysEventWrite(HiSysEvent::Domain::SAMGR, + HiSysEventEasyWrite(HiSysEvent::Domain::SAMGR, SA_IDLE, - HiSysEvent::EventType::BEHAVIOR, - SAID, said, - REASON, reason); - if (ret != 0) { - HILOGE("hisysevent report sa idle failed! ret %{public}d.", ret); - } + HiSysEventEasyType::EASY_EVENT_TYPE_BEHAVIOR, + reason); } } // OHOS diff --git a/services/samgr/native/BUILD.gn b/services/samgr/native/BUILD.gn index e9acf73f4ccf8dac4aad142e907246e7748184da..9d742a020c86f1e02dea2a12839c299b81c26666 100644 --- a/services/samgr/native/BUILD.gn +++ b/services/samgr/native/BUILD.gn @@ -100,6 +100,7 @@ ohos_executable("samgr") { "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", diff --git a/services/samgr/native/source/collect/ref_count_collect.cpp b/services/samgr/native/source/collect/ref_count_collect.cpp index 66b62b1cb49df3a615d1f30fccbd445fd70b9e82..b1d1eff5e87bdc803b4411c049a3657e851be7d6 100644 --- a/services/samgr/native/source/collect/ref_count_collect.cpp +++ b/services/samgr/native/source/collect/ref_count_collect.cpp @@ -14,6 +14,7 @@ */ #include "ref_count_collect.h" +#include namespace OHOS { namespace { @@ -116,7 +117,13 @@ void RefCountCollect::IdentifyUnrefResident() uint32_t refCount = saProxy->GetStrongRefCountForStub(); HILOGD("resident SA:%{public}d, ref count:%{public}u", saId, refCount); if (refCount == 1) { - ReportSAIdle(saId, "ref count 1"); + char reason[128] = {0}; + errno_t res = snprintf_s(reason, sizeof(reason), sizeof(reason) - 1, "saId:%d REASON:ref count 1", saId); + if (res < 0) { + HILOGE("SA:%{public}d report SA_IDLE snprintf_s error:%{public}d", saId, res); + continue; + } + ReportSAIdle(reason); HILOGI("resident SA:%{public}d, ref count:1", saId); } } diff --git a/services/samgr/native/test/unittest/BUILD.gn b/services/samgr/native/test/unittest/BUILD.gn index 3b0a2f5cca34994f365bedb1dd35546ae09200ad..d011cbeb543404a4f0f322d308dda9dcff947d13 100644 --- a/services/samgr/native/test/unittest/BUILD.gn +++ b/services/samgr/native/test/unittest/BUILD.gn @@ -108,6 +108,7 @@ ohos_unittest("SystemAbilityMgrTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", @@ -225,6 +226,7 @@ ohos_unittest("SystemAbilityMgrCollectTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", @@ -352,6 +354,7 @@ ohos_unittest("SystemAbilityMgrDeviceNetworkingTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", @@ -451,6 +454,7 @@ ohos_unittest("SystemAbilityMgrStubTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", @@ -536,6 +540,7 @@ ohos_unittest("SystemAbilityMgrProxyTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "init:libbegetutil", "ipc:ipc_single", "json:nlohmann_json_static", @@ -578,6 +583,7 @@ ohos_unittest("LocalAbilityManagerProxyTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "ipc:ipc_single", "json:nlohmann_json_static", ] @@ -648,6 +654,7 @@ ohos_unittest("SystemAbilityStateSchedulerTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", @@ -724,6 +731,7 @@ ohos_unittest("SystemAbilityMgrDumperTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", @@ -777,6 +785,7 @@ ohos_unittest("MockSystemAbilityManagerTest") { "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", @@ -982,6 +991,7 @@ ohos_executable("TestTool") { "eventhandler:libeventhandler", "ffrt:libffrt", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", diff --git a/test/fuzztest/samgr_fuzzer/BUILD.gn b/test/fuzztest/samgr_fuzzer/BUILD.gn index 2656669458a08f3224485d51e8523a9b2e33280c..25a3d3386e33c91556f794c376d29627808daa86 100644 --- a/test/fuzztest/samgr_fuzzer/BUILD.gn +++ b/test/fuzztest/samgr_fuzzer/BUILD.gn @@ -176,6 +176,7 @@ foreach(item, samgr_fuzztests) { "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", diff --git a/test/fuzztest/samgrcoverage_fuzzer/BUILD.gn b/test/fuzztest/samgrcoverage_fuzzer/BUILD.gn index db80705ad00cc63dc3b6bb8820b87da90dbe8c44..4ff84f1c9ab459fe48d76efccef592dda0bc57d6 100644 --- a/test/fuzztest/samgrcoverage_fuzzer/BUILD.gn +++ b/test/fuzztest/samgrcoverage_fuzzer/BUILD.gn @@ -79,6 +79,7 @@ ohos_fuzztest("SamgrCoverageFuzzTest") { "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", diff --git a/test/fuzztest/samgrdumper_fuzzer/BUILD.gn b/test/fuzztest/samgrdumper_fuzzer/BUILD.gn index 1d6123d81d4acdfbc0ee935626acbfd205048cd5..2f79bdfd6e0db66762ea2f6da4e9556ed719b043 100644 --- a/test/fuzztest/samgrdumper_fuzzer/BUILD.gn +++ b/test/fuzztest/samgrdumper_fuzzer/BUILD.gn @@ -78,6 +78,7 @@ ohos_fuzztest("SamgrDumperFuzzTest") { "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", diff --git a/test/fuzztest/systemabilitymanager_fuzzer/BUILD.gn b/test/fuzztest/systemabilitymanager_fuzzer/BUILD.gn index c5357e938bf82a3c98bd7bd53ccfe5180e02322d..aabdd78515d125ab1f0f54d1dbb7f5c629dd3988 100644 --- a/test/fuzztest/systemabilitymanager_fuzzer/BUILD.gn +++ b/test/fuzztest/systemabilitymanager_fuzzer/BUILD.gn @@ -78,6 +78,7 @@ ohos_fuzztest("SystemAbilityManagerFuzzTest") { "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", + "hisysevent:libhisysevent_easy", "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil",