diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 6516b3666ec52f77d37c755cf725ec9a819a73cf..bd64933c23ca15f3ee77b875c48f6523427d2a7b 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 4bd9f3f78fffda20c32356050d1e14f6ee6a7d2e..584f18ce768b451ffb0bb209c12f10bd82f99dba 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 e577ef7b87548c0c2ccbfe93d8e70c56f3355d1b..13e8ead264591e245b14ddfe7467ccd5e81102e9 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 902d65cf2c4ad431c0673c4886302133b3cc45c6..0de1e1aa801a58e72f1cefb9b6b17467f034f640 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 5b35e275301c6f5e1e820cf4ecf829bfa408c2c3..c2c955648e9a964b90e46269e1208ab23a890edb 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 4460e4721a3dc46179a1ef29f54caf4cd0ecc194..c38046ab7012f2d7d94b73b4130168eef3292dde 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; }