1 /* 2 * Copyright (c) 2021 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 IUPDATE_SERVICE_H 17 #define IUPDATE_SERVICE_H 18 19 #include <iostream> 20 #include "update_helper.h" 21 #include "iremote_broker.h" 22 #include "iremote_proxy.h" 23 #include "iupdate_callback.h" 24 25 namespace OHOS { 26 namespace UpdateEngine { 27 class IUpdateService : public OHOS::IRemoteBroker { 28 public: 29 enum { 30 CHECK_VERSION = 1, 31 DOWNLOAD, 32 PAUSE_DOWNLOAD, 33 RESUME_DOWNLOAD, 34 UPGRADE, 35 CLEAR_ERROR, 36 TERMINATE_UPGRADE, 37 SET_POLICY, 38 GET_POLICY, 39 GET_NEW_VERSION, 40 GET_NEW_VERSION_DESCRIPTION, 41 GET_CURRENT_VERSION, 42 GET_CURRENT_VERSION_DESCRIPTION, 43 GET_TASK_INFO, 44 REGISTER_CALLBACK, 45 UNREGISTER_CALLBACK, 46 CANCEL, 47 FACTORY_RESET, 48 APPLY_NEW_VERSION, 49 VERIFY_UPGRADE_PACKAGE 50 }; 51 52 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Updater.IUpdateService"); 53 public: 54 virtual int32_t RegisterUpdateCallback(const UpgradeInfo &info, const sptr<IUpdateCallback>& updateCallback) = 0; 55 56 virtual int32_t UnregisterUpdateCallback(const UpgradeInfo &info) = 0; 57 58 virtual int32_t CheckNewVersion(const UpgradeInfo &info) = 0; 59 60 virtual int32_t DownloadVersion(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo, 61 const DownloadOptions &downloadOptions, BusinessError &businessError) = 0; 62 63 virtual int32_t PauseDownload(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo, 64 const PauseDownloadOptions &pauseDownloadOptions, BusinessError &businessError) = 0; 65 66 virtual int32_t ResumeDownload(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo, 67 const ResumeDownloadOptions &resumeDownloadOptions, BusinessError &businessError) = 0; 68 69 virtual int32_t DoUpdate(const UpgradeInfo &info, const VersionDigestInfo &versionDigest, 70 const UpgradeOptions &upgradeOptions, BusinessError &businessError) = 0; 71 72 virtual int32_t ClearError(const UpgradeInfo &info, const VersionDigestInfo &versionDigest, 73 const ClearOptions &clearOptions, BusinessError &businessError) = 0; 74 75 virtual int32_t TerminateUpgrade(const UpgradeInfo &info, BusinessError &businessError) = 0; 76 77 virtual int32_t GetNewVersion(const UpgradeInfo &info, NewVersionInfo &newVersionInfo, 78 BusinessError &businessError) = 0; 79 80 virtual int32_t GetNewVersionDescription(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo, 81 const DescriptionOptions &descriptionOptions, VersionDescriptionInfo &newVersionDescriptionInfo, 82 BusinessError &businessError) = 0; 83 84 virtual int32_t GetCurrentVersionInfo(const UpgradeInfo &info, CurrentVersionInfo ¤tVersionInfo, 85 BusinessError &businessError) = 0; 86 87 virtual int32_t GetCurrentVersionDescription(const UpgradeInfo &info, const DescriptionOptions &descriptionOptions, 88 VersionDescriptionInfo ¤tVersionDescriptionInfo, BusinessError &businessError) = 0; 89 90 virtual int32_t GetTaskInfo(const UpgradeInfo &info, TaskInfo &taskInfo, BusinessError &businessError) = 0; 91 92 virtual int32_t SetUpgradePolicy(const UpgradeInfo &info, const UpgradePolicy &policy, 93 BusinessError &businessError) = 0; 94 95 virtual int32_t GetUpgradePolicy(const UpgradeInfo &info, UpgradePolicy &policy, BusinessError &businessError) = 0; 96 97 virtual int32_t Cancel(const UpgradeInfo &info, int32_t service, BusinessError &businessError) = 0; 98 99 virtual int32_t FactoryReset(BusinessError &businessError) = 0; 100 101 virtual int32_t ApplyNewVersion(const UpgradeInfo &info, const std::string &miscFile, 102 const std::string &packageName, BusinessError &businessError) = 0; 103 104 virtual int32_t VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath, 105 BusinessError &businessError) = 0; 106 }; 107 } // namespace UpdateEngine 108 } // namespace OHOS 109 #endif // IUPDATE_SERVICE_H 110