From ace57fb96e5b8c09a614fb11269bd013e893e358 Mon Sep 17 00:00:00 2001 From: zxf Date: Tue, 9 Sep 2025 21:05:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B6=88=E9=99=A4=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zxf --- services/common/src/bundle_active_core.cpp | 8 ++++++-- services/common/src/bundle_active_usage_database.cpp | 6 +++++- services/packageusage/src/bundle_active_user_service.cpp | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/services/common/src/bundle_active_core.cpp b/services/common/src/bundle_active_core.cpp index 4757711..2d80691 100644 --- a/services/common/src/bundle_active_core.cpp +++ b/services/common/src/bundle_active_core.cpp @@ -565,8 +565,12 @@ void BundleActiveCore::OnUserRemoved(const int32_t userId) if (it == userStatServices_.end()) { return; } - userStatServices_[userId]->OnUserRemoved(); - userStatServices_[userId].reset(); +// LCOV_EXCL_START + if (userStatServices_[userId] != nullptr) { + userStatServices_[userId]->OnUserRemoved(); + userStatServices_[userId].reset(); + } +// LCOV_EXCL_STOP userStatServices_.erase(userId); BundleActiveGroupController::GetInstance().OnUserRemoved(userId); } diff --git a/services/common/src/bundle_active_usage_database.cpp b/services/common/src/bundle_active_usage_database.cpp index 9f9f233..230b2b5 100644 --- a/services/common/src/bundle_active_usage_database.cpp +++ b/services/common/src/bundle_active_usage_database.cpp @@ -300,7 +300,11 @@ void BundleActiveUsageDatabase::HandleAllTableName(const uint32_t databaseType, string tableName; bundleActiveResult->GoToRow(i); bundleActiveResult->GetString(tableNameIndex, tableName); - allTableName.at(databaseType).push_back(tableName); +// LCOV_EXCL_START + if (allTableName.size() > databaseType) { + allTableName.at(databaseType).push_back(tableName); + } +// LCOV_EXCL_STOP } bundleActiveResult->Close(); } diff --git a/services/packageusage/src/bundle_active_user_service.cpp b/services/packageusage/src/bundle_active_user_service.cpp index 8df251d..608132d 100644 --- a/services/packageusage/src/bundle_active_user_service.cpp +++ b/services/packageusage/src/bundle_active_user_service.cpp @@ -212,7 +212,11 @@ void BundleActiveUserService::UpdatePeriodStats(const BundleActiveEvent& event, event.abilityId_, event.uid_); if (incrementBundleLaunch) { std::string bundleStatsKey = event.bundleName_ + std::to_string(event.uid_); - it->bundleStats_[bundleStatsKey]->IncrementBundleLaunchedCount(); +// LCOV_EXCL_START + if (it->bundleStats_[bundleStatsKey] != nullptr) { + it->bundleStats_[bundleStatsKey]->IncrementBundleLaunchedCount(); + } +// LCOV_EXCL_STOP } break; } -- Gitee From db21205ebca93ee8eca14b40d09b32ea4cd2c804 Mon Sep 17 00:00:00 2001 From: zxf Date: Wed, 10 Sep 2025 09:57:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B6=88=E9=99=A4=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zxf --- services/common/src/bundle_active_usage_database.cpp | 2 +- .../packageusage/src/bundle_active_user_service.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/services/common/src/bundle_active_usage_database.cpp b/services/common/src/bundle_active_usage_database.cpp index 230b2b5..d584ada 100644 --- a/services/common/src/bundle_active_usage_database.cpp +++ b/services/common/src/bundle_active_usage_database.cpp @@ -304,7 +304,7 @@ void BundleActiveUsageDatabase::HandleAllTableName(const uint32_t databaseType, if (allTableName.size() > databaseType) { allTableName.at(databaseType).push_back(tableName); } -// LCOV_EXCL_STOP +// LCOV_EXCL_STOP } bundleActiveResult->Close(); } diff --git a/services/packageusage/src/bundle_active_user_service.cpp b/services/packageusage/src/bundle_active_user_service.cpp index 608132d..28e6d17 100644 --- a/services/packageusage/src/bundle_active_user_service.cpp +++ b/services/packageusage/src/bundle_active_user_service.cpp @@ -210,14 +210,12 @@ void BundleActiveUserService::UpdatePeriodStats(const BundleActiveEvent& event, default: it->Update(event.bundleName_, event.continuousTaskAbilityName_, event.timeStamp_, event.eventId_, event.abilityId_, event.uid_); - if (incrementBundleLaunch) { - std::string bundleStatsKey = event.bundleName_ + std::to_string(event.uid_); + std::string bundleStatsKey = event.bundleName_ + std::to_string(event.uid_); // LCOV_EXCL_START - if (it->bundleStats_[bundleStatsKey] != nullptr) { - it->bundleStats_[bundleStatsKey]->IncrementBundleLaunchedCount(); - } -// LCOV_EXCL_STOP + if (incrementBundleLaunch && it->bundleStats_[bundleStatsKey] != nullptr) { + it->bundleStats_[bundleStatsKey]->IncrementBundleLaunchedCount(); } +// LCOV_EXCL_STOP break; } } -- Gitee