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
RegisterBrProxyService(const char * clientPkgName,const sptr<IRemoteObject> & object)78 int32_t SoftBusServerProxyFrame::RegisterBrProxyService(const char *clientPkgName, const sptr<IRemoteObject>& object)
79 {
80 sptr<IRemoteObject> remote = Remote();
81 if (remote == nullptr) {
82 COMM_LOGE(COMM_SDK, "remote is nullptr!");
83 return SOFTBUS_IPC_ERR;
84 }
85
86 sptr<IRemoteObject> clientStub = SoftBusServerProxyFrame::GetRemoteInstance();
87 if (clientStub == nullptr) {
88 COMM_LOGE(COMM_SDK, "client stub is nullptr!");
89 return SOFTBUS_IPC_ERR;
90 }
91 MessageParcel data;
92 if (!data.WriteInterfaceToken(GetDescriptor())) {
93 COMM_LOGE(COMM_SDK, "write InterfaceToken failed!");
94 return SOFTBUS_TRANS_PROXY_WRITETOKEN_FAILED;
95 }
96 if (!data.WriteRemoteObject(clientStub)) {
97 COMM_LOGE(COMM_SDK, "write remote object failed!");
98 return SOFTBUS_TRANS_PROXY_WRITEOBJECT_FAILED;
99 }
100 if (!data.WriteCString(clientPkgName)) {
101 COMM_LOGE(COMM_SDK, "write clientPkgName failed!");
102 return SOFTBUS_TRANS_PROXY_WRITECSTRING_FAILED;
103 }
104
105 MessageParcel reply;
106 MessageOption option;
107 int32_t err = remote->SendRequest(MANAGE_REGISTER_BR_PROXY_SERVICE, data, reply, option);
108 if (err != SOFTBUS_OK) {
109 COMM_LOGE(COMM_SDK, "SoftbusRegisterService send request failed! err:%{public}d", err);
110 return err;
111 }
112 int32_t serverRet = 0;
113 if (!reply.ReadInt32(serverRet)) {
114 COMM_LOGE(COMM_SDK, "SoftbusRegisterService read serverRet failed!");
115 return SOFTBUS_TRANS_PROXY_READINT_FAILED;
116 }
117 return serverRet;
118 }
119
CreateSessionServer(const char * pkgName,const char * sessionName,uint64_t timestamp)120 int32_t SoftBusServerProxyFrame::CreateSessionServer(const char *pkgName, const char *sessionName, uint64_t timestamp)
121 {
122 (void)pkgName;
123 (void)sessionName;
124 (void)timestamp;
125 return SOFTBUS_OK;
126 }
127
RemoveSessionServer(const char * pkgName,const char * sessionName,uint64_t timestamp)128 int32_t SoftBusServerProxyFrame::RemoveSessionServer(const char *pkgName, const char *sessionName, uint64_t timestamp)
129 {
130 (void)pkgName;
131 (void)sessionName;
132 (void)timestamp;
133 return SOFTBUS_OK;
134 }
135
OpenSession(const SessionParam * param,TransInfo * info)136 int32_t SoftBusServerProxyFrame::OpenSession(const SessionParam *param, TransInfo *info)
137 {
138 (void)param;
139 (void)info;
140 return SOFTBUS_OK;
141 }
142
OpenAuthSession(const char * sessionName,const ConnectionAddr * addrInfo)143 int32_t SoftBusServerProxyFrame::OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo)
144 {
145 (void)sessionName;
146 (void)addrInfo;
147 return SOFTBUS_OK;
148 }
149
NotifyAuthSuccess(int32_t channelId,int32_t channelType)150 int32_t SoftBusServerProxyFrame::NotifyAuthSuccess(int32_t channelId, int32_t channelType)
151 {
152 (void)channelId;
153 (void)channelType;
154 return SOFTBUS_OK;
155 }
156
ReleaseResources(int32_t channelId)157 int32_t SoftBusServerProxyFrame::ReleaseResources(int32_t channelId)
158 {
159 (void)channelId;
160 return SOFTBUS_OK;
161 }
162
CloseChannel(const char * sessionName,int32_t channelId,int32_t channelType)163 int32_t SoftBusServerProxyFrame::CloseChannel(const char *sessionName, int32_t channelId, int32_t channelType)
164 {
165 (void)sessionName;
166 (void)channelId;
167 (void)channelType;
168 return SOFTBUS_OK;
169 }
170
CloseChannelWithStatistics(int32_t channelId,int32_t channelType,uint64_t laneId,const void * dataInfo,uint32_t len)171 int32_t SoftBusServerProxyFrame::CloseChannelWithStatistics(int32_t channelId, int32_t channelType, uint64_t laneId,
172 const void *dataInfo, uint32_t len)
173 {
174 (void)channelId;
175 (void)channelType;
176 (void)laneId;
177 (void)dataInfo;
178 (void)len;
179 return SOFTBUS_OK;
180 }
181
SendMessage(int32_t channelId,int32_t channelType,const void * data,uint32_t len,int32_t msgType)182 int32_t SoftBusServerProxyFrame::SendMessage(int32_t channelId, int32_t channelType, const void *data,
183 uint32_t len, int32_t msgType)
184 {
185 (void)channelId;
186 (void)channelType;
187 (void)data;
188 (void)len;
189 (void)msgType;
190 return SOFTBUS_OK;
191 }
192
JoinLNN(const char * pkgName,void * addr,uint32_t addrTypeLen,bool isForceJoin)193 int32_t SoftBusServerProxyFrame::JoinLNN(const char *pkgName, void *addr, uint32_t addrTypeLen, bool isForceJoin)
194 {
195 (void)pkgName;
196 (void)addr;
197 (void)addrTypeLen;
198 (void)isForceJoin;
199 return SOFTBUS_OK;
200 }
201
LeaveLNN(const char * pkgName,const char * networkId)202 int32_t SoftBusServerProxyFrame::LeaveLNN(const char *pkgName, const char *networkId)
203 {
204 (void)pkgName;
205 (void)networkId;
206 return SOFTBUS_OK;
207 }
208
GetAllOnlineNodeInfo(const char * pkgName,void ** info,uint32_t infoTypeLen,int * infoNum)209 int32_t SoftBusServerProxyFrame::GetAllOnlineNodeInfo(const char *pkgName, void **info, uint32_t infoTypeLen,
210 int *infoNum)
211 {
212 (void)pkgName;
213 (void)info;
214 (void)infoTypeLen;
215 (void)infoNum;
216 return SOFTBUS_OK;
217 }
218
GetLocalDeviceInfo(const char * pkgName,void * info,uint32_t infoTypeLen)219 int32_t SoftBusServerProxyFrame::GetLocalDeviceInfo(const char *pkgName, void *info, uint32_t infoTypeLen)
220 {
221 (void)pkgName;
222 (void)info;
223 (void)infoTypeLen;
224 return SOFTBUS_OK;
225 }
226
GetNodeKeyInfo(const char * pkgName,const char * networkId,int key,unsigned char * buf,uint32_t len)227 int32_t SoftBusServerProxyFrame::GetNodeKeyInfo(const char *pkgName, const char *networkId, int key,
228 unsigned char *buf, uint32_t len)
229 {
230 (void)pkgName;
231 (void)networkId;
232 (void)key;
233 (void)buf;
234 (void)len;
235 return SOFTBUS_OK;
236 }
237
SetNodeDataChangeFlag(const char * pkgName,const char * networkId,uint16_t dataChangeFlag)238 int32_t SoftBusServerProxyFrame::SetNodeDataChangeFlag(const char *pkgName, const char *networkId,
239 uint16_t dataChangeFlag)
240 {
241 (void)pkgName;
242 (void)networkId;
243 (void)dataChangeFlag;
244 return SOFTBUS_OK;
245 }
246
RegDataLevelChangeCb(const char * pkgName)247 int32_t SoftBusServerProxyFrame::RegDataLevelChangeCb(const char *pkgName)
248 {
249 (void)pkgName;
250 return SOFTBUS_OK;
251 }
252
UnregDataLevelChangeCb(const char * pkgName)253 int32_t SoftBusServerProxyFrame::UnregDataLevelChangeCb(const char *pkgName)
254 {
255 (void)pkgName;
256 return SOFTBUS_OK;
257 }
258
SetDataLevel(const DataLevel * dataLevel)259 int32_t SoftBusServerProxyFrame::SetDataLevel(const DataLevel *dataLevel)
260 {
261 (void)dataLevel;
262 return SOFTBUS_OK;
263 }
264
RegisterRangeCallbackForMsdp(const char * pkgName)265 int32_t SoftBusServerProxyFrame::RegisterRangeCallbackForMsdp(const char *pkgName)
266 {
267 (void)pkgName;
268 return SOFTBUS_OK;
269 }
270
UnregisterRangeCallbackForMsdp(const char * pkgName)271 int32_t SoftBusServerProxyFrame::UnregisterRangeCallbackForMsdp(const char *pkgName)
272 {
273 (void)pkgName;
274 return SOFTBUS_OK;
275 }
276
StartTimeSync(const char * pkgName,const char * targetNetworkId,int32_t accuracy,int32_t period)277 int32_t SoftBusServerProxyFrame::StartTimeSync(const char *pkgName, const char *targetNetworkId, int32_t accuracy,
278 int32_t period)
279 {
280 (void)pkgName;
281 (void)targetNetworkId;
282 (void)accuracy;
283 (void)period;
284 return SOFTBUS_OK;
285 }
286
StopTimeSync(const char * pkgName,const char * targetNetworkId)287 int32_t SoftBusServerProxyFrame::StopTimeSync(const char *pkgName, const char *targetNetworkId)
288 {
289 (void)pkgName;
290 (void)targetNetworkId;
291 return SOFTBUS_OK;
292 }
293
QosReport(int32_t channelId,int32_t chanType,int32_t appType,int32_t quality)294 int32_t SoftBusServerProxyFrame::QosReport(int32_t channelId, int32_t chanType, int32_t appType, int32_t quality)
295 {
296 (void)channelId;
297 (void)chanType;
298 (void)appType;
299 (void)quality;
300 return SOFTBUS_OK;
301 }
302
StreamStats(int32_t channelId,int32_t channelType,const StreamSendStats * data)303 int32_t SoftBusServerProxyFrame::StreamStats(int32_t channelId, int32_t channelType, const StreamSendStats *data)
304 {
305 (void)channelId;
306 (void)channelType;
307 (void)data;
308 return SOFTBUS_OK;
309 }
310
RippleStats(int32_t channelId,int32_t channelType,const TrafficStats * data)311 int32_t SoftBusServerProxyFrame::RippleStats(int32_t channelId, int32_t channelType, const TrafficStats *data)
312 {
313 (void)channelId;
314 (void)channelType;
315 (void)data;
316 return SOFTBUS_OK;
317 }
318
EvaluateQos(const char * peerNetworkId,TransDataType dataType,const QosTV * qos,uint32_t qosCount)319 int32_t SoftBusServerProxyFrame::EvaluateQos(const char *peerNetworkId, TransDataType dataType, const QosTV *qos,
320 uint32_t qosCount)
321 {
322 (void)peerNetworkId;
323 (void)dataType;
324 (void)qos;
325 (void)qosCount;
326 return SOFTBUS_OK;
327 }
328
ProcessInnerEvent(int32_t eventType,uint8_t * buf,uint32_t len)329 int32_t SoftBusServerProxyFrame::ProcessInnerEvent(int32_t eventType, uint8_t *buf, uint32_t len)
330 {
331 (void)eventType;
332 (void)buf;
333 (void)len;
334 return SOFTBUS_OK;
335 }
336
PrivilegeCloseChannel(uint64_t tokenId,int32_t pid,const char * peerNetworkId)337 int32_t SoftBusServerProxyFrame::PrivilegeCloseChannel(uint64_t tokenId, int32_t pid, const char *peerNetworkId)
338 {
339 (void)tokenId;
340 (void)pid;
341 (void)peerNetworkId;
342 return SOFTBUS_OK;
343 }
344 } // namespace OHOS