From daafeb7e520b14066cd40152526a98b4c64d721a Mon Sep 17 00:00:00 2001 From: songbao1 Date: Mon, 21 Apr 2025 11:23:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=AA=81=E7=A0=B4=E5=85=8D=E6=89=93?= =?UTF-8?q?=E6=89=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- frameworks/ans/src/notification_request.cpp | 18 ++++++++++++++++++ .../ans/test/unittest/notification_test.cpp | 3 ++- interfaces/inner_api/notification_request.h | 5 +++++ .../advanced_notification_publish_service.cpp | 8 ++++++-- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index 96ce61f2b..66941765f 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") + + ", isSkipDoNotDisturbMode = " + (isSkipDoNotDisturbMode_ ? "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(isSkipDoNotDisturbMode_)) { + 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(); + isSkipDoNotDisturbMode_ = parcel.ReadBool(); bool valid {false}; @@ -1970,6 +1977,16 @@ void NotificationRequest::SetIsSystemApp(bool isSystemApp) isSystemApp_ = isSystemApp; } +bool NotificationRequest::IsSkipDoNotDisturbMode() const +{ + return isSkipDoNotDisturbMode_; +} + +void NotificationRequest::SetIsSkipDoNotDisturbMode(bool isSkipDoNotDisturbMode) +{ + isSkipDoNotDisturbMode_ = isSkipDoNotDisturbMode; +} + 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->isSkipDoNotDisturbMode_ = other.isSkipDoNotDisturbMode_; 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 17937fcd6..b735bd7f4 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, isSkipDoNotDisturbMode = isSkipDoNotDisturbMode_, " + "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 eaabdb4f9..2e10d6f7c 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 IsSkipDoNotDisturbMode() const; + + void SetIsSkipDoNotDisturbMode(bool isSkipDoNotDisturbMode); + bool IsCommonLiveView() const; bool IsSystemLiveView() const; @@ -1595,6 +1599,7 @@ private: bool forceDistributed_ {false}; bool notDistributed_ {false}; bool isSystemApp_ {false}; + bool isSkipDoNotDisturbMode_ {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 461958549..1f4badc33 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -381,7 +381,9 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s return; } - CheckDoNotDisturbProfile(record); + if (!request->IsSkipDoNotDisturbMode()) { + CheckDoNotDisturbProfile(record); + } ChangeNotificationByControlFlags(record, isAgentController); if (IsSaCreateSystemLiveViewAsBundle(record, ipcUid) && (std::static_pointer_cast( @@ -2625,7 +2627,9 @@ ErrCode AdvancedNotificationService::PublishNotificationBySa(const sptrIsSkipDoNotDisturbMode()) { + CheckDoNotDisturbProfile(record); + } ChangeNotificationByControlFlags(record, isAgentController); if (IsSaCreateSystemLiveViewAsBundle(record, ipcUid) && (std::static_pointer_cast( -- Gitee From c099b8c75f34dbcafb11d8fb561f70befc5e6cff Mon Sep 17 00:00:00 2001 From: songbao1 Date: Mon, 21 Apr 2025 11:44:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=AA=81=E7=A0=B4=E5=85=8D=E6=89=93?= =?UTF-8?q?=E6=89=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- .../test/unittest/advanced_notification_publish_service_test.cpp | 1 + 1 file changed, 1 insertion(+) 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 082570138..7609baa2c 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->SetIsSkipDoNotDisturbMode(true); MockIsOsAccountExists(true); MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE); -- Gitee From e586d69927d31d4b86a06391b27282af7e33a573 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Mon, 21 Apr 2025 14:47:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=AA=81=E7=A0=B4=E5=85=8D=E6=89=93?= =?UTF-8?q?=E6=89=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- frameworks/ans/src/notification_request.cpp | 16 ++++++++-------- .../ans/test/unittest/notification_test.cpp | 2 +- interfaces/inner_api/notification_request.h | 6 +++--- .../advanced_notification_publish_service.cpp | 4 ++-- ...dvanced_notification_publish_service_test.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index 66941765f..f1175fdab 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -804,7 +804,7 @@ std::string NotificationRequest::Dump() ", updateOnly = " + (updateOnly_ ? "true" : "false") + ", isForceDistributed = " + (forceDistributed_ ? "true" : "false") + ", isNotDistributed = " + (notDistributed_ ? "true" : "false") + - ", isSkipDoNotDisturbMode = " + (isSkipDoNotDisturbMode_ ? "true" : "false") + + ", isDoNotDisturbByPassed = " + (isDoNotDisturbByPassed_ ? "true" : "false") + ", removalWantAgent = " + (removalWantAgent_ ? "not null" : "null") + ", maxScreenWantAgent = " + (maxScreenWantAgent_ ? "not null" : "null") + ", additionalParams = " + (additionalParams_ ? "not null" : "null") + @@ -1244,7 +1244,7 @@ bool NotificationRequest::Marshalling(Parcel &parcel) const return false; } - if (!parcel.WriteBool(isSkipDoNotDisturbMode_)) { + if (!parcel.WriteBool(isDoNotDisturbByPassed_)) { ANS_LOGE("Failed to write flag notDistributed"); return false; } @@ -1673,7 +1673,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) isRemoveAllowed_ = parcel.ReadBool(); forceDistributed_ = parcel.ReadBool(); notDistributed_ = parcel.ReadBool(); - isSkipDoNotDisturbMode_ = parcel.ReadBool(); + isDoNotDisturbByPassed_ = parcel.ReadBool(); bool valid {false}; @@ -1977,14 +1977,14 @@ void NotificationRequest::SetIsSystemApp(bool isSystemApp) isSystemApp_ = isSystemApp; } -bool NotificationRequest::IsSkipDoNotDisturbMode() const +bool NotificationRequest::IsDoNotDisturbByPassed() const { - return isSkipDoNotDisturbMode_; + return isDoNotDisturbByPassed_; } -void NotificationRequest::SetIsSkipDoNotDisturbMode(bool isSkipDoNotDisturbMode) +void NotificationRequest::SetIsDoNotDisturbByPassed(bool isDoNotDisturbByPassed) { - isSkipDoNotDisturbMode_ = isSkipDoNotDisturbMode; + isDoNotDisturbByPassed_ = isDoNotDisturbByPassed; } void NotificationRequest::CopyBase(const NotificationRequest &other) @@ -2014,7 +2014,7 @@ void NotificationRequest::CopyBase(const NotificationRequest &other) this->forceDistributed_ = other.forceDistributed_; this->notDistributed_ = other.notDistributed_; this->isSystemApp_ = other.isSystemApp_; - this->isSkipDoNotDisturbMode_ = other.isSkipDoNotDisturbMode_; + 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 b735bd7f4..925ad26cd 100644 --- a/frameworks/ans/test/unittest/notification_test.cpp +++ b/frameworks/ans/test/unittest/notification_test.cpp @@ -314,7 +314,7 @@ 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, isSkipDoNotDisturbMode = isSkipDoNotDisturbMode_, " + "isNotDistributed = false, isDoNotDisturbByPassed = isDoNotDisturbByPassed_, " "removalWantAgent = null, maxScreenWantAgent = null, " "additionalParams = null, littleIcon = null, bigIcon = null, overlayIcon = null, " "notificationContent = null, notificationTemplate = null, actionButtons = empty, " diff --git a/interfaces/inner_api/notification_request.h b/interfaces/inner_api/notification_request.h index 2e10d6f7c..4788f2fc6 100644 --- a/interfaces/inner_api/notification_request.h +++ b/interfaces/inner_api/notification_request.h @@ -1255,9 +1255,9 @@ public: void SetIsSystemApp(bool isSystemApp); - bool IsSkipDoNotDisturbMode() const; + bool IsDoNotDisturbByPassed() const; - void SetIsSkipDoNotDisturbMode(bool isSkipDoNotDisturbMode); + void SetIsDoNotDisturbByPassed(bool isDoNotDisturbByPassed); bool IsCommonLiveView() const; @@ -1599,7 +1599,7 @@ private: bool forceDistributed_ {false}; bool notDistributed_ {false}; bool isSystemApp_ {false}; - bool isSkipDoNotDisturbMode_ {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 1f4badc33..158e58c58 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -381,7 +381,7 @@ ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const s return; } - if (!request->IsSkipDoNotDisturbMode()) { + if (!request->IsDoNotDisturbByPassed()) { CheckDoNotDisturbProfile(record); } ChangeNotificationByControlFlags(record, isAgentController); @@ -2627,7 +2627,7 @@ ErrCode AdvancedNotificationService::PublishNotificationBySa(const sptrIsSkipDoNotDisturbMode()) { + if (!request->IsDoNotDisturbByPassed()) { CheckDoNotDisturbProfile(record); } ChangeNotificationByControlFlags(record, isAgentController); 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 7609baa2c..62c53f998 100644 --- a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp @@ -294,7 +294,7 @@ HWTEST_F(AnsPublishServiceTest, Publish_00007, Function | SmallTest | Level1) request->SetSlotType(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); request->SetOwnerUid(1); request->SetIsAgentNotification(true); - request->SetIsSkipDoNotDisturbMode(true); + request->SetIsDoNotDisturbByPassed(true); MockIsOsAccountExists(true); MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE); -- Gitee From 2369dbdcdc02cc84444bb25be9773d3d10d50e8b Mon Sep 17 00:00:00 2001 From: luojingsong Date: Mon, 21 Apr 2025 11:10:43 +0000 Subject: [PATCH 4/4] update frameworks/ans/test/unittest/notification_test.cpp. Signed-off-by: luojingsong --- frameworks/ans/test/unittest/notification_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/ans/test/unittest/notification_test.cpp b/frameworks/ans/test/unittest/notification_test.cpp index 274e5d366..efd6ae753 100644 --- a/frameworks/ans/test/unittest/notification_test.cpp +++ b/frameworks/ans/test/unittest/notification_test.cpp @@ -314,7 +314,7 @@ 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, isDoNotDisturbByPassed = isDoNotDisturbByPassed_, " + "isNotDistributed = false, isDoNotDisturbByPassed = false, " "removalWantAgent = null, maxScreenWantAgent = null, " "additionalParams = null, littleIcon = null, bigIcon = null, overlayIcon = null, " "notificationContent = null, notificationTemplate = null, actionButtons = empty, " -- Gitee