From ad7deb48d178badcf3f3525d4f5759bc4c8a04d1 Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Mon, 25 Aug 2025 17:53:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DremovalWantAgent=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E8=A7=A3=E6=9E=90=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> --- frameworks/ets/ani/src/sts_convert_other.cpp | 16 ++++++---------- .../ets/ani/src/sts_notification_content.cpp | 6 ++---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/frameworks/ets/ani/src/sts_convert_other.cpp b/frameworks/ets/ani/src/sts_convert_other.cpp index c05cdaf0a..06f2564f1 100644 --- a/frameworks/ets/ani/src/sts_convert_other.cpp +++ b/frameworks/ets/ani/src/sts_convert_other.cpp @@ -26,19 +26,15 @@ std::shared_ptr UnwrapWantAgent(ani_env *env, ani_object agent) ANS_LOGE("UnwrapWantAgent failed, has nullPtr"); return nullptr; } - ani_status status = ANI_ERROR; - ani_long nativeObj {}; - if ((status = env->Object_GetFieldByName_Long(agent, "nativeObj", &nativeObj)) != ANI_OK) { - ANS_LOGI("UnwrapWantAgent Object_GetField_Long fetch failed, status = %{public}d", status); - return nullptr; - } - WantAgent* wantAgent = reinterpret_cast(nativeObj); - if (wantAgent == nullptr) { + WantAgent* pWantAgent = nullptr; + AppExecFwk::UnwrapWantAgent(env, agent, reinterpret_cast(&pWantAgent)); + + if (pWantAgent == nullptr) { ANS_LOGI("UnwrapWantAgent wantAgent nullptr"); return nullptr; } - std::shared_ptr wantAgentSp = std::make_shared(*wantAgent); - deletePoint(wantAgent); + std::shared_ptr wantAgentSp = std::make_shared(*pWantAgent); + deletePoint(pWantAgent); ANS_LOGD("UnwrapWantAgent end"); return wantAgentSp; } diff --git a/frameworks/ets/ani/src/sts_notification_content.cpp b/frameworks/ets/ani/src/sts_notification_content.cpp index c3e4d7baa..9e6ee15ff 100644 --- a/frameworks/ets/ani/src/sts_notification_content.cpp +++ b/frameworks/ets/ani/src/sts_notification_content.cpp @@ -1130,10 +1130,8 @@ ani_status UnWarpNotificationLocalLiveViewContent(ani_env *env, ani_object obj, return status; } ani_int typeCode = 0; - ani_boolean isUndefined = ANI_TRUE; - if ((status = GetPropertyInt(env, obj, "typeCode", isUndefined, typeCode)) != ANI_OK - || isUndefined == ANI_TRUE) { - ANS_LOGE("UnWarpNotificationLocalLiveViewContent: get typeCode failed"); + if ((status = env->Object_GetPropertyByName_Int(obj, "typeCode", &typeCode)) != ANI_OK) { + ANS_LOGE("UnWarpNotificationLocalLiveViewContent: get typeCode failed, status = %{public}d", status); return ANI_INVALID_ARGS; } localLiveViewContent->SetType(typeCode); -- Gitee