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 "appexecfwk_errors.h" 22 #include "bundle_framework_services_ipc_interface_code.h" 23 #include "iremote_proxy.h" 24 #include "ipc/installd_interface.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 class InstalldProxy : public IRemoteProxy<IInstalld> { 29 public: 30 explicit InstalldProxy(const sptr<IRemoteObject> &object); 31 virtual ~InstalldProxy() override; 32 /** 33 * @brief Create a bundle code directory through a proxy object. 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 &bundlePath) override; 38 /** 39 * @brief Extract the files of a HAP module to the code directory through a proxy object. 40 * @param srcModulePath Indicates the HAP file path. 41 * @param targetPath normal files decompression path. 42 * @param targetSoPath so files decompression path. 43 * @param cpuAbi cpuAbi. 44 * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise. 45 */ 46 virtual ErrCode ExtractModuleFiles(const std::string &srcModulePath, const std::string &targetPath, 47 const std::string &targetSoPath, const std::string &cpuAbi) override; 48 /** 49 * @brief Extract the files. 50 * @param extractParam Indicates the extractParam. 51 * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise. 52 */ 53 virtual ErrCode ExtractFiles(const ExtractParam &extractParam) override; 54 55 virtual ErrCode ExecuteAOT(const AOTArgs &aotArgs) override; 56 /** 57 * @brief Rename the module directory from temporaily path to the real path through a proxy object. 58 * @param oldPath Indicates the old path name. 59 * @param newPath Indicates the new path name. 60 * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise. 61 */ 62 virtual ErrCode RenameModuleDir(const std::string &oldPath, const std::string &newPath) override; 63 /** 64 * @brief Create a bundle data directory through a proxy object. 65 * @param createDirParam Indicates param 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 CreateDirParam &createDirPara) override; 69 /** 70 * @brief Remove a bundle data directory through a proxy object. 71 * @param bundleDir Indicates the bundle data directory path that to be created. 72 * @param userid Indicates userid to be set to the directory. 73 * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise. 74 */ 75 virtual ErrCode RemoveBundleDataDir(const std::string &bundleDir, const int userid) override; 76 /** 77 * @brief Remove a module data directory through a proxy object. 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 through a proxy object. 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 through a proxy object. 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 &bundlePath) 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 * @param isPreInstallApp Indicates the bundle install type. 110 * @param debug Indicates the bundle debug mode. 111 * @return Returns ERR_OK if set apl successfully; returns error code otherwise. 112 */ 113 virtual ErrCode SetDirApl(const std::string &dir, const std::string &bundleName, const std::string &apl, 114 bool isPreInstallApp, bool debug) override; 115 /** 116 * @brief Get all cache file path. 117 * @param dir Indicates the data dir. 118 * @param cachesPath Indicates the cache file path. 119 * @return Returns ERR_OK if get cache file path successfully; returns error code otherwise. 120 */ 121 virtual ErrCode GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath) override; 122 123 virtual ErrCode ScanDir( 124 const std::string &dir, ScanMode scanMode, ResultMode resultMode, std::vector<std::string> &paths) override; 125 126 virtual ErrCode MoveFile(const std::string &oldPath, const std::string &newPath) override; 127 128 virtual ErrCode CopyFile(const std::string &oldPath, const std::string &newPath, 129 const std::string &signatureFilePath = "") override; 130 131 virtual ErrCode Mkdir( 132 const std::string &dir, const int32_t mode, const int32_t uid, const int32_t gid) override; 133 134 virtual ErrCode GetFileStat(const std::string &file, FileStat &fileStat) override; 135 136 virtual ErrCode ExtractDiffFiles(const std::string &filePath, const std::string &targetPath, 137 const std::string &cpuAbi) override; 138 139 virtual ErrCode ApplyDiffPatch(const std::string &oldSoPath, const std::string &diffFilePath, 140 const std::string &newSoPath) override; 141 142 virtual ErrCode IsExistDir(const std::string &dir, bool &isExist) override; 143 144 virtual ErrCode IsExistFile(const std::string &path, bool &isExist) override; 145 146 virtual ErrCode IsDirEmpty(const std::string &dir, bool &isDirEmpty) override; 147 148 virtual ErrCode ObtainQuickFixFileDir(const std::string &dir, std::vector<std::string> &dirVec) override; 149 150 virtual ErrCode CopyFiles(const std::string &sourceDir, const std::string &destinationDir) override; 151 152 virtual ErrCode GetNativeLibraryFileNames(const std::string &filePath, const std::string &cpuAbi, 153 std::vector<std::string> &fileNames) override; 154 155 virtual ErrCode VerifyCodeSignature(const std::string &modulePath, const std::string &cpuAbi, 156 const std::string &targetSoPath, const std::string &signatureFileDir) override; 157 158 virtual ErrCode MoveFiles(const std::string &srcDir, const std::string &desDir) override; 159 160 private: 161 ErrCode TransactInstalldCmd(InstalldInterfaceCode code, MessageParcel &data, MessageParcel &reply, 162 MessageOption &option); 163 static inline BrokerDelegator<InstalldProxy> delegator_; 164 }; 165 } // namespace AppExecFwk 166 } // namespace OHOS 167 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_PROXY_H