diff --git a/services/common/src/bundle_active_core.cpp b/services/common/src/bundle_active_core.cpp index 4757711f225dd58c0a2125dbd6d0db7ec00f89c9..2d80691f930067c2e1973dd7f36f2e82fde3c35b 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 9f9f233b0f5001c6413af740baa4725e1a3482fb..d584ada2da37a669d07c49596ed56ea91588382f 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 8df251d1ad86b8507a5cf123d0c70a18b7154b51..28e6d170b6ffc10c04d7bcb3a78e046443e5ad82 100644 --- a/services/packageusage/src/bundle_active_user_service.cpp +++ b/services/packageusage/src/bundle_active_user_service.cpp @@ -210,10 +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 (incrementBundleLaunch && it->bundleStats_[bundleStatsKey] != nullptr) { it->bundleStats_[bundleStatsKey]->IncrementBundleLaunchedCount(); } +// LCOV_EXCL_STOP break; } }