/*
 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef UPDATER_CONST_H
#define UPDATER_CONST_H

#include <string>

namespace Updater {
constexpr const char *INSTALL_TIME_FILE = "install_time";
constexpr const char *ROLLBACK_FILE = "rollback";
constexpr const char *COMMAND_FILE = "/data/updater/command";
constexpr const char *TMP_LOG = "/tmp/updater.log";
constexpr const char *TMP_STAGE_LOG = "/tmp/updater_stage.log";
constexpr const char *TMP_ERROR_CODE_PATH = "/tmp/error_code.log";
constexpr const char *UPDATER_INODE_PATH = "/data/updater/inode";
constexpr const char *ERROR_CODE_PATH = "/data/updater/log/error_code.log";
constexpr const char *UPDATER_LOG_DIR = "/data/updater/log";
constexpr const char *UPDATER_LOG = "/data/updater/log/updater_log";
constexpr const char *SYS_INSTALLER_LOG = "/data/updater/log/sys_installer.log";
constexpr const char *UPDATER_STAGE_LOG = "/data/updater/log/updater_stage_log";
constexpr const char *UPDATER_LOG_FILE = "updater_log";
constexpr const char *UPDATER_STAGE_FILE = "updater_stage_log";
constexpr const char *UPDATER_PATH = "/data/updater";
constexpr const char *LOG_UPDATER_PATH = "/log/updater";
constexpr const char *UPDATER_LOCALE_FILE = "locale";
constexpr const char *UPDATER_RESULT_FILE = "updater_result";
constexpr const char *SINGULAR_UPDATE_PATH = "/data/updater/singular_update";
constexpr const char *SINGULAR_UPDATE_NAME = "singular_update";
constexpr const char *SINGULAR_UPDATE_RESULT = "singular_update_result";
constexpr const char *CDC_LOG_NAME = "cdc_log";
constexpr const char *MODULE_UPDATE_RESULT_FILE = "module_update_result";
constexpr const char *MISC_FILE = "/dev/block/platform/soc/10100000.himci.eMMC/by-name/misc";
constexpr const char *MISC_PATH = "/misc";
constexpr const char *UPDATER_BINARY = "updater_binary";
constexpr const char *STREAM_ZIP_PATH = "/data/updater/update_stream.zip";
constexpr const char *SDCARD_PATH = "/sdcard";
constexpr const char *INTERNAL_DATA_PATH = "/internaldata";
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";
constexpr const char *POWEROFF = "shutdown";
constexpr const char *BOOTDEV_TYPE = "/proc/bootdevice/type";
constexpr const char *MANUAL_UPLOAD_LOG_TIME_FILE = "manual_upload_time";
constexpr const char *UPLOAD_LOG_TIME_FILE = "upload_time";
constexpr const char *ERASE_LOG_OEMINFO = "not_erase_log_switch";
constexpr const char *RESET_MESSAGE_INFO = "reset_enter:331";
constexpr const char *SECURE_ERASE_MESSAGE_INFO = "--secure_erase\n--reset_enter:212";
constexpr const char *STREAM_PACKAGE_PATH = "/data/update/vab/stream_package/";
constexpr const char *STREAM_HEAD_FILETYPE = ".bin";
constexpr const char *STREAM_ZIP_FILETYPE = ".zip";
constexpr const char *STREAM_BIN_STREAMTYPE = ".shm";
constexpr const char *STREAM_ARG_PREFIX = "stream=";
constexpr const char *FACTORY_RESET_OTA_MISC = "--user_wipe_data\n--reset_enter:337";

// update mode
constexpr const char *SDCARD_MODE = "sdcard_update";
constexpr const char *OTA_MODE = "update_package";
constexpr const char *USB_MODE = "usb_update";
constexpr const char *OTA_INTRAL_MODE = "ota_intral_update";
constexpr const char *SDCARD_INTRAL_MODE = "sdcard_intral_update";
constexpr const char *UPDATRE_SCRIPT_ZIP = "/etc/updater_script.zip";
constexpr const char *FACTORY_INTERNAL_MODE = "factory_internal_update";
constexpr const char *USB_UPDATE_FAIL = "usb_update_fail";
constexpr const char *TOB_PKG_TAG = "tobpkg_in_sdcard";
constexpr const char *FACTORY_RESET_OTA_TAG = "factory_reset_ota";

// sd update ext mode
constexpr const char *SDCARD_NORMAL_UPDATE = "sdUpdate";
constexpr const char *SDCARD_UPDATE_FROM_DEV = "sdUpdateFromDev";
constexpr const char *SDCARD_MAINIMG = "mainUpdate";
constexpr const char *SDCARD_UPDATE_FROM_DATA = "sdUpdateFromData";

#ifndef UPDATER_UT
constexpr const char *SDCARD_CARD_PATH = "/sdcard/updater";
constexpr const char *SDCARD_CARD_PKG_PATH = "/sdcard/updater/updater.zip";
constexpr const char *DEFAULT_LOCALE = "en-US";
constexpr const char *G_WORK_PATH = "/tmp/";
constexpr const char *MMC_BLOCK_DEV_NAME = "/dev/block/mmcblk0";
constexpr const char *MMC_SIZE_FILE = "/sys/class/block/mmcblk0/size";
#else
constexpr const char *SDCARD_CARD_PATH = "/data/sdcard/updater";
constexpr const char *SDCARD_CARD_PKG_PATH = "/data/updater/updater/updater_full.zip";
constexpr const char *G_WORK_PATH = "/data/updater/src/";
constexpr const char *UT_VERSION = "OpenHarmony 3.2.9.1";
constexpr const char *MMC_BLOCK_DEV_NAME = "/data/block/mmcblk0";
constexpr const char *MMC_SIZE_FILE = "/data/class/block/mmcblk0/size";
#endif

// cpu affinity
constexpr const char *AFFECTED_CPUS = "affected_cpus";
constexpr const char *CPU_CORE_POLICY_NODE_DIR = "/sys/devices/system/cpu/cpufreq/policy";
constexpr int CPU_CATEGORIES = 3;
constexpr int LITTLE_CORE_INDEX = 0;
constexpr int MIDDLE_CORE_INDEX = 1;
constexpr int BIG_CORE_INDEX = 2;
constexpr unsigned int DEFAULT_LITTLE_CORES = 4;
constexpr unsigned int DEFAULT_BIG_CORES = 2;

// update retry
constexpr const char *UPDATER_RETRY_TAG = "retry_update";
constexpr const char *VERIFY_FAILED_REBOOT = "reboot_verify_failed";
constexpr const char *IO_FAILED_REBOOT = "reboot_IO_failed";
constexpr const char *BLOCK_UPDATE_FAILED_REBOOT = "reboot_block_update_failed";
constexpr const char *PROCESS_BIN_FAIL_RETRY = "process_bin_failed";
constexpr const char *EXTRACT_PATCH_FAIL_RETRY = "extract_patch_failed";

constexpr int MAX_RETRY_COUNT = 3;
constexpr int MINIMAL_ARGC_LIMIT = 2;
constexpr int MAXIMAL_ARGC_LIMIT = 4;
constexpr int32_t PKG_INFO_NUM = 3;
constexpr int MAX_LOG_BUF_SIZE = 4096;
constexpr int MAX_LOG_NAME_SIZE = 100;
constexpr long MAX_LOG_SIZE = 2 * 1024 * 1024;
constexpr long MAX_LOG_DIR_SIZE = 10 * 1024 * 1024;
constexpr int MAX_RESULT_SIZE = 20;
constexpr int MAX_RESULT_BUFF_SIZE = 1000;
constexpr int VERIFICATION_PROGRESS_TIME = 60;
constexpr float VERIFICATION_PROGRESS_FRACTION = 0.25f;
constexpr int PREDICTED_ELAPSED_TIME = 30;
constexpr int PROGRESS_VALUE_MAX = 1;
constexpr int PROGRESS_VALUE_MIN = 0;
constexpr int SLEEP_TIME = 1;
constexpr int DECIMAL = 10;
constexpr int BINARY = 2;
constexpr int FAKE_TEMPRATURE = 40;
constexpr int32_t DEFAULT_PROCESS_NUM = 2;
constexpr int32_t MAX_BUFFER_SIZE = 512;
constexpr int32_t DEFAULT_PIPE_NUM = 2;
constexpr int32_t BINARY_MAX_ARGS = 3;
constexpr int32_t BINARY_SECOND_ARG = 2;
constexpr int32_t WRITE_SECOND_CMD = 2;
constexpr uint32_t LITTLE_CPU_CORES = 4;
constexpr int REBOOT = 0;
constexpr int WIPE_DATA = 1;
constexpr int WIPE_CACHE = 2;
constexpr int FACTORY_RESET = 3;
constexpr int REBOOT_FASTBOOT = 4;
constexpr int UPDATE_FROM_SDCARD = 5;
constexpr int SHUTDOWN = 6;
constexpr int FULL_PERCENT_PROGRESS = 100;
constexpr int PROGRESS_VALUE_CONST = 2;
constexpr int SHOW_FULL_PROGRESS_TIME = 2000;
constexpr unsigned int LEAST_PARTITION_COUNT = 4;
constexpr unsigned int UI_SHOW_DURATION = 2000;
constexpr unsigned int INTERVAL_TIME = 300;
constexpr float EPSINON = 0.00001;
constexpr float FULL_EPSINON = 1;
constexpr uint64_t DEFAULT_1T_SIZE = 1024ULL * 1024 * 1024 * 1024;
constexpr uint32_t SSD_ERASE_1T_TIME = 266 * 60;
constexpr uint32_t UFS_ERASE_1T_TIME = 202 * 60;
constexpr uint32_t EMMC_ERASE_1T_TIME = 532 * 60;
constexpr int SHM_BLOCK_SIZE = 50 * 1024;
} // namespace Updater
#endif