完善OTA,故事模式逻辑
authorxue <2144439972@qq.com>
Sat, 20 Sep 2025 07:39:16 +0000 (15:39 +0800)
committerxue <2144439972@qq.com>
Sat, 20 Sep 2025 07:39:16 +0000 (15:39 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp

index a43c224..fba9674 100644 (file)
@@ -38,6 +38,10 @@ namespace OHOS
             THUNDERBIRD_LULLABYVIEW_5,
         };
 
+        UIImageAnimatorView *listenAnimator{nullptr};
+        ImageAnimatorInfo listenImageInfo[TB_LISTEN_FRAMES];
+        const char **listenPathsArray{nullptr};
+
     private:
         UIViewGroup *group{nullptr};
         UILabelExt *TextLabel{nullptr};
@@ -45,9 +49,6 @@ namespace OHOS
         UILabelExt *RemindLabel{nullptr};
         UIImageView *RemindIcon{nullptr};
         UIImageView *RemindIcon2{nullptr};
-        UIImageAnimatorView *listenAnimator{nullptr};
-        ImageAnimatorInfo listenImageInfo[TB_LISTEN_FRAMES];
-        const char **listenPathsArray{nullptr};
         void UpdateLullabyText(const char *text);
     };
 }
index 49c74dc..59c5e37 100644 (file)
@@ -39,6 +39,7 @@ namespace OHOS
         // OTA升级状态
         void UpdateOtaStatus(int status);   
         int GetOtaStatus();
+        int GetOtaProgress();
      // 新手引导相关函数
      enum class BindingStatus {
         BOUND = 0,      // 已绑定
@@ -50,7 +51,7 @@ namespace OHOS
         BindingStatus CheckBindingStatus();
 
         // 对话相关函数
-        bool StartRecording();
+        bool StartRecording(std::string audioPath);
         bool StopRecording();
         bool SendRecording();
         bool ReceiveAnswer();
@@ -117,6 +118,8 @@ namespace OHOS
         std::string m_currentTimeStr;
         // OTA升级状态
         int m_otaStatus;
+        // OTA升级进度
+        int m_otaProgress;
     };
 }
 
index 329bcb6..a3c29d6 100644 (file)
 
 namespace OHOS
 {
+    enum KeyType
+    {
+        KEY_TYPE_POWER = 0,
+        KEY_TYPE_FUNC,
+        KEY_TYPE_VENDOR_UP,
+        KEY_TYPE_VENDOR_DOWN,
+    };
     class ThunderBirdMainView;
     class ThunderBirdPresenter : public Presenter<ThunderBirdMainView>,
                                      public UIView::OnClickListener,
@@ -35,6 +42,8 @@ namespace OHOS
     private:
         bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
         bool X_DRAG_FLAG{false};
+
+        bool isLullabyRecording{false};
         
         // 按键处理函数
         bool HandlePowerKey(uint16_t keyState, int16_t currentView, int16_t currentSubView, int screenState);
@@ -44,17 +53,18 @@ namespace OHOS
         
         // 辅助函数
         void HandleDialogueFunction(int16_t currentView, int16_t currentSubView);
+        void HandleLullabyFunction(int16_t currentView, int16_t currentSubView);
         bool IsVolumeAdjustmentAvailable(int16_t currentView, int16_t currentSubView);
         void ShowVolumeAdjustment(int volumeDelta);
-        bool HandleViewNavigation(int16_t currentView, int16_t currentSubView, bool isUpKey);
+        bool HandleViewNavigation(int16_t currentView, int16_t currentSubView, bool isUpKey, KeyType keyType);
         
         // 界面导航处理函数
-        bool HandleGuideViewNavigation(int16_t currentSubView);
-        bool HandleDialogueViewNavigation(int16_t currentSubView);
-        bool HandleOtaViewNavigation(int16_t currentSubView);
-        bool HandleLullabyViewNavigation(int16_t currentSubView);
-        bool HandleReminderViewNavigation(int16_t currentSubView);
-        bool HandleAdjustViewNavigation(int16_t currentSubView);
+        bool HandleGuideViewNavigation(int16_t currentSubView, KeyType keyType);
+        bool HandleDialogueViewNavigation(int16_t currentSubView, KeyType keyType);
+        bool HandleOtaViewNavigation(int16_t currentSubView, KeyType keyType);
+        bool HandleLullabyViewNavigation(int16_t currentSubView, KeyType keyType);
+        bool HandleReminderViewNavigation(int16_t currentSubView, KeyType keyType);
+        bool HandleAdjustViewNavigation(int16_t currentSubView, KeyType keyType);
         bool CheckOtaConditionsAndProceed();
     };
 }
