From 5a7b5de87f73e20ba966c679e0fccc90036e4796 Mon Sep 17 00:00:00 2001 From: wangsen1994 Date: Mon, 23 Jun 2025 21:12:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8smallicon=E4=BC=A0=E8=BE=93?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E9=81=BF=E5=85=8Dipc=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangsen1994 --- frameworks/core/src/ans_notification.cpp | 3 ++- .../distributed/include/tlv_box/request_box.h | 2 -- .../distributed_publish_service_v2.cpp | 23 +++++++++++-------- .../distributed/src/tlv_box/request_box.cpp | 16 ------------- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index 2f88b686f..aab66f3aa 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -1605,7 +1605,8 @@ bool AnsNotification::CanPublishLiveViewContent(const NotificationRequest &reque ErrCode AnsNotification::CheckImageSize(const NotificationRequest &request) { auto littleIcon = request.GetLittleIcon(); - if (NotificationRequest::CheckImageOverSizeForPixelMap(littleIcon, MAX_ICON_SIZE)) { + bool collaborateFlag = request.GetDistributedCollaborate(); + if (!collaborateFlag && NotificationRequest::CheckImageOverSizeForPixelMap(littleIcon, MAX_ICON_SIZE)) { ANS_LOGE("The size of little icon exceeds limit"); return ERR_ANS_ICON_OVER_SIZE; } diff --git a/services/distributed/include/tlv_box/request_box.h b/services/distributed/include/tlv_box/request_box.h index d74e33227..2946f12cf 100644 --- a/services/distributed/include/tlv_box/request_box.h +++ b/services/distributed/include/tlv_box/request_box.h @@ -53,7 +53,6 @@ public: bool SetFinishTime(int64_t time); bool SetAutoDeleteTime(int64_t time); bool SetAppMessageId(const std::string& appMessageId); - bool SetAppIcon(const std::string& appIcon); bool SetAppName(const std::string& appName); bool SetAppLabel(const std::string& appLabel); bool SetAppIndex(const int32_t& appIndex); @@ -87,7 +86,6 @@ public: bool GetFinishTime(int64_t& time) const; bool GetAutoDeleteTime(int64_t& time) const; bool GetAppMessageId(std::string& appMessageId) const; - bool GetAppIcon(std::string& appIcon) const; bool GetAppName(std::string& appName) const; bool GetAppLabel(std::string& appLabel) const; bool GetAppIndex(int32_t& appIndex) const; diff --git a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp index 9d2660202..447691598 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp @@ -37,6 +37,7 @@ #include "string_wrapper.h" #include "distributed_subscribe_service.h" #include "remove_all_distributed_box.h" +#include "bundle_resource_helper.h" namespace OHOS { namespace Notification { @@ -528,24 +529,29 @@ void DistributedPublishService::SetNotificationExtendInfo(const sptrGetLittleIcon() != nullptr) { requestBox->SetSmallIcon(notificationRequest->GetLittleIcon()); } - auto params = notificationRequest->GetExtendInfo(); - if (params == nullptr) { - ANS_LOGI("Send request invalid extend info."); + if (deviceType == DistributedHardware::DmDeviceType::DEVICE_TYPE_WATCH || params == nullptr) { + ANS_LOGI("Send request no extend info %{public}d.", deviceType); return; } std::string content = params->GetStringParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_NAME); if (!content.empty()) { requestBox->SetAppName(content); + if (notificationRequest->GetLittleIcon() == nullptr) { + AppExecFwk::BundleResourceInfo resourceInfo; + if (DelayedSingleton::GetInstance()->GetBundleInfo(content, resourceInfo) != 0) { + ANS_LOGW("Dans get bundle icon failed %{public}s.", content.c_str()); + return; + } + std::shared_ptr iconPixelmap = AnsImageUtil::CreatePixelMapByString(resourceInfo.icon); + requestBox->SetSmallIcon(iconPixelmap); + ANS_LOGI("Dans self get bundle icon."); + } } content = params->GetStringParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_LABEL); if (!content.empty()) { requestBox->SetAppLabel(content); } - content = params->GetStringParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_ICON); - if (!content.empty()) { - requestBox->SetAppIcon(content); - } int32_t appIndex = params->GetIntParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_INDEX, 0); requestBox->SetAppIndex(appIndex); std::string key = EXTENDINFO_INFO_PRE + EXTENDINFO_USERID + @@ -749,9 +755,6 @@ void DistributedPublishService::MakeExtendInfo(const NotificationRequestBox& box if (box.GetAppName(info)) { extendInfo->SetParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_NAME, AAFwk::String::Box(info)); } - if (box.GetAppIcon(info)) { - extendInfo->SetParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_ICON, AAFwk::String::Box(info)); - } if (box.GetDeviceId(info)) { DistributedDeviceInfo peerDevice; if (DistributedDeviceService::GetInstance().GetDeviceInfo(info, peerDevice)) { diff --git a/services/distributed/src/tlv_box/request_box.cpp b/services/distributed/src/tlv_box/request_box.cpp index bd4caee3d..f7ac47a5d 100644 --- a/services/distributed/src/tlv_box/request_box.cpp +++ b/services/distributed/src/tlv_box/request_box.cpp @@ -267,14 +267,6 @@ bool NotificationRequestBox::SetAutoDeleteTime(int64_t time) return box_->PutValue(std::make_shared(AUTO_DELETE_TIME, time)); } -bool NotificationRequestBox::SetAppIcon(const std::string& appIcon) -{ - if (box_ == nullptr) { - return false; - } - return box_->PutValue(std::make_shared(APP_ICON, appIcon)); -} - bool NotificationRequestBox::SetAppName(const std::string& appName) { if (box_ == nullptr) { @@ -565,14 +557,6 @@ bool NotificationRequestBox::GetAppMessageId(std::string& appMessageId) const return box_->GetStringValue(NOTIFICATION_APP_MESSAGE_ID, appMessageId); } -bool NotificationRequestBox::GetAppIcon(std::string& appIcon) const -{ - if (box_ == nullptr) { - return false; - } - return box_->GetStringValue(APP_ICON, appIcon); -} - bool NotificationRequestBox::GetAppName(std::string& appName) const { if (box_ == nullptr) { -- Gitee