From ef482dc61eb50e9e84b4103dd2536a2531b5fc8f Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 30 Jun 2025 14:55:54 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B34GAi=E6=97=A0=E6=B3=95?= =?utf8?q?=E9=87=8D=E5=A4=8D=E4=BD=BF=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoiceModel.h | 1 + .../nativeui/aivoice/include/AiVoiceView.h | 5 +- .../nativeui/aivoice/src/AiVoiceModel.cpp | 9 +- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 7 +- .../nativeui/aivoice/src/AiVoiceView.cpp | 375 +++++++++++------- .../aivoice/src/AivoiceListeningView.cpp | 9 +- .../peripheral/slip/cat1Service/cat1_ws.cpp | 2 +- 7 files changed, 246 insertions(+), 162 deletions(-) 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 931d8c77e..57bc8df67 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -67,6 +67,7 @@ namespace OHOS bool AddAiAnswerToChatItems(); bool AddChatContentToItemArray(const ChatContentItem &item); uint8_t GetChatContentListCount(void); + void SetChatContentListCount(uint8_t count); // 更新和清空问题及回答 bool RemoveLastTwoItemsOrClear(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h index 607a54651..c8029bef7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h @@ -165,9 +165,11 @@ namespace OHOS bool CreateAiVoiceViewButton(void); bool CreateAiVoiceViewPicker(void); bool CreateAiVoiceScrollView(void); - void CreateAiVoiceView(void); + UIScrollView *CreateAiVoiceView(void); + void ClearAllAiVoiceScrollView(void); void ClearAll(void); void SetComponentVisibility(UIView *component, bool isVisible); + UIScrollView *scrollView{nullptr}; UILabelExt *title{nullptr}; /*标题*/ UILabelExt *startChatLabel{nullptr}; /*开始对话标签,暂时不用*/ UIButton *startChatButton{nullptr}; /*开始对话按钮*/ @@ -180,7 +182,6 @@ namespace OHOS UIButton *apiKeysButton{nullptr}; /*API Keys按钮,,暂时不用*/ UIPicker *aiModelPicker{nullptr}; /*ai模型选择器*/ UIScrollView *AiVoiceScrollView[MAX_AIVOICE_VIEWID]{nullptr}; - bool viewInitStatus{false}; }; } #endif \ No newline at end of file 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 0c67ae153..c3ac0345f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -239,6 +239,11 @@ namespace OHOS return ChatContentListCount; } + void AiVoiceModel::SetChatContentListCount(uint8_t count) + { + ChatContentListCount = count; + } + /*添加聊天内容项到数组*/ bool AiVoiceModel::AddChatContentToItemArray(const ChatContentItem &item) { @@ -679,8 +684,6 @@ namespace OHOS // uapi_stop_asr(); // stop_AudioCaptureProcess_AI(); uapi_UI_stop_asr(); - - } else if (GetSelect4gorbt() == AI_SELECT_BT) { @@ -1350,7 +1353,7 @@ namespace OHOS 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) + if ((asr_state == 1) && (chat_state == 1) && (tts_state == 1)) { init_4gai_task = true; } 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 bd2b03d22..75e92dea1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -408,7 +408,7 @@ namespace OHOS if (model->GetSelect4gorbt() == AI_SELECT_4G) { uapi_UI_start_asr(); -usleep(50000); + usleep(50000); ChangeViewAndLogicOperator(AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_AIMODE_CONNECTING); return true; } @@ -640,7 +640,10 @@ usleep(50000); if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); - AiVoiceModel::GetInstance().CancelCurAIChat(); + if (model->GetSelect4gorbt() == AI_SELECT_BT) + { + AiVoiceModel::GetInstance().CancelCurAIChat(); + } } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp index 7792bcc61..7f567a23b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -33,127 +33,135 @@ namespace OHOS return g_pAiVoiceView; } - void AiVoiceView::ClearAll(void) + void AiVoiceView::ClearAllAiVoiceScrollView(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ClearAll"); - if (viewInitStatus) + if (scrollView != nullptr) { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } + scrollView->RemoveAll(); + delete scrollView; + scrollView = nullptr; - if (AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] != nullptr) - { - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->RemoveAll(); + delete title; + title = nullptr; - delete title; - title = nullptr; + delete aiModelImage; + aiModelImage = nullptr; - delete aiModelImage; - aiModelImage = nullptr; + delete startChatButton; + startChatButton = nullptr; - delete startChatButton; - startChatButton = nullptr; + delete startChatLabel; + startChatLabel = nullptr; - delete startChatLabel; - startChatLabel = nullptr; + delete chatButton; + chatButton = nullptr; - delete chatButton; - chatButton = nullptr; + delete chatLabel; + chatLabel = nullptr; - delete chatLabel; - chatLabel = nullptr; + delete apiKeysLabel; + apiKeysLabel = nullptr; - delete apiKeysLabel; - apiKeysLabel = nullptr; + delete apiKeysButton; + apiKeysButton = nullptr; - delete apiKeysButton; - apiKeysButton = nullptr; + delete aiModelPicker; + aiModelPicker = nullptr; - delete aiModelPicker; - aiModelPicker = nullptr; + delete buttonBgImage; + buttonBgImage = nullptr; - delete buttonBgImage; - buttonBgImage = nullptr; + delete upImage; + upImage = nullptr; + } + } - delete upImage; - upImage = nullptr; + void AiVoiceView::ClearAll(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ClearAll"); - delete AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]; - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] = nullptr; - } + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + ClearAllAiVoiceScrollView(); - if (p_AiVoiceBluetoothFailedStartView != nullptr) - { - delete p_AiVoiceBluetoothFailedStartView; - p_AiVoiceBluetoothFailedStartView = nullptr; - } + if (p_AiVoiceBluetoothFailedStartView != nullptr) + { + delete p_AiVoiceBluetoothFailedStartView; + p_AiVoiceBluetoothFailedStartView = nullptr; + } - if (p_AivoiceMobileDataFailedStartView != nullptr) - { - delete p_AivoiceMobileDataFailedStartView; - p_AivoiceMobileDataFailedStartView = nullptr; - } + if (p_AivoiceMobileDataFailedStartView != nullptr) + { + delete p_AivoiceMobileDataFailedStartView; + p_AivoiceMobileDataFailedStartView = nullptr; + } - if (p_AivoiceConnectTimeoutView != nullptr) - { - delete p_AivoiceConnectTimeoutView; - p_AivoiceConnectTimeoutView = nullptr; - } + if (p_AivoiceConnectTimeoutView != nullptr) + { + delete p_AivoiceConnectTimeoutView; + p_AivoiceConnectTimeoutView = nullptr; + } - if (p_AivoiceListeningView != nullptr) - { - delete p_AivoiceListeningView; - p_AivoiceListeningView = nullptr; - } + if (p_AivoiceListeningView != nullptr) + { + delete p_AivoiceListeningView; + p_AivoiceListeningView = nullptr; + } - if (p_AivoiceThinkingView != nullptr) - { - delete p_AivoiceThinkingView; - p_AivoiceThinkingView = nullptr; - } + if (p_AivoiceThinkingView != nullptr) + { + delete p_AivoiceThinkingView; + p_AivoiceThinkingView = nullptr; + } - if (p_AivoiceReturnResultTextView != nullptr) - { - delete p_AivoiceReturnResultTextView; - p_AivoiceReturnResultTextView = nullptr; - } + if (p_AivoiceReturnResultTextView != nullptr) + { + delete p_AivoiceReturnResultTextView; + p_AivoiceReturnResultTextView = nullptr; + } - if (p_SetApiKeysView != nullptr) - { - delete p_SetApiKeysView; - p_SetApiKeysView = nullptr; - } + if (p_SetApiKeysView != nullptr) + { + delete p_SetApiKeysView; + p_SetApiKeysView = nullptr; + } - if (p_NotSetApiKeysView != nullptr) - { - delete p_NotSetApiKeysView; - p_NotSetApiKeysView = nullptr; - } + if (p_NotSetApiKeysView != nullptr) + { + delete p_NotSetApiKeysView; + p_NotSetApiKeysView = nullptr; + } - if (p_ApiKeysDeleteView != nullptr) - { - delete p_ApiKeysDeleteView; - p_ApiKeysDeleteView = nullptr; - } + if (p_ApiKeysDeleteView != nullptr) + { + delete p_ApiKeysDeleteView; + p_ApiKeysDeleteView = nullptr; + } - if (p_AiVoiceConnectingView != nullptr) - { - delete p_AiVoiceConnectingView; - p_AiVoiceConnectingView = nullptr; - } - if (p_AiVoiceSelectView != nullptr) - { - delete p_AiVoiceSelectView; - p_AiVoiceSelectView = nullptr; - } - if (p_Aivoice4gServiceConView != nullptr) + if (p_AiVoiceConnectingView != nullptr) + { + delete p_AiVoiceConnectingView; + p_AiVoiceConnectingView = nullptr; + } + if (p_AiVoiceSelectView != nullptr) + { + delete p_AiVoiceSelectView; + p_AiVoiceSelectView = nullptr; + } + if (p_Aivoice4gServiceConView != nullptr) + { + delete p_Aivoice4gServiceConView; + p_Aivoice4gServiceConView = nullptr; + } + for (int i = 0; i < MAX_AIVOICE_VIEWID; i++) + { + if (AiVoiceScrollView[i] != nullptr) { - delete p_Aivoice4gServiceConView; - p_Aivoice4gServiceConView = nullptr; + AiVoiceScrollView[i] = nullptr; } } } @@ -174,7 +182,7 @@ namespace OHOS // label->SetText("DeepSeek"); // } // else - label->SetTextId(labelconfig.textId); + label->SetTextId(labelconfig.textId); label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetRollSpeed(23); @@ -415,20 +423,20 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "aiModelPicker new fail!"); return false; } - aiModelPicker->SetPosition(203, 203, 60, 60); - aiModelPicker->SetViewId(AIVOICE_PICKER_VIEW_ID); - aiModelPicker->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - aiModelPicker->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - aiModelPicker->SetStyle(STYLE_BORDER_RADIUS, 150); - aiModelPicker->SetItemHeight(40); - aiModelPicker->SetLoopState(true); - aiModelPicker->SetRotateFactor(1.0); - aiModelPicker->RequestFocus(); - aiModelPicker->RegisterSelectedListener(presenter_); - aiModelPicker->SetTextColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0xff), Color::GetColorFromRGBA(0xff, 0x00, 0x00, 0xff)); - const char *uiPicker1Data[] = {"0", "1", "2", "3", "4", "5"}; - aiModelPicker->SetValues(uiPicker1Data, sizeof(uiPicker1Data) / sizeof(uiPicker1Data[0])); } + aiModelPicker->SetPosition(203, 203, 60, 60); + aiModelPicker->SetViewId(AIVOICE_PICKER_VIEW_ID); + aiModelPicker->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + aiModelPicker->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + aiModelPicker->SetStyle(STYLE_BORDER_RADIUS, 150); + aiModelPicker->SetItemHeight(40); + aiModelPicker->SetLoopState(true); + aiModelPicker->SetRotateFactor(1.0); + aiModelPicker->RequestFocus(); + aiModelPicker->RegisterSelectedListener(presenter_); + aiModelPicker->SetTextColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0xff), Color::GetColorFromRGBA(0xff, 0x00, 0x00, 0xff)); + const char *uiPicker1Data[] = {"0", "1", "2", "3", "4", "5"}; + aiModelPicker->SetValues(uiPicker1Data, sizeof(uiPicker1Data) / sizeof(uiPicker1Data[0])); return true; } @@ -436,41 +444,44 @@ namespace OHOS bool AiVoiceView::CreateAiVoiceScrollView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceScrollView"); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] = new UIScrollView(); - if (AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] == nullptr) + if (scrollView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] new fail!"); - return false; + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] new fail!"); + return false; + } } - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->SetPosition(0, 0, 466, 466); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->SetTouchable(true); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->SetDraggable(true); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->SetOnDragListener(presenter_); - container_->Add(AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]); - + scrollView->SetPosition(0, 0, 466, 466); + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + scrollView->SetOnDragListener(presenter_); return true; } - void AiVoiceView::CreateAiVoiceView(void) + UIScrollView *AiVoiceView::CreateAiVoiceView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView"); if (!CreateAiVoiceScrollView() || !CreateAiVoiceViewImageView() || !CreateAiVoiceViewPicker() || !CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView fail!"); - return; + return nullptr; } - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(title); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(aiModelPicker); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(aiModelImage); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(startChatButton); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(startChatLabel); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(chatButton); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(chatLabel); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(apiKeysButton); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(apiKeysLabel); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(buttonBgImage); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(upImage); + scrollView->Add(title); + scrollView->Add(aiModelPicker); + scrollView->Add(aiModelImage); + scrollView->Add(startChatButton); + scrollView->Add(startChatLabel); + scrollView->Add(chatButton); + scrollView->Add(chatLabel); + scrollView->Add(apiKeysButton); + scrollView->Add(apiKeysLabel); + scrollView->Add(buttonBgImage); + scrollView->Add(upImage); + + return scrollView; } void AiVoiceView::OnStart() @@ -488,11 +499,7 @@ namespace OHOS container_->SetDraggable(true); container_->SetOnClickListener(presenter_); - if (!viewInitStatus) - { - CreateAiVoiceView(); - viewInitStatus = true; - } + ChangeView(MAX_AIVOICE_VIEWID, AIVOICE_STARTCHAT_VIEWID); SetAiVoiceViewAllComponentsVisibilityStatus(); @@ -530,9 +537,19 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiVoiceStartChatView"); if (AiVoiceScrollView[thisView] == nullptr) { + UIScrollView *scrollview = CreateAiVoiceView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } - AiVoiceModel::GetInstance().CancelCurAIChat(); + if (AiVoiceModel::GetInstance().GetSelect4gorbt() == AI_SELECT_BT) + { + AiVoiceModel::GetInstance().CancelCurAIChat(); + } return true; } @@ -679,6 +696,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiVoicReturnResultTextView"); if (AiVoiceScrollView[thisView] == nullptr) { + AiVoiceModel::GetInstance().SetChatContentListCount(0); p_AivoiceReturnResultTextView = new AivoiceReturnResultTextView(); if (p_AivoiceReturnResultTextView == nullptr) { @@ -894,7 +912,7 @@ namespace OHOS return false; } - if (hideView < 0 || hideView >= MAX_AIVOICE_VIEWID) + if (hideView < 0 || hideView > MAX_AIVOICE_VIEWID) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CheckViewParam hideView err."); return false; @@ -906,12 +924,19 @@ namespace OHOS static const int16 AiVoiceDestroyMapper[] = { AIVOICE_AIMODE_CONNECTING, AIVOICE_4GSERVICECON_VIEW, - // AIVOICE_LISTENING_VIEWID, - // AIVOICE_THINKING_VIEWID, + AIVOICE_LISTENING_VIEWID, + AIVOICE_THINKING_VIEWID, + AIVOICE_SELECT_VIEW, + AIVOICE_CONNECT_TIMEOUT_VIEWID, + AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID, + AIVOICE_ALERT_APPBLUETOOTH_AND_4GNETWORK_VIEWID, + // AIVOICE_STARTCHAT_VIEWID, + AIVOICE_RETURN_RESULT_TEXT_VIEWID, }; void AiVoiceView::DestroyTempView(int16_t hideView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::DestroyTempView:%d", hideView); int viewSize = sizeof(AiVoiceDestroyMapper) / sizeof(AiVoiceDestroyMapper[0]); for (int i = 0; i < viewSize; i++) { @@ -944,17 +969,58 @@ namespace OHOS case AIVOICE_LISTENING_VIEWID: if (p_AivoiceListeningView) { - // delete p_AivoiceListeningView; - // p_AivoiceListeningView = nullptr; - p_AivoiceListeningView->StartOrStopAivoiceListeningImageAnimatorView(false); + if (p_AivoiceListeningView) + { + delete p_AivoiceListeningView; + p_AivoiceListeningView = nullptr; + } + // p_AivoiceListeningView->StartOrStopAivoiceListeningImageAnimatorView(false); } break; case AIVOICE_THINKING_VIEWID: if (p_AivoiceThinkingView) { - // delete p_AivoiceThinkingView; - // p_AivoiceThinkingView = nullptr; - p_AivoiceThinkingView->StartOrStopAiVoiceThinkingImageAnimatorView(false); + delete p_AivoiceThinkingView; + p_AivoiceThinkingView = nullptr; + // p_AivoiceThinkingView->StartOrStopAiVoiceThinkingImageAnimatorView(false); + } + break; + case AIVOICE_SELECT_VIEW: + if (p_AiVoiceSelectView) + { + delete p_AiVoiceSelectView; + p_AiVoiceSelectView = nullptr; + } + break; + case AIVOICE_CONNECT_TIMEOUT_VIEWID: + if (p_AivoiceConnectTimeoutView) + { + delete p_AivoiceConnectTimeoutView; + p_AivoiceConnectTimeoutView = nullptr; + } + break; + case AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID: + if (p_AivoiceMobileDataFailedStartView) + { + delete p_AivoiceMobileDataFailedStartView; + p_AivoiceMobileDataFailedStartView = nullptr; + } + break; + case AIVOICE_ALERT_APPBLUETOOTH_AND_4GNETWORK_VIEWID: + if (p_AiVoiceBluetoothFailedStartView) + { + delete p_AiVoiceBluetoothFailedStartView; + p_AiVoiceBluetoothFailedStartView = nullptr; + } + break; + case AIVOICE_STARTCHAT_VIEWID: + // ClearAllAiVoiceScrollView(); + break; + case AIVOICE_RETURN_RESULT_TEXT_VIEWID: + if (p_AivoiceReturnResultTextView) + { + delete p_AivoiceReturnResultTextView; + p_AivoiceReturnResultTextView = nullptr; } break; default: @@ -970,9 +1036,16 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CheckViewParam failed."); return; } - AiVoiceScrollView[hideView]->SetVisible(false); + if (hideView != MAX_AIVOICE_VIEWID) + { + if (AiVoiceScrollView[hideView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceScrollView[%d] is nullptr", hideView); + return; + } + AiVoiceScrollView[hideView]->SetVisible(false); + } ClickFunc(showView); - AiVoiceScrollView[showView]->SetVisible(true); if (AiVoiceScrollView[showView] != nullptr) { AiVoiceScrollView[showView]->SetVisible(true); @@ -1035,8 +1108,8 @@ namespace OHOS // } // else // { - title->SetTextId(textId); - title->ForceResetText(); + title->SetTextId(textId); + title->ForceResetText(); // } } if (aiModelImage) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp index f1d1b340e..f2d288ec9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp @@ -269,11 +269,14 @@ namespace OHOS .numFrames = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, .delay = AIVOICE_LISTENING_IMAGE_ANIMATOR_DELAY, }; - AiVoiceListeningImageAnimatorView = AivoiceListeningImageAnimatorInit(imageanimatorconfig); if (AiVoiceListeningImageAnimatorView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceListeningImageAnimatorView::AiVoiceListeningImageAnimatorView new fail"); - return false; + AiVoiceListeningImageAnimatorView = AivoiceListeningImageAnimatorInit(imageanimatorconfig); + if (AiVoiceListeningImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceListeningImageAnimatorView::AiVoiceListeningImageAnimatorView new fail"); + return false; + } } return true; diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp index 25f242e85..13abb2433 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp @@ -993,7 +993,7 @@ static uint8_t ai_tts_server_init_flag = 0; //tts初始化标志 // 获取ASR服务初始化标志 uint8_t get_ai_asr_service_init_flag(void) { - return true; + return 1; } // 设置ASR服务初始化标志 -- 2.17.1