From c463cbde90522d39fbaee34836eab490e879974c Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Thu, 28 Aug 2025 21:17:58 +0800 Subject: [PATCH] =?UTF-8?q?OnCanceled=E4=BB=A3=E7=A0=81=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/include/sts_subscribe.h | 4 +-- frameworks/ets/ani/src/sts_subscribe.cpp | 32 ++++++++++------------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/frameworks/ets/ani/include/sts_subscribe.h b/frameworks/ets/ani/include/sts_subscribe.h index be90cc471..8be5ddd3d 100644 --- a/frameworks/ets/ani/include/sts_subscribe.h +++ b/frameworks/ets/ani/include/sts_subscribe.h @@ -46,8 +46,8 @@ private: class StsSubscriberInstance : public OHOS::Notification::NotificationSubscriber { public: - StsSubscriberInstance(); - virtual ~StsSubscriberInstance(); + StsSubscriberInstance(){}; + virtual ~StsSubscriberInstance(){}; virtual void OnCanceled(const std::shared_ptr &request, const std::shared_ptr &sortingMap, int32_t deleteReason) override; diff --git a/frameworks/ets/ani/src/sts_subscribe.cpp b/frameworks/ets/ani/src/sts_subscribe.cpp index b22f35ed3..8de1e2dd1 100644 --- a/frameworks/ets/ani/src/sts_subscribe.cpp +++ b/frameworks/ets/ani/src/sts_subscribe.cpp @@ -92,23 +92,19 @@ void StsDistributedOperationCallback::SetVm(ani_vm *vm) etsVm_ = vm; } -StsSubscriberInstance::StsSubscriberInstance() -{} -StsSubscriberInstance::~StsSubscriberInstance() -{} void StsSubscriberInstance::OnCanceled( const std::shared_ptr &request, const std::shared_ptr &sortingMap, int32_t deleteReason) { - ANS_LOGD("enter"); + ANS_LOGD("OnCanceled enter"); std::lock_guard l(lock_); ani_env* etsEnv; ani_status aniResult = ANI_ERROR; ani_options aniArgs { 0, nullptr }; aniResult = vm_->AttachCurrentThread(&aniArgs, ANI_VERSION_1, &etsEnv); if (aniResult != ANI_OK) { - ANS_LOGD("AttachCurrentThread error. result: %{public}d.", aniResult); + ANS_LOGE("AttachCurrentThread error. result: %{public}d.", aniResult); return; } std::vector vec; @@ -117,27 +113,27 @@ void StsSubscriberInstance::OnCanceled( vec.push_back(obj); CallFunction(etsEnv, "onCancel", vec); } else { - ANS_LOGD("WarpSubscribeCallbackData faild"); + ANS_LOGE("WarpSubscribeCallbackData faild"); } aniResult = vm_->DetachCurrentThread(); if (aniResult != ANI_OK) { - ANS_LOGD("DetachCurrentThread error. result: %{public}d.", aniResult); + ANS_LOGE("DetachCurrentThread error. result: %{public}d.", aniResult); return; } - ANS_LOGD("done"); + ANS_LOGD("OnCanceled done"); } void StsSubscriberInstance::OnConsumed( const std::shared_ptr &request, const std::shared_ptr &sortingMap) { - ANS_LOGD("enter"); + ANS_LOGD("OnConsumed enter"); std::lock_guard l(lock_); ani_env* etsEnv; ani_status aniResult = ANI_ERROR; ani_options aniArgs { 0, nullptr }; aniResult = vm_->AttachCurrentThread(&aniArgs, ANI_VERSION_1, &etsEnv); if (aniResult != ANI_OK) { - ANS_LOGD("AttachCurrentThread error. result: %{public}d.", aniResult); + ANS_LOGE("AttachCurrentThread error. result: %{public}d.", aniResult); return; } std::vector vec; @@ -146,25 +142,25 @@ void StsSubscriberInstance::OnConsumed( vec.push_back(obj); CallFunction(etsEnv, "onConsume", vec); } else { - ANS_LOGD("WarpSubscribeCallbackData faild"); + ANS_LOGE("WarpSubscribeCallbackData faild"); } aniResult = vm_->DetachCurrentThread(); if (aniResult != ANI_OK) { ANS_LOGD("DetachCurrentThread error. result: %{public}d.", aniResult); return; } - ANS_LOGD("done"); + ANS_LOGD("OnConsumed done"); } void StsSubscriberInstance::OnUpdate(const std::shared_ptr &sortingMap) { - ANS_LOGD("enter"); + ANS_LOGD("OnUpdate enter"); std::lock_guard l(lock_); ani_env* etsEnv; ani_status aniResult = ANI_ERROR; ani_options aniArgs { 0, nullptr }; aniResult = vm_->AttachCurrentThread(&aniArgs, ANI_VERSION_1, &etsEnv); if (aniResult != ANI_OK) { - ANS_LOGD("AttachCurrentThread error. result: %{public}d.", aniResult); + ANS_LOGE("AttachCurrentThread error. result: %{public}d.", aniResult); return; } std::vector vec; @@ -173,14 +169,14 @@ void StsSubscriberInstance::OnUpdate(const std::shared_ptrDetachCurrentThread(); if (aniResult != ANI_OK) { - ANS_LOGD("DetachCurrentThread error. result: %{public}d.", aniResult); + ANS_LOGE("DetachCurrentThread error. result: %{public}d.", aniResult); return; } - ANS_LOGD("done"); + ANS_LOGD("OnUpdate done"); } void StsSubscriberInstance::OnConnected() { -- Gitee