From 3f53283947c8af67904642bffd257ff5950acecf Mon Sep 17 00:00:00 2001 From: houdisheng Date: Wed, 9 Mar 2022 20:05:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=88=86=E7=BB=84=E5=88=B7?= =?UTF-8?q?=E7=9B=98=E6=97=B6=EF=BC=8C=E5=8F=AA=E6=9B=B4=E6=96=B0=E6=9C=89?= =?UTF-8?q?=E5=8F=98=E5=8C=96=E7=9A=84=E5=BA=94=E7=94=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E6=9B=B4=E6=96=B0=E6=9C=AA=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- services/common/src/bundle_active_usage_database.cpp | 9 ++++++++- .../packagegroup/include/bundle_active_package_history.h | 1 + services/packagegroup/src/bundle_active_user_history.cpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/services/common/src/bundle_active_usage_database.cpp b/services/common/src/bundle_active_usage_database.cpp index 091dd41..4433bcc 100644 --- a/services/common/src/bundle_active_usage_database.cpp +++ b/services/common/src/bundle_active_usage_database.cpp @@ -552,8 +552,11 @@ void BundleActiveUsageDatabase::PutBundleHistoryData(int userId, int64_t outRowId = BUNDLE_ACTIVE_FAIL; NativeRdb::ValuesBucket valuesBucket; vector queryCondition; + int updatedcount = 0; + int unupdatedcount = 0; for (auto iter = userHistory->begin(); iter != userHistory->end(); iter++) { - if (iter->second == nullptr) { + if (iter->second == nullptr || !iter->second->isChanged_) { + unupdatedcount++; continue; } queryCondition.push_back(to_string(userId)); @@ -576,7 +579,11 @@ void BundleActiveUsageDatabase::PutBundleHistoryData(int userId, } valuesBucket.Clear(); queryCondition.clear(); + iter->second->isChanged_ = false; + updatedcount++; } + BUNDLE_ACTIVE_LOGI("PutBundleHistoryData, update %{public}d bundles, keep %{public}d bundles group", + updatedcount, unupdatedcount); } shared_ptr>> BundleActiveUsageDatabase::GetBundleHistoryData( diff --git a/services/packagegroup/include/bundle_active_package_history.h b/services/packagegroup/include/bundle_active_package_history.h index ff25c7a..bfced55 100644 --- a/services/packagegroup/include/bundle_active_package_history.h +++ b/services/packagegroup/include/bundle_active_package_history.h @@ -30,6 +30,7 @@ public: uint32_t reasonInGroup_; int64_t bundleAliveTimeoutTimeStamp_; int64_t bundleDailyTimeoutTimeStamp_; + bool isChanged_; BundleActivePackageHistory(); ~BundleActivePackageHistory() {}; }; diff --git a/services/packagegroup/src/bundle_active_user_history.cpp b/services/packagegroup/src/bundle_active_user_history.cpp index 5055d7c..255cc49 100644 --- a/services/packagegroup/src/bundle_active_user_history.cpp +++ b/services/packagegroup/src/bundle_active_user_history.cpp @@ -32,6 +32,7 @@ BundleActivePackageHistory::BundleActivePackageHistory() bundleAliveTimeoutTimeStamp_ = 0; bundleDailyTimeoutTimeStamp_ = 0; lastCalculatedGroup_ = ACTIVE_GROUP_NEVER; + isChanged_ = false; }; void BundleActiveUserHistory::WriteDeviceDuration() @@ -202,6 +203,7 @@ void BundleActiveUserHistory::SetBundleGroup(const string& bundleName, const int oneBundleHistory->bundleAliveTimeoutTimeStamp_ = setTimeStamp; oneBundleHistory->bundleDailyTimeoutTimeStamp_ = setTimeStamp; } + oneBundleHistory->isChanged_ = true; } void BundleActiveUserHistory::UpdateBootBasedAndScreenTime(const bool& isScreenOn, const int64_t bootBasedTimeStamp, -- Gitee