diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index 96ce61f2b890ffd13332c7a2d148fc24f2ad961c..f1175fdabab39589f4feb4f5ade4ca360f39c8ca 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -804,6 +804,7 @@ std::string NotificationRequest::Dump() ", updateOnly = " + (updateOnly_ ? "true" : "false") + ", isForceDistributed = " + (forceDistributed_ ? "true" : "false") + ", isNotDistributed = " + (notDistributed_ ? "true" : "false") + + ", isDoNotDisturbByPassed = " + (isDoNotDisturbByPassed_ ? "true" : "false") + ", removalWantAgent = " + (removalWantAgent_ ? "not null" : "null") + ", maxScreenWantAgent = " + (maxScreenWantAgent_ ? "not null" : "null") + ", additionalParams = " + (additionalParams_ ? "not null" : "null") + @@ -1243,6 +1244,11 @@ bool NotificationRequest::Marshalling(Parcel &parcel) const return false; } + if (!parcel.WriteBool(isDoNotDisturbByPassed_)) { + ANS_LOGE("Failed to write flag notDistributed"); + return false; + } + // write objects which managed by std::shared_ptr bool valid {false}; @@ -1667,6 +1673,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) isRemoveAllowed_ = parcel.ReadBool(); forceDistributed_ = parcel.ReadBool(); notDistributed_ = parcel.ReadBool(); + isDoNotDisturbByPassed_ = parcel.ReadBool(); bool valid {false}; @@ -1970,6 +1977,16 @@ void NotificationRequest::SetIsSystemApp(bool isSystemApp) isSystemApp_ = isSystemApp; } +bool NotificationRequest::IsDoNotDisturbByPassed() const +{ + return isDoNotDisturbByPassed_; +} + +void NotificationRequest::SetIsDoNotDisturbByPassed(bool isDoNotDisturbByPassed) +{ + isDoNotDisturbByPassed_ = isDoNotDisturbByPassed; +} + void NotificationRequest::CopyBase(const NotificationRequest &other) { this->notificationId_ = other.notificationId_; @@ -1997,6 +2014,7 @@ void NotificationRequest::CopyBase(const NotificationRequest &other) this->forceDistributed_ = other.forceDistributed_; this->notDistributed_ = other.notDistributed_; this->isSystemApp_ = other.isSystemApp_; + this->isDoNotDisturbByPassed_ = other.isDoNotDisturbByPassed_; this->isCoverActionButtons_ = other.isCoverActionButtons_; this->isUpdateByOwnerAllowed_ = other.isUpdateByOwnerAllowed_; this->distributedCollaborate_ = other.distributedCollaborate_; diff --git a/frameworks/ans/test/unittest/notification_test.cpp b/frameworks/ans/test/unittest/notification_test.cpp index 7346ad2392d2a7a5f568e55f9b9235d5e0bce224..efd6ae7537ebc49196ea87f279a6fd113dbe494e 100644 --- a/frameworks/ans/test/unittest/notification_test.cpp +++ b/frameworks/ans/test/unittest/notification_test.cpp @@ -314,7 +314,8 @@ HWTEST_F(NotificationTest, Dump_00001, Function | SmallTest | Level1) "isCountdown = false, inProgress = false, groupOverview = false, isRemoveAllowed = true, " "progressIndeterminate = false, unremovable = false, floatingIcon = false, onlyLocal = false, " "permitted = true, isAgent = false, updateOnly = false, isForceDistributed = false, " - "isNotDistributed = false, removalWantAgent = null, maxScreenWantAgent = null, " + "isNotDistributed = false, isDoNotDisturbByPassed = false, " + "removalWantAgent = null, maxScreenWantAgent = null, " "additionalParams = null, littleIcon = null, bigIcon = null, overlayIcon = null, " "notificationContent = null, notificationTemplate = null, actionButtons = empty, " "messageUsers = empty, userInputHistory = empty, distributedOptions = " diff --git a/interfaces/inner_api/notification_request.h b/interfaces/inner_api/notification_request.h index eaabdb4f9ccceba3aa50ae17e7718f0f3da6e919..4788f2fc6c5c75702ee174ad1a59ee4adcbb9dc2 100644 --- a/interfaces/inner_api/notification_request.h +++ b/interfaces/inner_api/notification_request.h @@ -1255,6 +1255,10 @@ public: void SetIsSystemApp(bool isSystemApp); + bool IsDoNotDisturbByPassed() const; + + void SetIsDoNotDisturbByPassed(bool isDoNotDisturbByPassed); + bool IsCommonLiveView() const; bool IsSystemLiveView() const; @@ -1595,6 +1599,7 @@ private: bool forceDistributed_ {false}; bool notDistributed_ {false}; bool isSystemApp_ {false}; + bool isDoNotDisturbByPassed_ {false}; std::shared_ptr wantAgent_ {}; std::shared_ptr removalWantAgent_ {}; diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 8816f9761b6e2d781618ed8b945697e5c1095e8f..944754eebd16ebcd93708d5e836703f87bf35782 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -383,7 +383,9 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s return; } - CheckDoNotDisturbProfile(record); + if (!request->IsDoNotDisturbByPassed()) { + CheckDoNotDisturbProfile(record); + } ChangeNotificationByControlFlags(record, isAgentController); if (IsSaCreateSystemLiveViewAsBundle(record, ipcUid) && (std::static_pointer_cast( @@ -2636,7 +2638,9 @@ ErrCode AdvancedNotificationService::PublishNotificationBySa(const sptrrequest, ipcUid); - CheckDoNotDisturbProfile(record); + if (!request->IsDoNotDisturbByPassed()) { + CheckDoNotDisturbProfile(record); + } ChangeNotificationByControlFlags(record, isAgentController); if (IsSaCreateSystemLiveViewAsBundle(record, ipcUid) && (std::static_pointer_cast( diff --git a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp index 955de927e1813e665344efaf394fed87e37eb6f4..38463ac082b18384ba03522a10c89380edaed641 100644 --- a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp @@ -294,6 +294,7 @@ HWTEST_F(AnsPublishServiceTest, Publish_00007, Function | SmallTest | Level1) request->SetSlotType(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); request->SetOwnerUid(1); request->SetIsAgentNotification(true); + request->SetIsDoNotDisturbByPassed(true); MockIsOsAccountExists(true); MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE);