• 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_INSTALLD_HOST_IMPL_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALLD_HOST_IMPL_H
18 
19 #include "ipc/installd_host.h"
20 #include "installd/installd_operator.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 class InstalldHostImpl : public InstalldHost {
25 public:
26     InstalldHostImpl();
27     virtual ~InstalldHostImpl();
28     /**
29      * @brief Create a bundle code directory.
30      * @param bundleDir Indicates the bundle code directory path that to be created.
31      * @return Returns ERR_OK if the bundle directory created successfully; returns error code otherwise.
32      */
33     virtual ErrCode CreateBundleDir(const std::string &bundleDir) override;
34     /**
35      * @brief Extract the files of a HAP module to the code directory.
36      * @param srcModulePath Indicates the HAP file path.
37      * @param targetPath normal files decompression path.
38      * @param targetSoPath so files decompression path.
39      * @param cpuAbi cpuAbi.
40      * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise.
41      */
42     virtual ErrCode ExtractModuleFiles(const std::string &srcModulePath, const std::string &targetPath,
43         const std::string &targetSoPath, const std::string &cpuAbi) override;
44     /**
45      * @brief Extract the files.
46      * @param extractParam Indicates the extractParam.
47      * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise.
48      */
49     virtual ErrCode ExtractFiles(const ExtractParam &extractParam) override;
50     /**
51      * @brief Rename the module directory from temporaily path to the real path.
52      * @param oldPath Indicates the old path name.
53      * @param newPath Indicates the new path name.
54      * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise.
55      */
56     virtual ErrCode RenameModuleDir(const std::string &oldPath, const std::string &newPath) override;
57     /**
58      * @brief Create a bundle data directory.
59      * @param bundleName Indicates bundleName to be set to the directory.
60      * @param userid Indicates userid to be set to the directory.
61      * @param uid Indicates uid to be set to the directory.
62      * @param gid Indicates gid to be set to the directory.
63      * @param apl Indicates apl to be set to the directory.
64      * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise.
65      */
66     virtual ErrCode CreateBundleDataDir(const std::string &bundleName, const int userid,
67         const int uid, const int gid, const std::string &apl) override;
68     /**
69      * @brief Remove a bundle data directory.
70      * @param bundleName Indicates the bundleName data directory path that to be created.
71      * @param userid Indicates userid to be set to the directory.
72      * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise.
73      */
74     virtual ErrCode RemoveBundleDataDir(
75         const std::string &bundleName, const int userid) override;
76     /**
77      * @brief Remove a module data directory.
78      * @param ModuleDir Indicates the module data directory path that to be created.
79      * @param userid Indicates userid to be set to the directory.
80      * @return Returns ERR_OK if the data directories created successfully; returns error code otherwise.
81      */
82     virtual ErrCode RemoveModuleDataDir(const std::string &ModuleDir, const int userid) override;
83     /**
84      * @brief Remove a directory.
85      * @param dir Indicates the directory path that to be removed.
86      * @return Returns ERR_OK if the  directory removed successfully; returns error code otherwise.
87      */
88     virtual ErrCode RemoveDir(const std::string &dir) override;
89     /**
90      * @brief Clean all files in a bundle data directory.
91      * @param bundleDir Indicates the data directory path that to be cleaned.
92      * @return Returns ERR_OK if the data directory cleaned successfully; returns error code otherwise.
93      */
94     virtual ErrCode CleanBundleDataDir(const std::string &bundleDir) override;
95     /**
96      * @brief Get bundle Stats.
97      * @param bundleName Indicates the bundle name.
98      * @param userId Indicates the user Id.
99      * @param bundleStats Indicates the bundle Stats.
100      * @return Returns ERR_OK if get stats successfully; returns error code otherwise.
101      */
102     virtual ErrCode GetBundleStats(
103         const std::string &bundleName, const int32_t userId, std::vector<int64_t> &bundleStats) override;
104     /**
105      * @brief Set dir apl.
106      * @param dir Indicates the data dir.
107      * @param bundleName Indicates the bundle name.
108      * @param apl Indicates the apl type.
109      * @return Returns ERR_OK if set apl successfully; returns error code otherwise.
110      */
111     virtual ErrCode SetDirApl(const std::string &dir, const std::string &bundleName, const std::string &apl) override;
112 
113     /**
114      * @brief Get all cache file path.
115      * @param dir Indicates the data dir.
116      * @param cachesPath Indicates the cache file path.
117      * @return Returns ERR_OK if get cache file path successfully; returns error code otherwise.
118      */
119     virtual ErrCode GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath) override;
120 
121     virtual ErrCode ScanDir(
122         const std::string &dir, ScanMode scanMode, ResultMode resultMode, std::vector<std::string> &paths) override;
123 
124     virtual ErrCode MoveFile(const std::string &oldPath, const std::string &newPath) override;
125 
126     virtual ErrCode CopyFile(const std::string &oldPath, const std::string &newPath) override;
127 
128     virtual ErrCode Mkdir(
129         const std::string &dir, const int32_t mode, const int32_t uid, const int32_t gid) override;
130 
131     virtual ErrCode GetFileStat(const std::string &file, FileStat &fileStat) override;
132 
133     virtual ErrCode ExtractDiffFiles(const std::string &filePath, const std::string &targetPath,
134         const std::string &cpuAbi) override;
135 
136     virtual ErrCode ApplyDiffPatch(const std::string &oldSoPath, const std::string &diffFilePath,
137         const std::string &newSoPath) override;
138 
139     virtual ErrCode IsExistDir(const std::string &dir, bool &isExist) override;
140 
141     virtual ErrCode IsDirEmpty(const std::string &dir, bool &isDirEmpty) override;
142 
143     virtual ErrCode ObtainQuickFixFileDir(const std::string &dir, std::vector<std::string> &dirVec) override;
144 
145     virtual ErrCode CopyFiles(const std::string &sourceDir, const std::string &destinationDir) override;
146 
147 private:
148     std::string GetBundleDataDir(const std::string &el, const int userid) const;
149 };
150 }  // namespace AppExecFwk
151 }  // namespace OHOS
152 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALLD_HOST_IMPL_H