From 8e678b8e692be016d0194692ee2245b1ae35fa2b Mon Sep 17 00:00:00 2001 From: "chenglei16@huawei.com" Date: Sat, 2 Aug 2025 16:59:12 +0800 Subject: [PATCH 1/2] add is_updater_mode instruction Signed-off-by: chenglei16@huawei.com --- services/updater_binary/update_processor.cpp | 10 +++++++++- services/updater_binary/update_processor.h | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/services/updater_binary/update_processor.cpp b/services/updater_binary/update_processor.cpp index e38ee4ab..dd9af1e7 100644 --- a/services/updater_binary/update_processor.cpp +++ b/services/updater_binary/update_processor.cpp @@ -83,7 +83,8 @@ const std::vector UpdaterEnv::GetInstructionNames() const static std::vector updaterCmds = { "sha_check", "first_block_check", "block_update", "raw_image_write", "update_partitions", "image_patch", - "image_sha_check", "pkg_extract", "pkg_extract_no_ret", "update_from_bin" + "image_sha_check", "pkg_extract", "pkg_extract_no_ret", "update_from_bin", + "is_updater_mode" }; return updaterCmds; } @@ -111,6 +112,8 @@ int32_t UpdaterInstructionFactory::CreateInstructionInstance(UScriptInstructionP instr = new UScriptInstructionPkgExtractRetSuc(); } else if (name == "update_from_bin") { instr = new UScriptInstructionBinFlowWrite(); + } else if (name == "is_updater_mode") { + instr = new UScriptInstructionIsUpdaterMode(); } return USCRIPT_SUCCESS; } @@ -527,4 +530,9 @@ int ProcessUpdater(bool retry, int pipeFd, const std::string &packagePath, const PkgManager::ReleasePackageInstance(pkgManager); return ret; } + +int32_t UScriptInstructionIsUpdaterMode::Execute(Uscript::UScriptEnv &env, Uscript::UScriptContext &context) +{ + return Utils::IsUpdaterMode() ? 1 : 0; +} } // Updater diff --git a/services/updater_binary/update_processor.h b/services/updater_binary/update_processor.h index a2342b58..8a5a786a 100644 --- a/services/updater_binary/update_processor.h +++ b/services/updater_binary/update_processor.h @@ -106,5 +106,12 @@ public: private: static size_t stashDataSize_; }; + +class UScriptInstructionIsUpdaterMode : public Uscript::UScriptInstruction { +public: + UScriptInstructionIsUpdaterMode() {} + virtual ~UScriptInstructionIsUpdaterMode() {} + int32_t Execute(Uscript::UScriptEnv &env, Uscript::UScriptContext &context) override; +}; } // Updater #endif /* UPDATE_PROCESSOR_H */ -- Gitee From 6aa492eb30fefe9a52e22eeb70aaf91754132ba0 Mon Sep 17 00:00:00 2001 From: "chenglei16@huawei.com" Date: Sat, 2 Aug 2025 17:28:03 +0800 Subject: [PATCH 2/2] add is_updater_mode instruction Signed-off-by: chenglei16@huawei.com --- services/updater_binary/update_processor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/updater_binary/update_processor.cpp b/services/updater_binary/update_processor.cpp index dd9af1e7..337ba0ae 100644 --- a/services/updater_binary/update_processor.cpp +++ b/services/updater_binary/update_processor.cpp @@ -533,6 +533,6 @@ int ProcessUpdater(bool retry, int pipeFd, const std::string &packagePath, const int32_t UScriptInstructionIsUpdaterMode::Execute(Uscript::UScriptEnv &env, Uscript::UScriptContext &context) { - return Utils::IsUpdaterMode() ? 1 : 0; + return Utils::IsUpdaterMode() ? USCRIPT_ERROR_EXECUTE : USCRIPT_SUCCESS; } } // Updater -- Gitee