• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CONSTANT_H
17 #define CONSTANT_H
18 
19 #include <stdint.h>
20 #include <string>
21 #include <vector>
22 
23 #include "update_helper.h"
24 
25 namespace OHOS {
26 namespace UpdateEngine {
27 namespace Constant {
28 constexpr int32_t ONE_DAY_HOUR = 24;
29 constexpr int32_t ONE_HOUR_MINUTES = 60;
30 constexpr int32_t ONE_MINUTE_SECONDS = 60;
31 constexpr int32_t FIVE_MINUTES_SECONDS = 5 * Constant::ONE_MINUTE_SECONDS;
32 
33 static const std::string DUPDATE_ENGINE_CONFIG_PATH = "/system/etc/update/dupdate_config.json";
34 
35 // 存放升级引擎数据库、缓存等文件的加密路径
36 static const std::string UPDATE_ENCRYPTED_ROOT_PATH = "/data/service/el1/public/update";
37 static const std::string DUPDATE_ENGINE_ENCRYPTED_ROOT_PATH = UPDATE_ENCRYPTED_ROOT_PATH + "/dupdate_engine";
38 static const std::string DATABASES_ROOT_PATH = DUPDATE_ENGINE_ENCRYPTED_ROOT_PATH + "/databases";
39 static const std::string PREFERENCES_ROOT_PATH = DUPDATE_ENGINE_ENCRYPTED_ROOT_PATH + "/preferences";
40 static const std::string FILES_ROOT_PATH = DUPDATE_ENGINE_ENCRYPTED_ROOT_PATH + "/files";
41 
42 // 存放ota升级包的非加密路径
43 static const std::string UPDATE_PACKAGE_ROOT_PATH = "/data/update";
44 static const std::string DUPDATE_ENGINE_PACKAGE_ROOT_PATH = UPDATE_PACKAGE_ROOT_PATH + "/ota_package";
45 
46 static const std::string DUE_INIT_FLAG = "due_init_flag"; // DUE初始启动标记
47 static const std::string PROCESS_RESTART_REASON = "process_restart_reason"; // 进程重启原因
48 } // namespace Constant
49 
50 enum class CommonEventType {
51     AUTO_UPGRADE = 0,
52     NET_CHANGED,
53     TIME_CHANGED,
54     TIME_ZONE_CHANGED,
55     BOOT_COMPLETE,
56     PROCESS_INIT,
57     NIGHT_UPGRADE,
58     SCREEN_OFF,
59     UPGRADE_REMIND,
60 };
61 
62 static const std::vector<DirInfo> BASE_DIR_INFOS {
63     {Constant::UPDATE_ENCRYPTED_ROOT_PATH, 0751, false},
64     {Constant::DUPDATE_ENGINE_ENCRYPTED_ROOT_PATH, 0700, false},
65     {Constant::DATABASES_ROOT_PATH, 0700, false},
66     {Constant::PREFERENCES_ROOT_PATH, 0700, false},
67     {Constant::FILES_ROOT_PATH, 0700, true},
68     {Constant::UPDATE_PACKAGE_ROOT_PATH, 0770, false},
69     {Constant::DUPDATE_ENGINE_PACKAGE_ROOT_PATH, 0770, true}
70 };
71 } // namespace UpdateEngine
72 } // namespace OHOS
73 #endif // CONSTANT_H