1 /* 2 * Copyright (c) 2022 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 UPDATE_SERVICE_IMPL_FIRMWARE_H 17 #define UPDATE_SERVICE_IMPL_FIRMWARE_H 18 19 #include <condition_variable> 20 21 #include "iservice_online_updater.h" 22 23 #include "firmware_preferences_utils.h" 24 #include "firmware_task.h" 25 #include "update_helper.h" 26 27 namespace OHOS { 28 namespace UpdateEngine { 29 class UpdateServiceImplFirmware final : public IServiceOnlineUpdater { 30 public: 31 UpdateServiceImplFirmware() = default; 32 33 ~UpdateServiceImplFirmware() = default; 34 35 DISALLOW_COPY_AND_MOVE(UpdateServiceImplFirmware); 36 37 int32_t CheckNewVersion(const UpgradeInfo &info, BusinessError &businessError, CheckResult &checkResult) final; 38 39 int32_t Download(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo, 40 const DownloadOptions &downloadOptions, BusinessError &businessError) final; 41 42 int32_t PauseDownload(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo, 43 const PauseDownloadOptions &pauseDownloadOptions, BusinessError &businessError) final; 44 45 int32_t ResumeDownload(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo, 46 const ResumeDownloadOptions &resumeDownloadOptions, BusinessError &businessError) final; 47 48 int32_t Upgrade(const UpgradeInfo &info, const VersionDigestInfo &versionDigest, 49 const UpgradeOptions &upgradeOptions, BusinessError &businessError) final; 50 51 int32_t ClearError(const UpgradeInfo &info, const VersionDigestInfo &versionDigest, 52 const ClearOptions &clearOptions, BusinessError &businessError) final; 53 54 int32_t TerminateUpgrade(const UpgradeInfo &info, BusinessError &businessError) final; 55 56 int32_t GetNewVersionInfo( 57 const UpgradeInfo &info, NewVersionInfo &newVersionInfo, BusinessError &businessError) final; 58 59 int32_t GetNewVersionDescription(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo, 60 const DescriptionOptions &descriptionOptions, VersionDescriptionInfo &newVersionDescriptionInfo, 61 BusinessError &businessError) final; 62 63 int32_t GetCurrentVersionInfo(const UpgradeInfo &info, CurrentVersionInfo ¤tVersionInfo, 64 BusinessError &businessError) final; 65 66 int32_t GetCurrentVersionDescription(const UpgradeInfo &info, const DescriptionOptions &descriptionOptions, 67 VersionDescriptionInfo ¤tVersionDescriptionInfo, BusinessError &businessError) final; 68 69 int32_t GetTaskInfo(const UpgradeInfo &info, TaskInfo &taskInfo, BusinessError &businessError) final; 70 71 int32_t SetUpgradePolicy(const UpgradeInfo &info, const UpgradePolicy &policy, 72 BusinessError &businessError) final; 73 74 int32_t GetUpgradePolicy(const UpgradeInfo &info, UpgradePolicy &policy, BusinessError &businessError) final; 75 76 int32_t Cancel(const UpgradeInfo &info, int32_t service, BusinessError &businessError) final; 77 78 private: 79 std::shared_ptr<FirmwarePreferencesUtil> preferencesUtil_ = 80 DelayedSingleton<FirmwarePreferencesUtil>::GetInstance(); 81 std::condition_variable conditionVariable_; 82 std::mutex checkNewVersionMutex_; 83 bool checkComplete_ = false; 84 void GetChangelogContent(std::string &dataXml, const std::string &language); 85 }; 86 } // namespace UpdateEngine 87 } // namespace OHOS 88 #endif // UPDATE_SERVICE_IMPL_FIRMWARE_H