1 /*
2 * Copyright (c) 2024 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 "lnn_connection_fsm_mock.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS {
22 void *g_lnnConnNewMock;
LnnConnFsmInterfaceMock()23 LnnConnFsmInterfaceMock::LnnConnFsmInterfaceMock()
24 {
25 g_lnnConnNewMock = reinterpret_cast<void *>(this);
26 }
27
~LnnConnFsmInterfaceMock()28 LnnConnFsmInterfaceMock::~LnnConnFsmInterfaceMock()
29 {
30 g_lnnConnNewMock = nullptr;
31 }
32
GetLnnConnInterface()33 static LnnConnFsmInterface *GetLnnConnInterface()
34 {
35 return reinterpret_cast<LnnConnFsmInterface *>(g_lnnConnNewMock);
36 }
37
38 extern "C" {
LnnNotifyDeviceVerified(const char * udid)39 void LnnNotifyDeviceVerified(const char *udid)
40 {
41 return GetLnnConnInterface()->LnnNotifyDeviceVerified(udid);
42 }
43
SoftBusGetBtState(void)44 int32_t SoftBusGetBtState(void)
45 {
46 return GetLnnConnInterface()->SoftBusGetBtState();
47 }
48
LnnGenerateBtMacHash(const char * btMac,int32_t brMacLen,char * brMacHash,int32_t hashLen)49 int32_t LnnGenerateBtMacHash(const char *btMac, int32_t brMacLen, char *brMacHash, int32_t hashLen)
50 {
51 return GetLnnConnInterface()->LnnGenerateBtMacHash(btMac, brMacLen, brMacHash, hashLen);
52 }
53
DeleteFromProfile(const char * udid)54 void DeleteFromProfile(const char *udid)
55 {
56 return GetLnnConnInterface()->DeleteFromProfile(udid);
57 }
58
SendDeviceStateToMlps(void * para)59 void SendDeviceStateToMlps(void *para)
60 {
61 return GetLnnConnInterface()->SendDeviceStateToMlps(para);
62 }
63
LnnUpdateNetworkId(const NodeInfo * newInfo)64 int32_t LnnUpdateNetworkId(const NodeInfo *newInfo)
65 {
66 return GetLnnConnInterface()->LnnUpdateNetworkId(newInfo);
67 }
68
AuthGetServerSide(int64_t authId,bool * isServer)69 int32_t AuthGetServerSide(int64_t authId, bool *isServer)
70 {
71 return GetLnnConnInterface()->AuthGetServerSide(authId, isServer);
72 }
73
LnnRetrieveDeviceInfo(const char * udid,NodeInfo * deviceInfo)74 int32_t LnnRetrieveDeviceInfo(const char *udid, NodeInfo *deviceInfo)
75 {
76 return GetLnnConnInterface()->LnnRetrieveDeviceInfo(udid, deviceInfo);
77 }
78
LnnRetrieveDeviceInfoByNetworkId(const char * networkId,NodeInfo * info)79 int32_t LnnRetrieveDeviceInfoByNetworkId(const char *networkId, NodeInfo *info)
80 {
81 return GetLnnConnInterface()->LnnRetrieveDeviceInfo(networkId, info);
82 }
83
AuthRestoreAuthManager(const char * udidHash,const AuthConnInfo * connInfo,uint32_t requestId,NodeInfo * nodeInfo,int64_t * authId)84 int32_t AuthRestoreAuthManager(
85 const char *udidHash, const AuthConnInfo *connInfo, uint32_t requestId, NodeInfo *nodeInfo, int64_t *authId)
86 {
87 return GetLnnConnInterface()->AuthRestoreAuthManager(udidHash, connInfo, requestId, nodeInfo, authId);
88 }
89
LnnLoadLocalBroadcastCipherKey(void)90 int32_t LnnLoadLocalBroadcastCipherKey(void)
91 {
92 return GetLnnConnInterface()->LnnLoadLocalBroadcastCipherKey();
93 }
94
LnnGetLocalBroadcastCipherKey(BroadcastCipherKey * broadcastKey)95 int32_t LnnGetLocalBroadcastCipherKey(BroadcastCipherKey *broadcastKey)
96 {
97 return GetLnnConnInterface()->LnnGetLocalBroadcastCipherKey(broadcastKey);
98 }
99
LnnSetLocalByteInfo(InfoKey key,const uint8_t * info,uint32_t len)100 int32_t LnnSetLocalByteInfo(InfoKey key, const uint8_t *info, uint32_t len)
101 {
102 return GetLnnConnInterface()->LnnSetLocalByteInfo(key, info, len);
103 }
104
LnnInsertLinkFinderInfo(const char * networkId)105 int32_t LnnInsertLinkFinderInfo(const char *networkId)
106 {
107 return GetLnnConnInterface()->LnnInsertLinkFinderInfo(networkId);
108 }
109
LnnUpdateGroupType(const NodeInfo * info)110 int32_t LnnUpdateGroupType(const NodeInfo *info)
111 {
112 return GetLnnConnInterface()->LnnUpdateGroupType(info);
113 }
114
LnnNotifySingleOffLineEvent(const ConnectionAddr * addr,NodeBasicInfo * basicInfo)115 void LnnNotifySingleOffLineEvent(const ConnectionAddr *addr, NodeBasicInfo *basicInfo)
116 {
117 return GetLnnConnInterface()->LnnNotifySingleOffLineEvent(addr, basicInfo);
118 }
119
LnnStopOfflineTimingByHeartbeat(const char * networkId,ConnectionAddrType addrType)120 void LnnStopOfflineTimingByHeartbeat(const char *networkId, ConnectionAddrType addrType)
121 {
122 return GetLnnConnInterface()->LnnStopOfflineTimingByHeartbeat(networkId, addrType);
123 }
124
LnnGetLocalNodeInfoSafe(NodeInfo * info)125 int32_t LnnGetLocalNodeInfoSafe(NodeInfo *info)
126 {
127 return GetLnnConnInterface()->LnnGetLocalNodeInfoSafe(info);
128 }
129
SetLpKeepAliveState(void * para)130 void SetLpKeepAliveState(void *para)
131 {
132 return GetLnnConnInterface()->SetLpKeepAliveState(para);
133 }
134
LnnPrintConnectionAddr(const ConnectionAddr * addr)135 const char *LnnPrintConnectionAddr(const ConnectionAddr *addr)
136 {
137 return GetLnnConnInterface()->LnnPrintConnectionAddr(addr);
138 }
139
LnnConvertAddrToAuthConnInfo(const ConnectionAddr * addr,AuthConnInfo * connInfo)140 bool LnnConvertAddrToAuthConnInfo(const ConnectionAddr *addr, AuthConnInfo *connInfo)
141 {
142 return GetLnnConnInterface()->LnnConvertAddrToAuthConnInfo(addr, connInfo);
143 }
144
LnnNotifyStateForSession(char * udid,int32_t retCode)145 void LnnNotifyStateForSession(char *udid, int32_t retCode)
146 {
147 return GetLnnConnInterface()->LnnNotifyStateForSession(udid, retCode);
148 }
149
AuthRemoveAuthManagerByAuthHandle(AuthHandle authHandle)150 void AuthRemoveAuthManagerByAuthHandle(AuthHandle authHandle)
151 {
152 return GetLnnConnInterface()->AuthRemoveAuthManagerByAuthHandle(authHandle);
153 }
154
LnnConvAddrTypeToDiscType(ConnectionAddrType type)155 DiscoveryType LnnConvAddrTypeToDiscType(ConnectionAddrType type)
156 {
157 return GetLnnConnInterface()->LnnConvAddrTypeToDiscType(type);
158 }
159
LnnNotifyOOBEStateChangeEvent(SoftBusOOBEState state)160 void LnnNotifyOOBEStateChangeEvent(SoftBusOOBEState state)
161 {
162 return GetLnnConnInterface()->LnnNotifyOOBEStateChangeEvent(state);
163 }
164
LnnNotifyHichainProofException(const char * proofInfo,uint32_t proofLen,uint16_t deviceTypeId,int32_t errCode)165 void LnnNotifyHichainProofException(const char *proofInfo, uint32_t proofLen, uint16_t deviceTypeId, int32_t errCode)
166 {
167 return GetLnnConnInterface()->LnnNotifyHichainProofException(proofInfo, proofLen, deviceTypeId, errCode);
168 }
169
LnnNotifyDeviceTrustedChange(int32_t type,const char * msg,uint32_t msgLen)170 void LnnNotifyDeviceTrustedChange(int32_t type, const char *msg, uint32_t msgLen)
171 {
172 return GetLnnConnInterface()->LnnNotifyDeviceTrustedChange(type, msg, msgLen);
173 }
174
GetAuthRequest(uint32_t requestId,AuthRequest * request)175 int32_t GetAuthRequest(uint32_t requestId, AuthRequest *request)
176 {
177 return GetLnnConnInterface()->GetAuthRequest(requestId, request);
178 }
179
UpdateDpSameAccount(int64_t accountId,const char * deviceId,int32_t peerUserId)180 void UpdateDpSameAccount(int64_t accountId, const char *deviceId, int32_t peerUserId)
181 {
182 return GetLnnConnInterface()->UpdateDpSameAccount(accountId, deviceId, peerUserId);
183 }
184
LnnGetAddrTypeByIfName(const char * ifName,ConnectionAddrType * type)185 int32_t LnnGetAddrTypeByIfName(const char *ifName, ConnectionAddrType *type)
186 {
187 return GetLnnConnInterface()->LnnGetAddrTypeByIfName(ifName, type);
188 }
189
LnnConvertAuthConnInfoToAddr(ConnectionAddr * addr,const AuthConnInfo * connInfo,ConnectionAddrType hintType)190 bool LnnConvertAuthConnInfoToAddr(ConnectionAddr *addr, const AuthConnInfo *connInfo, ConnectionAddrType hintType)
191 {
192 return GetLnnConnInterface()->LnnConvertAuthConnInfoToAddr(addr, connInfo, hintType);
193 }
194
LnnUpdateAccountInfo(const NodeInfo * info)195 int32_t LnnUpdateAccountInfo(const NodeInfo *info)
196 {
197 return GetLnnConnInterface()->LnnUpdateAccountInfo(info);
198 }
199
LnnUpdateRemoteDeviceName(const NodeInfo * info)200 int32_t LnnUpdateRemoteDeviceName(const NodeInfo *info)
201 {
202 return GetLnnConnInterface()->LnnUpdateRemoteDeviceName(info);
203 }
204
LnnIsSameConnectionAddr(const ConnectionAddr * addr1,const ConnectionAddr * addr2,bool isShort)205 bool LnnIsSameConnectionAddr(const ConnectionAddr *addr1, const ConnectionAddr *addr2, bool isShort)
206 {
207 return GetLnnConnInterface()->LnnIsSameConnectionAddr(addr1, addr2, isShort);
208 }
209
DelSessionKeyProfile(int32_t sessionKeyId)210 void DelSessionKeyProfile(int32_t sessionKeyId)
211 {
212 return GetLnnConnInterface()->DelSessionKeyProfile(sessionKeyId);
213 }
214
GetSessionKeyProfile(int32_t sessionKeyId,uint8_t * sessionKey,uint32_t * length)215 bool GetSessionKeyProfile(int32_t sessionKeyId, uint8_t *sessionKey, uint32_t *length)
216 {
217 return GetLnnConnInterface()->GetSessionKeyProfile(sessionKeyId, sessionKey, length);
218 }
219 }
220 } // namespace OHOS
221