• 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_TASK_H
17 #define FIRMWARE_TASK_H
18 
19 #include <string>
20 
21 #include "firmware_common.h"
22 #include "update_helper.h"
23 
24 namespace OHOS {
25 namespace UpdateEngine {
26 struct FirmwareTask {
27     std::string taskId;
28     UpgradeStatus status = UpgradeStatus::INIT;
29     int32_t progress = 0;
30     int errorCode = 0;
31     std::string errorMsg;
32     bool isExistTask = false;
33     std::string downloadTaskId;
34     CombinationType combinationType = CombinationType::INVALLID_TYPE;
35 
36     Order downloadOrder = Order::DOWNLOAD;
37     NetType downloadAllowNetwork = NetType::NOT_METERED_WIFI;
38     DownloadMode downloadMode = DownloadMode::MANUAL;
39 
40     Order upgradeOrder = Order::INSTALL;
41     UpgradeMode upgradeMode = UpgradeMode::MANUAL;
42 
43     std::string authResult;
44     std::string updateToken;
45     std::string deviceToken;
46     std::string tokenHMac;
47     std::string currentVersionList;
48     int64_t authTime = 0;
49 
ToStringFirmwareTask50     std::string ToString()
51     {
52         return std::string("FirmwareTask: ")
53         .append("taskId=").append(taskId).append(",")
54         .append("status=").append(std::to_string(CAST_INT(status))).append(",")
55         .append("progress=").append(std::to_string(progress)).append(",")
56         .append("errorCode=").append(std::to_string(errorCode)).append(",")
57         .append("errorMsg=").append(errorMsg).append(",")
58         .append("combinationType=").append(std::to_string(CAST_INT(combinationType))).append(",")
59         .append("downloadMode=").append(std::to_string(CAST_INT(downloadMode))).append(",")
60         .append("downloadAllowNetwork=").append(std::to_string(CAST_INT(downloadAllowNetwork))).append(",")
61         .append("downloadOrder=").append(std::to_string(CAST_INT(downloadOrder))).append(",")
62         .append("upgradeMode=").append(std::to_string(CAST_INT(upgradeMode))).append(",")
63         .append("upgradeOrder=").append(std::to_string(CAST_INT(upgradeOrder))).append(",")
64         .append("authResult=").append(authResult).append(",")
65         .append("updateToken=").append(updateToken).append(",")
66         .append("deviceToken=").append(deviceToken).append(",")
67         .append("tokenHMac=").append(tokenHMac).append(",")
68         .append("currentVersionList=").append(currentVersionList).append(",")
69         .append("authTime=").append(std::to_string(authTime)).append(",");
70     }
71 };
72 } // namespace UpdateEngine
73 } // namespace OHOS
74 #endif // FIRMWARE_TASK_H
75