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_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 25 class InstalldHostImpl : public InstalldHost { 26 public: 27 InstalldHostImpl(); 28 virtual ~InstalldHostImpl(); 29 /** 30 * @brief Create a bundle code directory. 31 * @param bundleDir Indicates the bundle code directory path that to be created. 32 * @return Returns ERR_OK if the bundle directory created successfully; returns error code otherwise. 33 */ 34 virtual ErrCode CreateBundleDir(const std::string &bundleDir) override; 35 /** 36 * @brief Remove a bundle code directory. 37 * @param bundleDir Indicates the bundle code directory path that to be removed. 38 * @return Returns ERR_OK if the bundle directory removed successfully; returns error code otherwise. 39 */ 40 virtual ErrCode RemoveBundleDir(const std::string &bundleDir) override; 41 /** 42 * @brief Extract the files of a HAP module to the code directory. 43 * @param srcModulePath Indicates the HAP file path. 44 * @param targetPath Indicates the code directory path that the HAP to be extracted to. 45 * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise. 46 */ 47 virtual ErrCode ExtractModuleFiles(const std::string &srcModulePath, const std::string &targetPath) override; 48 /** 49 * @brief Rename the module directory from temporaily path to the real path. 50 * @param oldPath Indicates the old path name. 51 * @param newPath Indicates the new path name. 52 * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise. 53 */ 54 virtual ErrCode RenameModuleDir(const std::string &oldPath, const std::string &newPath) override; 55 /** 56 * @brief Remove the module directory. 57 * @param moduleDir Indicates the module directory to be removed. 58 * @return Returns ERR_OK if the module directory removed successfully; returns error code otherwise. 59 */ 60 virtual ErrCode RemoveModuleDir(const std::string &moduleDir) override; 61 /** 62 * @brief Create a bundle data directory. 63 * @param bundleDir Indicates the bundle data directory path that to be created. 64 * @param uid Indicates uid to be set to the directory. 65 * @param gid Indicates gid to be set to the directory. 66 * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise. 67 */ 68 virtual ErrCode CreateBundleDataDir(const std::string &bundleDir, const int uid, const int gid) override; 69 /** 70 * @brief Remove a bundle data directory. 71 * @param bundleDir Indicates the bundle data directory path that to be removed. 72 * @return Returns ERR_OK if the bundle data directory removed successfully; returns error code otherwise. 73 */ 74 virtual ErrCode RemoveBundleDataDir(const std::string &bundleDataDir) override; 75 /** 76 * @brief Create a module and it's abilities data directory. 77 * @param bundleDir Indicates the module data directory path that to be created. 78 * @param abilityDirs Indicates the abilities data directory name that to be created. 79 * @param uid Indicates uid to be set to the directory. 80 * @param gid Indicates gid to be set to the directory. 81 * @return Returns ERR_OK if the data directories created successfully; returns error code otherwise. 82 */ 83 virtual ErrCode CreateModuleDataDir(const std::string &ModuleDir, const std::vector<std::string> &abilityDirs, 84 const int uid, const int gid) override; 85 /** 86 * @brief Remove a module data directory. 87 * @param bundleDir Indicates the module data directory path that to be removed. 88 * @return Returns ERR_OK if the module data directory removed successfully; returns error code otherwise. 89 */ 90 virtual ErrCode RemoveModuleDataDir(const std::string &moduleDataDir) override; 91 /** 92 * @brief Clean all files in a bundle data directory. 93 * @param bundleDir Indicates the data directory path that to be cleaned. 94 * @return Returns ERR_OK if the data directory cleaned successfully; returns error code otherwise. 95 */ 96 virtual ErrCode CleanBundleDataDir(const std::string &bundleDir) override; 97 }; 98 99 } // namespace AppExecFwk 100 } // namespace OHOS 101 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALLD_HOST_IMPL_H