1 /*
2 * Copyright (c) 2024-2025 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(UpdateDpAclParams * aclParams,SessionKey sessionKey,bool isNeedUpdateDk,AclWriteState aclState)180 void UpdateDpSameAccount(
181 UpdateDpAclParams *aclParams, SessionKey sessionKey, bool isNeedUpdateDk, AclWriteState aclState)
182 {
183 return GetLnnConnInterface()->UpdateDpSameAccount(aclParams, sessionKey, isNeedUpdateDk, aclState);
184 }
185
LnnGetAddrTypeByIfName(const char * ifName,ConnectionAddrType * type)186 int32_t LnnGetAddrTypeByIfName(const char *ifName, ConnectionAddrType *type)
187 {
188 return GetLnnConnInterface()->LnnGetAddrTypeByIfName(ifName, type);
189 }
190
LnnConvertAuthConnInfoToAddr(ConnectionAddr * addr,const AuthConnInfo * connInfo,ConnectionAddrType hintType)191 bool LnnConvertAuthConnInfoToAddr(ConnectionAddr *addr, const AuthConnInfo *connInfo, ConnectionAddrType hintType)
192 {
193 return GetLnnConnInterface()->LnnConvertAuthConnInfoToAddr(addr, connInfo, hintType);
194 }
195
LnnUpdateAccountInfo(const NodeInfo * info)196 int32_t LnnUpdateAccountInfo(const NodeInfo *info)
197 {
198 return GetLnnConnInterface()->LnnUpdateAccountInfo(info);
199 }
200
LnnUpdateRemoteDeviceName(const NodeInfo * info)201 int32_t LnnUpdateRemoteDeviceName(const NodeInfo *info)
202 {
203 return GetLnnConnInterface()->LnnUpdateRemoteDeviceName(info);
204 }
205
LnnIsSameConnectionAddr(const ConnectionAddr * addr1,const ConnectionAddr * addr2,bool isShort)206 bool LnnIsSameConnectionAddr(const ConnectionAddr *addr1, const ConnectionAddr *addr2, bool isShort)
207 {
208 return GetLnnConnInterface()->LnnIsSameConnectionAddr(addr1, addr2, isShort);
209 }
210
DelSessionKeyProfile(int32_t sessionKeyId)211 void DelSessionKeyProfile(int32_t sessionKeyId)
212 {
213 return GetLnnConnInterface()->DelSessionKeyProfile(sessionKeyId);
214 }
215
GetSessionKeyProfile(int32_t sessionKeyId,uint8_t * sessionKey,uint32_t * length)216 bool GetSessionKeyProfile(int32_t sessionKeyId, uint8_t *sessionKey, uint32_t *length)
217 {
218 return GetLnnConnInterface()->GetSessionKeyProfile(sessionKeyId, sessionKey, length);
219 }
220
GetAuthManagerByAuthId(int64_t authId)221 AuthManager *GetAuthManagerByAuthId(int64_t authId)
222 {
223 return GetLnnConnInterface()->GetAuthManagerByAuthId(authId);
224 }
225
GetLatestSessionKey(const SessionKeyList * list,AuthLinkType type,int32_t * index,SessionKey * key)226 int32_t GetLatestSessionKey(const SessionKeyList *list, AuthLinkType type, int32_t *index, SessionKey *key)
227 {
228 return GetLnnConnInterface()->GetLatestSessionKey(list, type, index, key);
229 }
230
DelDupAuthManager(AuthManager * auth)231 void DelDupAuthManager(AuthManager *auth)
232 {
233 return GetLnnConnInterface()->DelDupAuthManager(auth);
234 }
235
DelUserKeyByNetworkId(const char * networkId)236 void DelUserKeyByNetworkId(const char *networkId)
237 {
238 return GetLnnConnInterface()->DelUserKeyByNetworkId(networkId);
239 }
240
LnnNotifyAddRawEnhanceP2pEvent(LnnNotifyRawEnhanceP2pEvent * event)241 void LnnNotifyAddRawEnhanceP2pEvent(LnnNotifyRawEnhanceP2pEvent *event)
242 {
243 return GetLnnConnInterface()->LnnNotifyAddRawEnhanceP2pEvent(event);
244 }
245
RawLinkNeedUpdateAuthManager(const char * uuid,bool isServer)246 bool RawLinkNeedUpdateAuthManager(const char *uuid, bool isServer)
247 {
248 return GetLnnConnInterface()->RawLinkNeedUpdateAuthManager(uuid, isServer);
249 }
250
LnnStopOfflineTimingBySleHb(const char * networkId,ConnectionAddrType addrType)251 void LnnStopOfflineTimingBySleHb(const char *networkId, ConnectionAddrType addrType)
252 {
253 return GetLnnConnInterface()->LnnStopOfflineTimingBySleHb(networkId, addrType);
254 }
255
LnnCleanTriggerSparkInfo(const char * udid,ConnectionAddrType addrType)256 int32_t LnnCleanTriggerSparkInfo(const char *udid, ConnectionAddrType addrType)
257 {
258 return GetLnnConnInterface()->LnnCleanTriggerSparkInfo(udid, addrType);
259 }
260
LnnSetWiFiIp(NodeInfo * info,const char * ip,int32_t ifnameIdx)261 void LnnSetWiFiIp(NodeInfo *info, const char *ip, int32_t ifnameIdx)
262 {
263 return GetLnnConnInterface()->LnnSetWiFiIp(info, ip, ifnameIdx);
264 }
265 }
266 } // namespace OHOS
267