From: luozheng <1732036298@qq.com> Date: Thu, 26 Jun 2025 08:20:36 +0000 (+0800) Subject: 4GAI添加重连逻辑,待验证 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=bc2fdb23d5d6bb02c02bd14f70460739d416e474;p=mirrors%2FFD230.git 4GAI添加重连逻辑,待验证 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index a2ca19cda..cca2e5473 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -676,7 +676,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "停止录音"); if (GetSelect4gorbt() == AI_SELECT_4G) // 选的是4G需要关闭asr { - uapi_stop_asr(); + // uapi_stop_asr(); stop_AudioCaptureProcess_AI(); } else if (GetSelect4gorbt() == AI_SELECT_BT) @@ -1153,11 +1153,7 @@ namespace OHOS { if (view_ != nullptr && p_AiVoicePresenter != nullptr) { - uint8_t asr_state = 0; - uint8_t chat_state = 0; - asr_state = get_ai_asr_service_init_flag(); - chat_state = get_ai_chat_service_init_flag(); - if (asr_state == 1 && chat_state == 1) + if (AiVoiceModel::GetInstance().GetInit_4gai_task()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4gAi服务初始化成功"); bool state = true; @@ -1345,6 +1341,20 @@ namespace OHOS bool AiVoiceModel::GetInit_4gai_task(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::GetInit_4gai_task %d", init_4gai_task); + uint8_t asr_state = 0; + uint8_t chat_state = 0; + uint8_t tts_state = 0; + asr_state = get_ai_asr_service_init_flag(); + chat_state = get_ai_chat_service_init_flag(); + tts_state = get_ai_tts_server_init_flag(); + if (asr_state == 1 && chat_state == 1 && tts_state == 1) + { + init_4gai_task = true; + } + else + { + init_4gai_task = false; + } return init_4gai_task; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index 23835cdac..15c5307f4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -469,9 +469,9 @@ namespace OHOS { // 通过4G调用大模型 model->SetSelect4gorbt(AI_SELECT_4G); - init_ai_task(); if (!model->GetInit_4gai_task()) { + init_ai_task(); model->start_ai4g_connect_timer(); ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_4GSERVICECON_VIEW); // LOADING } @@ -505,9 +505,9 @@ namespace OHOS { // 通过4G调用大模型 model->SetSelect4gorbt(AI_SELECT_4G); - init_ai_task(); if (!model->GetInit_4gai_task()) { + init_ai_task(); model->start_ai4g_connect_timer(); ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_4GSERVICECON_VIEW); // LOADING }