1600cc4afSopenharmony_ci/*
2600cc4afSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3600cc4afSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4600cc4afSopenharmony_ci * you may not use this file except in compliance with the License.
5600cc4afSopenharmony_ci * You may obtain a copy of the License at
6600cc4afSopenharmony_ci *
7600cc4afSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8600cc4afSopenharmony_ci *
9600cc4afSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10600cc4afSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11600cc4afSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12600cc4afSopenharmony_ci * See the License for the specific language governing permissions and
13600cc4afSopenharmony_ci * limitations under the License.
14600cc4afSopenharmony_ci */
15600cc4afSopenharmony_ci
16600cc4afSopenharmony_ci#ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_INSTALLER_H
17600cc4afSopenharmony_ci#define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_INSTALLER_H
18600cc4afSopenharmony_ci
19600cc4afSopenharmony_ci#include <memory>
20600cc4afSopenharmony_ci#include <string>
21600cc4afSopenharmony_ci#include <vector>
22600cc4afSopenharmony_ci
23600cc4afSopenharmony_ci#include "nocopyable.h"
24600cc4afSopenharmony_ci
25600cc4afSopenharmony_ci#include "base_bundle_installer.h"
26600cc4afSopenharmony_ci#include "status_receiver_interface.h"
27600cc4afSopenharmony_ci
28600cc4afSopenharmony_cinamespace OHOS {
29600cc4afSopenharmony_cinamespace AppExecFwk {
30600cc4afSopenharmony_ciclass BundleInstaller : public BaseBundleInstaller {
31600cc4afSopenharmony_cipublic:
32600cc4afSopenharmony_ci    BundleInstaller(const int64_t installerId, const sptr<IStatusReceiver> &statusReceiver);
33600cc4afSopenharmony_ci    virtual ~BundleInstaller() override;
34600cc4afSopenharmony_ci    /**
35600cc4afSopenharmony_ci     * @brief Get the installer ID of an installer object.
36600cc4afSopenharmony_ci     * @return Returns the installer ID of this object.
37600cc4afSopenharmony_ci     */
38600cc4afSopenharmony_ci    int64_t GetInstallerId() const
39600cc4afSopenharmony_ci    {
40600cc4afSopenharmony_ci        return installerId_;
41600cc4afSopenharmony_ci    }
42600cc4afSopenharmony_ci    /**
43600cc4afSopenharmony_ci     * @brief Install a bundle using this installer object.
44600cc4afSopenharmony_ci     * @param bundleFilePath Indicates the path for storing the HAP of the bundle to install or update.
45600cc4afSopenharmony_ci     * @param installParam Indicates the install parameters.
46600cc4afSopenharmony_ci     * @return
47600cc4afSopenharmony_ci     */
48600cc4afSopenharmony_ci    void Install(const std::string &bundleFilePath, const InstallParam &installParam);
49600cc4afSopenharmony_ci    /**
50600cc4afSopenharmony_ci     * @brief Install a bundle by bundleName.
51600cc4afSopenharmony_ci     * @param bundleName Indicates the bundleName of the bundle to install.
52600cc4afSopenharmony_ci     * @param installParam Indicates the install parameters.
53600cc4afSopenharmony_ci     * @return
54600cc4afSopenharmony_ci     */
55600cc4afSopenharmony_ci    void Recover(const std::string &bundleName, const InstallParam &installParam);
56600cc4afSopenharmony_ci    /**
57600cc4afSopenharmony_ci     * @brief Install a bundle using this installer object.
58600cc4afSopenharmony_ci     * @param bundleFilePaths Indicates the paths for storing the HAP of the bundle to install or update.
59600cc4afSopenharmony_ci     * @param installParam Indicates the install parameters.
60600cc4afSopenharmony_ci     * @return
61600cc4afSopenharmony_ci     */
62600cc4afSopenharmony_ci    void Install(const std::vector<std::string> &bundleFilePaths, const InstallParam &installParam);
63600cc4afSopenharmony_ci    /**
64600cc4afSopenharmony_ci     * @brief Install a bundle by bundleName.
65600cc4afSopenharmony_ci     * @param bundleName Indicates the bundleName of the bundle to install.
66600cc4afSopenharmony_ci     * @param installParam Indicates the install parameters.
67600cc4afSopenharmony_ci     * @return
68600cc4afSopenharmony_ci     */
69600cc4afSopenharmony_ci    void InstallByBundleName(const std::string &bundleName, const InstallParam &installParam);
70600cc4afSopenharmony_ci    /**
71600cc4afSopenharmony_ci     * @brief Uninstall a bundle using this installer object.
72600cc4afSopenharmony_ci     * @param bundleName Indicates the bundle name of the application to uninstall.
73600cc4afSopenharmony_ci     * @param installParam Indicates the uninstall parameters.
74600cc4afSopenharmony_ci     * @return
75600cc4afSopenharmony_ci     */
76600cc4afSopenharmony_ci    void Uninstall(const std::string &bundleName, const InstallParam &installParam);
77600cc4afSopenharmony_ci    /**
78600cc4afSopenharmony_ci     * @brief Uninstall a module using this installer object.
79600cc4afSopenharmony_ci     * @param bundleName Indicates the bundle name of the module to uninstall.
80600cc4afSopenharmony_ci     * @param modulePackage Indicates the module package of the module to uninstall.
81600cc4afSopenharmony_ci     * @param installParam Indicates the uninstall parameters.
82600cc4afSopenharmony_ci     * @return
83600cc4afSopenharmony_ci     */
84600cc4afSopenharmony_ci    void Uninstall(const std::string &bundleName, const std::string &modulePackage, const InstallParam &installParam);
85600cc4afSopenharmony_ci    /**
86600cc4afSopenharmony_ci     * @brief Uninstall a bundle by uninstallParam.
87600cc4afSopenharmony_ci     * @param uninstallParam Indicates the input uninstallParam.
88600cc4afSopenharmony_ci     * @return
89600cc4afSopenharmony_ci     */
90600cc4afSopenharmony_ci    void Uninstall(const UninstallParam &uninstallParam);
91600cc4afSopenharmony_ci    /**
92600cc4afSopenharmony_ci     * @brief Update the installer state and send status from the StatusReceiver object.
93600cc4afSopenharmony_ci     * @attention This function will send the install status to StatusReceiver.
94600cc4afSopenharmony_ci     * @param state Indicates the state to be updated to.
95600cc4afSopenharmony_ci     * @return
96600cc4afSopenharmony_ci     */
97600cc4afSopenharmony_ci    virtual void UpdateInstallerState(const InstallerState state) override;
98600cc4afSopenharmony_ci    void UpdateBundleForSelf(const std::vector<std::string> &bundleFilePaths, const InstallParam &installParam);
99600cc4afSopenharmony_ci
100600cc4afSopenharmony_ci    void UninstallAndRecover(const std::string &bundleName, const InstallParam &installParam);
101600cc4afSopenharmony_ci
102600cc4afSopenharmony_ciprivate:
103600cc4afSopenharmony_ci    /**
104600cc4afSopenharmony_ci     * @brief Get all exist common userId.
105600cc4afSopenharmony_ci     * @attention This function will get all exist common userId.
106600cc4afSopenharmony_ci     * @return Returns all exist common userId
107600cc4afSopenharmony_ci     */
108600cc4afSopenharmony_ci    std::set<int32_t> GetExistsCommonUserIds();
109600cc4afSopenharmony_ci
110600cc4afSopenharmony_ci    void InstallDriverForAllUsers(const std::string &bundleFilePath, const InstallParam &installParam);
111600cc4afSopenharmony_ci
112600cc4afSopenharmony_ci    void InstallDriverForAllUsers(const std::vector<std::string> &bundleFilePaths, const InstallParam &installParam);
113600cc4afSopenharmony_ci
114600cc4afSopenharmony_ci    void RecoverDriverForAllUsers(const std::string &bundleName, const InstallParam &installParam);
115600cc4afSopenharmony_ci
116600cc4afSopenharmony_ciprivate:
117600cc4afSopenharmony_ci    const int64_t installerId_ = 0;
118600cc4afSopenharmony_ci    const sptr<IStatusReceiver> statusReceiver_;
119600cc4afSopenharmony_ci
120600cc4afSopenharmony_ci    DISALLOW_COPY_AND_MOVE(BundleInstaller);
121600cc4afSopenharmony_ci};
122600cc4afSopenharmony_ci}  // namespace AppExecFwk
123600cc4afSopenharmony_ci}  // namespace OHOS
124600cc4afSopenharmony_ci#endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_INSTALLER_H