From c8a7cd3a9d0bdb124b76fc67508f8ae0d1417090 Mon Sep 17 00:00:00 2001 From: wang19954 Date: Sat, 13 Sep 2025 09:48:50 +0800 Subject: [PATCH] IssueNo:#ICXT7J Description:fix dynamic clone bug Sig:SIG_ApplicaitonFramework Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangtiantian --- .../bundle_resource/bundle_resource_parser.h | 2 ++ .../bundle_resource_manager.cpp | 17 ++++++++++++++-- .../bundle_resource_parser.cpp | 20 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h b/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h index dddba70696..93e3c8ca64 100644 --- a/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h +++ b/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h @@ -41,6 +41,8 @@ public: // parse clone bundle resource info bool ParserCloneResourceInfo(const int32_t appIndex, std::vector &resourceInfos); + bool ParserCloneResourceInfo(const int32_t appIndex, ResourceInfo &resourceInfos); + bool ParseResourceInfosNoTheme(const int32_t userId, std::vector &resourceInfos); bool ParseIconResourceInfosWithTheme(const int32_t userId, std::vector &resourceInfos); diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp index 7b0f339dd7..eef9f4885b 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp @@ -737,6 +737,12 @@ bool BundleResourceManager::AddDynamicIconResource( resourceInfo.bundleName_ = bundleName; resourceInfo.appIndex_ = appIndex; if (userId != Constants::UNSPECIFIED_USERID) { + // process icon with badge + BundleResourceParser parser; + if ((appIndex > 0) && (!parser.ParserCloneResourceInfo(appIndex, resourceInfo))) { + APP_LOGE("parse clone resource failed -n %{public}s -u %{public}d -a %{public}d", + bundleName.c_str(), userId, appIndex); + } if (!bundleResourceIconRdb_->AddResourceIconInfo(userId, IconResourceType::DYNAMIC_ICON, resourceInfo)) { APP_LOGE("add dynamic icon failed -n %{public}s -u %{public}d -a %{public}d", bundleName.c_str(), userId, appIndex); @@ -756,9 +762,16 @@ bool BundleResourceManager::AddDynamicIconResource( resourceInfo.appIndex_ = 0; ret &= bundleResourceIconRdb_->AddResourceIconInfo(user, IconResourceType::DYNAMIC_ICON, resourceInfo); auto appIndexes = dataMgr->GetCloneAppIndexes(bundleName, user); + // process icon with badge + BundleResourceParser parser; for (const auto &index : appIndexes) { - resourceInfo.appIndex_ = index; - ret &= bundleResourceIconRdb_->AddResourceIconInfo(user, IconResourceType::DYNAMIC_ICON, resourceInfo); + ResourceInfo newResourceInfo = resourceInfo; + newResourceInfo.appIndex_ = index; + if (!parser.ParserCloneResourceInfo(appIndex, newResourceInfo)) { + APP_LOGE("parse clone resource failed -n %{public}s -u %{public}d -a %{public}d", + bundleName.c_str(), userId, appIndex); + } + ret &= bundleResourceIconRdb_->AddResourceIconInfo(user, IconResourceType::DYNAMIC_ICON, newResourceInfo); } } if (!ret) { diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp index 0a6b889cf1..9a80ccb56e 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp @@ -506,6 +506,26 @@ bool BundleResourceParser::ParserCloneResourceInfo( #endif } +bool BundleResourceParser::ParserCloneResourceInfo(const int32_t appIndex, ResourceInfo &resourceInfo) +{ + if (appIndex <= 0) { + APP_LOGE("-n %{public}s appIndex %{public}d is invalid", resourceInfo.GetKey().c_str(), appIndex); + return false; + } + std::vector resourceInfos; + resourceInfos.emplace_back(resourceInfo); + if (!ParserCloneResourceInfo(appIndex, resourceInfos)) { + APP_LOGE("-n %{public}s appIndex %{public}d parse badge failed", resourceInfo.GetKey().c_str(), appIndex); + return false; + } + if (resourceInfos.empty()) { + APP_LOGE("-n %{public}s appIndex %{public}d resourceInfo empty", resourceInfo.GetKey().c_str(), appIndex); + return false; + } + resourceInfo.icon_ = resourceInfos[0].icon_; + return true; +} + bool BundleResourceParser::ParseResourceInfosNoTheme( const int32_t userId, std::vector &resourceInfos) { -- Gitee