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_UPDATE_HELPER_H 17 #define FIRMWARE_UPDATE_HELPER_H 18 19 #include <algorithm> 20 21 #include "current_version_info.h" 22 #include "firmware_changelog_utils.h" 23 #include "firmware_constant.h" 24 #include "firmware_combine_version_utils.h" 25 #include "firmware_common.h" 26 #include "firmware_component.h" 27 #include "firmware_component_operator.h" 28 #include "firmware_file_utils.h" 29 #include "firmware_log.h" 30 #include "firmware_preferences_utils.h" 31 #include "firmware_task_operator.h" 32 #include "device_adapter.h" 33 #include "sha256_utils.h" 34 #include "time_utils.h" 35 #include "version_component.h" 36 37 namespace OHOS { 38 namespace UpdateService { 39 class FirmwareUpdateHelper { 40 public: 41 static bool IsBatteryEnough(int32_t batteryLimit); 42 static bool IsUpgradePackagesReady(const std::vector<FirmwareComponent> &componentList); 43 44 static void ClearFirmwareInfo(); 45 static void BuildCurrentVersionInfo(CurrentVersionInfo ¤tVersionInfo); 46 static void BuildNewVersionInfo(const std::vector<FirmwareComponent> &components, 47 std::vector<VersionComponent> &versionComponents); 48 static bool IsUpgradeFailed(UpgradeStatus status); 49 static std::string BuildTaskId(const std::vector<FirmwareComponent> &componentList); 50 static InstallType GetInstallType(); 51 static bool IsStreamUpgrade(); 52 static bool IsStreamUpgrade(const std::vector<FirmwareComponent> &componentList); 53 54 private: 55 static VersionComponent BuildHotaVersionComponent(std::vector<FirmwareComponent> &hotaComponents); 56 }; 57 } // namespace UpdateService 58 } // namespace OHOS 59 #endif // FIRMWARE_UPDATE_HELPER_H