• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "bus_center_utils_mock.h"
17 
18 using namespace testing::ext;
19 using namespace testing;
20 
21 namespace OHOS {
22 void *g_buscenterUtilsInterface;
BusCenterUtilsInterfaceMock()23 BusCenterUtilsInterfaceMock::BusCenterUtilsInterfaceMock()
24 {
25     g_buscenterUtilsInterface = reinterpret_cast<void *>(this);
26 }
27 
~BusCenterUtilsInterfaceMock()28 BusCenterUtilsInterfaceMock::~BusCenterUtilsInterfaceMock()
29 {
30     g_buscenterUtilsInterface = nullptr;
31 }
32 
GetBusCenterUtilsInterface()33 static BusCenterUtilsInterface *GetBusCenterUtilsInterface()
34 {
35     return reinterpret_cast<BusCenterUtilsInterface *>(g_buscenterUtilsInterface);
36 }
37 
38 extern "C" {
LnnGetFullStoragePath(LnnFileId id,char * path,uint32_t len)39 int32_t LnnGetFullStoragePath(LnnFileId id, char *path, uint32_t len)
40 {
41     return GetBusCenterUtilsInterface()->LnnGetFullStoragePath(id, path, len);
42 }
43 
SoftBusReadFullFile(const char * fileName,char * readBuf,uint32_t maxLen)44 int32_t SoftBusReadFullFile(const char *fileName, char *readBuf, uint32_t maxLen)
45 {
46     return GetBusCenterUtilsInterface()->SoftBusReadFullFile(fileName, readBuf, maxLen);
47 }
48 
GenerateRandomStr(char * str,uint32_t size)49 int32_t GenerateRandomStr(char *str, uint32_t size)
50 {
51     return GetBusCenterUtilsInterface()->GenerateRandomStr(str, size);
52 }
53 
SoftBusWriteFile(const char * fileName,const char * writeBuf,uint32_t len)54 int32_t SoftBusWriteFile(const char *fileName, const char *writeBuf, uint32_t len)
55 {
56     return GetBusCenterUtilsInterface()->SoftBusWriteFile(fileName, writeBuf, len);
57 }
58 
SoftBusGenerateRandomArray(unsigned char * randStr,uint32_t len)59 int32_t SoftBusGenerateRandomArray(unsigned char *randStr, uint32_t len)
60 {
61     return GetBusCenterUtilsInterface()->SoftBusGenerateRandomArray(randStr, len);
62 }
63 
SoftBusDecryptData(AesGcmCipherKey * key,const unsigned char * input,uint32_t inLen,unsigned char * decryptData,uint32_t * decryptLen)64 int32_t SoftBusDecryptData(
65     AesGcmCipherKey *key, const unsigned char *input, uint32_t inLen, unsigned char *decryptData, uint32_t *decryptLen)
66 {
67     return GetBusCenterUtilsInterface()->SoftBusDecryptData(key, input, inLen, decryptData, decryptLen);
68 }
69 }
70 } // namespace OHOS