diff --git a/frameworks/ans/src/notification_subscriber.cpp b/frameworks/ans/src/notification_subscriber.cpp index b235bb7fc8f247945f77c5b60805f1184b7f0026..f789cf1ec2c48b3ea9087324b68a6c2a876da17b 100644 --- a/frameworks/ans/src/notification_subscriber.cpp +++ b/frameworks/ans/src/notification_subscriber.cpp @@ -104,8 +104,13 @@ NotificationConstant::FlagStatus NotificationSubscriber::DowngradeReminder( } #endif -void NotificationSubscriber::ProcessRemoveExtendInfo(std::shared_ptr ¬ification) const +void NotificationSubscriber::ProcessRemoveExtendInfo(const std::string &deviceType, + std::shared_ptr ¬ification) const { + if (deviceType == NotificationConstant::PC_DEVICE_TYPE || + deviceType == NotificationConstant::PAD_DEVICE_TYPE) { + return; + } sptr request = notification->GetNotificationRequestPoint(); std::shared_ptr extendInfo = request->GetExtendInfo(); if (extendInfo != nullptr) { @@ -161,7 +166,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnConsumed( return ERR_OK; } #endif - subscriber_.ProcessRemoveExtendInfo(sharedNotification); + subscriber_.ProcessRemoveExtendInfo(subscriber_.GetDeviceType(), sharedNotification); subscriber_.OnConsumed( sharedNotification, std::make_shared(*notificationMap)); return ERR_OK; diff --git a/frameworks/core/src/listener/ans_subscriber_listener.cpp b/frameworks/core/src/listener/ans_subscriber_listener.cpp index 5b38c4a6905c31bdb3fbc3e4a18b4bbe31bce8fb..2ee4e4e3641599bd9c22e70afb40371bb412cae5 100644 --- a/frameworks/core/src/listener/ans_subscriber_listener.cpp +++ b/frameworks/core/src/listener/ans_subscriber_listener.cpp @@ -69,7 +69,7 @@ ErrCode SubscriberListener::OnConsumed( } #endif - subscriber->ProcessRemoveExtendInfo(sharedNotification); + subscriber->ProcessRemoveExtendInfo(subscriber->GetDeviceType(), sharedNotification); subscriber->OnConsumed( sharedNotification, std::make_shared(*notificationMap)); return ERR_OK; diff --git a/interfaces/inner_api/notification_subscriber.h b/interfaces/inner_api/notification_subscriber.h index f0d14a6c4d55868edce5e7c4bce0adf9f5d4d00f..c4fac028c8c774999c888c2c583c16ed86af2c76 100644 --- a/interfaces/inner_api/notification_subscriber.h +++ b/interfaces/inner_api/notification_subscriber.h @@ -137,7 +137,7 @@ public: bool ProcessSyncDecision(const std::string &deviceType, std::shared_ptr ¬ification) const; #endif -void ProcessRemoveExtendInfo(std::shared_ptr ¬ification) const; +void ProcessRemoveExtendInfo(const std::string &deviceType, std::shared_ptr ¬ification) const; private: class SubscriberImpl final : public AnsSubscriberStub { diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 39c8078d1ba371fd795437c21f03712475f771bb..9e01d352409237276089cec1f75e57587b6b287f 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -193,6 +193,7 @@ ErrCode AdvancedNotificationService::CollaborateFilter(const sptrGetStringParam("notification_collaboration_deviceType"); std::string deviceId = params->GetStringParam("notification_collaboration_deviceId"); + std::string localType = params->GetStringParam("notification_collaboration_localType"); int32_t userId = params->GetIntParam("notification_collaboration_userId", DEFAULT_USER_ID); auto result = NotificationPreferences::GetInstance()->GetDistributedAuthStatus(deviceType, deviceId, userId, switchEnabled); @@ -203,7 +204,7 @@ ErrCode AdvancedNotificationService::CollaborateFilter(const sptrGetSlotType(); if (slotType == NotificationConstant::SlotType::LIVE_VIEW) { result = NotificationPreferences::GetInstance()->IsDistributedEnabledBySlot( - NotificationConstant::SlotType::LIVE_VIEW, deviceType, switchEnabled); + NotificationConstant::SlotType::LIVE_VIEW, localType, switchEnabled); if (result != ERR_OK || !switchEnabled) { ANS_LOGW("Get live view distributed failed %{public}d %{public}d.", result, switchEnabled); return ERR_ANS_NOT_ALLOWED; @@ -211,7 +212,7 @@ ErrCode AdvancedNotificationService::CollaborateFilter(const sptrIsDistributedEnabled(deviceType, enable); + result = NotificationPreferences::GetInstance()->IsDistributedEnabled(localType, enable); if (result != ERR_OK || enable != NotificationConstant::ENABLE_STATUS::ENABLE_TRUE) { ANS_LOGW("Get notification distributed failed %{public}d %{public}d.", result, enable); return ERR_ANS_NOT_ALLOWED; diff --git a/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp b/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp index ac8aa9a08ad5a98fb26f4696a022a24bcb59c273..72c6a7038040c651fbc783ca2e378b9dc00b0db0 100644 --- a/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp +++ b/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp @@ -456,7 +456,6 @@ void SmartReminderCenter::FillRequestExtendInfo(const string &deviceType, Device std::shared_ptr extendInfo = request->GetExtendInfo(); if (extendInfo == nullptr) { extendInfo = std::make_shared(); - request->SetExtendInfo(extendInfo); } extendInfo->SetParam(EXTEND_INFO_PRE + "_" + EXTEND_INFO_APP_NAME, AAFwk::String::Box(appInfo.name)); extendInfo->SetParam(EXTEND_INFO_PRE + "_" + EXTEND_INFO_APP_LABEL, @@ -470,6 +469,7 @@ void SmartReminderCenter::FillRequestExtendInfo(const string &deviceType, Device AAFwk::String::Box(deviceStatus.deviceId)); extendInfo->SetParam(EXTEND_INFO_PRE + "_" + EXTEND_INFO_USER_ID + "_" + deviceType, AAFwk::Integer::Box(deviceStatus.userId)); + request->SetExtendInfo(extendInfo); ANS_LOGI("FillRequestExtendInfo result: %{public}s %{public}s %{public}s %{public}d %{public}s %{public}d", appInfo.name.c_str(), bundleResourceInfo.label.c_str(), bundleResourceInfo.icon.c_str(), appInfo.appIndex, diff --git a/services/distributed/include/tlv_box/request_box.h b/services/distributed/include/tlv_box/request_box.h index 81e94c8f038d4c105117da6bd5797efecb0f94f2..331669b415b94f05144aa38f135feff92046cd81 100644 --- a/services/distributed/include/tlv_box/request_box.h +++ b/services/distributed/include/tlv_box/request_box.h @@ -46,13 +46,14 @@ public: bool SetNotificationBigPicture(const std::shared_ptr& bigPicture); bool SetNotificationActionName(const std::string& actionName); bool SetNotificationUserInput(const std::string& userInput); - bool SetSmallIcon(const std::string& icon); + bool SetSmallIcon(const std::shared_ptr& smallIcon); bool SetBigIcon(const std::shared_ptr& bigIcon, int32_t deviceType); bool SetOverlayIcon(const std::shared_ptr& overlayIcon, int32_t deviceType); bool SetCommonLiveView(const std::vector& byteSequence); 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); @@ -84,6 +85,7 @@ 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/include/tlv_box/tlv_box.h b/services/distributed/include/tlv_box/tlv_box.h index 309b0bf9d7a285f8afa94ba642f58afcf3c0c983..fbb17f29ae1b2bf2c0d8f61be9dc8e7d6575ad5a 100644 --- a/services/distributed/include/tlv_box/tlv_box.h +++ b/services/distributed/include/tlv_box/tlv_box.h @@ -63,8 +63,9 @@ enum TlvType : int32_t { NOTIFICATION_LONG_TITLE = 22, ALL_LINES_LENGTH = 23, NOTIFICATION_APP_MESSAGE_ID = 24, - NOTIFICATION_USERID = 982, - DEVICE_USERID = 983, + NOTIFICATION_USERID = 981, + DEVICE_USERID = 982, + APP_ICON = 983, APP_INDEX = 984, APP_LABEL = 985, APP_NAME = 986, 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 8459e1d347070930057753072707c976ff636a54..045962bd6a6b65e8a659d1d6109dd8e223dd56d7 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp @@ -52,6 +52,7 @@ static const std::string EXTENDINFO_DEVICE_USERID = "userId"; static const std::string EXTENDINFO_DEVICE_ID = "deviceId"; static const std::string EXTENDINFO_ENABLE_CHECK = "check"; static const std::string EXTENDINFO_DEVICETYPE = "deviceType"; +static const std::string EXTENDINFO_LOCALTYPE = "localType"; DistributedPublishService& DistributedPublishService::GetInstance() { @@ -358,6 +359,9 @@ void DistributedPublishService::SetNotificationExtendInfo(const sptrGetOverlayIcon() != nullptr) { requestBox->SetOverlayIcon(notificationRequest->GetOverlayIcon(), deviceType); } + if (notificationRequest->GetLittleIcon() != nullptr) { + requestBox->SetSmallIcon(notificationRequest->GetLittleIcon()); + } auto params = notificationRequest->GetExtendInfo(); if (params == nullptr) { @@ -374,7 +378,7 @@ void DistributedPublishService::SetNotificationExtendInfo(const sptrGetStringParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_ICON); if (!content.empty()) { - requestBox->SetSmallIcon(content); + requestBox->SetAppIcon(content); } int32_t appIndex = params->GetIntParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_INDEX, 0); requestBox->SetAppIndex(appIndex); @@ -531,11 +535,19 @@ 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)) { extendInfo->SetParam(EXTENDINFO_INFO_PRE + EXTENDINFO_DEVICE_ID, AAFwk::String::Box(info)); + DistributedDeviceInfo peerDevice; + if (DistributedDeviceService::GetInstance().GetDeviceInfo(info, peerDevice)) { + std::string deviceType = DistributedDeviceService::DeviceTypeToTypeString(peerDevice.deviceType_); + extendInfo->SetParam(EXTENDINFO_INFO_PRE + EXTENDINFO_DEVICETYPE, AAFwk::String::Box(deviceType)); + } } - std::string deviceType = DistributedDeviceService::DeviceTypeToTypeString(local.deviceType_); - extendInfo->SetParam(EXTENDINFO_INFO_PRE + EXTENDINFO_DEVICETYPE, AAFwk::String::Box(deviceType)); + std::string localType = DistributedDeviceService::DeviceTypeToTypeString(local.deviceType_); + extendInfo->SetParam(EXTENDINFO_INFO_PRE + EXTENDINFO_LOCALTYPE, AAFwk::String::Box(localType)); int32_t appIndex; if (box.GetAppIndex(appIndex)) { extendInfo->SetParam(EXTENDINFO_INFO_PRE + EXTENDINFO_APP_INDEX, AAFwk::Integer::Box(appIndex)); @@ -548,6 +560,7 @@ void DistributedPublishService::MakeExtendInfo(const NotificationRequestBox& box request->SetReceiverUserId(userId); } } + extendInfo->DumpInfo(0); request->SetExtendInfo(extendInfo); } diff --git a/services/distributed/src/tlv_box/request_box.cpp b/services/distributed/src/tlv_box/request_box.cpp index ea49b12b3d9f528aad78bb3e55d9a9a34748f2a0..1d400491c243490f429ccc0f237b777494518892 100644 --- a/services/distributed/src/tlv_box/request_box.cpp +++ b/services/distributed/src/tlv_box/request_box.cpp @@ -188,11 +188,12 @@ bool NotificationRequestBox::SetNotificationUserInput(const std::string& userInp return box_->PutValue(std::make_shared(ACTION_USER_INPUT, userInput)); } -bool NotificationRequestBox::SetSmallIcon(const std::string& icon) +bool NotificationRequestBox::SetSmallIcon(const std::shared_ptr& smallIcon) { if (box_ == nullptr) { return false; } + std::string icon = AnsImageUtil::PackImage(smallIcon); return box_->PutValue(std::make_shared(BUNDLE_ICON, icon)); } @@ -266,6 +267,14 @@ 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) { @@ -521,6 +530,14 @@ 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) {