diff --git a/frameworks/ets/ani/src/manager/ani_do_not_disturb_profile.cpp b/frameworks/ets/ani/src/manager/ani_do_not_disturb_profile.cpp index 0bd98152fdba07cfe056b1844a92d535dd326fe7..71f94dd19d0b5ff4389d983e3687d5fa71b177a4 100644 --- a/frameworks/ets/ani/src/manager/ani_do_not_disturb_profile.cpp +++ b/frameworks/ets/ani/src/manager/ani_do_not_disturb_profile.cpp @@ -89,8 +89,6 @@ ani_object AniGetDoNotDisturbProfile(ani_env *env, ani_double id) OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } - ANS_LOGD("doNotDisturbProfile ProfileId: %{public}lld, ProfileName %{public}s", - doNotDisturbProfile->GetProfileId(), doNotDisturbProfile->GetProfileName().c_str()); if (!NotificationSts::WrapDoNotDisturbProfile(env, doNotDisturbProfile, profile)) { ANS_LOGE("AniGetDoNotDisturbProfile WrapDoNotDisturbProfile failed"); OHOS::AbilityRuntime::ThrowStsError(env, OHOS::Notification::ERROR_INTERNAL_ERROR, diff --git a/frameworks/ets/ani/src/sts_bundle_option.cpp b/frameworks/ets/ani/src/sts_bundle_option.cpp index 5f89307c847a276f4c372c8e3de3fa8755fc679a..2cf67a9bfdc0d15f84516fed7a0abe1baab43ed9 100644 --- a/frameworks/ets/ani/src/sts_bundle_option.cpp +++ b/frameworks/ets/ani/src/sts_bundle_option.cpp @@ -57,7 +57,7 @@ ani_object GetAniArrayBundleOption(ani_env* env, ANS_LOGE("GetAniArrayActionButton: arrayObj is nullptr"); return nullptr; } - ani_size index = 0; + int32_t index = 0; for (auto &option : bundleOptions) { std::shared_ptr optSp = std::make_shared(option); ani_object item; diff --git a/frameworks/ets/ani/src/sts_disturb_mode.cpp b/frameworks/ets/ani/src/sts_disturb_mode.cpp index 0b9924ebd7bbc8b5ae8a5b9d21c07b01665ddc1b..1cc2f7c285f947b872331c17355a377d1f02140e 100644 --- a/frameworks/ets/ani/src/sts_disturb_mode.cpp +++ b/frameworks/ets/ani/src/sts_disturb_mode.cpp @@ -104,7 +104,7 @@ bool WrapProfileTrustList(ani_env* env, sptr pr return false; } - size_t index = 0; + int32_t index = 0; for (const auto& bundle : trustList) { auto bundlePtr = std::make_shared(bundle); ani_object bundleObj = nullptr; diff --git a/frameworks/ets/ani/src/sts_notification_manager.cpp b/frameworks/ets/ani/src/sts_notification_manager.cpp index acde5ca6ae9f65429c02ad31ba7f1ce31ca34044..eb011638169efb21a1ab19def7c9c11a1879cf00 100644 --- a/frameworks/ets/ani/src/sts_notification_manager.cpp +++ b/frameworks/ets/ani/src/sts_notification_manager.cpp @@ -760,8 +760,7 @@ bool UnWarpNotificationDoNotDisturbDate( doNotDisturbDate.SetEndDate(static_cast(mDouble)); } if (doNotDisturbDate.GetBeginDate() >= doNotDisturbDate.GetEndDate()) { - ANS_LOGE("Invalid time range: begin(%{public}lld) >= end(%{public}lld)", - doNotDisturbDate.GetBeginDate(), doNotDisturbDate.GetEndDate()); + ANS_LOGE("Invalid time range"); return false; } ANS_LOGD("Successfully parsed DoNotDisturbDate"); diff --git a/frameworks/ets/ets/@ohos.notificationManager.ets b/frameworks/ets/ets/@ohos.notificationManager.ets index f621dcb2f81deb5b9f92c8c3937743588ff32b09..ab484c2cb6f87a442b34a02a531b5a2b7f3e9495 100644 --- a/frameworks/ets/ets/@ohos.notificationManager.ets +++ b/frameworks/ets/ets/@ohos.notificationManager.ets @@ -246,11 +246,11 @@ export default namespace notificationManager { } } if (slot.desc !== undefined && slot.desc?.trim() === '') { - return errorParamInvalid; - } + return errorParamInvalid; + } if (slot.sound !== undefined && slot.sound?.trim() === '') { - return errorParamInvalid; - } + return errorParamInvalid; + } if (slot.vibrationValues !== undefined && slot.vibrationValues?.length === 0) { return errorParamInvalid; } @@ -310,183 +310,240 @@ export default namespace notificationManager { function isInvalidContent(normal?: NotificationBasicContent): boolean { if (normal === null) { - return false; - } - if (!normal?.title || normal?.title?.trim() === '') { - return false; - } - if (!normal?.text || normal?.text?.trim() === '') { - return false; - } - if (normal?.additionalText !== undefined && normal?.additionalText?.trim() === '') { - return false; - } - if (normal?.lockscreenPicture != undefined && !(normal?.lockscreenPicture instanceof image.PixelMap)) { - return false; - } - + return false; + } + if (!normal?.title || normal?.title?.trim() === '') { + return false; + } + if (!normal?.text || normal?.text?.trim() === '') { + return false; + } + if (normal?.additionalText !== undefined && normal?.additionalText?.trim() === '') { + return false; + } + if (normal?.lockscreenPicture != undefined && !(normal?.lockscreenPicture instanceof image.PixelMap)) { + return false; + } return true; } function isInvalidLongText(longText?: NotificationLongTextContent): boolean { if (longText === null) { - return false; - } - if (!longText?.longText || longText?.longText?.trim() === '') { - return false; - } - if (!longText?.briefText || longText?.briefText?.trim() === '') { - return false; - } - if (!longText?.expandedTitle || longText?.expandedTitle?.trim() === '') { - return false; - } + return false; + } + if (!longText?.title || longText?.title?.trim() === '') { + return false; + } + if (!longText?.text || longText?.text?.trim() === '') { + return false; + } + if (longText?.additionalText !== undefined && longText?.additionalText?.trim() === '') { + return false; + } + if (longText?.lockscreenPicture != undefined && !(longText?.lockscreenPicture instanceof image.PixelMap)) { + return false; + } + if (!longText?.longText || longText?.longText?.trim() === '') { + return false; + } + if (!longText?.briefText || longText?.briefText?.trim() === '') { + return false; + } + if (!longText?.expandedTitle || longText?.expandedTitle?.trim() === '') { + return false; + } return true; } function isInvalidMultiLine(multiLine?: NotificationMultiLineContent): boolean { if (multiLine === null) { - return false - } - if (!multiLine?.briefText || multiLine?.briefText.trim() === '') { - return false; - } - if (!multiLine?.longTitle || multiLine?.longTitle.trim() === '') { - return false; - } - if (multiLine?.lines?.length === 0) { - return false; - } - + return false + } + if (!multiLine?.title || multiLine?.title?.trim() === '') { + return false; + } + if (!multiLine?.text || multiLine?.text?.trim() === '') { + return false; + } + if (multiLine?.additionalText !== undefined && multiLine?.additionalText?.trim() === '') { + return false; + } + if (multiLine?.lockscreenPicture != undefined && !(multiLine?.lockscreenPicture instanceof image.PixelMap)) { + return false; + } + if (!multiLine?.briefText || multiLine?.briefText.trim() === '') { + return false; + } + if (!multiLine?.longTitle || multiLine?.longTitle.trim() === '') { + return false; + } + if (multiLine?.lines?.length === 0) { + return false; + } return true; } function isInvalidPicture(picture?: NotificationPictureContent): boolean { if (picture === null) { - return false; - } - if (!picture?.briefText || picture?.briefText?.trim() === '') { - return false; - } - if (!picture?.expandedTitle || picture?.expandedTitle?.trim() === '') { - return false; - } - if (!(picture?.picture instanceof image.PixelMap)) { - return false; - } + return false; + } + if (!picture?.title || picture?.title?.trim() === '') { + return false; + } + if (!picture?.text || picture?.text?.trim() === '') { + return false; + } + if (picture?.additionalText !== undefined && picture?.additionalText?.trim() === '') { + return false; + } + if (picture?.lockscreenPicture != undefined && !(picture?.lockscreenPicture instanceof image.PixelMap)) { + return false; + } + if (!picture?.briefText || picture?.briefText?.trim() === '') { + return false; + } + if (!picture?.expandedTitle || picture?.expandedTitle?.trim() === '') { + return false; + } + if (!(picture?.picture instanceof image.PixelMap)) { + return false; + } return true; } function isInvalidSystemLiveView(systemLiveView?: NotificationSystemLiveViewContent): boolean { if (systemLiveView === null) { - return false - } - if (systemLiveView?.capsule !== undefined && systemLiveView?.capsule === null) { - return false - } - if (systemLiveView?.capsule?.title !== undefined && systemLiveView?.capsule?.title?.trim() === '') { - return false; - } - if (systemLiveView?.capsule?.icon != undefined && !(systemLiveView?.capsule?.icon instanceof image.PixelMap)) { - return false; - } - if (systemLiveView?.capsule?.backgroundColor != undefined && systemLiveView?.capsule?.backgroundColor?.trim() === '') { - return false; - } - if (systemLiveView?.capsule?.content != undefined && systemLiveView?.capsule?.content?.trim() === '') { - return false; - } - if (systemLiveView?.capsule?.capsuleButtons != undefined && systemLiveView?.capsule?.capsuleButtons?.length === 0) { - return false; - } - if (systemLiveView?.button !== undefined && systemLiveView?.button === null) { - return false; - } - if (systemLiveView?.button?.names != undefined && systemLiveView?.button?.names?.length === 0) { - return false; - } - if (systemLiveView?.button?.icons != undefined && systemLiveView?.button?.icons?.length === 0) { - return false; - } - if (systemLiveView?.button?.iconsResource != undefined && systemLiveView?.button?.iconsResource?.length === 0) { - return false; - } - - if (systemLiveView?.cardButtons !== undefined && systemLiveView?.cardButtons?.length === 0) { - return false; - } + return false + } + if (!systemLiveView?.title || systemLiveView?.title?.trim() === '') { + return false; + } + if (!systemLiveView?.text || systemLiveView?.text?.trim() === '') { + return false; + } + if (systemLiveView?.additionalText !== undefined && systemLiveView?.additionalText?.trim() === '') { + return false; + } + if (systemLiveView?.lockscreenPicture != undefined && !(systemLiveView?.lockscreenPicture instanceof image.PixelMap)) { + return false; + } + if (systemLiveView?.capsule !== undefined && systemLiveView?.capsule === null) { + return false + } + if (systemLiveView?.capsule?.title !== undefined && systemLiveView?.capsule?.title?.trim() === '') { + return false; + } + if (systemLiveView?.capsule?.icon != undefined && !(systemLiveView?.capsule?.icon instanceof image.PixelMap)) { + return false; + } + if (systemLiveView?.capsule?.backgroundColor != undefined && systemLiveView?.capsule?.backgroundColor?.trim() === '') { + return false; + } + if (systemLiveView?.capsule?.content != undefined && systemLiveView?.capsule?.content?.trim() === '') { + return false; + } + if (systemLiveView?.capsule?.capsuleButtons != undefined && systemLiveView?.capsule?.capsuleButtons?.length === 0) { + return false; + } + if (systemLiveView?.button !== undefined && systemLiveView?.button === null) { + return false; + } + if (systemLiveView?.button?.names != undefined && systemLiveView?.button?.names?.length === 0) { + return false; + } + if (systemLiveView?.button?.icons != undefined && systemLiveView?.button?.icons?.length === 0) { + return false; + } + if (systemLiveView?.button?.iconsResource != undefined && systemLiveView?.button?.iconsResource?.length === 0) { + return false; + } + if (systemLiveView?.cardButtons !== undefined && systemLiveView?.cardButtons?.length === 0) { + return false; + } return true; } function isInvalidLiveView(liveView?: NotificationLiveViewContent): boolean { if (liveView === null) { - return false; - } - if (liveView?.extraInfo !== undefined && liveView?.extraInfo === null) { - return false; - } - if (liveView?.pictureInfo !== undefined && liveView?.pictureInfo === null) { - return false; - } + return false; + } + if (!liveView?.title || liveView?.title?.trim() === '') { + return false; + } + if (!liveView?.text || liveView?.text?.trim() === '') { + return false; + } + if (liveView?.additionalText !== undefined && liveView?.additionalText?.trim() === '') { + return false; + } + if (liveView?.lockscreenPicture != undefined && !(liveView?.lockscreenPicture instanceof image.PixelMap)) { + return false; + } + if (liveView?.extraInfo !== undefined && liveView?.extraInfo === null) { + return false; + } + if (liveView?.pictureInfo !== undefined && liveView?.pictureInfo === null) { + return false; + } return true; } function isInvalidTemplate(template?: NotificationTemplate): boolean { if (template === null) { - return false; - } - if (template?.name != undefined && template?.name?.trim() === '') { - return false; - } - if (template?.data != undefined && template?.data === null) { - return false; - } + return false; + } + if (template?.name != undefined && template?.name?.trim() === '') { + return false; + } + if (template?.data != undefined && template?.data === null) { + return false; + } return true; } function isInvalidDistributedOption(distributedOption?: DistributedOptions): boolean { if (distributedOption === null) { - return false - } - if (distributedOption?.supportDisplayDevices != undefined && distributedOption?.supportDisplayDevices?.length === 0) { - return false; - } - if (distributedOption?.supportOperateDevices != undefined && distributedOption?.supportOperateDevices?.length === 0) { - return false; - } + return false + } + if (distributedOption?.supportDisplayDevices != undefined && distributedOption?.supportDisplayDevices?.length === 0) { + return false; + } + if (distributedOption?.supportOperateDevices != undefined && distributedOption?.supportOperateDevices?.length === 0) { + return false; + } 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 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) { - return false; - } - if (bundleOption?.bundle != undefined && bundleOption?.bundle?.trim() === '') { - return false; - } + return false; + } + if (bundleOption?.bundle != undefined && bundleOption?.bundle?.trim() === '') { + return false; + } return true; } function isInvalidParameter(request: NotificationRequest): BusinessError diff --git a/frameworks/ets/ets/notification/notificationRequest.ets b/frameworks/ets/ets/notification/notificationRequest.ets index 5b1993bd1cb6aa35a4d6964adc251c800c98a5b1..b990da8d56f06a96bf3348824e1385cc17b9a942 100644 --- a/frameworks/ets/ets/notification/notificationRequest.ets +++ b/frameworks/ets/ets/notification/notificationRequest.ets @@ -108,7 +108,6 @@ export interface NotificationRequest { readonly creatorUid?: number; readonly creatorPid?: number; readonly creatorUserId?: number; - readonly creatorInstanceKey?: number; sound?: string; classification?: string; readonly hashCode?: string; @@ -160,7 +159,6 @@ class NotificationRequestInner implements NotificationRequest { public readonly creatorUid?: number | undefined; public readonly creatorPid?: number | undefined; public readonly creatorUserId?: number | undefined; - public readonly creatorInstanceKey?: number | undefined; public sound?: string | undefined; public classification?: string | undefined; public readonly hashCode?: string | undefined;