1 /*
2 * Copyright (c) 2021-2023 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 "softbus_server_proxy_standard.h"
17
18 #include "softbus_client_stub.h"
19 #include "softbus_server_ipc_interface_code.h"
20
21 namespace OHOS {
22 sptr<IRemoteObject> SoftBusServerProxyFrame::clientCallbackStub_;
23 std::mutex SoftBusServerProxyFrame::instanceLock;
24
GetRemoteInstance()25 sptr<IRemoteObject> SoftBusServerProxyFrame::GetRemoteInstance()
26 {
27 if (clientCallbackStub_ == nullptr) {
28 std::lock_guard<std::mutex> autoLock(instanceLock);
29 if (clientCallbackStub_ == nullptr) {
30 clientCallbackStub_ = sptr<IRemoteObject>(new (std::nothrow) SoftBusClientStub());
31 }
32 }
33 return clientCallbackStub_;
34 }
35
SoftbusRegisterService(const char * clientPkgName,const sptr<IRemoteObject> & object)36 int32_t SoftBusServerProxyFrame::SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject>& object)
37 {
38 sptr<IRemoteObject> remote = Remote();
39 if (remote == nullptr) {
40 COMM_LOGE(COMM_SDK, "remote is nullptr!");
41 return SOFTBUS_IPC_ERR;
42 }
43
44 sptr<IRemoteObject> clientStub = SoftBusServerProxyFrame::GetRemoteInstance();
45 if (clientStub == nullptr) {
46 COMM_LOGE(COMM_SDK, "client stub is nullptr!");
47 return SOFTBUS_IPC_ERR;
48 }
49 MessageParcel data;
50 if (!data.WriteInterfaceToken(GetDescriptor())) {
51 COMM_LOGE(COMM_SDK, "SoftbusRegisterService write InterfaceToken failed!");
52 return SOFTBUS_TRANS_PROXY_WRITETOKEN_FAILED;
53 }
54 if (!data.WriteRemoteObject(clientStub)) {
55 COMM_LOGE(COMM_SDK, "SoftbusRegisterService write remote object failed!");
56 return SOFTBUS_TRANS_PROXY_WRITEOBJECT_FAILED;
57 }
58 if (!data.WriteCString(clientPkgName)) {
59 COMM_LOGE(COMM_SDK, "SoftbusRegisterService write clientPkgName failed!");
60 return SOFTBUS_TRANS_PROXY_WRITECSTRING_FAILED;
61 }
62
63 MessageParcel reply;
64 MessageOption option;
65 int32_t err = remote->SendRequest(MANAGE_REGISTER_SERVICE, data, reply, option);
66 if (err != 0) {
67 COMM_LOGE(COMM_SDK, "SoftbusRegisterService send request failed!");
68 return SOFTBUS_IPC_ERR;
69 }
70 int32_t serverRet = 0;
71 if (!reply.ReadInt32(serverRet)) {
72 COMM_LOGE(COMM_SDK, "SoftbusRegisterService read serverRet failed!");
73 return SOFTBUS_TRANS_PROXY_READINT_FAILED;
74 }
75 return serverRet;
76 }
77
CreateSessionServer(const char * pkgName,const char * sessionName)78 int32_t SoftBusServerProxyFrame::CreateSessionServer(const char *pkgName, const char *sessionName)
79 {
80 (void)pkgName;
81 (void)sessionName;
82 return SOFTBUS_OK;
83 }
84
RemoveSessionServer(const char * pkgName,const char * sessionName)85 int32_t SoftBusServerProxyFrame::RemoveSessionServer(const char *pkgName, const char *sessionName)
86 {
87 (void)pkgName;
88 (void)sessionName;
89 return SOFTBUS_OK;
90 }
91
OpenSession(const SessionParam * param,TransInfo * info)92 int32_t SoftBusServerProxyFrame::OpenSession(const SessionParam *param, TransInfo *info)
93 {
94 (void)param;
95 (void)info;
96 return SOFTBUS_OK;
97 }
98
OpenAuthSession(const char * sessionName,const ConnectionAddr * addrInfo)99 int32_t SoftBusServerProxyFrame::OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo)
100 {
101 (void)sessionName;
102 (void)addrInfo;
103 return SOFTBUS_OK;
104 }
105
NotifyAuthSuccess(int32_t channelId,int32_t channelType)106 int32_t SoftBusServerProxyFrame::NotifyAuthSuccess(int32_t channelId, int32_t channelType)
107 {
108 (void)channelId;
109 (void)channelType;
110 return SOFTBUS_OK;
111 }
112
ReleaseResources(int32_t channelId)113 int32_t SoftBusServerProxyFrame::ReleaseResources(int32_t channelId)
114 {
115 (void)channelId;
116 return SOFTBUS_OK;
117 }
118
CloseChannel(const char * sessionName,int32_t channelId,int32_t channelType)119 int32_t SoftBusServerProxyFrame::CloseChannel(const char *sessionName, int32_t channelId, int32_t channelType)
120 {
121 (void)sessionName;
122 (void)channelId;
123 (void)channelType;
124 return SOFTBUS_OK;
125 }
126
CloseChannelWithStatistics(int32_t channelId,int32_t channelType,uint64_t laneId,const void * dataInfo,uint32_t len)127 int32_t SoftBusServerProxyFrame::CloseChannelWithStatistics(int32_t channelId, int32_t channelType, uint64_t laneId,
128 const void *dataInfo, uint32_t len)
129 {
130 (void)channelId;
131 (void)channelType;
132 (void)laneId;
133 (void)dataInfo;
134 (void)len;
135 return SOFTBUS_OK;
136 }
137
SendMessage(int32_t channelId,int32_t channelType,const void * data,uint32_t len,int32_t msgType)138 int32_t SoftBusServerProxyFrame::SendMessage(int32_t channelId, int32_t channelType, const void *data,
139 uint32_t len, int32_t msgType)
140 {
141 (void)channelId;
142 (void)channelType;
143 (void)data;
144 (void)len;
145 (void)msgType;
146 return SOFTBUS_OK;
147 }
148
JoinLNN(const char * pkgName,void * addr,uint32_t addrTypeLen,bool isForceJoin)149 int32_t SoftBusServerProxyFrame::JoinLNN(const char *pkgName, void *addr, uint32_t addrTypeLen, bool isForceJoin)
150 {
151 (void)pkgName;
152 (void)addr;
153 (void)addrTypeLen;
154 (void)isForceJoin;
155 return SOFTBUS_OK;
156 }
157
LeaveLNN(const char * pkgName,const char * networkId)158 int32_t SoftBusServerProxyFrame::LeaveLNN(const char *pkgName, const char *networkId)
159 {
160 (void)pkgName;
161 (void)networkId;
162 return SOFTBUS_OK;
163 }
164
GetAllOnlineNodeInfo(const char * pkgName,void ** info,uint32_t infoTypeLen,int * infoNum)165 int32_t SoftBusServerProxyFrame::GetAllOnlineNodeInfo(const char *pkgName, void **info, uint32_t infoTypeLen,
166 int *infoNum)
167 {
168 (void)pkgName;
169 (void)info;
170 (void)infoTypeLen;
171 (void)infoNum;
172 return SOFTBUS_OK;
173 }
174
GetLocalDeviceInfo(const char * pkgName,void * info,uint32_t infoTypeLen)175 int32_t SoftBusServerProxyFrame::GetLocalDeviceInfo(const char *pkgName, void *info, uint32_t infoTypeLen)
176 {
177 (void)pkgName;
178 (void)info;
179 (void)infoTypeLen;
180 return SOFTBUS_OK;
181 }
182
GetNodeKeyInfo(const char * pkgName,const char * networkId,int key,unsigned char * buf,uint32_t len)183 int32_t SoftBusServerProxyFrame::GetNodeKeyInfo(const char *pkgName, const char *networkId, int key,
184 unsigned char *buf, uint32_t len)
185 {
186 (void)pkgName;
187 (void)networkId;
188 (void)key;
189 (void)buf;
190 (void)len;
191 return SOFTBUS_OK;
192 }
193
SetNodeDataChangeFlag(const char * pkgName,const char * networkId,uint16_t dataChangeFlag)194 int32_t SoftBusServerProxyFrame::SetNodeDataChangeFlag(const char *pkgName, const char *networkId,
195 uint16_t dataChangeFlag)
196 {
197 (void)pkgName;
198 (void)networkId;
199 (void)dataChangeFlag;
200 return SOFTBUS_OK;
201 }
202
RegDataLevelChangeCb(const char * pkgName)203 int32_t SoftBusServerProxyFrame::RegDataLevelChangeCb(const char *pkgName)
204 {
205 (void)pkgName;
206 return SOFTBUS_OK;
207 }
208
UnregDataLevelChangeCb(const char * pkgName)209 int32_t SoftBusServerProxyFrame::UnregDataLevelChangeCb(const char *pkgName)
210 {
211 (void)pkgName;
212 return SOFTBUS_OK;
213 }
214
SetDataLevel(const DataLevel * dataLevel)215 int32_t SoftBusServerProxyFrame::SetDataLevel(const DataLevel *dataLevel)
216 {
217 (void)dataLevel;
218 return SOFTBUS_OK;
219 }
220
RegBleRangeCb(const char * pkgName)221 int32_t SoftBusServerProxyFrame::RegBleRangeCb(const char *pkgName)
222 {
223 (void)pkgName;
224 return SOFTBUS_OK;
225 }
226
UnregBleRangeCb(const char * pkgName)227 int32_t SoftBusServerProxyFrame::UnregBleRangeCb(const char *pkgName)
228 {
229 (void)pkgName;
230 return SOFTBUS_OK;
231 }
232
StartTimeSync(const char * pkgName,const char * targetNetworkId,int32_t accuracy,int32_t period)233 int32_t SoftBusServerProxyFrame::StartTimeSync(const char *pkgName, const char *targetNetworkId, int32_t accuracy,
234 int32_t period)
235 {
236 (void)pkgName;
237 (void)targetNetworkId;
238 (void)accuracy;
239 (void)period;
240 return SOFTBUS_OK;
241 }
242
StopTimeSync(const char * pkgName,const char * targetNetworkId)243 int32_t SoftBusServerProxyFrame::StopTimeSync(const char *pkgName, const char *targetNetworkId)
244 {
245 (void)pkgName;
246 (void)targetNetworkId;
247 return SOFTBUS_OK;
248 }
249
QosReport(int32_t channelId,int32_t chanType,int32_t appType,int32_t quality)250 int32_t SoftBusServerProxyFrame::QosReport(int32_t channelId, int32_t chanType, int32_t appType, int32_t quality)
251 {
252 (void)channelId;
253 (void)chanType;
254 (void)appType;
255 (void)quality;
256 return SOFTBUS_OK;
257 }
258
StreamStats(int32_t channelId,int32_t channelType,const StreamSendStats * data)259 int32_t SoftBusServerProxyFrame::StreamStats(int32_t channelId, int32_t channelType, const StreamSendStats *data)
260 {
261 (void)channelId;
262 (void)channelType;
263 (void)data;
264 return SOFTBUS_OK;
265 }
266
RippleStats(int32_t channelId,int32_t channelType,const TrafficStats * data)267 int32_t SoftBusServerProxyFrame::RippleStats(int32_t channelId, int32_t channelType, const TrafficStats *data)
268 {
269 (void)channelId;
270 (void)channelType;
271 (void)data;
272 return SOFTBUS_OK;
273 }
274
EvaluateQos(const char * peerNetworkId,TransDataType dataType,const QosTV * qos,uint32_t qosCount)275 int32_t SoftBusServerProxyFrame::EvaluateQos(const char *peerNetworkId, TransDataType dataType, const QosTV *qos,
276 uint32_t qosCount)
277 {
278 (void)peerNetworkId;
279 (void)dataType;
280 (void)qos;
281 (void)qosCount;
282 return SOFTBUS_OK;
283 }
284
ProcessInnerEvent(int32_t eventType,uint8_t * buf,uint32_t len)285 int32_t SoftBusServerProxyFrame::ProcessInnerEvent(int32_t eventType, uint8_t *buf, uint32_t len)
286 {
287 (void)eventType;
288 (void)buf;
289 (void)len;
290 return SOFTBUS_OK;
291 }
292
PrivilegeCloseChannel(uint64_t tokenId,int32_t pid,const char * peerNetworkId)293 int32_t SoftBusServerProxyFrame::PrivilegeCloseChannel(uint64_t tokenId, int32_t pid, const char *peerNetworkId)
294 {
295 (void)tokenId;
296 (void)pid;
297 (void)peerNetworkId;
298 return SOFTBUS_OK;
299 }
300 } // namespace OHOS