From c89315d50364984ca0161fa83ddd508962d4344f Mon Sep 17 00:00:00 2001 From: songbao1 Date: Sat, 22 Mar 2025 11:18:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=89=93=E7=82=B9=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- .../advanced_notification_publish_service.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 3238874c3..69a356934 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -300,8 +300,11 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); ANS_LOGD("%{public}s", __FUNCTION__); + HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_9, EventBranchId::BRANCH_0); if (!request) { - ANSR_LOGE("ReminderRequest object is nullptr"); + ANS_LOGE("Request object is nullptr"); + message.ErrorCode(ERR_ANS_INVALID_PARAM).Message("Request object is nullptr"); + NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return ERR_ANS_INVALID_PARAM; } ErrCode result = PrePublishRequest(request); @@ -326,17 +329,23 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s sptr bundleOption = new (std::nothrow) NotificationBundleOption(bundle, uid); if (record->bundleOption == nullptr || bundleOption == nullptr) { ANS_LOGE("Failed to create bundleOption"); + message.ErrorCode(ERR_ANS_NO_MEMORY).Message("Failed to create bundleOption"); + NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return ERR_ANS_NO_MEMORY; } record->bundleOption->SetAppInstanceKey(request->GetAppInstanceKey()); record->notification = new (std::nothrow) Notification(request); if (record->notification == nullptr) { ANS_LOGE("Failed to create notification"); + message.ErrorCode(ERR_ANS_NO_MEMORY).Message("Failed to create notification"); + NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return ERR_ANS_NO_MEMORY; } if (notificationSvrQueue_ == nullptr) { ANS_LOGE("Serial queue is invalid."); + message.ErrorCode(ERR_ANS_NO_MEMORY).Message("Serial queue is invalid."); + NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return ERR_ANS_INVALID_PARAM; } @@ -347,6 +356,8 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s if (IsDisableNotification(bundle)) { ANS_LOGE("bundle in Disable Notification list, bundleName=%{public}s", bundle.c_str()); result = ERR_ANS_REJECTED_WITH_DISABLE_NOTIFICATION; + message.BranchId(EventBranchId::BRANCH_1) + .ErrorCode(result).Message("bundle in Disable Notification list, bundleName=" + bundle); return; } if (AssignValidNotificationSlot(record, bundleOption) != ERR_OK) { @@ -373,10 +384,12 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s bool isNotificationExists = IsNotificationExists(record->notification->GetKey()); result = FlowControlService::GetInstance()->FlowControl(record, ipcUid, isNotificationExists); if (result != ERR_OK) { + message.BranchId(EventBranchId::BRANCH_5).ErrorCode(result).Message("publish failed with FlowControl"); return; } if (AssignToNotificationList(record) != ERR_OK) { ANS_LOGE("Failed to assign notification list"); + message.BranchId(EventBranchId::BRANCH_5).ErrorCode(result).Message("Failed to assign notification list"); return; } @@ -385,6 +398,7 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s }); notificationSvrQueue_->wait(handler); if (result != ERR_OK) { + NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return result; } -- Gitee From 5a20a115ffb1943e9cab575964cc065e4e5ca7f8 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Wed, 16 Apr 2025 19:55:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=89=93=E7=82=B9=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- .../ans/src/advanced_notification_publish_service.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 69a356934..df00fb015 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -303,8 +303,6 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_9, EventBranchId::BRANCH_0); if (!request) { ANS_LOGE("Request object is nullptr"); - message.ErrorCode(ERR_ANS_INVALID_PARAM).Message("Request object is nullptr"); - NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return ERR_ANS_INVALID_PARAM; } ErrCode result = PrePublishRequest(request); @@ -329,23 +327,17 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s sptr bundleOption = new (std::nothrow) NotificationBundleOption(bundle, uid); if (record->bundleOption == nullptr || bundleOption == nullptr) { ANS_LOGE("Failed to create bundleOption"); - message.ErrorCode(ERR_ANS_NO_MEMORY).Message("Failed to create bundleOption"); - NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return ERR_ANS_NO_MEMORY; } record->bundleOption->SetAppInstanceKey(request->GetAppInstanceKey()); record->notification = new (std::nothrow) Notification(request); if (record->notification == nullptr) { ANS_LOGE("Failed to create notification"); - message.ErrorCode(ERR_ANS_NO_MEMORY).Message("Failed to create notification"); - NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return ERR_ANS_NO_MEMORY; } if (notificationSvrQueue_ == nullptr) { ANS_LOGE("Serial queue is invalid."); - message.ErrorCode(ERR_ANS_NO_MEMORY).Message("Serial queue is invalid."); - NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); return ERR_ANS_INVALID_PARAM; } -- Gitee