1 /* 2 * Copyright (c) 2023 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_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_RESOURCE_HOST_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_RESOURCE_HOST_H 18 19 #include <mutex> 20 21 #include "iremote_stub.h" 22 #include "nocopyable.h" 23 24 #include "appexecfwk_errors.h" 25 #include "bundle_resource_interface.h" 26 #include "bundle_resource_proxy.h" 27 28 namespace OHOS { 29 namespace AppExecFwk { 30 class BundleResourceHost : public IRemoteStub<IBundleResource> { 31 public: 32 BundleResourceHost(); 33 virtual ~BundleResourceHost() = default; 34 35 int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 36 37 private: 38 ErrCode HandleGetBundleResourceInfo(MessageParcel &data, MessageParcel &reply); 39 40 ErrCode HandleGetLauncherAbilityResourceInfo(MessageParcel &data, MessageParcel &reply); 41 42 ErrCode HandleGetAllBundleResourceInfo(MessageParcel &data, MessageParcel &reply); 43 44 ErrCode HandleGetAllLauncherAbilityResourceInfo(MessageParcel &data, MessageParcel &reply); 45 46 int32_t AllocatAshmemNum(); 47 48 ErrCode WriteParcelableIntoAshmem(MessageParcel &tempParcel, MessageParcel &reply); 49 50 ErrCode HandleAddResourceInfoByBundleName(MessageParcel &data, MessageParcel &reply); 51 52 ErrCode HandleAddResourceInfoByAbility(MessageParcel &data, MessageParcel &reply); 53 54 ErrCode HandleDeleteResourceInfo(MessageParcel &data, MessageParcel &reply); 55 56 template<typename T> 57 ErrCode WriteParcelInfo(const T &parcelInfo, MessageParcel &reply); 58 59 template<typename T> 60 ErrCode WriteVectorToParcel(std::vector<T> &parcelVector, MessageParcel &reply); 61 62 std::mutex bundleAshmemMutex_; 63 int32_t ashmemNum_ = 0; 64 65 DISALLOW_COPY_AND_MOVE(BundleResourceHost); 66 }; 67 } 68 } 69 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_RESOURCE_HOST_H 70