From 917ee1353b680c9eb62a7ffa0832d71208f416ea Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 28 Oct 2024 11:31:49 +0800 Subject: [PATCH] =?utf8?q?AI=E8=AF=AD=E9=9F=B3=E4=BC=98=E5=8C=96=EF=BC=8C?= =?utf8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/src/AiVoiceModel.cpp | 10 +- .../nativeui/aivoice/src/AiVoiceView.cpp | 110 +++++++++++++++--- .../aivoice/src/AivoiceThinkingView.cpp | 5 +- 3 files changed, 104 insertions(+), 21 deletions(-) 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 35c847da1..6adb6e0d1 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-10-23 14:19:17 + * @LastEditTime: 2024-10-28 11:02:51 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -546,7 +546,7 @@ namespace OHOS // 停止聆听用户问题 void AiVoiceModel::StopListenAndRecordingUserQuestion(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::StopListenAndRecordingUserQuestion"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::StopListenAndRecordingUserQuestion"); int32_t argc = 1; uint8_t *argv = (uint8_t *)"stop"; AudioCaptureSample(argc, (const char **)&argv); @@ -714,7 +714,7 @@ namespace OHOS // 声明定时器变量 static osTimerId_t g_screen60s_timer = nullptr; - static uint16_t SCREEN_60S_TIME = 60; // 60s + static int8_t SCREEN_60S_TIME = 60; // 60s static void ai_start_screen60s_timer_callbackProc(int data) { @@ -796,7 +796,7 @@ namespace OHOS } static osTimerId_t g_listeningEndHandle = nullptr; - static uint8_t LISTENING_TIMEOUT = 10; // 10s钟无操作关闭该视图 + static int8_t LISTENING_TIMEOUT = 10; // 10s钟无操作关闭该视图 static void AIListeningCallbackProc(int data) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AIListeningCallbackProc %d", LISTENING_TIMEOUT); @@ -880,7 +880,7 @@ namespace OHOS } static osTimerId_t g_ai_is_ready_Handle = nullptr; // 处理查询AI是否就绪定时器 - static uint8_t AI_IS_READY_TIMEOUT = 5; // 5s钟超时 + static int8_t AI_IS_READY_TIMEOUT = 5; // 5s钟超时 static void AI_IS_READY_CallbackProc(int data) { if (AI_IS_READY_TIMEOUT <= 0) // 模型连接失败有5秒超时 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 df62d0226..ef2258fb3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-17 10:39:36 + * @LastEditTime: 2024-10-28 11:14:56 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -530,7 +530,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_AiVoiceBluetoothFailedStartView->CreateAiVoiceBluetoothFailedStartView(); + // AiVoiceScrollView[thisView] = p_AiVoiceBluetoothFailedStartView->CreateAiVoiceBluetoothFailedStartView(); + UIScrollView *scrollview = p_AiVoiceBluetoothFailedStartView->CreateAiVoiceBluetoothFailedStartView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } return true; @@ -548,7 +555,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_AivoiceMobileDataFailedStartView->CreateAivoiceMobileDataFailedStartView(); + // AiVoiceScrollView[thisView] = p_AivoiceMobileDataFailedStartView->CreateAivoiceMobileDataFailedStartView(); + UIScrollView *scrollview = p_AivoiceMobileDataFailedStartView->CreateAivoiceMobileDataFailedStartView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } return true; @@ -566,7 +580,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_AivoiceConnectTimeoutView->CreateAivoiceConnectTimeoutView(); + // AiVoiceScrollView[thisView] = p_AivoiceConnectTimeoutView->CreateAivoiceConnectTimeoutView(); + UIScrollView *scrollview = p_AivoiceConnectTimeoutView->CreateAivoiceConnectTimeoutView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } @@ -585,10 +606,17 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_AivoiceListeningView->CreateAivoiceListeningView(); + // AiVoiceScrollView[thisView] = p_AivoiceListeningView->CreateAivoiceListeningView(); + UIScrollView *scrollview = p_AivoiceListeningView->CreateAivoiceListeningView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } - if(p_AivoiceListeningView) + if (p_AivoiceListeningView) { p_AivoiceListeningView->GetShowtimeoutLabel()->SetText("10"); p_AivoiceListeningView->GetShowtimeoutLabel()->Invalidate(); @@ -609,7 +637,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_AivoiceThinkingView->CreateAivoiceThinkingView(); + // AiVoiceScrollView[thisView] = p_AivoiceThinkingView->CreateAivoiceThinkingView(); + UIScrollView *scrollview = p_AivoiceThinkingView->CreateAivoiceThinkingView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } return true; @@ -627,7 +662,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_AivoiceReturnResultTextView->CreateAivoiceReturnResultTextView(); + // AiVoiceScrollView[thisView] = p_AivoiceReturnResultTextView->CreateAivoiceReturnResultTextView(); + UIScrollView *scrollview = p_AivoiceReturnResultTextView->CreateAivoiceReturnResultTextView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } return true; @@ -645,7 +687,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_SetApiKeysView->CreateSetApiKeysView(); + // AiVoiceScrollView[thisView] = p_SetApiKeysView->CreateSetApiKeysView(); + UIScrollView *scrollview = p_SetApiKeysView->CreateSetApiKeysView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } return true; @@ -663,7 +712,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_NotSetApiKeysView->CreateNotSetApiKeysView(); + // AiVoiceScrollView[thisView] = p_NotSetApiKeysView->CreateNotSetApiKeysView(); + UIScrollView *scrollview = p_NotSetApiKeysView->CreateNotSetApiKeysView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } return true; @@ -681,7 +737,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_ApiKeysDeleteView->CreateApiKeysDeleteView(); + // AiVoiceScrollView[thisView] = p_ApiKeysDeleteView->CreateApiKeysDeleteView(); + UIScrollView *scrollview = p_ApiKeysDeleteView->CreateApiKeysDeleteView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } return true; @@ -699,7 +762,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); return false; } - AiVoiceScrollView[thisView] = p_AiVoiceConnectingView->CreateAiVoiceConnectingView(); + // AiVoiceScrollView[thisView] = p_AiVoiceConnectingView->CreateAiVoiceConnectingView(); + UIScrollView *scrollview = p_AiVoiceConnectingView->CreateAiVoiceConnectingView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView); + return false; + } + AiVoiceScrollView[thisView] = scrollview; container_->Add(AiVoiceScrollView[thisView]); } return true; @@ -736,6 +806,7 @@ namespace OHOS bool jug = (this->*(ViewMapper[i].func))(interface); if (jug == false) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ClickFunc err."); return false; } return true; @@ -772,8 +843,11 @@ namespace OHOS { if (hideView == AiVoiceDestroyMapper[i]) { - container_->Remove(AiVoiceScrollView[hideView]); - AiVoiceScrollView[hideView] = nullptr; + if (AiVoiceScrollView[hideView] != nullptr) + { + container_->Remove(AiVoiceScrollView[hideView]); + AiVoiceScrollView[hideView] = nullptr; + } break; } } @@ -802,6 +876,14 @@ namespace OHOS AiVoiceScrollView[hideView]->SetVisible(false); ClickFunc(showView); AiVoiceScrollView[showView]->SetVisible(true); + if (AiVoiceScrollView[showView] != nullptr) + { + AiVoiceScrollView[showView]->SetVisible(true); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceScrollView[%d] is nullptr", showView); + } Draw(); DestroyTempView(hideView); AiVoiceModel::GetInstance().SetCurView(showView); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp index 0d224e6ef..e50d3a0fe 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-15 10:14:37 + * @LastEditTime: 2024-10-28 11:12:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceThinkingView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -264,7 +264,7 @@ namespace OHOS UIScrollView *AivoiceThinkingView::CreateAivoiceThinkingView(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingView"); #if 0 if (scrollView == nullptr) { @@ -316,6 +316,7 @@ namespace OHOS { scrollView->Add(cancelThink); } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingView success!!"); return scrollView; } else -- 2.17.1