• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_INTERFACE_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_INTERFACE_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "iremote_broker.h"
23 
24 #include "appexecfwk_errors.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 
29 class IInstalld : public IRemoteBroker {
30 public:
31     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.Installd");
32     /**
33      * @brief Create a bundle code directory.
34      * @param bundleDir Indicates the bundle code directory path that to be created.
35      * @return Returns ERR_OK if the bundle directory created successfully; returns error code otherwise.
36      */
37     virtual ErrCode CreateBundleDir(const std::string &bundleDir) = 0;
38     /**
39      * @brief Remove a bundle code directory.
40      * @param bundleDir Indicates the bundle code directory path that to be removed.
41      * @return Returns ERR_OK if the bundle directory removed successfully; returns error code otherwise.
42      */
43     virtual ErrCode RemoveBundleDir(const std::string &bundleDir) = 0;
44     /**
45      * @brief Extract the files of a HAP module to the code directory.
46      * @param srcModulePath Indicates the HAP file path.
47      * @param targetPath Indicates the code directory path that the HAP to be extracted to.
48      * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise.
49      */
50     virtual ErrCode ExtractModuleFiles(const std::string &srcModulePath, const std::string &destPath) = 0;
51     /**
52      * @brief Remove the module directory.
53      * @param moduleDir Indicates the module directory to be removed.
54      * @return Returns ERR_OK if the module directory removed successfully; returns error code otherwise.
55      */
56     virtual ErrCode RemoveModuleDir(const std::string &moduleDir) = 0;
57     /**
58      * @brief Rename the module directory from temporaily path to the real path.
59      * @param oldPath Indicates the old path name.
60      * @param newPath Indicates the new path name.
61      * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise.
62      */
63     virtual ErrCode RenameModuleDir(const std::string &oldDir, const std::string &newDir) = 0;
64     /**
65      * @brief Create a bundle data directory.
66      * @param bundleDir Indicates the bundle data directory path that to be created.
67      * @param uid Indicates uid to be set to the directory.
68      * @param gid Indicates gid to be set to the directory.
69      * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise.
70      */
71     virtual ErrCode CreateBundleDataDir(const std::string &bundleDir, const int uid, const int gid) = 0;
72     /**
73      * @brief Remove a bundle data directory.
74      * @param bundleDir Indicates the bundle data directory path that to be removed.
75      * @return Returns ERR_OK if the bundle data directory removed successfully; returns error code otherwise.
76      */
77     virtual ErrCode RemoveBundleDataDir(const std::string &bundleDataDir) = 0;
78     /**
79      * @brief Create a module and it's abilities data directory.
80      * @param bundleDir Indicates the module data directory path that to be created.
81      * @param abilityDirs Indicates the abilities data directory name that to be created.
82      * @param uid Indicates uid to be set to the directory.
83      * @param gid Indicates gid to be set to the directory.
84      * @return Returns ERR_OK if the data directories created successfully; returns error code otherwise.
85      */
86     virtual ErrCode CreateModuleDataDir(
87         const std::string &ModuleDir, const std::vector<std::string> &abilityDirs, const int uid, const int gid) = 0;
88     /**
89      * @brief Remove a module data directory.
90      * @param bundleDir Indicates the module data directory path that to be removed.
91      * @return Returns ERR_OK if the module data directory removed successfully; returns error code otherwise.
92      */
93     virtual ErrCode RemoveModuleDataDir(const std::string &moduleDataDir) = 0;
94     /**
95      * @brief Clean all files in a bundle data directory.
96      * @param bundleDir Indicates the data directory path that to be cleaned.
97      * @return Returns ERR_OK if the data directory cleaned successfully; returns error code otherwise.
98      */
99     virtual ErrCode CleanBundleDataDir(const std::string &bundleDir) = 0;
100 
101     enum class Message {
102         CREATE_BUNDLE_DIR = 1,
103         REMOVE_BUNDLE_DIR,
104         EXTRACT_MODULE_FILES,
105         REMOVE_MODULE_DIR,
106         RENAME_MODULE_DIR,
107         CREATE_BUNDLE_DATA_DIR,
108         REMOVE_BUNDLE_DATA_DIR,
109         CREATE_MODULE_DATA_DIR,
110         REMOVE_MODULE_DATA_DIR,
111         CLEAN_BUNDLE_DATA_DIR,
112     };
113 };
114 
115 }  // namespace AppExecFwk
116 }  // namespace OHOS
117 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_INTERFACE_H