From 44c4897804e063cce7265eef4819fea26391ccfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=98=89=E5=AE=9D?= Date: Mon, 10 Feb 2025 17:31:07 +0800 Subject: [PATCH 1/3] commit msg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄嘉宝 --- .../source/collect/common_event_collect.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/services/samgr/native/source/collect/common_event_collect.cpp b/services/samgr/native/source/collect/common_event_collect.cpp index 17c15b55..ef2ba714 100644 --- a/services/samgr/native/source/collect/common_event_collect.cpp +++ b/services/samgr/native/source/collect/common_event_collect.cpp @@ -41,6 +41,7 @@ constexpr uint32_t UNSUB_DELAY_TIME = 10 * 1000; constexpr int64_t MAX_EXTRA_DATA_ID = 1000000000; constexpr int32_t COMMON_EVENT_SERVICE_ID = 3299; constexpr int32_t TRIGGER_THREAD_RECLAIM_DELAY_TIME = 130 * 1000; +constexpr int32_t MAX_CES_SECONDS = 10; constexpr const char* SCREEN_TRIGGER_THREAD_RECLAIM = "SCREEN_TRIGGER_THREAD_RECLAIM"; constexpr const char* CLEAR_TRIGGER_THREAD_RECLAIM = "CLEAR_TRIGGER_THREAD_RECLAIM"; constexpr const char* UID = "uid"; @@ -357,14 +358,16 @@ int64_t CommonEventCollect::SaveOnDemandReasonExtraData(const EventFwk::CommonEv wantMap[UID] = std::to_string(uid); wantMap[NET_TYPE] = std::to_string(netType); wantMap[BUNDLE_NAME] = want.GetBundle(); - std::lock_guard autoLock(extraDataLock_); - wantMap[COMMON_EVENT_ACTION_NAME] = want.GetAction(); - OnDemandReasonExtraData extraData(data.GetCode(), data.GetData(), wantMap); + { + std::lock_guard autoLock(extraDataLock_); + wantMap[COMMON_EVENT_ACTION_NAME] = want.GetAction(); + OnDemandReasonExtraData extraData(data.GetCode(), data.GetData(), wantMap); - int64_t extraDataId = GenerateExtraDataIdLocked(); - extraDatas_[extraDataId] = extraData; - HILOGD("CommonEventCollect save extraData %{public}d,n:%{public}zu", - static_cast(extraDataId), extraDatas_.size()); + int64_t extraDataId = GenerateExtraDataIdLocked(); + extraDatas_[extraDataId] = extraData; + HILOGD("CommonEventCollect save extraData %{public}d,n:%{public}zu", + static_cast(extraDataId), extraDatas_.size()); + } if (workHandler_ == nullptr) { HILOGI("CommonEventCollect workHandler is nullptr"); return -1; @@ -679,7 +682,7 @@ CommonEventSubscriber::CommonEventSubscriber(const EventFwk::CommonEventSubscrib void CommonEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData& data) { - SamgrXCollie samgrXCollie("samgr--OnReceiveEvent"); + SamgrXCollie samgrXCollie("samgr--OnReceiveEvent", MAX_CES_SECONDS); std::string action = data.GetWant().GetAction(); int32_t code = data.GetCode(); auto collect = collect_.promote(); -- Gitee From 6652d78fbf485e78e0352ccd9665fc1002f2b50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=98=89=E5=AE=9D?= Date: Thu, 13 Feb 2025 14:40:28 +0800 Subject: [PATCH 2/3] commit msg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄嘉宝 --- .../source/collect/common_event_collect.cpp | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/services/samgr/native/source/collect/common_event_collect.cpp b/services/samgr/native/source/collect/common_event_collect.cpp index ef2ba714..ec6062b3 100644 --- a/services/samgr/native/source/collect/common_event_collect.cpp +++ b/services/samgr/native/source/collect/common_event_collect.cpp @@ -358,16 +358,14 @@ int64_t CommonEventCollect::SaveOnDemandReasonExtraData(const EventFwk::CommonEv wantMap[UID] = std::to_string(uid); wantMap[NET_TYPE] = std::to_string(netType); wantMap[BUNDLE_NAME] = want.GetBundle(); - { - std::lock_guard autoLock(extraDataLock_); - wantMap[COMMON_EVENT_ACTION_NAME] = want.GetAction(); - OnDemandReasonExtraData extraData(data.GetCode(), data.GetData(), wantMap); + std::lock_guard autoLock(extraDataLock_); + wantMap[COMMON_EVENT_ACTION_NAME] = want.GetAction(); + OnDemandReasonExtraData extraData(data.GetCode(), data.GetData(), wantMap); - int64_t extraDataId = GenerateExtraDataIdLocked(); - extraDatas_[extraDataId] = extraData; - HILOGD("CommonEventCollect save extraData %{public}d,n:%{public}zu", - static_cast(extraDataId), extraDatas_.size()); - } + int64_t extraDataId = GenerateExtraDataIdLocked(); + extraDatas_[extraDataId] = extraData; + HILOGD("CommonEventCollect save extraData %{public}d,n:%{public}zu", + static_cast(extraDataId), extraDatas_.size()); if (workHandler_ == nullptr) { HILOGI("CommonEventCollect workHandler is nullptr"); return -1; @@ -392,14 +390,14 @@ void CommonEventCollect::RemoveOnDemandReasonExtraData(int64_t extraDataId) std::lock_guard autoLock(extraDataLock_); extraDatas_.erase(extraDataId); } - HILOGD("CommonEventCollect remove extraData %{public}d", static_cast(extraDataId)); + HILOGI("CommonEventCollect remove extraData %{public}d", static_cast(extraDataId)); RemoveSaExtraDataId(extraDataId); } bool CommonEventCollect::GetOnDemandReasonExtraData(int64_t extraDataId, OnDemandReasonExtraData& extraData) { std::lock_guard autoLock(extraDataLock_); - HILOGD("CommonEventCollect get extraData %{public}d", static_cast(extraDataId)); + HILOGI("CommonEventCollect get extraData %{public}d", static_cast(extraDataId)); if (extraDatas_.count(extraDataId) == 0) { return false; } -- Gitee From 9b7dfc6de84508b1a85837dda86af49685f6e79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=98=89=E5=AE=9D?= Date: Thu, 13 Feb 2025 14:41:14 +0800 Subject: [PATCH 3/3] commit msg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄嘉宝 --- services/samgr/native/source/collect/common_event_collect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/samgr/native/source/collect/common_event_collect.cpp b/services/samgr/native/source/collect/common_event_collect.cpp index ec6062b3..3ab7f1bd 100644 --- a/services/samgr/native/source/collect/common_event_collect.cpp +++ b/services/samgr/native/source/collect/common_event_collect.cpp @@ -363,7 +363,7 @@ int64_t CommonEventCollect::SaveOnDemandReasonExtraData(const EventFwk::CommonEv OnDemandReasonExtraData extraData(data.GetCode(), data.GetData(), wantMap); int64_t extraDataId = GenerateExtraDataIdLocked(); - extraDatas_[extraDataId] = extraData; + extraDatas_[extraDataId] = extraData; HILOGD("CommonEventCollect save extraData %{public}d,n:%{public}zu", static_cast(extraDataId), extraDatas_.size()); if (workHandler_ == nullptr) { -- Gitee