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 "iremote_proxy.h" 22 #include "appexecfwk_errors.h" 23 #include "ipc/installd_interface.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class InstalldProxy : public IRemoteProxy<IInstalld> { 28 public: 29 explicit InstalldProxy(const sptr<IRemoteObject> &object); 30 virtual ~InstalldProxy() override; 31 /** 32 * @brief Create a bundle code directory through a proxy object. 33 * @param bundleDir Indicates the bundle code directory path that to be created. 34 * @return Returns ERR_OK if the bundle directory created successfully; returns error code otherwise. 35 */ 36 virtual ErrCode CreateBundleDir(const std::string &bundlePath) override; 37 /** 38 * @brief Extract the files of a HAP module to the code directory through a proxy object. 39 * @param srcModulePath Indicates the HAP file path. 40 * @param targetPath normal files decompression path. 41 * @param targetSoPath so files decompression path. 42 * @param cpuAbi cpuAbi. 43 * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise. 44 */ 45 virtual ErrCode ExtractModuleFiles(const std::string &srcModulePath, const std::string &targetPath, 46 const std::string &targetSoPath, const std::string &cpuAbi) override; 47 /** 48 * @brief Extract the files. 49 * @param extractParam Indicates the extractParam. 50 * @return Returns ERR_OK if the HAP file extracted successfully; returns error code otherwise. 51 */ 52 virtual ErrCode ExtractFiles(const ExtractParam &extractParam) override; 53 /** 54 * @brief Rename the module directory from temporaily path to the real path through a proxy object. 55 * @param oldPath Indicates the old path name. 56 * @param newPath Indicates the new path name. 57 * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise. 58 */ 59 virtual ErrCode RenameModuleDir(const std::string &oldPath, const std::string &newPath) override; 60 /** 61 * @brief Create a bundle data directory through a proxy object. 62 * @param bundleName Indicates bundleName to be set to the directory. 63 * @param userid Indicates userid to be set to the directory. 64 * @param uid Indicates uid to be set to the directory. 65 * @param gid Indicates gid to be set to the directory. 66 * @param apl Indicates apl to be set to the directory. 67 * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise. 68 */ 69 virtual ErrCode CreateBundleDataDir(const std::string &bundleName, const int userid, 70 const int uid, const int gid, const std::string &apl) override; 71 /** 72 * @brief Remove a bundle data directory through a proxy object. 73 * @param bundleDir Indicates the bundle data directory path that to be created. 74 * @param userid Indicates userid to be set to the directory. 75 * @return Returns ERR_OK if the bundle data directory created successfully; returns error code otherwise. 76 */ 77 virtual ErrCode RemoveBundleDataDir(const std::string &bundleDir, const int userid) override; 78 /** 79 * @brief Remove a module data directory through a proxy object. 80 * @param ModuleDir Indicates the module data directory path that to be created. 81 * @param userid Indicates userid to be set to the directory. 82 * @return Returns ERR_OK if the data directories created successfully; returns error code otherwise. 83 */ 84 virtual ErrCode RemoveModuleDataDir(const std::string &ModuleDir, const int userid) override; 85 /** 86 * @brief Remove a directory through a proxy object. 87 * @param dir Indicates the directory path that to be removed. 88 * @return Returns ERR_OK if the directory removed successfully; returns error code otherwise. 89 */ 90 virtual ErrCode RemoveDir(const std::string &dir) override; 91 /** 92 * @brief Clean all files in a bundle data directory through a proxy object. 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 &bundlePath) override; 97 /** 98 * @brief Get bundle Stats. 99 * @param bundleName Indicates the bundle name. 100 * @param userId Indicates the user Id. 101 * @param bundleStats Indicates the bundle Stats. 102 * @return Returns ERR_OK if get stats successfully; returns error code otherwise. 103 */ 104 virtual ErrCode GetBundleStats( 105 const std::string &bundleName, const int32_t userId, std::vector<int64_t> &bundleStats) override; 106 /** 107 * @brief Set dir apl. 108 * @param dir Indicates the data dir. 109 * @param bundleName Indicates the bundle name. 110 * @param apl Indicates the apl type. 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) override; 114 /** 115 * @brief Get all cache file path. 116 * @param dir Indicates the data dir. 117 * @param cachesPath Indicates the cache file path. 118 * @return Returns ERR_OK if get cache file path successfully; returns error code otherwise. 119 */ 120 virtual ErrCode GetBundleCachePath(const std::string &dir, std::vector<std::string> &cachePath) override; 121 122 virtual ErrCode ScanDir( 123 const std::string &dir, ScanMode scanMode, ResultMode resultMode, std::vector<std::string> &paths) override; 124 125 virtual ErrCode MoveFile(const std::string &oldPath, const std::string &newPath) override; 126 127 virtual ErrCode CopyFile(const std::string &oldPath, const std::string &newPath) 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 IsDirEmpty(const std::string &dir, bool &isDirEmpty) override; 143 144 virtual ErrCode ObtainQuickFixFileDir(const std::string &dir, std::vector<std::string> &dirVec) override; 145 146 virtual ErrCode CopyFiles(const std::string &sourceDir, const std::string &destinationDir) override; 147 148 private: 149 ErrCode TransactInstalldCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, 150 MessageOption &option); 151 static inline BrokerDelegator<InstalldProxy> delegator_; 152 }; 153 } // namespace AppExecFwk 154 } // namespace OHOS 155 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_PROXY_H