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 virtual ErrCode ExecuteAOT(const AOTArgs &aotArgs) override; 52 /** 53 * @brief Rename the module directory from temporaily path to the real path. 54 * @param oldPath Indicates the old path name. 55 * @param newPath Indicates the new path name. 56 * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise. 57 */ 58 virtual ErrCode RenameModuleDir(const std::string &oldPath, const std::string &newPath) override; 59 /** 60 * @brief Create a bundle data directory. 61 * @param createDirParam Indicates param to be set to the directory. 62 * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise. 63 */ 64 virtual ErrCode CreateBundleDataDir(const CreateDirParam &createDirParam) override; 65 /** 66 * @brief Remove a bundle data directory. 67 * @param bundleName Indicates the bundleName data directory path that to be created. 68 * @param userid Indicates userid 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 RemoveBundleDataDir( 72 const std::string &bundleName, const int userid) override; 73 /** 74 * @brief Remove a module data directory. 75 * @param ModuleDir Indicates the module data directory path that to be created. 76 * @param userid Indicates userid to be set to the directory. 77 * @return Returns ERR_OK if the data directories created successfully; returns error code otherwise. 78 */ 79 virtual ErrCode RemoveModuleDataDir(const std::string &ModuleDir, const int userid) override; 80 /** 81 * @brief Remove a directory. 82 * @param dir Indicates the directory path that to be removed. 83 * @return Returns ERR_OK if the directory removed successfully; returns error code otherwise. 84 */ 85 virtual ErrCode RemoveDir(const std::string &dir) override; 86 /** 87 * @brief Clean all files in a bundle data directory. 88 * @param bundleDir Indicates the data directory path that to be cleaned. 89 * @return Returns ERR_OK if the data directory cleaned successfully; returns error code otherwise. 90 */ 91 virtual ErrCode CleanBundleDataDir(const std::string &bundleDir) override; 92 /** 93 * @brief Get bundle Stats. 94 * @param bundleName Indicates the bundle name. 95 * @param userId Indicates the user Id. 96 * @param bundleStats Indicates the bundle Stats. 97 * @return Returns ERR_OK if get stats successfully; returns error code otherwise. 98 */ 99 virtual ErrCode GetBundleStats( 100 const std::string &bundleName, const int32_t userId, std::vector<int64_t> &bundleStats) override; 101 /** 102 * @brief Set dir apl. 103 * @param dir Indicates the data dir. 104 * @param bundleName Indicates the bundle name. 105 * @param apl Indicates the apl type. 106 * @param isPreInstallApp Indicates the bundle install type. 107 * @param debug Indicates the bundle debug mode. 108 * @return Returns ERR_OK if set apl successfully; returns error code otherwise. 109 */ 110 virtual ErrCode SetDirApl(const std::string &dir, const std::string &bundleName, const std::string &apl, 111 bool isPreInstallApp, bool debug) 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, 127 const std::string &signatureFilePath = "") override; 128 129 virtual ErrCode Mkdir( 130 const std::string &dir, const int32_t mode, const int32_t uid, const int32_t gid) override; 131 132 virtual ErrCode GetFileStat(const std::string &file, FileStat &fileStat) override; 133 134 virtual ErrCode ExtractDiffFiles(const std::string &filePath, const std::string &targetPath, 135 const std::string &cpuAbi) override; 136 137 virtual ErrCode ApplyDiffPatch(const std::string &oldSoPath, const std::string &diffFilePath, 138 const std::string &newSoPath) override; 139 140 virtual ErrCode IsExistDir(const std::string &dir, bool &isExist) override; 141 142 virtual ErrCode IsExistFile(const std::string &path, bool &isExist) override; 143 144 virtual ErrCode IsDirEmpty(const std::string &dir, bool &isDirEmpty) override; 145 146 virtual ErrCode ObtainQuickFixFileDir(const std::string &dir, std::vector<std::string> &dirVec) override; 147 148 virtual ErrCode CopyFiles(const std::string &sourceDir, const std::string &destinationDir) override; 149 150 virtual ErrCode GetNativeLibraryFileNames(const std::string &filePath, const std::string &cpuAbi, 151 std::vector<std::string> &fileNames) override; 152 153 virtual ErrCode VerifyCodeSignature(const std::string &modulePath, const std::string &cpuAbi, 154 const std::string &targetSoPath, const std::string &signatureFileDir) override; 155 156 virtual ErrCode MoveFiles(const std::string &srcDir, const std::string &desDir) override; 157 158 private: 159 std::string GetBundleDataDir(const std::string &el, const int userid) const; 160 }; 161 } // namespace AppExecFwk 162 } // namespace OHOS 163 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INSTALLD_HOST_IMPL_H