1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef UPDATER_CONST_H 16 #define UPDATER_CONST_H 17 18 #include <string> 19 20 namespace Updater { 21 constexpr const char *INSTALL_TIME_FILE = "install_time"; 22 constexpr const char *COMMAND_FILE = "/data/updater/command"; 23 constexpr const char *TMP_LOG = "/tmp/updater.log"; 24 constexpr const char *TMP_STAGE_LOG = "/tmp/updater_stage.log"; 25 constexpr const char *TMP_ERROR_CODE_PATH = "/tmp/error_code.log"; 26 constexpr const char *ERROR_CODE_PATH = "/data/updater/log/error_code.log"; 27 constexpr const char *UPDATER_LOG_DIR = "/data/updater/log"; 28 constexpr const char *UPDATER_LOG = "/data/updater/log/updater_log"; 29 constexpr const char *SYS_INSTALLER_LOG = "/data/updater/log/sys_installer.log"; 30 constexpr const char *UPDATER_STAGE_LOG = "/data/updater/log/updater_stage_log"; 31 constexpr const char *UPDATER_LOG_FILE = "updater_log"; 32 constexpr const char *UPDATER_STAGE_FILE = "updater_stage_log"; 33 constexpr const char *UPDATER_PATH = "/data/updater"; 34 constexpr const char *SYS_INSTALLER_PATH = "/mnt/sys_installer"; 35 constexpr const char *UPDATER_LOCALE_FILE = "locale"; 36 constexpr const char *UPDATER_RESULT_FILE = "updater_result"; 37 constexpr const char *MODULE_UPDATE_RESULT_FILE = "module_update_result"; 38 constexpr const char *MISC_FILE = "/dev/block/platform/soc/10100000.himci.eMMC/by-name/misc"; 39 constexpr const char *MISC_PATH = "/misc"; 40 constexpr const char *UPDATER_BINARY = "updater_binary"; 41 constexpr const char *SDCARD_PATH = "/sdcard"; 42 constexpr const char *UPDATER_HDC_LOG = "/data/updater/log/flashd_hdc.log"; 43 constexpr const char *PREFIX_UFS_NODE = "/dev/block/sd"; 44 constexpr const char *SDCARD_PACKAGE_SUFFIX = ".zip"; 45 constexpr const char *POWEROFF = "shutdown"; 46 constexpr const char *BOOTDEV_TYPE = "/proc/bootdevice/type"; 47 constexpr const char *UPLOAD_LOG_TIME_FILE = "upload_time"; 48 49 // update mode 50 constexpr const char *SDCARD_MODE = "sdcard_update"; 51 constexpr const char *OTA_MODE = "update_package"; 52 constexpr const char *USB_MODE = "usb_update"; 53 constexpr const char *SDCARD_INTRAL_MODE = "sdcard_intral_update"; 54 constexpr const char *UPDATRE_SCRIPT_ZIP = "/etc/updater_script.zip"; 55 constexpr const char *FACTORY_INTERNAL_MODE = "factory_internal_update"; 56 57 // sd update ext mode 58 constexpr const char *SDCARD_NORMAL_UPDATE = "sdUpdate"; 59 constexpr const char *SDCARD_UPDATE_FROM_DEV = "sdUpdateFromDev"; 60 constexpr const char *SDCARD_MAINIMG = "mainUpdate"; 61 constexpr const char *SDCARD_UPDATE_FROM_DATA = "sdUpdateFromData"; 62 63 #ifndef UPDATER_UT 64 constexpr const char *SDCARD_CARD_PATH = "/sdcard/updater"; 65 constexpr const char *SDCARD_CARD_PKG_PATH = "/sdcard/updater/updater.zip"; 66 constexpr const char *DEFAULT_LOCALE = "en-US"; 67 constexpr const char *G_WORK_PATH = "/tmp/"; 68 constexpr const char *MMC_BLOCK_DEV_NAME = "/dev/block/mmcblk0"; 69 constexpr const char *MMC_SIZE_FILE = "/sys/class/block/mmcblk0/size"; 70 #else 71 constexpr const char *SDCARD_CARD_PATH = "/data/sdcard/updater"; 72 constexpr const char *SDCARD_CARD_PKG_PATH = "/data/updater/updater/updater_full.zip"; 73 constexpr const char *G_WORK_PATH = "/data/updater/src/"; 74 constexpr const char *UT_VERSION = "OpenHarmony 3.2.9.1"; 75 constexpr const char *MMC_BLOCK_DEV_NAME = "/data/block/mmcblk0"; 76 constexpr const char *MMC_SIZE_FILE = "/data/class/block/mmcblk0/size"; 77 #endif 78 79 // update retry 80 constexpr const char *UPDATER_RETRY_TAG = "retry_update"; 81 constexpr const char *VERIFY_FAILED_REBOOT = "reboot_verify_failed"; 82 constexpr const char *IO_FAILED_REBOOT = "reboot_IO_failed"; 83 84 constexpr int MAX_RETRY_COUNT = 3; 85 constexpr int MINIMAL_ARGC_LIMIT = 2; 86 constexpr int MAXIMAL_ARGC_LIMIT = 4; 87 constexpr int MAX_LOG_BUF_SIZE = 4096; 88 constexpr int MAX_LOG_NAME_SIZE = 100; 89 constexpr long MAX_LOG_SIZE = 2 * 1024 * 1024; 90 constexpr long MAX_LOG_DIR_SIZE = 10 * 1024 * 1024; 91 constexpr int MAX_RESULT_SIZE = 20; 92 constexpr int MAX_RESULT_BUFF_SIZE = 1000; 93 constexpr int VERIFICATION_PROGRESS_TIME = 60; 94 constexpr float VERIFICATION_PROGRESS_FRACTION = 0.25f; 95 constexpr int PREDICTED_ELAPSED_TIME = 30; 96 constexpr int PROGRESS_VALUE_MAX = 1; 97 constexpr int PROGRESS_VALUE_MIN = 0; 98 constexpr int SLEEP_TIME = 1; 99 constexpr int DECIMAL = 10; 100 constexpr int BINARY = 2; 101 constexpr int FAKE_TEMPRATURE = 40; 102 constexpr int32_t DEFAULT_PROCESS_NUM = 2; 103 constexpr int32_t MAX_BUFFER_SIZE = 512; 104 constexpr int32_t DEFAULT_PIPE_NUM = 2; 105 constexpr int32_t BINARY_MAX_ARGS = 3; 106 constexpr int32_t BINARY_SECOND_ARG = 2; 107 constexpr int32_t WRITE_SECOND_CMD = 2; 108 constexpr int REBOOT = 0; 109 constexpr int WIPE_DATA = 1; 110 constexpr int WIPE_CACHE = 2; 111 constexpr int FACTORY_RESET = 3; 112 constexpr int REBOOT_FASTBOOT = 4; 113 constexpr int UPDATE_FROM_SDCARD = 5; 114 constexpr int SHUTDOWN = 6; 115 constexpr int FULL_PERCENT_PROGRESS = 100; 116 constexpr int PROGRESS_VALUE_CONST = 2; 117 constexpr int SHOW_FULL_PROGRESS_TIME = 2000; 118 constexpr unsigned int LEAST_PARTITION_COUNT = 4; 119 constexpr unsigned int UI_SHOW_DURATION = 2000; 120 constexpr unsigned int INTERVAL_TIME = 300; 121 constexpr float EPSINON = 0.00001; 122 constexpr float FULL_EPSINON = 1; 123 } // namespace Updater 124 #endif 125