diff --git a/frameworks/ets/ani/src/sts_convert_other.cpp b/frameworks/ets/ani/src/sts_convert_other.cpp index c05cdaf0a0bbf90bdd5841ec5034358b4b0f6e83..06f2564f1ea731c9977df89160ea914a6c65f455 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 c3e4d7baa882c4bd1a0e586e81c6625f1940c8f0..9e6ee15ffc2c87ceffbdf870456784439a07ebf0 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);