From 859268625de68e34c87558701247b87c7a2d2538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BD=B3=E6=A0=8B?= Date: Tue, 14 Jan 2025 11:15:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?Signed-off-by:=20=E7=8E=8B=E4=BD=B3?= =?UTF-8?q?=E6=A0=8B=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add log --- services/applypatch/block_set.cpp | 4 ++++ services/updater_utils.cpp | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/services/applypatch/block_set.cpp b/services/applypatch/block_set.cpp index 9a3c3911..b49614d7 100644 --- a/services/applypatch/block_set.cpp +++ b/services/applypatch/block_set.cpp @@ -23,6 +23,7 @@ #include "applypatch/command.h" #include "applypatch/store.h" #include "applypatch/transfer_manager.h" +#include "log/dump.h" #include "log/log.h" #include "patch/update_patch.h" #include "securec.h" @@ -207,12 +208,15 @@ size_t BlockSet::TotalBlockSize() const int32_t BlockSet::VerifySha256(const std::vector &buffer, const size_t size, const std::string &expected) { + UPDATER_INIT_RECORD; uint8_t digest[SHA256_DIGEST_LENGTH]; SHA256(buffer.data(), size * H_BLOCK_SIZE, digest); std::string hexdigest = Utils::ConvertSha256Hex(digest, SHA256_DIGEST_LENGTH); if (hexdigest == expected) { return 0; } + LOG(ERROR) << "hexdigest is " << hexdigest << ", expected is " << expected; + UPDATER_LAST_WORD(hexdigest, expected); return -1; } diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index bcbf30f7..57041dab 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -26,6 +26,7 @@ #include "misc_info/misc_info.h" #include "package/pkg_manager.h" #include "securec.h" +#include "updater/hwfault_retry.h" #include "updater/updater.h" #include "updater/updater_const.h" #include "updater_main.h" @@ -204,6 +205,12 @@ void PostUpdater(bool clearMisc) if (!access(COMMAND_FILE, 0) && unlink(COMMAND_FILE) != 0) { LOG(ERROR) << "Delete command failed"; } + if (HwFaultRetry::GetInstance().IsRetry()) { + if (isMountDataAndSaveLogs) { + SaveLogs(); + } + return; + } // delete updater tmp files if (access(UPDATER_PATH, 0) == 0 && access(SDCARD_CARD_PATH, 0) != 0 && !DeleteUpdaterPath(UPDATER_PATH)) { -- Gitee From 13bd192028b3770634a27bdccb5ba809e34bd877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BD=B3=E6=A0=8B?= Date: Tue, 14 Jan 2025 05:48:15 +0000 Subject: [PATCH 2/4] update test/unittest/flashd_test/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王佳栋 --- test/unittest/flashd_test/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unittest/flashd_test/BUILD.gn b/test/unittest/flashd_test/BUILD.gn index 6fb16a94..87c0fd02 100644 --- a/test/unittest/flashd_test/BUILD.gn +++ b/test/unittest/flashd_test/BUILD.gn @@ -62,6 +62,7 @@ ohos_unittest("flashd_unittest") { "${updater_path}/services/flashd/partition.cpp", "${updater_path}/services/hdi/client/update_hdi_client.cpp", "${updater_path}/services/hdi/server/update_hdi_impl.cpp", + "${updater_path}/services/hwfault_retry/hwfault_retry.cpp", "${updater_path}/services/updater_utils.cpp", "flashd_unittest.cpp", ] -- Gitee From a9a27801289a2f38bdd8363149a514e13ab18ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BD=B3=E6=A0=8B?= Date: Tue, 14 Jan 2025 17:06:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?Signed-off-by:=20=E7=8E=8B=E4=BD=B3?= =?UTF-8?q?=E6=A0=8B=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix --- services/updater_utils.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index 57041dab..a42bae70 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -192,6 +192,19 @@ bool IsMountDataAndSaveLogs(void) return (!(isSdCardMode || isUsbMode) && (isDataAlreadyMounted || !isLogMounted)) || isSdCardIntralMode; } +static DeleteUpdaterTmpFiles() +{ + if (access(UPDATER_PATH, 0) == 0 && access(SDCARD_CARD_PATH, 0) != 0 && !DeleteUpdaterPath(UPDATER_PATH)) { + LOG(ERROR) << "DeleteUpdaterPath failed"; + } + if (access(SDCARD_CARD_PATH, 0) == 0 && !DeleteUpdaterPath(SDCARD_CARD_PATH)) { + LOG(ERROR) << "Delete sdcard path failed"; + } + if (access(Flashd::FLASHD_FILE_PATH, 0) == 0 && !DeleteUpdaterPath(Flashd::FLASHD_FILE_PATH)) { + LOG(ERROR) << "DeleteUpdaterPath failed"; + } +} + void PostUpdater(bool clearMisc) { STAGE(UPDATE_STAGE_BEGIN) << "PostUpdater"; @@ -205,22 +218,8 @@ void PostUpdater(bool clearMisc) if (!access(COMMAND_FILE, 0) && unlink(COMMAND_FILE) != 0) { LOG(ERROR) << "Delete command failed"; } - if (HwFaultRetry::GetInstance().IsRetry()) { - if (isMountDataAndSaveLogs) { - SaveLogs(); - } - return; - } - - // delete updater tmp files - if (access(UPDATER_PATH, 0) == 0 && access(SDCARD_CARD_PATH, 0) != 0 && !DeleteUpdaterPath(UPDATER_PATH)) { - LOG(ERROR) << "DeleteUpdaterPath failed"; - } - if (access(SDCARD_CARD_PATH, 0) == 0 && !DeleteUpdaterPath(SDCARD_CARD_PATH)) { - LOG(ERROR) << "Delete sdcard path failed"; - } - if (access(Flashd::FLASHD_FILE_PATH, 0) == 0 && !DeleteUpdaterPath(Flashd::FLASHD_FILE_PATH)) { - LOG(ERROR) << "DeleteUpdaterPath failed"; + if (!HwFaultRetry::GetInstance().IsRetry()) { + DeleteUpdaterTmpFiles(); } if (isMountDataAndSaveLogs) { SaveLogs(); -- Gitee From 8315b6b5a1ee8cc0be06a6dddd72e14a674467fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BD=B3=E6=A0=8B?= Date: Tue, 14 Jan 2025 09:18:28 +0000 Subject: [PATCH 4/4] update services/updater_utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王佳栋 --- services/updater_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/updater_utils.cpp b/services/updater_utils.cpp index a42bae70..6c7c0983 100755 --- a/services/updater_utils.cpp +++ b/services/updater_utils.cpp @@ -192,7 +192,7 @@ bool IsMountDataAndSaveLogs(void) return (!(isSdCardMode || isUsbMode) && (isDataAlreadyMounted || !isLogMounted)) || isSdCardIntralMode; } -static DeleteUpdaterTmpFiles() +static void DeleteUpdaterTmpFiles() { if (access(UPDATER_PATH, 0) == 0 && access(SDCARD_CARD_PATH, 0) != 0 && !DeleteUpdaterPath(UPDATER_PATH)) { LOG(ERROR) << "DeleteUpdaterPath failed"; -- Gitee