index 9a91425..b466698 100644 (file)
@@ -307,7 +307,7 @@ namespace OHOS
                 TextLabel->SetRollSpeed(35);
                 TextLabel->SetVisible(true);
             }
-            if (listenAnimator) { listenAnimator->SetVisible(true); listenAnimator->Start(); }
+            if (listenAnimator) { listenAnimator->SetVisible(true);  }
             if (RemindLabel)
             {
                 RemindLabel->SetPosition(80, 275, 200, 25);
index ab8cfc9..35006c5 100644 (file)
 
 
 
-     // ---------------------- OTA 倒计时定时器(5 -> 1,每步1秒) ----------------------
+    // ---------------------- OTA 倒计时定时器(5 -> 1,每步1秒,然后监控下载状态) ----------------------
      static osTimerId_t g_otaCountdownTimer = nullptr;
      static int g_otaCountdownValue = 0;
+    static int g_otaDownloadTimeout = 0; // 下载超时计数器(秒)
+    static const int OTA_DOWNLOAD_TIMEOUT_SECONDS = 60; // 60秒超时
      static void OtaCountdownTimerProc(uint8_t data)
      {
          (void)data;
-         if (g_otaCountdownValue < 1)
+        
+        // 前5秒:倒计时阶段
+        if (g_otaCountdownValue > 0)
+        {
+            g_otaCountdownValue -= 1;
+            GraphicService::GetInstance()->PostGraphicEvent([](){
+                if (ThunderBirdOtaView::GetInstance())
          {
-             // 停止并删除
+                    ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue);
+                }
+            });
+            return;
+        }
+        
+        // 倒计时结束,跳转到下载中界面
+        if (g_otaCountdownValue == 0)
+        {
+            g_otaCountdownValue = -1; // 标记已进入下载阶段
+            g_otaDownloadTimeout = 0; // 重置超时计数器
+            
+            // 开始OTA下载
+            do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0);
+            ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING);
+            return;
+        }
+        
+        // 下载阶段:检查OTA状态
+        if (g_otaCountdownValue == -1)
+        {
+            g_otaDownloadTimeout++;
+            // 检查超时(60秒无数据更新)
+            if (g_otaDownloadTimeout >= OTA_DOWNLOAD_TIMEOUT_SECONDS)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OTA download timeout after %d seconds", OTA_DOWNLOAD_TIMEOUT_SECONDS);
+                
+                // 停止定时器
              if (g_otaCountdownTimer != nullptr)
              {
                  osTimerStop(g_otaCountdownTimer);
                  osTimerDelete(g_otaCountdownTimer);
                  g_otaCountdownTimer = nullptr;
              }
-             g_otaCountdownValue = 0;
-             //自动跳转到开始OTA界面
-             do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0);//升级开始
-             ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING);
+                
+                // 跳转到失败界面
+                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED);
              return;
- 
+            }
             
-         }
-         g_otaCountdownValue -= 1;
-         GraphicService::GetInstance()->PostGraphicEvent([](){
-             if (ThunderBirdOtaView::GetInstance())
-             {
-                 ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue);
-             }
-         });
+            // 检查OTA状态
+            ThunderBirdModel* model = ThunderBirdModel::GetInstance();
+            int otaStatus = model->GetOtaStatus();
+            
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA status check: status=%d, timeout=%d", otaStatus, g_otaDownloadTimeout);
+            
+            if (otaStatus == 2) // 更新成功
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OTA update success");
+                
+                // 停止定时器
+                if (g_otaCountdownTimer != nullptr)
+                {
+                    osTimerStop(g_otaCountdownTimer);
+                    osTimerDelete(g_otaCountdownTimer);
+                    g_otaCountdownTimer = nullptr;
+                }
+                
+                // 跳转到成功界面
+                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS);
+                return;
+            }
+            else if (otaStatus == 3) // 更新失败
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OTA update failed");
+                
+                // 停止定时器
+                if (g_otaCountdownTimer != nullptr)
+                {
+                    osTimerStop(g_otaCountdownTimer);
+                    osTimerDelete(g_otaCountdownTimer);
+                    g_otaCountdownTimer = nullptr;
+                }
+                
+                // 跳转到失败界面
+                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED);
+                return;
+            }
+        }
      }
      static void OtaCountdownTimerCb(uint8_t data)
      {
          g_otaCountdownTimer = nullptr;
      }
          g_otaCountdownValue = 0;
