diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 460edc41a2bc9a4b15248b8933d15a2df7e1c44e..958b9bae6d0662034f52c9280fad720cfd31f750 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 2d3f236757b66bd901c4e7ea6b4d5847c8d9984e..c873f6127c6244027e02ecbbced044304a36b3d8 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) { 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 1a80864fc2af1af548ba0b95e404c2ed4a6d1a8c..8beae1eb6b14d27b60212aad07c7a51e4dcc8a46 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