• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_PROXY_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_PROXY_H
18 
19 #include <string>
20 
21 #include "iremote_proxy.h"
22 #include "appexecfwk_errors.h"
23 #include "ipc/installd_interface.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 class InstalldProxy : public IRemoteProxy<IInstalld> {
28 public:
29     explicit InstalldProxy(const sptr<IRemoteObject> &object);
30     virtual ~InstalldProxy() override;
31     /**
32      * @brief Create a bundle code directory through a proxy object.
33      * @param bundleDir Indicates the bundle code directory path that to be created.
34      * @return Returns ERR_OK if the bundle directory created successfully; returns error code otherwise.
35      */
36     virtual ErrCode CreateBundleDir(const std::string &bundlePath) override;
37     /**
38      * @brief Extract the files of a HAP module to the code directory through a proxy object.
39      * @param srcModulePath Indicates the HAP file path.
40      * @param targetPath normal files decompression path.
41      * @param targetSoPath so files decompression path.
42      * @param cpuAbi cpuAbi.
43      * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise.
44      */
45     virtual ErrCode ExtractModuleFiles(const std::string &srcModulePath, const std::string &targetPath,
46         const std::string &targetSoPath, const std::string &cpuAbi) override;
47     /**
48      * @brief Rename the module directory from temporaily path to the real path through a proxy object.
49      * @param oldPath Indicates the old path name.
50      * @param newPath Indicates the new path name.
51      * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise.
52      */
53     virtual ErrCode RenameModuleDir(const std::string &oldPath, const std::string &newPath) override;
54     /**
55      * @brief Create a bundle data directory through a proxy object.
56      * @param bundleDir Indicates the bundle data directory path that to be created.
57      * @param userid Indicates userid to be set to the directory.
58      * @param uid Indicates uid to be set to the directory.
59      * @param gid Indicates gid to be set to the directory.
60      * @param apl Indicates apl to be set to the directory.
61      * @param onlyOneUser Indicates is only one user or not.
62      * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise.
63      */
64     virtual ErrCode CreateBundleDataDir(const std::string &bundleDir, const int userid,
65         const int uid, const int gid, const std::string &apl, bool onlyOneUser = true) override;
66     /**
67      * @brief Remove a bundle data directory through a proxy object.
68      * @param bundleDir Indicates the bundle data directory path that to be created.
69      * @param userid Indicates userid to be set to the directory.
70      * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise.
71      */
72     virtual ErrCode RemoveBundleDataDir(const std::string &bundleDir, const int userid) override;
73     /**
74      * @brief Create a module and it's abilities data directory through a proxy object.
75      * @param bundleDir Indicates the module data directory path that to be created.
76      * @param abilityDirs Indicates the abilities data directory name that to be created.
77      * @param uid Indicates uid to be set to the directory.
78      * @param gid Indicates gid to be set to the directory.
79      * @return Returns ERR_OK if the data directories created successfully; returns error code otherwise.
80      */
81     virtual ErrCode CreateModuleDataDir(const std::string &ModuleDir, const std::vector<std::string> &abilityDirs,
82         const int uid, const int gid) override;
83     /**
84      * @brief Remove a module data directory through a proxy object.
85      * @param ModuleDir Indicates the module data directory path that to be created.
86      * @param userid Indicates userid to be set to the directory.
87      * @return Returns ERR_OK if the data directories created successfully; returns error code otherwise.
88      */
89     virtual ErrCode RemoveModuleDataDir(const std::string &ModuleDir, const int userid) override;
90     /**
91      * @brief Remove a directory through a proxy object.
92      * @param dir Indicates the directory path that to be removed.
93      * @return Returns ERR_OK if the  directory removed successfully; returns error code otherwise.
94      */
95     virtual ErrCode RemoveDir(const std::string &dir) override;
96     /**
97      * @brief Clean all files in a bundle data directory through a proxy object.
98      * @param bundleDir Indicates the data directory path that to be cleaned.
99      * @return Returns ERR_OK if the data directory cleaned successfully; returns error code otherwise.
100      */
101     virtual ErrCode CleanBundleDataDir(const std::string &bundlePath) override;
102     /**
103      * @brief Get bundle Stats.
104      * @param bundleName Indicates the bundle name.
105      * @param userId Indicates the user Id.
106      * @param bundleStats Indicates the bundle Stats.
107      * @return Returns ERR_OK if get stats successfully; returns error code otherwise.
108      */
109     virtual ErrCode GetBundleStats(
110         const std::string &bundleName, const int32_t userId, std::vector<int64_t> &bundleStats) override;
111     /**
112      * @brief Set dir apl.
113      * @param dir Indicates the data dir.
114      * @param bundleName Indicates the bundle name.
115      * @param apl Indicates the apl type.
116      * @return Returns ERR_OK if set apl successfully; returns error code otherwise.
117      */
118     virtual ErrCode SetDirApl(const std::string &dir, const std::string &bundleName, const std::string &apl) override;
119     /**
120      * @brief Get all cache file path.
121      * @param dir Indicates the data dir.
122      * @param cachesPath Indicates the cache file path.
123      * @return Returns ERR_OK if get cache file path successfully; returns error code otherwise.
124      */
125     virtual ErrCode GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath) override;
126 
127 private:
128     ErrCode TransactInstalldCmd(uint32_t code, MessageParcel &data, MessageParcel &reply,
129         MessageOption &option);
130     static inline BrokerDelegator<InstalldProxy> delegator_;
131 };
132 }  // namespace AppExecFwk
133 }  // namespace OHOS
134 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_PROXY_H