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