diff --git a/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h b/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h index dddba70696c0409ebbbd8518a1dbaeb1611270be..93e3c8ca642422c1ee836093b1d55cc35f26662a 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 7b0f339dd7409fc87c7aa196c6b0d39445182a60..eef9f4885b887b55df748a8fd188459e1fd3e037 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 0a6b889cf143f7e120d1009b398d179e1d820fd5..9a80ccb56e9506b1a26006872620a56b22dcd496 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) {