diff --git a/frameworks/js/napi/src/manager/napi_sync_config.cpp b/frameworks/js/napi/src/manager/napi_sync_config.cpp index 65f049804f28e32243b98abd7121aad71f95739d..fba201cc9845753555a4c696b9cfe74ca4c4c4d4 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 501d91b4a44ac7e67b226eb55106527fba1f46a4..6cfed332d596201eb28897f30cf43269850594e4 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 5d53c8a99601908592e6cb6c3a907c1da244f1b3..fcb7aaff735eb5ae8fa1b2d2397a5ce76d391772 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 0fbd7f518a7dbcf560d97284754d156e22ee4234..cffbca1a21c591952b7ae8c4876e0b45fd771542 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 8f95de83d943431367cbbf43082ca8cd2291c1d9..ffe04b7fc5a73f7bb3baae1e38ef1947fb56134e 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