diff --git a/frameworks/ets/ets/@ohos.notificationManager.ets b/frameworks/ets/ets/@ohos.notificationManager.ets index 81676b99bcd6df37fbd0b70580bc51f8b5308f51..23aeef8c69d8a429b5926cc887a31cc4cd64cb90 100644 --- a/frameworks/ets/ets/@ohos.notificationManager.ets +++ b/frameworks/ets/ets/@ohos.notificationManager.ets @@ -458,28 +458,6 @@ export default namespace notificationManager { } return true; } - function isInvalidUnifiedGroupInfo(unifiedGroupInfo?: UnifiedGroupInfo): boolean - { - if (unifiedGroupInfo === null) { - return false; - } - if (unifiedGroupInfo?.key != undefined && unifiedGroupInfo?.key?.trim() === '') { - return false; - } - if (unifiedGroupInfo?.title != undefined && unifiedGroupInfo?.title?.trim() === '') { - return false; - } - if (unifiedGroupInfo?.content != undefined && unifiedGroupInfo?.content?.trim() === '') { - return false; - } - if (unifiedGroupInfo?.sceneName != undefined && unifiedGroupInfo?.sceneName?.trim() === '') { - return false; - } - if (unifiedGroupInfo?.extraInfo != undefined && unifiedGroupInfo?.extraInfo == null) { - return false; - } - return true; - } function isInvalidBundleOption(bundleOption?: BundleOption): boolean { if (bundleOption === null) { @@ -552,18 +530,12 @@ export default namespace notificationManager { if (request.content?.liveView !== undefined && !isInvalidLiveView(request.content.liveView)) { return errorParamInvalid; } - if (request?.appMessageId !== undefined && request?.appMessageId?.trim() === '') { - return errorParamInvalid; - } if (request?.wantAgent !== undefined && request.wantAgent == null) { return errorParamInvalid; } if(request?.extendInfo !== undefined && request?.extendInfo == null) { return errorParamInvalid; } - if (request?.actionButtons !== undefined && request?.actionButtons?.length === 0) { - return errorParamInvalid; - } if (request.smallIcon !== undefined && request.smallIcon == null) { return errorParamInvalid; } @@ -573,30 +545,12 @@ export default namespace notificationManager { if (request?.overlayIcon !== undefined && request.overlayIcon == null) { return errorParamInvalid; } - if (request?.groupName !== undefined && request?.groupName?.trim() === '') { - return errorParamInvalid; - } - if (request?.creatorBundleName !== undefined && request?.creatorBundleName?.trim() === '') { - return errorParamInvalid; - } - if (request?.sound !== undefined && request?.sound?.trim() === '') { - return errorParamInvalid; - } - if (request?.classification !== undefined && request?.classification?.trim() === '') { - return errorParamInvalid; - } - if (request?.hashCode !== undefined && request?.hashCode?.trim() === '') { - return errorParamInvalid; - } if (request?.template !== undefined && !isInvalidTemplate(request.template)) { return errorParamInvalid; } if (request?.distributedOption !== undefined && !isInvalidDistributedOption(request.distributedOption)) { return errorParamInvalid; } - if (request?.deviceId !== undefined && request?.deviceId?.trim() === '') { - return errorParamInvalid; - } if (request?.removalWantAgent !== undefined && request.removalWantAgent == null) { return errorParamInvalid; } @@ -606,12 +560,6 @@ export default namespace notificationManager { if (request?.agentBundle !== undefined && !isInvalidBundleOption(request.agentBundle)) { return errorParamInvalid; } - if (request?.unifiedGroupInfo !== undefined && !isInvalidUnifiedGroupInfo(request.unifiedGroupInfo)) { - return errorParamInvalid; - } - if (request?.appInstanceKey !== undefined && request?.appInstanceKey?.trim() === '') { - return errorParamInvalid; - } if (request?.color !== undefined && typeof request.color === 'number') { const num = request.color ?? -1; if (num < 0) { diff --git a/frameworks/ets/ets/@ohos.notificationSubscribe.ets b/frameworks/ets/ets/@ohos.notificationSubscribe.ets index c428ffb4371b3190200808b892cf2cc2aebd5d9e..b848fd7364c3c2934e86e33c441a963d1182a545 100644 --- a/frameworks/ets/ets/@ohos.notificationSubscribe.ets +++ b/frameworks/ets/ets/@ohos.notificationSubscribe.ets @@ -29,7 +29,7 @@ const rejectInternalError: BusinessError = {code: ERROR_INTERNAL_ERROR, const callbackInternalError: BusinessError = {code: ERROR_INTERNAL_ERROR, data: undefined}; const successCallbackError: BusinessError = {code: ERROR_OK, data: undefined}; -const errorParamInvalid: BusinessError = {code: ERROR_PARAM_INVALID, data: "Invalid parameter"}; +const errorParamInvalid: BusinessError = {code: ERROR_PARAM_INVALID, message: "Invalid parameter"}; function isInvalidParameter(bundle: BundleOption): BusinessError { @@ -52,6 +52,17 @@ function isInvalidParameter(bundle: BundleOption): BusinessError return error; } +function isInvalidParameter(info?: NotificationSubscribeInfo): boolean +{ + if (info == null) { + return false; + } + if (info?.deviceType != undefined && info.deviceType?.length === 0) { + return false; + } + return true; +} + export default namespace notificationSubscribe { loadLibrary("notification_subscribe_ani.z") export interface NotificationKey { @@ -106,6 +117,9 @@ export default namespace notificationSubscribe { if (subscriber == undefined || info == undefined || callback == undefined) { throw errorParamInvalid; } + if (!isInvalidParameter(info)) { + throw errorParamInvalid; + } let p = taskpool.execute((): void => { notificationSubscribe.nativeSubscribe(subscriber, info) }); p.then( (e: NullishType): void => { @@ -120,6 +134,9 @@ export default namespace notificationSubscribe { if (subscriber == undefined) { throw errorParamInvalid; } + if (!isInvalidParameter(info)) { + throw errorParamInvalid; + } let pPromise = new Promise((resolve: ResolveCallback, reject: RejectCallback): void =>{ let p = taskpool.execute((): void => { notificationSubscribe.nativeSubscribe(subscriber, info)}); p.then(