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_wifiservice_monitor_mock.h"
17 #include "softbus_error_code.h"
18 
19 namespace OHOS {
20 void *g_interface = nullptr;
21 
LnnWifiServiceMonitorInterfaceMock()22 LnnWifiServiceMonitorInterfaceMock::LnnWifiServiceMonitorInterfaceMock()
23 {
24     g_interface = reinterpret_cast<void *>(this);
25 }
26 
~LnnWifiServiceMonitorInterfaceMock()27 LnnWifiServiceMonitorInterfaceMock::~LnnWifiServiceMonitorInterfaceMock()
28 {
29     if (g_interface != nullptr) {
30         free(g_interface);
31         g_interface = nullptr;
32     }
33 }
34 
GetLnnWifiServiceMonitorInterface()35 static LnnWifiServiceMonitorInterface *GetLnnWifiServiceMonitorInterface()
36 {
37     return reinterpret_cast<LnnWifiServiceMonitorInterface *>(g_interface);
38 }
39 
40 extern "C" {
GetLooper(int32_t looper)41     SoftBusLooper *GetLooper(int32_t looper)
42     {
43         return GetLnnWifiServiceMonitorInterface()->GetLooper(looper);
44     }
45 
LnnNotifyWlanStateChangeEvent(void *state)46     void LnnNotifyWlanStateChangeEvent(void *state)
47     {
48         return GetLnnWifiServiceMonitorInterface()->LnnNotifyWlanStateChangeEvent(state);
49     }
50 
LnnAsyncCallbackHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para)51     int32_t LnnAsyncCallbackHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para)
52     {
53         return GetLnnWifiServiceMonitorInterface()->LnnAsyncCallbackHelper(looper, callback, para);
54     }
55 
SoftBusIsWifiActive(void)56     bool SoftBusIsWifiActive(void)
57     {
58         return GetLnnWifiServiceMonitorInterface()->SoftBusIsWifiActive();
59     }
60 
SoftBusGetLinkedInfo(SoftBusWifiLinkedInfo *info)61     int32_t SoftBusGetLinkedInfo(SoftBusWifiLinkedInfo *info)
62     {
63         return GetLnnWifiServiceMonitorInterface()->SoftBusGetLinkedInfo(info);
64     }
65 
LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para, uint64_t delayMillis)66     int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
67         void *para, uint64_t delayMillis)
68     {
69         return GetLnnWifiServiceMonitorInterface()->LnnAsyncCallbackDelayHelper(looper, callback, para, delayMillis);
70     }
71 }
72 } // namespace OHOS