• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "client_trans_proxy_manager_d2d_mock.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS {
22 void *g_transD2DInterface;
TransClientProxyD2DInterfaceMock()23 TransClientProxyD2DInterfaceMock::TransClientProxyD2DInterfaceMock()
24 {
25     g_transD2DInterface = reinterpret_cast<void *>(this);
26 }
27 
~TransClientProxyD2DInterfaceMock()28 TransClientProxyD2DInterfaceMock::~TransClientProxyD2DInterfaceMock()
29 {
30     g_transD2DInterface = nullptr;
31 }
32 
GetProxyManagerD2DInterface()33 static TransClientProxyManagerD2DInterface *GetProxyManagerD2DInterface()
34 {
35     return reinterpret_cast<TransClientProxyManagerD2DInterface *>(g_transD2DInterface);
36 }
37 
38 extern "C" {
ClientGetChannelBusinessTypeByChannelId(int32_t channelId,int32_t * businessType)39 int32_t ClientGetChannelBusinessTypeByChannelId(int32_t channelId, int32_t *businessType)
40 {
41     return GetProxyManagerD2DInterface()->ClientGetChannelBusinessTypeByChannelId(channelId, businessType);
42 }
43 
TransProxyPackD2DBytes(ProxyDataInfo * dataInfo,const char * sessionKey,const char * sessionIv,SessionPktType flag)44 int32_t TransProxyPackD2DBytes(ProxyDataInfo *dataInfo, const char *sessionKey, const char *sessionIv,
45     SessionPktType flag)
46 {
47     return GetProxyManagerD2DInterface()->TransProxyPackD2DBytes(dataInfo, sessionKey, sessionIv, flag);
48 }
49 
TransProxyPackD2DData(ProxyDataInfo * dataInfo,uint32_t sliceNum,SessionPktType pktType,uint32_t cnt,uint32_t * dataLen)50 uint8_t *TransProxyPackD2DData(ProxyDataInfo *dataInfo, uint32_t sliceNum, SessionPktType pktType,
51     uint32_t cnt, uint32_t *dataLen)
52 {
53     return GetProxyManagerD2DInterface()->TransProxyPackD2DData(dataInfo, sliceNum, pktType, cnt, dataLen);
54 }
55 
ServerIpcSendMessage(int32_t channelId,int32_t channelType,const void * data,uint32_t len,int32_t msgType)56 int32_t ServerIpcSendMessage(int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType)
57 {
58     return GetProxyManagerD2DInterface()->ServerIpcSendMessage(channelId, channelType, data, len, msgType);
59 }
60 
TransProxyProcessD2DData(ProxyDataInfo * dataInfo,const PacketD2DHead * dataHead,const char * data,int32_t businessType)61 int32_t TransProxyProcessD2DData(ProxyDataInfo *dataInfo, const PacketD2DHead *dataHead,
62     const char *data, int32_t businessType)
63 {
64     return GetProxyManagerD2DInterface()->TransProxyProcessD2DData(dataInfo, dataHead, data, businessType);
65 }
66 
TransProxyDecryptD2DData(int32_t businessType,ProxyDataInfo * dataInfo,const char * sessionKey,const unsigned char * sessionCommonIv)67 int32_t TransProxyDecryptD2DData(int32_t businessType, ProxyDataInfo *dataInfo, const char *sessionKey,
68     const unsigned char *sessionCommonIv)
69 {
70     return GetProxyManagerD2DInterface()->TransProxyDecryptD2DData(businessType, dataInfo, sessionKey, sessionCommonIv);
71 }
72 
TransProxySessionDataLenCheck(uint32_t dataLen,SessionPktType type)73 int32_t TransProxySessionDataLenCheck(uint32_t dataLen, SessionPktType type)
74 {
75     return GetProxyManagerD2DInterface()->TransProxySessionDataLenCheck(dataLen, type);
76 }
77 
ClientGetSessionIdByChannelId(int32_t channelId,int32_t channelType,int32_t * sessionId,bool isClosing)78 int32_t ClientGetSessionIdByChannelId(int32_t channelId, int32_t channelType, int32_t *sessionId, bool isClosing)
79 {
80     return GetProxyManagerD2DInterface()->ClientGetSessionIdByChannelId(channelId, channelType, sessionId, isClosing);
81 }
82 
ClientGetSessionCallbackAdapterById(int32_t sessionId,SessionListenerAdapter * callbackAdapter,bool * isServer)83 int32_t ClientGetSessionCallbackAdapterById(int32_t sessionId, SessionListenerAdapter *callbackAdapter, bool *isServer)
84 {
85     return GetProxyManagerD2DInterface()->ClientGetSessionCallbackAdapterById(sessionId, callbackAdapter, isServer);
86 }
87 
DeleteDataSeqInfoList(uint32_t dataSeq,int32_t channelId)88 int32_t DeleteDataSeqInfoList(uint32_t dataSeq, int32_t channelId)
89 {
90     return GetProxyManagerD2DInterface()->DeleteDataSeqInfoList(dataSeq, channelId);
91 }
92 
GetSupportTlvAndNeedAckById(int32_t channelId,int32_t channelType,bool * supportTlv,bool * needAck)93 int32_t GetSupportTlvAndNeedAckById(int32_t channelId, int32_t channelType, bool *supportTlv, bool *needAck)
94 {
95     return GetProxyManagerD2DInterface()->GetSupportTlvAndNeedAckById(
96         channelId, channelType, supportTlv, needAck);
97 }
98 
DataSeqInfoListAddItem(uint32_t dataSeq,int32_t channelId,int32_t socketId,int32_t channelType)99 int32_t DataSeqInfoListAddItem(uint32_t dataSeq, int32_t channelId, int32_t socketId, int32_t channelType)
100 {
101     return GetProxyManagerD2DInterface()->DataSeqInfoListAddItem(dataSeq, channelId, socketId, channelType);
102 }
103 }
104 }
105