From 95dca5719492bfbc7086e86d5df6b36b9e193aba Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Thu, 28 Aug 2025 19:24:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?SetOptionalFieldSlotLevel=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: heguokai <275503077@qq.com> --- frameworks/ets/ani/src/sts_slot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/ets/ani/src/sts_slot.cpp b/frameworks/ets/ani/src/sts_slot.cpp index 14816206a..ee3f4c6b9 100644 --- a/frameworks/ets/ani/src/sts_slot.cpp +++ b/frameworks/ets/ani/src/sts_slot.cpp @@ -26,20 +26,20 @@ bool SetOptionalFieldSlotLevel( { ANS_LOGD("SetOptionalFieldSlotLevel call"); if (env == nullptr || cls == nullptr || object == nullptr) { - ANS_LOGE("SetOptionalFieldSlotLevel failed, has nullptr"); + ANS_LOGE("SetOptionalFieldSlotLevel failed, env, object or cls is null"); return false; } ani_field field = nullptr; ani_status status = env->Class_FindField(cls, fieldName.c_str(), &field); if (status != ANI_OK || field == nullptr) { - ANS_LOGE("Class_FindField failed or null field, status=%{public}d, fieldName=%{public}s", + ANS_LOGE("Class_FindField failed or field is null, status=%{public}d, fieldName=%{public}s", status, fieldName.c_str()); return false; } ani_enum_item enumItem = nullptr; NotificationSts::SlotLevelCToEts(env, value, enumItem); if (enumItem == nullptr) { - ANS_LOGE("null enumItem"); + ANS_LOGE("SlotLevelCToEts enumItem is null"); return false; } status = env->Object_SetField_Ref(object, field, enumItem); -- Gitee From 6e7646e3b2a6d3201be54d69ed09abc2dfd7cd95 Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Tue, 9 Sep 2025 19:31:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbutton=E9=87=8C=E9=9D=A2i?= =?UTF-8?q?cons=E7=9A=84=E5=9B=BE=E7=89=87=E8=B6=85=E8=BF=87=E6=9C=80?= =?UTF-8?q?=E5=A4=A7=E5=80=BC=E4=B8=8D=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: heguokai <275503077@qq.com> --- .../ani/include/sts_notification_content.h | 2 +- frameworks/ets/ani/include/sts_request.h | 2 +- .../ets/ani/src/manager/ani_publish.cpp | 24 +++-- .../ets/ani/src/sts_notification_content.cpp | 15 ++- frameworks/ets/ani/src/sts_request.cpp | 93 ++++++++++--------- 5 files changed, 79 insertions(+), 57 deletions(-) diff --git a/frameworks/ets/ani/include/sts_notification_content.h b/frameworks/ets/ani/include/sts_notification_content.h index 34f73e559..63e0b548b 100644 --- a/frameworks/ets/ani/include/sts_notification_content.h +++ b/frameworks/ets/ani/include/sts_notification_content.h @@ -72,7 +72,7 @@ ani_status GetIconButtonArray(ani_env *env, ani_object param, const char *name, std::vector &res, const uint32_t maxLen); ani_object GetAniIconButtonArray(ani_env *env, const std::vector buttons); -void UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, +bool UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, NotificationLocalLiveViewButton &button); bool WarpNotificationLocalLiveViewButton(ani_env *env, const NotificationLocalLiveViewButton &button, ani_object &buttonObject); diff --git a/frameworks/ets/ani/include/sts_request.h b/frameworks/ets/ani/include/sts_request.h index 5a1416d3b..36c3fe618 100644 --- a/frameworks/ets/ani/include/sts_request.h +++ b/frameworks/ets/ani/include/sts_request.h @@ -35,7 +35,7 @@ void UnWarpDistributedOptions(ani_env *env, ani_object obj, StsDistributedOption bool WarpNotificationUnifiedGroupInfo(ani_env* env, const std::shared_ptr &groupInfo, ani_object &groupInfoObject); -ani_status UnWarpNotificationRequest( +int32_t UnWarpNotificationRequest( ani_env *env, ani_object obj, std::shared_ptr ¬ificationRequest); bool WarpNotificationRequest( ani_env *env, const NotificationRequest *notificationRequest, ani_class &cls, ani_object &outAniObj); diff --git a/frameworks/ets/ani/src/manager/ani_publish.cpp b/frameworks/ets/ani/src/manager/ani_publish.cpp index 4913ca684..e65653f94 100644 --- a/frameworks/ets/ani/src/manager/ani_publish.cpp +++ b/frameworks/ets/ani/src/manager/ani_publish.cpp @@ -30,9 +30,11 @@ void AniPublish(ani_env *env, ani_object obj) { ANS_LOGD("AniPublish call"); std::shared_ptr notificationRequest = std::make_shared(); - if (NotificationSts::UnWarpNotificationRequest(env, obj, notificationRequest) != ANI_OK) { + int32_t ret = NotificationSts::UnWarpNotificationRequest(env, obj, notificationRequest); + if (ret != ERR_OK) { ANS_LOGE("AniPublish UnWarpNotificationRequest failed"); - NotificationSts::ThrowStsErroWithMsg(env, "AniPublish ERROR_INTERNAL_ERROR"); + int externalCode = NotificationSts::GetExternalCode(ret); + OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } int returncode = NotificationHelper::PublishNotification(*notificationRequest); @@ -48,8 +50,10 @@ void AniPublishWithId(ani_env *env, ani_object obj, ani_int userId) ANS_LOGD("AniPublishWithId start"); //NotificationRequest request; std::shared_ptr notificationRequest = std::make_shared(); - if (NotificationSts::UnWarpNotificationRequest(env, obj, notificationRequest) != ANI_OK) { - NotificationSts::ThrowStsErroWithMsg(env, "AniPublishWithId ERROR_INTERNAL_ERROR"); + int32_t ret = NotificationSts::UnWarpNotificationRequest(env, obj, notificationRequest); + if (ret != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(ret); + OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } notificationRequest->SetOwnerUserId(userId); @@ -72,9 +76,11 @@ void AniPublishAsBundle(ani_env *env, ani_object request, ani_string representat } std::shared_ptr notificationRequest = std::make_shared(); - if (NotificationSts::UnWarpNotificationRequest(env, request, notificationRequest) != ANI_OK) { + int32_t ret = NotificationSts::UnWarpNotificationRequest(env, request, notificationRequest); + if (ret != ERR_OK) { ANS_LOGE("AniPublishAsBundle failed"); - NotificationSts::ThrowStsErroWithMsg(env, "AniPublishAsBundle ERROR_INTERNAL_ERROR"); + int externalCode = NotificationSts::GetExternalCode(ret); + OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } notificationRequest->SetOwnerUserId(userId); @@ -94,8 +100,10 @@ void AniPublishAsBundleWithBundleOption(ani_env *env, ani_object representativeB { ANS_LOGE("AniPublishAsBundleWithBundleOption enter"); std::shared_ptr notificationRequest = std::make_shared(); - if (NotificationSts::UnWarpNotificationRequest(env, request, notificationRequest) != ANI_OK) { - NotificationSts::ThrowStsErroWithMsg(env, "AniPublishAsBundleWithBundleOption ERROR_INTERNAL_ERROR"); + int32_t ret = NotificationSts::UnWarpNotificationRequest(env, request, notificationRequest); + if (ret != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(ret); + OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } diff --git a/frameworks/ets/ani/src/sts_notification_content.cpp b/frameworks/ets/ani/src/sts_notification_content.cpp index 73524f10f..fd3ce246d 100644 --- a/frameworks/ets/ani/src/sts_notification_content.cpp +++ b/frameworks/ets/ani/src/sts_notification_content.cpp @@ -356,19 +356,23 @@ ani_status GetIconButtonArray(ani_env *env, ani_object param, const char *name, return status; } -void UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, +bool UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, NotificationLocalLiveViewButton &button) { ANS_LOGD("UnWarpNotificationLocalLiveViewButton call"); if (env == nullptr || obj == nullptr) { ANS_LOGE("UnWarpNotificationLocalLiveViewButton failed, has nullptr"); - return; + return false; } std::vector names = {}; // names?: Array if (GetPropertyStringArray(env, obj, "names", names, BUTTON_RESOURCE_SIZE) == ANI_OK) { for (auto name: names) { - button.addSingleButtonName(GetResizeStr(name, STR_MAX_SIZE)); + if (icon != nullptr && static_cast(icon->GetByteCount()) <= MAX_ICON_SIZE) { + button.addSingleButtonIcon(icon); + } else { + return false; + } } } else { ANS_LOGD("UnWarpNotificationLocalLiveViewButton get names failed."); @@ -393,6 +397,7 @@ void UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, ANS_LOGD("UnWarpNotificationLocalLiveViewButton get iconsResource failed."); } ANS_LOGD("UnWarpNotificationLocalLiveViewButton end"); + return true; } bool WarpNotificationLocalLiveViewButton( @@ -1059,7 +1064,9 @@ bool GetLocalLiveViewContentByOne(ani_env *env, ani_object obj, if (GetPropertyRef(env, obj, "button", isUndefined, buttonRef) == ANI_OK && isUndefined == ANI_FALSE && buttonRef != nullptr) { NotificationLocalLiveViewButton button; - UnWarpNotificationLocalLiveViewButton(env, static_cast(buttonRef), button); + if (!UnWarpNotificationLocalLiveViewButton(env, static_cast(buttonRef), button)) { + return false; + } localLiveViewContent->SetButton(button); localLiveViewContent->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::BUTTON); } else { diff --git a/frameworks/ets/ani/src/sts_request.cpp b/frameworks/ets/ani/src/sts_request.cpp index 11e1ffe3d..854dfac85 100644 --- a/frameworks/ets/ani/src/sts_request.cpp +++ b/frameworks/ets/ani/src/sts_request.cpp @@ -27,6 +27,7 @@ #include "ani_common_want.h" #include "sts_bundle_option.h" #include "sts_subscribe.h" +#include "ans_inner_errors.h" namespace OHOS { namespace NotificationSts { @@ -295,144 +296,149 @@ void GetNotificationRequestByNumber(ani_env *env, ani_object obj, ANS_LOGD("GetNotificationRequestByNumber end"); } -bool GetNotificationNormalContent(ani_env *env, ani_object obj, std::shared_ptr &request) +int32_t GetNotificationNormalContent(ani_env *env, ani_object obj, std::shared_ptr &request) { ANS_LOGD("GetNotificationNormalContent start"); if (env == nullptr || obj == nullptr || request == nullptr) { ANS_LOGE("GetNotificationNormalContent failed, has nullptr"); - return false; + return ERROR_INTERNAL_ERROR; } ani_boolean isUndefined = ANI_TRUE; ani_ref contentRef = {}; if (ANI_OK != GetPropertyRef(env, obj, "normal", isUndefined, contentRef) || isUndefined == ANI_TRUE || contentRef == nullptr) { ANS_LOGE("GetNotificationNormalContent get ref failed"); - return false; + return ERROR_INTERNAL_ERROR; } std::shared_ptr normalContent = std::make_shared(); UnWarpNotificationNormalContent(env, static_cast(contentRef), normalContent); request->SetContent(std::make_shared(normalContent)); ANS_LOGD("GetNotificationNormalContent end"); - return true; + return ERR_OK; } -bool GetNotificationLongTextContent(ani_env *env, ani_object obj, std::shared_ptr &request) +int32_t GetNotificationLongTextContent(ani_env *env, ani_object obj, std::shared_ptr &request) { ANS_LOGD("GetNotificationLongTextContent start"); if (env == nullptr || obj == nullptr || request == nullptr) { ANS_LOGE("GetNotificationLongTextContent failed, has nullptr"); - return false; + return ERROR_INTERNAL_ERROR; } ani_boolean isUndefined = ANI_TRUE; ani_ref contentRef = {}; if (ANI_OK != GetPropertyRef(env, obj, "longText", isUndefined, contentRef) || isUndefined == ANI_TRUE || contentRef == nullptr) { ANS_LOGE("GetNotificationLongTextContent get ref failed"); - return false; + return ERROR_INTERNAL_ERROR; } std::shared_ptr longTextContent = std::make_shared(); UnWarpNotificationLongTextContent(env, static_cast(contentRef), longTextContent); request->SetContent(std::make_shared(longTextContent)); ANS_LOGD("GetNotificationLongTextContent end"); - return true; + return ERR_OK; } -bool GetNotificationPictureContent(ani_env *env, ani_object obj, std::shared_ptr &request) +int32_t GetNotificationPictureContent(ani_env *env, ani_object obj, std::shared_ptr &request) { ANS_LOGD("GetNotificationPictureContent start"); if (env == nullptr || obj == nullptr || request == nullptr) { ANS_LOGE("GetNotificationPictureContent failed, has nullptr"); - return false; + return ERROR_INTERNAL_ERROR; } ani_boolean isUndefined = ANI_TRUE; ani_ref contentRef = {}; if (ANI_OK != GetPropertyRef(env, obj, "picture", isUndefined, contentRef) || isUndefined == ANI_TRUE || contentRef == nullptr) { ANS_LOGE("GetNotificationPictureContent get ref failed"); - return false; + return ERROR_INTERNAL_ERROR; } std::shared_ptr pictureContent = std::make_shared(); UnWarpNotificationPictureContent(env, static_cast(contentRef), pictureContent); request->SetContent(std::make_shared(pictureContent)); ANS_LOGD("GetNotificationPictureContent end"); - return true; + return ERR_OK; } -bool GetNotificationMultiLineContent(ani_env *env, ani_object obj, std::shared_ptr &request) +int32_t GetNotificationMultiLineContent(ani_env *env, ani_object obj, std::shared_ptr &request) { ANS_LOGD("GetNotificationMultiLineContent start"); if (env == nullptr || obj == nullptr || request == nullptr) { ANS_LOGE("GetNotificationMultiLineContent failed, has nullptr"); - return false; + return ERROR_INTERNAL_ERROR; } ani_boolean isUndefined = ANI_TRUE; ani_ref contentRef = {}; if (ANI_OK != GetPropertyRef(env, obj, "multiLine", isUndefined, contentRef) || isUndefined == ANI_TRUE || contentRef == nullptr) { ANS_LOGE("GetNotificationMultiLineContent get ref failed"); - return false; + return ERROR_INTERNAL_ERROR; } std::shared_ptr multiLineContent = std::make_shared(); UnWarpNotificationMultiLineContent(env, static_cast(contentRef), multiLineContent); request->SetContent(std::make_shared(multiLineContent)); ANS_LOGD("GetNotificationMultiLineContent end"); - return true; + return ERR_OK; } -bool GetNotificationLocalLiveViewContent(ani_env *env, ani_object obj, std::shared_ptr &request) +int32_t GetNotificationLocalLiveViewContent(ani_env *env, ani_object obj, std::shared_ptr &request) { ANS_LOGD("GetNotificationLocalLiveViewContent start"); if (env == nullptr || obj == nullptr || request == nullptr) { ANS_LOGE("GetNotificationLocalLiveViewContent failed, has nullptr"); - return false; + return ERROR_INTERNAL_ERROR; } ani_boolean isUndefined = ANI_TRUE; ani_ref contentRef = {}; if (ANI_OK != GetPropertyRef(env, obj, "systemLiveView", isUndefined, contentRef) || isUndefined == ANI_TRUE || contentRef == nullptr) { ANS_LOGE("GetNotificationLocalLiveViewContent get ref failed"); - return false; + return ERROR_INTERNAL_ERROR; } std::shared_ptr localLiveView = std::make_shared(); - UnWarpNotificationLocalLiveViewContent(env, static_cast(contentRef), localLiveView); + ani_status status = ANI_OK; + status = UnWarpNotificationLocalLiveViewContent(env, static_cast(contentRef), localLiveView); + if (status != ANI_OK) { + ANS_LOGE("UnWarpNotificationLocalLiveViewContent failed, status %{public}d", status); + return ERROR_PARAM_INVALID; + } request->SetContent(std::make_shared(localLiveView)); ANS_LOGD("GetNotificationLocalLiveViewContent end"); - return true; + return ERR_OK; } -bool GetNotificationLiveViewContent(ani_env *env, ani_object obj, std::shared_ptr &request) +int32_t GetNotificationLiveViewContent(ani_env *env, ani_object obj, std::shared_ptr &request) { ANS_LOGD("GetNotificationLiveViewContent start"); if (env == nullptr || obj == nullptr || request == nullptr) { ANS_LOGE("GetNotificationLiveViewContent failed, has nullptr"); - return false; + return ERROR_INTERNAL_ERROR; } ani_boolean isUndefined = ANI_TRUE; ani_ref contentRef = {}; if (ANI_OK != GetPropertyRef(env, obj, "liveView", isUndefined, contentRef) || isUndefined == ANI_TRUE || contentRef == nullptr) { ANS_LOGE("GetNotificationLiveViewContent get ref failed"); - return false; + return ERROR_INTERNAL_ERROR; } std::shared_ptr liveViewContent = std::make_shared(); UnWarpNotificationLiveViewContent(env, static_cast(contentRef), liveViewContent); request->SetContent(std::make_shared(liveViewContent)); ANS_LOGD("GetNotificationLiveViewContent end"); - return true; + return ERR_OK; } -bool GetNotificationContent(ani_env *env, ani_object obj, ContentType outType, +int32_t GetNotificationContent(ani_env *env, ani_object obj, ContentType outType, std::shared_ptr &request) { ANS_LOGD("GetNotificationContentWithType start"); if (env == nullptr || obj == nullptr || request == nullptr) { ANS_LOGE("GetNotificationContent failed, has nullptr"); - return false; + return ERROR_INTERNAL_ERROR; } ANS_LOGD("GetNotificationContent ContentType = %{public}d", static_cast(outType)); switch (outType) { @@ -454,16 +460,16 @@ bool GetNotificationContent(ani_env *env, ani_object obj, ContentType outType, ANS_LOGD("ContentType not find. type %{public}d", static_cast(outType)); break; } - return true; + return ERR_OK; } -ani_status GetNotificationContent(ani_env *env, ani_object obj, +int32_t GetNotificationContent(ani_env *env, ani_object obj, std::shared_ptr &request) { ANS_LOGD("GetNotificationContent start"); if (env == nullptr || obj == nullptr || request == nullptr) { ANS_LOGE("GetNotificationContent failed, has nullptr"); - return ANI_ERROR; + return ERROR_INTERNAL_ERROR; } ani_status status = ANI_OK; ani_boolean isUndefined = ANI_TRUE; @@ -471,26 +477,27 @@ ani_status GetNotificationContent(ani_env *env, ani_object obj, if (ANI_OK != (status = GetPropertyRef(env, obj, "content", isUndefined, notificationContentRef)) || isUndefined == ANI_TRUE) { ANS_LOGE("GetNotificationContent:get contentRef failed. status %{public}d", status); - return status; + return ERROR_INTERNAL_ERROR; } ani_ref contentTypeRef; if (ANI_OK != (status = GetPropertyRef(env, static_cast(notificationContentRef), "notificationContentType", isUndefined, contentTypeRef)) || isUndefined == ANI_TRUE || contentTypeRef == nullptr) { ANS_LOGE("GetNotificationContent:get notificationContentType failed. status %{public}d", status); - return status; + return ERROR_INTERNAL_ERROR; } ContentType type; if (!ContentTypeEtsToC(env, static_cast(contentTypeRef), type)) { ANS_LOGE("GetNotificationContent:ContentTypeEtsToC failed"); - return ANI_INVALID_ARGS; + return ERROR_INTERNAL_ERROR; } - if (!GetNotificationContent(env, static_cast(notificationContentRef), type, request)) { + int32_t ret = GetNotificationContent(env, static_cast(notificationContentRef), type, request); + if (ret != ERR_OK) { ANS_LOGE("GetNotificationContent:GetNotificationContent failed"); - return ANI_INVALID_ARGS; + return ret; } ANS_LOGD("GetNotificationContent end"); - return ANI_OK; + return ERR_OK; } void GetNotificationSlotType(ani_env *env, ani_object obj, std::shared_ptr &request) @@ -725,12 +732,12 @@ void GetNotificationBundleOption(ani_env *env, ani_object obj, } } -ani_status GetNotificationRequestByCustom(ani_env *env, ani_object obj, +int32_t GetNotificationRequestByCustom(ani_env *env, ani_object obj, std::shared_ptr ¬ificationRequest) { - ani_status status = GetNotificationContent(env, obj, notificationRequest); - if (status != ANI_OK) { - return ANI_INVALID_ARGS; + int32_t status = GetNotificationContent(env, obj, notificationRequest); + if (status != ERR_OK) { + return status; } GetNotificationSlotType(env, obj, notificationRequest); GetNotificationWantAgent(env, obj, notificationRequest); @@ -748,15 +755,15 @@ ani_status GetNotificationRequestByCustom(ani_env *env, ani_object obj, return status; } -ani_status UnWarpNotificationRequest(ani_env *env, ani_object obj, +int32_t UnWarpNotificationRequest(ani_env *env, ani_object obj, std::shared_ptr ¬ificationRequest) { ANS_LOGD("UnWarpNotificationRequest start"); if (env == nullptr || obj == nullptr) { ANS_LOGE("UnWarpNotificationRequest has nullptr"); - return ANI_ERROR; + return ERROR_INTERNAL_ERROR; } - ani_status status = ANI_ERROR; + int32_t status = ERR_OK; GetNotificationRequestByNumber(env, obj, notificationRequest); GetNotificationRequestByString(env, obj, notificationRequest); GetNotificationRequestByBoolean(env, obj, notificationRequest); -- Gitee From ef4a8876206bfff81a2160c1d8f8cec133425efa Mon Sep 17 00:00:00 2001 From: heguokai Date: Wed, 10 Sep 2025 01:16:11 +0000 Subject: [PATCH 3/4] update frameworks/ets/ani/src/sts_notification_content.cpp. Signed-off-by: heguokai --- frameworks/ets/ani/src/sts_notification_content.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frameworks/ets/ani/src/sts_notification_content.cpp b/frameworks/ets/ani/src/sts_notification_content.cpp index fd3ce246d..d6c85609f 100644 --- a/frameworks/ets/ani/src/sts_notification_content.cpp +++ b/frameworks/ets/ani/src/sts_notification_content.cpp @@ -368,11 +368,7 @@ bool UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, // names?: Array if (GetPropertyStringArray(env, obj, "names", names, BUTTON_RESOURCE_SIZE) == ANI_OK) { for (auto name: names) { - if (icon != nullptr && static_cast(icon->GetByteCount()) <= MAX_ICON_SIZE) { - button.addSingleButtonIcon(icon); - } else { - return false; - } + button.addSingleButtonName(GetResizeStr(name, STR_MAX_SIZE)); } } else { ANS_LOGD("UnWarpNotificationLocalLiveViewButton get names failed."); @@ -381,7 +377,11 @@ bool UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, std::vector> icons = {}; if (ANI_OK == GetPixelMapArray(env, obj, "icons", icons, BUTTON_RESOURCE_SIZE)) { for (auto icon : icons) { - button.addSingleButtonIcon(icon); + if (icon != nullptr && static_cast(icon->GetByteCount()) <= MAX_ICON_SIZE) { + button.addSingleButtonIcon(icon); + } else { + return false; + } } } else { ANS_LOGD("UnWarpNotificationLocalLiveViewButton get icons failed."); -- Gitee From 218ab94aae7446681a8d1dc1dbe1ede645b9952b Mon Sep 17 00:00:00 2001 From: heguokai Date: Wed, 10 Sep 2025 01:17:18 +0000 Subject: [PATCH 4/4] update frameworks/ets/ani/src/sts_notification_content.cpp. Signed-off-by: heguokai --- frameworks/ets/ani/src/sts_notification_content.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/ets/ani/src/sts_notification_content.cpp b/frameworks/ets/ani/src/sts_notification_content.cpp index d6c85609f..cdbbebc40 100644 --- a/frameworks/ets/ani/src/sts_notification_content.cpp +++ b/frameworks/ets/ani/src/sts_notification_content.cpp @@ -368,7 +368,7 @@ bool UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, // names?: Array if (GetPropertyStringArray(env, obj, "names", names, BUTTON_RESOURCE_SIZE) == ANI_OK) { for (auto name: names) { - button.addSingleButtonName(GetResizeStr(name, STR_MAX_SIZE)); + button.addSingleButtonName(GetResizeStr(name, STR_MAX_SIZE)); } } else { ANS_LOGD("UnWarpNotificationLocalLiveViewButton get names failed."); -- Gitee