From de620ed54ad369a63f1990d5f27395efd2dc7319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 11 Jan 2024 16:36:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=8F=90=E4=BA=A4=E9=97=AE=E9=A2=98=20Signed?= =?UTF-8?q?-off-by:=20=E9=82=B9=E5=8F=8B=E6=9D=BE=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/firmware_download_executor.h | 3 +- .../src/firmware_download_executor.cpp | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/services/firmware/upgrade/executor/include/firmware_download_executor.h b/services/firmware/upgrade/executor/include/firmware_download_executor.h index b1aaed54..d1ed58d3 100644 --- a/services/firmware/upgrade/executor/include/firmware_download_executor.h +++ b/services/firmware/upgrade/executor/include/firmware_download_executor.h @@ -24,6 +24,7 @@ namespace OHOS { namespace UpdateEngine { +const int32_t SLEEP_MILLISECONDS = 200; class FirmwareDownloadExecutor : public FirmwareIExecutor { public: FirmwareDownloadExecutor(const DownloadOptions &downloadOptions, FirmwareProgressCallback progressCallback) @@ -37,7 +38,7 @@ private: void PerformDownload(); void DownloadCallback(std::string serverUrl, std::string packageName, Progress progress); bool VerifyDownloadPkg(const std::string &pkgName, Progress &progress); - + std::string GenerateDownloadTaskId(); private: DownloadOptions downloadOptions_; std::vector components_; diff --git a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp index 9ac08cd3..f95d9109 100644 --- a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp @@ -56,6 +56,21 @@ void FirmwareDownloadExecutor::DoDownload() GetTask(); if (tasks_.downloadTaskId.empty()) { // 首次触发下载 + std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MILLISECONDS)); + GetTask(); + FIRMWARE_LOGI("FirmwareDownloadExecutor StartDownload"); + if (tasks_.downloadTaskId.empty()) { + std::string downloadTaskId = GenerateDownloadTaskId(); + FIRMWARE_LOGI("DoDownload: %{public}s", downloadTaskId.c_str()); + FirmwareTaskOperator().UpdateDownloadTaskIdByTaskId(tasks_.taskId, downloadTaskId); + } else { + FIRMWARE_LOGI("DoDownload Repeat subcommit"); + Progress progress; + progress.status = UpgradeStatus::DOWNLOADING; + progress.endReason = "not perrmit repeat submmit"; + firmwareProgressCallback_.progressCallback(progress); + return; + } PerformDownload(); } else { // 恢复下载 @@ -175,5 +190,21 @@ bool FirmwareDownloadExecutor::VerifyDownloadPkg(const std::string &pkgName, Pro } return true; } + +std::string FirmwareDownloadExecutor::GenerateDownloadTaskId() +{ + std::vector downloadInfos; + std::vector components; + FirmwareComponentOperator().QueryAll(components); + for (auto component : components) { + downloadInfos.push_back(component.descriptPackageId); + } + sort(downloadInfos.begin(), downloadInfos.end()); + std::string srcString; + for (auto downloadInfo : downloadInfos) { + srcString += downloadInfo; + } + return Sha256Utils::CalculateHashCode(srcString); +} } // namespace UpdateEngine } // namespace OHOS -- Gitee From 4bb7da84feb8bac6c8928791d25bc1be9df0e57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 11 Jan 2024 08:39:17 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=8F=90=E4=BA=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- .../upgrade/executor/include/firmware_download_executor.h | 2 +- .../upgrade/executor/src/firmware_download_executor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/firmware/upgrade/executor/include/firmware_download_executor.h b/services/firmware/upgrade/executor/include/firmware_download_executor.h index d1ed58d3..c6cea43b 100644 --- a/services/firmware/upgrade/executor/include/firmware_download_executor.h +++ b/services/firmware/upgrade/executor/include/firmware_download_executor.h @@ -24,7 +24,7 @@ namespace OHOS { namespace UpdateEngine { -const int32_t SLEEP_MILLISECONDS = 200; +const int32_t DOWNLOAD_SLEEP_MILLISECONDS = 200; class FirmwareDownloadExecutor : public FirmwareIExecutor { public: FirmwareDownloadExecutor(const DownloadOptions &downloadOptions, FirmwareProgressCallback progressCallback) diff --git a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp index f95d9109..79d2a022 100644 --- a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp @@ -56,7 +56,7 @@ void FirmwareDownloadExecutor::DoDownload() GetTask(); if (tasks_.downloadTaskId.empty()) { // 首次触发下载 - std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MILLISECONDS)); + std::this_thread::sleep_for(std::chrono::milliseconds(DOWNLOAD_SLEEP_MILLISECONDS)); GetTask(); FIRMWARE_LOGI("FirmwareDownloadExecutor StartDownload"); if (tasks_.downloadTaskId.empty()) { -- Gitee