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_PROXY_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_RESOURCE_PROXY_H 18 19 #include "bundle_resource_interface.h" 20 #include "bundle_framework_core_ipc_interface_code.h" 21 #include "iremote_proxy.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 class BundleResourceProxy : public IRemoteProxy<IBundleResource> { 26 public: 27 explicit BundleResourceProxy(const sptr<IRemoteObject>& object); 28 virtual ~BundleResourceProxy() = default; 29 30 virtual ErrCode GetBundleResourceInfo(const std::string &bundleName, const uint32_t flags, 31 BundleResourceInfo &bundleResourceInfo, const int32_t appIndex = 0) override; 32 33 virtual ErrCode GetLauncherAbilityResourceInfo(const std::string &bundleName, const uint32_t flags, 34 std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfo, const int32_t appIndex = 0) override; 35 36 virtual ErrCode GetAllBundleResourceInfo(const uint32_t flags, 37 std::vector<BundleResourceInfo> &bundleResourceInfos) override; 38 39 virtual ErrCode GetAllLauncherAbilityResourceInfo(const uint32_t flags, 40 std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfos) override; 41 42 virtual ErrCode AddResourceInfoByBundleName(const std::string &bundleName, const int32_t userId) override; 43 44 virtual ErrCode AddResourceInfoByAbility(const std::string &bundleName, const std::string &moduleName, 45 const std::string &abilityName, const int32_t userId) override; 46 47 virtual ErrCode DeleteResourceInfo(const std::string &key) override; 48 49 virtual ErrCode GetExtensionAbilityResourceInfo(const std::string &bundleName, 50 const ExtensionAbilityType extensionAbilityType, const uint32_t flags, 51 std::vector<LauncherAbilityResourceInfo> &extensionAbilityResourceInfo, const int32_t appIndex = 0) override; 52 53 private: 54 template<typename T> 55 ErrCode GetParcelInfo(BundleResourceInterfaceCode code, MessageParcel &data, T &parcelInfo); 56 57 template<typename T> 58 ErrCode GetVectorParcelInfo( 59 BundleResourceInterfaceCode code, MessageParcel &data, std::vector<T> &parcelInfos); 60 61 ErrCode GetParcelInfoFromAshMem(MessageParcel &reply, void *&data); 62 63 bool SendRequest(BundleResourceInterfaceCode code, MessageParcel &data, MessageParcel &reply); 64 65 static inline BrokerDelegator<BundleResourceProxy> delegator_; 66 }; 67 } // AppExecFwk 68 } // OHOS 69 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_RESOURCE_PROXY_H 70