From 89287f6b43667dc523c0a8726adf523db40a544b Mon Sep 17 00:00:00 2001 From: xdongs Date: Sat, 13 Sep 2025 15:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=BF=90=E5=8A=A8=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E7=99=BD=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xdongs --- .../js/napi/src/manager/napi_sync_config.cpp | 5 ++- interfaces/inner_api/notification_constant.h | 1 + services/ans/include/smart_reminder_center.h | 1 + .../ans/src/advanced_notification_service.cpp | 1 - .../smart_reminder_center.cpp | 34 +++++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/frameworks/js/napi/src/manager/napi_sync_config.cpp b/frameworks/js/napi/src/manager/napi_sync_config.cpp index 65f049804..fba201cc9 100644 --- a/frameworks/js/napi/src/manager/napi_sync_config.cpp +++ b/frameworks/js/napi/src/manager/napi_sync_config.cpp @@ -27,6 +27,7 @@ namespace { constexpr char RING_LIST_KEY_NAME[] = "RING_TRUSTLIST_PKG"; constexpr char CTRL_LIST_KEY_NAME[] = "NOTIFICATION_CTL_LIST_PKG"; constexpr char CAMPAIGN_NOTIFICATION_SWITCH_LIST_PKG[] = "CAMPAIGN_NOTIFICATION_SWITCH_LIST_PKG"; + constexpr char HEALTH_BUNDLE_WHITE_LIST[] = "HEALTH_BUNDLE_WHITE_LIST"; } struct ConfigParams { @@ -71,7 +72,9 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, params.key = keyStr; if (std::strlen(keyStr) == 0 || (strcmp(keyStr, KEY_NAME) != 0 && strcmp(keyStr, RING_LIST_KEY_NAME) != 0 - && strcmp(keyStr, CTRL_LIST_KEY_NAME) != 0 && strcmp(keyStr, CAMPAIGN_NOTIFICATION_SWITCH_LIST_PKG) != 0)) { + && strcmp(keyStr, CTRL_LIST_KEY_NAME) != 0 + && strcmp(keyStr, CAMPAIGN_NOTIFICATION_SWITCH_LIST_PKG) != 0 + && strcmp(keyStr, HEALTH_BUNDLE_WHITE_LIST) != 0)) { ANS_LOGE("Argument type error. String expected."); std::string msg = "Incorrect parameter types.The type of param must be string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); diff --git a/interfaces/inner_api/notification_constant.h b/interfaces/inner_api/notification_constant.h index 501d91b4a..6cfed332d 100644 --- a/interfaces/inner_api/notification_constant.h +++ b/interfaces/inner_api/notification_constant.h @@ -440,6 +440,7 @@ public: constexpr static const char* DEVICESTYPES[] = {"headset", "liteWearable", "wearable", "2in1", "tablet"}; constexpr static const char* ANS_VOIP = "ANS_VOIP"; constexpr static const char* PC_PAD_VOIP_FLAG = "110101"; + constexpr static const char* HEALTH_BUNDLE_WHITE_LIST = "HEALTH_BUNDLE_WHITE_LIST"; }; } // namespace Notification } // namespace OHOS diff --git a/services/ans/include/smart_reminder_center.h b/services/ans/include/smart_reminder_center.h index 5d53c8a99..fcb7aaff7 100644 --- a/services/ans/include/smart_reminder_center.h +++ b/services/ans/include/smart_reminder_center.h @@ -101,6 +101,7 @@ private: const AppExecFwk::ApplicationInfo &appInfo, const AppExecFwk::BundleResourceInfo &bundleResourceInfo) const; bool IsCollaborationAllowed(const sptr &request) const; + bool CheckHealthWhiteList(const sptr &request, const string &deviceType) const; map> currentReminderMethods_; map>>> reminderMethods_; diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 0fbd7f518..cffbca1a2 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -667,7 +667,6 @@ ErrCode AdvancedNotificationService::PublishPreparedNotification(const sptrIsSilentReminderEnabled(bundleOption, enableStatus); if (enableStatus == NotificationConstant::SWITCH_STATE::USER_MODIFIED_OFF || enableStatus == NotificationConstant::SWITCH_STATE::SYSTEM_DEFAULT_OFF) { - ANS_LOGI("xds-test"); EXTENTION_WRAPPER->HandlePrivilegeMessage(bundleOption, request, isAgentController); } #endif diff --git a/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp b/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp index 8f95de83d..ffe04b7fc 100644 --- a/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp +++ b/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp @@ -346,6 +346,9 @@ void SmartReminderCenter::InitValidDevices( ANS_LOGI("liveView smart switch is closed, deviceType = %{public}s", deviceType.c_str()); continue; } + if (!CheckHealthWhiteList(request, deviceType)) { + continue; + } syncDevices.insert(deviceType); smartDevices.insert(deviceType); request->SetNotificationControlFlags(notificationControlFlags | CONTROL_BY_SMART_REMINDER); @@ -772,6 +775,37 @@ void SmartReminderCenter::GetDeviceStatusByType( } ANS_LOGI("deviceType: %{public}s, bitStatus: %{public}s", deviceType.c_str(), bitStatus.to_string().c_str()); } + +bool SmartReminderCenter::CheckHealthWhiteList(const sptr &request, + const string &deviceType) const +{ + if (NotificationConstant::SlotType::LIVE_VIEW != request->GetSlotType()) { + return true; + } + + if (deviceType.compare(NotificationConstant::WEARABLE_DEVICE_TYPE) != 0 && + deviceType.compare(NotificationConstant::LITEWEARABLE_DEVICE_TYPE) != 0) { + return true; + } + + std::string value; + NotificationPreferences::GetInstance()->GetKvFromDb(NotificationConstant::HEALTH_BUNDLE_WHITE_LIST, + value, SUBSCRIBE_USER_INIT); + if (value.empty()) { + return true; + } + + std::string bundleName = request->GetOwnerBundleName(); + if (bundleName.empty()) { + return true; + } + bool notInWhiteList = value.find(bundleName) == std::string::npos; + if (notInWhiteList) { + ANS_LOGI("not in white list. bundleName = %{public}s", bundleName.c_str()); + return false; + } + return true; +} } // namespace Notification } // namespace OHOS #endif -- Gitee