1 /*
2  * Copyright (c) 2024 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 ISERVICE_ONLINE_UPDATER_H
17 #define ISERVICE_ONLINE_UPDATER_H
18 
19 #include "refbase.h"
20 
21 #include "business_error.h"
22 #include "check_result.h"
23 #include "clear_options.h"
24 #include "current_version_info.h"
25 #include "description_options.h"
26 #include "download_options.h"
27 #include "iupdate_callback.h"
28 #include "pause_download_options.h"
29 #include "resume_download_options.h"
30 #include "new_version_info.h"
31 #include "upgrade_info.h"
32 #include "upgrade_options.h"
33 #include "upgrade_policy.h"
34 #include "task_info.h"
35 #include "version_description_info.h"
36 #include "version_digest_info.h"
37 
38 namespace OHOS::UpdateEngine {
39 class IServiceOnlineUpdater : public virtual RefBase {
40 public:
41     virtual ~IServiceOnlineUpdater() = default;
42 
43     virtual int32_t CheckNewVersion(const UpgradeInfo &info, BusinessError &businessError,
44         CheckResult &checkResult) = 0;
45 
46     virtual int32_t Download(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo,
47         const DownloadOptions &downloadOptions, BusinessError &businessError) = 0;
48 
49     virtual int32_t PauseDownload(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo,
50         const PauseDownloadOptions &pauseDownloadOptions, BusinessError &businessError) = 0;
51 
52     virtual int32_t ResumeDownload(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo,
53         const ResumeDownloadOptions &resumeDownloadOptions, BusinessError &businessError) = 0;
54 
55     virtual int32_t Upgrade(const UpgradeInfo &info, const VersionDigestInfo &versionDigest,
56         const UpgradeOptions &upgradeOptions, BusinessError &businessError) = 0;
57 
58     virtual int32_t ClearError(const UpgradeInfo &info, const VersionDigestInfo &versionDigest,
59         const ClearOptions &clearOptions, BusinessError &businessError) = 0;
60 
61     virtual int32_t TerminateUpgrade(const UpgradeInfo &info, BusinessError &businessError) = 0;
62 
63     virtual int32_t GetNewVersionInfo(const UpgradeInfo &info, NewVersionInfo &newVersionInfo,
64         BusinessError &businessError) = 0;
65 
66     virtual int32_t GetNewVersionDescription(const UpgradeInfo &info, const VersionDigestInfo &versionDigestInfo,
67         const DescriptionOptions &descriptionOptions, VersionDescriptionInfo &newVersionDescriptionInfo,
68         BusinessError &businessError) = 0;
69 
70     virtual int32_t GetCurrentVersionInfo(const UpgradeInfo &info, CurrentVersionInfo &currentVersionInfo,
71         BusinessError &businessError) = 0;
72 
73     virtual int32_t GetCurrentVersionDescription(const UpgradeInfo &info, const DescriptionOptions &descriptionOptions,
74         VersionDescriptionInfo &currentVersionDescriptionInfo, BusinessError &businessError) = 0;
75 
76     virtual int32_t GetTaskInfo(const UpgradeInfo &info, TaskInfo &taskInfo, BusinessError &businessError) = 0;
77 
78     virtual int32_t SetUpgradePolicy(const UpgradeInfo &info, const UpgradePolicy &policy,
79         BusinessError &businessError) = 0;
80 
81     virtual int32_t GetUpgradePolicy(const UpgradeInfo &info, UpgradePolicy &policy, BusinessError &businessError) = 0;
82 
83     virtual int32_t Cancel(const UpgradeInfo &info, int32_t service, BusinessError &businessError) = 0;
84 };
85 } // namespace OHOS::UpdateEngine
86 #endif // ISERVICE_ONLINE_UPDATER_H
87