From 8a95024fa0a3729b3012c4ef886b9b3fbf492858 Mon Sep 17 00:00:00 2001 From: sy <1286649497@qq.com> Date: Tue, 5 Aug 2025 11:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4=E6=88=B3?= =?UTF-8?q?=EF=BC=8C=E8=B7=9F=E8=B8=AA=E6=97=8B=E8=BD=AC=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E8=A7=A6=E5=8F=91=E5=92=8C=E6=89=A7=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../window_napi/js_window_listener.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index a0cfa068a2..bafde91275 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -14,6 +14,9 @@ */ #include +//新增: +#include // 用于获取系统时间 +#include // 用于时间格式化 #include "event_handler.h" #include "event_runner.h" @@ -1001,6 +1004,13 @@ void JsWindowListener::OnWindowWillClose(sptr window) void JsWindowListener::OnRotationChange(const RotationChangeInfo& rotationChangeInfo, RotationChangeResult& rotationChangeResult) { + // 新增:获取并打印当前时间 + auto now = std::time(nullptr); + auto localTime = std::localtime(&now); + char timeStr[100]; + std::strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", localTime); + TLOGI(WmsLogTag::WMS_ROTATION, "Rotation change event occurred at: %s", timeStr); + auto jsCallback = [self = weakRef_, rotationChangeInfo, &rotationChangeResult, env = env_] () { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnRotationChange"); auto thisListener = self.promote(); @@ -1008,6 +1018,13 @@ void JsWindowListener::OnRotationChange(const RotationChangeInfo& rotationChange TLOGE(WmsLogTag::WMS_ROTATION, "this listener or env is nullptr"); return; } + // 新增:回调执行时打印时间 + auto callbackTime = std::time(nullptr); + auto callbackLocalTime = std::localtime(&callbackTime); + char callbackTimeStr[100]; + std::strftime(callbackTimeStr, sizeof(callbackTimeStr), "%Y-%m-%d %H:%M:%S", callbackLocalTime); + TLOGI(WmsLogTag::WMS_ROTATION, "Rotation change callback executed at: %s", callbackTimeStr); + HandleScope handleScope(env); napi_value rotationInfoObj = CreateRotationChangeInfoObject(env, rotationChangeInfo); if (rotationInfoObj == nullptr) { -- Gitee