diff --git a/frameworks/ans/core/src/ans_notification.cpp b/frameworks/ans/core/src/ans_notification.cpp index 74d77b835984f077a15a955e2497652666bad3f9..d57d6fc56df04dd2c2037e184252c5c0bad046fe 100644 --- a/frameworks/ans/core/src/ans_notification.cpp +++ b/frameworks/ans/core/src/ans_notification.cpp @@ -160,6 +160,11 @@ ErrCode AnsNotification::GetNotificationSlotGroups(std::vector> &slots) { + if (bundleOption.GetBundleName().empty()) { + ANS_LOGE("Invalid bundle name."); + return ERR_ANS_INVALID_PARAM; + } + if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -586,6 +611,11 @@ ErrCode AnsNotification::UpdateNotificationSlots( ErrCode AnsNotification::UpdateNotificationSlotGroups( const NotificationBundleOption &bundleOption, const std::vector> &groups) { + if (bundleOption.GetBundleName().empty()) { + ANS_LOGE("Invalid bundle name."); + return ERR_ANS_INVALID_PARAM; + } + if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -651,6 +681,11 @@ ErrCode AnsNotification::SetNotificationsEnabledForDefaultBundle(const std::stri ErrCode AnsNotification::SetNotificationsEnabledForSpecifiedBundle( const NotificationBundleOption &bundleOption, const std::string &deviceId, bool enabled) { + if (bundleOption.GetBundleName().empty()) { + ANS_LOGE("Invalid bundle name."); + return ERR_ANS_INVALID_PARAM; + } + if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -662,6 +697,11 @@ ErrCode AnsNotification::SetNotificationsEnabledForSpecifiedBundle( ErrCode AnsNotification::SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled) { + if (bundleOption.GetBundleName().empty()) { + ANS_LOGE("Invalid bundle name."); + return ERR_ANS_INVALID_PARAM; + } + if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -673,6 +713,11 @@ ErrCode AnsNotification::SetShowBadgeEnabledForBundle(const NotificationBundleOp ErrCode AnsNotification::GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled) { + if (bundleOption.GetBundleName().empty()) { + ANS_LOGE("Invalid bundle name."); + return ERR_ANS_INVALID_PARAM; + } + if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -712,6 +757,11 @@ ErrCode AnsNotification::GetDisturbMode(NotificationConstant::DisturbMode &distu ErrCode AnsNotification::CancelGroup(const std::string &groupName) { + if (groupName.empty()) { + ANS_LOGE("Invalid group name."); + return ERR_ANS_INVALID_PARAM; + } + if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -723,6 +773,11 @@ ErrCode AnsNotification::CancelGroup(const std::string &groupName) ErrCode AnsNotification::RemoveGroupByBundle( const NotificationBundleOption &bundleOption, const std::string &groupName) { + if (bundleOption.GetBundleName().empty() || groupName.empty()) { + ANS_LOGE("Invalid parameter."); + return ERR_ANS_INVALID_PARAM; + } + if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED;