From 856d5ecbabc33e154416436df92897595b412564 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Fri, 25 Apr 2025 10:52:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=89=8D=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- .../ans/src/advanced_notification_service.cpp | 15 +++++++++------ .../ans/src/notification_subscriber_manager.cpp | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 460edc41a..958b9bae6 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -2208,6 +2208,10 @@ ErrCode AdvancedNotificationService::PushCheck(const sptr & { ANS_LOGD("start."); if (pushCallBacks_.find(request->GetSlotType()) == pushCallBacks_.end()) { + if (AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER) && + AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER)) { + return ERR_OK; + } return ERR_ANS_PUSH_CHECK_UNREGISTERED; } sptr pushCallBack = pushCallBacks_[request->GetSlotType()]; @@ -2233,16 +2237,15 @@ ErrCode AdvancedNotificationService::PushCheck(const sptr & } ErrCode result = pushCallBack->OnCheckNotification(jsonObject.dump(), pushCallBackParam); - if (AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER) && - AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER) && - result != ERR_OK) { - ANS_LOGI("The application with the permission fails to pushcheck."); - result = ERR_OK; - } if (result != ERR_OK) { HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_2, EventBranchId::BRANCH_5) .ErrorCode(result).Message("Push OnCheckNotification failed."); NotificationAnalyticsUtil::ReportPublishFailedEvent(request, message); + if (AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER) && + AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER)) { + ANS_LOGI("The application with the permission fails to pushcheck."); + result = ERR_OK; + } } if (pushCallBackParam != nullptr && !pushCallBackParam->eventControl.empty() && extroInfo != nullptr) { extroInfo->SetParam("eventControl", AAFwk::String::Box(pushCallBackParam->eventControl)); diff --git a/services/ans/src/notification_subscriber_manager.cpp b/services/ans/src/notification_subscriber_manager.cpp index 2d3f23675..c873f6127 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -599,7 +599,6 @@ bool NotificationSubscriberManager::IsSubscribedBysubscriber( return false; } auto soltType = notification->GetNotificationRequestPoint()->GetSlotType(); - ANS_LOGI("slotTypecount:%{public}d", (int)record->slotTypes.size()); auto slotIter = std::find(record->slotTypes.begin(), record->slotTypes.end(), soltType); bool isSubscribedSlotType = (record->slotTypes.size() == 0) || (slotIter != record->slotTypes.end()); if (!isSubscribedSlotType) { -- Gitee From ff1bddabc0d3b3df2b7cd2921d1054ca7558121f Mon Sep 17 00:00:00 2001 From: songbao1 Date: Fri, 25 Apr 2025 17:17:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=89=8D=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- .../advanced_notification_service_publish_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ans/test/unittest/advanced_notification_service_test/advanced_notification_service_publish_test.cpp b/services/ans/test/unittest/advanced_notification_service_test/advanced_notification_service_publish_test.cpp index 1a80864fc..8beae1eb6 100644 --- a/services/ans/test/unittest/advanced_notification_service_test/advanced_notification_service_publish_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test/advanced_notification_service_publish_test.cpp @@ -1363,7 +1363,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20000, EXPECT_EQ(nullptr, req->GetBigIcon()); req->SetOverlayIcon(nullptr); EXPECT_EQ(nullptr, req->GetOverlayIcon()); - ASSERT_EQ(advancedNotificationService_->Publish("label", req), (int)ERR_ANS_PUSH_CHECK_UNREGISTERED); + ASSERT_EQ(advancedNotificationService_->Publish("label", req), (int)ERR_OK); } } // namespace Notification } // namespace OHOS -- Gitee