diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index f1175fdabab39589f4feb4f5ade4ca360f39c8ca..de6a313a2c3df71ca5d744a97570aa893a910e0a 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -2857,7 +2857,10 @@ bool NotificationRequest::HasUserInputButton() { for (std::shared_ptr button : actionButtons_) { if (button->GetUserInput() != nullptr) { - return true; + std::string inputKey = button->GetUserInput()->GetInputKey(); + if (!inputKey.empty()) { + return true; + } } } return false; diff --git a/services/ans/include/notification_analytics_util.h b/services/ans/include/notification_analytics_util.h index 681c4c26099c0a77ed442f080d68105ffe12796b..76537a62e5af216b327351ddcde8d2f3050c501a 100644 --- a/services/ans/include/notification_analytics_util.h +++ b/services/ans/include/notification_analytics_util.h @@ -144,6 +144,8 @@ public: static void ReportSkipFailedEvent(const HaMetaMessage& message); + static void ReportPublishWithUserInput(const sptr& request); + private: static void ReportNotificationEvent(const sptr& request, EventFwk::Want want, int32_t eventCode, const std::string& reason); diff --git a/services/ans/include/notification_app_privileges.h b/services/ans/include/notification_app_privileges.h index 17643d6e910d08e47df23cb871765eda442788cb..3135c7c4fa44ec648ef36de90f640d5a3a81052d 100644 --- a/services/ans/include/notification_app_privileges.h +++ b/services/ans/include/notification_app_privileges.h @@ -29,8 +29,10 @@ public: bool IsLiveViewEnabled() const; bool IsBannerEnabled() const; bool IsReminderEnabled() const; + bool IsDistributedReplyEnabled() const; private: + static constexpr int32_t DISTRIBUTED_REPLY_SEQ = 4; static constexpr int32_t REMINDER_ENABLED_SEQ = 2; static constexpr int32_t BANNER_ENABLED_SEQ = 1; static constexpr int32_t LIVE_VIEW_ENABLED_SEQ = 0; @@ -40,4 +42,4 @@ private: } // namespace Notification } // namespace OHOS -#endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_NOTIFICATION_APP_PRIVILEGES_H \ No newline at end of file +#endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_NOTIFICATION_APP_PRIVILEGES_H diff --git a/services/ans/include/notification_config_parse.h b/services/ans/include/notification_config_parse.h index 35615c2a7df67ca60f36b269ca2354a653e3051d..77b9f77450eee8045099742a594fa6dd6f1c358d 100644 --- a/services/ans/include/notification_config_parse.h +++ b/services/ans/include/notification_config_parse.h @@ -51,6 +51,7 @@ public: bool IsLiveViewEnabled(const std::string bundleName) const; bool IsBannerEnabled(const std::string bundleName) const; bool IsReminderEnabled(const std::string& bundleName) const; + bool IsDistributedReplyEnabled(const std::string& bundleName) const; void GetFlowCtrlConfigFromCCM(FlowControlThreshold &threshold); bool GetSmartReminderEnableList(std::vector& deviceTypes); bool GetMirrorNotificationEnabledStatus(std::vector& deviceTypes); diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 335407526c57333ce65743941ac851892b00fda3..2c25b77a010b91ea0f0cc36b0bcabe5ccaecd4e9 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -737,6 +737,7 @@ ErrCode AdvancedNotificationService::PublishPreparedNotification(const sptrwait(handler); diff --git a/services/ans/src/common/notification_analytics_util.cpp b/services/ans/src/common/notification_analytics_util.cpp index e7499a4ce8d8bdd2691a2e5b093520e5748b9472..66005871a0a960f7922bb8ec1ec1726d7fd2bc44 100644 --- a/services/ans/src/common/notification_analytics_util.cpp +++ b/services/ans/src/common/notification_analytics_util.cpp @@ -431,6 +431,31 @@ void NotificationAnalyticsUtil::ReportSAPublishSuccessEvent(const sptr& request) +{ + ANS_LOGD("ReportPublishSuccessEvent enter"); + if (request == nullptr || !request->HasUserInputButton()) { + return; + } + + EventFwk::Want want; + nlohmann::json ansData; + if (!request->GetOwnerBundleName().empty()) { + ansData["ownerBundleName"] = request->GetOwnerBundleName(); + } + if (!request->GetCreatorBundleName().empty()) { + ansData["createBundleName"] = request->GetCreatorBundleName(); + } + ansData["userInput"] = true; + ansData["slotType"] = static_cast(request->GetSlotType()); + ansData["contentType"] = static_cast(request->GetNotificationType()); + std::string message = ansData.dump(-1, ' ', false, nlohmann::json::error_handler_t::replace); + want.SetParam("ansData", message); + want.SetAction(NOTIFICATION_EVENT_PUSH_AGENT); + + IN_PROCESS_CALL_WITHOUT_RET(AddListCache(want, ANS_CUSTOMIZE_CODE)); +} + void NotificationAnalyticsUtil::ReportNotificationEvent(const sptr& request, EventFwk::Want want, int32_t eventCode, const std::string& reason) { diff --git a/services/ans/src/common/notification_app_privileges.cpp b/services/ans/src/common/notification_app_privileges.cpp index ee2f05a911624b6496dc2fda5acd373ef49a766f..11bb6fb44a2236fb8e66ea3f35c72d9f9a758404 100644 --- a/services/ans/src/common/notification_app_privileges.cpp +++ b/services/ans/src/common/notification_app_privileges.cpp @@ -28,6 +28,9 @@ NotificationAppPrivileges::NotificationAppPrivileges(const std::string &flagStr) if (flagStr.size() > REMINDER_ENABLED_SEQ && flagStr[REMINDER_ENABLED_SEQ] == '1') { privileges_ |= 1 << REMINDER_ENABLED_SEQ; } + if (flagStr.size() > DISTRIBUTED_REPLY_SEQ && flagStr[DISTRIBUTED_REPLY_SEQ] == '1') { + privileges_ |= 1 << DISTRIBUTED_REPLY_SEQ; + } } bool NotificationAppPrivileges::IsLiveViewEnabled() const { @@ -50,5 +53,12 @@ bool NotificationAppPrivileges::IsReminderEnabled() const } return false; } +bool NotificationAppPrivileges::IsDistributedReplyEnabled() const +{ + if ((privileges_ & (1 << DISTRIBUTED_REPLY_SEQ)) != 0) { + return true; + } + return false; +} } // namespace Notification -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/ans/src/common/notification_config_parse.cpp b/services/ans/src/common/notification_config_parse.cpp index e9adb280f7f746b3829db0e443c5d27db7f978d2..1f28fe0184ced14ccfaa63959ca79671440eb4ca 100644 --- a/services/ans/src/common/notification_config_parse.cpp +++ b/services/ans/src/common/notification_config_parse.cpp @@ -184,6 +184,15 @@ bool NotificationConfigParse::IsReminderEnabled(const std::string& bundleName) c return appPrivileges->IsReminderEnabled(); } +bool NotificationConfigParse::IsDistributedReplyEnabled(const std::string& bundleName) const +{ + std::shared_ptr appPrivileges = GetAppPrivileges(bundleName); + if (appPrivileges == nullptr) { + return false; + } + return appPrivileges->IsDistributedReplyEnabled(); +} + bool NotificationConfigParse::IsBannerEnabled(const std::string bundleName) const { std::shared_ptr appPrivileges = GetAppPrivileges(bundleName); diff --git a/services/ans/src/notification_subscriber_manager.cpp b/services/ans/src/notification_subscriber_manager.cpp index bdd5fa1ef1a072436bf882400bde69d2917eb854..fdf171dc90aa04e8235a394302ef9693db904d91 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -674,6 +674,12 @@ bool NotificationSubscriberManager::ConsumeRecordFilter( ANS_LOGI("ConsumeRecordFilter-filterType-im"); return false; } + std::string bundleName = notification->GetBundleName(); + if (isQuickReply && record->deviceType == DEVICE_TYPE_WEARABLE && + !DelayedSingleton::GetInstance()->IsDistributedReplyEnabled(bundleName)) { + ANS_LOGI("ConsumeRecordFilter-filterType-im bundle %{public}s", bundleName.c_str()); + return false; + } } return true;