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 a0cfa068a255bd2ec39e66326930066079d7d45c..bafde91275e3ad7a16cbbf9c33663beb212d691b 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) {