From c85e9166252c1d44516c6e17db4c0a90543e834c Mon Sep 17 00:00:00 2001 From: xiaozuo00 Date: Thu, 4 Sep 2025 21:44:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=97=A0=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E4=B8=BB=E9=A2=98=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaozuo00 Change-Id: Id5555fc4a175c6cdfcd2aaeb5e56189fdcf64445 --- .../src/bundle_resource/bundle_resource_icon_rdb.cpp | 8 ++++++++ .../src/bundle_resource/bundle_resource_parser.cpp | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_icon_rdb.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_icon_rdb.cpp index ead7667356..049fee2478 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_icon_rdb.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_icon_rdb.cpp @@ -366,6 +366,10 @@ bool BundleResourceIconRdb::ConvertToLauncherAbilityResourceInfo( static_cast(ResourceFlag::GET_RESOURCE_INFO_ALL)); if (getIcon) { ret = absSharedResultSet->GetString(INDEX_ICON, launcherAbilityResourceInfo.icon); + if (launcherAbilityResourceInfo.icon.empty()) { + APP_LOGE("icon is empty"); + return false; + } CHECK_RDB_RESULT_RETURN_IF_FAIL(ret, "GetString label icon, ret: %{public}d"); } @@ -373,6 +377,10 @@ bool BundleResourceIconRdb::ConvertToLauncherAbilityResourceInfo( == static_cast(ResourceFlag::GET_RESOURCE_INFO_WITH_DRAWABLE_DESCRIPTOR); if (getDrawable) { ret = absSharedResultSet->GetBlob(INDEX_FOREGROUND, launcherAbilityResourceInfo.foreground); + if (launcherAbilityResourceInfo.foreground.empty()) { + APP_LOGE("foreground is empty"); + return false; + } CHECK_RDB_RESULT_RETURN_IF_FAIL(ret, "GetBlob foreground, ret: %{public}d"); ret = absSharedResultSet->GetBlob(INDEX_BACKGROUND, launcherAbilityResourceInfo.background); diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp index 9e41166443..0a6b889cf1 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp @@ -592,7 +592,11 @@ bool BundleResourceParser::ParseIconResourceInfosWithTheme( APP_LOGW_NOFUNC("ParseResourceInfo fail key:%{public}s", resourceInfos[index].GetKey().c_str()); } } - if (resourceInfos[0].icon_.empty()) { + bool invalidIcon = std::all_of(resourceInfos.begin(), resourceInfos.end(), + [](const auto& resourceInfo) { + return resourceInfo.icon_.empty(); + }); + if (invalidIcon) { APP_LOGE_NOFUNC("ParseResourceInfos fail -n %{public}s -m %{public}s", resourceInfos[0].bundleName_.c_str(), resourceInfos[0].moduleName_.c_str()); return false; -- Gitee