From 40cefdad92a5d09de97844f835e9264d9e223870 Mon Sep 17 00:00:00 2001 From: fengjituo111 Date: Wed, 11 Jun 2025 11:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=905.1.0-release=E3=80=91mediaQuery?= =?UTF-8?q?=E9=80=82=E9=85=8D=E6=89=A9=E5=B1=95=E5=B1=8F=E5=A4=9A=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengjituo111 --- .../frontend_delegate_declarative.cpp | 8 +------- interfaces/napi/kits/mediaquery/js_media_query.cpp | 5 +++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp b/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp index fe595af7e9c..95b8bf03dd9 100644 --- a/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp +++ b/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp @@ -2430,13 +2430,7 @@ void FrontendDelegateDeclarative::OnSurfaceChanged() void FrontendDelegateDeclarative::OnMediaQueryUpdate(bool isSynchronous) { - auto containerId = Container::CurrentId(); - if (containerId < 0) { - auto container = Container::GetActive(); - if (container) { - containerId = container->GetInstanceId(); - } - } + auto containerId = Container::CurrentIdSafely(); bool isInSubwindow = containerId >= 1000000; if (isInSubwindow) { return; diff --git a/interfaces/napi/kits/mediaquery/js_media_query.cpp b/interfaces/napi/kits/mediaquery/js_media_query.cpp index 740d1e927f3..45f91a05bcd 100644 --- a/interfaces/napi/kits/mediaquery/js_media_query.cpp +++ b/interfaces/napi/kits/mediaquery/js_media_query.cpp @@ -113,6 +113,7 @@ public: static void TriggerAllCallbacks(std::vector& copyListeners) { MediaQueryer queryer; + std::string mediaInfo; for (auto& listener : copyListeners) { OHOS::Ace::ContainerScope scope(listener->GetInstanceId()); auto json = MediaQueryInfo::GetMediaQueryJsonInfo(); @@ -129,8 +130,6 @@ public: if (delayDeleteCallbacks_->find(cbRef) != delayDeleteCallbacks_->end()) { continue; } - TAG_LOGI(AceLogTag::ACE_MEDIA_QUERY, "trigger:%{public}s matches:%{public}d", - listener->media_.c_str(), listener->matches_); napi_handle_scope scope = nullptr; napi_open_handle_scope(listener->env_, &scope); if (scope == nullptr) { @@ -143,6 +142,7 @@ public: napi_value resultArg = nullptr; listener->MediaQueryResult::NapiSerializer(listener->env_, resultArg); + mediaInfo += listener->media_ + ":" + (listener->matches_ ? "1" : "0") + " "; napi_value result = nullptr; napi_status status = napi_call_function(listener->env_, nullptr, cb, 1, &resultArg, &result); if (status != napi_ok) { @@ -152,6 +152,7 @@ public: napi_close_handle_scope(listener->env_, scope); } } + TAG_LOGI(AceLogTag::ACE_MEDIA_QUERY, "trigger: %{public}s", mediaInfo.c_str()); } static napi_value On(napi_env env, napi_callback_info info) -- Gitee