diff --git a/frameworks/ans/src/notification_subscriber.cpp b/frameworks/ans/src/notification_subscriber.cpp index a68adb1ebe3fdc25d8290190513ee95bb829697d..babc6cc5e4628d9563a2a7e4455cec563207a63a 100644 --- a/frameworks/ans/src/notification_subscriber.cpp +++ b/frameworks/ans/src/notification_subscriber.cpp @@ -45,6 +45,14 @@ std::string NotificationSubscriber::GetDeviceType() const bool NotificationSubscriber::ProcessSyncDecision( const std::string &deviceType, std::shared_ptr ¬ification) const { +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER + if ((request->GetNotificationControlFlags() & 1 << 25) != 0 && + (request->GetSlotType() == NotificationConstant::SlotType::CONTENT_INFORMATION || + request->GetSlotType() == NotificationConstant::SlotType::OTHER)) { + ANS_LOGD("No need to consume privileged message."); + return true; + } +#endif sptr request = notification->GetNotificationRequestPoint(); if (request == nullptr) { ANS_LOGE("No need to consume cause invalid reqeuest."); diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn index 6f83c282502c2b20b83db430f9c4157e383eb175..4a65f0ce15dd504253cf0539d9c6cc24d160660f 100644 --- a/services/ans/BUILD.gn +++ b/services/ans/BUILD.gn @@ -199,9 +199,8 @@ ohos_source_set("ans_service_sources") { defines += [ "ENABLE_ANS_EXT_WRAPPER" ] } - if (distributed_notification_service_feature_summary && - distributed_notification_service_feature_privileged_message) { - defines += [ "ENABLE_ANS_USERGROWTH_EXT_WRAPPER" ] + if (distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER" ] } if (telephony_cust) { diff --git a/services/ans/include/notification_extension_wrapper.h b/services/ans/include/notification_extension_wrapper.h index b915dad2bc12c5f8c1b3fe3c6465e8b107578cca..455a12cdca893de3a2d79a23057908bf08e0466f 100644 --- a/services/ans/include/notification_extension_wrapper.h +++ b/services/ans/include/notification_extension_wrapper.h @@ -42,7 +42,9 @@ public: typedef void (*UPDATE_BY_BUNDLE)(const std::string bundleName, int deleteType); typedef int32_t (*REMINDER_CONTROL)(const std::string &bundleName); typedef int32_t (*BANNER_CONTROL)(const std::string &bundleName); +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER typedef void (*MODIFY_REMINDER_FLAGS)(const sptr &request); +#endif ErrCode SyncAdditionConfig(const std::string& key, const std::string& value); void UpdateByCancel(const std::vector>& notifications, int deleteReason); @@ -54,7 +56,9 @@ public: void UpdateByBundle(const std::string bundleName, int deleteType); int32_t ReminderControl(const std::string &bundleName); int32_t BannerControl(const std::string &bundleName); +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER void ModifyReminderFlags(const sptr &request); +#endif private: static int32_t convertToDelType(int32_t deleteReason); @@ -70,7 +74,9 @@ private: REMINDER_CONTROL reminderControl_ = nullptr; BANNER_CONTROL bannerControl_ = nullptr; bool isRegisterDataSettingObserver = false; +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER MODIFY_REMINDER_FLAGS modifyReminderFlags_ = nullptr; +#endif }; #define EXTENTION_WRAPPER ::OHOS::DelayedSingleton::GetInstance() diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index f3af1399d62b695d110ba6c863e628a1dc264662..1f1c36f159559f8552e7d9e40fe956ee7f5eafc7 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -983,7 +983,7 @@ void AdvancedNotificationService::ChangeNotificationByControlFlags(const std::sh flags->SetStatusIconEnabled(false); } -#ifdef ENABLE_ANS_USERGROWTH_EXT_WRAPPER +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER EXTENTION_WRAPPER->ModifyReminderFlags(record->request); if (flags->IsSoundEnabled() == NotificationConstant::FlagStatus::OPEN) { record->notification->SetEnableSound(true); @@ -1616,7 +1616,7 @@ ErrCode AdvancedNotificationService::FlowControl(const std::shared_ptrrequest->IsAlertOneTime()) { - CloseAlert(record); + CloseAlert(record); } result = UpdateFlowCtrl(record, callingUid); } @@ -1642,7 +1642,7 @@ ErrCode AdvancedNotificationService::PublishFlowCtrl(const std::shared_ptrisThirdparty == true) { @@ -2182,7 +2182,7 @@ ErrCode AdvancedNotificationService::UnregisterPushCallback() ANS_LOGE("The registration callback has not been processed yet."); return ERR_INVALID_OPERATION; } - + { std::lock_guard lock(pushMutex_); pushCallBacks_.clear(); diff --git a/services/ans/src/notification_extension_wrapper.cpp b/services/ans/src/notification_extension_wrapper.cpp index 28ae36c9918286b029ac6f1e5b75c24c2a2e4304..7bafabe5504f234863fe432bc234f6efff83990e 100644 --- a/services/ans/src/notification_extension_wrapper.cpp +++ b/services/ans/src/notification_extension_wrapper.cpp @@ -61,14 +61,24 @@ void ExtensionWrapper::InitExtentionWrapper() localControl_ = (LOCAL_CONTROL)dlsym(extensionWrapperHandle_, "LocalControl"); reminderControl_ = (REMINDER_CONTROL)dlsym(extensionWrapperHandle_, "ReminderControl"); bannerControl_ = (BANNER_CONTROL)dlsym(extensionWrapperHandle_, "BannerControl"); +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER modifyReminderFlags_ = (MODIFY_REMINDER_FLAGS)dlsym(extensionWrapperHandle_, "ModifyReminderFlags"); +#endif + if (syncAdditionConfig_ == nullptr || bannerControl_ == nullptr || localControl_ == nullptr - || reminderControl_ == nullptr || modifyReminderFlags_ == nullptr) { + || reminderControl_ == nullptr) { ANS_LOGE("extension wrapper symbol failed, error: %{public}s", dlerror()); return; } +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER + if (modifyReminderFlags_ == nullptr) { + ANS_LOGE("extension wrapper modifyReminderFlags symbol failed, error: %{public}s", dlerror()); + return; + } +#endif + std::string ctrlConfig = NotificationPreferences::GetInstance()->GetAdditionalConfig("NOTIFICATION_CTL_LIST_PKG"); if (!ctrlConfig.empty()) { syncAdditionConfig_("NOTIFICATION_CTL_LIST_PKG", ctrlConfig); @@ -168,6 +178,7 @@ int32_t ExtensionWrapper::BannerControl(const std::string &bundleName) return bannerControl_(bundleName); } +#ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER void ExtensionWrapper::ModifyReminderFlags(const sptr &request) { if (modifyReminderFlags_ == nullptr) { @@ -176,6 +187,7 @@ void ExtensionWrapper::ModifyReminderFlags(const sptr &requ } modifyReminderFlags_(request); } +#endif __attribute__((no_sanitize("cfi"))) int32_t ExtensionWrapper::LocalControl(const sptr &request) {