1 /*
2  * Copyright (c) 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 
16 #ifndef FIRMWARE_CONSTANT_H
17 #define FIRMWARE_CONSTANT_H
18 
19 #include <vector>
20 
21 #include "constant.h"
22 
23 namespace OHOS {
24 namespace UpdateEngine {
25 namespace Firmware {
26 constexpr double HALF_PROGRESS = 0.5;
27 constexpr int32_t NIGHT_UPGRADE_START_HOUR = 2;
28 constexpr int32_t NIGHT_UPGRADE_END_HOUR = 4;
29 constexpr int32_t VER_CARRY_DEVICE_ID = 2;
30 
31 static const std::string HOTA_CURRENT_COMPONENT_ID = "hota_current_component_id";
32 
33 static const std::string UPDATE_ACTION = "update_action"; // recovery upgrade
34 
35 static const std::string PACKAGE_ROOT_PATH = Constant::DUPDATE_ENGINE_PACKAGE_ROOT_PATH + "/firmware";
36 static const std::string PACKAGE_PATH = PACKAGE_ROOT_PATH + "/versions";
37 
38 static const std::string ENCRYPTED_ROOT_PATH = Constant::FILES_ROOT_PATH + "/firmware";
39 static const std::string CHANGELOG_PATH = ENCRYPTED_ROOT_PATH + "/changelogs";
40 
41 static const std::string AUTO_DOWNLOAD_SWITCH = "auto_download_switch"; // 自动下载开关
42 
43 constexpr float COMPRESSION_RATIO = 0.2;
44 
45 constexpr int32_t ONE_HUNDRED = 100;
46 
47 const std::string BOOTSLOTS_DEFAULT_VALUE = "0";
48 const std::string BOOTSLOTS_AB_UPDATE_VALUE = "2";
49 constexpr int32_t SLEEP_TIME_BEFORE_REBOOT = 2;
50 
51 } // namespace Firmware
52 
53 static const std::vector<DirInfo> FIRMWARE_DIR_INFOS {
54     {Firmware::ENCRYPTED_ROOT_PATH, 0700, true},
55     {Firmware::CHANGELOG_PATH, 0700, true},
56     {Firmware::PACKAGE_ROOT_PATH, 0770, true},
57     {Firmware::PACKAGE_PATH, 0770, true}
58 };
59 } // namespace UpdateEngine
60 } // namespace OHOS
61 #endif // FIRMWARE_CONSTANT_H
62