完善OTA流程
authorxue <2144439972@qq.com>
Fri, 19 Sep 2025 08:33:39 +0000 (16:33 +0800)
committerxue <2144439972@qq.com>
Fri, 19 Sep 2025 08:33:39 +0000 (16:33 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdDialogueView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.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/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp

index 7c00ae3..7cbc5b9 100644 (file)
@@ -34,7 +34,11 @@ namespace OHOS
         int ota_update_boot();
         // 恢复出厂设置相关函数
         void restore_factory_settings();
-        
+        // OTA升级进度
+        void UpdateOtaProgress(int progress);
+        // OTA升级状态
+        void UpdateOtaStatus(int status);   
+        int GetOtaStatus();
      // 新手引导相关函数
      enum class BindingStatus {
         BOUND = 0,      // 已绑定
@@ -116,6 +120,8 @@ namespace OHOS
         std::vector<ReminderData> m_reminders;
         uint32_t m_nextReminderId;
         std::string m_currentTimeStr;
+        // OTA升级状态
+        int m_otaStatus;
     };
 }
 
index 3c56fde..ee0ee18 100644 (file)
@@ -121,6 +121,8 @@ namespace OHOS
             TextLabel_Y->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             TextLabel_Y->SetStyle(STYLE_TEXT_COLOR, 0xff000000);
             TextLabel_Y->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            TextLabel_Y->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); 
+            TextLabel_Y->SetRollSpeed(35);
             TextLabel_Y->SetVisible(false);
             group->Add(TextLabel_Y);
         }
index ae4cfcd..562b193 100644 (file)
@@ -977,7 +977,7 @@ namespace OHOS
 #ifdef SUPPORT_BATTERY_SERVICE
         Batteryvalue = battery_get_voltage(&voltage);
 #endif
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", Batteryvalue);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", Batteryvalue);
         if (batteryLabel)
         {
             batteryLabel->SetText((std::to_string(static_cast<int>(Batteryvalue))).c_str()); // 电量
@@ -995,7 +995,7 @@ namespace OHOS
         bool isCharging = false;
 #ifdef SUPPORT_BATTERY_SERVICE
         isCharging = get_charge_stat(); // 获取充电状态
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "isCharging = %d", isCharging);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "isCharging = %d", isCharging);
 #endif
 
         // 充电流程:进入充电显示“充电中”(一次),满电显示“充电完成”(一次)
@@ -1025,7 +1025,7 @@ namespace OHOS
                         g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGING);
                     }
 
-                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView_, currentSubView_);
+                    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView_, currentSubView_);
                     
                 }
 
index 4a99e4d..9ddc252 100644 (file)
          //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_CHARACTER, nullptr, 0);//获取角色配置
          return -1;
      }
-         
+
+     /*************************OTA升级*************************/
      int ThunderBirdModel::ota_update_boot()
      {
-         /*************************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升级
           {
          return -1;
      }
 
+     /*************************OTA升级进度*************************/
+     void ThunderBirdModel::UpdateOtaProgress(int progress)
+     {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::UpdateOtaProgress: %d", progress);
+        if(ThunderBirdOtaView::GetInstance())
+        {
+            ThunderBirdOtaView::GetInstance()->SetRemindProgress(progress);
+        }
+     }
+
+     /*************************OTA升级状态*************************/
+     void ThunderBirdModel::UpdateOtaStatus(int status)
+     {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::UpdateOtaStatus: %d", status);
+        m_otaStatus = status;
+     }
+     /*************************获取OTA升级状态*************************/
+     int ThunderBirdModel::GetOtaStatus()
+     {
+        return m_otaStatus;
+     }
+     
+
      // ==================== 恢复出厂设置相关函数 ====================
      void ThunderBirdModel::restore_factory_settings()
      {
          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;
          }
index 670627a..2ac068b 100644 (file)
@@ -607,11 +607,9 @@ namespace OHOS
         {
             return;
         }
-        int newVal = remindProgressValue_ + value;
-        if (newVal < 0) { newVal = 0; }
-        if (newVal > 100) { newVal = 100; }
-        remindProgressValue_ = newVal;
-        VolumeProgress->SetValue(remindProgressValue_);
+        if (value < 0) { value = 0; }
+        if (value > 100) { value = 100;} 
+        VolumeProgress->SetValue(value);
         VolumeProgress->Invalidate();
     }
 }
index 3648107..9bbd2d6 100644 (file)
@@ -29,15 +29,21 @@ int get_start_conversation_flag(void)
     return g_start_conversation_flag;
 }
 
+// 获取OTA升级完状态
 void push_ota_status(int status)
 {
     printf("push_ota_status: %d\n", status);
+    OHOS::ThunderBirdModel::GetInstance()->UpdateOtaStatus(status);
 }
 
+// 获取OTA升级进度
 void push_ota_progress(int progress)
 {
+    printf("push_ota_progress: %d\n", progress);
+    OHOS::ThunderBirdModel::GetInstance()->UpdateOtaProgress(progress);
 }
 
+// 恢复出厂设置
 void do_restore_factory_setting(void)
 {
     printf("do_restore_factory_setting\n");