From 6f33ab2b85360adc0063b819ee264801132ad1d1 Mon Sep 17 00:00:00 2001 From: wangsen1994 Date: Tue, 29 Apr 2025 15:14:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B7=A8=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=8D=8F=E5=90=8Cim=E7=99=BD=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangsen1994 --- frameworks/ans/src/notification_request.cpp | 5 +++- .../ans/include/notification_analytics_util.h | 2 ++ .../ans/include/notification_app_privileges.h | 4 ++- .../ans/include/notification_config_parse.h | 1 + .../ans/src/advanced_notification_service.cpp | 1 + .../common/notification_analytics_util.cpp | 25 +++++++++++++++++++ .../common/notification_app_privileges.cpp | 12 ++++++++- .../src/common/notification_config_parse.cpp | 9 +++++++ .../src/notification_subscriber_manager.cpp | 6 +++++ 9 files changed, 62 insertions(+), 3 deletions(-) diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index a7b01c4c9..43e5a25bd 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 ee131ce42..91a0f1ab3 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 17643d6e9..3135c7c4f 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 4816c6dcf..0a7f7f477 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 460edc41a..1fde53b75 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 dabbb059b..6793cfef8 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 ee2f05a91..11bb6fb44 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 689a1bad9..7d5497e84 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 2d3f23675..5bbbd85f2 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; -- Gitee