From cc4aa225f40e8256d3feba42186dd251963f66c4 Mon Sep 17 00:00:00 2001 From: xiaoshuai Date: Thu, 16 May 2024 18:11:08 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20d652355=20from=20https://gitee.com/shaw?= =?UTF-8?q?=5Fcoco/notification=5Fdistributed=5Fnotification=5Fservice/pul?= =?UTF-8?q?ls/1717=20=20=E6=B6=88=E6=81=AF=E8=81=9A=E5=90=88-=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E5=BC=80=E5=85=B3,=E5=85=B3=E9=97=AD=E6=B8=85?= =?UTF-8?q?=E7=A9=BAgroupinfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaoshuai Change-Id: Ie9cab5173c2b03b66c58dd25a69417ec19eafc07 --- .../include/advanced_notification_service.h | 8 +++++++- ...nced_aggregation_data_roaming_observer.cpp | 5 +++-- .../ans/src/advanced_datashare_observer.cpp | 4 ++-- .../advanced_notification_publish_service.cpp | 19 +++++++++++++++++++ .../ans/src/advanced_notification_service.cpp | 2 +- .../src/notification_extension_wrapper.cpp | 4 ++-- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 6516b3666..bd64933c2 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1013,6 +1013,12 @@ public: * @return Returns set result. */ ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status) override; + + /** + * @brief clear notification when aggregate local switch close. + */ + void ClearAllNotificationGroupInfo(std::string localSwitch); + /** * @brief Reset pushcallback proxy */ @@ -1325,7 +1331,7 @@ private: static std::mutex pushMutex_; static std::map> pushCallBacks_; static std::map> checkRequests_; - + bool aggregateLocalSwitch_ = false; std::shared_ptr runner_ = nullptr; std::shared_ptr handler_ = nullptr; std::list> notificationList_; diff --git a/services/ans/src/advanced_aggregation_data_roaming_observer.cpp b/services/ans/src/advanced_aggregation_data_roaming_observer.cpp index 4bd9f3f78..584f18ce7 100644 --- a/services/ans/src/advanced_aggregation_data_roaming_observer.cpp +++ b/services/ans/src/advanced_aggregation_data_roaming_observer.cpp @@ -29,13 +29,14 @@ void AdvancedAggregationDataRoamingObserver::OnChange() { string enable = ""; AdvancedNotificationService::GetInstance()->GetUnifiedGroupInfoFromDb(enable); - ANS_LOGI("fengyunfei GetUnifiedGroupInfoFromDb enter, enable:%{public}s", enable.c_str()); + ANS_LOGI("GetUnifiedGroupInfoFromDb enter, enable:%{public}s", enable.c_str()); #ifdef ENABLE_ANS_EXT_WRAPPER EXTENTION_WRAPPER->SetlocalSwitch(enable); + AdvancedNotificationService::GetInstance()->ClearAllNotificationGroupInfo(enable); #else ANS_LOGD("Not enabled ans_ext"); #endif } } // namespace Telephony -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/ans/src/advanced_datashare_observer.cpp b/services/ans/src/advanced_datashare_observer.cpp index e577ef7b8..13e8ead26 100644 --- a/services/ans/src/advanced_datashare_observer.cpp +++ b/services/ans/src/advanced_datashare_observer.cpp @@ -62,7 +62,7 @@ void AdvancedDatashareObserver::UnRegisterSettingsObserver( void AdvancedDatashareObserver::RegisterSettingsObserver( const Uri &uri, const sptr &dataObserver) { - ANS_LOGI("fengyunfei AdvancedDatashareObserver::RegisterSettingsObserver enter"); + ANS_LOGD("AdvancedDatashareObserver::RegisterSettingsObserver enter"); std::shared_ptr settingHelper = CreateDataShareHelper(); if (settingHelper == nullptr) { ANS_LOGE("Register settings observer by nullptr"); @@ -84,4 +84,4 @@ void AdvancedDatashareObserver::NotifyChange(const Uri &uri) } } // namespace Notification -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 902d65cf2..0de1e1aa8 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -2194,5 +2194,24 @@ ErrCode AdvancedNotificationService::SetTargetDeviceStatus(const std::string &de deviceType.c_str(), DelayedSingleton::GetInstance()->GetDeviceStatus(deviceType)); return ret; } + +void AdvancedNotificationService::ClearAllNotificationGroupInfo(std::string localSwitch) +{ + ANS_LOGD("ClearNotification enter."); + bool status = (localSwitch == "true"); + if (notificationSvrQueue_ == nullptr) { + ANS_LOGE("ClearNotification Serial queue is invalid."); + return; + } + + ffrt::task_handle handler = notificationSvrQueue_->submit_h([=]() { + if (aggregateLocalSwitch_ && !status) { + for (const auto& item : notificationList_) { + item->notification->GetNotificationRequestPoint()->SetUnifiedGroupInfo(nullptr); + } + } + aggregateLocalSwitch_ = status; + }); +} } // namespace Notification } // namespace OHOS diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 5b35e2753..c2c955648 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1055,7 +1055,7 @@ ErrCode AdvancedNotificationService::GetUnifiedGroupInfoFromDb(std::string &enab Uri enableUri(datashareHelper->GetUnifiedGroupEnableUri()); bool ret = datashareHelper->Query(enableUri, KEY_UNIFIED_GROUP_ENABLE, enable); if (!ret) { - ANS_LOGE("Query focus mode enable fail."); + ANS_LOGE("Query smart aggregation switch failed."); return -1; } diff --git a/services/ans/src/notification_extension_wrapper.cpp b/services/ans/src/notification_extension_wrapper.cpp index 4460e4721..c38046ab7 100644 --- a/services/ans/src/notification_extension_wrapper.cpp +++ b/services/ans/src/notification_extension_wrapper.cpp @@ -89,13 +89,13 @@ void ExtensionWrapper::SetlocalSwitch(std::string &enable) void ExtensionWrapper::RegisterDataSettingObserver() { - ANS_LOGI("fengyunfei ExtensionWrapper::RegisterDataSettingObserver enter"); + ANS_LOGD("ExtensionWrapper::RegisterDataSettingObserver enter"); if (aggregationRoamingObserver_ == nullptr) { aggregationRoamingObserver_ = new (std::nothrow) AdvancedAggregationDataRoamingObserver(); } if (aggregationRoamingObserver_ == nullptr) { - ANS_LOGI("aggregationRoamingObserver_ is null"); + ANS_LOGE("aggregationRoamingObserver_ is null"); return; } -- Gitee