From: luozheng <1732036298@qq.com> Date: Mon, 29 Sep 2025 02:45:31 +0000 (+0800) Subject: 文本更新用post更新,优化ws断连标志位更新 X-Git-Tag: V1.0.9_20251128_194606_LN~291 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=e1b826f7107fadce003bb93b178eeaf1812f6dcb;p=mirrors%2FFD230.git 文本更新用post更新,优化ws断连标志位更新 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h index 4e87f19bb..1c8fbc33f 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h @@ -61,6 +61,7 @@ typedef enum { HAND_API_ERROR_NOTIFY, // 协议错误通知 HAND_BIND_AND_UNBIND_NOTIFY, // 绑定和解绑通知 HAND_SCREEN_IMAGE_DOWNLOAD_SUCCESS_NOTIFY, // 屏保下载成功通知 + HAND_TEXT_UPDATE_NOTIFY, // 更新文本内容通知 MAX_NUM_HANDLER, } UiServiceMsgId; 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 2ae130783..4567bc6b8 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 @@ -695,17 +695,18 @@ void ThunderBirdModel::SetTextStr(const char *textId) { - if (textId == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设置对话文本: textId is null"); - return; - } - ThunderBirdDialogueView::GetInstance()->UpdateDialogueText(m_currentTimeStr.c_str()); - //清除录音内容 - ClearTextStr(); - - // 添加文本内容 - m_currentTimeStr = textId; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设置对话文本: %s", m_currentTimeStr.c_str()); + if (textId == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设置对话文本: textId is null"); + return; + } + if(ThunderBirdDialogueView::GetInstance()) + ThunderBirdDialogueView::GetInstance()->UpdateDialogueText(m_currentTimeStr.c_str()); + //清除录音内容 + ClearTextStr(); + + // 添加文本内容 + m_currentTimeStr = textId; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设置对话文本: %s", m_currentTimeStr.c_str()); } void ThunderBirdModel::ClearTextStr() 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 d7307d71e..4d542c874 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 @@ -97,6 +97,7 @@ static void HandDownloadEmojiNotify(Request *request); static void HandApiErrorNotify(Request *request); static void HandBindAndUnbindNotify(Request *request); static void HandScreenImageDownloadSuccessNotify(Request *request); +static void HandTextUpdateNotify(Request *request); // 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头) MsgHandlerEntry msgHandlers[] = { {HANDLE_JUMP_OTA_VIEW, HandleJumpOtaView}, @@ -110,6 +111,7 @@ MsgHandlerEntry msgHandlers[] = { {HAND_API_ERROR_NOTIFY,HandApiErrorNotify}, {HAND_BIND_AND_UNBIND_NOTIFY,HandBindAndUnbindNotify}, {HAND_SCREEN_IMAGE_DOWNLOAD_SUCCESS_NOTIFY,HandScreenImageDownloadSuccessNotify}, + {HAND_TEXT_UPDATE_NOTIFY,HandTextUpdateNotify}, }; /* -------------------------------------------------------------------------- */ void ScreenTurnOn(int32_t timeout) @@ -540,6 +542,14 @@ void HandScreenImageDownloadSuccessNotify(Request *request) // std::bind(&OHOS::ThunderBirdModel::HandleScreenImageDownloadSuccess,OHOS::ThunderBirdModel::GetInstance())); } +// 更新文本内容通知 +void HandTextUpdateNotify(Request *request) +{ + std::string value(static_cast(request->data), request->len); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&OHOS::ThunderBirdModel::SetTextStr,OHOS::ThunderBirdModel::GetInstance(),value.c_str())); +} + /* -------------------------------------------------------------------------- */ #ifdef __cplusplus } diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c index 9f0a85e3a..89197ce62 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c @@ -412,12 +412,12 @@ void ln_ws_process_message(const ws_data_msg_t *data_msg, ws_command_t type) printf("[LN][WS] Processing WebSocket Connected event\n"); set_is_ln_get_device_network_success(1); } - else + else if(type == WS_CMD_DISCONNECTED) { printf("[LN][WS] Processing WebSocket Disconnected event\n"); set_is_ln_get_device_network_success(0); } - + if (!data_msg || !data_msg->raw_json) { printf("[WS] invalid data message\n"); diff --git a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp index febdf3061..946c4345b 100644 --- a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp +++ b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp @@ -19,7 +19,7 @@ extern "C" // 推送文本给ui void push_text_to_ui(const char *text) { - OHOS::ThunderBirdModel::GetInstance()->SetTextStr(text); + SendMsgToUIService(HAND_TEXT_UPDATE_NOTIFY, 0, (void *)text, (int32_t)strlen(text)); } // 是否开始对话标志:开始对话、结束对话、故事开始、故事结束 static int g_start_conversation_flag = START_CONVERSATION_FLAG_UNKNOWN;