From: xue <2144439972@qq.com> Date: Thu, 13 Nov 2025 09:20:57 +0000 (+0800) Subject: 解决哄睡不显示文本Bug X-Git-Tag: V1.0.9_20251128_194606_LN~65^2~5 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=2a5cf67c7ba0cb1c96c80e3f37c9361a264a40d9;p=mirrors%2FFD230.git 解决哄睡不显示文本Bug --- 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 c95087847..d7e8d9f75 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 @@ -73,6 +73,8 @@ typedef enum { HAND_NPC_EMOTION_CHANGE_NOTIFY, // npc表情变化通知 HAND_TIMELINE_STATUS_CHANGE_NOTIFY, // 时间线状态变化通知 HAND_UPGRADE_DESCRIPTION_NOTIFY, // 升级描述通知 + HAND_STORY_RESPONSE_FINISHED_NOTIFY, // 故事响应finished通知 + HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY, // 对话响应finished通知 MAX_NUM_HANDLER, } UiServiceMsgId; 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 ca8643de5..a23ea2839 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 @@ -109,6 +109,8 @@ static void HandAudioRecordingEndNotify(Request *request); static void HandNpcEmotionChangeNotify(Request *request); static void HandTimelineStatusChangeNotify(Request *request); static void HandUpgradeDescriptionNotify(Request *request); +static void HandStoryResponseFinishedNotify(Request *request); +static void HandDialogueResponseFinishedNotify(Request *request); // 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头) MsgHandlerEntry msgHandlers[] = { {HANDLE_JUMP_OTA_VIEW, HandleJumpOtaView}, @@ -134,6 +136,8 @@ MsgHandlerEntry msgHandlers[] = { {HAND_NPC_EMOTION_CHANGE_NOTIFY,HandNpcEmotionChangeNotify}, {HAND_TIMELINE_STATUS_CHANGE_NOTIFY,HandTimelineStatusChangeNotify}, {HAND_UPGRADE_DESCRIPTION_NOTIFY,HandUpgradeDescriptionNotify}, + {HAND_STORY_RESPONSE_FINISHED_NOTIFY,HandStoryResponseFinishedNotify}, + {HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY,HandDialogueResponseFinishedNotify}, }; /* -------------------------------------------------------------------------- */ void ScreenTurnOn(int32_t timeout) @@ -788,6 +792,30 @@ void HandUpgradeDescriptionNotify(Request *request) GraphicService::GetInstance()->PostGraphicEvent( std::bind(&OHOS::OtaModel::SetUpgradeDescription,OHOS::OtaModel::GetInstance(), description)); } + +void HandStoryResponseFinishedNotify(Request *request) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandStoryResponseFinishedNotify msg_id = %d", request->msgId); + if (request->data && request->len == sizeof(bool)) { + bool finished = *(static_cast(request->data)); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandStoryResponseFinishedNotify finished = %d", finished); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&OHOS::ThunderBirdModel::HandleStoryResponseFinished, + OHOS::ThunderBirdModel::GetInstance(), finished)); + } +} + +void HandDialogueResponseFinishedNotify(Request *request) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDialogueResponseFinishedNotify msg_id = %d", request->msgId); + if (request->data && request->len == sizeof(bool)) { + bool finished = *(static_cast(request->data)); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDialogueResponseFinishedNotify finished = %d", finished); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&OHOS::ThunderBirdModel::HandleDialogueResponseFinished, + OHOS::ThunderBirdModel::GetInstance(), finished)); + } +} /* -------------------------------------------------------------------------- */ #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 548ffc51d..caf168276 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c @@ -1080,16 +1080,28 @@ void ln_ws_process_message(const ws_data_msg_t *data_msg, ws_command_t type) { ln_parse_voice_chat_response(json_str, (int)strlen(json_str)); } + // 如果finished=true,通知ThunderBirdModel + if (data_msg && data_msg->finished) { + push_dialogue_response_finished_notification(true); + } break; } case WS_CMD_CHOOSE_STORY_RESPONSE: { push_text_to_ui(data_msg->text_content); - break; + // 如果finished=true,通知ThunderBirdModel + if (data_msg && data_msg->finished) { + push_story_response_finished_notification(true); + } + break; } case WS_CMD_RANDOM_STORY_RESPONSE: { push_text_to_ui(data_msg->text_content); + // 如果finished=true,通知ThunderBirdModel + if (data_msg && data_msg->finished) { + push_story_response_finished_notification(true); + } break; } case WS_CMD_AUDIO_PLAYBACK_START: diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c index d3d362d21..ed80b6b8b 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c @@ -1818,10 +1818,18 @@ static int ln_ws_parse_data_message(const char *json_str, ws_data_msg_t *data_ms cJSON *data_data = cJSON_GetObjectItem(data_obj, "data"); if (data_data && cJSON_IsObject(data_data)) { // 解析storyTheme字段,存储到text_content中 - cJSON *story_theme = cJSON_GetObjectItem(data_data, "storyTheme"); - if (story_theme && cJSON_IsString(story_theme) && story_theme->valuestring) { - strncpy(data_msg->text_content, story_theme->valuestring, sizeof(data_msg->text_content) - 1); - data_msg->text_content[sizeof(data_msg->text_content) - 1] = '\0'; + // cJSON *story_theme = cJSON_GetObjectItem(data_data, "storyTheme"); + // if (story_theme && cJSON_IsString(story_theme) && story_theme->valuestring) { + // strncpy(data_msg->text_content, story_theme->valuestring, sizeof(data_msg->text_content) - 1); + // data_msg->text_content[sizeof(data_msg->text_content) - 1] = '\0'; + // } + cJSON *story_content = cJSON_GetObjectItem(data_data, "storyContent"); + if (story_content && cJSON_IsString(story_content) && story_content->valuestring) { + // 如果text_content为空,使用storyContent填充 + if (strlen(data_msg->text_content) == 0) { + strncpy(data_msg->text_content, story_content->valuestring, sizeof(data_msg->text_content) - 1); + data_msg->text_content[sizeof(data_msg->text_content) - 1] = '\0'; + } } // 解析storyAudioUrl字段,存储到audio_url中 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 109ef3cbd..22ec66451 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 @@ -291,11 +291,12 @@ void push_npc_emotion_change_notification(const char *emotion) //通知时间线状态变化 void push_timeline_status_change_notification(const char *description, const char *emotion) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[TIMELINE_STATUS_CHANGE] description=%s, emotion=%s", description, emotion); - char payload[512] = {0}; const char *d = description ? description : ""; const char *e = emotion ? emotion : ""; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[TIMELINE_STATUS_CHANGE] description=[%s], emotion=[%s]", d, e); + char payload[512] = {0}; (void)snprintf(payload, sizeof(payload) - 1, "%s|%s", d, e); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[TIMELINE_STATUS_CHANGE] payload=[%s], len=%d", payload, (int)strlen(payload)); SendMsgToUIService(HAND_TIMELINE_STATUS_CHANGE_NOTIFY, 0, (void *)payload, (int32_t)strlen(payload)); } @@ -308,6 +309,20 @@ void push_upgrade_description_notification(const char *description) (void)snprintf(payload, sizeof(payload) - 1, "%s", d); SendMsgToUIService(HAND_UPGRADE_DESCRIPTION_NOTIFY, 0, (void *)payload, (int32_t)strlen(payload)); } + +//通知故事响应finished +void push_story_response_finished_notification(bool finished) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[STORY_RESPONSE_FINISHED] finished=%d", finished); + SendMsgToUIService(HAND_STORY_RESPONSE_FINISHED_NOTIFY, 0, &finished, sizeof(finished)); +} + +//通知对话响应finished +void push_dialogue_response_finished_notification(bool finished) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[DIALOGUE_RESPONSE_FINISHED] finished=%d", finished); + SendMsgToUIService(HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY, 0, &finished, sizeof(finished)); +} #ifdef __cplusplus }; #endif \ No newline at end of file diff --git a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h index e6cccc3e3..1ca3442d6 100644 --- a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h +++ b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h @@ -113,6 +113,10 @@ void push_npc_emotion_change_notification(const char *emotion); void push_timeline_status_change_notification(const char *description, const char *emotion); //推送升级描述 void push_upgrade_description_notification(const char *description); +//通知故事响应finished +void push_story_response_finished_notification(bool finished); +//通知对话响应finished +void push_dialogue_response_finished_notification(bool finished); #ifdef __cplusplus } #endif