1fb299fa2Sopenharmony_ci/*
2fb299fa2Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3fb299fa2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fb299fa2Sopenharmony_ci * you may not use this file except in compliance with the License.
5fb299fa2Sopenharmony_ci * You may obtain a copy of the License at
6fb299fa2Sopenharmony_ci *
7fb299fa2Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8fb299fa2Sopenharmony_ci *
9fb299fa2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fb299fa2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fb299fa2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fb299fa2Sopenharmony_ci * See the License for the specific language governing permissions and
13fb299fa2Sopenharmony_ci * limitations under the License.
14fb299fa2Sopenharmony_ci */
15fb299fa2Sopenharmony_ci#include "update_image_patch.h"
16fb299fa2Sopenharmony_ci#include <cerrno>
17fb299fa2Sopenharmony_ci#include <fcntl.h>
18fb299fa2Sopenharmony_ci#include <pthread.h>
19fb299fa2Sopenharmony_ci#include <sstream>
20fb299fa2Sopenharmony_ci#include <sys/mman.h>
21fb299fa2Sopenharmony_ci#include <sys/stat.h>
22fb299fa2Sopenharmony_ci#include <sys/types.h>
23fb299fa2Sopenharmony_ci#include <unistd.h>
24fb299fa2Sopenharmony_ci#include <memory>
25fb299fa2Sopenharmony_ci#include <vector>
26fb299fa2Sopenharmony_ci#include "applypatch/block_set.h"
27fb299fa2Sopenharmony_ci#include "applypatch/store.h"
28fb299fa2Sopenharmony_ci#include "applypatch/transfer_manager.h"
29fb299fa2Sopenharmony_ci#include "applypatch/partition_record.h"
30fb299fa2Sopenharmony_ci#include "diffpatch/diffpatch.h"
31fb299fa2Sopenharmony_ci#include "dump.h"
32fb299fa2Sopenharmony_ci#include "fs_manager/mount.h"
33fb299fa2Sopenharmony_ci#include "log/log.h"
34fb299fa2Sopenharmony_ci#include "patch/update_patch.h"
35fb299fa2Sopenharmony_ci#include "updater/updater_const.h"
36fb299fa2Sopenharmony_ci#include "updater/hwfault_retry.h"
37fb299fa2Sopenharmony_ci#include "utils.h"
38fb299fa2Sopenharmony_ci
39fb299fa2Sopenharmony_ciusing namespace Uscript;
40fb299fa2Sopenharmony_ciusing namespace Hpackage;
41fb299fa2Sopenharmony_ciusing namespace Updater;
42fb299fa2Sopenharmony_ci
43fb299fa2Sopenharmony_cinamespace Updater {
44fb299fa2Sopenharmony_ciconstexpr uint32_t IMAGE_PATCH_CMD_LEN = 6;
45fb299fa2Sopenharmony_ciconstexpr uint32_t IMAGE_PATCH_CHECK_CMD_LEN = 5;
46fb299fa2Sopenharmony_ci
47fb299fa2Sopenharmony_ciint32_t USInstrImagePatch::Execute(Uscript::UScriptEnv &env, Uscript::UScriptContext &context)
48fb299fa2Sopenharmony_ci{
49fb299fa2Sopenharmony_ci    int32_t result = ExecuteImagePatch(env, context);
50fb299fa2Sopenharmony_ci    context.PushParam(result);
51fb299fa2Sopenharmony_ci    return result;
52fb299fa2Sopenharmony_ci}
53fb299fa2Sopenharmony_ci
54fb299fa2Sopenharmony_ciint32_t USInstrImagePatch::GetParam(Uscript::UScriptContext &context, ImagePatchPara &para)
55fb299fa2Sopenharmony_ci{
56fb299fa2Sopenharmony_ci    if (context.GetParamCount() != IMAGE_PATCH_CMD_LEN) {
57fb299fa2Sopenharmony_ci        LOG(ERROR) << "para count error " << context.GetParamCount();
58fb299fa2Sopenharmony_ci        return USCRIPT_INVALID_PARAM;
59fb299fa2Sopenharmony_ci    }
60fb299fa2Sopenharmony_ci
61fb299fa2Sopenharmony_ci    int index = 0;
62fb299fa2Sopenharmony_ci    uint32_t ret = static_cast<uint32_t>(context.GetParam(index++, para.partName));
63fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.srcSize));
64fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.srcHash));
65fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.destSize));
66fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.destHash));
67fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.patchFile));
68fb299fa2Sopenharmony_ci    if (ret != USCRIPT_SUCCESS) {
69fb299fa2Sopenharmony_ci        LOG(ERROR) << "para get error";
70fb299fa2Sopenharmony_ci        return USCRIPT_INVALID_PARAM;
71fb299fa2Sopenharmony_ci    }
72fb299fa2Sopenharmony_ci    para.devPath = GetBlockDeviceByMountPoint(para.partName);
73fb299fa2Sopenharmony_ci    if (para.devPath.empty()) {
74fb299fa2Sopenharmony_ci        LOG(ERROR) << "get " << para.partName << " dev path error";
75fb299fa2Sopenharmony_ci        return USCRIPT_ERROR_EXECUTE;
76fb299fa2Sopenharmony_ci    }
77fb299fa2Sopenharmony_ci    return USCRIPT_SUCCESS;
78fb299fa2Sopenharmony_ci}
79fb299fa2Sopenharmony_ci
80fb299fa2Sopenharmony_cistd::string USInstrImagePatch::GetFileHash(const std::string &file)
81fb299fa2Sopenharmony_ci{
82fb299fa2Sopenharmony_ci    UpdatePatch::MemMapInfo mapBuffer {};
83fb299fa2Sopenharmony_ci    if (PatchMapFile(file, mapBuffer) != UpdatePatch::PATCH_SUCCESS) {
84fb299fa2Sopenharmony_ci        LOG(ERROR) << "PatchMapFile error";
85fb299fa2Sopenharmony_ci        return "";
86fb299fa2Sopenharmony_ci    }
87fb299fa2Sopenharmony_ci    UpdatePatch::BlockBuffer data = { mapBuffer.memory, mapBuffer.length };
88fb299fa2Sopenharmony_ci    std::string resultSha = UpdatePatch::GeneraterBufferHash(data);
89fb299fa2Sopenharmony_ci    std::transform(resultSha.begin(), resultSha.end(), resultSha.begin(), ::toupper);
90fb299fa2Sopenharmony_ci    return resultSha;
91fb299fa2Sopenharmony_ci}
92fb299fa2Sopenharmony_ci
93fb299fa2Sopenharmony_ciint32_t USInstrImagePatch::ApplyPatch(const ImagePatchPara &para, const UpdatePatch::MemMapInfo &srcData,
94fb299fa2Sopenharmony_ci    const PkgBuffer &patchData)
95fb299fa2Sopenharmony_ci{
96fb299fa2Sopenharmony_ci    std::vector<uint8_t> empty;
97fb299fa2Sopenharmony_ci    UpdatePatch::PatchParam patchParam = {
98fb299fa2Sopenharmony_ci        srcData.memory, srcData.length, patchData.buffer, patchData.length
99fb299fa2Sopenharmony_ci    };
100fb299fa2Sopenharmony_ci    std::unique_ptr<DataWriter> writer = DataWriter::CreateDataWriter(WRITE_RAW, para.devPath);
101fb299fa2Sopenharmony_ci    if (writer.get() == nullptr) {
102fb299fa2Sopenharmony_ci        LOG(ERROR) << "Cannot create block writer, pkgdiff patch abort!";
103fb299fa2Sopenharmony_ci        return -1;
104fb299fa2Sopenharmony_ci    }
105fb299fa2Sopenharmony_ci    std::string resultSha = para.destHash;
106fb299fa2Sopenharmony_ci    std::transform(resultSha.begin(), resultSha.end(), resultSha.begin(), ::tolower);
107fb299fa2Sopenharmony_ci    int32_t ret = UpdatePatch::UpdateApplyPatch::ApplyImagePatch(patchParam, empty,
108fb299fa2Sopenharmony_ci        [&](size_t start, const UpdatePatch::BlockBuffer &data, size_t size) -> int {
109fb299fa2Sopenharmony_ci            return (writer->Write(data.buffer, size, nullptr)) ? 0 : -1;
110fb299fa2Sopenharmony_ci        }, resultSha);
111fb299fa2Sopenharmony_ci    writer.reset();
112fb299fa2Sopenharmony_ci    if (ret != 0) {
113fb299fa2Sopenharmony_ci        LOG(ERROR) << "Fail to ApplyImagePatch";
114fb299fa2Sopenharmony_ci        return -1;
115fb299fa2Sopenharmony_ci    }
116fb299fa2Sopenharmony_ci    return USCRIPT_SUCCESS;
117fb299fa2Sopenharmony_ci}
118fb299fa2Sopenharmony_ci
119fb299fa2Sopenharmony_ciint32_t USInstrImagePatch::CreatePatchStream(Uscript::UScriptEnv &env, const ImagePatchPara &para,
120fb299fa2Sopenharmony_ci    PkgManager::StreamPtr &patchStream)
121fb299fa2Sopenharmony_ci{
122fb299fa2Sopenharmony_ci    if (env.GetPkgManager() == nullptr) {
123fb299fa2Sopenharmony_ci        LOG(ERROR) << "Error to get pkg manager";
124fb299fa2Sopenharmony_ci        return -1;
125fb299fa2Sopenharmony_ci    }
126fb299fa2Sopenharmony_ci
127fb299fa2Sopenharmony_ci    std::string patchName = para.patchFile;
128fb299fa2Sopenharmony_ci    const FileInfo *info = env.GetPkgManager()->GetFileInfo(patchName);
129fb299fa2Sopenharmony_ci    if (info == nullptr) {
130fb299fa2Sopenharmony_ci        LOG(WARNING) << "Error to get file info " << para.patchFile; // 兼容旧升级包
131fb299fa2Sopenharmony_ci        patchName = para.partName;
132fb299fa2Sopenharmony_ci        info = env.GetPkgManager()->GetFileInfo(patchName);
133fb299fa2Sopenharmony_ci        if (info == nullptr) {
134fb299fa2Sopenharmony_ci            return -1;
135fb299fa2Sopenharmony_ci        }
136fb299fa2Sopenharmony_ci    }
137fb299fa2Sopenharmony_ci
138fb299fa2Sopenharmony_ci    std::string patchFile = UPDATER_PATH + para.patchFile;
139fb299fa2Sopenharmony_ci    int32_t ret = env.GetPkgManager()->CreatePkgStream(patchStream,
140fb299fa2Sopenharmony_ci        patchFile, info->unpackedSize, PkgStream::PkgStreamType_MemoryMap);
141fb299fa2Sopenharmony_ci    if (ret != PKG_SUCCESS || patchStream == nullptr) {
142fb299fa2Sopenharmony_ci        LOG(ERROR) << "Error to create output stream";
143fb299fa2Sopenharmony_ci        return -1;
144fb299fa2Sopenharmony_ci    }
145fb299fa2Sopenharmony_ci
146fb299fa2Sopenharmony_ci    ret = env.GetPkgManager()->ExtractFile(patchName, patchStream);
147fb299fa2Sopenharmony_ci    if (ret != PKG_SUCCESS) {
148fb299fa2Sopenharmony_ci        env.GetPkgManager()->ClosePkgStream(patchStream);
149fb299fa2Sopenharmony_ci        LOG(ERROR) << "Error to extract file " << para.patchFile;
150fb299fa2Sopenharmony_ci        return -1;
151fb299fa2Sopenharmony_ci    }
152fb299fa2Sopenharmony_ci
153fb299fa2Sopenharmony_ci    LOG(INFO) << "USInstrImagePatch::CreatePatchStream " << para.partName;
154fb299fa2Sopenharmony_ci    return USCRIPT_SUCCESS;
155fb299fa2Sopenharmony_ci}
156fb299fa2Sopenharmony_ci
157fb299fa2Sopenharmony_cistd::string USInstrImagePatch::GetSourceFile(const ImagePatchPara &para)
158fb299fa2Sopenharmony_ci{
159fb299fa2Sopenharmony_ci    // Back up partitions to prevent power failures during the upgrade.
160fb299fa2Sopenharmony_ci    std::string srcFile = UPDATER_PATH + para.partName + ".backup";
161fb299fa2Sopenharmony_ci
162fb299fa2Sopenharmony_ci    if (access(srcFile.c_str(), F_OK) == 0 && GetFileHash(srcFile) != para.srcHash) {
163fb299fa2Sopenharmony_ci        LOG(INFO) << "using backup file:" << srcFile;
164fb299fa2Sopenharmony_ci        return srcFile;
165fb299fa2Sopenharmony_ci    }
166fb299fa2Sopenharmony_ci
167fb299fa2Sopenharmony_ci    if (!Utils::CopyFile(para.devPath, srcFile)) {
168fb299fa2Sopenharmony_ci        LOG(ERROR) << "copy " << para.devPath << " to " << srcFile << " failed";
169fb299fa2Sopenharmony_ci        return "";
170fb299fa2Sopenharmony_ci    }
171fb299fa2Sopenharmony_ci    return srcFile;
172fb299fa2Sopenharmony_ci}
173fb299fa2Sopenharmony_ci
174fb299fa2Sopenharmony_ciint32_t USInstrImagePatch::ExecuteImagePatch(Uscript::UScriptEnv &env, Uscript::UScriptContext &context)
175fb299fa2Sopenharmony_ci{
176fb299fa2Sopenharmony_ci    ImagePatchPara para {};
177fb299fa2Sopenharmony_ci    int32_t ret = GetParam(context, para);
178fb299fa2Sopenharmony_ci    if (ret != USCRIPT_SUCCESS) {
179fb299fa2Sopenharmony_ci        UPDATER_LAST_WORD(ret);
180fb299fa2Sopenharmony_ci        LOG(ERROR) << "GetParam error";
181fb299fa2Sopenharmony_ci        return ret;
182fb299fa2Sopenharmony_ci    }
183fb299fa2Sopenharmony_ci
184fb299fa2Sopenharmony_ci    if (env.IsRetry()) {
185fb299fa2Sopenharmony_ci        LOG(DEBUG) << "Retry updater, check if current partition updatered already during last time";
186fb299fa2Sopenharmony_ci        if (PartitionRecord::GetInstance().IsPartitionUpdated(para.partName)) {
187fb299fa2Sopenharmony_ci            LOG(INFO) << para.partName << " already updated, skip";
188fb299fa2Sopenharmony_ci            return USCRIPT_SUCCESS;
189fb299fa2Sopenharmony_ci        }
190fb299fa2Sopenharmony_ci    }
191fb299fa2Sopenharmony_ci
192fb299fa2Sopenharmony_ci    std::string srcFile = GetSourceFile(para);
193fb299fa2Sopenharmony_ci    if (srcFile.empty()) {
194fb299fa2Sopenharmony_ci        UPDATER_LAST_WORD(USCRIPT_ERROR_EXECUTE);
195fb299fa2Sopenharmony_ci        LOG(ERROR) << "get source file error";
196fb299fa2Sopenharmony_ci        return USCRIPT_ERROR_EXECUTE;
197fb299fa2Sopenharmony_ci    }
198fb299fa2Sopenharmony_ci    UpdatePatch::MemMapInfo srcData {};
199fb299fa2Sopenharmony_ci    ret = UpdatePatch::PatchMapFile(srcFile, srcData);
200fb299fa2Sopenharmony_ci    if (ret != 0) {
201fb299fa2Sopenharmony_ci        UPDATER_LAST_WORD(ret);
202fb299fa2Sopenharmony_ci        LOG(ERROR) << "Failed to mmap src file error:" << ret;
203fb299fa2Sopenharmony_ci        return -1;
204fb299fa2Sopenharmony_ci    }
205fb299fa2Sopenharmony_ci
206fb299fa2Sopenharmony_ci    PkgManager::StreamPtr patchStream = nullptr;
207fb299fa2Sopenharmony_ci    ret = CreatePatchStream(env, para, patchStream);
208fb299fa2Sopenharmony_ci    if (ret != USCRIPT_SUCCESS) {
209fb299fa2Sopenharmony_ci        UPDATER_LAST_WORD(USCRIPT_ERROR_EXECUTE);
210fb299fa2Sopenharmony_ci        LOG(ERROR) << "CreatePatchStream error";
211fb299fa2Sopenharmony_ci        return USCRIPT_ERROR_EXECUTE;
212fb299fa2Sopenharmony_ci    }
213fb299fa2Sopenharmony_ci    PkgBuffer patchData = {};
214fb299fa2Sopenharmony_ci    patchStream->GetBuffer(patchData);
215fb299fa2Sopenharmony_ci
216fb299fa2Sopenharmony_ci    ret = ApplyPatch(para, srcData, patchData);
217fb299fa2Sopenharmony_ci    if (ret != USCRIPT_SUCCESS) {
218fb299fa2Sopenharmony_ci        env.GetPkgManager()->ClosePkgStream(patchStream);
219fb299fa2Sopenharmony_ci        return ret;
220fb299fa2Sopenharmony_ci    }
221fb299fa2Sopenharmony_ci
222fb299fa2Sopenharmony_ci    PartitionRecord::GetInstance().RecordPartitionUpdateStatus(para.partName, true);
223fb299fa2Sopenharmony_ci    env.GetPkgManager()->ClosePkgStream(patchStream);
224fb299fa2Sopenharmony_ci    unlink(srcFile.c_str());
225fb299fa2Sopenharmony_ci    LOG(INFO) << "USInstrImageCheck::Execute ret:" << ret;
226fb299fa2Sopenharmony_ci    return ret;
227fb299fa2Sopenharmony_ci}
228fb299fa2Sopenharmony_ci
229fb299fa2Sopenharmony_ciint32_t USInstrImageShaCheck::Execute(Uscript::UScriptEnv &env, Uscript::UScriptContext &context)
230fb299fa2Sopenharmony_ci{
231fb299fa2Sopenharmony_ci    int32_t result = ExecuteShaCheck(env, context);
232fb299fa2Sopenharmony_ci    context.PushParam(result);
233fb299fa2Sopenharmony_ci    return result;
234fb299fa2Sopenharmony_ci}
235fb299fa2Sopenharmony_ci
236fb299fa2Sopenharmony_ciint32_t USInstrImageShaCheck::GetParam(Uscript::UScriptContext &context, CheckPara &para)
237fb299fa2Sopenharmony_ci{
238fb299fa2Sopenharmony_ci    if (context.GetParamCount() != IMAGE_PATCH_CHECK_CMD_LEN) {
239fb299fa2Sopenharmony_ci        LOG(ERROR) << "para count error " << context.GetParamCount();
240fb299fa2Sopenharmony_ci        return USCRIPT_INVALID_PARAM;
241fb299fa2Sopenharmony_ci    }
242fb299fa2Sopenharmony_ci    int index = 0;
243fb299fa2Sopenharmony_ci    uint32_t ret = static_cast<uint32_t>(context.GetParam(index++, para.partName));
244fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.srcSize));
245fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.srcHash));
246fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.destSize));
247fb299fa2Sopenharmony_ci    ret |= static_cast<uint32_t>(context.GetParam(index++, para.destHash));
248fb299fa2Sopenharmony_ci    if (ret != USCRIPT_SUCCESS) {
249fb299fa2Sopenharmony_ci        LOG(ERROR) << "para get error";
250fb299fa2Sopenharmony_ci        return USCRIPT_INVALID_PARAM;
251fb299fa2Sopenharmony_ci    }
252fb299fa2Sopenharmony_ci
253fb299fa2Sopenharmony_ci    para.devPath = GetBlockDeviceByMountPoint(para.partName);
254fb299fa2Sopenharmony_ci    if (para.devPath.empty()) {
255fb299fa2Sopenharmony_ci        LOG(ERROR) << "cannot get block device of partition" << para.partName;
256fb299fa2Sopenharmony_ci        return USCRIPT_ERROR_EXECUTE;
257fb299fa2Sopenharmony_ci    }
258fb299fa2Sopenharmony_ci    LOG(INFO) << "dev path: " << para.devPath;
259fb299fa2Sopenharmony_ci    return USCRIPT_SUCCESS;
260fb299fa2Sopenharmony_ci}
261fb299fa2Sopenharmony_ci
262fb299fa2Sopenharmony_ciint32_t USInstrImageShaCheck::CheckHash(const CheckPara &para)
263fb299fa2Sopenharmony_ci{
264fb299fa2Sopenharmony_ci    UpdatePatch::MemMapInfo mapBuffer {};
265fb299fa2Sopenharmony_ci    if (PatchMapFile(para.devPath, mapBuffer) != UpdatePatch::PATCH_SUCCESS) {
266fb299fa2Sopenharmony_ci        LOG(ERROR) << "PatchMapFile error";
267fb299fa2Sopenharmony_ci        return USCRIPT_ERROR_EXECUTE;
268fb299fa2Sopenharmony_ci    }
269fb299fa2Sopenharmony_ci    if (!std::all_of(para.srcSize.begin(), para.srcSize.end(), ::isdigit)) {
270fb299fa2Sopenharmony_ci        LOG(ERROR) << "para size error " << para.srcSize;
271fb299fa2Sopenharmony_ci        return USCRIPT_ERROR_EXECUTE;
272fb299fa2Sopenharmony_ci    }
273fb299fa2Sopenharmony_ci    size_t length = std::stoul(para.srcSize);
274fb299fa2Sopenharmony_ci    UpdatePatch::BlockBuffer data = { mapBuffer.memory, length };
275fb299fa2Sopenharmony_ci    std::string resultSha = UpdatePatch::GeneraterBufferHash(data);
276fb299fa2Sopenharmony_ci    std::transform(resultSha.begin(), resultSha.end(), resultSha.begin(), ::toupper);
277fb299fa2Sopenharmony_ci    if (resultSha != para.srcHash) {
278fb299fa2Sopenharmony_ci        LOG(ERROR) << "resultSha:" << resultSha << " srcHash:" << para.srcHash;
279fb299fa2Sopenharmony_ci        return USCRIPT_INVALID_PARAM;
280fb299fa2Sopenharmony_ci    }
281fb299fa2Sopenharmony_ci    return USCRIPT_SUCCESS;
282fb299fa2Sopenharmony_ci}
283fb299fa2Sopenharmony_ci
284fb299fa2Sopenharmony_ciint32_t USInstrImageShaCheck::ExecuteShaCheck(Uscript::UScriptEnv &env, Uscript::UScriptContext &context)
285fb299fa2Sopenharmony_ci{
286fb299fa2Sopenharmony_ci    UPDATER_INIT_RECORD;
287fb299fa2Sopenharmony_ci    if (env.IsRetry() && !Utils::CheckFaultInfo(VERIFY_FAILED_REBOOT)) {
288fb299fa2Sopenharmony_ci        return USCRIPT_SUCCESS;
289fb299fa2Sopenharmony_ci    }
290fb299fa2Sopenharmony_ci
291fb299fa2Sopenharmony_ci    CheckPara para {};
292fb299fa2Sopenharmony_ci    int32_t ret = GetParam(context, para);
293fb299fa2Sopenharmony_ci    if (ret != USCRIPT_SUCCESS) {
294fb299fa2Sopenharmony_ci        UPDATER_LAST_WORD(ret);
295fb299fa2Sopenharmony_ci        LOG(ERROR) << "GetParam error";
296fb299fa2Sopenharmony_ci        return ret;
297fb299fa2Sopenharmony_ci    }
298fb299fa2Sopenharmony_ci
299fb299fa2Sopenharmony_ci    ret = CheckHash(para);
300fb299fa2Sopenharmony_ci    if (ret != USCRIPT_SUCCESS) {
301fb299fa2Sopenharmony_ci        UPDATER_LAST_WORD(ret);
302fb299fa2Sopenharmony_ci        env.PostMessage(UPDATER_RETRY_TAG, VERIFY_FAILED_REBOOT);
303fb299fa2Sopenharmony_ci        LOG(ERROR) << "CheckHash error";
304fb299fa2Sopenharmony_ci        return ret;
305fb299fa2Sopenharmony_ci    }
306fb299fa2Sopenharmony_ci
307fb299fa2Sopenharmony_ci    LOG(INFO) << "USInstrImageCheck::Execute Success";
308fb299fa2Sopenharmony_ci    return USCRIPT_SUCCESS;
309fb299fa2Sopenharmony_ci}
310fb299fa2Sopenharmony_ci}
311fb299fa2Sopenharmony_ci
312