From: xue <2144439972@qq.com> Date: Fri, 17 Oct 2025 09:59:32 +0000 (+0800) Subject: 优化下载被OTA打断的逻辑 X-Git-Tag: V1.0.9_20251128_194606_LN~208^2~2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a030224c62255768a6f7bf1e141923247a4ffb98;p=mirrors%2FFD230.git 优化下载被OTA打断的逻辑 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp index e9dc58eb2..6dd27704e 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp @@ -36,7 +36,8 @@ namespace OHOS UIViewGroup* OtaCountdownView::InitUI() { - OtaModel::GetInstance()->StartCountdownTimer(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaCountdownView::InitUI"); + OtaModel::GetInstance()->StartCountdownTimer(5); // 创建主容器 group = new UIViewGroup(); if (group) { diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp index 92575aa82..f45b09699 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp @@ -159,6 +159,11 @@ namespace OHOS else if (currentView == OtaView::OTA_VIEW_UPDATE_FAILED) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "升级失败界面重试"); OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_FAILED, OtaView::OTA_VIEW_COUNTDOWN); + OtaModel::GetInstance()->StartCountdownTimer(5); + if(OtaCountdownView::GetInstance()) + { + OtaCountdownView::GetInstance()->UpdateCountdown(5); + } } break; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp index 00d04305e..0b331ee68 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp @@ -6,6 +6,7 @@ #include "ota/include/OtaSuccessView.h" #include "ota/include/OtaPresenter.h" #include "wearable_log.h" +#include "thunderbird/include/ThunderBirdModel.h" namespace OHOS @@ -121,11 +122,12 @@ namespace OHOS void OtaSuccessView::UpdateDownloadSuccess(std::string content) { + //已完成下载 + ThunderBirdModel::GetInstance()->ClearDownloadFile(); if(content == "下载失败") { RemindIcon1->SetSrc("/user/res/warning.bin"); - RemindIcon->SetVisible(false); - RemindLabel->SetVisible(false); + RemindLabel->SetText("按 退出"); TextLabel->SetText(content.c_str()); LittleTextLabel->SetText("请在小程序重新下载\n继续下载失败的文件"); LittleTextLabel->SetX(98); @@ -133,7 +135,6 @@ namespace OHOS LittleTextLabel->Invalidate(); RemindLabel->Invalidate(); RemindIcon1->Invalidate(); - RemindIcon->Invalidate(); return; } TextLabel->SetText(content.c_str()); 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 0f68f457d..c98c0eaef 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 @@ -202,7 +202,8 @@ namespace OHOS void HandleDownloadFile(int type); // 获取文件下载类型 int GetDownloadFile(); - + // 清空下载文件类型 + void ClearDownloadFile(); // 表情切换函数 bool SwitchExpression(const char* eyeShape, const char* eyeColor); @@ -242,6 +243,9 @@ namespace OHOS void DequeueAndPushAudioText(); bool HasAudioTextInQueue(); void ClearAudioTextQueue(); + + // 夜间更新处理 + void HandleNightUpdate(); // 对话状态显示相关函数 void SetCurrentExpression(const std::string& expression); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp index 8965e820b..9ce3c62f8 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp @@ -261,6 +261,13 @@ namespace OHOS } void ThunderBirdMainView::OnStart()//开机操作 { + + //下载文件被打断的恢复操作 + if(ThunderBirdModel::GetInstance()->GetDownloadFile() != -1) + { + ThunderBirdModel::GetInstance()->HandleDownloadFile(ThunderBirdModel::GetInstance()->GetDownloadFile()); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::OnStart"); View::OnStart(); GetRootContainer()->SetTouchable(true); @@ -330,17 +337,11 @@ namespace OHOS else if(ThunderBirdModel::GetInstance()->StartBootOperation() == 1) { ChangeView(MAXVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW); - //ChangeView(MAXVIEW, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4); } } ScrollView_->Add(InitBaseData()); // 最上面状态栏 - - - // // 增加按键监听 - // RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::ThunderBirdPresenter::GetInstance(); - // RootView::GetInstance()->SetOnKeyActListener(keyactListener); } } @@ -771,7 +772,15 @@ namespace OHOS if (videoPlay_->isExited_ || !videoPlay_->isEntered_) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::Initback videoPlay_->StartVideoPlay"); - videoPlay_->StartVideoPlay(); + // 添加状态检查,避免重复启动 + if (!videoPlay_->isPlayed_) { + int32_t ret = videoPlay_->StartVideoPlay(); + if (ret != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::Initback StartVideoPlay failed, ret=%d", ret); + } + } else { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::Initback videoPlay_ already playing, skipping StartVideoPlay"); + } } ScrollView_->Add(surfaceView_); @@ -824,9 +833,12 @@ namespace OHOS return false; } IsOpenScreenImageModel_ = true; - //暂停视频播放 - if (videoPlay_ != nullptr) { + //暂停视频播放 - 添加状态检查,避免在视频未初始化时调用 + if (videoPlay_ != nullptr && videoPlay_->isEntered_ && videoPlay_->isPlayed_) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::OpenScreenImageModel: Pausing video play"); videoPlay_->PauseVideoPlay(); + } else { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::OpenScreenImageModel: Video not ready for pause, skipping"); } //切换屏保图片 SwitchIconImage(LN_DEVICE_SCREEN_IMAGE_FILE); @@ -844,9 +856,12 @@ namespace OHOS return false; } IsOpenScreenImageModel_ = false; - //恢复视频播放 - if (videoPlay_ != nullptr) { + //恢复视频播放 - 添加状态检查,避免在视频未初始化时调用 + if (videoPlay_ != nullptr && videoPlay_->isEntered_ && videoPlay_->isPause_) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::CloseScreenImageModel: Resuming video play"); videoPlay_->ResumeVideoPlay(); + } else { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::CloseScreenImageModel: Video not ready for resume, skipping"); } //恢复默认屏保图片 SwitchIconImage("/user/res/1.bin");