+         g_otaDownloadTimeout = 0; // 重置超时计数器
      }
 
 
      void ThunderBirdModel::UpdateOtaProgress(int progress)
      {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::UpdateOtaProgress: %d", progress);
+        m_otaProgress = progress;
         if(ThunderBirdOtaView::GetInstance())
         {
             ThunderBirdOtaView::GetInstance()->SetRemindProgress(progress);
         }
      }
-
+     /*************************获取OTA升级进度*************************/
+     int ThunderBirdModel::GetOtaProgress()
+     {
+        return m_otaProgress;
+     }
      /*************************OTA升级状态*************************/
      void ThunderBirdModel::UpdateOtaStatus(int status)
      {
      }
 
      // ==================== 对话相关函数 ====================
-     bool ThunderBirdModel::StartRecording()
+     bool ThunderBirdModel::StartRecording(std::string audioPath)
      {
          WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartRecording");
          
              return false;
          }
          g_isRecording = true;//设置录音状态
-         std::string audioPath = uapi_ln_get_story_choose_audio_path();
+        // std::string audioPath = uapi_ln_get_speechchat_audio_path();
         if(audioPath.empty())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartRecording: 故事选择的录音文件路径为空");
index 2ac068b..95fd3b7 100644 (file)
@@ -1,5 +1,6 @@
 #include "thunderbird/include/ThunderBirdOtaView.h"
 #include "thunderbird/include/ThunderBirdModel.h"
+#include "thunderbird/include/ThunderBirdPresenter.h"
 #include "wearable_log.h"
 
 namespace OHOS
@@ -486,6 +487,11 @@ namespace OHOS
         }
         case THUNDERBIRD_OTAVIEW_UPDATING:
         {
+            if(ThunderBirdModel::GetInstance()->GetOtaStatus() != 1)//如果不是下载状态 则返回
+            {
+                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED);
+                return;
+            }
             if (TextLabel)
             {
                 TextLabel->SetPosition(90, 108, 180, 82);
index f4e0d41..d813b91 100644 (file)
@@ -211,10 +211,15 @@ namespace OHOS
                 }
                 return true;
             }
-            
-            // 处理对话功能
-            HandleDialogueFunction(currentView, currentSubView);
-            return true;
+            if(currentView == THUNDERBIRD_LULLABYVIEW && currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3)
+            {
+                HandleLullabyFunction(currentView, currentSubView);              
+            }
+            else
+            {
+                // 处理对话功能
+                HandleDialogueFunction(currentView, currentSubView);
+            }
         }
         
         return true;
@@ -241,7 +246,7 @@ namespace OHOS
             }
             
             // 界面导航
-            return HandleViewNavigation(currentView, currentSubView, true);
+            return HandleViewNavigation(currentView, currentSubView, true, KEY_TYPE_VENDOR_UP);
         }
         
         return true;
@@ -275,9 +280,12 @@ namespace OHOS
             }
             
             // OTA界面特殊处理
-            if (currentView == THUNDERBIRD_OTAVIEW) {
-                return HandleOtaViewNavigation(currentSubView);
-            }
+            // if (currentView == THUNDERBIRD_OTAVIEW) {
+            //     return HandleOtaViewNavigation(currentSubView, KEY_TYPE_VENDOR_DOWN);
+            // }
+            
+            // 其他界面的通用导航处理
+            return HandleViewNavigation(currentView, currentSubView, false, KEY_TYPE_VENDOR_DOWN);
         }
         
         return true;
@@ -299,10 +307,36 @@ namespace OHOS
         } else {
             // 开始录音
             ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
-            ThunderBirdModel::GetInstance()->StartRecording();
+            ThunderBirdModel::GetInstance()->StartRecording(uapi_ln_get_speechchat_audio_path());
         }
     }
 
