diff --git a/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp b/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp index fe595af7e9c6e12cb6d4b617fc04801c741d3073..95b8bf03dd9cd5a038391e8d8d48e5a6db542010 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 740d1e927f3691ebdb2daa81755e079d29729e3c..45f91a05bcd965e3e7e91884d708f8029d9c746b 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)