From 7416e707b3925f26c5f81cf16a25e5f6d09c386d Mon Sep 17 00:00:00 2001 From: houdisheng Date: Thu, 10 Mar 2022 17:54:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dreportusage=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E5=BA=94=E7=94=A8=E5=88=86=E7=BB=84=E5=90=8E=E6=9C=AA?= =?UTF-8?q?=E8=90=BD=E7=9B=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- services/packagegroup/src/bundle_active_group_controller.cpp | 5 ++++- services/packagegroup/src/bundle_active_user_history.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/packagegroup/src/bundle_active_group_controller.cpp b/services/packagegroup/src/bundle_active_group_controller.cpp index b4ca1b7..a6dc710 100644 --- a/services/packagegroup/src/bundle_active_group_controller.cpp +++ b/services/packagegroup/src/bundle_active_group_controller.cpp @@ -277,19 +277,22 @@ void BundleActiveGroupController::CheckAndUpdateGroup(const std::string& bundleN groupReason = GROUP_CONTROL_REASON_TIMEOUT; } int64_t bootBasedTimeStampAdjusted = bundleUserHistory_->GetBootBasedTimeStamp(bootBasedTimeStamp); + bool notTimeout = false; if (newGroup >= ACTIVE_GROUP_ALIVE && oneBundleHistory->bundleAliveTimeoutTimeStamp_ > bootBasedTimeStampAdjusted) { newGroup = ACTIVE_GROUP_ALIVE; groupReason = oneBundleHistory->reasonInGroup_; groupReason = (newGroup == oldGroup) ? oneBundleHistory->reasonInGroup_ : GROUP_CONTROL_REASON_USAGE | GROUP_EVENT_REASON_ALIVE_NOT_TIMEOUT; + notTimeout = true; } else if (newGroup >= ACTIVE_GROUP_DAILY && oneBundleHistory->bundleDailyTimeoutTimeStamp_ > bootBasedTimeStampAdjusted) { newGroup = ACTIVE_GROUP_DAILY; groupReason = (newGroup == oldGroup) ? oneBundleHistory->reasonInGroup_ : GROUP_CONTROL_REASON_USAGE | GROUP_EVENT_REASON_ALIVE_TIMEOUT; + notTimeout = true; } - if (oldGroup < newGroup) { + if (oldGroup < newGroup || notTimeout) { BUNDLE_ACTIVE_LOGI("CheckAndUpdateGroup called SetBundleGroup"); bundleUserHistory_->SetBundleGroup(bundleName, userId, bootBasedTimeStamp, newGroup, groupReason, false); } diff --git a/services/packagegroup/src/bundle_active_user_history.cpp b/services/packagegroup/src/bundle_active_user_history.cpp index 255cc49..e1d59b5 100644 --- a/services/packagegroup/src/bundle_active_user_history.cpp +++ b/services/packagegroup/src/bundle_active_user_history.cpp @@ -179,6 +179,7 @@ void BundleActiveUserHistory::ReportUsage(shared_ptr oneBundleUsageHistory->currentGroup_ = newGroup; } oneBundleUsageHistory->reasonInGroup_ = GROUP_CONTROL_REASON_USAGE | groupReason; + oneBundleUsageHistory->isChanged_ = true; } void BundleActiveUserHistory::SetBundleGroup(const string& bundleName, const int userId, -- Gitee From d47d76263e195c2e7301063feb22f03140c20292 Mon Sep 17 00:00:00 2001 From: houdisheng Date: Thu, 10 Mar 2022 18:39:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dreportusage=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E5=BA=94=E7=94=A8=E5=88=86=E7=BB=84=E5=90=8E=E6=9C=AA?= =?UTF-8?q?=E8=90=BD=E7=9B=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- services/common/src/bundle_active_core.cpp | 10 +++++++++- .../include/bundle_active_group_controller.h | 2 +- .../src/bundle_active_group_controller.cpp | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/services/common/src/bundle_active_core.cpp b/services/common/src/bundle_active_core.cpp index 7e9ff88..1d431ec 100644 --- a/services/common/src/bundle_active_core.cpp +++ b/services/common/src/bundle_active_core.cpp @@ -293,7 +293,15 @@ void BundleActiveCore::ShutDown() int64_t timeStamp = timer->GetBootTimeMs(); BundleActiveEvent event(BundleActiveEvent::SHUTDOWN, timeStamp); event.bundleName_ = BundleActiveEvent::DEVICE_EVENT_PACKAGE_NAME; - bundleGroupController_->ShutDown(timeStamp); + std::vector activatedOsAccountIds; + GetAllActiveUser(activatedOsAccountIds); + if (activatedOsAccountIds.size() == 0) { + BUNDLE_ACTIVE_LOGI("query activated account failed, no account activated"); + return; + } + for (uint32_t i = 0; i < activatedOsAccountIds.size(); i++) { + bundleGroupController_->ShutDown(timeStamp, activatedOsAccountIds[i]); + } ReportEventToAllUserId(event); RestoreAllData(); } diff --git a/services/packagegroup/include/bundle_active_group_controller.h b/services/packagegroup/include/bundle_active_group_controller.h index a5d57b3..90c03cb 100644 --- a/services/packagegroup/include/bundle_active_group_controller.h +++ b/services/packagegroup/include/bundle_active_group_controller.h @@ -83,7 +83,7 @@ public: bool IsScreenOn(); int IsBundleIdle(const std::string& bundleName, const int userId); int QueryPackageGroup(const int userId, const std::string& bundleName); - void ShutDown(const int64_t bootBasedTimeStamp); + void ShutDown(const int64_t bootBasedTimeStamp, const int userId); void OnUserSwitched(const int userId); private: diff --git a/services/packagegroup/src/bundle_active_group_controller.cpp b/services/packagegroup/src/bundle_active_group_controller.cpp index a6dc710..97b3297 100644 --- a/services/packagegroup/src/bundle_active_group_controller.cpp +++ b/services/packagegroup/src/bundle_active_group_controller.cpp @@ -379,9 +379,10 @@ bool BundleActiveGroupController::IsBundleInstalled(const std::string& bundleNam return true; } -void BundleActiveGroupController::ShutDown(const int64_t bootBasedTimeStamp) +void BundleActiveGroupController::ShutDown(const int64_t bootBasedTimeStamp, const int userId) { BUNDLE_ACTIVE_LOGI("ShutDown called"); + CheckEachBundleState(userId); bundleUserHistory_->UpdateBootBasedAndScreenTime(false, bootBasedTimeStamp, true); } -- Gitee