1 /* 2 * Copyright (c) 2021 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 "mock_wifi_public.h" 17 18 using namespace OHOS::Wifi; 19 20 static bool g_mockTag = false; 21 GetInstance()22MockWifiPublic &MockWifiPublic::GetInstance() 23 { 24 static MockWifiPublic gMockWifiPublic; 25 return gMockWifiPublic; 26 }; 27 MockWifiPublic()28MockWifiPublic::MockWifiPublic() 29 {} 30 SetMockFlag(bool flag)31void MockWifiPublic::SetMockFlag(bool flag) 32 { 33 g_mockTag = flag; 34 } 35 GetMockFlag(void)36bool MockWifiPublic::GetMockFlag(void) 37 { 38 return g_mockTag; 39 } 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 int __real_RemoteCall(RpcClient *client); __wrap_RemoteCall(RpcClient * client)45int __wrap_RemoteCall(RpcClient *client) 46 { 47 if (g_mockTag) { 48 return MockWifiPublic::GetInstance().RemoteCall(client); 49 } else { 50 return __real_RemoteCall(client); 51 } 52 } 53 #ifdef __cplusplus 54 } 55 #endif 56