Merge branch 'sdk650pathc0423' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0...
authorxue <2144439972@qq.com>
Tue, 14 Oct 2025 08:54:51 +0000 (16:54 +0800)
committerxue <2144439972@qq.com>
Tue, 14 Oct 2025 08:54:51 +0000 (16:54 +0800)
1  2 
code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h
code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp
code/sdk/zhihui/leiniao/imsl_ln/ln_api.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_websocket.c
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h

@@@ -65,7 -65,8 +65,9 @@@ typedef enum 
      HAND_DOWNLOAD_SUCCESS_NOTIFY, // 下载成功通知
      HAND_DOWNLOAD_FAIL_NOTIFY, // 下载失败通知
      HAND_DOWNLOAD_PROGRESS_NOTIFY, // 下载进度通知
++    HAND_AUDIO_PLAYBACK_START_NOTIFY, // 音频播放开始通知
      HAND_AUDIO_PLAYBACK_END_NOTIFY, // 音频播放结束通知
+     HAND_NPC_EMOTION_CHANGE_NOTIFY, // npc表情变化通知
      MAX_NUM_HANDLER, 
  } UiServiceMsgId;
  
@@@ -101,7 -101,8 +101,9 @@@ static void HandDownloadFileNotify(Requ
  static void HandDownloadSuccessNotify(Request *request);
  static void HandDownloadFailNotify(Request *request);
  static void HandDownloadProgressNotify(Request *request);
++static void HandAudioPlaybackStartNotify(Request *request);
  static void HandAudioPlaybackEndNotify(Request *request);
+ static void HandNpcEmotionChangeNotify(Request *request);
  // 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头)
  MsgHandlerEntry msgHandlers[] = {
      {HANDLE_JUMP_OTA_VIEW, HandleJumpOtaView},
      {HAND_DOWNLOAD_SUCCESS_NOTIFY,HandDownloadSuccessNotify},
      {HAND_DOWNLOAD_FAIL_NOTIFY,HandDownloadFailNotify},
      {HAND_DOWNLOAD_PROGRESS_NOTIFY,HandDownloadProgressNotify},
++    {HAND_AUDIO_PLAYBACK_START_NOTIFY,HandAudioPlaybackStartNotify},
      {HAND_AUDIO_PLAYBACK_END_NOTIFY,HandAudioPlaybackEndNotify},
+     {HAND_NPC_EMOTION_CHANGE_NOTIFY,HandNpcEmotionChangeNotify},
  };
  /* -------------------------------------------------------------------------- */
  void ScreenTurnOn(int32_t timeout)
@@@ -607,6 -609,6 +611,14 @@@ void HandDownloadFailNotify(Request *re
      GraphicService::GetInstance()->PostGraphicEvent(
          std::bind(&OHOS::OtaModel::HandleDownloadFail,OHOS::OtaModel::GetInstance(), type));
  }
++// 音频播放开始通知
++void HandAudioPlaybackStartNotify(Request *request)
++{
++    WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandAudioPlaybackStartNotify msg_id = %d", request->msgId);
++    GraphicService::GetInstance()->PostGraphicEvent(
++        std::bind(&OHOS::ThunderBirdModel::HandleAudioPlaybackStart,OHOS::ThunderBirdModel::GetInstance()));
++}
++
  // 音频播放结束通知
  void HandAudioPlaybackEndNotify(Request *request)
  {
      GraphicService::GetInstance()->PostGraphicEvent(
          std::bind(&OHOS::ThunderBirdModel::HandleAudioPlaybackEnd,OHOS::ThunderBirdModel::GetInstance()));
  }
+ // 通知npc表情变化
+ void HandNpcEmotionChangeNotify(Request *request)
+ {
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandNpcEmotionChangeNotify msg_id = %d", request->msgId);
+     std::string emotion(static_cast<char*>(request->data), request->len);
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandNpcEmotionChangeNotify emotion = %s", emotion.c_str());
++    GraphicService::GetInstance()->PostGraphicEvent(
++        std::bind(&OHOS::ThunderBirdModel::HandleNpcEmotionChange,OHOS::ThunderBirdModel::GetInstance(),emotion.c_str()));
+ }
  /* -------------------------------------------------------------------------- */
  #ifdef __cplusplus
  }
@@@ -1497,6 -1497,6 +1497,8 @@@ static void ln_ws_default_message_handl
              LN_WS_DEBUG("Default: Processing Audio Playback End event\n");
              break;
          case WS_CMD_SENTENCE_PLAYBACK_COMPLETE:
++            //推送文本到UI
++            push_audio_playback_start_notification();
              LN_WS_DEBUG("Default: Processing Sentence Playback Complete event\n");
              break;
          case WS_CMD_AUDIO_RECORDING_START:
@@@ -2498,7 -2498,7 +2500,7 @@@ static void mark_oldest_valid_audio_dur
  static bool check_playback_completion_by_duration(void)
  {
      uint32_t oldest_audio_duration_ms = get_oldest_valid_audio_duration();
--    
++    oldest_audio_duration_ms-=200;
      if (oldest_audio_duration_ms == 0) {
          return false; // 没有有效的音频时长数据
      }
          
          // 触发单句语音播放完成事件
          if (g_ws_message_callback != NULL) {
++            push_audio_playback_start_notification();
              g_ws_message_callback(NULL, WS_CMD_SENTENCE_PLAYBACK_COMPLETE);
          }
          
@@@ -255,6 -255,6 +255,12 @@@ void push_download_progress_notificatio
  }
  
  //通知音频播放结束了
++//通知音频播放开始了
++void push_audio_playback_start_notification(void)
++{
++    SendMsgToUIService(HAND_AUDIO_PLAYBACK_START_NOTIFY, 0, NULL, 0);
++}
++
  void push_audio_playback_end_notification(void)
  {
      SendMsgToUIService(HAND_AUDIO_PLAYBACK_END_NOTIFY, 0, NULL, 0);
@@@ -99,7 -99,9 +99,10 @@@ void push_download_fail_notification(in
  // 推送文件下载进度通知到UI
  void push_download_progress_notification(int progress);
  //通知音频播放结束了
++void push_audio_playback_start_notification(void);
  void push_audio_playback_end_notification(void);
+ //通知npc表情变化
+ void push_npc_emotion_change_notification(const char *emotion);
  #ifdef __cplusplus
  }
  #endif