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_HOST_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_HOST_H 18 19 #include <string> 20 21 #include "iremote_stub.h" 22 23 #include "ipc/installd_interface.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class InstalldHost : public IRemoteStub<IInstalld> { 28 public: 29 InstalldHost(); 30 virtual ~InstalldHost() override; 31 32 virtual int OnRemoteRequest( 33 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 34 35 private: 36 /** 37 * @brief Handles the CreateBundleDir function called from a IInstalld proxy object. 38 * @param data Indicates the data to be read. 39 * @param reply Indicates the reply to be sent; 40 * @return Returns true if called successfully; returns false otherwise. 41 */ 42 bool HandleCreateBundleDir(MessageParcel &data, MessageParcel &reply); 43 /** 44 * @brief Handles the ExtractModuleFiles function called from a IInstalld proxy object. 45 * @param data Indicates the data to be read. 46 * @param reply Indicates the reply to be sent; 47 * @return Returns true if called successfully; returns false otherwise. 48 */ 49 bool HandleExtractModuleFiles(MessageParcel &data, MessageParcel &reply); 50 /** 51 * @brief Handles the HandleExtractFiles function called from a IInstalld proxy object. 52 * @param data Indicates the data to be read. 53 * @param reply Indicates the reply to be sent; 54 * @return Returns true if called successfully; returns false otherwise. 55 */ 56 bool HandleExtractFiles(MessageParcel &data, MessageParcel &reply); 57 /** 58 * @brief Handles the RenameModuleDir function called from a IInstalld proxy object. 59 * @param data Indicates the data to be read. 60 * @param reply Indicates the reply to be sent; 61 * @return Returns true if called successfully; returns false otherwise. 62 */ 63 bool HandleRenameModuleDir(MessageParcel &data, MessageParcel &reply); 64 /** 65 * @brief Handles the CreateBundleDataDir function called from a IInstalld proxy object. 66 * @param data Indicates the data to be read. 67 * @param reply Indicates the reply to be sent; 68 * @return Returns true if called successfully; returns false otherwise. 69 */ 70 bool HandleCreateBundleDataDir(MessageParcel &data, MessageParcel &reply); 71 /** 72 * @brief Handles the RemoveBundleDataDir function called from a IInstalld proxy object. 73 * @param data Indicates the data to be read. 74 * @param reply Indicates the reply to be sent; 75 * @return Returns true if called successfully; returns false otherwise. 76 */ 77 bool HandleRemoveBundleDataDir(MessageParcel &data, MessageParcel &reply); 78 /** 79 * @brief Handles the RemoveModuleDataDir function called from a IInstalld proxy object. 80 * @param data Indicates the data to be read. 81 * @param reply Indicates the reply to be sent; 82 * @return Returns true if called successfully; returns false otherwise. 83 */ 84 bool HandleRemoveModuleDataDir(MessageParcel &data, MessageParcel &reply); 85 /** 86 * @brief Handles the RemoveDir function called from a IInstalld proxy object. 87 * @param data Indicates the data to be read. 88 * @param reply Indicates the reply to be sent; 89 * @return Returns true if called successfully; returns false otherwise. 90 */ 91 bool HandleRemoveDir(MessageParcel &data, MessageParcel &reply); 92 /** 93 * @brief Handles the CleanBundleDataDir function called from a IInstalld proxy object. 94 * @param data Indicates the data to be read. 95 * @param reply Indicates the reply to be sent; 96 * @return Returns true if called successfully; returns false otherwise. 97 */ 98 bool HandleCleanBundleDataDir(MessageParcel &data, MessageParcel &reply); 99 /** 100 * @brief Handles the CleanBundleDataDir function called from a IInstalld proxy object. 101 * @param data Indicates the data to be read. 102 * @param reply Indicates the reply to be sent; 103 * @return Returns true if called successfully; returns false otherwise. 104 */ 105 bool HandleGetBundleStats(MessageParcel &data, MessageParcel &reply); 106 107 /** 108 * @brief Init private hash map funcMap_. 109 */ 110 void init(); 111 /** 112 * @brief Handles the set dir apl function called from a IInstalld proxy object. 113 * @param data Indicates the data to be read. 114 * @param reply Indicates the reply to be sent; 115 * @return Returns true if called successfully; returns false otherwise. 116 */ 117 bool HandleSetDirApl(MessageParcel &data, MessageParcel &reply); 118 119 /** 120 * @brief Handles the all GetBundleCachePath function. 121 * @param data Indicates the data to be read. 122 * @param reply Indicates the reply to be sent; 123 * @return Returns true if called successfully; returns false otherwise. 124 */ 125 bool HandleGetBundleCachePath(MessageParcel &data, MessageParcel &reply); 126 127 bool HandleScanDir(MessageParcel &data, MessageParcel &reply); 128 129 bool HandleMoveFile(MessageParcel &data, MessageParcel &reply); 130 131 bool HandleCopyFile(MessageParcel &data, MessageParcel &reply); 132 133 bool HandleMkdir(MessageParcel &data, MessageParcel &reply); 134 135 bool HandleGetFileStat(MessageParcel &data, MessageParcel &reply); 136 137 bool HandleExtractDiffFiles(MessageParcel &data, MessageParcel &reply); 138 139 bool HandleApplyDiffPatch(MessageParcel &data, MessageParcel &reply); 140 141 bool HandleIsExistDir(MessageParcel &data, MessageParcel &reply); 142 143 bool HandleIsDirEmpty(MessageParcel &data, MessageParcel &reply); 144 145 bool HandObtainQuickFixFileDir(MessageParcel &data, MessageParcel &reply); 146 147 bool HandCopyFiles(MessageParcel &data, MessageParcel &reply); 148 149 using InstalldFunc = bool (InstalldHost::*)(MessageParcel &, MessageParcel &); 150 std::unordered_map<uint32_t, InstalldFunc> funcMap_; 151 }; 152 } // namespace AppExecFwk 153 } // namespace OHOS 154 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_INSTALLD_HOST_H