diff --git a/services/applypatch/block_set.cpp b/services/applypatch/block_set.cpp index 9a3c391152e0410a68b95c7450cf99c4c23d951b..b49614d7bb85782bd226586cef2a2691e3fc1b0b 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 bcbf30f7f687a3c32cdb326943c50a2a07cfc69d..6c7c09832dad9bd18cadca81ae5458a0f7af769b 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" @@ -191,6 +192,19 @@ bool IsMountDataAndSaveLogs(void) return (!(isSdCardMode || isUsbMode) && (isDataAlreadyMounted || !isLogMounted)) || isSdCardIntralMode; } +static void 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"; @@ -204,16 +218,8 @@ void PostUpdater(bool clearMisc) if (!access(COMMAND_FILE, 0) && unlink(COMMAND_FILE) != 0) { LOG(ERROR) << "Delete command failed"; } - - // 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(); diff --git a/test/unittest/flashd_test/BUILD.gn b/test/unittest/flashd_test/BUILD.gn index 6fb16a940051ed37e452c73618aa440c1da430e4..87c0fd02944286128098e459c3e9354d8a857127 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", ]