diff --git a/services/include/updater/updater_const.h b/services/include/updater/updater_const.h index 9a21f31b080c010d9389d29f6730e2e0abb5f8d4..7e8f292e4bf47ff4062fa9e81523a681205aec92 100644 --- a/services/include/updater/updater_const.h +++ b/services/include/updater/updater_const.h @@ -39,6 +39,7 @@ constexpr const char *MISC_FILE = "/dev/block/platform/soc/10100000.himci.eMMC/b constexpr const char *MISC_PATH = "/misc"; constexpr const char *UPDATER_BINARY = "updater_binary"; constexpr const char *SDCARD_PATH = "/sdcard"; +constexpr const char *FACTORY_INTERNAL_SDCARD_PATH = "/data/update/dload"; constexpr const char *UPDATER_HDC_LOG = "/data/updater/log/flashd_hdc.log"; constexpr const char *PREFIX_UFS_NODE = "/dev/block/sd"; constexpr const char *SDCARD_PACKAGE_SUFFIX = ".zip"; diff --git a/services/sdcard_update/sdcard_update.cpp b/services/sdcard_update/sdcard_update.cpp index a46d5cc647ab7b144bc9f10e5f9a0346cfe2bc03..46fdbaed3c2fd81ed789831b145ae9e444de0e89 100644 --- a/services/sdcard_update/sdcard_update.cpp +++ b/services/sdcard_update/sdcard_update.cpp @@ -58,6 +58,12 @@ __attribute__((weak)) UpdaterStatus GetSdcardPkgsFromDev(UpdaterParams &upParams return UPDATE_ERROR; } +__attribute__((weak)) bool IsFactoryVersion(void) +{ + LOG(INFO) << "Set IsFactoryVersion false"; + return false; +} + bool CheckPathNeedMountSD(UpdaterParams &upParams) { for (auto pkgPath : upParams.updatePackage) { @@ -68,6 +74,16 @@ bool CheckPathNeedMountSD(UpdaterParams &upParams) return true; } +bool CheckDataPathNeedMountSD(UpdaterParams &upParams) +{ + for (auto pkgPath : upParams.updatePackage) { + if (pkgPath.find("/data/update/dload/") != 0) { + return false; + } + } + return true; +} + bool DoMountSdcard(std::vector &sdcardStr, std::string &mountPoint) { bool mountSuccess = false; @@ -98,10 +114,6 @@ UpdaterStatus CheckSdcardPkgs(UpdaterParams &upParams) LOG(INFO) << "get sd card from dev succeed, skip get package from sd card"; return UPDATE_SUCCESS; } - if (upParams.sdExtMode == SDCARD_NORMAL_UPDATE && GetFactoryInternalPkgs(upParams) == UPDATE_SUCCESS) { - LOG(INFO) << "get factory internal sdcard pkgs succeed"; - return UPDATE_SUCCESS; - } std::string mountPoint = std::string(SDCARD_PATH); std::vector sdcardStr = GetBlockDevicesByMountPoint(mountPoint); if (sdcardStr.empty()) { @@ -115,7 +127,18 @@ UpdaterStatus CheckSdcardPkgs(UpdaterParams &upParams) return UPDATE_ERROR; } } - if ((Utils::CheckUpdateMode(Updater::SDCARD_MODE) && !Utils::CheckUpdateMode(Updater::SDCARD_INTRAL_MODE)) || + if (upParams.sdExtMode == SDCARD_NORMAL_UPDATE && CheckDataPathNeedMountSD(upParams) && IsFactoryVersion()) { + if (MountForPath("/data") != 0 && GetMountStatusForPath("/data") != MountStatus::MOUNT_MOUNTED) { + LOG(ERROR) << "factory_internal_update mount data fail"; + return UPDATE_ERROR; + } + Utils::SetMessageToMisc(upParams.miscCmd, 0, "factory_internal_update"); // set factory internal update + upParams.sdExtMode = SDCARD_FACTORY_INTERNAL_MODE; + LOG(INFO) << "factory_internal_update is successfully written to misc"; + } + if ((Utils::CheckUpdateMode(Updater::SDCARD_MODE) && + !Utils::CheckUpdateMode(Updater::SDCARD_INTRAL_MODE) && + !Utils::CheckUpdateMode(Updater::FACTORY_INTERNAL_MODE)) || (Utils::CheckUpdateMode(Updater::SDCARD_INTRAL_MODE) && CheckPathNeedMountSD(upParams))) { if (!DoMountSdcard(sdcardStr, mountPoint)) { LOG(ERROR) << "mount sdcard fail!"; @@ -124,14 +147,9 @@ UpdaterStatus CheckSdcardPkgs(UpdaterParams &upParams) } #endif if (GetSdcardPkgsPath(upParams) != UPDATE_SUCCESS) { - LOG(ERROR) << "there is no package in sdcard/updater, please check"; + LOG(ERROR) << "there is no package in sdcard/updater or data/update, please check"; return UPDATE_ERROR; } return UPDATE_SUCCESS; } -__attribute__((weak)) UpdaterStatus GetFactoryInternalPkgs(UpdaterParams &upParams) -{ - LOG(INFO) << "not implemented get normal update sdcard pkgs"; - return UPDATE_ERROR; -} } // Updater