From 3af0d60792139a7c8c88698f680e116ea3cad62b Mon Sep 17 00:00:00 2001 From: liwang <965027894@qq.com> Date: Wed, 10 Sep 2025 10:51:27 +0800 Subject: [PATCH] =?UTF-8?q?disableNotificationFeature=E6=8E=A5=E5=8F=A3401?= =?UTF-8?q?=E6=83=85=E5=86=B5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liwang <965027894@qq.com> --- .../ets/ani/src/manager/ani_notification_enable.cpp | 5 ++--- frameworks/ets/ets/@ohos.notificationManager.ets | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp index 71c3c256d..3224058a3 100644 --- a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp @@ -161,9 +161,8 @@ void AniDisableNotificationFeature(ani_env *env, ani_boolean disabled, ani_objec ANS_LOGD("AniDisableNotificationFeature enter"); std::vector bundleListStd; if (!NotificationSts::GetStringArrayByAniObj(env, bundleList, bundleListStd)) { - std::string msg = "Invalid bundleList: must be an array of strings."; - ANS_LOGE("GetStringArrayByAniObj failed. msg: %{public}s", msg.c_str()); - OHOS::NotificationSts::ThrowError(env, Notification::ERROR_PARAM_INVALID, msg); + ANS_LOGE("GetStringArrayByAniObj failed. Invalid bundleList"); + OHOS::NotificationSts::ThrowStsErrorWithInvalidParam(env); return; } Notification::NotificationDisable param; diff --git a/frameworks/ets/ets/@ohos.notificationManager.ets b/frameworks/ets/ets/@ohos.notificationManager.ets index bc9a8dfa3..363d60eab 100644 --- a/frameworks/ets/ets/@ohos.notificationManager.ets +++ b/frameworks/ets/ets/@ohos.notificationManager.ets @@ -2426,6 +2426,14 @@ export default namespace notificationManager { } export function disableNotificationFeature(disabled:boolean, bundleList: Array): Promise { + if (bundleList.length == 0) { + throw errorParamInvalid; + } + bundleList.forEach((value, index, bundleList) => { + if (value.trim().isEmpty()) { + throw errorParamInvalid; + } + }); let pPromise = new Promise((resolve: ResolveCallback, reject: RejectCallback): void => { let p = taskpool.execute((): void => { nativedisableNotificationFeature(disabled,bundleList); -- Gitee