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_COMPONENT_H 17 #define FIRMWARE_COMPONENT_H 18 19 #include <string> 20 21 #include "package_type.h" 22 #include "ota_type.h" 23 #include "update_define.h" 24 #include "upgrade_status.h" 25 26 namespace OHOS { 27 namespace UpdateService { 28 struct FirmwareComponent { 29 int32_t id = 0; 30 31 std::string versionId; // 标识包的唯一性 32 int32_t packageIndex = 0; // 包的安装顺序 33 PackageType versionPackageType = PackageType::DYNAMIC; 34 OtaType otaType = OtaType::REGULAR; 35 36 std::string targetBlVersionNumber; 37 std::string targetBlDisplayVersionNumber; 38 39 std::string versionNumber; // 包文件本身的versionNumber 40 41 std::string blVersionInfo; 42 std::string componentId; 43 std::string descriptPackageId; 44 std::string changelogUrl; 45 int32_t blVersionType = 0; 46 47 bool isNeedRestart; 48 int32_t patchType = 0; 49 std::string url; 50 std::string reserveUrl; 51 int32_t storageType = 0; // 内测或商用版本 52 53 std::string fileName; // 包的名字,来自filelist 54 int64_t size = 0; // 包大小,来自filelist 55 std::string verifyInfo; // 包的sha256值,来自filelist 56 std::string spath; 57 58 UpgradeStatus status = UpgradeStatus::INIT; 59 int32_t progress = 0; 60 int64_t recordPoint = 0; 61 ToStringFirmwareComponent62 std::string ToString() 63 { 64 return std::string("FirmwareComponent: ") 65 .append("id=").append(std::to_string(id)).append(",") 66 .append("versionId=").append(versionId).append(",") 67 .append("packageIndex=").append(std::to_string(packageIndex)).append(",") 68 .append("versionPackageType=").append(std::to_string(CAST_INT(versionPackageType))).append(",") 69 .append("otaType=").append(std::to_string(CAST_INT(otaType))).append(",") 70 .append("targetBlVersionNumber=").append(targetBlVersionNumber).append(",") 71 .append("targetBlDisplayVersionNumber=").append(targetBlDisplayVersionNumber).append(",") 72 .append("versionNumber=").append(versionNumber).append(",") 73 .append("blVersionInfo=").append(blVersionInfo).append(",") 74 .append("componentId=").append(componentId).append(",") 75 .append("descriptPackageId=").append(descriptPackageId).append(",") 76 .append("changelogUrl=").append(changelogUrl).append(",") 77 .append("blVersionType=").append(std::to_string(blVersionType)).append(",") 78 .append("isNeedRestart=").append(std::to_string(isNeedRestart)).append(",") 79 .append("patchType=").append(std::to_string(patchType)).append(",") 80 .append("url=").append(url).append(",") 81 .append("reserveUrl=").append(reserveUrl).append(",") 82 .append("storageType=").append(std::to_string(storageType)).append(",") 83 .append("fileName=").append(fileName).append(",") 84 .append("size=").append(std::to_string(size)).append(",") 85 .append("verifyInfo=").append(verifyInfo).append(",") 86 .append("spath=").append(spath).append(",") 87 .append("status=").append(std::to_string(CAST_INT(status))).append(",") 88 .append("progress=").append(std::to_string(progress)).append(",") 89 .append("recordPoint=").append(std::to_string(recordPoint)); 90 } 91 }; 92 } // namespace UpdateService 93 } // namespace OHOS 94 #endif // FIRMWARE_COMPONENT_H 95