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 #include "auth_common_mock.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS {
22 void *g_commonInterface;
AuthCommonInterfaceMock()23 AuthCommonInterfaceMock::AuthCommonInterfaceMock()
24 {
25 g_commonInterface = reinterpret_cast<void *>(this);
26 }
27
~AuthCommonInterfaceMock()28 AuthCommonInterfaceMock::~AuthCommonInterfaceMock()
29 {
30 g_commonInterface = nullptr;
31 }
32
GetCommonInterface()33 static AuthCommonInterface *GetCommonInterface()
34 {
35 return reinterpret_cast<AuthCommonInterfaceMock *>(g_commonInterface);
36 }
37
38 extern "C" {
LnnAsyncCallbackDelayHelper(SoftBusLooper * looper,LnnAsyncCallbackFunc callback,void * para,uint64_t delayMillis)39 int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
40 void *para, uint64_t delayMillis)
41 {
42 return GetCommonInterface()->LnnAsyncCallbackDelayHelper(looper, callback, para, delayMillis);
43 }
44
LnnGetRemoteNumU64Info(const char * networkId,InfoKey key,uint64_t * info)45 int32_t LnnGetRemoteNumU64Info(const char *networkId, InfoKey key, uint64_t *info)
46 {
47 return GetCommonInterface()->LnnGetRemoteNumU64Info(networkId, key, info);
48 }
49
LnnGetLocalNumU64Info(InfoKey key,uint64_t * info)50 int32_t LnnGetLocalNumU64Info(InfoKey key, uint64_t *info)
51 {
52 return GetCommonInterface()->LnnGetLocalNumU64Info(key, info);
53 }
54
SoftBusGetBtState(void)55 int32_t SoftBusGetBtState(void)
56 {
57 return GetCommonInterface()->SoftBusGetBtState();
58 }
59
SoftBusGetBrState(void)60 int32_t SoftBusGetBrState(void)
61 {
62 return GetCommonInterface()->SoftBusGetBrState();
63 }
64
LnnHbOnTrustedRelationReduced(void)65 void LnnHbOnTrustedRelationReduced(void)
66 {
67 return GetCommonInterface()->LnnHbOnTrustedRelationReduced();
68 }
69
LnnInsertSpecificTrustedDevInfo(const char * udid)70 int32_t LnnInsertSpecificTrustedDevInfo(const char *udid)
71 {
72 return GetCommonInterface()->LnnInsertSpecificTrustedDevInfo(udid);
73 }
74
LnnGetNetworkIdByUuid(const char * uuid,char * buf,uint32_t len)75 int32_t LnnGetNetworkIdByUuid(const char *uuid, char *buf, uint32_t len)
76 {
77 return GetCommonInterface()->LnnGetNetworkIdByUuid(uuid, buf, len);
78 }
79
LnnGetStaFrequency(const NodeInfo * info)80 int32_t LnnGetStaFrequency(const NodeInfo *info)
81 {
82 return GetCommonInterface()->LnnGetStaFrequency(info);
83 }
84
LnnEncryptAesGcm(AesGcmInputParam * in,int32_t keyIndex,uint8_t ** out,uint32_t * outLen)85 int32_t LnnEncryptAesGcm(AesGcmInputParam *in, int32_t keyIndex, uint8_t **out, uint32_t *outLen)
86 {
87 return GetCommonInterface()->LnnEncryptAesGcm(in, keyIndex, out, outLen);
88 }
89
LnnDecryptAesGcm(AesGcmInputParam * in,uint8_t ** out,uint32_t * outLen)90 int32_t LnnDecryptAesGcm(AesGcmInputParam *in, uint8_t **out, uint32_t *outLen)
91 {
92 return GetCommonInterface()->LnnDecryptAesGcm(in, out, outLen);
93 }
94
LnnGetTrustedDevInfoFromDb(char ** udidArray,uint32_t * num)95 int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num)
96 {
97 return GetCommonInterface()->LnnGetTrustedDevInfoFromDb(udidArray, num);
98 }
99
LnnGetAllOnlineNodeNum(int32_t * nodeNum)100 int32_t LnnGetAllOnlineNodeNum(int32_t *nodeNum)
101 {
102 return GetCommonInterface()->LnnGetAllOnlineNodeNum(nodeNum);
103 }
104
LnnSetLocalStrInfo(InfoKey key,const char * info)105 int32_t LnnSetLocalStrInfo(InfoKey key, const char *info)
106 {
107 return GetCommonInterface()->LnnSetLocalStrInfo(key, info);
108 }
109
LnnNotifyEmptySessionKey(int64_t authId)110 int32_t LnnNotifyEmptySessionKey(int64_t authId)
111 {
112 return GetCommonInterface()->LnnNotifyEmptySessionKey(authId);
113 }
114
LnnNotifyLeaveLnnByAuthHandle(AuthHandle * authHandle)115 int32_t LnnNotifyLeaveLnnByAuthHandle(AuthHandle *authHandle)
116 {
117 return GetCommonInterface()->LnnNotifyLeaveLnnByAuthHandle(authHandle);
118 }
119
LnnRequestLeaveSpecific(const char * networkId,ConnectionAddrType addrType)120 int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType)
121 {
122 return GetCommonInterface()->LnnRequestLeaveSpecific(networkId, addrType);
123 }
124
SoftBusGetBtMacAddr(SoftBusBtAddr * mac)125 int32_t SoftBusGetBtMacAddr(SoftBusBtAddr *mac)
126 {
127 return GetCommonInterface()->SoftBusGetBtMacAddr(mac);
128 }
129
GetNodeFromPcRestrictMap(const char * udidHash,uint32_t * count)130 int32_t GetNodeFromPcRestrictMap(const char *udidHash, uint32_t *count)
131 {
132 return GetCommonInterface()->GetNodeFromPcRestrictMap(udidHash, count);
133 }
134
DeleteNodeFromPcRestrictMap(const char * udidHash)135 void DeleteNodeFromPcRestrictMap(const char *udidHash)
136 {
137 return GetCommonInterface()->DeleteNodeFromPcRestrictMap(udidHash);
138 }
139
AuthFailNotifyProofInfo(int32_t errCode,const char * errorReturn,uint32_t errorReturnLen)140 int32_t AuthFailNotifyProofInfo(int32_t errCode, const char *errorReturn, uint32_t errorReturnLen)
141 {
142 return GetCommonInterface()->AuthFailNotifyProofInfo(errCode, errorReturn, errorReturnLen);
143 }
144 }
145 } // namespace OHOS