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 int 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
AuthRestoreAuthManager(const char * udidHash,const AuthConnInfo * connInfo,uint32_t requestId,NodeInfo * nodeInfo,int64_t * authId)79 int32_t AuthRestoreAuthManager(const char *udidHash, const AuthConnInfo *connInfo, uint32_t requestId,
80 NodeInfo *nodeInfo, int64_t *authId)
81 {
82 return GetLnnConnInterface()->AuthRestoreAuthManager(udidHash, connInfo, requestId, nodeInfo, authId);
83 }
84
LnnLoadLocalBroadcastCipherKey(void)85 int32_t LnnLoadLocalBroadcastCipherKey(void)
86 {
87 return GetLnnConnInterface()->LnnLoadLocalBroadcastCipherKey();
88 }
89
LnnGetLocalBroadcastCipherKey(BroadcastCipherKey * broadcastKey)90 int32_t LnnGetLocalBroadcastCipherKey(BroadcastCipherKey *broadcastKey)
91 {
92 return GetLnnConnInterface()->LnnGetLocalBroadcastCipherKey(broadcastKey);
93 }
94
LnnSetLocalByteInfo(InfoKey key,const uint8_t * info,uint32_t len)95 int32_t LnnSetLocalByteInfo(InfoKey key, const uint8_t *info, uint32_t len)
96 {
97 return GetLnnConnInterface()->LnnSetLocalByteInfo(key, info, len);
98 }
99
LnnInsertLinkFinderInfo(const char * networkId)100 int32_t LnnInsertLinkFinderInfo(const char *networkId)
101 {
102 return GetLnnConnInterface()->LnnInsertLinkFinderInfo(networkId);
103 }
104
LnnUpdateGroupType(const NodeInfo * info)105 int32_t LnnUpdateGroupType(const NodeInfo *info)
106 {
107 return GetLnnConnInterface()->LnnUpdateGroupType(info);
108 }
109
LnnNotifySingleOffLineEvent(const ConnectionAddr * addr,NodeBasicInfo * basicInfo)110 void LnnNotifySingleOffLineEvent(const ConnectionAddr *addr, NodeBasicInfo *basicInfo)
111 {
112 return GetLnnConnInterface()->LnnNotifySingleOffLineEvent(addr, basicInfo);
113 }
114
LnnStopOfflineTimingByHeartbeat(const char * networkId,ConnectionAddrType addrType)115 void LnnStopOfflineTimingByHeartbeat(const char *networkId, ConnectionAddrType addrType)
116 {
117 return GetLnnConnInterface()->LnnStopOfflineTimingByHeartbeat(networkId, addrType);
118 }
119
LnnGetLocalNodeInfoSafe(NodeInfo * info)120 int32_t LnnGetLocalNodeInfoSafe(NodeInfo *info)
121 {
122 return GetLnnConnInterface()->LnnGetLocalNodeInfoSafe(info);
123 }
124
SetLpKeepAliveState(void * para)125 void SetLpKeepAliveState(void *para)
126 {
127 return GetLnnConnInterface()->SetLpKeepAliveState(para);
128 }
129
LnnPrintConnectionAddr(const ConnectionAddr * addr)130 const char *LnnPrintConnectionAddr(const ConnectionAddr *addr)
131 {
132 return GetLnnConnInterface()->LnnPrintConnectionAddr(addr);
133 }
134
LnnConvertAddrToAuthConnInfo(const ConnectionAddr * addr,AuthConnInfo * connInfo)135 bool LnnConvertAddrToAuthConnInfo(const ConnectionAddr *addr, AuthConnInfo *connInfo)
136 {
137 return GetLnnConnInterface()->LnnConvertAddrToAuthConnInfo(addr, connInfo);
138 }
139
LnnConvAddrTypeToDiscType(ConnectionAddrType type)140 DiscoveryType LnnConvAddrTypeToDiscType(ConnectionAddrType type)
141 {
142 return GetLnnConnInterface()->LnnConvAddrTypeToDiscType(type);
143 }
144
LnnNotifyOOBEStateChangeEvent(SoftBusOOBEState state)145 void LnnNotifyOOBEStateChangeEvent(SoftBusOOBEState state)
146 {
147 return GetLnnConnInterface()->LnnNotifyOOBEStateChangeEvent(state);
148 }
149
LnnNotifyHichainProofException(const char * proofInfo,uint32_t proofLen,uint16_t deviceTypeId,int32_t errCode)150 void LnnNotifyHichainProofException(
151 const char *proofInfo, uint32_t proofLen, uint16_t deviceTypeId, int32_t errCode)
152 {
153 return GetLnnConnInterface()->LnnNotifyHichainProofException(proofInfo, proofLen, deviceTypeId, errCode);
154 }
155 }
156 } // namespace OHOS
157