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