+        /**
+     * @brief 处理哄睡功能
+     */
+     void ThunderBirdPresenter::HandleLullabyFunction(int16_t currentView, int16_t currentSubView)
+     {
+         if (currentView == THUNDERBIRD_LULLABYVIEW && 
+             currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3) {
+                if(isLullabyRecording == false)
+                {
+                    ThunderBirdModel::GetInstance()->StartRecording(uapi_ln_get_story_choose_audio_path());
+                    isLullabyRecording = true;
+                    ThunderBirdLullabyView::GetInstance()->listenAnimator->Start();
+                    return;
+                }
+                else
+                {
+                    // 停止录音并发送
+                    ThunderBirdModel::GetInstance()->StopRecording();
+                    isLullabyRecording = false;
+                    do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_STORY_CHOOSE, NULL, 0);
+                    ThunderBirdLullabyView::GetInstance()->listenAnimator->Stop();
+                    return;
+                }
+         }
+     }
+
     /**
      * @brief 检查是否可以调节音量
      */
@@ -330,26 +364,26 @@ namespace OHOS
     /**
      * @brief 处理界面导航
      */
-    bool ThunderBirdPresenter::HandleViewNavigation(int16_t currentView, int16_t currentSubView, bool isUpKey)
+    bool ThunderBirdPresenter::HandleViewNavigation(int16_t currentView, int16_t currentSubView, bool isUpKey, KeyType keyType)
     {
         switch (currentView) {
-            case THUNDERBIRD_GUIDEVIEW:
-                return HandleGuideViewNavigation(currentSubView);
+            case THUNDERBIRD_GUIDEVIEW://引导绑定界面
+                return HandleGuideViewNavigation(currentSubView, keyType);
                 
-            case THUNDERBIRD_DIALOGUEVIEW:
-                return HandleDialogueViewNavigation(currentSubView);
+            case THUNDERBIRD_DIALOGUEVIEW://对话界面
+                return HandleDialogueViewNavigation(currentSubView, keyType);
                 
-            case THUNDERBIRD_OTAVIEW:
-                return HandleOtaViewNavigation(currentSubView);
+            case THUNDERBIRD_OTAVIEW://OTA界面
+                return HandleOtaViewNavigation(currentSubView, keyType);
                 
-            case THUNDERBIRD_LULLABYVIEW:
-                return HandleLullabyViewNavigation(currentSubView);
+            case THUNDERBIRD_LULLABYVIEW://哄睡界面
+                return HandleLullabyViewNavigation(currentSubView, keyType);
                 
-            case THUNDERBIRD_REMINDERVIEW:
-                return HandleReminderViewNavigation(currentSubView);
+            case THUNDERBIRD_REMINDERVIEW://提醒界面
+                return HandleReminderViewNavigation(currentSubView, keyType);
                 
-            case THUNDERBIRD_ADJUSTVIEW:
-                return HandleAdjustViewNavigation(currentSubView);
+            case THUNDERBIRD_ADJUSTVIEW://提示界面
+                return HandleAdjustViewNavigation(currentSubView, keyType);
                 
             default:
                 return true;
@@ -361,70 +395,89 @@ namespace OHOS
     /**
      * @brief 处理引导界面导航
      */
-    bool ThunderBirdPresenter::HandleGuideViewNavigation(int16_t currentSubView)
+    bool ThunderBirdPresenter::HandleGuideViewNavigation(int16_t currentSubView, KeyType keyType)
     {
-        switch (currentSubView) {
-            case ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_1:
-                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_GUIDEVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2);
-                break;
-            case ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2:
-                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_GUIDEVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3);
-                break;
-            case ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3:
-                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_GUIDEVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING);
-                break;
+        if(keyType == KEY_TYPE_VENDOR_UP)
+        {
+        switch (currentSubView) 
+            {
+                case ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_1:
+                    ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_GUIDEVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2);
+                    break;
+                case ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2:
+                    ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_GUIDEVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3);
+                    break;
+                case ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3:
+                    ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_GUIDEVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING);
+                    break;
+            }
         }
         return true;
+ 
     }
 
     /**
      * @brief 处理对话界面导航
      */
