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 BUS_CENTER_EX_OBJ_H 17 #define BUS_CENTER_EX_OBJ_H 18 19 #include "bus_center_ex_obj_stub.h" 20 21 namespace OHOS { 22 class BusCenterExObj : public BusCenterExObjStub { 23 public: 24 BusCenterExObj() = default; 25 26 ~BusCenterExObj() override = default; 27 28 int32_t EnableDiscoveryPolicy(const char *pkgName, const char *capability, bool enable, 29 const sptr<IRemoteObject> &callback) override; 30 int32_t SetDiscoveryPolicy(const char *capability, DiscoveryPolicy policy, const DeviceInfo *device) override; 31 int32_t JoinMetaNode(const char *pkgName, void *addr, CustomData *customData, uint32_t addrTypeLen, 32 const sptr<IRemoteObject> &callback) override; 33 int32_t SetPreLinkParam(const void *msg, const uint32_t msgLen) override; 34 int32_t GetPreLinkParam(void *msg, uint32_t *msgLen) override; 35 int32_t RegPreLinkParamListener(const char *pkgName, const sptr<IRemoteObject> &callback) override; 36 int32_t LeaveMetaNode(const char *pkgName, const char *metaNodeId, const sptr<IRemoteObject> &callback) override; 37 int32_t ResourceConflictCheck(const SoftBusResourceRequest *resource, ConflictInfo *conflict) override; 38 int32_t RegisterConflictListener(const char *pkgName, const sptr<IRemoteObject> &callback) override; 39 int32_t CtrlLNNBleHb(const char *pkgName, int32_t strategy, int32_t timeout) override; 40 int32_t ResolveResourceConflict(const char *pkgName, const char *deviceId) override; 41 42 private: 43 bool OpenSoftbusPluginSo(); 44 using EnableDiscoveryPolicyFunc = int32_t (*)(const char *pkgName, const char *capability, bool enable, 45 const sptr<IRemoteObject> &callback); 46 using SetDiscoveryPolicyFunc = int32_t (*)(const char *capability, DiscoveryPolicy policy, 47 const DeviceInfo *device); 48 using JoinMetaNodeFunc = int32_t (*)(const char *pkgName, void *addr, CustomData *customData, 49 uint32_t addrTypeLen, const sptr<IRemoteObject> &callback); 50 using SetPreLinkParamFunc = int32_t (*)(const void *msg, const uint32_t msgLen); 51 using GetPreLinkParamFunc = int32_t (*)(void *msg, uint32_t *msgLen); 52 using RegPreLinkParamListenerFunc = int32_t (*)(const char *pkgName, 53 const sptr<IRemoteObject> &callback); 54 using LeaveMetaNodeFunc = int32_t (*)(const char *pkgName, const char *metaNodeId, 55 const sptr<IRemoteObject> &callback); 56 using ResourceConflictCheckFunc = int32_t (*)(const SoftBusResourceRequest *resource, 57 ConflictInfo *conflict); 58 using RegisterConflictListenerFunc = int32_t (*)(const char *pkgName, 59 const sptr<IRemoteObject> &callback); 60 using CtrlLNNBleHbFunc = int32_t (*)(const char *pkgName, int32_t strategy, int32_t timeout); 61 using ResolveResourceConflictFunc = int32_t (*)(const char *pkgName, const char *deviceId); 62 63 EnableDiscoveryPolicyFunc enableDiscoveryPolicyFunc_ = nullptr; 64 SetDiscoveryPolicyFunc setDiscoveryPolicyFunc_ = nullptr; 65 JoinMetaNodeFunc joinMetaNodeFunc_ = nullptr; 66 SetPreLinkParamFunc setPreLinkParamFunc_ = nullptr; 67 GetPreLinkParamFunc getPreLinkParamFunc_ = nullptr; 68 RegPreLinkParamListenerFunc regPreLinkParamListenerFunc_ = nullptr; 69 LeaveMetaNodeFunc leaveMetaNodeFunc_ = nullptr; 70 ResourceConflictCheckFunc resourceConflictCheckFunc_ = nullptr; 71 RegisterConflictListenerFunc registerConflictListenerFunc_ = nullptr; 72 CtrlLNNBleHbFunc ctrlLNNBleHbFunc_ = nullptr; 73 ResolveResourceConflictFunc resolveResourceConflictFunc_ = nullptr; 74 75 std::mutex loadSoMutex_; 76 bool isLoaded_ = false; 77 void *soHandle_ = nullptr; 78 }; 79 } // namespace OHOS 80 81 #endif // BUS_CENTER_EX_OBJ_H 82