diff --git a/services/distributed/include/tlv_box/request_box.h b/services/distributed/include/tlv_box/request_box.h index dc1a0f7f7935d8328ff766b58533425eea244be9..23686ca7e8a7df02522e5f188284d0b539548e87 100644 --- a/services/distributed/include/tlv_box/request_box.h +++ b/services/distributed/include/tlv_box/request_box.h @@ -40,6 +40,7 @@ public: bool SetNotificationBriefText(const std::string& text); bool SetNotificationExpandedTitle(const std::string& text); bool SetNotificationLongText(const std::string& text); + bool SetAllLineLength(const int32_t& length); bool SetNotificationAllLines(const std::vector& allLines); bool SetNotificationBigPicture(const std::shared_ptr& bigPicture); bool SetNotificationActionName(const std::string& actionName); @@ -61,6 +62,7 @@ public: bool GetNotificationBriefText(std::string& text) const; bool GetNotificationExpandedTitle(std::string& text) const; bool GetNotificationLongText(std::string& text) const; + bool GetAllLineLength(int32_t& length) const; bool GetNotificationAllLines(std::vector& allLines) const; bool GetNotificationBigPicture(std::shared_ptr& bigPicture) const; bool GetNotificationActionName(std::string& actionName) const; diff --git a/services/distributed/include/tlv_box/tlv_box.h b/services/distributed/include/tlv_box/tlv_box.h index 6a5bff36945f52e79aedc04b626229abf9c36e92..14486e51ecc5cc529c09fa6feec0c2302f2711e3 100644 --- a/services/distributed/include/tlv_box/tlv_box.h +++ b/services/distributed/include/tlv_box/tlv_box.h @@ -60,6 +60,8 @@ enum TlvType : int32_t { NOTIFICATION_BRIEF_TEXT = 20, NOTIFICATION_EXPANDED_TITLE = 21, NOTIFICATION_LONG_TITLE = 22, + NOTIFICATION_ALL_LINES_START_INDEX = 23, + ALL_LINES_LENGTH = 26, RESULT_CODE = 989, OPERATION_TYPE = 990, OPERATION_EVENT_ID = 991, diff --git a/services/distributed/src/soft_bus/distributed_publish_service.cpp b/services/distributed/src/soft_bus/distributed_publish_service.cpp index 47abc88b1c826b58cb4bbbdf6d053eb0a434ed21..a3d50c59ea078ee8c9e0a0b90f14e68c1a1db3c7 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service.cpp @@ -247,6 +247,10 @@ void DistributedService::MakeNotificationButtons(const NotifticationRequestBox& std::string actionName; std::string userInputKey; box.GetNotificationActionName(actionName); + if (actionName.empty()) { + ANS_LOGE("Check actionButtons is null."); + return; + } box.GetNotificationUserInput(userInputKey); std::shared_ptr userInput = NotificationUserInput::Create(userInputKey); std::shared_ptr actionButton = diff --git a/services/distributed/src/tlv_box/request_box.cpp b/services/distributed/src/tlv_box/request_box.cpp index 475200c6cb0e9cc0cc66893346b66e81c5caee6a..fb7f4e4698aaf50974d155d75f30a645c84bd368 100644 --- a/services/distributed/src/tlv_box/request_box.cpp +++ b/services/distributed/src/tlv_box/request_box.cpp @@ -136,9 +136,26 @@ bool NotifticationRequestBox::SetNotificationLongText(const std::string& text) return box_->PutValue(std::make_shared(NOTIFICATION_LONG_TITLE, text)); } +bool NotifticationRequestBox::SetAllLineLength(const int32_t& length) +{ + if (box_ == nullptr) { + return false; + } + return box_->PutValue(std::make_shared(ALL_LINES_LENGTH, length)); +} + bool NotifticationRequestBox::SetNotificationAllLines(const std::vector& allLines) { - return true; + if (box_ == nullptr) { + return false; + } + int32_t index = 0; + for (auto& line : allLines) { + if (box_->PutValue(std::make_shared(NOTIFICATION_ALL_LINES_START_INDEX + index, line))) { + index++; + } + } + return SetAllLineLength(index); } bool NotifticationRequestBox::SetNotificationBigPicture(const std::shared_ptr& bigPicture) @@ -307,8 +324,25 @@ bool NotifticationRequestBox::GetNotificationLongText(std::string& text) const return box_->GetStringValue(NOTIFICATION_LONG_TITLE, text); } +bool NotifticationRequestBox::GetAllLineLength(int32_t& length) const +{ + if (box_ == nullptr) { + return false; + } + return box_->GetInt32Value(ALL_LINES_LENGTH, length); +} + bool NotifticationRequestBox::GetNotificationAllLines(std::vector& allLines) const { + int32_t length = 0; + if (!GetAllLineLength(length)) { + return false; + } + for (int i = 0; i < length; i++) { + std::string line; + if (box_->GetStringValue(NOTIFICATION_ALL_LINES_START_INDEX + i, line)) + allLines.push_back(line); + } return true; }