From cd2a1f4a56e334de4e84a7bd2cba0bde0f4510db Mon Sep 17 00:00:00 2001 From: caisking Date: Thu, 23 Apr 2026 15:50:04 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E5=BC=80=E5=85=B3=E6=9C=BA?= =?utf8?q?=E7=9A=84=E6=97=A5=E5=BF=97=E8=B7=9F=E8=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativelauncher/src/NativeLauncher.cpp | 51 ++++++++++++------- .../nativeui/main/src/MainViewSample.cpp | 9 ++++ .../src/RebootAndShutdownPresenter.cpp | 3 ++ .../src/ShutDownImageAnimatorView.cpp | 4 ++ .../nativeui/system/src/SystemLogModel.cpp | 9 +++- code/sdk/zhihui/utils/custom_utils.c | 25 ++++++++- 6 files changed, 79 insertions(+), 22 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativelauncher/src/NativeLauncher.cpp index 01c336eb1..32acdaf05 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -60,6 +60,8 @@ #include "battery_hal.h" #endif +extern "C" uint64_t uapi_ulp_systick_get_ms(void); + namespace OHOS { NativeLauncher::NativeLauncher() {} @@ -73,30 +75,30 @@ NativeLauncher &NativeLauncher::GetInstance(void) void NativeLauncher::InitNativeLauncher(LaunchMode mode) { + uint64_t launcherStartMs = uapi_ulp_systick_get_ms(); + uint64_t launcherLastStageMs = launcherStartMs; + auto logLauncherStage = [&](const char *stageName) { + uint64_t nowMs = uapi_ulp_systick_get_ms(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "【开机流程】NativeLauncher阶段:%s,当前时间=%llu ms,阶段耗时=%llu ms,总耗时=%llu ms", + stageName, + (unsigned long long)nowMs, + (unsigned long long)(nowMs - launcherLastStageMs), + (unsigned long long)(nowMs - launcherStartMs)); + launcherLastStageMs = nowMs; + }; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "【开机流程】进入InitNativeLauncher,mode=%d,t0=%llu ms", + mode, (unsigned long long)launcherStartMs); + #ifdef JS_ENABLE ACELite::ProductAdapter::SetScreenSize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); ACELite::ProductAdapter::SetDefaultFontStyle( DEFAULT_VECTOR_FONT_FILENAME, ACELite::ProductAdapter::GetDefaultFontSize()); #endif WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "c %d", mode); - if (mode == LaunchMode::SAFE_MODE) - { - GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::NEW_FONT_DIR, GILROY_BOLD_FONT); // 注册字体 - set_current_global_font_name(GILROY_BOLD_FONT); - if (language::GetInstance()->InitLangues() == false) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLangues error"); - } - /*加载安全模式Slice*/ - #ifdef FD230_650 - InitSafeModeSlice(); - #endif - NativeAbility::GetInstance().SetDefaultSliceId(VIEW_SAFE_MODE); - // PresenterTask::GetInstance()->Init(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "safe_mode is enter!"); - } - else if (mode == LaunchMode::NORMAL_MODE) - { + + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "【开机流程】启动模式:正常模式"); // 初始化语言 GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::VECTOR_FONT_DIR, HARMONYOS_VECTOR_FONT_FILENAME); GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::NEW_FONT_DIR, GILROY_BOLD_FONT); // 注册字体 @@ -112,9 +114,11 @@ void NativeLauncher::InitNativeLauncher(LaunchMode mode) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLangues error"); } + logLauncherStage("正常模式字体和语言初始化完成"); // 初始化所有预加载slice NativeRegisterManager::GetInstance().InitAllNativesSlices(); + logLauncherStage("预加载Slice初始化完成"); CallerLogModel::GetInstance()->InitPhoneService(); @@ -136,9 +140,11 @@ void NativeLauncher::InitNativeLauncher(LaunchMode mode) // 初始化默认首页 ScreenModels::GetInstance()->PreLoadAppimages(); + logLauncherStage("基础业务模块初始化完成"); // 注册按键事件 RebootAndShutdownModel::GetInstance().RegisterAllKeyEvents(); + logLauncherStage("按键事件注册完成"); // 开机检测充电状态 #ifdef SUPPORT_BATTERY_SERVICE @@ -165,6 +171,7 @@ void NativeLauncher::InitNativeLauncher(LaunchMode mode) //更新主表盘配置 MainModel::GetInstance().InitDialState(); + logLauncherStage("表盘配置初始化完成"); // 初始化屏幕亮度 cm_initScreenBrightness(); @@ -174,7 +181,8 @@ void NativeLauncher::InitNativeLauncher(LaunchMode mode) // 初始化压力测试 StressTestModel::GetInstance().LoadResultFromFile(); - } + logLauncherStage("屏幕与压力测试配置初始化完成"); + // 注册开机时间 SystemLogData systemlog; systemlog.timestamp = SystemLogModel::GetInstance()->GetCurrentTime(); @@ -187,6 +195,7 @@ void NativeLauncher::InitNativeLauncher(LaunchMode mode) SystemLogModel::GetInstance()->load_nextday_log(); // 读取popup_windows日志 SystemLogModel::GetInstance()->load_popup_windows_log(); + logLauncherStage("系统日志恢复与开机记录完成"); /* ----------------------------- 650-0723patch合并 ---------------------------- */ // SportsModel::GetInstance()->Init(); @@ -198,6 +207,10 @@ void NativeLauncher::InitNativeLauncher(LaunchMode mode) RecentManager::GetInstance()->SetMaxSize(5); // 5: max number of recent apps. PageTransitionMgr::GetInstance().SetRecentMinPeriod(1000); // 1000: min period /* -------------------------------------------------------------------------- */ + logLauncherStage("最近任务与页面切换策略初始化完成"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "【开机流程】InitNativeLauncher结束,总耗时=%llu ms(注:最终开机完成以进入表盘界面为准)", + (unsigned long long)(uapi_ulp_systick_get_ms() - launcherStartMs)); } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainViewSample.cpp index d69fc20a2..d3d96381c 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -13,6 +13,7 @@ // extern DialInfo_1 dialInfo_1[MAX_DIALNUM_1]; extern "C" uint8_t uapi_dev_runtime_get_lock_status(void); +extern "C" uint64_t uapi_ulp_systick_get_ms(void); namespace OHOS { @@ -24,6 +25,7 @@ namespace OHOS static constexpr uint16_t MESLABLE_HEIGHT_TMP = 30; static constexpr uint8_t FONT_SIZE_TMP = 24; static constexpr uint8_t PULL_MIDDLE_VIEW_OPA = 0; + static bool g_bootWatchfaceReadyLogged = false; #define DIALSTATE 1 @@ -280,6 +282,13 @@ namespace OHOS #endif AddViewToRootContainer(mainSwipeGroup); + if (!g_bootWatchfaceReadyLogged) + { + uint64_t bootCostMs = uapi_ulp_systick_get_ms(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "【开机完成】已进入表盘主界面,开机耗时=%llu ms", (unsigned long long)bootCostMs); + g_bootWatchfaceReadyLogged = true; + } } void MainViewSample::UpdateStateShow() { diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp index d795b87fd..f645b24f5 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp @@ -108,6 +108,7 @@ namespace OHOS } else if (&view == view_->GetButtonEnsure()) // 关机确认 { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] UI confirm shutdown"); view_->ChangeView(SHUTDOWNTIPVIEW, SHUTDOWNANIMATOR); @@ -167,10 +168,12 @@ namespace OHOS if (isShutDownOperation == true) { // uapi_poweroff_device(); // 关机 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] Presenter OnAnimatorStop -> SHUTDOWN_TYPE"); shutdown_reboot_prejobs(SHUTDOWN_TYPE); } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] Presenter OnAnimatorStop -> REBOOT_TYPE"); shutdown_reboot_prejobs(REBOOT_TYPE); } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp index f31ac5a46..da37916ad 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp @@ -63,14 +63,17 @@ namespace OHOS { UNUSED(view); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnAnimatorStop"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] AnimatorStop: operationType=%d", OperationType); switch (OperationType) { case 0: // uapi_poweroff_device(); // 关机 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] AnimatorStop -> shutdown_reboot_prejobs(SHUTDOWN_TYPE)"); shutdown_reboot_prejobs(SHUTDOWN_TYPE); break; case 1: // uapi_reboot_device(); // 重启 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] AnimatorStop -> shutdown_reboot_prejobs(REBOOT_TYPE)"); shutdown_reboot_prejobs(REBOOT_TYPE); break; case 2: @@ -94,6 +97,7 @@ namespace OHOS void ShutDownImageAnimatorView::ShutDownImageAnimator_Start(int type) { OperationType = type; // 保存操作类型:0 关机 1 重启 2 恢复出厂 3解绑恢复出厂 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] AnimatorStart: operationType=%d", type); shutDownImageAnimatorView->Start(); // 开始播放关机动画 diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemLogModel.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemLogModel.cpp index 04294f71f..ec4c0e71e 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemLogModel.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemLogModel.cpp @@ -39,6 +39,8 @@ void report_log(OHOS::SystemLogType type) { OHOS::SystemLogData systemlog; systemlog.timestamp = OHOS::SystemLogModel::GetInstance()->GetCurrentTime(); systemlog.type = type; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] report_log: type=%d ts=%u", + static_cast(type), systemlog.timestamp); #ifdef FD230_650 uapi_save_runtime_log_Time(); #endif @@ -58,6 +60,8 @@ void set_low_battery_shutdown_flag(bool enable) // 关机保存 void start_report_log(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] start_report_log: low_battery=%d", + g_low_battery_shutdown ? 1 : 0); if (g_low_battery_shutdown) { report_log(OHOS::SystemLogType::POWER_OFF_LOW_BATTERY); g_low_battery_shutdown = false; @@ -67,7 +71,10 @@ void start_report_log(void) } // 重启保存 -void stop_report_log(void) { report_log(OHOS::SystemLogType::RESTART); } +void stop_report_log(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PWR_FLOW] stop_report_log: restart"); + report_log(OHOS::SystemLogType::RESTART); +} // 恢复存储保存 void resume_report_log(void) { report_log(OHOS::SystemLogType::FACTORY_RESET); } diff --git a/code/sdk/zhihui/utils/custom_utils.c b/code/sdk/zhihui/utils/custom_utils.c index c2afb0330..b3e1f9c73 100644 --- a/code/sdk/zhihui/utils/custom_utils.c +++ b/code/sdk/zhihui/utils/custom_utils.c @@ -329,21 +329,27 @@ void mcu_poweroff(void) //关机 void uapi_poweroff_device(void) { - //重启前要保存时间 + PRINT("[PWR_FLOW] uapi_poweroff_device: enter\r\n"); + //重启前要保存时间 uapi_calendar_store_date(); + PRINT("[PWR_FLOW] uapi_poweroff_device: calendar stored\r\n"); //关机保存 start_report_log(); + PRINT("[PWR_FLOW] uapi_poweroff_device: power-off log reported\r\n"); osDelay(50); //同步nand文件系统,重启mount速度快 reset_deal_with_fs(); + PRINT("[PWR_FLOW] uapi_poweroff_device: fs synced\r\n"); osDelay(50); // uapi_sys_shipmode(0); // uint32_t irq = osal_irq_lock(); + PRINT("[PWR_FLOW] uapi_poweroff_device: poweroff_bt_dsp_display\r\n"); poweroff_bt_dsp_display(); + PRINT("[PWR_FLOW] uapi_poweroff_device: mcu_poweroff\r\n"); mcu_poweroff(); // osal_irq_restore(irq); - + PRINT("[PWR_FLOW] uapi_poweroff_device: exit-unreachable\r\n"); } @@ -351,17 +357,23 @@ void uapi_poweroff_device(void) //重启 void uapi_reboot_device(void) { + PRINT("[PWR_FLOW] uapi_reboot_device: enter\r\n"); //重启前要保存时间 uapi_calendar_store_date(); + PRINT("[PWR_FLOW] uapi_reboot_device: calendar stored\r\n"); //重启保存 stop_report_log(); + PRINT("[PWR_FLOW] uapi_reboot_device: reboot log reported\r\n"); // mcu_os_sys_reset(NULL,NULL); osDelay(50); //同步nand文件系统,重启mount速度快 reset_deal_with_fs(); + PRINT("[PWR_FLOW] uapi_reboot_device: fs synced\r\n"); osDelay(50); + PRINT("[PWR_FLOW] uapi_reboot_device: mcu_reset\r\n"); mcu_reset(); + PRINT("[PWR_FLOW] uapi_reboot_device: exit-unreachable\r\n"); } @@ -378,6 +390,7 @@ static uint8_t doing_shutdown_type = 0; void shutdown_reboot_prejobs_task(void) { PRINT("shutdown_reboot_prejobs_task: Start, doing_shutdown_type=%d\r\n", doing_shutdown_type); + PRINT("[PWR_FLOW] prejobs_task: start, type=%d\r\n", doing_shutdown_type); // 检查 doing_shutdown_type 是否有效 if(doing_shutdown_type != UPDATE_TYPE && @@ -446,6 +459,7 @@ void shutdown_reboot_prejobs_task(void) if(doing_shutdown_type==UPDATE_TYPE) { PRINT("shutdown_reboot_prejobs_task: UPDATE_TYPE branch\r\n"); + PRINT("[PWR_FLOW] prejobs_task: UPDATE_TYPE -> upg_reboot\r\n"); uapi_calendar_store_date(); PRINT("shutdown_reboot_prejobs_task: uapi_calendar_store_date() completed\r\n"); @@ -463,11 +477,13 @@ void shutdown_reboot_prejobs_task(void) else if(doing_shutdown_type==SHUTDOWN_TYPE) { PRINT("shutdown_reboot_prejobs_task: SHUTDOWN_TYPE branch\r\n"); + PRINT("[PWR_FLOW] prejobs_task: SHUTDOWN_TYPE -> uapi_poweroff_device\r\n"); uapi_poweroff_device(); } else if(doing_shutdown_type==REBOOT_TYPE) { PRINT("shutdown_reboot_prejobs_task: REBOOT_TYPE branch\r\n"); + PRINT("[PWR_FLOW] prejobs_task: REBOOT_TYPE -> uapi_reboot_device\r\n"); uapi_reboot_device(); } else @@ -490,6 +506,7 @@ void shutdown_reboot_prejobs_task(void) void shutdown_reboot_prejobs(uint8_t type) { PRINT("shutdown_reboot_prejobs !\r\n"); + PRINT("[PWR_FLOW] shutdown_reboot_prejobs: request type=%d\r\n", type); start_shutdown_or_reboot(type); @@ -506,11 +523,15 @@ void shutdown_reboot_prejobs(uint8_t type) if(ret != ERRCODE_SUCC) { PRINT("create shutdown_reboot_prejobs thread failed %d!\r\n",ret); + PRINT("[PWR_FLOW] shutdown_reboot_prejobs: thread create failed ret=%d\r\n", ret); + } else { + PRINT("[PWR_FLOW] shutdown_reboot_prejobs: thread created\r\n"); } } void start_shutdown_or_reboot(uint8_t type) { + PRINT("[PWR_FLOW] start_shutdown_or_reboot: type=%d (prev=%d)\r\n", type, doing_shutdown_type); doing_shutdown_type = type; } -- 2.17.1