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 #include "client_bus_center_manager_mock.h"
17 
18 #include <securec.h>
19 
20 #include "softbus_common.h"
21 #include "softbus_error_code.h"
22 
23 using namespace testing;
24 using namespace testing::ext;
25 namespace OHOS {
26 void *g_clientBusCenterManagerInterface;
ClientBusCenterManagerInterfaceMock()27 ClientBusCenterManagerInterfaceMock::ClientBusCenterManagerInterfaceMock()
28 {
29     g_clientBusCenterManagerInterface = reinterpret_cast<void *>(this);
30 }
31 
~ClientBusCenterManagerInterfaceMock()32 ClientBusCenterManagerInterfaceMock::~ClientBusCenterManagerInterfaceMock()
33 {
34     g_clientBusCenterManagerInterface = nullptr;
35 }
36 
GetBusCenterManagerInterface()37 static ClientBusCenterManagerInterfaceMock *GetBusCenterManagerInterface()
38 {
39     return reinterpret_cast<ClientBusCenterManagerInterfaceMock *>(g_clientBusCenterManagerInterface);
40 }
41 
42 extern "C" {
BusCenterServerProxyInit(void)43 int32_t BusCenterServerProxyInit(void)
44 {
45     return GetBusCenterManagerInterface()->BusCenterServerProxyInit();
46 }
47 
BusCenterServerProxyDeInit(void)48 void BusCenterServerProxyDeInit(void)
49 {
50     return GetBusCenterManagerInterface()->BusCenterServerProxyDeInit();
51 }
52 
SoftbusGetConfig(ConfigType type,unsigned char * val,uint32_t len)53 int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
54 {
55     return GetBusCenterManagerInterface()->SoftbusGetConfig(type, val, len);
56 }
57 
ServerIpcGetAllOnlineNodeInfo(const char * pkgName,void ** info,uint32_t infoTypeLen,int32_t * infoNum)58 int32_t ServerIpcGetAllOnlineNodeInfo(const char *pkgName, void **info, uint32_t infoTypeLen, int32_t *infoNum)
59 {
60     return GetBusCenterManagerInterface()->ServerIpcGetAllOnlineNodeInfo(pkgName, info, infoTypeLen, infoNum);
61 }
62 
ServerIpcGetLocalDeviceInfo(const char * pkgName,void * info,uint32_t infoTypeLen)63 int32_t ServerIpcGetLocalDeviceInfo(const char *pkgName, void *info, uint32_t infoTypeLen)
64 {
65     return GetBusCenterManagerInterface()->ServerIpcGetLocalDeviceInfo(pkgName, info, infoTypeLen);
66 }
67 
ServerIpcGetNodeKeyInfo(const char * pkgName,const char * networkId,int key,unsigned char * buf,uint32_t len)68 int32_t ServerIpcGetNodeKeyInfo(const char *pkgName, const char *networkId, int key, unsigned char *buf, uint32_t len)
69 {
70     return GetBusCenterManagerInterface()->ServerIpcGetNodeKeyInfo(pkgName, networkId, key, buf, len);
71 }
72 
ServerIpcSetNodeDataChangeFlag(const char * pkgName,const char * networkId,uint16_t dataChangeFlag)73 int32_t ServerIpcSetNodeDataChangeFlag(const char *pkgName, const char *networkId, uint16_t dataChangeFlag)
74 {
75     return GetBusCenterManagerInterface()->ServerIpcSetNodeDataChangeFlag(pkgName, networkId, dataChangeFlag);
76 }
77 
ServerIpcJoinLNN(const char * pkgName,void * addr,unsigned int addrTypeLen)78 int32_t ServerIpcJoinLNN(const char *pkgName, void *addr, unsigned int addrTypeLen)
79 {
80     return GetBusCenterManagerInterface()->ServerIpcJoinLNN(pkgName, addr, addrTypeLen);
81 }
82 
ServerIpcLeaveLNN(const char * pkgName,const char * networkId)83 int32_t ServerIpcLeaveLNN(const char *pkgName, const char *networkId)
84 {
85     return GetBusCenterManagerInterface()->ServerIpcLeaveLNN(pkgName, networkId);
86 }
87 
ServerIpcStartTimeSync(const char * pkgName,const char * targetNetworkId,int32_t accuracy,int32_t period)88 int32_t ServerIpcStartTimeSync(const char *pkgName, const char *targetNetworkId, int32_t accuracy, int32_t period)
89 {
90     return GetBusCenterManagerInterface()->ServerIpcStartTimeSync(pkgName, targetNetworkId, accuracy, period);
91 }
92 
ServerIpcStopTimeSync(const char * pkgName,const char * targetNetworkId)93 int32_t ServerIpcStopTimeSync(const char *pkgName, const char *targetNetworkId)
94 {
95     return GetBusCenterManagerInterface()->ServerIpcStopTimeSync(pkgName, targetNetworkId);
96 }
97 
ServerIpcPublishLNN(const char * pkgName,const PublishInfo * info)98 int32_t ServerIpcPublishLNN(const char *pkgName, const PublishInfo *info)
99 {
100     return GetBusCenterManagerInterface()->ServerIpcPublishLNN(pkgName, info);
101 }
102 
ServerIpcStopPublishLNN(const char * pkgName,int32_t publishId)103 int32_t ServerIpcStopPublishLNN(const char *pkgName, int32_t publishId)
104 {
105     return GetBusCenterManagerInterface()->ServerIpcStopPublishLNN(pkgName, publishId);
106 }
107 
ServerIpcRefreshLNN(const char * pkgName,const SubscribeInfo * info)108 int32_t ServerIpcRefreshLNN(const char *pkgName, const SubscribeInfo *info)
109 {
110     return GetBusCenterManagerInterface()->ServerIpcRefreshLNN(pkgName, info);
111 }
112 
ServerIpcStopRefreshLNN(const char * pkgName,int32_t refreshId)113 int32_t ServerIpcStopRefreshLNN(const char *pkgName, int32_t refreshId)
114 {
115     return GetBusCenterManagerInterface()->ServerIpcStopRefreshLNN(pkgName, refreshId);
116 }
117 
118 } // extern "C"
119 } // namespace OHOS
120