diff --git a/services/common/src/bundle_active_core.cpp b/services/common/src/bundle_active_core.cpp index 7e9ff8823a00a2fa74cc6f96386e9f3be4432850..1d431ec773eba40d739eba0ecf080536e880662f 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 a5d57b30547468fc696ae7ca058247d0457d44f0..90c03cb291af3d569251447c90284deb2c9e986f 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 b4ca1b75d59906d0dfd39b8b87e05eb96c549a5d..97b32975d019f353732c15f573b9b6a7e261d0d5 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); } @@ -376,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); } diff --git a/services/packagegroup/src/bundle_active_user_history.cpp b/services/packagegroup/src/bundle_active_user_history.cpp index 255cc49994c17fd7a67522df6a5e1ad36012e1ee..e1d59b5179dc0cb95a23200d4b7d94fe5e27b6b4 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,