1 /* 2 * Copyright (c) 2021-2025 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_HOST_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_HOST_H 18 19 #include <mutex> 20 #include <string> 21 22 #include "event_handler.h" 23 #include "event_runner.h" 24 #include "iremote_stub.h" 25 #include "ipc/installd_interface.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 class InstalldHost : public IRemoteStub<IInstalld> { 30 public: 31 InstalldHost(); 32 virtual ~InstalldHost() override; 33 34 virtual int OnRemoteRequest( 35 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 36 37 private: 38 /** 39 * @brief Handles the CreateBundleDir function called from a IInstalld proxy object. 40 * @param data Indicates the data to be read. 41 * @param reply Indicates the reply to be sent; 42 * @return Returns true if called successfully; returns false otherwise. 43 */ 44 bool HandleCreateBundleDir(MessageParcel &data, MessageParcel &reply); 45 /** 46 * @brief Handles the ExtractModuleFiles function called from a IInstalld proxy object. 47 * @param data Indicates the data to be read. 48 * @param reply Indicates the reply to be sent; 49 * @return Returns true if called successfully; returns false otherwise. 50 */ 51 bool HandleExtractModuleFiles(MessageParcel &data, MessageParcel &reply); 52 /** 53 * @brief Handles the HandleExtractFiles function called from a IInstalld proxy object. 54 * @param data Indicates the data to be read. 55 * @param reply Indicates the reply to be sent; 56 * @return Returns true if called successfully; returns false otherwise. 57 */ 58 bool HandleExtractFiles(MessageParcel &data, MessageParcel &reply); 59 /** 60 * @brief Handles the HandleExtractHnpFiles function called from a IInstalld proxy object. 61 * @param data Indicates the data to be read. 62 * @param reply Indicates the reply to be sent; 63 * @return Returns true if called successfully; returns false otherwise. 64 */ 65 bool HandleExtractHnpFiles(MessageParcel &data, MessageParcel &reply); 66 67 bool HandleProcessBundleInstallNative(MessageParcel &data, MessageParcel &reply); 68 bool HandleProcessBundleUnInstallNative(MessageParcel &data, MessageParcel &reply); 69 70 bool HandleExecuteAOT(MessageParcel &data, MessageParcel &reply); 71 72 bool HandlePendSignAOT(MessageParcel &data, MessageParcel &reply); 73 74 bool HandleStopAOT(MessageParcel &data, MessageParcel &reply); 75 76 bool HandleDeleteUninstallTmpDirs(MessageParcel &data, MessageParcel &reply); 77 /** 78 * @brief Handles the RenameModuleDir function called from a IInstalld proxy object. 79 * @param data Indicates the data to be read. 80 * @param reply Indicates the reply to be sent; 81 * @return Returns true if called successfully; returns false otherwise. 82 */ 83 bool HandleRenameModuleDir(MessageParcel &data, MessageParcel &reply); 84 /** 85 * @brief Handles the CreateBundleDataDir function called from a IInstalld proxy object. 86 * @param data Indicates the data to be read. 87 * @param reply Indicates the reply to be sent; 88 * @return Returns true if called successfully; returns false otherwise. 89 */ 90 bool HandleCreateBundleDataDir(MessageParcel &data, MessageParcel &reply); 91 92 bool HandleCreateBundleDataDirWithVector(MessageParcel &data, MessageParcel &reply); 93 /** 94 * @brief Handles the RemoveBundleDataDir function called from a IInstalld proxy object. 95 * @param data Indicates the data to be read. 96 * @param reply Indicates the reply to be sent; 97 * @return Returns true if called successfully; returns false otherwise. 98 */ 99 bool HandleRemoveBundleDataDir(MessageParcel &data, MessageParcel &reply); 100 /** 101 * @brief Handles the RemoveModuleDataDir function called from a IInstalld proxy object. 102 * @param data Indicates the data to be read. 103 * @param reply Indicates the reply to be sent; 104 * @return Returns true if called successfully; returns false otherwise. 105 */ 106 bool HandleRemoveModuleDataDir(MessageParcel &data, MessageParcel &reply); 107 /** 108 * @brief Handles the RemoveDir function called from a IInstalld proxy object. 109 * @param data Indicates the data to be read. 110 * @param reply Indicates the reply to be sent; 111 * @return Returns true if called successfully; returns false otherwise. 112 */ 113 bool HandleRemoveDir(MessageParcel &data, MessageParcel &reply); 114 /** 115 * @brief Handles the GetDiskUsage function called from a IInstalld proxy object. 116 * @param data Indicates the data to be read. 117 * @param reply Indicates the reply to be sent; 118 * @return Returns true if called successfully; returns false otherwise. 119 */ 120 bool HandleGetDiskUsage(MessageParcel &data, MessageParcel &reply); 121 /** 122 * @brief Handles the GetDiskUsage function called from a IInstalld proxy object. 123 * @param data Indicates the data to be read. 124 * @param reply Indicates the reply to be sent; 125 * @return Returns true if called successfully; returns false otherwise. 126 */ 127 bool HandleGetDiskUsageFromPath(MessageParcel &data, MessageParcel &reply); 128 /** 129 * @brief Handles the CleanBundleDataDir function called from a IInstalld proxy object. 130 * @param data Indicates the data to be read. 131 * @param reply Indicates the reply to be sent; 132 * @return Returns true if called successfully; returns false otherwise. 133 */ 134 bool HandleCleanBundleDataDir(MessageParcel &data, MessageParcel &reply); 135 /** 136 * @brief Handles the CleanBundleDataDirByName function called from a IInstalld proxy object. 137 * @param data Indicates the data to be read. 138 * @param reply Indicates the reply to be sent; 139 * @return Returns true if called successfully; returns false otherwise. 140 */ 141 bool HandleCleanBundleDataDirByName(MessageParcel &data, MessageParcel &reply); 142 /** 143 * @brief Handles the CleanBundleDataDir function called from a IInstalld proxy object. 144 * @param data Indicates the data to be read. 145 * @param reply Indicates the reply to be sent; 146 * @return Returns true if called successfully; returns false otherwise. 147 */ 148 bool HandleGetBundleStats(MessageParcel &data, MessageParcel &reply); 149 150 bool HandleGetAllBundleStats(MessageParcel &data, MessageParcel &reply); 151 152 /** 153 * @brief Handles the set dir apl function called from a IInstalld proxy object. 154 * @param data Indicates the data to be read. 155 * @param reply Indicates the reply to be sent; 156 * @return Returns true if called successfully; returns false otherwise. 157 */ 158 bool HandleSetDirApl(MessageParcel &data, MessageParcel &reply); 159 160 /** 161 * @brief Handles the all GetBundleCachePath function. 162 * @param data Indicates the data to be read. 163 * @param reply Indicates the reply to be sent; 164 * @return Returns true if called successfully; returns false otherwise. 165 */ 166 bool HandleGetBundleCachePath(MessageParcel &data, MessageParcel &reply); 167 168 bool HandleScanDir(MessageParcel &data, MessageParcel &reply); 169 170 bool HandleMoveFile(MessageParcel &data, MessageParcel &reply); 171 172 bool HandleCopyFile(MessageParcel &data, MessageParcel &reply); 173 174 bool HandleMkdir(MessageParcel &data, MessageParcel &reply); 175 176 bool HandleGetFileStat(MessageParcel &data, MessageParcel &reply); 177 178 bool HandleExtractDiffFiles(MessageParcel &data, MessageParcel &reply); 179 180 bool HandleApplyDiffPatch(MessageParcel &data, MessageParcel &reply); 181 182 bool HandleIsExistDir(MessageParcel &data, MessageParcel &reply); 183 184 bool HandleIsExistFile(MessageParcel &data, MessageParcel &reply); 185 186 bool HandleIsExistApFile(MessageParcel &data, MessageParcel &reply); 187 188 bool HandleIsDirEmpty(MessageParcel &data, MessageParcel &reply); 189 190 bool HandObtainQuickFixFileDir(MessageParcel &data, MessageParcel &reply); 191 192 bool HandCopyFiles(MessageParcel &data, MessageParcel &reply); 193 194 bool HandGetNativeLibraryFileNames(MessageParcel &data, MessageParcel &reply); 195 196 bool HandVerifyCodeSignature(MessageParcel &data, MessageParcel &reply); 197 198 bool HandleCheckEncryption(MessageParcel &data, MessageParcel &reply); 199 200 bool HandMoveFiles(MessageParcel &data, MessageParcel &reply); 201 202 bool HandExtractDriverSoFiles(MessageParcel &data, MessageParcel &reply); 203 204 bool HandExtractEncryptedSoFiles(MessageParcel &data, MessageParcel &reply); 205 206 bool HandVerifyCodeSignatureForHap(MessageParcel &data, MessageParcel &reply); 207 208 bool HandDeliverySignProfile(MessageParcel &data, MessageParcel &reply); 209 210 bool HandRemoveSignProfile(MessageParcel &data, MessageParcel &reply); 211 212 bool HandleSetEncryptionDir(MessageParcel &data, MessageParcel &reply); 213 214 bool HandleDeleteEncryptionKeyId(MessageParcel &data, MessageParcel &reply); 215 216 bool HandleRemoveExtensionDir(MessageParcel &data, MessageParcel &reply); 217 218 bool HandleIsExistExtensionDir(MessageParcel &data, MessageParcel &reply); 219 220 bool HandleCreateExtensionDataDir(MessageParcel &data, MessageParcel &reply); 221 222 bool HandleGetExtensionSandboxTypeList(MessageParcel &data, MessageParcel &reply); 223 224 bool HandleAddUserDirDeleteDfx(MessageParcel &data, MessageParcel &reply); 225 226 bool HandleMoveHapToCodeDir(MessageParcel &data, MessageParcel &reply); 227 228 bool HandleMigrateData(MessageParcel &data, MessageParcel &reply); 229 230 bool HandleCreateDataGroupDirs(MessageParcel &data, MessageParcel &reply); 231 232 bool HandleDeleteDataGroupDirs(MessageParcel &data, MessageParcel &reply); 233 234 bool HandleBackUpFirstBootLog(MessageParcel &data, MessageParcel &reply); 235 236 void AddCloseInstalldTask(); 237 238 void RemoveCloseInstalldTask(); 239 240 void InitEventHandler(); 241 242 std::mutex unloadTaskMutex_; 243 std::shared_ptr<EventHandler> handler_ = nullptr; 244 std::shared_ptr<EventRunner> runner_ = nullptr; 245 }; 246 } // namespace AppExecFwk 247 } // namespace OHOS 248 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_HOST_H