diff --git a/services/updater.cpp b/services/updater.cpp index 22b392ca1836787347ac2b153fd31175c4851fac..84158f918c239146a026a12ee7c18a8a6e6cde2b 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -537,18 +537,21 @@ void ExcuteSubProc(const UpdaterParams &upParams, const std::string &fullPath, i } } const std::string retryPara = upParams.retryCount > 0 ? "retry=1" : "retry=0"; + int ret = -1; if (upParams.updateBin.size() > 0) { LOG(INFO) << "Binary Path:" << upParams.updateBin[upParams.pkgLocation].c_str(); - execl(fullPath.c_str(), fullPath.c_str(), upParams.updateBin[upParams.pkgLocation].c_str(), + ret = execl(fullPath.c_str(), fullPath.c_str(), upParams.updateBin[upParams.pkgLocation].c_str(), std::to_string(pipeWrite).c_str(), retryPara.c_str(), nullptr); } else if (upParams.updatePackage.size() > 0) { LOG(INFO) << "Binary Path:" << upParams.updatePackage[upParams.pkgLocation].c_str(); - execl(fullPath.c_str(), fullPath.c_str(), upParams.updatePackage[upParams.pkgLocation].c_str(), + ret = execl(fullPath.c_str(), fullPath.c_str(), upParams.updatePackage[upParams.pkgLocation].c_str(), std::to_string(pipeWrite).c_str(), retryPara.c_str(), nullptr); } - LOG(ERROR) << "Execute updater binary failed"; - UPDATER_LAST_WORD(UPDATE_ERROR, "Execute updater binary failed"); - exit(-1); + if (ret < 0) { + LOG(ERROR) << "Execute updater binary failed, errno = " << errno; + UPDATER_LAST_WORD(UPDATE_ERROR, "Execute updater binary failed, errno = ", errno); + exit(-1); + } } UpdaterStatus HandlePipeMsg(UpdaterParams &upParams, int pipeRead, bool &retryUpdate) diff --git a/services/updater_main.h b/services/updater_main.h index 3118d01dc5e0662defe6998694a5e8a24cdf38f9..2dcc764253beb45630f8f5989d48d4c9803f7846 100644 --- a/services/updater_main.h +++ b/services/updater_main.h @@ -27,6 +27,7 @@ enum FactoryResetMode { USER_WIPE_DATA = 0, FACTORY_WIPE_DATA, MENU_WIPE_DATA, + CLEAR_SPACE, INVALID_MODE, }; diff --git a/services/updater_ui.cpp b/services/updater_ui.cpp index ce20ea0e26b31437d84fcfde15412d4635f130fb..8dc258a3023328d5cf914ef1962eceb4a8d1a684 100644 --- a/services/updater_ui.cpp +++ b/services/updater_ui.cpp @@ -118,6 +118,7 @@ DEFINE_ASYN_CALLBACK(OnLabelSDCardNoDelayEvt) Utils::RemoveUpdateInfoFromMisc("sdcard_update"); GetFacade().ShowLogRes(res == UPDATE_CORRUPT ? TR(LOGRES_VERIFY_FAILED) : TR(LOGRES_UPDATE_FAILED)); GetFacade().ShowFailedPage(); + NotifyAutoReboot(upParams.updateMode); return; } GetFacade().ShowLogRes(TR(LABEL_UPD_OK_DONE)); diff --git a/utils/include/utils_common.h b/utils/include/utils_common.h index de27cc06f44dd54112ca893ebf209112d8e01884..cf1085600b353655a7c752c2229e3a70089445dc 100644 --- a/utils/include/utils_common.h +++ b/utils/include/utils_common.h @@ -27,6 +27,9 @@ namespace Utils { bool PathToRealPath(const std::string &path, std::string &realPath); void UsSleep(int usec); bool IsUpdaterMode(); +void* LoadLibrary(const std::string &libName, const std::string &libPath); +void CloseLibrary(void* handle); +void* GetFunction(void* handle, const std::string &funcName); } // Utils } // Updater #endif // UTILS_COMMON_H \ No newline at end of file diff --git a/utils/include/utils_fs.h b/utils/include/utils_fs.h index 3170aa6c77e9c4e99e243e08607dfa74248fca8c..a257f81b2c78de7bdea0eb7feca9a65333ba6740 100644 --- a/utils/include/utils_fs.h +++ b/utils/include/utils_fs.h @@ -29,9 +29,6 @@ int64_t GetFilesFromDirectory(const std::string &path, std::vector bool RemoveDir(const std::string &path); bool IsFileExist(const std::string &path); bool IsDirExist(const std::string &path); -void* LoadLibrary(const std::string &libName, const std::string &libPath); -void CloseLibrary(void* handle); -void* GetFunction(void* handle, const std::string &funcName); } // Utils } // Updater #endif // UTILS_FS_H \ No newline at end of file diff --git a/utils/utils_common.cpp b/utils/utils_common.cpp index 31186a7af1579c5fc1b809521f42dfcd32104db0..6c1e7c35efc2cb4471d5178d16febff0608203da 100644 --- a/utils/utils_common.cpp +++ b/utils/utils_common.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -76,5 +77,52 @@ bool IsUpdaterMode() LOG(INFO) << "normal mode"; return false; } + +void* LoadLibrary(const std::string &libName, const std::string &libPath) +{ + if (libName.empty()) { + LOG(ERROR) << "lib name is empty"; + return nullptr; + } + if (libPath != "/system/lib64/" && libPath != "/vendor/lib64/") { + LOG(ERROR) << "lib path invalid"; + return nullptr; + } + std::string libAbsPath = libPath + libName; + char realPath[PATH_MAX + 1] = {0}; + if (realpath(libAbsPath.c_str(), realPath) == nullptr) { + LOG(ERROR) << "realpath error"; + return nullptr; + } + void* handle = dlopen(libAbsPath.c_str(), RTLD_LAZY); + if (handle == nullptr) { + LOG(ERROR) << "dlopen fail, lib name = " << libName << "; dlerror = " << dlerror(); + return nullptr; + } + return handle; +} + +void CloseLibrary(void* handle) +{ + if (handle == nullptr) { + LOG(ERROR) << "handle is nulptr"; + return; + } + dlclose(handle); + handle = nullptr; +} + +void* GetFunction(void* handle, const std::string &funcName) +{ + if (handle == nullptr) { + LOG(ERROR) << "handle is nullptr"; + return nullptr; + } + if (funcName.empty()) { + LOG(ERROR) << "func name is empty"; + return nullptr; + } + return dlsym(handle, funcName.c_str()); +} } // Utils } // updater diff --git a/utils/utils_fs.cpp b/utils/utils_fs.cpp index 28e154330c5a02c818d5653d90f0db3be6d27d9d..d14497f38edebfb8452a445742277c3268946671 100644 --- a/utils/utils_fs.cpp +++ b/utils/utils_fs.cpp @@ -149,52 +149,5 @@ bool IsDirExist(const std::string &path) } return false; } - -void* LoadLibrary(const std::string &libName, const std::string &libPath) -{ - if (libName.empty()) { - LOG(ERROR) << "lib name is empty"; - return nullptr; - } - if (libPath != "/system/lib64/" && libPath != "/vendor/lib64/") { - LOG(ERROR) << "lib path invalid"; - return nullptr; - } - std::string libAbsPath = libPath + libName; - char realPath[PATH_MAX + 1] = {0}; - if (realpath(libAbsPath.c_str(), realPath) == nullptr) { - LOG(ERROR) << "realpath error"; - return nullptr; - } - void* handle = dlopen(libAbsPath.c_str(), RTLD_LAZY); - if (handle == nullptr) { - LOG(ERROR) << "dlopen fail, lib name = " << libName << "; dlerror = " << dlerror(); - return nullptr; - } - return handle; -} - -void CloseLibrary(void* handle) -{ - if (handle == nullptr) { - LOG(ERROR) << "handle is nulptr"; - return; - } - dlclose(handle); - handle = nullptr; -} - -void* GetFunction(void* handle, const std::string &funcName) -{ - if (handle == nullptr) { - LOG(ERROR) << "handle is nullptr"; - return nullptr; - } - if (funcName.empty()) { - LOG(ERROR) << "func name is empty"; - return nullptr; - } - return dlsym(handle, funcName.c_str()); -} } // Utils } // updater