1 /*
2 * Copyright (c) 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 <cstdint>
17 #include <securec.h>
18
19 #include "lnn_local_ledger_deps_mock.h"
20 #include "lnn_sle_capability_mock.h"
21 #include "softbus_common.h"
22 #include "softbus_error_code.h"
23
24 using namespace testing;
25 using namespace testing::ext;
26
27 namespace OHOS {
28 void *g_lnnSleCapabilityInterface;
29
LnnSleCapabilityInterfaceMock()30 LnnSleCapabilityInterfaceMock::LnnSleCapabilityInterfaceMock()
31 {
32 g_lnnSleCapabilityInterface = reinterpret_cast<void *>(this);
33 }
34
~LnnSleCapabilityInterfaceMock()35 LnnSleCapabilityInterfaceMock::~LnnSleCapabilityInterfaceMock()
36 {
37 g_lnnSleCapabilityInterface = nullptr;
38 }
39
GetLnnSleCapabilityInterface()40 static LnnSleCapabilityInterfaceMock *GetLnnSleCapabilityInterface()
41 {
42 return reinterpret_cast<LnnSleCapabilityInterfaceMock *>(g_lnnSleCapabilityInterface);
43 }
44
45 extern "C" {
GetSleRangeCapacityPacked(void)46 int32_t GetSleRangeCapacityPacked(void)
47 {
48 return GetLnnSleCapabilityInterface()->GetSleRangeCapacityPacked();
49 }
50
LnnGetLocalNumInfo(InfoKey key,int32_t * info)51 int32_t LnnGetLocalNumInfo(InfoKey key, int32_t *info)
52 {
53 return GetLnnSleCapabilityInterface()->LnnGetLocalNumInfo(key, info);
54 }
55
LnnUpdateSleCapacityAndVersion(int32_t slecap)56 int32_t LnnUpdateSleCapacityAndVersion(int32_t slecap)
57 {
58 return GetLnnSleCapabilityInterface()->LnnUpdateSleCapacityAndVersion(slecap);
59 }
60
IsSleEnabledPacked(void)61 bool IsSleEnabledPacked(void)
62 {
63 return GetLnnSleCapabilityInterface()->IsSleEnabledPacked();
64 }
65
GetLocalSleAddrPacked(char * sleAddr,uint32_t sleAddrLen)66 int32_t GetLocalSleAddrPacked(char *sleAddr, uint32_t sleAddrLen)
67 {
68 return GetLnnSleCapabilityInterface()->GetLocalSleAddrPacked(sleAddr, sleAddrLen);
69 }
70
LnnSetLocalStrInfo(InfoKey key,const char * info)71 int32_t LnnSetLocalStrInfo(InfoKey key, const char *info)
72 {
73 return GetLnnSleCapabilityInterface()->LnnSetLocalStrInfo(key, info);
74 }
75
cJSON_CreateObject()76 cJSON *cJSON_CreateObject()
77 {
78 return GetLnnSleCapabilityInterface()->cJSON_CreateObject();
79 }
80
AddNumberToJsonObject(cJSON * json,const char * const string,int32_t num)81 bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num)
82 {
83 return GetLnnSleCapabilityInterface()->AddNumberToJsonObject(json, string, num);
84 }
85
AddStringToJsonObject(cJSON * json,const char * const string,const char * value)86 bool AddStringToJsonObject(cJSON *json, const char * const string, const char *value)
87 {
88 return GetLnnSleCapabilityInterface()->AddStringToJsonObject(json, string, value);
89 }
90
LnnRegSyncInfoHandler(LnnSyncInfoType type,LnnSyncInfoMsgHandler handler)91 int32_t LnnRegSyncInfoHandler(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler)
92 {
93 return GetLnnSleCapabilityInterface()->LnnRegSyncInfoHandler(type, handler);
94 }
95
SoftBusAddSleStateListenerPacked(const SoftBusSleStateListener * listener,int32_t * listenerId)96 int32_t SoftBusAddSleStateListenerPacked(const SoftBusSleStateListener *listener, int32_t *listenerId)
97 {
98 return GetLnnSleCapabilityInterface()->SoftBusAddSleStateListenerPacked(listener, listenerId);
99 }
100
LnnSetDLSleRangeInfo(const char * id,IdCategory type,int32_t sleCap,const char * addr)101 int32_t LnnSetDLSleRangeInfo(const char *id, IdCategory type, int32_t sleCap, const char *addr)
102 {
103 return GetLnnSleCapabilityInterface()->LnnSetDLSleRangeInfo(id, type, sleCap, addr);
104 }
105 } // extern "C"
106 } // namespace OHOS
107