diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index a7b01c4c999376703b435dc33949777c4240ebc3..43e5a25bdd1fa73d891ed60793f3f0dd93d7241a 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -2849,7 +2849,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 ee131ce421ad81af16d5bfab2511af285df4caad..91a0f1ab303ee605ae20991b0e3810ea757e623b 100644 --- a/services/ans/include/notification_analytics_util.h +++ b/services/ans/include/notification_analytics_util.h @@ -141,6 +141,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 4816c6dcfb97ce7601aeb79f4bd9faa34dadf816..0a7f7f47737cadb9590369cf6eb1e8762b9a85ef 100644 --- a/services/ans/include/notification_config_parse.h +++ b/services/ans/include/notification_config_parse.h @@ -54,6 +54,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 460edc41a2bc9a4b15248b8933d15a2df7e1c44e..1fde53b75d0ba5d6fe8a89191ceb2b3bcaff6d06 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 dabbb059b471b86ea64ba0dc3e3e7d6825898223..6793cfef85bb01bd92edbfbfdda7656f44dc1d6b 100644 --- a/services/ans/src/common/notification_analytics_util.cpp +++ b/services/ans/src/common/notification_analytics_util.cpp @@ -430,6 +430,31 @@ void NotificationAnalyticsUtil::ReportNotificationEvent(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::ReportModifyEvent(const HaMetaMessage& message) { if (!ReportFlowControl(MODIFY_ERROR_EVENT_CODE)) { 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 689a1bad99820a03410e704324a090e67364b76a..7d5497e84ca311708b99de6d6a80c4bbb2a5bfa6 100644 --- a/services/ans/src/common/notification_config_parse.cpp +++ b/services/ans/src/common/notification_config_parse.cpp @@ -191,6 +191,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 2d3f236757b66bd901c4e7ea6b4d5847c8d9984e..5bbbd85f28f7ae8a1f856b59c563d60fec5e96a3 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -639,6 +639,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;