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_data_cloud_sync_deps_mock.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS {
22 void *g_dataCloudSyncInterface;
LnnDataCloudSyncInterfaceMock()23 LnnDataCloudSyncInterfaceMock::LnnDataCloudSyncInterfaceMock()
24 {
25 g_dataCloudSyncInterface = reinterpret_cast<void *>(this);
26 }
27
~LnnDataCloudSyncInterfaceMock()28 LnnDataCloudSyncInterfaceMock::~LnnDataCloudSyncInterfaceMock()
29 {
30 g_dataCloudSyncInterface = nullptr;
31 }
32
GetDataCloudSyncInterface()33 static LnnDataCloudSyncInterface *GetDataCloudSyncInterface()
34 {
35 return reinterpret_cast<LnnDataCloudSyncInterface *>(g_dataCloudSyncInterface);
36 }
37
38 extern "C" {
LnnSaveRemoteDeviceInfo(const NodeInfo * deviceInfo)39 int32_t LnnSaveRemoteDeviceInfo(const NodeInfo *deviceInfo)
40 {
41 return GetDataCloudSyncInterface()->LnnSaveRemoteDeviceInfo(deviceInfo);
42 }
43
LnnRetrieveDeviceInfo(const char * udid,NodeInfo * deviceInfo)44 int32_t LnnRetrieveDeviceInfo(const char *udid, NodeInfo *deviceInfo)
45 {
46 return GetDataCloudSyncInterface()->LnnRetrieveDeviceInfo(udid, deviceInfo);
47 }
48
LnnDeleteDeviceInfo(const char * udid)49 void LnnDeleteDeviceInfo(const char *udid)
50 {
51 return GetDataCloudSyncInterface()->LnnDeleteDeviceInfo(udid);
52 }
53
LnnGetLocalCacheNodeInfo(NodeInfo * info)54 int32_t LnnGetLocalCacheNodeInfo(NodeInfo *info)
55 {
56 return GetDataCloudSyncInterface()->LnnGetLocalCacheNodeInfo(info);
57 }
58
LnnPackCloudSyncDeviceInfo(cJSON * json,const NodeInfo * cloudSyncInfo)59 int32_t LnnPackCloudSyncDeviceInfo(cJSON *json, const NodeInfo *cloudSyncInfo)
60 {
61 return GetDataCloudSyncInterface()->LnnPackCloudSyncDeviceInfo(json, cloudSyncInfo);
62 }
63
LnnUnPackCloudSyncDeviceInfo(cJSON * json,NodeInfo * cloudSyncInfo)64 int32_t LnnUnPackCloudSyncDeviceInfo(cJSON *json, NodeInfo *cloudSyncInfo)
65 {
66 return GetDataCloudSyncInterface()->LnnUnPackCloudSyncDeviceInfo(json, cloudSyncInfo);
67 }
68
LnnUpdateNetworkId(const NodeInfo * newInfo)69 int32_t LnnUpdateNetworkId(const NodeInfo *newInfo)
70 {
71 return GetDataCloudSyncInterface()->LnnUpdateNetworkId(newInfo);
72 }
73
LnnGetLocalBroadcastCipherInfo(CloudSyncInfo * info)74 int32_t LnnGetLocalBroadcastCipherInfo(CloudSyncInfo *info)
75 {
76 return GetDataCloudSyncInterface()->LnnGetLocalBroadcastCipherInfo(info);
77 }
78
LnnSetRemoteBroadcastCipherInfo(const char * value,const char * udid)79 int32_t LnnSetRemoteBroadcastCipherInfo(const char *value, const char *udid)
80 {
81 return GetDataCloudSyncInterface()->LnnSetRemoteBroadcastCipherInfo(value, udid);
82 }
83
LnnGenerateHexStringHash(const unsigned char * str,char * hashStr,uint32_t len)84 int32_t LnnGenerateHexStringHash(const unsigned char *str, char *hashStr, uint32_t len)
85 {
86 return GetDataCloudSyncInterface()->LnnGenerateHexStringHash(str, hashStr, len);
87 }
88
ConvertHexStringToBytes(unsigned char * outBuf,uint32_t outBufLen,const char * inBuf,uint32_t inLen)89 int32_t ConvertHexStringToBytes(unsigned char *outBuf, uint32_t outBufLen, const char *inBuf, uint32_t inLen)
90 {
91 return GetDataCloudSyncInterface()->ConvertHexStringToBytes(outBuf, outBufLen, inBuf, inLen);
92 }
93
LnnAsyncCallbackDelayHelper(SoftBusLooper * looper,LnnAsyncCallbackFunc callback,void * para,uint64_t delayMillis)94 int32_t LnnAsyncCallbackDelayHelper(
95 SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para, uint64_t delayMillis)
96 {
97 return GetDataCloudSyncInterface()->LnnAsyncCallbackDelayHelper(looper, callback, para, delayMillis);
98 }
99
LnnGetLocalNodeInfoSafe(NodeInfo * info)100 int32_t LnnGetLocalNodeInfoSafe(NodeInfo *info)
101 {
102 return GetDataCloudSyncInterface()->LnnGetLocalNodeInfoSafe(info);
103 }
104
LnnPackCloudSyncAckSeq(cJSON * json,char * peerudid)105 int32_t LnnPackCloudSyncAckSeq(cJSON *json, char *peerudid)
106 {
107 return GetDataCloudSyncInterface()->LnnPackCloudSyncAckSeq(json, peerudid);
108 }
109 }
110 } // namespace OHOS