• 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 FIRMWARE_COMMON_H
17 #define FIRMWARE_COMMON_H
18 
19 #include <string>
20 
21 #include "anonymous_utils.h"
22 #include "constant.h"
23 #include "firmware_component.h"
24 #include "firmware_log.h"
25 #include "update_define.h"
26 
27 namespace OHOS {
28 namespace UpdateService {
29 enum class FirmwareStep {
30     INIT = 0,
31     CHECK_STEP,
32     DOWNLOAD_STEP,
33     AUTH_STEP,
34     INSTALL_STEP,
35     APPLY_STEP,
36     COMPLETE = 10
37 };
38 
39 enum class CheckStatus {
40     CHECK_SUCCESS = 0,
41     CHECK_FAIL,
42     FILE_LIST_REQUEST_SUCCESS,
43     FILE_LIST_REQUEST_FAIL,
44     CHANGELOG_REQUEST_SUCCESS,
45     CHANGELOG_REQUEST_FAIL
46 };
47 
48 enum class BlType {
49     HOTA_TYPE = 1,
50     COTA_TYPE = 2,
51     DYNAMIC_TYPE = 100
52 };
53 
54 enum class CheckResultStatus {
55     STATUS_SYSTEM_ERROR = -1,
56     STATUS_NEW_VERSION_AVAILABLE = 0,
57     STATUS_NEW_VERSION_NOT_AVAILABLE = 1,
58     STATUS_SERVER_IS_BUSY = 2
59 };
60 
61 enum class InstallType {
62     QUICK_FIX = 1,
63     SYS_INSTALLER,
64     STREAM_INSTALLLER,
65     UPDATER
66 };
67 
68 struct Duration {
69     int32_t duration = -1; // 搜包周期 单位:小时
70 };
71 
72 struct VersionPackageRule {
73 public:
74     std::string versionNumber;
75     std::string displayVersionNumber;
76     std::string versionPackageType;
77 };
78 
79 enum VersionIndex {
80     BASE_INDEX = 0,
81     CUST_INDEX,
82     PRELOAD_INDEX
83 };
84 
85 enum StorageType {
86     COMMERCIAL = 1,
87     BETA = 2
88 };
89 
90 struct UpdatePackage {
91     std::string versionId;
92     int32_t packageIndex = 0;
93     PackageType versionPackageType = PackageType::DYNAMIC;
94 };
95 
96 struct TargetBlComponent {
97     std::string versionNumber;
98     std::string displayVersionNumber;
99     PackageType versionPackageType = PackageType::DYNAMIC;
100 };
101 
102 struct BlVersionCheckResult {
103     std::string status;
104     std::string pollingPeriod;
105     std::string blVersionInfo;
106     int32_t blVersionType = 0;
107     std::string descriptPackageId;
108     std::vector<UpdatePackage> updatePackages;
109     std::vector<TargetBlComponent> targetBlComponents;
110 };
111 
112 struct Version {
113     std::string url;
114     std::string reserveUrl;
115     int32_t storageType = 0;
116     std::string versionId;
117     std::string versionNumber;
118 };
119 
120 struct BlCheckResponse {
121     std::string status;
122     std::vector<BlVersionCheckResult> blVersionCheckResults;
123     std::vector<Version> versionList;
124 };
125 
126 struct CheckAndAuthInfo {
127     std::string responseStatus;
128 };
129 
130 enum class CombinationType {
131     INVALLID_TYPE = 0,
132     HOTA = 1
133 };
134 
135 enum class DownloadMode {
136     MANUAL = 0,
137     AUTO
138 };
139 
140 enum class UpgradeMode {
141     MANUAL = 0,
142     NIGHT
143 };
144 
145 enum class RequestType {
146     CHECK = 0,
147     AUTH
148 };
149 
150 enum class DownloadEndReason {
151     INIT = 0,
152     SUCCESS = 1,
153     DOWNLOADING = 2,
154     FAIL = 3,
155     VERIFY_FAIL = 4,
156     IO_EXCEPTION = 5,
157     REDIRECT = 6,
158     SERVER_TIMEOUT = 7,
159     PAUSE = 8,
160     CANCEL = 9,
161     NO_ENOUGH_MEMORY = 10,
162     NET_NOT_AVAILIABLE,
163     DOWNLAOD_INFO_EMPTY,
164     CURL_ERROR,
165     SYSTEM_BUSY,
166     INIT_PACKAGE_FAIL,
167     NET_CHANGE,
168 };
169 } // namespace UpdateService
170 } // namespace OHOS
171 #endif // FIRMWARE_COMMON_H
172