From 81bb7816dc54e41c631f1e1b1facb1b7752cb26b Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Wed, 17 Sep 2025 20:27:55 +0800 Subject: [PATCH] =?utf8?q?=E9=9B=B7=E9=B8=9F=E6=B5=8B=E8=AF=95=E5=BD=95?= =?utf8?q?=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/ln/nativeapp/CMakeLists.txt | 1 + .../thunderbird/include/ThunderBirdModel.h | 57 + .../thunderbird/src/ThunderBirdModel.cpp | 1182 ++++++++++++----- .../thunderbird/src/ThunderBirdPresenter.cpp | 13 +- .../ln/service/msg_center/CMakeLists.txt | 1 + .../wearable/ohos_startup/ohosfwk_startup.c | 4 +- 6 files changed, 899 insertions(+), 359 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/ln/nativeapp/CMakeLists.txt index 779b0cc29..9954f7bf6 100644 --- a/code/sdk/application/wearable/ln/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/ln/nativeapp/CMakeLists.txt @@ -63,6 +63,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits/animator ${ROOTDIR}/open_source/flatbuffers/include ${ROOT_DIR}/open_source/openharmony/third_party/lwip/lwip_adapter/lwip_driver_adapter + ${ROOT_DIR}/zhihui/leiniao/imsl_ln ) file(GLOB_RECURSE SOURCES "${NativeApp}/nativeui/*.cpp") diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h index 2004abd16..e526ed297 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -5,6 +5,10 @@ #include #include #include +#include +#include +#include +#include #include "AppViewIDs.h" #include "UiConfig.h" @@ -25,11 +29,64 @@ namespace OHOS void StopCountUpTimer(void); int GetCountUpValue() const; + // 开机操作函数 + int StartBootOperation(); + + // 新手引导相关函数 + enum class BindingStatus { + BOUND = 0, // 已绑定 + NOT_BOUND = 1, // 未绑定 + NO_NETWORK = 2 // 没有网络 + }; + BindingStatus CheckBindingStatus(); + + // 对话相关函数 + bool StartRecording(); + bool StopRecording(); + bool SendRecording(); + bool ReceiveAnswer(); + std::string GetConversationText(); + bool EndConversation(); + + // 哄睡模式相关函数 + bool StartLullabyMode(); + bool StopLullabyMode(); + bool IsLullabyModeActive() const; + + // 提醒结构体定义 + struct ReminderData { + uint32_t id; // 提醒ID + uint32_t timestamp; // 时间戳 + char content[256]; // 提醒内容(最大255字符) + bool isActive; // 是否激活 + uint32_t createTime; // 创建时间 + + ReminderData() : id(0), timestamp(0), isActive(false), createTime(0) { + memset(content, 0, sizeof(content)); + } + }; + + // 事项提醒相关函数 + bool AddReminder(const std::string& content, uint32_t timestamp); + bool RemoveReminder(uint32_t reminderId); + bool UpdateReminder(uint32_t reminderId, const std::string& content, uint32_t timestamp); + std::vector GetReminders(); + + // 文件存储相关函数 + bool SaveRemindersToFile(); + bool LoadRemindersFromFile(); + std::string GetReminderFilePath() const; + uint32_t GenerateReminderId(); + private: ThunderBirdModel(); virtual ~ThunderBirdModel(); ThunderBirdModel(const ThunderBirdModel &) = delete; ThunderBirdModel &operator=(const ThunderBirdModel &) = delete; + + // 提醒数据存储 + std::vector m_reminders; + uint32_t m_nextReminderId; }; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index c71b9d858..5a491a9cd 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -12,359 +12,831 @@ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/ThunderBirdModel.cpp */ -#include "thunderbird/include/ThunderBirdModel.h" -#include "thunderbird/include/ThunderBirdReminderView.h" -#include "thunderbird/include/ThunderBirdOtaView.h" -#include "thunderbird/include/ThunderBirdLullabyView.h" -#include "thunderbird/include/ThunderBirdMainView.h" -#include "wearable_log.h" -#include -#include -#include "wearable_log.h" -#include "custom_utils.h" -#include -namespace OHOS -{ - enum OTA_STATUS - { - OTA_STATUS_LOW_BATTERY = 0, - OTA_STATUS_DOW, - OTA_STATUS_UPDATING, - OTA_STATUS_SUCCESS, - }; - ThunderBirdModel::ThunderBirdModel() {} - ThunderBirdModel::~ThunderBirdModel() {} - - ThunderBirdModel *ThunderBirdModel::GetInstance() - { - static ThunderBirdModel instance; - return &instance; - } - // 获取当前时间戳字符串 - std::string ThunderBirdModel::GetCurrentTimeStr() - { - uint32_t timeStamp = 0; - if (uapi_get_timestampe_ss(&timeStamp) != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); - return "----/--/-- \n --/--"; - } - // 将时间戳转换为 time_t 类型 - time_t rawtime = static_cast(timeStamp); - struct tm *timeinfo = localtime(&rawtime); - - if (timeinfo == NULL) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert time"); - return "----/--/-- \n --/--"; - } - - // 格式化时间为字符串 (HH:MM:SS format) - char buffer[20]; // 格式: HH:MM:SS - std::strftime(buffer, sizeof(buffer), "%H:%M", timeinfo); - return std::string(buffer); - } - void ThunderBirdModel::timer_callback_proc() - { - ThunderBirdMainView *view = ThunderBirdMainView::GetInstance(); - if (view) - { - view->UpdateTimeText(GetCurrentTimeStr().c_str()); - } - } - - - - /* ---------------------- 状态栏时间刷新定时器 ---------------------- */ - static osTimerId_t g_timer = nullptr; - /*定时器到期时的处理*/ - static void TimerCallbackProc(uint8_t data) - { - // 倒计时 - ThunderBirdModel::GetInstance()->timer_callback_proc(); - ThunderBirdMainView::GetInstance()->updateSignalDisplay(); - ThunderBirdMainView::GetInstance()->UpdateBatteryProcess(); - } - /* - * @brief 回调函数 - */ - static void TimerCallback(uint8_t data) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerCallback %d", data); - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(TimerCallbackProc, data)); - } - - /* - * @brief 开启定时器函数 - * @param interval 时间间隔,单位ms - */ - void ThunderBirdModel::StartTimer(uint32_t interval) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartTimer"); - /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 - * ------------------------- */ - if (g_timer != nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); - return; - } - - /* --------------------------------- 2.创建定时器 - * -------------------------------- */ - g_timer = osTimerNew((osTimerFunc_t)TimerCallback, osTimerPeriodic, - nullptr, nullptr); - // 检查定时器创建是否成功 - if (g_timer == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); - return; - } - - /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 - * ---------------------------- */ - /* --------------------------------- 4.启动定时器 - * -------------------------------- */ - osStatus_t ret = osTimerStart(g_timer, interval); - /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 - * nullptr -------------------- */ - if (ret != osOK) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "osTimerDelete failed, ret = %lx!!", ret); - if (g_timer != nullptr) - { - ret = osTimerDelete(g_timer); - } - g_timer = nullptr; - return; - } - } - /* - * @brief 停止定时器 - */ - void ThunderBirdModel::StopTimer(void) - { - // 检查定时器是否存在 - if (g_timer != nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::BP_StopTimer"); - osTimerStop(g_timer); - // 删除定时器并置为 nullptr - osStatus_t ret = osTimerDelete(g_timer); - if (ret != osOK) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "osTimerDelete failed, ret = %lx!!", ret); - } - g_timer = nullptr; - } - } - - /*----------------------提醒界面定时器----------------------------------*/ - static osTimerId_t g_reminderHideTimer = nullptr; - static void ReminderHideTimerCallbackProc(uint8_t data) - { - (void)data; - auto *reminder = ThunderBirdReminderView::GetInstance(); - if (reminder != nullptr) - { - reminder->HideAll(); - } - int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); - int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView, currentSubView); - // 隐藏后切回之前的界面 - // auto *mainv = ThunderBirdReminderView::GetInstance(); - // if (mainv != nullptr)//判断条件需要修改 - // { - // mainv->Show(-1); - // } - } - static void ReminderHideTimerCallback(uint8_t data) - { - GraphicService::GetInstance()->PostGraphicEvent(std::bind(ReminderHideTimerCallbackProc, data)); - } - void ThunderBirdModel::StartReminderHideTimer(uint32_t intervalMs) - { - if (g_reminderHideTimer != nullptr) - { - osTimerStop(g_reminderHideTimer); - osStatus_t ret = osTimerDelete(g_reminderHideTimer); - (void)ret; - g_reminderHideTimer = nullptr; - } - g_reminderHideTimer = osTimerNew((osTimerFunc_t)ReminderHideTimerCallback, osTimerOnce, nullptr, nullptr); - if (g_reminderHideTimer == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartReminderHideTimer new timer failed!!"); - return; - } - osStatus_t ret = osTimerStart(g_reminderHideTimer, intervalMs); - if (ret != osOK) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartReminderHideTimer start failed, ret = %lx!!", ret); - osTimerDelete(g_reminderHideTimer); - g_reminderHideTimer = nullptr; - } - auto *reminder = ThunderBirdReminderView::GetInstance();//先隐藏全部提醒界面 - if (reminder != nullptr) - { - reminder->HideAll(); - } - } - - // ---------------------- OTA 倒计时定时器(5 -> 1,每步1秒) ---------------------- - static osTimerId_t g_otaCountdownTimer = nullptr; - static int g_otaCountdownValue = 0; - static void OtaCountdownTimerProc(uint8_t data) - { - (void)data; - if (g_otaCountdownValue < 1) - { - // 停止并删除 - if (g_otaCountdownTimer != nullptr) - { - osTimerStop(g_otaCountdownTimer); - osTimerDelete(g_otaCountdownTimer); - g_otaCountdownTimer = nullptr; - } - g_otaCountdownValue = 0; - //自动跳转到开始OTA界面 - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING); - return; - - - } - g_otaCountdownValue -= 1; - GraphicService::GetInstance()->PostGraphicEvent([](){ - if (ThunderBirdOtaView::GetInstance()) - { - ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue); - } - }); - } - static void OtaCountdownTimerCb(uint8_t data) - { - OtaCountdownTimerProc(data); - } - void ThunderBirdModel::StartOtaCountdown(uint32_t startVal) - { - // 范围保护 - if (startVal < 1) { startVal = 1; } - if (startVal > 5) { startVal = 5; } - // 先停旧定时器 - if (g_otaCountdownTimer != nullptr) - { - osTimerStop(g_otaCountdownTimer); - osTimerDelete(g_otaCountdownTimer); - g_otaCountdownTimer = nullptr; - } - g_otaCountdownValue = (int)startVal; - // 立即刷新一次当前值 - if (ThunderBirdOtaView::GetInstance()) - { - ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue); - } - // 创建1s周期定时器 - uint32_t oneSecond = 1000; - g_otaCountdownTimer = osTimerNew((osTimerFunc_t)OtaCountdownTimerCb, osTimerPeriodic, nullptr, nullptr); - if (g_otaCountdownTimer == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown new timer failed!!"); - return; - } - osStatus_t ret = osTimerStart(g_otaCountdownTimer, oneSecond); - if (ret != osOK) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown start failed, ret = %lx!!", ret); - osTimerDelete(g_otaCountdownTimer); - g_otaCountdownTimer = nullptr; - } - } - void ThunderBirdModel::StopOtaCountdown(void) - { - if (g_otaCountdownTimer != nullptr) - { - osTimerStop(g_otaCountdownTimer); - osTimerDelete(g_otaCountdownTimer); - g_otaCountdownTimer = nullptr; - } - g_otaCountdownValue = 0; - } + #include "thunderbird/include/ThunderBirdModel.h" + #include "thunderbird/include/ThunderBirdReminderView.h" + #include "thunderbird/include/ThunderBirdOtaView.h" + #include "thunderbird/include/ThunderBirdLullabyView.h" + #include "thunderbird/include/ThunderBirdMainView.h" + #include "wearable_log.h" + #include + #include + #include "wearable_log.h" + #include "custom_utils.h" + #include + #include + #include + #include "custom_runtime.h" + #include "ln_api.h" + namespace OHOS + { + enum OTA_STATUS + { + OTA_STATUS_LOW_BATTERY = 0, + OTA_STATUS_DOW, + OTA_STATUS_UPDATING, + OTA_STATUS_SUCCESS, + }; + static bool g_isRecording = false;//是否正在录音 + ThunderBirdModel::ThunderBirdModel() : m_nextReminderId(1) + { + // 初始化时加载提醒数据 + // LoadRemindersFromFile(); + } + + ThunderBirdModel::~ThunderBirdModel() + { + // 析构时保存提醒数据 + // SaveRemindersToFile(); + } - - // ---------------------- 通用计时加一定时器(0 -> targetSeconds,每步1秒) ---------------------- - static osTimerId_t g_countUpTimer = nullptr; - static int g_countUpTargetSeconds = 0; - static int g_countUpValue = 0; - static void CountUpTimerProc(uint8_t data) - { - (void)data; - if (g_countUpValue >= g_countUpTargetSeconds) - { - if (g_countUpTimer != nullptr) - { - osTimerStop(g_countUpTimer); - osTimerDelete(g_countUpTimer); - g_countUpTimer = nullptr; - } - return; - } - g_countUpValue += 1; - ThunderBirdLullabyView::GetInstance()->UpdateTimeText(g_countUpValue, g_countUpTargetSeconds); - } - static void CountUpTimerCb(uint8_t data) - { - CountUpTimerProc(data); - } - void ThunderBirdModel::StartCountUpTimer(uint32_t targetSeconds) - { - // 参数保护:至少为1秒 - if (targetSeconds < 1) { targetSeconds = 1; } - // 停止旧定时器 - if (g_countUpTimer != nullptr) - { - osTimerStop(g_countUpTimer); - osStatus_t ret = osTimerDelete(g_countUpTimer); - (void)ret; - g_countUpTimer = nullptr; - } - // 初始化 - g_countUpTargetSeconds = (int)targetSeconds; - g_countUpValue = 0; - // 创建1s周期定时器 - uint32_t oneSecond = 1000; - g_countUpTimer = osTimerNew((osTimerFunc_t)CountUpTimerCb, osTimerPeriodic, nullptr, nullptr); - if (g_countUpTimer == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountUpTimer new timer failed!!"); - return; - } - osStatus_t ret = osTimerStart(g_countUpTimer, oneSecond); - if (ret != osOK) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountUpTimer start failed, ret = %lx!!", ret); - osTimerDelete(g_countUpTimer); - g_countUpTimer = nullptr; - } - } - void ThunderBirdModel::StopCountUpTimer(void) - { - if (g_countUpTimer != nullptr) - { - osTimerStop(g_countUpTimer); - osStatus_t ret = osTimerDelete(g_countUpTimer); - if (ret != osOK) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopCountUpTimer delete failed, ret = %lx!!", ret); - } - g_countUpTimer = nullptr; - } - } - int ThunderBirdModel::GetCountUpValue() const - { - return g_countUpValue; - } - -} + ThunderBirdModel *ThunderBirdModel::GetInstance() + { + static ThunderBirdModel instance; + return &instance; + } + // 获取当前时间戳字符串 + std::string ThunderBirdModel::GetCurrentTimeStr() + { + uint32_t timeStamp = 0; + if (uapi_get_timestampe_ss(&timeStamp) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); + return "----/--/-- \n --/--"; + } + // 将时间戳转换为 time_t 类型 + time_t rawtime = static_cast(timeStamp); + struct tm *timeinfo = localtime(&rawtime); + + if (timeinfo == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert time"); + return "----/--/-- \n --/--"; + } + + // 格式化时间为字符串 (HH:MM:SS format) + char buffer[20]; // 格式: HH:MM:SS + std::strftime(buffer, sizeof(buffer), "%H:%M", timeinfo); + return std::string(buffer); + } + void ThunderBirdModel::timer_callback_proc() + { + ThunderBirdMainView *view = ThunderBirdMainView::GetInstance(); + if (view) + { + view->UpdateTimeText(GetCurrentTimeStr().c_str()); + } + } + + + + /* ---------------------- 状态栏时间刷新定时器 ---------------------- */ + static osTimerId_t g_timer = nullptr; + /*定时器到期时的处理*/ + static void TimerCallbackProc(uint8_t data) + { + // 倒计时 + ThunderBirdModel::GetInstance()->timer_callback_proc(); + ThunderBirdMainView::GetInstance()->updateSignalDisplay(); + ThunderBirdMainView::GetInstance()->UpdateBatteryProcess(); + } + /* + * @brief 回调函数 + */ + static void TimerCallback(uint8_t data) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerCallback %d", data); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(TimerCallbackProc, data)); + } + + /* + * @brief 开启定时器函数 + * @param interval 时间间隔,单位ms + */ + void ThunderBirdModel::StartTimer(uint32_t interval) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartTimer"); + /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 + * ------------------------- */ + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); + return; + } + + /* --------------------------------- 2.创建定时器 + * -------------------------------- */ + g_timer = osTimerNew((osTimerFunc_t)TimerCallback, osTimerPeriodic, + nullptr, nullptr); + // 检查定时器创建是否成功 + if (g_timer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); + return; + } + + /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 + * ---------------------------- */ + /* --------------------------------- 4.启动定时器 + * -------------------------------- */ + osStatus_t ret = osTimerStart(g_timer, interval); + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 + * nullptr -------------------- */ + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "osTimerDelete failed, ret = %lx!!", ret); + if (g_timer != nullptr) + { + ret = osTimerDelete(g_timer); + } + g_timer = nullptr; + return; + } + } + /* + * @brief 停止定时器 + */ + void ThunderBirdModel::StopTimer(void) + { + // 检查定时器是否存在 + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::BP_StopTimer"); + osTimerStop(g_timer); + // 删除定时器并置为 nullptr + osStatus_t ret = osTimerDelete(g_timer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "osTimerDelete failed, ret = %lx!!", ret); + } + g_timer = nullptr; + } + } + + /*----------------------提醒界面定时器----------------------------------*/ + static osTimerId_t g_reminderHideTimer = nullptr; + static void ReminderHideTimerCallbackProc(uint8_t data) + { + (void)data; + auto *reminder = ThunderBirdReminderView::GetInstance(); + if (reminder != nullptr) + { + reminder->HideAll(); + } + int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); + int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView, currentSubView); + // 隐藏后切回之前的界面 + // auto *mainv = ThunderBirdReminderView::GetInstance(); + // if (mainv != nullptr)//判断条件需要修改 + // { + // mainv->Show(-1); + // } + } + static void ReminderHideTimerCallback(uint8_t data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(ReminderHideTimerCallbackProc, data)); + } + void ThunderBirdModel::StartReminderHideTimer(uint32_t intervalMs) + { + if (g_reminderHideTimer != nullptr) + { + osTimerStop(g_reminderHideTimer); + osStatus_t ret = osTimerDelete(g_reminderHideTimer); + (void)ret; + g_reminderHideTimer = nullptr; + } + g_reminderHideTimer = osTimerNew((osTimerFunc_t)ReminderHideTimerCallback, osTimerOnce, nullptr, nullptr); + if (g_reminderHideTimer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartReminderHideTimer new timer failed!!"); + return; + } + osStatus_t ret = osTimerStart(g_reminderHideTimer, intervalMs); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartReminderHideTimer start failed, ret = %lx!!", ret); + osTimerDelete(g_reminderHideTimer); + g_reminderHideTimer = nullptr; + } + auto *reminder = ThunderBirdReminderView::GetInstance();//先隐藏全部提醒界面 + if (reminder != nullptr) + { + reminder->HideAll(); + } + } + + // ---------------------- OTA 倒计时定时器(5 -> 1,每步1秒) ---------------------- + static osTimerId_t g_otaCountdownTimer = nullptr; + static int g_otaCountdownValue = 0; + static void OtaCountdownTimerProc(uint8_t data) + { + (void)data; + if (g_otaCountdownValue < 1) + { + // 停止并删除 + if (g_otaCountdownTimer != nullptr) + { + osTimerStop(g_otaCountdownTimer); + osTimerDelete(g_otaCountdownTimer); + g_otaCountdownTimer = nullptr; + } + g_otaCountdownValue = 0; + //自动跳转到开始OTA界面 + ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING); + return; + + + } + g_otaCountdownValue -= 1; + GraphicService::GetInstance()->PostGraphicEvent([](){ + if (ThunderBirdOtaView::GetInstance()) + { + ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue); + } + }); + } + static void OtaCountdownTimerCb(uint8_t data) + { + OtaCountdownTimerProc(data); + } + void ThunderBirdModel::StartOtaCountdown(uint32_t startVal) + { + // 范围保护 + if (startVal < 1) { startVal = 1; } + if (startVal > 5) { startVal = 5; } + // 先停旧定时器 + if (g_otaCountdownTimer != nullptr) + { + osTimerStop(g_otaCountdownTimer); + osTimerDelete(g_otaCountdownTimer); + g_otaCountdownTimer = nullptr; + } + g_otaCountdownValue = (int)startVal; + // 立即刷新一次当前值 + if (ThunderBirdOtaView::GetInstance()) + { + ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue); + } + // 创建1s周期定时器 + uint32_t oneSecond = 1000; + g_otaCountdownTimer = osTimerNew((osTimerFunc_t)OtaCountdownTimerCb, osTimerPeriodic, nullptr, nullptr); + if (g_otaCountdownTimer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown new timer failed!!"); + return; + } + osStatus_t ret = osTimerStart(g_otaCountdownTimer, oneSecond); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown start failed, ret = %lx!!", ret); + osTimerDelete(g_otaCountdownTimer); + g_otaCountdownTimer = nullptr; + } + } + void ThunderBirdModel::StopOtaCountdown(void) + { + if (g_otaCountdownTimer != nullptr) + { + osTimerStop(g_otaCountdownTimer); + osTimerDelete(g_otaCountdownTimer); + g_otaCountdownTimer = nullptr; + } + g_otaCountdownValue = 0; + } + + + // ---------------------- 通用计时加一定时器(0 -> targetSeconds,每步1秒) ---------------------- + static osTimerId_t g_countUpTimer = nullptr; + static int g_countUpTargetSeconds = 0; + static int g_countUpValue = 0; + static void CountUpTimerProc(uint8_t data) + { + (void)data; + if (g_countUpValue >= g_countUpTargetSeconds) + { + if (g_countUpTimer != nullptr) + { + osTimerStop(g_countUpTimer); + osTimerDelete(g_countUpTimer); + g_countUpTimer = nullptr; + } + return; + } + g_countUpValue += 1; + ThunderBirdLullabyView::GetInstance()->UpdateTimeText(g_countUpValue, g_countUpTargetSeconds); + } + static void CountUpTimerCb(uint8_t data) + { + CountUpTimerProc(data); + } + void ThunderBirdModel::StartCountUpTimer(uint32_t targetSeconds) + { + // 参数保护:至少为1秒 + if (targetSeconds < 1) { targetSeconds = 1; } + // 停止旧定时器 + if (g_countUpTimer != nullptr) + { + osTimerStop(g_countUpTimer); + osStatus_t ret = osTimerDelete(g_countUpTimer); + (void)ret; + g_countUpTimer = nullptr; + } + // 初始化 + g_countUpTargetSeconds = (int)targetSeconds; + g_countUpValue = 0; + // 创建1s周期定时器 + uint32_t oneSecond = 1000; + g_countUpTimer = osTimerNew((osTimerFunc_t)CountUpTimerCb, osTimerPeriodic, nullptr, nullptr); + if (g_countUpTimer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountUpTimer new timer failed!!"); + return; + } + osStatus_t ret = osTimerStart(g_countUpTimer, oneSecond); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountUpTimer start failed, ret = %lx!!", ret); + osTimerDelete(g_countUpTimer); + g_countUpTimer = nullptr; + } + } + void ThunderBirdModel::StopCountUpTimer(void) + { + if (g_countUpTimer != nullptr) + { + osTimerStop(g_countUpTimer); + osStatus_t ret = osTimerDelete(g_countUpTimer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopCountUpTimer delete failed, ret = %lx!!", ret); + } + g_countUpTimer = nullptr; + } + } + int ThunderBirdModel::GetCountUpValue() const + { + return g_countUpValue; + } + // ==================== 开机操作函数 ==================== + int ThunderBirdModel::StartBootOperation() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartBootOperation"); + //绑定设备提示 > 配置更新成功>OTA升级>其他(按触发时间先后提示) + /*************************用户是否绑定*************************/ + do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_USER_ID, nullptr, 0);//获取用户是否绑定 + if(uapi_ln_is_device_bound() == 0)//未绑定 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartBootOperation: 未绑定"); + ThunderBirdMainView::GetInstance()->ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_1); + return 0; + } + else if(uapi_ln_is_device_bound() == 1)//已绑定 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartBootOperation: 已绑定"); + ThunderBirdMainView::GetInstance()->ChangeView(MAXVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); + return 1; + } + + /*************************更新角色配置*************************/ + //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_CHARACTER, nullptr, 0);//获取角色配置 + + + /*************************OTA升级*************************/ + do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_GET_TASK, nullptr, 0);//获取是否需要OTA升级 + if(uapi_ln_ota_get_update_type() == 1)//强制OTA升级 + { + ThunderBirdMainView::GetInstance()->ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW); + return 3; + } + if(uapi_ln_ota_get_update_type() == 0)//可选OTA升级 + { + ThunderBirdMainView::GetInstance()->ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL); + //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0); + return 5; + } + return -1; + } + + // ==================== 新手引导相关函数 ==================== + ThunderBirdModel::BindingStatus ThunderBirdModel::CheckBindingStatus() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::CheckBindingStatus"); + + // TODO: 实现实际的绑定状态检查逻辑 + // 这里需要根据实际的网络状态和设备绑定状态来判断 + //if(uapi_dev_runtime_get_cat1_signal() == 99) + // 模拟实现 - 实际应该检查网络连接和绑定状态 + // 返回未绑定状态作为默认值 + return BindingStatus::NOT_BOUND; + } + #ifdef __cplusplus + extern "C" + { + #endif + int32_t AudioCaptureSample(int32_t argc, const char *argv[]); + + #ifdef __cplusplus + }; + #endif + // ==================== 对话相关函数 ==================== + bool ThunderBirdModel::StartRecording() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartRecording"); + + // TODO: 实现开始录音逻辑 + // 1. 初始化录音设备 + // 2. 开始录音 + // 3. 设置录音状态 + if(g_isRecording == true) + { + return false; + } + g_isRecording = true;//设置录音状态 + std::string audioPath = "/user/123.mp3";//故事选择的录音文件路径 + // uapi_ln_get_story_choose_audio_path(); + // audioPath = "/user/audio/test.pcm";//修改为实际的录音文件路径 + + // // 确保目录存在 + //std::string dirPath = "/user/123.mp3"; + // 这里可以添加目录创建逻辑 + + const char *defaultArgs[6] = {"01", "mp3", "16000", "1", "16", audioPath.c_str()}; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartRecording: 开始录音,路径: %s", audioPath.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartRecording: 参数 - 格式: %s, 采样率: %s, 声道: %s, 位宽: %s", + defaultArgs[1], defaultArgs[2], defaultArgs[3], defaultArgs[4]); + + int32_t ret = AudioCaptureSample(6, defaultArgs); + if (ret != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartRecording: AudioCaptureSample 失败,返回值: %d", ret); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartRecording: 可能的原因 - 音频设备被占用、权限不足或音频服务未初始化"); + g_isRecording = false; + return false; + } + + return true; // 模拟成功 + } + + bool ThunderBirdModel::StopRecording() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StopRecording"); + + // TODO: 实现停止录音逻辑 + // 1. 停止录音设备 + // 2. 保存录音文件 + // 3. 清理录音状态 + if(g_isRecording == false) + { + return false; + } + g_isRecording = false;//设置录音状态 + int32_t argc = 1; + uint8_t *argv = (uint8_t *)"stop"; + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StopRecording: 停止录音"); + int32_t ret = AudioCaptureSample(argc, (const char **)&argv); + if (ret != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StopRecording: AudioCaptureSample 停止失败,返回值: %d", ret); + return false; + } + + return true; // 模拟成功 + } + + bool ThunderBirdModel::SendRecording() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SendRecording"); + + // TODO: 实现发送录音逻辑 + // 1. 读取录音文件 + // 2. 通过网络发送到服务器 + // 3. 等待服务器响应 + //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_SPEECH_CHAT_STREAM, NULL, 0);//开始对话 + do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_STORY_CHOOSE, NULL, 0);//选择故事 + + return true; // 模拟成功 + } + + bool ThunderBirdModel::ReceiveAnswer() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::ReceiveAnswer"); + + // TODO: 实现接收回答逻辑 + // 1. 监听服务器响应 + // 2. 解析回答数据 + // 3. 更新对话状态 + if(g_isRecording == false && 1/*服务器相应*/) + { + + } + return true; // 模拟成功 + } + + std::string ThunderBirdModel::GetConversationText() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::GetConversationText"); + + // TODO: 实现获取对话文本逻辑 + // 1. 从缓存或存储中获取对话文本 + // 2. 格式化文本 + // 3. 返回文本内容 + + return "模拟对话文本"; // 模拟返回 + } + + bool ThunderBirdModel::EndConversation() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::EndConversation"); + + // TODO: 实现结束对话逻辑 + // 1. 清理对话状态 + // 2. 保存对话记录 + // 3. 释放相关资源 + + return true; // 模拟成功 + } + + // ==================== 哄睡模式相关函数 ==================== + bool ThunderBirdModel::StartLullabyMode() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartLullabyMode"); + + // TODO: 实现开始哄睡模式逻辑 + // 1. 初始化哄睡模式状态 + // 2. 开始播放哄睡音频 + // 3. 设置定时器 + // 4. 更新UI状态 + + return true; // 模拟成功 + } + + bool ThunderBirdModel::StopLullabyMode() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StopLullabyMode"); + + // TODO: 实现停止哄睡模式逻辑 + // 1. 停止播放哄睡音频 + // 2. 清理哄睡模式状态 + // 3. 停止相关定时器 + // 4. 更新UI状态 + + return true; // 模拟成功 + } + + bool ThunderBirdModel::IsLullabyModeActive() const + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::IsLullabyModeActive"); + + // TODO: 实现检查哄睡模式是否激活的逻辑 + // 1. 检查哄睡模式状态标志 + // 2. 检查音频播放状态 + // 3. 返回当前状态 + + return false; // 模拟未激活 + } + + // ==================== 事项提醒相关函数 ==================== + bool ThunderBirdModel::AddReminder(const std::string& content, uint32_t timestamp) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::AddReminder: %s, timestamp: %u", + content.c_str(), timestamp); + + // 验证输入参数 + if (content.empty() || content.length() >= 255) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid reminder content"); + return false; + } + + if (timestamp == 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid timestamp"); + return false; + } + + // 创建提醒对象 + ReminderData reminder; + reminder.id = GenerateReminderId(); + reminder.timestamp = timestamp; + reminder.isActive = true; + reminder.createTime = static_cast(time(nullptr)); + + // 复制内容(确保不超过255字符) + strncpy(reminder.content, content.c_str(), sizeof(reminder.content) - 1); + reminder.content[sizeof(reminder.content) - 1] = '\0'; + + // 添加到列表 + m_reminders.push_back(reminder); + + // 保存到文件 + if (!SaveRemindersToFile()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to save reminders to file"); + // 从列表中移除(回滚) + m_reminders.pop_back(); + return false; + } + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Added reminder with ID: %u", reminder.id); + return true; + } + + bool ThunderBirdModel::RemoveReminder(uint32_t reminderId) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::RemoveReminder: %u", reminderId); + + // 查找提醒 + auto it = std::find_if(m_reminders.begin(), m_reminders.end(), + [reminderId](const ReminderData& reminder) { + return reminder.id == reminderId; + }); + + if (it == m_reminders.end()) { + WEARABLE_LOGW(WEARABLE_LOG_MODULE_APP, "Reminder not found: %u", reminderId); + return false; + } + + // 从列表中删除 + m_reminders.erase(it); + + // 保存到文件 + if (!SaveRemindersToFile()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to save reminders to file after removal"); + return false; + } + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Removed reminder with ID: %u", reminderId); + return true; + } + + bool ThunderBirdModel::UpdateReminder(uint32_t reminderId, const std::string& content, uint32_t timestamp) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::UpdateReminder: %u, %s, %u", + reminderId, content.c_str(), timestamp); + + // 验证输入参数 + if (content.empty() || content.length() >= 255) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid reminder content"); + return false; + } + + if (timestamp == 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid timestamp"); + return false; + } + + // 查找提醒 + auto it = std::find_if(m_reminders.begin(), m_reminders.end(), + [reminderId](const ReminderData& reminder) { + return reminder.id == reminderId; + }); + + if (it == m_reminders.end()) { + WEARABLE_LOGW(WEARABLE_LOG_MODULE_APP, "Reminder not found: %u", reminderId); + return false; + } + + // 更新提醒内容和时间 + it->timestamp = timestamp; + strncpy(it->content, content.c_str(), sizeof(it->content) - 1); + it->content[sizeof(it->content) - 1] = '\0'; + + // 保存到文件 + if (!SaveRemindersToFile()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to save reminders to file after update"); + return false; + } + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Updated reminder with ID: %u", reminderId); + return true; + } + + std::vector ThunderBirdModel::GetReminders() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::GetReminders"); + + // TODO: 实现获取提醒列表逻辑 + // 1. 从存储系统读取所有提醒 + // 2. 按时间排序 + // 3. 格式化为字符串列表 + // 4. 返回提醒列表 + + std::vector reminders; + for (const auto& reminder : m_reminders) { + if (reminder.isActive) { + char timeStr[32]; + time_t time = static_cast(reminder.timestamp); + struct tm* timeinfo = localtime(&time); + if (timeinfo) { + strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M", timeinfo); + std::string reminderStr = std::string(timeStr) + ": " + reminder.content; + reminders.push_back(reminderStr); + } + } + } + return reminders; + } + + // ==================== 文件存储相关函数 ==================== + std::string ThunderBirdModel::GetReminderFilePath() const + { + // 返回提醒数据文件的完整路径 + return "/user/reminders/reminder_data.bin"; + } + + uint32_t ThunderBirdModel::GenerateReminderId() + { + return m_nextReminderId++; + } + + bool ThunderBirdModel::SaveRemindersToFile() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SaveRemindersToFile"); + + std::string filePath = GetReminderFilePath(); + + // 创建目录(如果不存在) + std::string dirPath = filePath.substr(0, filePath.find_last_of('/')); + // TODO: 实现目录创建逻辑 + + // 打开文件进行二进制写入 + std::ofstream file(filePath, std::ios::binary); + if (!file.is_open()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file for writing: %s", filePath.c_str()); + return false; + } + + // 写入提醒数量 + uint32_t count = static_cast(m_reminders.size()); + file.write(reinterpret_cast(&count), sizeof(count)); + + // 写入每个提醒数据 + for (const auto& reminder : m_reminders) { + file.write(reinterpret_cast(&reminder), sizeof(ReminderData)); + } + + file.close(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Saved %u reminders to file", count); + return true; + } + + bool ThunderBirdModel::LoadRemindersFromFile() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::LoadRemindersFromFile"); + + std::string filePath = GetReminderFilePath(); + + // 打开文件进行二进制读取 + std::ifstream file(filePath, std::ios::binary); + if (!file.is_open()) { + WEARABLE_LOGW(WEARABLE_LOG_MODULE_APP, "Reminder file not found: %s", filePath.c_str()); + return false; // 文件不存在不算错误 + } + + // 清空现有数据 + m_reminders.clear(); + + // 读取提醒数量 + uint32_t count = 0; + file.read(reinterpret_cast(&count), sizeof(count)); + + if (count > 1000) { // 防止异常数据 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid reminder count: %u", count); + return false; + } + + // 读取每个提醒数据 + for (uint32_t i = 0; i < count; i++) { + ReminderData reminder; + file.read(reinterpret_cast(&reminder), sizeof(ReminderData)); + + // 验证数据有效性 + if (reminder.id > 0 && reminder.timestamp > 0) { + m_reminders.push_back(reminder); + // 更新下一个ID + if (reminder.id >= m_nextReminderId) { + m_nextReminderId = reminder.id + 1; + } + } + } + + file.close(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Loaded %u reminders from file", static_cast(m_reminders.size())); + return true; + } + + /* + 1、新手引导 + 判断是否绑定 返回,0:绑定,1:未绑定;2:没有网络 使用枚举 + 2、对话 + 2.1 录音 + 开始录音接口 + 停止录音接口 + 2.2 发送录音接口 + 2.3 接收回答数据 + 2.4 对话文本获取接口 + 2.5 对话结束接口 + 3、哄睡模式 + 4、事项提醒 + */ + } + \ No newline at end of file diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index fcdd1593b..7940f742f 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -158,8 +158,17 @@ namespace OHOS int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); - ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING); - + if(currentView == THUNDERBIRD_DIALOGUEVIEW && currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING) + { + ThunderBirdModel::GetInstance()->StopRecording(); + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); + ThunderBirdModel::GetInstance()->SendRecording(); + } + else + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING); + ThunderBirdModel::GetInstance()->StartRecording(); + } } diff --git a/code/sdk/application/wearable/ln/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/ln/service/msg_center/CMakeLists.txt index 22745fe22..db5c1d1ac 100644 --- a/code/sdk/application/wearable/ln/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/ln/service/msg_center/CMakeLists.txt @@ -31,6 +31,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/zhihui/4g/cat1Service ${ROOT_DIR}/zhihui/4g/cat1Service/include ${ROOT_DIR}/zhihui/4g/cat1Service/Service + ${ROOT_DIR}/zhihui/leiniao ) set(SOURCES diff --git a/code/sdk/application/wearable/ohos_startup/ohosfwk_startup.c b/code/sdk/application/wearable/ohos_startup/ohosfwk_startup.c index b313663ff..cc0800f09 100644 --- a/code/sdk/application/wearable/ohos_startup/ohosfwk_startup.c +++ b/code/sdk/application/wearable/ohos_startup/ohosfwk_startup.c @@ -85,13 +85,13 @@ void ohos_startup() return; } -#ifndef BOARD_LEINIAO +//#ifdef BOARD_LEINIAO #ifdef ENABLE_UIKIT boot_animation_init(); #endif wait_animation_stop(); boot_animation_init_deinit(); -#endif +//#endif #if defined(CONFIG_OTA_UPDATE_SUPPORT) && defined(ENABLE_UIKIT) //如果在升级状态,则不进入系统 if (upg_check_upgrade_need_upgrade()) return ; -- 2.17.1