From 2a474e4297af679d47c51a1b391543f481cedc73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B5=A9?= Date: Sat, 13 Sep 2025 14:41:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9A=90=E7=A7=81?= =?UTF-8?q?=E7=A9=BA=E9=97=B4=E5=8D=87=E7=BA=A7=E5=BA=94=E7=94=A8=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=B8=BB=E7=A9=BA=E9=97=B4=E5=8D=A1=E7=89=87=E6=9C=AA?= =?UTF-8?q?reload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈浩 --- .../bms_mgr/form_bundle_event_callback.h | 2 ++ services/include/common/util/form_util.h | 2 ++ .../bms_mgr/form_bundle_event_callback.cpp | 27 ++++++++++++++----- services/src/common/util/form_util.cpp | 9 +++++++ .../fms_form_util_test/fms_form_util_test.cpp | 7 +++++ 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/services/include/bms_mgr/form_bundle_event_callback.h b/services/include/bms_mgr/form_bundle_event_callback.h index 92f235a859..f542cf3f68 100644 --- a/services/include/bms_mgr/form_bundle_event_callback.h +++ b/services/include/bms_mgr/form_bundle_event_callback.h @@ -43,6 +43,8 @@ public: void OnReceiveEvent(const EventFwk::CommonEventData eventData) override; private: DISALLOW_COPY_AND_MOVE(FormBundleEventCallback); + + void HandleBundleChange(const std::string &bundleName, int32_t userId); }; } // namespace OHOS } // namespace AppExecFwk diff --git a/services/include/common/util/form_util.h b/services/include/common/util/form_util.h index 1cb5fc1a42..57f03458f4 100644 --- a/services/include/common/util/form_util.h +++ b/services/include/common/util/form_util.h @@ -173,6 +173,8 @@ public: static long long ConvertStringToLongLong(const std::string &strInfo, int radix = BASE_REQUEST_CODE_NUM); static bool IsActiveUser(const int32_t userId); + + static void GetActiveUsers(std::vector &activeList); }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/src/bms_mgr/form_bundle_event_callback.cpp b/services/src/bms_mgr/form_bundle_event_callback.cpp index 7da3b22f2c..ebd935d63c 100644 --- a/services/src/bms_mgr/form_bundle_event_callback.cpp +++ b/services/src/bms_mgr/form_bundle_event_callback.cpp @@ -18,6 +18,7 @@ #include "feature/bundle_forbidden/form_bundle_forbid_mgr.h" #include "form_mgr/form_mgr_queue.h" #include "feature/bundle_distributed/form_distributed_mgr.h" +#include "common/util/form_util.h" namespace OHOS { namespace AppExecFwk { @@ -55,12 +56,7 @@ void FormBundleEventCallback::OnReceiveEvent(const EventFwk::CommonEventData eve action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED) { // install or update HILOG_WARN("bundleName:%{public}s changed", bundleName.c_str()); - FormEventUtil::HandleBundleFormInfoChanged(bundleName, userId); - std::function taskFunc = [bundleName, userId]() { - FormEventUtil::HandleUpdateFormCloud(bundleName); - FormEventUtil::HandleProviderUpdated(bundleName, userId); - }; - FormMgrQueue::GetInstance().ScheduleTask(0, taskFunc); + HandleBundleChange(bundleName, userId); } else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED) { // uninstall module/bundle int appIndex = want.GetIntParam("appIndex", 0); @@ -91,5 +87,24 @@ void FormBundleEventCallback::OnReceiveEvent(const EventFwk::CommonEventData eve } } +void FormBundleEventCallback::HandleBundleChange(const std::string &bundleName, int32_t userId) +{ + std::vector activeList; + FormUtil::GetActiveUsers(activeList); + auto iter = std::find(activeList.begin(), activeList.end(), userId); + if (iter == activeList.end()) { + activeList.emplace_back(userId); + } + HILOG_INFO("active user list len:%{public}zu", activeList.size()); + for (const int32_t userId : activeList) { + bool needReload = true; + FormEventUtil::HandleBundleFormInfoChanged(bundleName, userId, needReload); + std::function taskFunc = [bundleName, userId, needReload]() { + FormEventUtil::HandleUpdateFormCloud(bundleName); + FormEventUtil::HandleProviderUpdated(bundleName, userId, needReload); + }; + FormMgrQueue::GetInstance().ScheduleTask(0, taskFunc); + } +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/services/src/common/util/form_util.cpp b/services/src/common/util/form_util.cpp index 0e5e20ca5f..a58e2b333e 100644 --- a/services/src/common/util/form_util.cpp +++ b/services/src/common/util/form_util.cpp @@ -1970,5 +1970,14 @@ bool FormUtil::IsActiveUser(const int32_t userId) auto iter = std::find(activeList.begin(), activeList.end(), userId); return iter != activeList.end() && errCode == ERR_OK; } + +void FormUtil::GetActiveUsers(std::vector &activeList) +{ + ErrCode errCode = DelayedSingleton::GetInstance()->QueryActiveOsAccountIds(activeList); + if (errCode != ERR_OK) { + HILOG_ERROR("QueryActiveOsAccountIds failed"); + return; + } +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/fms_form_util_test/fms_form_util_test.cpp b/test/unittest/fms_form_util_test/fms_form_util_test.cpp index cbaeae1c65..fc8a89ee56 100644 --- a/test/unittest/fms_form_util_test/fms_form_util_test.cpp +++ b/test/unittest/fms_form_util_test/fms_form_util_test.cpp @@ -814,5 +814,12 @@ HWTEST_F(FormUtilTest, FormUtilTest_030, TestSize.Level1) MockQueryActiveOsAccountIdsParams(false); EXPECT_EQ(false, FormUtil::IsActiveUser(accountId)); } + +HWTEST_F(FormUtilTest, FormUtilTest_031, TestSize.Level0) +{ + std::vector activeList; + FormUtil::GetActiveUsers(activeList); + EXPECT_EQ(true, activeList.empty()); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file -- Gitee From 560ab2b88fb602df6e5b239abf1ad029661df023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B5=A9?= Date: Sat, 13 Sep 2025 14:43:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9A=90=E7=A7=81?= =?UTF-8?q?=E7=A9=BA=E9=97=B4=E5=8D=87=E7=BA=A7=E5=BA=94=E7=94=A8=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=B8=BB=E7=A9=BA=E9=97=B4=E5=8D=A1=E7=89=87=E6=9C=AA?= =?UTF-8?q?reload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈浩 --- services/src/bms_mgr/form_bundle_event_callback.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/bms_mgr/form_bundle_event_callback.cpp b/services/src/bms_mgr/form_bundle_event_callback.cpp index ebd935d63c..e5e2b6a528 100644 --- a/services/src/bms_mgr/form_bundle_event_callback.cpp +++ b/services/src/bms_mgr/form_bundle_event_callback.cpp @@ -49,7 +49,7 @@ void FormBundleEventCallback::OnReceiveEvent(const EventFwk::CommonEventData eve return; } - HILOG_INFO("action:%{public}s", action.c_str()); + HILOG_INFO("action:%{public}s, userId:%{public}d", action.c_str(), userId); wptr weakThis = this; if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED || -- Gitee From f4d3c238973a4df7b2b9625d732a09944631e0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B5=A9?= Date: Sat, 13 Sep 2025 17:33:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9A=90=E7=A7=81?= =?UTF-8?q?=E7=A9=BA=E9=97=B4=E5=8D=87=E7=BA=A7=E5=BA=94=E7=94=A8=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=B8=BB=E7=A9=BA=E9=97=B4=E5=8D=A1=E7=89=87=E6=9C=AA?= =?UTF-8?q?reload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈浩 --- services/src/bms_mgr/form_bundle_event_callback.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/src/bms_mgr/form_bundle_event_callback.cpp b/services/src/bms_mgr/form_bundle_event_callback.cpp index e5e2b6a528..705d330925 100644 --- a/services/src/bms_mgr/form_bundle_event_callback.cpp +++ b/services/src/bms_mgr/form_bundle_event_callback.cpp @@ -97,11 +97,10 @@ void FormBundleEventCallback::HandleBundleChange(const std::string &bundleName, } HILOG_INFO("active user list len:%{public}zu", activeList.size()); for (const int32_t userId : activeList) { - bool needReload = true; - FormEventUtil::HandleBundleFormInfoChanged(bundleName, userId, needReload); - std::function taskFunc = [bundleName, userId, needReload]() { + FormEventUtil::HandleBundleFormInfoChanged(bundleName, userId); + std::function taskFunc = [bundleName, userId]() { FormEventUtil::HandleUpdateFormCloud(bundleName); - FormEventUtil::HandleProviderUpdated(bundleName, userId, needReload); + FormEventUtil::HandleProviderUpdated(bundleName, userId); }; FormMgrQueue::GetInstance().ScheduleTask(0, taskFunc); } -- Gitee