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 UPDATE_SERVICE_KITS_H
17#define UPDATE_SERVICE_KITS_H
18
19#include <iostream>
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 "update_callback_info.h"
32#include "upgrade_info.h"
33#include "upgrade_options.h"
34#include "upgrade_policy.h"
35#include "task_info.h"
36#include "version_description_info.h"
37#include "version_digest_info.h"
38
39namespace OHOS::UpdateEngine {
40class UpdateServiceKits {
41public:
42    UpdateServiceKits() = default;
43    virtual ~UpdateServiceKits() = default;
44    DISALLOW_COPY_AND_MOVE(UpdateServiceKits);
45
46    /**
47     * Get instance of ohos account manager.
48     *
49     * @return Instance of ohos account manager.
50     */
51    static UpdateServiceKits& GetInstance();
52
53    virtual int32_t RegisterUpdateCallback(const UpgradeInfo &info, const UpdateCallbackInfo &cb) = 0;
54
55    virtual int32_t UnregisterUpdateCallback(const UpgradeInfo &info) = 0;
56
57    virtual int32_t CheckNewVersion(const UpgradeInfo &info, BusinessError &businessError,
58        CheckResult &checkResult) = 0;
59
60    virtual int32_t Download(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 Upgrade(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 GetNewVersionInfo(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 &currentVersionInfo,
85        BusinessError &businessError) = 0;
86
87    virtual int32_t GetCurrentVersionDescription(const UpgradeInfo &info, const DescriptionOptions &descriptionOptions,
88        VersionDescriptionInfo &currentVersionDescriptionInfo, 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::vector<std::string> &packageNames, BusinessError &businessError) = 0;
103
104    virtual int32_t VerifyUpgradePackage(const std::string &packagePath, const std::string &keyPath,
105        BusinessError &businessError) = 0;
106};
107} // namespace OHOS::UpdateEngine
108#endif // UPDATE_SERVICE_KITS_H
109