diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index 2f88b686f93957d5bf19e4137a74b0d12583ffcc..aab66f3aac7a39b126f57805090eff3be14c1d64 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 d74e33227846ca67ba43740e9ccb068a7fc4697b..2946f12cf78ed7d246d984d853e0d8311b9fba1b 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 9d2660202d4ffd7b4c1d723b76dcda313eaca320..4476915982c85707b64d71327497aa36440ae82f 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 bd4caee3d1dc96697bfe17737ea48e71a108cc63..f7ac47a5dba00881636520ed8c25014e4ced58ce 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) {