-    bool ThunderBirdPresenter::HandleDialogueViewNavigation(int16_t currentSubView)
+    bool ThunderBirdPresenter::HandleDialogueViewNavigation(int16_t currentSubView, KeyType keyType)
     {
-        switch (currentSubView) {
-            case ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING:
-                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_DIALOGUEVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
-                break;
-            case ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING:
-                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_DIALOGUEVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
-                break;
-            case ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW:
-                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_DIALOGUEVIEW, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME);
-                break;
-        }
+        // switch (currentSubView) {
+        //     case ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING:
+        //         ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_DIALOGUEVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
+        //         break;
+        //     case ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING:
+        //         ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_DIALOGUEVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
+        //         break;
+        //     case ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW:
+        //         ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_DIALOGUEVIEW, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME);
+        //         break;
+        // }
         return true;
     }
 
     /**
      * @brief 处理OTA界面导航
      */
-    bool ThunderBirdPresenter::HandleOtaViewNavigation(int16_t currentSubView)
+    bool ThunderBirdPresenter::HandleOtaViewNavigation(int16_t currentSubView, KeyType keyType)
     {
-        switch (currentSubView) {
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW:
-                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS);
-                break;
-                
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL:
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS:
-                // 确认升级,检查条件
-                return CheckOtaConditionsAndProceed();
+        if(keyType == KEY_TYPE_VENDOR_UP)//VENDOR_UP键
+        {
+            switch (currentSubView) {
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW:
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL:
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS:
+                    // 确认升级,检查条件
+                    return CheckOtaConditionsAndProceed();
+                    
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN:
+                    // 进入更新中,手动确认,不等待
+                    ThunderBirdModel::GetInstance()->StopOtaCountdown();//取消倒计时界面整个定时器
+                    ThunderBirdModel::GetInstance()->StartOtaCountdown(0);//直接进入更新中,定时器会自己跳转与执行指令
+                    break;
+                    
+                // VENDOR_DOWN键的特殊处理
                 
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN:
-                // 进入更新中
-                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING);
-                do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0);
+            }
+            return true;
+        }
+        else if(keyType == KEY_TYPE_VENDOR_DOWN)//VENDOR_DOWN键
+        {
+            switch (currentSubView) {
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW:
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL:
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS:
+                ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE);
                 break;
-                
-            // VENDOR_DOWN键的特殊处理
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE:
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED:
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY:
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NETWORK_ERROR:
-            case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_MEMORY_ERROR:
+
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE:
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED:
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY:
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NETWORK_ERROR:
+                case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_MEMORY_ERROR:
                 ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING);
                 break;
+            }
+            return true;
         }
         return true;
     }
@@ -446,6 +499,7 @@ namespace OHOS
         } else {
             // 条件满足,开始倒计时
             ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN);
+
         }
         return true;
     }
@@ -453,8 +507,10 @@ namespace OHOS
     /**
      * @brief 处理哄睡界面导航
      */
-    bool ThunderBirdPresenter::HandleLullabyViewNavigation(int16_t currentSubView)
+    bool ThunderBirdPresenter::HandleLullabyViewNavigation(int16_t currentSubView, KeyType keyType)
     {
+        if(keyType == KEY_TYPE_VENDOR_UP)
+        {
         switch (currentSubView) {
             case ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1:
                 ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_2);
@@ -463,23 +519,33 @@ namespace OHOS
                 ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3);
                 break;
             case ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3:
+                do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_STORY_RANDOM, NULL, 0);//随机故事
                 ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4);
                 break;
             case ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4:
                 ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5);
                 break;
             case ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5:
-                // 返回主界面
+                do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_STORY_FINISH, NULL, 0);//确认结束哄睡
                 ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING);
                 break;
         }
+        }
+        else if(keyType == KEY_TYPE_VENDOR_DOWN)
+        {
+            switch (currentSubView) {
+                case ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3:
+                    ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4);
+                    break;
+            }
+        }
         return true;
     }
 
     /**
      * @brief 处理提醒界面导航
      */
-    bool ThunderBirdPresenter::HandleReminderViewNavigation(int16_t currentSubView)
+    bool ThunderBirdPresenter::HandleReminderViewNavigation(int16_t currentSubView, KeyType keyType)
     {
         switch (currentSubView) {
             case ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME:
@@ -508,7 +574,7 @@ namespace OHOS
     /**
      * @brief 处理调节界面导航
      */
-    bool ThunderBirdPresenter::HandleAdjustViewNavigation(int16_t currentSubView)
+    bool ThunderBirdPresenter::HandleAdjustViewNavigation(int16_t currentSubView, KeyType keyType)
     {
         switch (currentSubView) {
             case ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS: