From 0491b20d7139111b644938f11018aa5dbc6ac5be Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Tue, 31 Mar 2026 09:55:01 +0800 Subject: [PATCH] =?utf8?q?=E5=AF=B9=E8=AF=9D=E6=A8=A1=E5=BC=8F=E5=BC=BA?= =?utf8?q?=E5=88=B6=E4=B8=8D=E6=81=AF=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../thunderbird/include/ThunderBirdModel.h | 4 +-- .../thunderbird/src/ThunderBirdModel.cpp | 36 ++++++++++++++++++- .../thunderbird/src/ThunderBirdPresenter.cpp | 3 +- .../nativeui/uiservice/src/ui_service.cpp | 8 ++++- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h index 380f7a67d..87c37bff8 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -61,13 +61,13 @@ namespace OHOS static constexpr int SCREEN_KEEPON_LEVEL_30MIN = 3; static constexpr int SCREEN_KEEPON_LEVEL_ALWAYS = 4; int GetScreenKeeponLevel() const { return screenKeeponLevel_; } - /** 设置档位并写入 KV,然后应用当前档位 */ + /** 设置档位并写入 KV,然后应用当前档位(对话聆听/说话中仅写 KV,退出对话后再 Apply) */ void SetScreenKeeponLevel(int level); /** 仅将当前档位应用到系统(不写 KV) */ void ApplyScreenKeeponLevel(); /** 开机时从 KV 读取档位 */ void LoadScreenKeeponLevelFromKV(); - /** 服务端协议 ScreenTimeoutUpdate:单位秒,0 表示不息屏;落 KV 并立即生效 */ + /** 服务端 ScreenTimeoutUpdate:单位秒,0=不息屏;落 KV 并应用(对话中仅落 KV,退出后再 Apply) */ void SetScreenTimeoutSeconds(uint32_t screenTimeoutSec); // 故事模式超时定时器(1分钟无文本切换则退出) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 1cb949e43..0cf1b14be 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -114,6 +114,26 @@ extern "C" { static bool g_isRecording = false;//是否正在录音 + /** 对话进行(聆听/说话,或 Presenter 已标记对话中):息屏档位只写入 KV,不 Apply,避免服务端/设置顶掉对话亮屏策略 */ + static bool ThunderBirdShouldDeferScreenKeeponApply() + { + ThunderBirdPresenter *pre = ThunderBirdPresenter::GetInstance(); + if (pre != nullptr && pre->isDialogueing) { + return true; + } + ThunderBirdMainView *mainView = ThunderBirdMainView::GetInstance(); + if (mainView == nullptr) { + return false; + } + const int16_t cv = mainView->GetCurrentView(); + const int16_t csv = mainView->GetCurrentSubView(); + if (cv != THUNDERBIRD_DIALOGUEVIEW) { + return false; + } + return (csv == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING || + csv == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); + } + /**************************产测相关************************************/ /* AT^LN_STRESS_TEST_DIALOGUE 压测线程:产测期间定期内存拷贝,拉高 CPU 使用率(仅拷贝,不写文件) */ static osMessageQueueId_t g_stress_save_queue = nullptr; @@ -1626,6 +1646,10 @@ extern "C" { else if (level == SCREEN_KEEPON_LEVEL_30MIN) secStr = "1800"; else if (level == SCREEN_KEEPON_LEVEL_ALWAYS) secStr = "0"; (void)UtilsSetValue("screen_timeout_sec", secStr); + if (ThunderBirdShouldDeferScreenKeeponApply()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[ScreenKeepon] SetScreenKeeponLevel: level=%d saved to KV, apply deferred (in dialogue)", level); + return; + } ApplyScreenKeeponLevel(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[ScreenKeepon] SetScreenKeeponLevel: level=%d, saved to KV", level); } @@ -1653,6 +1677,12 @@ extern "C" { (void)snprintf(buf, sizeof(buf) - 1, "%u", (unsigned)screenTimeoutSec); (void)UtilsSetValue("screen_timeout_sec", buf); + if (ThunderBirdShouldDeferScreenKeeponApply()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "[ScreenKeepon] SetScreenTimeoutSeconds: sec=%u => level=%d, KV saved, apply deferred (in dialogue)", + (unsigned)screenTimeoutSec, screenKeeponLevel_); + return; + } ApplyScreenKeeponLevel(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[ScreenKeepon] SetScreenTimeoutSeconds: sec=%u => level=%d", (unsigned)screenTimeoutSec, screenKeeponLevel_); } @@ -2145,7 +2175,8 @@ extern "C" { if (currentView == THUNDERBIRD_DIALOGUEVIEW && (currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING || currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING)) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "聆听/说话界面超时,自动跳转并退出对话"); - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); + /* 退出对话勿强制关常亮:按 KV 档位恢复(用户设为常亮则继续保持) */ + ApplyScreenKeeponLevel(); if(bind_status == true) { view->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW); @@ -4359,6 +4390,9 @@ extern "C" { // 不在这里切换表情,标志位保持为1,在发呆中界面时获取时间线表情 // m_needGetTimelineExpression 保持为 true,表示需要获取时间线表情 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnExitDialogueMode: 退出对话模式,标志位保持为true,将在发呆中界面获取时间线表情"); + + /* 对话中若仅记录了息屏档位(未 Apply),此处统一按 KV 生效(含日程提醒等所有出口) */ + ApplyScreenKeeponLevel(); } // 进入哄睡模式时记录当前表情(进入THUNDERBIRD_LULLABYVIEW_4时调用) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index 32b1ec95b..376c64ca9 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -1277,7 +1277,8 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "退出对话模式,当前子状态: %d", currentSubView); - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); + /* 退出对话按用户息屏档位恢复;勿一律 CANCEL,否则「常亮」被清掉导致很快灭屏 */ + ThunderBirdModel::GetInstance()->ApplyScreenKeeponLevel(); #if LN_VOICE_CHAT_ENABLED //发送结束对话流标志 do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_CHAT_SESSION_END, NULL, 0); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp index f1d626d8b..39909ec4b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp @@ -175,7 +175,13 @@ void ScreenTurnOn(int32_t timeout) void ScreenTurnOff(void) { - if (OHOS::HealthModel::GetInstance()->GetBriScrStatus() == 1) { + // if (OHOS::HealthModel::GetInstance()->GetBriScrStatus() == 1) { + // return; + // } + OHOS::ThunderBirdMainView *tbMain = OHOS::ThunderBirdMainView::GetInstance(); + if (tbMain != nullptr && tbMain->GetCurrentView() == OHOS::THUNDERBIRD_DIALOGUEVIEW && + (tbMain->GetCurrentSubView() == OHOS::ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING || tbMain->GetCurrentSubView() == OHOS::ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING)) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScreenTurnOff] skip: in dialogue view"); return; } #if defined(SUPPORT_POWER_MANAGER) -- 2.17.1