From: luozheng <1732036298@qq.com> Date: Tue, 15 Oct 2024 11:04:02 +0000 (+0800) Subject: AI语音,添加两种情况判断: X-Git-Tag: release_V1.2.70_20241020_135402~5^2~30 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1192%2F3;p=mirrors%2FFD230.git AI语音,添加两种情况判断: 情况1,如果AI录音数据重传多次没成功,弹窗进入错误界面 情况2,如果AI思考中,手机蓝牙断开,弹窗进入错误界面 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h index d5b8ddec9..0ea15200c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-26 16:45:56 + * @LastEditTime: 2024-10-15 19:03:35 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h */ #ifndef AI_VOICE_MODEL_H @@ -33,6 +33,7 @@ namespace OHOS AI_RESPONSE_CONTENT, //AI回应内容 AI_RESPONSE_ERROR,//AI 回应错误 AI_RESPONSE_END,//AI 回应结束 + AI_BLE_ERROR,//蓝牙数据传入错误 }; static AiVoiceModel &GetInstance(void); // 获取单例实例 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 6230e2872..3f7f04716 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-28 10:30:19 + * @LastEditTime: 2024-10-15 19:02:09 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -26,6 +26,7 @@ #include "settings/include/SettingModel.h" #include #include +#include "bleService.h" namespace OHOS { // 声明定时器变量 @@ -173,7 +174,8 @@ namespace OHOS // 获取APP蓝牙是否已连接 bool AiVoiceModel::GetAPPBluetoothIsConnect(void) { - return SettingModel::GetInstance().GetPhoneConnectStatus(); + // return SettingModel::GetInstance().GetPhoneConnectStatus(); + return get_ble_connect(); } // 获取4G网络是否正常 @@ -514,8 +516,9 @@ namespace OHOS AIResponseType = type; errnote = str; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AIResponseType = %d,errnote = %s\n", AIResponseType, errnote.c_str()); - //如果是:AI录音解析错误或AI 回应错误 ->跳转AI回应错误界面 - if (AIResponseType == AiVoiceModel::AI_RECORDING_PARSING_ERROR || AIResponseType == AiVoiceModel::AI_RESPONSE_ERROR) + //如果是:AI录音解析错误或AI 回应错误 ,或者重传多次录音数据->跳转AI回应错误界面 + if (AIResponseType == AiVoiceModel::AI_RECORDING_PARSING_ERROR || AIResponseType == AiVoiceModel::AI_RESPONSE_ERROR + || AIResponseType == AiVoiceModel::AI_BLE_ERROR) { SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)errnote.c_str(), errnote.length()); return; @@ -663,7 +666,7 @@ namespace OHOS /*定时器到期时的处理*/ static void AIVoice_TimerCallbackProc(int data) { - if (!AiVoiceModel::GetInstance().GetAiVoiceConnectStatus()) + if (!AiVoiceModel::GetInstance().GetAiVoiceConnectStatus()) // 查询AI模型是否可用的定时器 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,AiModelConnectTimeout = %d", AiModelConnectTimeout); AiModelConnectTimeout--; @@ -682,7 +685,7 @@ namespace OHOS } } } - else + else // 等待AI思考完成的定时器 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,Time = %d", Time); Time -= 1; @@ -699,6 +702,18 @@ namespace OHOS std::string str = AiVoiceModel::GetInstance().GetErrnote(); SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); } + else + { + //4g中途断连待扩展 + + //蓝牙的连接状态判断,如果AI思考过程中途断连,直接弹窗提示,不在硬等 + if(get_ble_connect() == false) + { + AiVoiceModel::GetInstance().SetErrnote("ble is disconnected"); + std::string str = AiVoiceModel::GetInstance().GetErrnote(); + SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + } + } } return; }