1 /* 2 * Copyright (c) 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_DBMS_INCLUDE_DISTRIBUTED_BMS_PROXY_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_DBMS_INCLUDE_DISTRIBUTED_BMS_PROXY_H 18 19 #include <string> 20 21 #include "distributed_bms_interface.h" 22 #include "iremote_proxy.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 class DistributedBmsProxy : public IRemoteProxy<IDistributedBms> { 27 public: 28 explicit DistributedBmsProxy(const sptr<IRemoteObject> &object); 29 virtual ~DistributedBmsProxy() override; 30 31 /** 32 * @brief get remote ability info 33 * @param elementName Indicates the elementName. 34 * @param remoteAbilityInfo Indicates the remote ability info. 35 * @return Returns result code when get ability info. 36 */ 37 int32_t GetRemoteAbilityInfo( 38 const OHOS::AppExecFwk::ElementName &elementName, RemoteAbilityInfo &remoteAbilityInfo) override; 39 /** 40 * @brief get remote ability infos 41 * @param elementNames Indicates the elementNames. 42 * @param remoteAbilityInfos Indicates the remote ability infos. 43 * @return Returns result code when get remote ability infos. 44 */ 45 int32_t GetRemoteAbilityInfos( 46 const std::vector<ElementName> &elementNames, std::vector<RemoteAbilityInfo> &remoteAbilityInfos) override; 47 /** 48 * @brief get ability info 49 * @param elementName Indicates the elementName. 50 * @param remoteAbilityInfo Indicates the remote ability info. 51 * @return Returns result code when get ability info. 52 */ 53 int32_t GetAbilityInfo( 54 const OHOS::AppExecFwk::ElementName &elementName, RemoteAbilityInfo &remoteAbilityInfo) override; 55 /** 56 * @brief get ability infos 57 * @param elementNames Indicates the elementNames. 58 * @param remoteAbilityInfos Indicates the remote ability infos. 59 * @return Returns result code when get ability infos. 60 */ 61 int32_t GetAbilityInfos( 62 const std::vector<ElementName> &elementNames, std::vector<RemoteAbilityInfo> &remoteAbilityInfos) override; 63 64 private: 65 int32_t SendRequest(IDistributedBms::Message code, MessageParcel &data, MessageParcel &reply); 66 template<typename T> 67 bool WriteParcelableVector(const std::vector<T> &parcelableVector, Parcel &data); 68 template <typename T> 69 int32_t GetParcelableInfo(IDistributedBms::Message code, MessageParcel &data, T &parcelableInfo); 70 template <typename T> 71 int32_t GetParcelableInfos(IDistributedBms::Message code, MessageParcel &data, std::vector<T> &parcelableInfos); 72 static inline BrokerDelegator<DistributedBmsProxy> delegator_; 73 }; 74 } // namespace AppExecFwk 75 } // namespace OHOS 76 #endif // FOUNDATION_APPEXECFWK_SERVICES_DBMS_INCLUDE_DISTRIBUTED_BMS_PROXY_H