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